Commit Graph

377 Commits

Author SHA1 Message Date
tg 0c2de1902c • change mksh to only then behave more POSuXish when called as /bin/sh or
“-sh” if -DMKSH_BINSHREDUCED was passed during compilation, for example
  for Debian, but d̲e̲f̲i̲n̲i̲t̲i̲v̲e̲l̲y̲ n̲̲o̲̲t̲̲ for MirBSD™
• split up regression test to force this behaviour
• remove the gunk from our MirBSD™ startup scripts again
• mention arc4random.c changes on website, sync clog, warn packagers
2008-10-20 19:29:25 +00:00
tg 2fc9fb99d7 when doing a history search (^R), restore old input line on
abortion (^G – ^C is SIGINT and doesn’t work like this, but
that’s actually good IMO)

prompted by enquiry about the Emacs editing mode by <smultron:#MidnightBSD>
2008-10-19 20:15:45 +00:00
tg 9be489ea90 use less stack storage, prefer .bss storage (saves us a memset() call)
and .data instead of another initialisation; this was prompted by a bug
in scan-build (the value can never be NULL, but it doesn’t realise it),
although this doesn’t fix it, but less stack usage is always good
2008-10-15 10:25:01 +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 37934a07cf fix prodded by cnuke@ for AIX with IBM xlC 7.0:
fool the compiler into not doing static bounds checking when we do
one-past-the-array-boundary pointer assignments for cases where the
only accesses are like (*--pointer); bump version
2008-10-10 21:30:43 +00:00
tg 5d9e4c9e16 unbreak MKSH_SMALL after x_histp related changes 2008-10-05 16:06:43 +00:00
tg 27ee1866fe implement Message-ID: <20081004171903.GA14184@boetes.org>
in a somewhat hackish way, and it’s still quite different from zsh,
but probably closer to a desired functionality

XXX this makes state by abusing 「modified」 and 「xmp」 (“the mark”).
2008-10-04 23:08:04 +00:00
tg 13231b50eb ignore more dups 2008-09-30 19:25:51 +00:00
tg b24dc6e725 add regression tests, sync manpage, bump version number 2008-09-30 18:43:07 +00:00
tg f53a8196e4 däs isch ei buul, koa int… 2008-09-30 17:49:26 +00:00
tg b65a7f7f9e bump mksh patchlevel for today’s sorta-tested half-done changes, with more
to follow (see <Pine.BSM.4.64L.0809201417560.22066@herc.mirbsd.org>), as I
probably am not going to hack any more tonight
2008-09-20 19:18:00 +00:00
tg 8a853f24be • bring back automatic turn-on of FPOSIX if called as sh/-sh
‣ only if !MKSH_SMALL
  ‣ add appropriate regression test
• if FPOSIX is set, do not close fds > 2 on exec, Debian #499139
• add appropriate regression tests for keeping fds private or not
2008-09-17 19:31:30 +00:00
tg 977237ad14 • merge vi_reset() and edit_reset() into x_vi() to allow for following:
• fix vi mode (which, however, is officially orphaned) multi-line $PS1 by
  using a similar algorithm for prompt skipping as emacs mode (changing
  the meaning of prompt_trunc variable and using prompt_redraw, just even
  more efficiently than vi mode); reported by asarch via IRC
• fix multi-line prompts if last line is “too large” by using emacs mode
  algorithm of just internally appending a newline, while here ☺ this even
  saves us having to re-add the prompt_skip variable…

WARNING: this is only barely tested, as almost nobody ever uses vi mode
⇒ test yourself, there may be bugs (e.g. off-by-ones); already known is
  that the vi input line editing mode is NOT multibyte safe…
