Commit Graph

259 Commits

Author SHA1 Message Date
tg af53a7d16a • speed optimisation: drop SF_FIRST flag, factor out skipping the
UTF-8 BOM instead (UTFMODE has a separate value now for activated
  during BOM skipping)
• parsing a COMSUB now skips UTF-8 BOM, too, but only temporarily
2011-03-13 16:03:54 +00:00
tg e66eaab861 let SLETARRAY use SRETRACE, too 2011-03-13 15:57:23 +00:00
tg f16386954d drop dead code 2011-03-13 15:31:46 +00:00
tg 5710e78857 implement better SASPAREN handling (actually, reusable very good for the
case where SASPAREN→COMSUB downgrading is done) by “logging” input and
restarting from there if needed
2011-03-13 01:11:58 +00:00
tg 9b8fafb757 correct documentation 2011-03-12 23:16:51 +00:00
tg 75db4cdb56 • back out the EXPRSUB change
• optimise some code
• split testcase into two, one with expected-fail
2011-03-12 23:04:48 +00:00
tg ff0a3c8a8a SASPAREN changes have the same problem, revert too for now 2011-03-12 22:44:28 +00:00
tg fc42105199 revert SLETARRAY changes for now, this introduces problems 2011-03-12 22:40:02 +00:00
tg 17dbd3bd83 • make EXPRSUB not initiate an ASCIIZ string any more but a wdstring
(token stream, lexer output / parser input), EOS terminated, let
  SASPAREN use the same lexing as SBASE (e.g. COMSUB recursively)
• make wdstrip recursive
• fix processing of COMSUB in wdstrip
⇒ pass comsub-1 test
• expose another debugging function
2011-03-12 21:41:15 +00:00
tg fb1392fb6b even more test cases for comsub (2 breaking, but one of them fixed already) 2011-03-12 20:20:17 +00:00
tg 6894618bb9 • x=$(cat <<-EOF
EOF) # works again now, plugging a regression
• rewrite the here document parsing code to be *much* more efficient
  (and a bit more readable too!) using goto, while here (no kidding)
2011-03-07 20:32:50 +00:00
tg 5f8075fc82 introduce a tobool(cond) abstraction¹ and switch bool to char if !stdbool.h
① currently: ((cond) ? true : false) but (!!(cond)) and casting to bool,
  the latter only if stdbool.h, would also work – which performs best on
  (and across) all supported systems?
2011-03-07 20:30:41 +00:00
tg 009d4c7b75 drop more currently unused 2011-03-07 20:09:34 +00:00
tg 2075dd23b2 drop unused 2011-03-07 20:08:48 +00:00
tg bfe34ba110 reduce data size by 320 bytes by packing struct lex_state tighter
and reducing amount of them allocated in each “pack” from 31 to 7
since $(…) is recursive anyway (I tried hard to need even only 5)
2011-03-07 20:07:52 +00:00
tg 1f392ab09b • more fixes (some regression, some new)
• more testcases, stricter testcases
2011-03-06 17:08:14 +00:00
tg 25905b91a7 the long-awaited recursive parser for COMSUB $(…) expressions
fixes RedHat BZ#496791
2011-03-06 01:25:35 +00:00
tg b4948e430f this is a bashism but might be from ksh93 IIRC… still dead ugly as hell! 2010-12-19 20:00:56 +00:00
tg 667d792d6a • Address concerns of Chris Palmer from the Android security team
– possible integer overflows in memory allocation, mostly
    ‣ multiplication: all are checked now
    ‣ addition: reviewed them, most were “proven” or guessed to be
      “almost” impossible to run over (e.g. when we have a string
      whose length is taken it is assumed that the length will be
      more than only a few bytes below SIZE_MAX, since code and
      stack have to fit); some are checked now (e.g. when one of
      the summands is an off_t); most of the unchecked ones are
      annotated now
    ⇒ cost (MirBSD/i386 static): +76 .text
    ⇒ cost (Debian sid/i386): +779 .text  -4 .data
  – on Linux targets, setuid() setresuid() setresgid() can fail
    with EAGAIN; check for that and, if so, warn once and retry
    infinitely (other targets to be added later once we know that
    they are “insane”)
    ⇒ cost (Debian sid/i386): +192 .text (includes .rodata)
