Commit Graph

79 Commits

Author SHA1 Message Date
tg 7463e5daa7 fix an oversight 2009-04-07 21:23:28 +00:00
tg 9e83002841 try to do some optimum struct packing except for struct env
(pointers, longs, size_t first; time_t next; int etc. then enum, bool)
2009-04-07 18:41:37 +00:00
tg 5e22cb486f <sys/file.h> is only required for, and only contains, flock(2) 2009-02-20 13:25:10 +00:00
tg 31d1499219 * back out almost all of the memory allocator related changes, as aalloc
was hard to type and hard to fix, galloc is also hard to fix, and some
  things I learned will probably improve things more but make me use the
  original form as base (especially for space savings)
* let sizeofN die though, remove even more casts
* optimise, polish
* regen Makefiles
* sprinkle a few /* CONSTCOND */ while here
2008-12-13 17:02:18 +00:00
tg 4d3fc2413e switch to a (nmemb,size) API from a (nmemb*size) API
cost: text += (308, 256, 4, -100)
2008-11-12 00:54:52 +00:00
tg 65b1923b61 build warning-free with LLVM+Clang on MirBSD itself
$ (CCC_LD=mgcc CC=ccc sh Build.sh -r && ./test.sh -v) 2>&1 | tee log
Total failed: 2 (as expected)
Total passed: 278

Just the result is huge, and we could of course build to intermediate
byte code to optimise globally…
2008-11-09 20:32:18 +00:00
tg 88d7b7d08b • rewrite code to no longer use statements-as-expressions
• optimise a little
• Build.sh: remove HAVE_EXPSTMT test
• Build.sh, */Makefile: sort tests, regenerate
• mksh.hts: sync clog
2008-10-28 14:32:43 +00:00
tg 7daf3f0b59 fix a warning
From: Elias Pipping <elias@pipping.org>
2008-10-14 19:48:27 +00:00
tg c11187f993 fix some of the things scan-build[1] found (but not some false positives)
10x

From: Elias Pipping <elias@pipping.org>
[1] http://clang.llvm.org/StaticAnalysis.html
2008-10-13 23:06:04 +00:00
tg 9cd963ea45 • check.t: change history-e-minus-5 regression test to avoid false failure
caused by ignoredups history control
• histrap.c: enable ignoredups after fc -s editing too
2008-09-30 19:36:16 +00:00
tg 13231b50eb ignore more dups 2008-09-30 19:25:51 +00:00
tg f53a8196e4 däs isch ei buul, koa int… 2008-09-30 17:49:26 +00:00
tg e95a79e31c even simpler *and* const clean 2008-07-12 17:16:03 +00:00
tg 0b4f34e0a8 • syn.c: replace expanded use of str_save() with the actual macro
• others: fix 6 (!) cases of non-constant or side-effect arguments
  to the str_save() or str_nsave() macros, and other abuse of them
• also fix some cosmetics and other un-nice code while here
2008-07-12 16:56:40 +00:00
tg d415592b37 check return value of unlink(2) when trying to remove an existing HISTFILE,
since mksh(1) did go into an infinite loop if that fails first

bug spotted, initial patch and help drafting a test case
From: Decklin Foster <decklin@red-bean.com>

note there are more instances of unlink(2) and others (like chmod(2), as
spotted by flawfinder) which aren’t checked… but at least the other case
of unlink(2) use in histrap.c doesn’t cause any trouble (I think)
2008-07-06 22:41:09 +00:00
tg 419600db62 fix the RCS IDs 2008-06-08 17:16:25 +00:00
tg 399157adcc cast two pointer arithmetics to ptrdiff_t
commit inspired by fgsch:
> Log message:
> cast pointer arithmetic to unsigned so we can behave correctly on
> underflows. fixes fc -l 1 in my box where line is 1667511151.
> krw@ ok.

  to signed rather. oops.
