Commit Graph

488 Commits

Author SHA1 Message Date
tg 5f31b8c97a • bring back test -H ifdef S_ISCDF (for HP-UX)
• whitespace, etc.
• bump version for tonight, I’m not gonna hack on c_cd,
  all this pathname stuff is mind-boggling…
2011-03-26 21:46:06 +00:00
tg 7d86eaba8c simplify code to use existing $PWD 2011-03-26 19:43:49 +00:00
tg 803c51914b • move funcs.c:do_realpath() to misc.c and make it global
⇒ consider merging simplify_path()
• move funcs.c:c_cd() to misc.c
• make misc.c:make_path() static, c_cd() is its only user
  ⇒ mark as obsolete
• tweak misc.c:set_current_wd() to drop ksh_get_wd() argument

should be no code change, but the entire path stuff is a mess…
so expect actual implementation changes or even rewrites shortly
2011-03-24 19:05:49 +00:00
tg 8d8ee0cc6a ironhead reported in IRC that some Cygwin guys (not he, he’s just the
packager) complain that mksh collapses two leading slashes; IIRC POSIX
has a clause for UNC pathnames, so stop doing that, plus add a test
2011-03-23 18:47:07 +00:00
tg bc4c3b9af0 • save/restore here document pointer during yyrecursive(), fixes crash
• add mirbsd/openbsd (omalloc rules!) specific testcase for the above
• $__progname must be used quoted, fix in comsub-torture testcase (my bad)
2011-03-21 21:57:35 +00:00
tg 3c41d2b063 fix cast; bump version 2011-03-17 22:09:23 +00:00
tg a1a5922fc6 • make misc.c(gmatch.c):pat_scan() static and fix int → bool 2011-03-17 21:59:30 +00:00
tg d4e19b6624 • make DEBUG:dumpchar() not static (consider rolling into shf?) 2011-03-17 21:58:40 +00:00
tg 79c6d6043e • introduce a virtual TARGET_OS=Android that just sets a check category
and switches to the TARGET_OS=Linux
• introduce android as regression test suite category
• add an android specific standard alias
• clean up redundant ‘-o sh’ arg in a few checks
2011-03-16 20:26:36 +00:00
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 2a3d4db123 lint is your friend 2011-03-13 01:20:25 +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 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 f8659785ac • add a tree debugging dumper #ifdef DEBUG
• use shf_putc (macro), shf_putchar (function) ipv tputc
• replace shf_putchar(x,y) calls for side-effect-less x with shf_putc
• plug another bug in the tree code – '\' → "\\" (backslashes must be
  escaped inside double quotes, too)
• adjust testsuite (and, I _had_ wondered…)
2011-03-08 18:49:51 +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 1f392ab09b • more fixes (some regression, some new)
• more testcases, stricter testcases
2011-03-06 17:08:14 +00:00
tg c995f7ca98 I thought of making COMSUB pass a pointer to the struct op *t->left around
instead, but the parser for the so-called “backticks” (U+0060) still emits
plaintext COMSUB wdstrings, and the evaluation code emits plaintext if the
code is not run (‘-n’ option), so it’s not worth the effort and memory ma-
nagement issues, even though it _would_ optimise the most common case…

Bump version numbers, sync regression tests; add one testcase from the old
webpages too. Sync manpage, this now works, but keep the workaround in, as
“portability issue” with slightly changed wording.

Also, /bin/sleep must be used in one manpage example if sleep is built in.
2011-03-06 01:50:11 +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 f3dbbe3f0c split malloc_os and friends further into
• functions called by mksh’s grouping memory allocator
• functions called by mksh code itself

the latter may be changed to call the internal grouping allocator,
if a porter so desires (but if this were recommended, the code in
question would already do so, so…)
2011-03-05 21:48:09 +00:00
tg 0b6afea352 introduce macros for malloc, realloc, free to hide them from mksh
no code may henceforth use memory (de-)allocation functions directly
use these macros, porters can change them for abstraction
2011-03-05 21:43:18 +00:00
tg 6a941a3c39 fix UWIN: don’t close fd #3 (also, int→bool) 2011-02-27 19:29:32 +00:00
tg 0b57abd4d3 • add -u option (POSIX: unbuffered ⇒ nop) to the built-in cat
• PIPESTATUS now supported (like bash 2) whose last member
  may actually differ from $? since the latter may not be the
  result of a pipeline partial command
• add regression tests, documentation, etc.
2011-02-18 22:26:13 +00:00
tg 36d41ed9ee * plug a regression introduced as a pasto (think, mira!)
* add selftest-direct-builtin-call regression test, while here
2011-02-13 21:13:08 +00:00
tg a796512040 • more comment and int→bool cleanup, add and improve some comments
• in interactive mode, always look up {LC_{ALL,CTYPE},LANG} environment
  variables if setlocale/nl_langinfo(CODESET) doesn’t suffice