• setmode.c: Do overflow checking for realloc() too; switch back
  from calloc() to a checked malloc() for simplification while there
• define -DIN_MKSH and let setmode.c look a tad nicer while here
2010-09-14 21:26:19 +00:00
tg 06c6be0a70 shave off another 468 bytes: we’re 300 bytes smaller than BEFORE the
cat builtin was added now… (also removed utf-8 from source files, in
favour of just ASCII)
2010-08-28 20:22:24 +00:00
tg 3747722db4 improve string pooling: saves 316 bytes in .text 2010-08-28 18:50:58 +00:00
tg c187f3089f a tad annoying, when external programmes such as GNU screen are running,
we don’t get SIGWINCH when the window size changes during the runtime of
that, so, the signal is only usable reliably during editing in the shell
and we re-check the window size before each interactive edit line again
2010-07-25 11:35:43 +00:00
tg c11d35312a Michal Hlavinka from Red Hat found another SIGSEGV
fix: when iterating over all Sources, know when to stop…
2010-07-21 11:31:16 +00:00
tg 7c91e018f4 • merge printf from OpenBSD
• deactivate %a and %A since our libc doesn’t have it
• rewrite the mksh integration code to use shf instead of stdio, removing
  floating point support always in the process, as shf doesn’t support it
  ⇒ saves 11114 (6706 text, 168 data, 4240 bss) with dietlibc on Debian
• fix -Wall -Wextra -Wformat -Wstrict-aliasing=2 for gcc (Debian 4.4.4-7)
• fix these and -Wc++-compat for gcc version 4.6.0 20100711 (experimental)
  [trunk revision 162057] (Debian 20100711-1) except:
  – a few enum warnings that relate to eglibc’s {g,s}etrlimit() functions
    taking an enum instead of an int because they’re too stupid to adhere
    to POSIX interfaces they design by themselves
  – all “request for implicit conversion” involving a "void *" on one side
• tweak the manual page somewhat more
2010-07-17 22:09:40 +00:00
tg a516ea5d89 fix another initialisation error caught by Valgrind 2010-07-04 18:29:40 +00:00
tg 30046ffcf2 implement “live” SIGWINCH handling in the Emacs editing mode
for winstonw from IRC #!/bin/mksh
2010-07-04 17:45:17 +00:00
tg ff9f89f22f Fix two more POSIX conformance bugs and minor documentation/comment issues 2010-04-08 13:21:08 +00:00
tg 2557cfbbe5 move label, see <Pine.BSM.4.64L.1003311156380.24549@herc.mirbsd.org> (my
first paragraph in that) for reason: to make it more clear from the code
2010-03-31 12:20:04 +00:00
tg 401e262689 fix another expand-ugly SUSv4 bug 2010-03-27 16:53:17 +00:00
tg e5e6857c43 (hopefully) fix the substitution thing for good 2010-02-25 20:18:19 +00:00
tg ae2901146f begin fixing up ${foo+word}, see austin-group-l for discussion and DR 2010-02-23 21:51:49 +00:00
tg 5beee95d6b at least _parse_ the construct ${foo+(bar)} correctly
(whether the output is correct is still up for debate)
2010-02-18 17:31:23 +00:00
tg 4eb17f8752 remove some more of this ugliness 2010-01-29 09:34:31 +00:00
tg c67bed8790 • unbreak testsuite for MKSH_SMALL
• sync version and © year
2010-01-28 20:58:34 +00:00
tg 4aba1d69b5 DEC ucode cc politely reminds me this is not a good way of doing stuff, 10x 2010-01-28 20:52:08 +00:00
tg 2765a07564 when using persistent history (and not MKSH_SMALL), let the shells
concurrently accessing the same $HISTFILE be more synchronised with
each other: empty lines (just pressing Return) and duplicates (that
are split and written twice by the lines loaded from $HISTFILE in
the meantime); requested by Maximilian “mxey” Gaß in #!/bin/mksh
2010-01-25 16:12:57 +00:00
tg 703551bd4f attempt a better fix: break off widthadj upon encountering NUL,
add remaining columns as octets (should also speed optimise)
2009-12-05 20:17:59 +00:00
tg 86d4dee0da valgrind (thanks ciruZ for trying) found uninitialised memory use
in utf_skipcols by x_goto
2009-12-05 19:44:09 +00:00
tg 2094e3f25c since we have wcwidth anyway, expose it as ${%strvar} to the user, iff
utf8-mode is enabled (otherwise it'll be a synonym for ${#strvar} aka
the number of octets in it)
2009-11-21 23:23:20 +00:00
tg 5f58261287 fix long-standing parenthesēs problem: ((foo) || bar) is now parsed corr. 2009-10-04 12:45:23 +00:00
tg c2e5737fca fix dollar quotes in here strings and here documents (regression) 2009-10-04 12:44:19 +00:00
tg 33b9f8b666 * rename "set -o posix" (FPOSIX) to "set -o sh" (FSH) because it's not
just a "somewhat more POSIX" but also a "/bin/sh legacy kludge" mode
* consistently capitalise POSIX and SUSv3/SUSv4 (same as AT&T ksh) and
  Bourne shell
