Commit Graph

52 Commits

Author SHA1 Message Date
tg e392983af7 Possible fix for Coverity CID#7:
convert options() prototype to unsigned (size_t, in fact), and make an
explicitly casted (size_t)-1 the error return code, modelled after what
is often used in Unix libraries
2007-05-13 18:33:29 +00:00
tg 3daaf229ca Fix for Coverity CID #6 (null pointer dereference in error path) 2007-05-13 18:15:25 +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 377dbe464a some gcc 4.1.2pre warning shutup 2007-03-10 18:16:28 +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 ffc0a2e438 add c_mknod() if MKSH_NEED_MKNOD even if MKSH_SMALL 2007-01-26 18:37:26 +00:00
tg a712de8e63 ok, -rHEAD shall be unbroken 2007-01-15 00:18:47 +00:00
tg 84085a8747 solaris 8 / gcc 3.4.3 / -m64 warnings 2007-01-14 23:57:44 +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 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 6775d79b2a Revision [7]1.16 / ([8]download) - [9]annotate - [10][select for
diffs] , Mon Nov 20 21:53:39 2006 UTC (2 weeks, 1 day ago) by miod
Compute user-given ulimit value times ulimit unit as an rlim_t value, not a
long value; catches some 32 bit overflows on 32 bit platforms.

Found by drahn@, ok otto@
2006-12-06 13:41:23 +00:00
tg 8a4b64fde3 fix 'typeset -p' to act according to TFM and ksh93 2006-11-19 17:13:36 +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 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 35b30679c7 since so many internal things hardcode 'C' locale anyway,
use own is{digit,lower,upper} macros that go via byte ranges

doesn't affect utf-8 hack because these only operate on single bytes anyway
saves 224t
2006-11-10 06:53:27 +00:00
tg 2342fa1242 don't use setreuid(2) etc. stuff, like OpenBSD
only affects suid shell scripts, which are *ugh* anyway,
and I really have no idea what the old code did, when, why, etc.
262t 16d 2i
2006-11-10 06:16:25 +00:00
tg d10dd31b9a correct a few protos and comments
saves 4 .text bytes and my nerves
2006-11-10 03:45:57 +00:00
tg 6334091d86 omit usage msg if small 2006-11-09 23:19:52 +00:00
tg 3c33cbcecc don't compile mknod(1) builtin if MKSH_SMALL
saves 1037 text, 20 data (on i386)
2006-11-09 22:18:10 +00:00
tg c81966621a merge non-Plan9-specific stuff from the branch, add KNF, etc. 2006-08-24 20:32:53 +00:00
tg 5e619e1ef3 style(9) 2006-08-01 13:43:28 +00:00
tg bc93d1c90d fix the "char subscripts" issue, bump version 2006-07-03 12:16:31 +00:00
tg 7672b9b346 apply some fixes from OpenBSD and don't apply some others
but sync RCS IDs for easier future adaption:
* Simplify savefd() by removing the "noclose" flag and make noclose
  behavior the default. Almost all uses of savefd() are followed
  by an implicit or explicit close.
* fix typos
* might as well make ksh_getopt() match real getopt(), ie. get rid of that
  stupid EOF concept that was never true. adobriyan@gmail
* use SEEK_* for lseek()
* fix lint comments, no functional changes
* remove excessive optimization; from adobriyan@gmail
* only santa checks things twice; from adobriyan@gmail
* Interpret zero-filled numbers as decimal; PR 4213; from Alexey Dobriyan
2006-05-10 18:54:13 +00:00
tg 3f2912d717 * update to mksh R26c
* there is no comma in front of "which" in English, I was taught
2006-01-30 12:37:24 +00:00
tg 94ee3b388a sync with OpenBSD: remove unused code and vars; name clash with libc
compiles under MirBSD
2006-01-29 20:04:54 +00:00
tg 95cfad6339 * only have one $MirOS RCS ID per file to shrink source size
(this is an exception from normal use)
* bump to R26
2005-11-22 18:40:44 +00:00
tg 9b97d72d5e * move _all_ #include stuff into sh.h
* sort out #include stuff which isn't necessary on MirOS into compat.h
2005-10-25 19:53:29 +00:00
tg 181463f990 another Slowlaris speciality... 2005-10-25 19:35:14 +00:00
tg 2f9687c58a follow OpenBSD and add mknod as mksh builtin (mknod <file> p acts as mkfifo)
but write a good chunk of that code myself (better structured, better error
handling, more gotos, less function calls, int -> bool)

passes all tests on mirbsd; this will become mksh R25 once tested on other
supported OSes
2005-10-21 12:41:56 +00:00
tg 0b85dc1e81 remove USE_PRINTF hooks, it never worked anyway, and probably nobody
is going to fix it...
2005-10-21 11:44:25 +00:00
tg 7ee8296628 our test(1) promises we can do string1 < string2, and
our /bin/test uses mksh... so we pee (literally) on
POSIX and don't accept < and > only for [[ ... ]] operator
2005-10-08 19:31:00 +00:00
tg 6c985b8b81 fix uber-pedantic Apple GCC 4 2005-09-12 19:28:18 +00:00
tg 6c5d08ea6f * add printf(1) as mksh(1) builtin on MirOS
(or, more general, all systems using Makefile
  instead of Build.sh)
* document this fact
2005-08-26 22:03:56 +00:00
tg 049c867c7d follow style(9) ;) 2005-08-21 12:52:29 +00:00
tg fb64668227 remove Korn's bizarre /dev/fd hack
(only affects Interix!)

Tests on /dev/fd are now officially unsupported in mksh too.
2005-07-06 00:02:06 +00:00
tg 76c700b3a6 get rid of $PGRP
get rid of special bourne-shell emulating mode
2005-07-04 12:34:24 +00:00
tg e392a30930 get rid of special "POSIX"ish mode 2005-07-04 12:27:28 +00:00
tg 430fb8edab missing piece 2005-06-24 15:40:38 +00:00
tg cdb2beb29b Interix defines RLIMIT_VMEM to RLIMIT_AS, no need for us to act (sigh) 2005-06-08 10:25:40 +00:00
tg 50b9b9181b use RLIMIT_AS if RLIMIT_VMEM is not available
they roughly equal each other anyway
2005-06-08 10:14:09 +00:00
tg cd54ef8f51 * fix emacs [ tabcompletion bug
XXX it's probably a bug in vi mode too, it just doesn't show
* bring manual page and reality into closer sync'd state
* sort ulimits
2005-05-25 23:31:08 +00:00
tg d7c3f0a066 make setuid/setgid scripts and access() work again
by reverting some OpenBSD and applying some Debian diff
2005-05-25 13:46:02 +00:00
tg ba859c9ab1 make mksh -exc 'eval false || true'; echo $? echo 0 not 1
From Debian bug #269067
2005-05-25 09:39:49 +00:00
tg e3cfc9261a * add RLIMIT_LOCKS from Debian pdksh diff
* unify ifdef and spacing of all RLIMITs
2005-05-25 09:18:16 +00:00
tg dc5614a091 missing preprocessor defines on Solaris 2005-05-23 15:24:43 +00:00
tg c0d3fd1ef7 -Wformat catched on solaris 2005-05-23 15:23:12 +00:00
tg b8a06e0fbe * Solaris misses sig_t
* our gmatch becomes gmatchx, it's extended against sh(C)
2005-05-23 15:18:17 +00:00