2008-09-14 20:24:59 +00:00
tg 9ab67aa02f • merge final version of the stack-free diff as committed by jaredy@openbsd
thanks for helping with the bug
• merge RCS IDs
• bump mksh version
2008-08-02 17:45:12 +00:00
tg 68e028ea4b fixes for constant conditionals, from gcc-4.2 fat binary building 2008-07-18 11:33:13 +00:00
tg 5f0269ed9a fix attempt to free pointer to stack (function-local storage)
discovered by Elias Pipping
patch by Jared Yanovich
alloc/afree checker by Todd C. Miller
2008-07-14 12:29:06 +00:00
tg f47d20bc85 bump version 2008-07-12 18:09:37 +00:00
tg 06b83a8df8 600 bytes more for the small version aren't worth it; it looks
as if there are not many NULL pointers to be optimised away
2008-07-12 17:47:21 +00:00
tg b6236be77a further optimisation attempts in the str_save() and str_nsave() area 2008-07-12 17:23:00 +00:00
tg 99ccfb4024 bump versions (since we lowered the fd limit again) 2008-07-10 21:55:08 +00:00
tg 0b4e9918ba limit fd usage – at least ULTRIX doesn’t cope 2008-07-10 18:48:02 +00:00
tg ca7cd043db • bump NUFILE and FDBASE, allowing for more than 10 fds used by scripts
• change the code to accept more than a single digit for an fd
2008-07-09 21:32:45 +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 c77d67ef4d • add code to support GNU bash’s “&> file” I/O redirection extension,
and make it fit into mksh’s model (also gives us a couple of things
  GNU bash doesn’t have
• add regression tests for all of these

Lukas “smultron” Upton from MidnightBSD spotted a script with /bin/sh
shebang invalidly using “&>” in some Apple backup toolkit, 10x

XXX why fds are limited to one digit?
2008-06-28 22:51:56 +00:00
tg 18bbd23397 • more usage fixes, inspired by sobrado
• bump mksh patchlevel
2008-06-08 17:15:30 +00:00
tg 6eea28c1f3 I’m sorta shocked… 2008-05-17 20:10:52 +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 b41a72ac2e add new builtin “realpath” calling realpath(3) on its argument, skipping
over “--” for compatibility to Debian realpath(1) and possibly busybox’

“sounds handy” replaced@TNF
2008-05-17 18:27:57 +00:00
tg 6be5205b36 mksh:
* initialise the integers PPID, OPTIND, RANDOM, SECONDS, and TMOUT to base-10
* bring back PGRP as base-10 integer to the process group via getpgrp(2)
* initialise USER_ID as base-10 integer to the effective user id as retrieved
  from geteuid(2) = $(id -u)
* use $USER_ID in dot.mkshrc instead of spawning an id(1) process
  -> dot.mkshrc,v 1.34 now requires mksh R34
* convert more int to bool where appropriate
* remove dead code - getpgrp(2) cannot fail
* sync manual page to reality
* bump to mksh R34(beta) - feature freeze

XXX check if our_pgrp in jobs.c is still really needed, the setpgid call
XXX probably just makes us our own pgrp leader, and we might have to use
XXX and update kshpgrp accordingly - need feedback/help here but I think
XXX this simplification should be possible if I grok the code correctly.

etc/profile:
* adjust to $USER_ID changes in mksh (speed-up here, too)

mksh.hts:
* sync changelog
2008-05-15 15:24:11 +00:00
tg 604ec0ff6c remove dead code and ifdefs, speed up configuring 2008-05-04 01:51:31 +00:00
tg 4230cf91de thinko: multibyte characters are not always 1 column wide 2008-05-02 18:55:37 +00:00
tg 1ed64c3e26 bump 2008-04-22 19:00:41 +00:00
tg a3dab099d9 sh.h can provide its rcsid itself, no need for that ugly hack 2008-04-22 18:57:26 +00:00
tg 5fb55148a1 merge the fix for that segfault 2008-04-20 01:41:57 +00:00
tg 309c674ed7 mostly revert 100480A853206FB56FA and parse utf-8 lead bytes ourselves 2008-04-20 00:24:26 +00:00
tg e20694eceb utf-8 function overhaul (size optimisation)
XXX maybe we can get more out of this?
2008-04-20 00:03:50 +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 6c6be2a87e _careful_ (feature) sync with oksh:
(3 weeks, 5 days ago) by millert
Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do.  Requested by espie@, OK deraadt@
2008-04-16 21:56:03 +00:00
tg fc607a6c1b SECURITY fix: when spawning mksh on a new terminal (tty, not /dev/null),
flush all of its I/O first – someone could have written on it beforehand
2008-04-11 19:55:24 +00:00
tg afaa3ffa59 move some portability stuff required only for setmode.c into that
(XXX we somehow do need a sorta libbsd…)
2008-04-06 23:27:19 +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 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 2f0c894290 • fix one more of the enum arithmetics complaints
• split Xinit into XinitN and Xinit macro, the former
  not initialising the “xp” argument of the latter,
  and use this to get rid of two variables that are
  only assigned but never referenced (gcc doesn’t see
  this, but MIPSpro and IIRC SUNWcc do)
• re-indent while here
• bump patchlevel
2008-03-28 13:46:53 +00:00
tg def9c172df • Add support for Ultrix 4.5 and ucode cc (?)
‣ I/O redirection seems broken:
    $ (date; date >/dev/null; date) | wc -l
    1 (expected: 2)
  ‣ other than that: working fine
  ‣ -YBSD (default) and -YSYSTEM_FIVE don’t work, just -YPOSIX, somehow
• Fix $(…) to `…` for OSF/1 V2.0 /bin/sh
  ‣ this compiler is FUBAR though:
	$ cat >t.c
	main() { return (foo()); }
	$ cc t.c
	ld:
	Unresolved :
	foo
	$ echo $?
	0
	$ ls -l a.out
	-rwxr-xr-x   1 mirbsd   users      10835 Jul 21 17:12 a.out
  ‣ it seems to have ucode, but man is not installed
• new mirtoconf check: mkstemp(3)
• if !HAVE_MKSTEMP (Ultrix), use tempnam(3)
• only use printf(1) if it exists (it doesn’t on Ultrix)
• a few more signals
• add S_ISLNK if the OS doesn’t define it
• add strcasecmp(3) proto for Ultrix (it _is_ in <portability.h>, but
  only for -YBSD I think)
• fgrep(1) on Ultrix doesn’t do “-e ① -e ②”

10x DEChengst:#UnixNL for giving access
2008-03-25 21:34:45 +00:00
tg 83b8798da3 support dæmonisation in mksh, for example
|	csh -cf '/command/svscanboot &'
and
|	/usr/mpkg/bin/pgrphack /usr/mpkg/bin/svscanboot &
can now be replaced with
|	/bin/mksh -T- /usr/mpkg/bin/svscanboot
2008-03-23 22:09:59 +00:00
tg 26ba2854a2 support BSD/OS 3.1 with gcc2, 10x replaced@tnf
except MAP_FAILED not being defined, no issues
2008-03-23 20:55:18 +00:00
tg 845f6f0d64 • check for flock decl too (weird on OSF/1: if !POSIX and BSD)
• un-experimental Tru64
2008-03-05 18:49:15 +00:00
tg 0e6df4736a • now this builds fine on DEChengst’s Tru64 box:
| OSF1 rubbereendje.dechengst.nl V5.1 2650 alpha
  with the vendor compiler:
  | Compaq C V6.5-011 on HP Tru64 UNIX V5.1B (Rev. 2650)
  | Compiler Driver V6.5-003 (sys) cc Driver
• the platform’s sig_t is incompatible too (simplify check)
• no compile warnings at all
• results in:
  $ size mksh
  | text    data    bss     dec     hex
  | 327680  16384   17808   361872  58590
  $ file mksh
  | mksh:   COFF format alpha dynamically linked, demand paged executable or object module not stripped - version 3.13-14
  $ ldd mksh
  |
  |         Main  =>   mksh
  |         libc.so  =>   /usr/shlib/libc.so
  $ ls -l mksh
  | -rwxr-xr-x   1 mirbsd   users     395200 Mar  5 19:18 mksh
• minor testsuite issues:
  FAIL ./check.t:regression-13
        unexpected stderr - got too much output
        wanted nothing
        got:
                Successful
                cat: output error
  ⇒ probably harmless
• works like a charm!
2008-03-05 18:21:45 +00:00
tg 3d9bd0e1f0 OSF/1 doesn’t seem to declare revoke(2) anywhere 2008-03-05 17:06:50 +00:00
tg 4912b5cf67 quite a big change, but now the variables expanded are not
scanned for slashes, plus the ADELIM code gets more use and
a bugfix ☺
2008-03-01 21:10:26 +00:00
tg 36c4552e1f we don't need to be special if called as -sh any longer now 2008-03-01 02:21:38 +00:00
tg 8aa54e42a9 fix 2008-02-27 12:49:54 +00:00
tg 85b0cb20eb almost hack ${foo//bar/baz} support for real, now
still one corner case left ☹
→ 11:09⎜«Han:#UnixNL» Ik _haat_ bash
⇒ kann ich mich nur anschließen…
2008-02-27 11:24:12 +00:00
tg 01b54f1fd5 I _think_ this implements ${foo/bar/baz} logic (bar is a glob pattern)
todo tomorrow:
• test case (compare with e.g. GNU bash)
• manpage
• version bump

sqchar is a bit ugly, but \/ must be preserved, as we don’t get wdencoded
strings later on in the process (eval.c CSUBST) and I didn’t want to have
an implementation like ${foo: 2: 3} this time
2008-02-27 01:00:10 +00:00
tg 5ea53a15c7 implement “here strings” 2008-02-26 20:43:11 +00:00
tg 9b1504a221 move some constants private to the lexer into its .c file 2008-02-26 20:35:25 +00:00
tg d16fc19335 live code from FOSDEM: add print \xDB and \u20AC, including regression test
agreed bsiegert@
good idea and manpage diff ok'd by some netbsd person sitting next to me
2008-02-24 15:48:43 +00:00
tg 98f0a3c101 oops 2007-10-25 15:34:57 +00:00
tg 6976ed8bc3 get rid of u_char, u_int, u_long 2007-10-25 15:23:10 +00:00
tg 3b5bbaefcb optimise (struct padding, function→macro, etc.) 2007-10-25 15:19:16 +00:00
tg 13676f4914 even better: don't require 64-bit types at all
also, improve wording of Build.sh (passive terms)
2007-10-25 14:26:53 +00:00
tg bbbe959bf2 only check for 64-bit integer types if needed (arc4random support) 2007-10-25 14:18:56 +00:00
tg 2ca968e25f • fix for the pipeline-as-coprocess problem
• bump to mksh R32
2007-10-25 13:51:19 +00:00
tg 97ba2fabc7 first step towards mksh R32 ☺
allow array indices in the uint32_t range (0‥4294967295) and map negatives
into that range; adjust manual page and regression tests; to be used RSN ☻
2007-10-18 20:32:33 +00:00
tg e2c2a1c1a0 clean up the CHARMASK mess 2007-10-14 13:43:41 +00:00
tg 52b9911ff6 revert the return type of x_e_getc() back from u_char to int
this change broke abortion on failure to read input, was not
needed for gcc warnings and is the fault of Intel’s compiler

this should fix the other busy-loop problem occuring only on
GNU/Linux so far – 10x spaetzle@freewrt.o for pointing me to
the problem; reproduced on my work craptop
2007-10-09 14:50:50 +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 b82204aa3d proto 2007-08-20 14:06:10 +00:00
tg 1e3783f030 employ string pooling techniques to save off a few more bytes
(probably more than the new “rename” builtin ever required…)
2007-08-19 23:12:23 +00:00
tg ca46f3dc98 new builtin “rename” (this name sounds better than “mksh_mv_rescue” ☻)
to just call rename(2) directly, e.g. if /bin/mv needs /lib/ld-uClibc.so.0

some assorted code cleanup
2007-08-19 22:06:27 +00:00
tg e99f988aae feature freeze for mksh R31, to be released as part of MirOS #10 2007-08-18 00:22:09 +00:00
tg f684b0ceb1 Implement the “source” command, as requested by some and agreed bsiegert@
In contrast to AT&T ksh93, its semantics are like GNU bash in that it ap-
pends the current working directory to the search path; it is implemented
as a shell alias instead of enhancing funcs.c:shbuiltins[] like in ksh93.
2007-08-13 19:39:21 +00:00
tg f3bb1472df Debian warning cleanup 2007-08-12 13:52:03 +00:00
tg 499327f7b8 add “set -o arc4random”, RTFM for details 2007-08-12 13:42:23 +00:00
tg cf2eb697e2 use bounds check for function that calls read
prompted by lina output, 10x tarzeau
not a bug
2007-08-06 12:02:39 +00:00
tg 496b8f4dc3 • new way of checking for mknod & friends, due to tcc vs glibc weirdness
• bump vsn for the code restructuring
2007-07-31 11:11:25 +00:00
tg 3718a00106 • test on HURD (gnubber)
• fix unreachable code (break stmt) cought by suncc on yofuh's E420
• bump vsn to today
2007-07-26 13:23:52 +00:00
tg b20e5a90ce initial support for PW32, not quite working yet (same issues as Minix 3 and Plan 9, I think) 2007-07-24 21:47:14 +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 f2a52c65fa … and fix that bug.
Guvf pbzzvg haxabjvatyl fcbafberq
ol NheVFC ToE, fvapr jr hfr zxfu,
naq zl bgure gnfxf ner jnvgvat...
2007-07-23 14:28:52 +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 a1433b7122 • Build.sh: always prepend well-known signal names, so that some signals
will not come up weirdly (e.g. on AIX: SIGSAK (SIGMAX?), SIGIO (SIGAIO?),
  SIGURG (SIGIOINT?)), and add a few more while here
• check.t, sh.h: bump
2007-07-22 13:46:15 +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 56a8da33cf • make the "if called as sh, set FPOSIX" not !SMALL-only
• bump to R30-gamma, feature freeze
2007-07-17 13:56:51 +00:00
tg 78d58de7a0 fix the rest of it 2007-07-06 02:22:57 +00:00
tg 26a6e5acc9 make this pass varexpand-substr-1 and ‘c’ of varexpand-substr-2
by actually using the lexer and parser for that
2007-07-06 01:53:36 +00:00
tg f948c13a78 • fix display problem
• add <libutil.h> if it exists – revoke(2) on UWIN
• add <stdlib.h> for NULL in test of mmap(2)
• regen CPPFLAGS for MirBSD native builds
2007-07-01 21:47:08 +00:00
tg 7004525fcc • add support for the Borland C++ Builder (on UWIN)
• add support for the Digital Mars compiler (on UWIN)
• clean up
• describe new build targets and that UWIN sucks
• bump vsn
2007-07-01 21:27:03 +00:00
tg 572119b454 some <getopt.h> from vendors define a “struct option”, so use a
different name for ours
2007-07-01 16:49:18 +00:00
tg ca17798533 this is bash compatibility week, and by suggestion of actual users,
namely Dr. Robert “Pfeffer” Arnold (in this case, in FreeWRT), make
a half-completed attempt at implementing ${foo:2:3} substring evals
(of course, negatives can't work right now and that the numbers are
in face expressions is something I only read later too – this is to
be revisited later, but it's already late)

don't depend on this behaviour yet though

if someone wants to add more regression tests, feel free to…
2007-06-27 23:12:59 +00:00
tg 3a94b076a0 implement bash-style array initialisation, as requested by many
still experimental
2007-06-22 23:34:42 +00:00
tg d42f966d22 rewrite some code; bug found by HP's C compiler 2007-06-21 16:04:46 +00:00
tg e596de4759 make sure that “integer” and “local” are defined even in FPOSIX mode, which
is a compromise anyway; these lunox people will have to live with that, too
many existing korn shell alike scripts depend on it even if not on the full
korn shell syntax availability (note: this doesn't mean using these in some
script with #!/bin/sh is ok)
2007-06-17 00:50:09 +00:00
tg 17b7a28ac8 • check.t: add some FPOSIX regression tests (1 still fails)
• all: remove vi editing mode #if defined(MKSH_SMALL) || defined(MKSH_NOVI)
  saves 12608 byts on i386
• check.t: add $0 quoting
2007-06-15 21:55:20 +00:00
tg e258f1e9fe bump 2007-06-09 22:02:04 +00:00
tg bf671f42fa don't use __extension__, cought by sunpro on linux 2007-06-09 22:01:42 +00:00
tg 40484a2f21 from sunpro 12 on linux: optimise use of the const-vs-unconst catcher
thanks cnuke@ for testing
2007-06-09 21:59:21 +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 5dfde5c670 first part of the Intel C Compiler (Linux) shaddap
| tglaser@hephaistos:~ $ /usr/local/intel/cc/9.1.042/bin/icc -V
| Intel(R) C Compiler for 32-bit applications, Version 9.1    Build 20060706Z Package ID: l_cc_c_9.1.042
this one is muuuuch too verbose IMHO, _and_ it #defines __GNUC__ (eek)
2007-06-06 21:36:29 +00:00
tg 63c31c43e3 fix for the SUNpro 8 on yofuh's E420:
cc: Sun C 5.8 Patch 121015-04 2007/01/10
2007-06-05 19:48:47 +00:00
tg 10b48d1f92 on Linux 2.0, <sys/sysmacros.h> defines makedev(), but on Solaris, both it
and <sys/mkdev.h> do it, where the latter seems to contain the newer ones,
it undefines them before redefining too, so move its inclusion up a little
2007-06-05 19:35:13 +00:00
tg 1e93f97b8c compile warning-free on SUNpro (regression test suite pass) for MirBSD 2007-06-04 21:33:28 +00:00
tg 6e1bfd6e4b When compiling native MirOS BSD binaries with SUNpro 12 (don't look like a
car only slower, yes this is possible, and the resulting binary passes the
testsuite just fine), the definition of __RCSID() in <sys/cdefs.h> expands
to something with __attribute__((used)), which triggers a warning, because
__attribute__ in general is supported but the used attribute isn't. Thusly
always use our own strings and get rid of the MULTI_RCSID test (introduced
because __RCSID() on Darwin is inferiour).

Maybe we should fix <sys/cdefs.h> too? #ifdef __SUNPRO_C helps here.
2007-06-04 21:27:53 +00:00
tg 2beb60ebf3 for R30, don't check for confstr() declaration any more
it was #if solaris'd in R28, and the system I have access
on does declare it now (still Solaris 8)

this can be put back if anyone complains, of course.
2007-05-24 23:07:19 +00:00
tg a3ab909ff6 bump vsn, we had a regression… 2007-05-24 19:50:38 +00:00
tg 9b86b32dc8 ah, of course, bump the date 2007-05-22 19:31:01 +00:00
tg f5d4e21aa2 • fix the third dramsey scrolling bug for both ^D at BOL and ^W at EOL
(I hope)
• fix another one I found: after ^D'ing, insert at BOL, the > is displayed
  one character too late
2007-05-21 19:25:32 +00:00
tg 252861b156 fix the latest appearance of the dramsey backwards movement bug, cf.
Message-ID: <e3fded850705200935h6ac2c9ebgbc7a9b10ac034a49@mail.gmail.com>
and Message-ID: <Pine.BSM.4.64L.0705201659500.8619@odem.66h.42h.de>
2007-05-20 17:53:13 +00:00
tg fcd6e4f07a bump version 2007-05-13 19:18:26 +00:00
tg a84655e3e0 fix Coverity CID #8, #9
it's wrong to use strchr(s, 0) to look for the NUL byte, because in some
environments it apparently might return NULL

use new macro strnul = s+strlen(s) instead (not side-effect safe tho)
2007-05-13 19:14:05 +00:00
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 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