2009-10-02 18:08:37 +00:00
tg 1dfb13b603 change undef/def MKSH_NOVI into 0/1 MKSH_S_NOVI flag (with more to come:
MKSH_S_EDIT for small (Emacs) editing mode, MKSH_S_FEAT for all the dis-
abled language features), which can be set to 0 despite MKSH_SMALL being
defined to re-enable the Vi command line editing mode (which I wouldn't,
but fits into the general mastermind scheme)
2009-09-24 17:15:33 +00:00
tg 1a28786229 * shrink MKSH_SMALL even further by removing functionality like
some GNU bash extensions (suggested by cnuke@) and bind macros
* make the random cache more efficient (and the code potentially
  smaller, although we have a new implementation of the oaat hash
  function, alongside the old one, now) and pushb only if needed
  (i.e. state has changed or user has set $RANDOM, but not onfork)
2009-09-23 18:04:58 +00:00
tg 01239f35eb un-do a workaroung for something fixed by 1004AB55BFD3DADFED4 2009-09-19 22:33:10 +00:00
tg 9fd4b9db41 $'…' functionality, documentation improvements, fixes for backslash
expansion in all modes, regression tests for both kinds of backslash
expansion; unbksl() revamp; make CTRL macro available globally
2009-09-19 21:54:46 +00:00
tg 4392aced96 the capability to get array indicēs (keys), Korn shell style
bash4 doesn’t have it at all, despite knowing associative arrays
zsh does it………… differently and weird

this is for indexed arrays, as mksh doesn’t have associative arrays
but it should help ☺
2009-08-28 22:39:09 +00:00
tg 4ccdfc8508 much better solution: save tablep and hash value¹ in the struct tbl entry
① also saves time during texpand :D

XXX this doesn’t work well with the current indexed-array implementation
2009-08-28 20:30:59 +00:00
tg 7240c843ce this is a rather stupid diff: give ktsearch/ktenter the capability to
return information needed to do a real ktremove instead of the pseudo
ktdelete operation which merely unsets the DEFINED flag to mark it as
eligible for texpand garbage collection (even worse, !DEFINED entries
are still counted)
2009-08-28 19:57:43 +00:00
tg ca1f967a45 • use Jenkins’ one-at-a-time hash for mksh keytabs, as it has
much better avalanche and no known funnels
• improve comments
• fix some types (uint32_t for hash, size_t for sizes)
• optimise ktsort()

no functional change, I think
2009-08-28 18:54:01 +00:00
tg f349aeab3c be more robust against things like Debian #535970
reverts and rewrites the code from cid 10047C1EBA57E4F4AF0

