Commit Graph

64 Commits

Author SHA1 Message Date
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 9b62cf15bf • more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
  at non-interactive startup, enabled at interactive startup, if the
  current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
  change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
  sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
  ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
  or do the same as print \x## or \u#### (depending on the utf8-hack flag),
  plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
  (print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
  base-0 numbers which I had planned to use for raw octets first, as they are
  used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +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 954352cae3 some more code “folding”
should decrease size
2008-04-01 22:20:20 +00:00
tg e8d61a1d99 • unify ksh_dup2() usage, use bool where appropriate
• apply diff from mirbsdksh-1.11:
  #ifdef DUP2_BROKEN
  /* Ultrix systems like to preserve the close-on-exec flag */
  ‣ XXX we do #ifdef __ultrix here (imake-style) instead of mirtoconfing it
    (but does anyone know of any other OS with the same problem? plus we’d
    see it as we now know the symptoms)
• remove ultrix Build.hs warn=' but might work…' in the hope it DOES
2008-04-01 20:40:22 +00:00
tg 84e78bcfb6 clean up 2007-10-25 13:27:00 +00:00
tg c1c939e340 • fix memory leaks found by coverity
from netbsd via oksh
  we had the NULL pointer deref already fixed
• avoid a bogus not-setting the return value of edit.c:x_file_glob()
  introduced by the above change in oksh
• escape ? as well (but not ] because that’s wrong)
  reminded by cbiere@netbsd via oksh
• Unsetting a non-existent variable is not an error. See
  http://www.opengroup.org/onlinepubs/009695399/utilities/unset.html
  report from Arkadiusz Miskiewicz; fixed based on
  http://cvs.pld-linux.org diff via oksh but modified slightly
• Be more smart waiting for input for non-interactive scripts.  Fix
  based on a diff from debian:  see their bug#296446 (via oksh)
  modified slightly
  this also fixes cnuke@’s “mksh busy loop” problem, for which I never
  received a bug report, but the Debian bug page contains a set of two
  scripts to reproduce this before (and no longer after) this commit
• some KNF
• bump version
2007-09-09 18:06:42 +00:00
tg e37577de42 fix another errexit bug: unwind() is __dead, so the pseudo-signal was never
delivered to the process
• regression test by Clint Pachl, verified against Debian ksh93 by me
• place to fix it in the code discovered by Otto Moerbeek
2007-07-24 11:22:04 +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 cf5fc9eac2 some null/NUL 2007-07-22 13:38:26 +00:00
tg 979406bba7 • support IBM xlC on AIX
• fix all bugs it could find ☺
2007-07-22 13:34:52 +00:00
tg f280b66d0a make sure ELF, a.out, COFF, MZ/PE and gzip binaries aren't executed via sh
should save us some error messages
2007-06-15 21:22:40 +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 a3e012c69b dead code removal 2007-05-13 18:49:00 +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 0dba495c4b • MKSH_SMALL users want to trade off size vs functionality,
they thusly don't deserve shebang processing
• fix a comment (spelling; technical correctness)
2007-04-18 00:59:20 +00:00
tg 12b2011a96 also accept a carriage return as end of shebang line;
helps to at least not get messages like
| sysop@odem2k:~/mb $ ./foo.sh
| : No such file or directory
| 127|sysop@odem2k:~/mb $ _
if you forgot to convert CR-LF into LF (of course only if the
kernel fails with ENOEXEC – an ENOENT would not help in these
cases), but of course other things will fail
2007-04-17 21:26:34 +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 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 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 a712de8e63 ok, -rHEAD shall be unbroken 2007-01-15 00:18:47 +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 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 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 a1ff719ba4 thanks to the nice property of my reimplementation of getn to also
return a value in case of an error (0 or the partial result, which
is the full result in case of trailing junk even), using it to rid
atoi() is possible, saving 9t 4d 1i
2006-11-10 04:03:59 +00:00
tg c60dbdc6cb * change EXECSHELL to /bin/sh (we can override it via environment anyway,
and this is a sensible choice instead of ourselves)
* move this stuff from sh.h into exec.c where it belongs
* simplify set -o stuff

saves 8 bytes
2006-11-10 01:44:40 +00:00
tg 5e619e1ef3 style(9) 2006-08-01 13:43:28 +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 f38d8299f9 Change interpretation of '\"' in here documents with substitution
according to SUSv3 and other modern shells (POSIX allows both).
Idea for the patch (add another lex state) from OpenBSD, but the
implementation differs slightly (and is better in quality).

Also add two testcases (/bin/sh passes both, old mksh only one),
and document the change in the manual page. Sync RCS IDs with OBSD.
2005-11-22 18:36:20 +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 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 3506838417 undo fix for Debian PR #71256 which turned to be bogus and break make(1) 2005-07-07 22:00:45 +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 84dcd241c1 the new pdksh maintainer's patch is bogus
he didn't even run the testsuite

now, in not-rv_pass mode, traps are still executed
XXX look where this could break
2005-05-25 14:07:29 +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 d0ce928ea8 new upstream patch ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14-patches.2
from maintainer via Debian PR #71256
2005-05-25 11:31:15 +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
tg cd7b8bd79b Add mirbsdksh R21, which was developed in a temporary external CVS repo-
sitory whose ChangeLog follows. mksh R21 is licenced under the MirOS li-
cence, shown in "sh.h", and a two-clause UCB-style licence by Marc Espie
as shown in "alloc.c".

This executable is a fair bit smaller and shorter than our /bin/ksh that
it is designed to eventually replace (as /bin/sh hardlink), with the old
/bin/ksh to completely vanish. It is still in beta testing though, and I
don't think it will compile on other operating systems.

mksh R21 is a completely new port, bringing together the OpenBSD-current
/bin/ksh, the MirOS-current /bin/ksh and the older mksh R20 (which still
was portable, ocvs-based).
2005-05-23 03:06:10 +00:00
tg d8d708aa45 * un-hook bin/ksh, usr.bin/xmlwf and lib/libexpat from the build
- expat as discussed with bsiegert@ today on the phone
  - ksh as announced earlier on the lists
* un-hook lib/libexpat from make includes
* remove /usr/include/{,open}ssl upgrade workaround from includes/Makefile
* nuke old bin/ksh
* nuke libexpat and xmlwf
2005-10-21 11:33:15 +00:00
tg a90702a5a1 Initial revision 2005-03-06 15:42:55 +00:00
tg 1a183984c4 Replace fd_clexec() with calls to fcntl(fd, F_SETFD, FD_CLOEXEC)
From: Todd C. Miller <millert@cvs.openbsd.org>
2004-12-31 17:42:45 +00:00
tg e824f36ff0 catch up with diffs/fixed we already had
From: Otto Moerbeek <otto@cvs.openbsd.org>
2004-12-28 22:40:40 +00:00
tg 0114af375d Use stdbool.h instead of rolling our own bools.
From: Todd C. Miller <millert@cvs.openbsd.org>

XXX #ifndef HAVE_STDBOOL_H ?
2004-12-28 22:32:09 +00:00
tg d5ff21ea1d (anything *)0 -> NULL 2004-12-18 19:22:30 +00:00