2008-06-08 17:14:31 +00:00
tg f17b8b1c8b • alloc() can’t fail, afree() can take NULL
‣ macro afreechk() is superfluous
• get rid of macro afreechv() by re-doing the “don’t leak that much” code
• some KNF (mostly, whitespace and 80c) while here
2008-05-17 18:47:03 +00:00
tg 7ddf56dbbc • new ksh_mbswidth
• fix: when printing menus (tab expansion, for instance), honour width of
  the multibyte characters printed
• some int→bool while here
2008-04-19 17:21:55 +00:00
tg acc2e9a67a • Ultrix doesn’t define MAP_FAILED either
• on Ultrix, mmap() returns a caddr_t instead of a void*, so cast
2008-04-02 16:55:06 +00:00
tg 351104715e ignore failure to define MAP_FILE 2008-03-27 17:59:28 +00:00
tg 94158b2326 shut up gcc-lib/alpha-dec-osf4.0d/2.8.1 2008-03-05 16:54:21 +00:00
tg 5e02cce898 optimise more :) 2007-10-25 15:34:30 +00:00
tg ccb41ecb4d shut up some gcc warn_unused_result thingies from Fedora 2007-09-09 19:12:10 +00:00
tg 6b9c277fbc shut up tcc 2007-08-20 14:12:29 +00:00
tg 809c1446b2 some steps towards building with tcc 2007-07-31 10:42:15 +00:00
tg b09b3621e2 • we had an unused variable leftover
• make warning-free for both gcc and xlC
2007-07-22 14:01:50 +00:00
tg 979406bba7 • support IBM xlC on AIX
• fix all bugs it could find ☺
2007-07-22 13:34:52 +00:00
tg 2e42fa62b6 Borland C++ found these 2007-07-01 21:10:29 +00:00
tg 9f61aea3de fix mmap args and retval (cosmetic) 2007-07-01 17:13:52 +00:00
tg 3dcf22a319 ok, icc _did_ track down a few ones, and I fixed errno abuse a little too
however, bad S/N ratio

side effect bonus: smaller code size now
2007-06-06 23:28:17 +00:00
tg 91431e4cf6 with this, we don't need the special list of pre-known signal names
any more either, and can make use of code sharing between detection
of sys_siglist and sys_signame (and the underscored variants); nuke
the now-useless signames.c file too (merge struct into histrap.c)
2007-06-05 21:47:49 +00:00
tg 1e93f97b8c compile warning-free on SUNpro (regression test suite pass) for MirBSD 2007-06-04 21:33:28 +00:00
tg 0989f7da67 Fix for Coverity CID#2: false bug, but still a problem.
Analysis:
internal_errorf(int, fmt, ...) was only a __dead function if the int argument
was non-0, which the Prevent probably was unable to follow. Change all uses of
internal_errorf(0, fmt, ...) to internal_warningf(fmt, ...); change the pro-
totype of internal_errorf() to internal_errorf(fmt, ...) and all remaining
uses remove the non-0 int argument; add __dead to internal_errorf() proto;
flesh out guts of internal_errorf() and internal_warningf() into a new local
function for optimisation purposes.

Some whitespace cleanup and dead code removal (return after internal_errorf(1))
2007-05-13 17:51:24 +00:00
tg 83c2ee87f4 • remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
  that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
  only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
  to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version

¹) side effect from creating API-correct cstrchr, cstrstr, etc.
   uses goto so it must be better ☻

tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 03:04:28 +00:00
tg 62b347a1b0 merge the const branch +- a few 2007-03-04 00:13:17 +00:00
tg e31b852abc mirtoconf the checks if to use persistent history support 2007-03-03 21:36:08 +00:00
tg 67a28c4c3f typo, prevents compilation under Interix (has _sys_signame[] array) 2007-02-27 15:03:28 +00:00
tg bca0f4d603 * Build.sh, histrap.c: prevent testing of strsignal() if we have sys_siglist[]
* mksh.1: .Nm is never used with "" as argument, fixes GNU groff 1.15
2007-01-17 23:47:15 +00:00
tg c480656076 shrink .data a little 2007-01-15 02:48:28 +00:00
tg 0b7376a1ad * histrap.c: picky /a1/sw/pkgs/gcc-3.4.3/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.3/
* main.c: thinko
2007-01-12 02:06:34 +00:00
tg 5891915f1b * Scan for __attribute__((...)) in general (the earliest was 2.5,
where we had 'noreturn' etc. but no '__noreturn__')
* Scan for __attribute__((bounded)) and __attribute__((used))
  if we have __attribute__((noreturn))
* To be able to scan if certain attributes give warnings,
  scan for -Werror with a simple programme which hopefully triggers none
* Convert __attribute__((unused)) to __unused, noreturn -> __dead
* Unify other attributes
* Clean up typography a little more
2007-01-12 01:49:29 +00:00
tg c430db0b00 constify 2007-01-12 01:30:35 +00:00
tg 0e4bbd4bf6 * inittraps: convert signal _names_ to uppercase, we're matching
case-sensitively in the 'trap' builtin, and Mac OSX has them
  in lowercase at sys_signame[]…
* gettraps: optimise
2007-01-12 00:37:09 +00:00
tg 2f15a11c55 Clean up the signal mess, saves 172 Bytes:
* 'sigseen' in Build.sh goes away
* Signal name existence is checked in this order:
  have our own¹ -> sys_signame[] -> _sys_signame[] -> build our own²
* Signal description existence is checked in this order:
  sys_siglist[] -> _sys_siglist[] -> strsignal() -> NULL³
¹ Predefined list of items, for operating systems where we
  cannot build² them, i.e. Plan 9 and Minix 3 (e.g. no $CPP -dD)
² The usual cpp(1) stuff
³ Changed later, see below
* Make $CPP test dependent on $NEED_MKSH_SIGNAME (others can
  be added here, this is not absolute)
* Make signal name list generation² dependent on $NEED_MKSH_SIGNAME
* Fix check if the generation worked
* Guarantee that sigtraps[*].name and sigtraps[*].mess are valid
  C strings; this makes the code shorter *and* removes a few pos-
  sible nil pointer dereferences
* Embed autoconf'd usages of sys_sig* / strsignal / mksh_sigpairs
  into inittraps()
* Check for each signal 0<=i<=NSIG that
  name is not NULL or "" -> replace with ("%d", i)
  mess is not NULL or "" -> replace with ("Signal %d", i)
  name does not start (case-insensitive) with "SIG" -> name += 3
* In gettrap(), fix check if signal name starts, case-sensitive
  or case-insensitive, depending on need, with "SIG" (bug from millert@)

Other changes:
* Build.sh: ac_test[n]() are documented
* Build.sh: ac_test[n]() can have negative prereqs as well now
* Build.sh: use <<-'EOF' consistently
* bump patchlevel to today
2007-01-12 00:25:40 +00:00
tg 5b525d79fb format string warnings, courtesy of Interix 3.5 2006-11-12 12:49:25 +00:00
tg 56ffbf7e70 hand-sorted ctypes/chtypes upgrade; use table-driven where they make
sense and preprocessored otherwise; unify the logic
saves 144t 1i and lots of cpp(1) time, as well as improves readability
2006-11-10 07:52:04 +00:00
tg ca2b1d88ca kill two others, saves 55t 8d 2i 2006-11-10 06:40:05 +00:00
tg 493ad928e3 if MKSH_SMALL, disable persistent history code as well (like on Solaris,
where it can't work anyway), and fix that code to shrink
saves 2071t 20d 5i
2006-11-10 05:23:14 +00:00
tg 208c45da25 more cleanup; incidentally, replacing libc function with syscall maybe speedup
9t 4d 1i
2006-11-10 04:22:13 +00:00