XXX find out if this is done right
2009-07-06 15:06:25 +00:00
tg e1d8d7ed01 capitalise AT&T® 2009-06-11 12:42:21 +00:00
tg 0432f97ffe more KNF, mostly whitespace, this time more manual labour applying style(9) 2009-06-10 18:12:51 +00:00
tg 6b2ad96bac some rather mechanical KNF, now that style(9) clarified on the status
of sizeof() as a function-like unary operator; use parenthesēs around
sizeof and return args consistently too
2009-06-08 20:06:50 +00:00
tg da5dc48cd0 implement an extension that an interactive mode input line, when
starting with an ‘!’ exclamation mark at the beginning of a com-
mand (PS1 not PS2), shall have the same effect as the predefined
“r” alias, to be compatible with csh and GNU bash’s “!string” to
«Execute last used command starting with string» – documentation
and feature request provided by wbx@ (Waldemar Brodkorb)
2009-05-27 19:52:38 +00:00
tg b90007d784 • Build.sh, strlcpy.c: gcc-current conversion &c. warnings cleanup
• histrap.c, lex.c, misc.c: get average stack frame size to <= 768 bytes
• check.t, sh.h: bump version
2009-05-27 09:58:24 +00:00
tg b145ca5c9f • sync distrib/special/mksh/Makefile with bin/mksh/Build.sh and
fix the regression test’s results while here, which have been
  broken since cid 10049D9BE5254CE65B8
• get rid of separate copyright file which was intended for De-
  bian; track down commits in all files of oksh-mirbsd and mksh
  to get correct copyright years per-file, as is BSD custom
2009-05-16 16:59:42 +00:00
tg d2b5538f55 some int->bool, KNF, ... 2009-04-07 19:13:11 +00:00
tg edeb22fb96 tabs vs spaces 2009-04-07 19:06:44 +00:00
tg 22f1fb6cd6 fix off-by-one calculation mistake making PS1 ending in newline double it 2009-03-15 18:30:40 +00:00
tg 31d1499219 * back out almost all of the memory allocator related changes, as aalloc
was hard to type and hard to fix, galloc is also hard to fix, and some
  things I learned will probably improve things more but make me use the
  original form as base (especially for space savings)
* let sizeofN die though, remove even more casts
* optimise, polish
* regen Makefiles
* sprinkle a few /* CONSTCOND */ while here
2008-12-13 17:02:18 +00:00
tg 042086e49e rename utf8-hack to utf8-mode (use set -U or set +U instead, anyway)
and announce less hackish things
2008-12-04 18:11:08 +00:00
tg 4897682502 Alias expansion has a recursion check which tries to break the cycle if
encountered. However, when reading end of input, the source type is set
to SEOF while popping, whereas the recursion check code only checks for
an SALIAS type.

Fix: add a new SF_HASALIAS flag; change u.tblp from being valid if type
is SALIAS to being valid if SF_HASALIAS is set; set SF_HASALIAS for the
created SALIAS sources; set SF_HASALIAS and u.tblp when creating SALIAS
whose next is SEOF on the SEOF source as well.

Reported by Michael Hlavinka as Redhat Bug #474115
2008-12-02 12:39:38 +00:00
tg 4d3fc2413e switch to a (nmemb,size) API from a (nmemb*size) API
cost: text += (308, 256, 4, -100)
2008-11-12 00:54:52 +00:00
tg c80c28633b change use of “Area *” to “PArea” and “struct Area” to “TArea”
no change in size (mgcc and pcc, small and full)
2008-11-11 23:50:31 +00:00
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
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 af7fcd2498 smaller even 2008-09-30 19:35:10 +00:00
tg 051522c9ea optimise 2008-09-30 19:28:12 +00:00
tg 13231b50eb ignore more dups 2008-09-30 19:25:51 +00:00
tg 563d4b5b19 implement duplicate ignoring in the history, also requested by asarch,
and wanted by me for a while
2008-09-30 17:58:49 +00:00
tg f53a8196e4 däs isch ei buul, koa int… 2008-09-30 17:49:26 +00:00
tg 3287571386 Do not push lines beginning (at the $PS1) with an IFS White Space (space,
tab, newline) or an IFS Character ($IFS) into the history at all.
2008-09-20 14:17:30 +00:00
tg 0b4f34e0a8 • syn.c: replace expanded use of str_save() with the actual macro
• others: fix 6 (!) cases of non-constant or side-effect arguments
  to the str_save() or str_nsave() macros, and other abuse of them
