Commit Graph

163 Commits

Author SHA1 Message Date
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 384032b729 fix the “dramsey horizontal scrolling bug” – time for you to find another ☺ 2007-05-10 19:08:48 +00:00
tg 1a0b51b697 • arc4random, arc4random_push: use our own protos to check
XXX u_int32_t is not ISO C99, but seems to work well enough
  XXX if it fails anywhere, we'll see in the build logs
  XXX apple doesn't have the standard uint32_t and API doesn't specify it
• sys_siglist_defn: rename to sys_siglist_decl as we're really checking
  for the declaration in the headers; change wording to “check if … does
  not need to be declared” since we don't need to declare if we don't use
• scan for arc4random, arc4random_push, confstr declarations too
• sh.h: confstr declaration is no longer #ifdef __sun__; sort
2007-04-24 10:42:02 +00:00
tg 615a7794a6 AIX has sys_siglist[] but doesn't define it anywhere, so add a means to
scan for defns and use it here; bug reported by Kurt Telep
2007-04-23 20:37:16 +00:00
tg a823a03370 part of the AIX clean-up
with help of <Gurft> on freenode (Kurt)
2007-04-23 14:04:38 +00:00
tg 002904664e version bump here, too (CR-LF shebang) 2007-04-17 23:51:32 +00:00
tg 2785ce3de4 • (re)implement shebang execution file parsing; this makes the “and which
do not start with a "#!shell" sequence” part of mksh(1) true again; this
  was probably lost in mksh R21 or so when I decided/saw that our kernel
  always parses shebang lines (code written myself, not taken from pdksh
  again or MirBSD kernel, but verified against both)
• bom+shebang execution now works, no need setting EXECSHELL in the test
• bump version
2007-04-15 12:09:57 +00:00
tg 1692a6da66 ignore the UTF-8 Byte Order Mark at the beginning of the input (via a file
given to execute, standard input (interactive or not), via -c command line
argument, or after “eval”, but not for $(…) comsubs, at the beginning of a
subsequent line, or within a line, etc.); regression test for it

idea during my “week off” (despite the pain), bsiegert@ thinks it's good –
and utf-8 capable tools ought to be able to do this anyway
2007-04-15 10:45:59 +00:00
tg 7071cada42 • use wdcopy() not str_save() to duplicate an “encoded string”, whatever
• prevent out-of-bounds memory access, cought by glibc malloc on IA-64
2007-03-14 02:41:09 +00:00
tg 377dbe464a some gcc 4.1.2pre warning shutup 2007-03-10 18:16:28 +00:00
tg c61deaea27 remove unused utf_width(); bump vsn 2007-03-10 00:42:00 +00:00
tg e0e432347b Minix 3 has no S_ISSOCK (probably not even UNIX® domain sockets)
and lacks other things (rlimit stuff), so it won't make it today
2007-03-04 05:14:10 +00:00
tg 17d0fd1e23 more NSIG 2007-03-04 05:04:54 +00:00
tg 0a20bb8dd4 • Minix 3 doesn't have <sys/mman.h>
• Some OSes might need <stdint.h> for int32_t (Minix 3 with GCC)
2007-03-04 04:36:45 +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 ad05a2414b * edit.c: when tabcompleting a newline to backslash+newline, this
sequence is eaten before the command is called; cought by <TGEN>
  (Thomas E. Spanjaard) via IRC
  fix is to tabcomplete a newline to singlequote+newline+singlequote
* bump version
2007-02-16 17:46:42 +00:00
tg 665fba6dbf bump version 2007-02-07 02:31:06 +00:00
tg 8d696d001e if mksh_small don't even support -T instead of ignoring it 2007-01-26 18:27:34 +00:00
tg 6d157ffe47 autoscan for persistent history support 2007-01-18 16:05:05 +00:00
tg 7b903e4aa9 header overhaul: replace all #ifdef __OS__ with mirtoconf checks
(except the persistent history one)
2007-01-18 15:50:32 +00:00
tg 70a7e1527b oops, this must of course be a pointer 2007-01-18 01:03:10 +00:00
tg 65a86d2f67 bring back sig_t as void pointer in the rare case we
don't have sighandler_t or __sighandler_t either
2007-01-18 00:10:16 +00:00
tg ecc6beb7d5 scan for sig_t (and friends) 2007-01-17 23:54:39 +00:00
tg af606537e2 if we don't have rlim_t, assume it's long 2007-01-17 23:18:55 +00:00
tg 22ab30b556 Linux missing MAP_FAILED? 2007-01-17 23:10:14 +00:00
tg c3de1d7564 <sys/sysmacros.h> contains major/minor/makedev on Linux 2.0 2007-01-17 23:04:19 +00:00
tg ddd2dac47d * support old environments without libgen.h (ancient GNU/Linux)
and stdbool.h (ancient GNU/Linux; NetBSD® 1.6.1)
* __dead must come after, not before, to accomodate gcc 2.7.2.3
2007-01-17 22:51:47 +00:00
tg ceb5a7dba0 check if __RCSID() can be used multiple times; req'd eg. on Mac 2007-01-17 21:42:23 +00:00
tg 263f518dfd * Build.sh: add -fwrapv to standard CFLAGS, just to be on the safe
side (I don't have capacities to scan 71711 files in MirOS for a
  standards-compliance whack)