• add the ability to call any builtin (some don't make sense or wouldn't
  work) directly by analysing argv[0]
• for direct builtin calls, the {LC_{ALL,CTYPE},LANG} environment
  variables determine utf8-mode, even if MKSH_ASSUME_UTF8 was set
• when called as builtin, echo behaves POSIXish
• add domainname as alias for true on MirBSD only, to be able to link it
• sync mksh Makefiles with Build.sh output
• adjust manpage wrt release plans
• link some things to mksh now that we have callable builtins:
  bin/echo bin/kill bin/pwd bin/sleep (exact matches)
  bin/test bin/[ (were scripts before)
  bin/domainname=usr/bin/true usr/bin/false (move to /bin/ now)
• drop linked utilities and, except for echo and kill, their manpages
• adjust instbin and link a few more there as well
2011-02-11 01:18:23 +00:00
tg cc8caf2cf9 add a sleep builtin that can deal with fractions too 2011-02-11 00:41:38 +00:00
tg 5161342b9b fix warning about signed vs. unsigned comparision and potential truncation error 2011-02-09 13:08:27 +00:00
tg d4658a569e refactor code to be able to track whether we have a parameter substitution
or a “proper” glob expansion; if there’s a dollar, but not a glob, refrain
from appending a space later (LP: #710539)
2011-02-03 15:57:52 +00:00
tg 30d8e3934d SUSv4 says trap foo UNKNOWN is not a syntax error, merely exit ≠0.
Inspired by 673dab8698b0399c967216c02262eaf95361a75c.
2011-01-30 01:36:00 +00:00
tg bdfcdc56c8 introduce MKSH_NOPROSPECTOFWORK which is like pdksh’s JOB_SIGS in reverse, like MKSH_UNEMPLOYED is pdksh’s JOBS in reverse; allows mksh to work (hah! no pun intended…) with klibc (and possibly, Syllable Desktop and Plan 9) for now, until they fix their bugs 2011-01-30 01:35:35 +00:00
tg 414c09ab1a plug regression introduced with read -d by fixing the problem differently 2011-01-22 20:33:14 +00:00
tg da9d0f3d97 ${foo@x} is now special-expansion for values of x, defined for now:
‘#’ = hash of $foo
2011-01-21 22:25:34 +00:00
tg cc31d86e3b • implement KSHEGID, KSHGID, KSHUID variables by suggestion of Richard K.
(KSHEUID aka USER_ID already exists)
• simplify, speed up LCG and $RANDOM handling again
2011-01-21 21:04:48 +00:00
tg 230f59d064 New functionality: assign here document to string variable directly,
without cat and temp files. Hacked in Lëtzebuerg ☺

This was the third try. Where to put this was not palpable… same for =(…)
2011-01-09 21:57:29 +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 27dce9168a change behaviour of argument-less exit in traps to match SUSv4; Debian #599484 (original patch from Jonathan Nieder, thanks!) in a variant that appears to handle nested traps well 2010-11-01 17:29:05 +00:00
tg 29de79c7bf mknod’s now demoted and only used as special-case builtin, in MirBSD only
built for the installer, to save time, as the original OpenBSD hack wanted
2010-10-08 17:56:57 +00:00
tg 3365cb8d0f • Build.sh: fix a compiler warning which, had it not been irrelevant in
a mirtoconf check, would’ve been a real problem on an LP64 platform
• sh.h: work around a bad interaction between -Wformat on gcc and manual
  string pooling for T_synerr, which is used in place of a format string
  in some places
2010-10-01 19:04:38 +00:00
tg e169648b89 while here, change SETUID_CAN_FAIL_WITH_EAGAIN to abort immediately
by suggestion of Chris Palmer again
2010-09-19 19:28:23 +00:00
tg 915b30adfe revert part of the “size reduction” diff (zero size change though):
shellf() implies an shf_flush()…
2010-09-15 21:08:19 +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 08862021ee add size optimisation hacks by me from Android except ifdef’d
(note, I’d prefer everyone to keep IDSTRINGs around though)
2010-09-14 21:15:11 +00:00
tg 56a69907d5 optimise error messages, option parsing, and make more builtins
recognise "--", costs us 20 .text 0 .data 0 .bss
2010-09-05 19:51:35 +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 d09fd67299 make cat an mksh builtin, for things like here documents
if any options are given, the external programme is invoked instead
2010-08-28 17:21:46 +00:00
tg 297e2ced89 fix blocking_read prototype 2010-08-28 16:47:11 +00:00
tg 4e08a79555 whitespace 2010-08-28 15:48:20 +00:00
tg 475cafb90e int → bool 2010-08-28 15:39:20 +00:00
tg a0d43a99fd it’s ugly to write a ./stdint.h file if we can instead define the
types from sh.h; sync clog
2010-08-24 15:19:54 +00:00