• also fix some cosmetics and other un-nice code while here
2008-07-12 16:56:40 +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 943446cadf … one more regression test we pass…
• hd <<< bar
  → like bash, ksh93, zsh
• hd <<< #bar
  → like zsh (bash, ksh93: syntax error)
• hd <<<
  → like hd <<< '' (bash, ksh93, zsh: syntax error)
2008-07-09 20:41:23 +00:00
tg 08624e7e49 sync with openbsd: only the RCS IDs, because the changed code in
question either does not exist in mksh (lex.c) or refers to the
only “feature” we do not pull, GNU bash-like $PS1 (main.c)
2008-07-08 22:28:26 +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 fcb931ae2e more safe idiom 2008-06-28 22:01:44 +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 604ec0ff6c remove dead code and ifdefs, speed up configuring 2008-05-04 01:51:31 +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 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 3321382ad2 more, this time on mirbsd… *sigh* 2008-03-05 16:49:22 +00:00
tg 3ff6cc397a found by gcc on OSF/1 10x to Jupp Schugt (penpen) 2008-03-05 16:40:57 +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 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 0f1501326b clean up, optimise, comment code 2008-02-26 21:08:33 +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 8c86fedc2d * lex.c: Don't expand aliases if there's an opening bracket just after
the token. Fixes unreported problem with pdksh reporting syntax error
    on the init scripts that define function named ‘stop’ (clashing
    with an built-in alias.)

 -- Robert Luberda <robert@debian.org>  Sun, 27 Feb 2005 18:36:55 +0100
2008-02-24 22:12:36 +00:00
tg f9a4d9605c reduce RAM usage 2007-10-25 15:27:54 +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 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 979406bba7 • support IBM xlC on AIX
• fix all bugs it could find ☺
2007-07-22 13:34:52 +00:00
tg 4422137a88 introduce SADELIM_MAKE matching style – ${foo:S/bar/baz/flags} –
to complement SADELIM_BASH, as before – ${foo/bar/baz} –
but ifdef'd out for now, so probably no coding style. also new
is a flags array (not declared yet)
2007-07-07 22:29:36 +00:00
tg a29f4f60f8 I'm an idiot and this looks better and is more KISS (I suppose)
too bad I don't just wrap it in braces
2007-07-06 02:39:37 +00:00
tg fca52a0f6a give the lexer a bigger state stack if !MKSH_SMALL 2007-07-06 02:24:18 +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 e6055dbf19 better position for that (cosmetics) 2007-07-05 23:48:53 +00:00
tg 0cd850b207 optimise – we already did that one range check before 2007-06-23 00:05:04 +00:00
tg 3a94b076a0 implement bash-style array initialisation, as requested by many
still experimental
2007-06-22 23:34:42 +00:00
tg 199994fed8 we can do all that 2007-06-16 15:02:56 +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 5d6b21fda2 it's FALLTHROUGH, 10x moritz@obsd 2007-06-04 19:25:45 +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 96283ed453 Workaround for Coverity CID#1: the Prevent parser didn't recognise there
were multiple possible values for c inside the code.