* copyright: mention CVS changelogs as place of contributors' name
  and credit information, too
* check.t, sh.h: bump
2007-01-17 01:24:29 +00:00
tg c480656076 shrink .data a little 2007-01-15 02:48:28 +00:00
tg 981a515287 bump vsn 2007-01-15 00:38:20 +00:00
tg 87f681b488 * revert some of the const-warning cleanup which must be done
with different means (reads, tricky magical kludgery)
  YES, THIS BREAKS -rHEAD, I KNOW.
* while here, fix spelling
2007-01-12 10:18:22 +00:00
tg 4867c8dcef pasto 2007-01-12 02:02:21 +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 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 e960fabf63 expand ~foo to getpwnam("foo")->dir only #if !defined(MKSH_SMALL)
this makes it possible to build a (small) mksh on glibc systems statically
2007-01-11 00:32:31 +00:00
tg b725114422 use RLIMIT_AS, after much RTFM 2007-01-06 18:48:27 +00:00
tg dbf5cdf632 * main.c: prevent segmentation faults on inferiour operating systems
such as Debian GNU/Linux "etch" 4.0 with not installed locale file
  corresponding to the current environmental settings. ばかたち!
2007-01-06 17:08:14 +00:00
tg 17a3fffc26 * main.c: when doing the conversion from strcasecmp (wrongly used)
to strcasestr, it was used in a wrong way (reverse logic error in
  checking its return value), turning to mis-detection of UTF-8 locale.
* sh.h, check.t: bump version
* copyright: bump year
2007-01-03 22:43:48 +00:00
tg 1f6ba50590 this is mksh, benzday edition (2006/12/07)
last code change was on 12/06
2006-12-11 16:09:49 +00:00
tg 15a0b1a021 catch up openbsd manpage changes: typos; from alf schlichting,
and revisit the RLIMIT_AS issue
2006-12-06 13:46:28 +00:00
tg 98e9111bbc remove the "set -o sh" option (dummy anyway),
"set +o emacs-usemeta" and "set -o vi-show8" which are always on now,
since we have proper internationalisation (i.e. utf-8) support, and
assume the user either has a 'C' locale and can't enter 8-bit chars,
his terminal is 8bit-transparent, or he has a 'UTF-8' locale.
2006-11-19 20:43:14 +00:00
tg c2e79abc08 make mksh compatible to the AT&T ksh spec which says, according to
twkm (from #ksh on freenode), that $RANDOM is always an unsigned
15-bit decimal integer.

(RANDOM << 15 | RANDOM) thusly yields 30 bit, which is still more
than 36^5, so we can use it on the baselife CD to speed things up
2006-11-19 16:43:43 +00:00
tg d3dea44bb5 whitespace fixes 2006-11-16 13:35:00 +00:00
tg 151d913115 remove all but these __CRAZY=Yes build warnings:
main.c: In function 'main':
 main.c:208: warning: cast discards qualifiers from pointer target type
 main.c:329: warning: cast discards qualifiers from pointer target type

no warnings at autoconf time left either; will take care of these two later
(might revisit changes from this commit), maybe change declararion for the
builtins to have their argv[] be const strings, and go through strict type
and qualifier checking again. this'll further improve stability.

XXX these changes might have introduced (more?) memory leaks,
XXX someone who knows about these tools should verify with
XXX automatic memory usage analysers (valgrind?)

still passes testsuite
2006-11-12 14:58:16 +00:00
tg 2c1ffced08 unbelievably, cygwin doesn't have strcasestr(3) 2006-11-12 13:15:27 +00:00
tg 62d9cf9fa9 only auto-enable set -o utf8-hack (set -U) for interactive shells 2006-11-12 10:44:42 +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