Commit Graph

282 Commits

Author SHA1 Message Date
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
ahoka 776cc76ccb Add check for the nice(3) system call.
It may be not implemented on some plaforms, though it's usually present.

Required to compile on Haiku as of 2008 October.
2008-10-26 21:51:27 +00:00
tg 8230c9d8ae • do not use __typeof__ even if we have statements-as-expressions, to
please pcc, prompted for by Anders “ragge” Magnusson, problem spotted
  originally by Adam “replaced” Hoka
  ⇒ rewrote x_bs2() and utf_backch() into a combined x_bs3() function,
    since these are never used in any other way
• whitespace cleanup, while here
2008-10-26 20:59:40 +00:00
tg bc046dd8f2 this will most certainly be mksh R36 2008-10-24 21:35:43 +00:00
tg 331b45af7d • OSF/1 may not have MAP_FAILED defined either
XXX mmap() works only on devices on some DEC OSes, not on files, so,
  XXX instead, it were best to disable it altogether
• bump date
2008-10-24 19:54:23 +00:00
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