Rewrite code in question to use if instead of switch; optimise while here.
2007-05-13 18:07:22 +00:00
tg d2d035355f a certain size optimisation broke the utf8bom-3 regression test if
mksh was configured to have utf-8 mode “always on” (because it's
really only always on for interactive shells); setting it to really
always on would break the other half of this regression test, so
do the optimisation only if MKSH_SMALL
2007-05-10 19:22:11 +00:00
tg c0e5c09351 optimisation: #ifdef MKSH_ASSUME_UTF8, don't bother to “Flag(FUTFHACK) = 1;” on UTF-8 BOM encounter, it's always on (unless manually set to off) – saves a few bytes, I guess 2007-04-26 11:58:53 +00:00
tg 680e8ebd3f if we read an utf-8 BOM, enable the utf8-hack flag (we can test for that on
mirbsd even because the main.c enabling is only run for interactive shells)
2007-04-15 12:28:38 +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 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 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 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 feb7dddd44 * use only macros for ctype stuff any more
XXX one of these uses a gcc extension, ok for now tho
* don't include <ctype.h> any more at all
* don't try nl_langinfo in small mode, just check locale

saves 171 .text, 4 .data, 256 .bss, 1 import
2006-11-10 07:18:58 +00:00
tg a373d2e7ab first part of utf-8 ability in mksh, already works pretty well 2006-11-05 15:31:37 +00:00
tg 790c312e9f fix the prompt redrawal routines for multi-line prompts, prompts
with embedded newline (\n), and multi-line prompts with embedded
newlines. single-line prompts should be not affected; prompts with
embedded carriage return (\r) should be fixed by this as well.
also fix prompt_redraw comment (can't remove the variable though,
since it's required if the shell inserts a newline after the prompt
herself).
tested on cygwin and interix
2006-08-02 11:33:37 +00:00
tg ad43cfa6cd rename 'count' into the more appropriate 'columns' 2006-08-02 10:42:30 +00:00
tg df54522223 * Build.sh: fix accidental CR-LF catastrophe
(yeah, that's what you get from developing with a
  16-bit MS-DOS(R) executable of your favourite text editor)
* lex.c, mksh.1: do not print the delimiting character for
  not-to-be-counted character sequences (i.e. ANSI escapes)
  in prompts any more, mostly because ASCII 01h is printable
  on both Interix and Cygwin and I'm lazy
  (this also fixes prompt width counting if a printable character
  such as 'x' is used as delimiting character)
* lex.c: through printing the prompt character by character,
  also print the delimited sequences if skipping, fixes some
  prompt redrawal not honouring colours stuff while not totally
  redrawing the entire prompt
2006-08-02 10:41:03 +00:00
tg 857fb659bc fix multiline prompts with "delimiter chars"
(only the last line of the prompt is redrawn, keep this in mind
when doing the ANSI colour game)

TODO:
* maybe go back up one line and redraw whole prompt?
* optionally edit command on multiple lines, bash-like,
  instead of scrolling horizontally
2006-08-01 14:59:51 +00:00
tg a15c5c319a * use modulo operation, Mr Glockner
* allow promptlen to return values > $COLUMNS
2006-08-01 14:35:44 +00:00
tg ce18e01f2c move promptlen from edit.c into lex.c 2006-08-01 14:10:25 +00:00
tg c504a42ac1 (partial) sync with openbsd (and fix after them),
gives us a better wrapping prompt and a manpage wording cleanup
2006-08-01 14:09:20 +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 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 f11d5ff712 clean up code 2005-07-04 12:47:13 +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 a21be8d676 some lint cleanup 2005-06-08 22:34:03 +00:00
tg 521da70fc8 * major revamp of build system
* whitespace cleanup; junk comment removal
* syndicate debian/copyright file from my port (shrinks sh.h)
* bump to R23
2005-06-08 21:51:22 +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 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 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
tg cbeac44097 * unifdef EDIT, VI, EMACS, HISTORY
* optimise away 0 ||
no binary changes
2004-12-18 19:17:10 +00:00
tg 4c4a9323f8 unifdef: KSH
no binary change
2004-12-18 18:58:32 +00:00
tg c34add61ff un-OS/2 (sorry)
no binary change
2004-12-13 19:05:09 +00:00
tg b99edc6cc1 From: Todd C. Miller <Todd.Miller@courtesan.com>
Cool, thanks for testing.
 - todd
2004-12-13 16:48:54 +00:00
tg 97d9512149 bump to mksh R19 2004-12-10 18:12:32 +00:00
tg 7920708324 Initial revision 2004-12-10 18:12:29 +00:00