Commit Graph

932 Commits

Author SHA1 Message Date
tg faa0a78df3 restore yyrecursive context in quitenv (LP#1069428) 2012-10-30 20:07:15 +00:00
tg bfe7d78d40 bring back ${ foo;} sans dot.mkshrc patch, using a temporary file, and as experimental feature 2012-10-22 20:19:18 +00:00
tg 574c024635 introduce MKSH_DISABLE_EXPERIMENTAL and wrap the new feature introduced
in cid 1005084678C510CF7E4 in it
2012-10-22 16:53:22 +00:00
tg c7419d9e6a defer setting exstat for eval to 0 (the one used in case shell() is empty)
until after the stuff run in shell() has had a chance to toy with $?

bug forwarded by one of our packagers, found by one of their users
2012-10-21 21:55:05 +00:00
tg 31f24a4040 add some bounds, for a subsequent commit:
• all writers of exstat ensure the value is in [0; 0xFF]
• all readers of exstat AND it with 0xFF (not strictly needed thus)
• trap_exstat is “safe”, i.e. always either -1 or [0; 0xFF]
2012-10-21 21:39:06 +00:00
tg bebb2d2254 EXPERIMENTAL optimisation for “sh -c 'foo'” to equal “sh -c 'exit foo'” iff
several conditions are met as outlined below; for more background, refer to
http://www.FreeBSD.org/cgi/query-pr.cgi?pr=113860

We don’t yet optimise 「% sh -c '{ echo a; sleep 10;}&'; sleep 1; ps T」 so
the FreeBSD® sh approach cannot work for us, but scanning the “sh -c” argu‐
ment for disallowed characters and, if not, setting a flag that enables the
shell to exec the tree when parsed as TCOM *and not c_trap()* was possible.

Disallowed characters are currently C_QUOTE except space, that is:
Tab Newline " # $ & ' ( ) * ; < = > ? [ \ ] ` |

This should catch all cases of magic, variables, subshells, pipelines, etc.
2012-10-21 21:26:41 +00:00
tg d8662eb228 even more hacks to pass “-O666 -fstrict-overflow -Wstrict-overflow=9 -flto=jobserver” with “gcc version 4.8.0 20120930 (experimental) [trunk revision 191865] (Debian 20120930-1)” ☹ plus make the rtchecks mandatory 2012-10-03 17:24:23 +00:00
tg c39bfe09ee rewrite some code to avoid gcc 4.8 complaining 2012-10-03 16:16:15 +00:00
tg b55d9870e3 reorder notoktomul to have the constant as second argument like notoktoadd 2012-10-03 15:55:37 +00:00
tg 0575d07671 rewrite XPtrV to use size_t instead of pointer arithmetic, for gcc-snapshot (20120930-1) -fstrict-overflow -Wstrict-overflow=9 2012-10-03 15:50:32 +00:00
tg 167995da22 repair choiceless select builtin 2012-10-03 15:13:34 +00:00
tg 9fbdef8e60 pure RCSID sync with OpenBSD, as we introduced SIGWINCH tracking earlier
XXX we could track whether tty_fd has already been successfully opened,
XXX the ttystate initialised, and then just never close it unless it is
XXX necessary, then we can keep COLUMNS/LINES accurate in scripts, even
2012-09-21 17:20:22 +00:00
tg eac85ffdf1 OpenBSD found out that "building argv for $* and $@" manipulates l->argv
in place which affects ps(1) output on BSD; create a new array and copy
the original parts from argv[] there without touching argv passed to main
2012-09-07 21:02:43 +00:00
tg 0415b74436 Update wcwidth data from Unicode 6.1.0 2012-09-01 23:46:41 +00:00
tg e6ddeaa53d sync clog 2012-08-24 21:33:51 +00:00
tg e2d1f3bf99 related to LP#1025843 fix tab completion for tilde
this code is insane, who wrote globbing and expansion for mksh’s
predecessor must have been on very interesting drugs
2012-08-24 21:15:42 +00:00
tg 42ac0dc08e second attempt at getting '$FOO/b*r/baz' tab-completed right,
plus the beginning of the tilde fix… do not use, this is fucking
impossible to get right, but I’d like an archival commit
2012-08-24 20:57:46 +00:00
tg 2ed6e8998c repair globbing $foo/ba*r/baz 2012-08-24 20:05:13 +00:00
tg 84020897fd allow overriding /etc location (LP#1039713), but don’t do it 2012-08-24 19:09:10 +00:00
tg beca8ed86f more int → bool 2012-08-24 19:02:57 +00:00
tg bb5e56d4c4 remove ${ foo;} from mksh again due to buffering issues jilles found 2012-08-17 18:34:25 +00:00
tg f18b1fae85 bump 2012-08-03 18:45:32 +00:00
tg 9b7b7f742e implement ksh93 feature ${ foo;} 2012-07-30 21:37:17 +00:00
tg 0db4002bd6 remove unused flag 2012-07-30 17:04:31 +00:00
tg aedb299057 note that some longjmp don’t handle 0 properly
cf. <500C1B2E.9030602@zytor.com>
2012-07-22 15:56:51 +00:00
tg 058e7f8ed4 do implement quoting, as ${foo@Q} though, as hommage at mirmake
dedicate this “release” to Andi
and use tomorrow’s (UTC) day for version, to cover up my debian fuckup
2012-07-20 23:22:13 +00:00
tg 4778a2a62f lesson learned from http://k1024.org/~iusty/blog/entry/perf-null/ – add -DMKSH_SMALL_BUT_FAST which gives more speed (8/20K less cycles, 5/9K less insns, 1.8/2.4k less branches, 65/275 less branch misses) on Debian/amd64 (klibc-static/eglibc) at cost of 0/2 more page faults and 6K/6K more text size 2012-07-01 15:55:00 +00:00
tg 516678f4fd imply MKSH_CONSERVATIVE_FDS by MKSH_LEGACY_MODE, too 2012-07-01 15:44:31 +00:00
tg 35c65bb568 bugfix: make CONSERVATIVE_FDS implied by MKSH_SMALL actually work 2012-07-01 15:41:56 +00:00
tg 67714b270a dissolve the hashtab nonsense, ¾ is good, and mirkev will also use that 2012-07-01 15:38:09 +00:00
tg c1f821d4e5 (mksh) tighten 32-bit requirements; (lksh) switch to long; allow any bitness 2012-06-28 20:17:39 +00:00
tg ea01d80833 hackish work-around the lexer to make alias definitions in mksh -c
work (Closes: #517009) and mention in the manpage why they sometimes
do not work (doing so for COMSUBs is not worth the effort)
2012-06-28 20:05:11 +00:00
tg dc5ae267ce make tempvar() and vtemp global 2012-06-28 20:02:29 +00:00
tg 45fba44292 sync w/ oksh (RCSID only # no change needed) 2012-06-28 20:01:01 +00:00
tg 1fa4453946 mh… all I’m gonna hack on upstream today… fix -t for manpage generation and cleanup code snippets; bump vsn; sync clog 2012-06-26 19:33:33 +00:00
tg c212458922 bump for mksh with lksh-except-long, so we get the ball moving 2012-06-26 18:11:05 +00:00
tg 967e929e98 add basic LEGACY KSH mode (Build.sh -L), no changes yet 2012-06-25 16:05:10 +00:00
tg 6f1078606e bump after dealing with all things Benny had Coverity find
remainging CIDs not listed are either

• false positive (bug in coverity)
• intentional (possibly with lint override coverity doesn't parse)
• VLA (XXX find out how to mix C99 and ANSI VLAs)
• things flagged as possible resource leaks I have no idea about
  (no biggie though, and only in error cases I think)
2012-06-24 20:39:26 +00:00
tg 3125146b43 Fix typeset issues (LP: #993847)
This was actually more evil:
• use a recursive function to display blocks in reverse order,
  so that local variable values overwrite global ones
• add array support to typeset -p (from typeset -p -)
• display 'set -A varname' line before setting values, for -p
• if -p got arguments, only display those (from the innermost scope)

Also, the usual amount of code cleanup…
2012-05-09 23:21:00 +00:00
tg ea8f29f428 sprinkle CONSERVATIVE_FDS for many older OSes; DISABLE_TTY_WARNING for BeOS and Coherent (probably more to come); NO_CMDLINE_EDITING to Plan 9; put Hurd NO_PATH_MAX into MKSH__ private namespace 2012-05-05 17:37:44 +00:00
tg f34cae3997 keep up 2012-05-04 22:44:34 +00:00
tg e6ace01f12 last parts of Coherent patchkit: O_ACCMODE and termio 2012-05-04 22:18:27 +00:00
tg fef3808126 more symlink(7) nonexistence support code 2012-05-04 22:05:02 +00:00
tg 7beac6668d provide for Coherent not having gettimeofday(2), imake style (bad, but this is not for others to use without a second thought anyway) 2012-05-04 21:47:04 +00:00
tg 2d31aca859 more int→bool while trying to let ^D output CR+LF (which shan’t be, oh my…) 2012-05-04 21:15:34 +00:00
tg 5780bc5eb7 new MKSH_NO_CMDLINE_EDITING to disable command line editing in its entirety
mainly for the Plan 9 port though it may also help the WinAPI variant,
other porting efforts, as well as a new project I cannot say yet
2012-05-04 20:49:08 +00:00
tg 7c4bf78446 move bi_getn from misc.c to funcs.c and make it static
even antique gcc versions will usually inline it now
2012-05-04 20:08:25 +00:00
tg b67de6ba17 add experimental code to use sigprocmask+pause+sigprocmask ipv sigsuspend (and harden j_sigchld handler for that) to improve working on BeOS 5.0 and Coherent UNIX, found by RT 2012-04-27 16:16:23 +00:00
tg 5204e7cc4f after discussion with ciruZ, switch mksh from NZAT to NZAAT fully
to get rid of the bias introduced by making the hash never zero

… he also pointed out a memory (heap) usage optimisation… which
may impact code size a bit though as I’d need to pass an additional
argument on hashtable function calls… or, forgo the benefit of not
having to pointer-align the key in the structure, which can be as
much as 3/7 octets per item, heap storage… OTOH the saved space is
4/8 octets per not-allocated item, possibly some code (use of an
multiply-add opcode), but the function call overhead/cost would
possibly be quite a bit… I guess I’ll have to measure…
2012-04-22 21:50:35 +00:00
tg 5eea59ad57 rewrite maketemp() obsoleting tempnam(3) and mkstemp(3) external deps 2012-04-14 16:07:48 +00:00
tg 70e6988d25 factor out rndget() code, for adding users
XXX in the future, the entire scheme must be rethinked when we need more
XXX entropy for the hash tables; possibly a cheap add using NZAT and re-
XXX initialise the LCG only on access and when added (so keep NZAT state
XXX separate from LCG state); also, then we will need a more elaborate
XXX scheme, such as adding from environment, editor keypresses and timing
2012-04-14 14:35:13 +00:00
tg b49abfac18 genericise MKSH_NO_SIGSETJMP 2012-04-14 14:07:47 +00:00
tg 29e4269f33 if the OS does not provide sig_atomic_t and/or ssize_t, you can now define
MKSH_TYPEDEF_SIG_ATOMIC_T and MKSH_TYPEDEF_SSIZE_T via CPPFLAGS to the
*correct* definitions (it’s absolutely critical they be correct!)
2012-04-14 14:02:40 +00:00
tg 5b4d0dbbc5 drop all deprecated code, you have been warned 2012-04-07 11:19:53 +00:00
tg 5d4492608a more speling 2012-04-06 15:23:11 +00:00
tg 3d3081115b if LDSTATIC is not empty (i.e. "-static" or " "), always add “our” sources:
• strlcpy
• utf_wcwidth
note strchr/strstr from misc.c are still #ifdef DEBUG only, as they are
not eligible: they’re for const-cleanliness debugging purposes

XXX get rid of multiple occurrences of binary search code, too…
2012-04-06 15:20:42 +00:00
tg 981ad02dbe drop str{,n}casecmp, too 2012-04-06 13:29:01 +00:00
tg 4a89ae1cd0 drop the need for strcasestr: just uppercase a copy and compare with uppercased 2012-04-06 12:59:28 +00:00
tg 6faa68ff8b LynxOS defines PRINT somewhere, undef it 2012-04-06 11:51:43 +00:00
tg e67b98e21b use _setjmp/_longjmp on NeXTstep: its Intel port always restores the signal mask on siglongjmp, which we never have 2012-03-31 17:30:00 +00:00
tg cf75e7b6ce couple of minor/cosmetic fixes from RT’s compile farm:
• promote SCO OpenServer and UnixWare to !oswarn
• omit trying -O2/-O on OpenServer 5 and USL C
• cast mksh_ari_t to int, mksh_uari_t to unsigned int for printf
• skip ulimit-1 on syllable (which is still too broken)
• write ((mksh_ari_t)-2147483648) ipv UB ((mksh_ari_t)1 << 31)
  and add a comment that that is actually meant
• rewrite functions returning !void ending in NOTREACHED
  so they’ve got a jump target returning an error at the
  end, to aid older compilers and just to be safe
• cast struct stat.st_size to off_t or size_t explicitly when needed
• shorten struct env by two bytes and an alignment, at least

also, optimise control flow and fix more paren matching cases
2012-03-29 19:23:01 +00:00
tg 45fa321c23 fail in a clean way even on b0rken compilers 2012-03-28 23:09:24 +00:00
tg c4a4b8b275 I don’t know what those compiler authors were smoking… 2012-03-28 11:05:16 +00:00
tg 6dd03ddfad pass the version to avoid stale Makefile.inc files 2012-03-27 23:13:42 +00:00
tg 16ac73b074 g/c magic definitions for simple chars (as opposed to e.g. tokens/lexems)
some (such as NOT) were already gone; this should unconfuse; most were
unused anyway…
2012-03-27 22:58:39 +00:00
tg 2a47cab08f add a note that mksh_{,u}ari_t are, sadly, not currently configurable 2012-03-27 22:49:47 +00:00
tg 340cd95cf0 #undef flock (LP: #912691) 2012-03-27 22:41:17 +00:00
tg 95a2c63096 • implement fcntl(2)-based advisory locking as an alternative iff flock(2)
is not found, from a suggestion by RT (LP: #912691)
• try harder (in a loop) to acquire a file lock if the locking mechanism
  documents EINTR is a possibility (fcntl always, flock on Linux not .Ox)
• use -std=c99 not -std=gnu99 if it must be at all
2012-03-27 22:36:53 +00:00
tg e3b9f14d88 You have this ↓ guy a lot to thank for.
00:45 -!- variable [root@freebsd/developer/variable] has joined #!/bin/mksh

• +b *!*root@*, +b $a:root, +b $r:root on one more channel
• certain checks to prevent:
00:47 < variable> wjcw: sh.h:308: error: conflicting types for 'getrusage'
01:19 < variable> oh
01:19 < variable> I needed to run Build.sh
2012-03-27 21:23:52 +00:00
tg 4f8b7de3a9 Susv3mon says: rlim_t are unsigned 2012-03-26 21:10:44 +00:00
tg 87654270ab fix regression w.r.t. TTY and external programmes:
• release the TTY after the initial change_winsz()
• since we release it, we can skip initialising tty_state, too
2012-03-25 14:28:14 +00:00
tg 1f96d87aea • MFC almost everything not breaking backwards compatibility or introducing
deep changes into R40-stable branch
• Version accordingly: HEAD gets 2012/03/24 (hi Eddy/Chris) so we backdate
  $KSH_VERSION for R40-stable to 2012/03/20 (hi David) as that comes before
  even though it includes today’s latest fixes
• Also, sync clog (including MFC indicators)
2012-03-24 21:22:25 +00:00
tg 21c15c0b8f huh, I thought I had extended ${parameter@#hash} already; make it so now,
but not yet things like ${parameter@Fi} (1 if integer, 0 otherwise), etc.
also bump patchlevel and © years in recently changed files
2012-03-23 23:25:30 +00:00
tg 24e8a6996b always keep x_cols and x_lins valid; check once at start including tty init
if we find any, but not later; do not check on every read

⇒ allows changing COLUMNS and LINES (independent of each other, or both)
  for script shells by passing them in an environment setting, even if
  we get a tty; interactive shells still check before each line is read…

reported by the PLD guys, thanks
2012-03-23 21:58:24 +00:00
tg 3795e667c5 drop use of the NOT macro, [^foo] ≠ [!foo] anyway, and we’re not gonna change that 2012-03-23 20:07:13 +00:00
tg c5cc22a13f efficient debug-to-file output (/tmp racy, but hey) 2012-03-23 19:38:12 +00:00
tg e141394a83 RCSID sync from oksh; reduce hash table #elements if !MKSH_SMALL to speed up 2012-03-03 21:30:59 +00:00
tg 929bc9ee9e make jobs reporting deal with UTF-8 (in utf8-mode)
reported by Andrew Kudryashov, 10x
2012-02-06 17:42:24 +00:00
tg bee3bbaaf8 reduce stack usage a bit (several candidates for more, including $CC itself…) 2012-01-29 01:41:15 +00:00
tg ac29bad3fe fix regression escaping single-char strings 2012-01-04 19:09:36 +00:00
tg 8a8535b321 oeps… 2012-01-03 01:01:44 +00:00
tg 2578c66b61 move linkage check (which uses sh.h INCLUDES_ONLY) to when all of its
prerequisites are actually fulfilled, i.e. evrn further down than with
the last commit doing this, and move some prerequisites of stuff that
has wandered outside the !INCLUDES_ONLY block with the compile-time
assert changes to the outside, too

fixes FTBFS on MSYS which has neither <stdint.h> nor uint32_t
reported by RT
2012-01-03 00:58:09 +00:00
tg d5edc79f5a gc-sections found size optimisation chances 2011-12-31 00:27:27 +00:00
tg da9ce25524 put a bit of type safety into the history code 2011-12-30 21:00:32 +00:00
tg 31bf077591 don’t clobber the tree used for printing IOACTs in process_TIF (LP: #907224) 2011-12-29 23:36:25 +00:00
tg 4af399bd8d give dumptree an dumpioact helper 2011-12-29 22:54:22 +00:00
tg 7b89945505 use sane spelling of read-only consistently 2011-12-16 20:03:28 +00:00
tg 44c408f9ac shuffle caddr_t to its only user, and use (void *) on Linux instead,
to appease Fefe’s dietlibc [-Wdeprecated-declarations]
2011-12-10 14:12:17 +00:00
tg 3b87d173d4 • finally, the code and manual page text to deprecate, and code to not
handle any more, octal 010 style constants, as promised
• overhaul the manpage re. arithmetic expressions, make the guarantees
  mksh code has explicitly, precisely, clear
• to reduce burden of the compiler, getint() now operates on mksh_uari_t
  internally; it already applied the sign after operation, anyway (C99
  guarantees wraparound on unsigned types, but for signed types we need
  specific compiler support; apparently, this comes from hardware limits)
• use const and shuffle order of locals around while here
2011-12-10 13:34:19 +00:00
tg f8098a7f48 actually catch out of [1;36] bounds integer bases 2011-12-09 20:40:26 +00:00
tg da83890648 move compile-time assertions out of misc.c(#ifdef DEBUG) into Build.sh 2011-12-03 00:01:28 +00:00
tg 1ac636670f • improve comments
• do shave off 20 bytes from c_test() and get rid of the ugly stack
  variable and double “using” despite not parsing
2011-12-02 22:55:49 +00:00
tg 2fb9df56e4 rewrite funcs.c:c_test(), i.e. test(1) and [(1), to follow POSIX and XSI
in the cases where they are defined unambiguously; bug reported by
Jilles Tjoelker in <20111129232526.GC14357@stack.nl> due to a report
by Stefano Lattarini on bug-autoconf

in the ambiguous case, I stick to traditional pdksh behaviour, which means
	test ! a = b	vs.	test a = b
and
	test ! a -o b	vs.	test a -o b
behave different from each other (in the second case, the NOT operator
binds strong; POSIX demands a reduction to 3 arguments and negating
that result in the first case), so we're at two known not-ok in the
FreeBSD® testsuite. (81 and 82 in regress.sh,v 1.3)
2011-11-30 21:34:15 +00:00
tg 0695039dc0 fix stateptr-underflow; really do call fastbox regression checks; bump vsn 2011-11-26 00:45:21 +00:00
tg dd014625e1 Fix regression introduced by mixing the recursive parser and support
for ;| and ;& in TCASE: ;;-less last casepart produced ";\0" in the
SREREAD string which obviously cased reparsing to fail

test from http://www.in-ulm.de/~mascheck/various/cmd-subst/
2011-11-22 18:01:41 +00:00
tg d7079f3f0e bump 2011-11-19 21:22:02 +00:00
tg e20b1295b7 promote x=(a b); x+=(c) to standard mksh functionality at cost of 932 MKSH_SMALL .text bytes on MirBSD/i386 2011-11-11 22:14:19 +00:00
tg 90afc54ee8 • select(0, …) misbehaves on Interix (by Markus Duft <mduft@gentoo.org>)
• select(n, NULL, NULL, NULL, …) behaves the same (by Bruno Haible)
2011-11-09 22:17:26 +00:00
tg c620f865c1 cid 1004E0F5C27271F5B00 broke integer-base handling of built-in parameters
mksh -c 'echo a=$RANDOM; RANDOM=0x12; echo b=$RANDOM' # behaviour changed
2011-11-08 22:07:15 +00:00
tg 92b60a9a5e forgotten in cid 1004EA5BF612F516747 to take '\n' presence as $'…' quoting reason 2011-10-26 20:46:16 +00:00
tg fed31331f4 rename more identifiers with trailing underscores 2011-10-25 22:36:39 +00:00
tg cd7dab250b also Xcheck_grow_ may not end with an underscore 2011-10-25 22:25:07 +00:00
tg 5893a36bad document “export -” accident found by Snader_LB 2011-10-24 19:41:13 +00:00
tg d6bf9c197b better handling of eval and CPPFLAGS in build system 2011-10-07 19:51:44 +00:00
tg 9782f6b4d1 • access(2) is broken in at least kFreeBSD 9.0 as “modern” OS, so bring
back the wrapper code as well as refactor most other code calling it
• apparently, names can’t end in ‘_’ or contain ‘__’ anywhere…
2011-09-07 15:24:22 +00:00
tg 577c918beb patch most of Jerker Bäck’s concerns out, unless not applicable 2011-08-27 18:06:52 +00:00
tg 5d9c88ceeb jg71 reported -DMKSH_ASSUME_UTF8=* breaks defining stristr 2011-08-27 17:30:07 +00:00
tg 308290e2b6 dict.leo.org says this is correct 2011-08-13 22:19:41 +00:00
tg 80223417d7 followup fix for 1004D90467358D6B13C regarding escaped substitutions
found in, out of all things, Debian/m68k, by Wouter Verhelst (Yoe)
fix hacked at DebConf 11, Бања Лука, Република Српска, Босна и Херцеговина
2011-07-26 16:57:28 +00:00
tg a7566387cf optimise an if away, and possibly even the function bodies… 2011-07-20 23:47:29 +00:00
tg 6ce68e906f now that I got Hash.cs compiled and run, I’m amazed; make NZAAT (and NZAT!) all green with a small tweak; bit distribution and χ2 look OK as well 2011-07-18 00:35:46 +00:00
tg 09db3d67a2 finish merging from R40-stable; set version number to yesterday though 2011-07-16 17:08:52 +00:00
tg e03b485d75 ‣ merge from mksh R40-stable
move /etc/{,suid_}profile to /system/etc/ for Android (but do not make
the location of /etc configurable); rewrite manpage section about
/etc/{,suid_}profile, .profile, .mkshrc
2011-07-16 17:08:21 +00:00
tg 8d1edbd95e ‣ merge from mksh R40-stable
use common macro bodies shf_{get,put}c_ for definition
of shf_{put,get}c as functions (MKSH_SMALL) or macros, respectively
2011-07-16 17:07:35 +00:00
tg a4a000eafb take down the entire xterm (or GNU screen tab), hard, with:
mksh-R40 -c 'x=$COLUMNS; awk "BEGIN{exit(1)}"'
10x to the PLD Linux guys for spotting _and_ bisecting this!
2011-07-07 20:24:53 +00:00
tg 3ef67e3296 replace uses of OAAT hash in all its variants by NZAT (mksh internal) or NZAAT (all others) 2011-07-06 22:22:02 +00:00
tg f2405b7dde • bump patchlevel to today’s
• while here, reformat 'struct tbl' comment-wise and placement-wise
  and drop the Tflag typedef
• while here, write regression test for the "global" built-in, which
  does what typeset is supposed to do except that it doubles as "local"
2011-07-05 20:12:20 +00:00
tg 0739fa74a0 address "env RANDOM=1=2=3 mksh" DoS by integrifying more 2011-07-02 17:57:41 +00:00
tg edaab2cafe tabcomplete ~ and ~foo like $FOO (idea by yofuh) 2011-06-30 13:48:13 +00:00
tg 43c8d8765f pretty tricky thing, IBM’s curses library does nameref foo=foo… 2011-06-21 21:50:26 +00:00
tg c57f8ede17 make set_refflag an enum to get easier to understand code 2011-06-21 21:11:21 +00:00
tg fab3be3584 re-indent comments 2011-06-21 21:10:12 +00:00
tg 7ce3a2ad54 HP-UX aCC suggested more “≠ 0” and parenthesēs 2011-06-12 14:58:45 +00:00
tg 6571d66386 add missing shf_flush() before prompting 2011-06-11 03:14:50 +00:00
tg e0fb8dc431 • rework hash table interna to avoid gcc-4.1 on Debian etch bug
• also improve behaviour with _a lot_ (>2²⁸) entries
• while here, improve comments and whitespace
2011-06-05 19:58:21 +00:00
tg ebb8bed911 fix segfault due to limit of hashtable entries (global variables) discovered by Jb_boin: unlimit to 2^30 minus epsilon 2011-06-04 16:42:31 +00:00
tg b3d38f9cdf better parsing for x=(…) – bug noted by Frank Terbeck 2011-06-04 16:11:20 +00:00
tg d1b8800ee8 • AIX: display OS version better (tested on 5.3 by cnuke@)
• IBM XL C: display version better (tested on V7.0 by cnuke@)
• do not 'IFS=: read nr name', Cygwin 1.7 dash fails it
• disable cd-pe, glob-range-3 on Cygwin (the former cannot
  succeed because the mv fails, the latter fails from 1.7 on)
• mark heredoc-tmpfile-8 as need-pass: no
• apply __attribute__ only to a function prototype, not to
  the body (even if static), since xlC fails that
• bump version to R40 (beta)
2011-05-29 16:31:42 +00:00
tg 2cfc3e5c3d mksh R40 Release Candidate 1
Testsuite:
• add new need-pass: {yes|no} attribute, default yes
• exit with 1 if a need-pass test failed unexpectedly
  idea by Kacper Kornet <draenog@pld-linux.org>
• mark utf8bom-2 as need-pass: no
Infrstructure:
• add housekeeping function for making a tty raw
• switch functions with unused results to void
• struct op: u.charflag contains last char of ;; in TPAT
• var.c:arraysearch is now a global function
Language:
• add ;& (fall through) and ;| (examine next) delimiters
  in addition to ;; (end case) as zsh extensions, because
  POSIX standardised on ;& already
• add -A (read into array), -N (read exactly n bytes),
  -n (read up to n bytes), -t (timeout) flags for read
  from ksh93
• allow read -N -1 or -n -1 to slurp the entire input
• add -a (read into array the input characters) extension
  specific to mksh to read, idea by David Korn
• add -e (exit with error if PWD was not set correctly
  after a physical cd) to cd builtin, mandated by next
  POSIX, and change error codes accordingly
Rewrites:
• full rewrite of read builtin and its manpage section
• add regression tetss for most of the new functionality
• duplicate hexdump demo tests for use of read -a
• use read -raN-1 in dot.mkshrc to get NUL safe base64,
  DJB cdb hash and Jenkins one-at-a-time hash functions
2011-05-29 02:18:57 +00:00
tg 3f21a0e199 • add patch from Robert Luberda <robert@debian.org> fixing the
four-argument form of test (yet again…), thanks
• drop the obsolete (pre-POSIX) form “test -t” without fd
2011-05-06 15:41:25 +00:00
tg c021aa4cad • use a flag for determining here strings, don’t parse delimiter every time
• don’t leak memory parsing possible I/O redirection tokens
• get rid of volatile by using more const (also helps codegen, methinks)
• support empty here document markers (mksh extension)
• pimp the manpage
2011-05-05 00:05:01 +00:00
tg 69f98bca9a • fix wtf(1) by keeping the paren in ${foo#\(} properly escaped in COMSUB
• merge tputS and wdstrip_internal
⇒ net save: 604 .text 0 .data 0 .bss (MirBSD/i386)
2011-05-02 22:52:54 +00:00
tg 8bc51681b1 sync clog 2011-04-22 21:44:35 +00:00
tg 45cd3a340b this is about the amount -Wl,--gc-sections can help me to eliminate 2011-04-22 12:21:55 +00:00
tg 6c0255ecb2 more static initialisers (verified using nm comparision between mksh
built with/-out "-ffunction-sections -fdata-sections -Wl,--gc-sections"
2011-04-22 12:15:42 +00:00
tg 61a8888213 always catch SIGALRM even in non-interactive shells to make sleep work 2011-04-17 12:24:44 +00:00
tg 6c45e3e764 avoid namespace conflicts with __attribute__(…) 2011-04-09 21:01:03 +00:00
tg e39dea490f sync… various things 2011-04-09 18:47:14 +00:00
tg d57a033057 • no longer use <stdbool.h> even if it’s available
• ensure that bool/true/false are cpp macros, overriding any pre-defined
• document the requirement that tobool(x) must map any-type 'x' into bool
• document the requirement that a bool must only be true or false, and
  that it (tobool() rather) must have an identity mapping to 'short'
• possibly fix ksh_func for/and fpFUNCTf – maybe spotted by cnuke@
2011-04-09 15:14:55 +00:00
tg 63a08586be easier debugging with HAVE_STDBOOL_H=0 for if bool is indeed built-in 2011-04-09 14:58:53 +00:00
tg 7d3643d7b4 skip the UTF-8 BOM early, then check the magic (ELF, a.out, COFF, …) 2011-04-02 10:30:11 +00:00
tg 19e128c4e1 add testcases, bump vsn 2011-03-28 08:40:42 +00:00
tg e8ea9954aa • Implement http://austingroupbugs.net/view.php?id=367 and align things
a bit more with POSIX and the other shells

I considered http://austingroupbugs.net/view.php?id=253 but the use
of bi_errorf() is interesting, especially as it’s often enough a
noreturn function, and funnily enough, 'cd -P /foo' returns 0 while
'chdir -P /foo' fails (so idk where to put -e)…
2011-03-27 18:50:06 +00:00
tg ad3707d17d don’t leak memory (pdksh did), and forgot a hunk 2011-03-27 01:30:38 +00:00
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
tg 7fdc42cead fix realpath builtin’s handling of (source) pathnames with a trailing slash
as per POSIX (if a trailing slash is part of the symlink target it fails as
well, like GNU readlink -f does)
2010-08-24 14:42:04 +00:00
tg 23f3f58d14 on MirBSD we can use the system wcwidth() and save ~800by on the ramdisc 2010-08-14 21:35:13 +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 befbed2859 int → bool 2010-07-24 17:08:30 +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 c6eedad976 *sigh* this code is interesting: assume you want to output via shf to
a string buffer whose window size is currently 32 (initial), your data
is 96 bytes, this routine used to resize the buffer to 64, append your
first 64 bytes to it (no matter if there's already something in it)
and then writes the remaining bytes to stdio fd instead of the string…
if it doesn’t SIGABRT before

discovered by wbx@ – thanks – bug inherited from pdksh 5.2.14 (AD 1999)
2010-07-19 22:41:04 +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 6b006202a1 partial oksh sync (RCSID and do add some parenthesēs to the list of
reserved words, but really only these which are only recognised at
the beginning of a line as the context says, not blindly all of them)
2010-07-13 13:12:32 +00:00
tg a6c81ea978 on obsd/mbsd, entropy is cheap enough for us to do this (codepath in
kernel checked for both) for additional seeding ($RANDOM is still from
the LCG only)
2010-07-11 11:17:33 +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 4cbb5a9d46 to speed up mksh, get rid of arc4random(3) uses and use the LCG always;
depend on ASLR for seeding
2010-07-04 17:33:58 +00:00
tg 2d6b4acba1 simplify a bunch of things (no SIGWINCH handler, errno is saved for
an shtrap automatically) and gratitutous reformatting of comments
2010-07-04 13:36:43 +00:00
tg 747b27a846 apply diff from manuel giraud via oksh to keep track of LINENO in a trap 2010-05-22 12:49:16 +00:00
tg f24e2c80a9 disallow some more kinds to trim a vector; Debian #581867 2010-05-16 19:04:42 +00:00
tg 01a0d1104a address two performance issues in do_realpath():
• avoid calling realloc twice in sequence, since the final
  size is known at the first call already
• do not lstat(2) the same path twice in the Hurd codepath
2010-04-27 21:39:09 +00:00
tg 6e98fbe27b Fourth time’s a charm… another bugfix related to the commitids
1004BBDD84556472D84, 1004BBF77B81D30DA7C and 1004BBF7CD656308A1C
to unbreak kwalletcli
2010-04-20 09:10:07 +00:00
tg 14ea7e9038 draft a testcase to understand the problem fixed by cid 1004BBF77B81D30DA7C
and make it actually work: the OpenBSD fix failed since 1004BBDD84556472D84
2010-04-09 19:16:31 +00:00
tg ff9f89f22f Fix two more POSIX conformance bugs and minor documentation/comment issues 2010-04-08 13:21:08 +00:00
tg 401e262689 fix another expand-ugly SUSv4 bug 2010-03-27 16:53:17 +00:00
tg 98e43b0f7a rework ‘m’ and ‘v’ ulimits; add more (seen at zsh) 2010-03-27 16:51:39 +00:00
tg 50f081c369 even better on Haiku:
* let ulimits work
* add a Haiku-specific ulimit
* always use UTF-8, they have no locales but a UTF-8 terminal
2010-03-14 11:58:33 +00:00
tg e5e6857c43 (hopefully) fix the substitution thing for good 2010-02-25 20:18:19 +00:00
tg 150a35a02d x_bind cannot have the nonnull attribute
cought by Frank “enstein” Terbeck «ft:#grml» (efftee), 10x
2010-02-23 18:13:04 +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 566f882d83 Add some assertions – mkssert() – for things clang’s scan-build can’t see 2010-01-28 20:26:52 +00:00
tg 17b04f3879 No, __attribute__((used)) with SUNWcc on MirBSD still won’t work… 2010-01-28 15:13:25 +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 f3b3b4b1fb remove some debugging code 2010-01-25 14:38:04 +00:00
tg 559125f5f9 RCSID sync (oksh bumped their array limit again… wonder when………) 2010-01-16 19:08:05 +00:00
tg 833810a154 While we were supposed to use Ctrl-Arrowkey for wordwise jumping,
some idiotic terminal emulators and/or people seem to use the es-
cape codes normally denoting Alt-Arrowkey instead so let's simply
bind them to the vt_hack as well... (untested)
2010-01-08 22:21:06 +00:00
tg 6115f5a91c • re-implement wcswidth-like behaviour for ${%foo} even in !UTFMODE
• merge the rest of branch tg-wcswidth-behaviour
• enhance test cases for wcswidth-like behaviour
• switch hash table collision resolution algorithm to Python’s as announced
• bump vsn
2010-01-01 17:44:10 +00:00
tg c413edb34a jobs.c: apply patch from deraadt@o:
│remember to restore errno (ie. stop someone from making a mistake later)
│ok guenther
check.t, sh.h: bump vsn

I wonder though why errno must be restored even if nothing was
called after reading it… moid?
2009-12-31 14:05:44 +00:00
tg 769e222586 re-vamp __attribute__ handling; let this pass on HP-UX bundled compiler
as well as HP aCC
2009-12-12 22:27:10 +00:00
tg 65a3713605 strchr related fixes 2009-12-05 22:19:42 +00:00
tg 8213a28403 llvm/clang scan-build is now content… 2009-12-05 17:43:50 +00:00
tg 417fd60c76 * fix 'set -A foo -- [2]=a b c' contingency (tested against GNU bash4,
which, in its latest sid incarnation, even received mksh's ability
  to produce ${!foo[*]} array keys, wow!)
* plug a memory leak while here (ATEMP only, but still)
2009-12-01 19:15:35 +00:00
tg 24b48aeb3f this better be const, too 2009-11-29 17:37:22 +00:00
tg fa3acb939b fix 'mksh -U -i' and 'mksh +U -i' 2009-11-28 15:38:30 +00:00
tg a09f05e77a /me is annoyed
I read, IIRC in the Cederqvist, that 'cvs tag' sets a sticky tag onto
the cwd… it doesn’t, apparently. (I actually like it better this way,
but one needs to know!)
2009-11-28 14:28:03 +00:00
tg 883d9d99b3 switch ${%foo} to wcswidth-like behaviour – slightly problematic, and
the “set +U” case isn’t even handled

committed to branch because I’d like to get more input on this, for now
2009-11-28 14:21:47 +00:00
tg 4cff10296b bump vsn 2009-11-22 14:25:18 +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 fe853065bb make print_columns() aware that octets≠characters≠columns 2009-11-09 23:35:11 +00:00
tg 6fcacf577d make tab completing filenames with ':' '=' '$' '`' work as well as
others (colon and equals sign need to be simply escaped, while dollar
sign and accent gravis need double escaping like opening square brak-
ket did back then); add = to C_QUOTE to simplify (doesn't break any-
thing) and sort these strings asciibetically while here
2009-10-30 00:57:39 +00:00
tg dc98ec23a6 do not use PATH_MAX on GNU/Hurd (even if it *was* defined), but use
some glibc-only functions that don’t require its use instead

tested on gnubber, where (admittedly) sysconf(_PC_PATH_MAX) == 1024…
2009-10-27 17:00:02 +00:00
tg ceb591bf6a • better IV for the oaathash-on-binary (as if we prepended a '\x01')
• better variable name for the LCG state
2009-10-18 12:30:06 +00:00
tg eafe88aa74 • overhaul handling of special variables
• use a combination of the one-at-a-time hash and an LCG for handling
  the $RANDOM special if !HAVE_ARC4RANDOM instead of rand(3)/srand(3)
  and get rid of time(3) usage to reduce import footprint
• raise entropy state (mostly in the !HAVE_ARC4RANDOM case though…)
• simplify handling of the $RANDOM_SPECIAL generally
• tweak hash() to save a temp var for non-optimising compilers
• some int → mksh_ari_t and other type fixes
• general tweaking of code and comments
2009-10-17 21:16:05 +00:00
tg 578d4e6314 fix exit-eval-1 (Debian #550717), sync SUSv4 wording, improve comments 2009-10-15 16:36:27 +00:00
tg 549888a183 while testing haserl-0.9.26 on MirBSD, I discovered that the echo builtin
in FSH mode did in fact, contrary to POSIX and Debian Policy 10.4 behavi-
our (I think), interpret escape sequences; fix and add testsuite for echo
2009-10-10 21:17:31 +00:00
tg 73147a7fe9 fix lazy evaluation of assignments in ternary ops 2009-10-04 13:19:33 +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 ff8b75f46f SUSv4 says that there be exit 127; the old code tried but failed, so it
was an actual programmatical bug…
2009-09-29 12:28:13 +00:00
tg 7b7b75b026 * move the utf_* functions to a smaller file, to reduce the pain the
CPU has to endure while gcc is crunching on edit.c
* comment on mksh not using _exactly_ OPTU-8/OPTU-16 (XXX)
2009-09-26 04:01:34 +00:00
tg a59d14b565 further optimise and simplify the handling of $RANDOM, reads and writes
to it are now either arc4random or rand/srand, but srand retains the old
state; set +o arc4random is no longer possible, but if it's there we use
arc4random(3), if not, we use rand(3) for $RANDOM reads; optimise special
variable handling too and fix a few consts and other minor things
2009-09-26 03:40:03 +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 1ea1096a4e Add a hack input function for VT100-style key sequences; support
Ctrl-CurLeft and Ctrl-CurRight (not quite ANSI, but fits the scheme)
2009-09-20 17:23:52 +00:00
tg 588921333e more of this:
• shell flags are now handled in one single place (sh_flags.h)
• sync comments (between enum and array) and manpage with reality
• FMONITOR is now no longer needed for Hartz IV shells
2009-09-20 16:40:58 +00:00
tg 3630e1f7dc only one digits instance, thank you very much 2009-09-20 13:08:12 +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 c8eb13a13f align with C standard (optional C style); document differences to C style
for print builtin (align with ksh93 ipv GNU bash)
2009-09-19 19:08:48 +00:00
tg e0f000fb83 new function unbksl doing "backslash expansion" independent of c_print();
also make a separate subsection about it in the manpage
2009-09-19 15:16:05 +00:00
tg 3639137e48 another ksh93 feature: test -o ?foo (almost zero cost) 2009-09-07 17:24:49 +00:00
tg 9dd98da40d Support Dave Korn’s alternative 「'a'」 (or 「'…'」) form for base-one
integers in addition to my 「1#a」 (or 「1#…」), which also allows for
finer end-of-character checking. Note that this is locale-dependent in
ksh93, set ±U dependent in mksh, and mksh’s OPTU-16 encoding is used.
2009-09-06 17:55:55 +00:00
tg 9531e12b36 merge the nameref code, using mksh standard scoping as discussed 2009-09-06 17:42:15 +00:00
tg 4a4be7d313 add the chdir builtin from mircvs://contrib/hosted/tg/deb/mksh/ for
better dash compatibility (mksh is now a dash superset if printf is
compiled in)
2009-08-30 21:02:01 +00:00
tg e622d80394 replace pdksh’s get_phys_path() and do_phys_path() with my new
do_realpath() function – looking fine, review welcome though
2009-08-30 13:30:08 +00:00
tg 31e02e59f7 add a do_realpath() implementation replacing the use of the external
libc function realpath(3) which may not be available on the target
system; compile the realpath builtin unconditionally

looks fine to me, but review is appreciated; this is (very) lightly
based upon MirBSD libc’s realpath(3) and pdksh’s get_phys_path()
2009-08-30 13:22:39 +00:00
tg 09abc55150 documentation and test suite for tonight’s new features, ☾ gn8 2009-08-28 22:46:21 +00:00
tg 4e5553bcb4 fix type (array indices should be of the unsigned arithmetic type) 2009-08-28 22:23:34 +00:00
tg 1fd4515528 optimise 2009-08-28 21:07:27 +00:00
tg 7cb17b16a0 more int→bool 2009-08-28 21:04:18 +00:00
tg 9b8d4023fa … but since I liked the bonus of having the hval stored so much, merge
it with the array index; var.c says that
│ 1244         /* The table entry is always [0] */
so that we can have a special flag and a union which stores hval for
the table index, the array index otherwise (coïncidentally *hint hint*
they have the same size)
2009-08-28 21:01:27 +00:00
tg bb7a720a00 for now, until we really use kt*() otherwise, ifdef out tablep/hval 2009-08-28 20:38:43 +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 cd7f3fd836 another int→bool 2009-08-28 19:16:17 +00:00
tg 2cda4dd7bb this wants a size_t (but ssize_t is enough, since order(size_t) elements
is pretty much impossible… I estimate at most a million, but not more
than 16 million, array or keytab entries)
2009-08-28 18:59:01 +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 8f937ec71b shuffle fields of struct tbl around for better padding results 2009-08-28 18:33:05 +00:00
tg 0e1266ef90 While mksh R39 builds fine on MirOS #7s8E on my trusty sparc, pgcc 2.95.3
throws out quite some warnings – fix most of them except most emitted via
-Wconversion; work around some others; discard bogus warnings.

sync clog
2009-08-08 13:08:53 +00:00
tg ed0299042c more use of memcpy(3) when we know destination and source sizes 2009-08-01 20:32:45 +00:00
tg 68f9bfa689 if duplicating strings, it’s idiotic to use strlcpy(3) when we know
the sizes (checked)
2009-08-01 20:29:25 +00:00
tg c172cdc922 bump version and rebuild+check on MirBSD 2009-08-01 14:21:30 +00:00
tg cb2fd22c38 "official" but unsupported printf-as-builtin code, cleaner API than
in the branch; USE_PRINTF_BUILTIN=1 to enable it (Build.sh + Makefile)
2009-07-30 19:11:12 +00:00
tg 918aca2c45 * add __COPYRIGHT
* if MirBSD is recent enough, use OS' RCSID macros
2009-07-30 18:42:31 +00:00
tg 758dc5c6fe * improve CPPFLAGS vs #define handling again: do not touch CPPFLAGS from
Build.sh but use 'if defined(PRECOND) && !defined(TOBEDEFINED)'if possible
* for all of the source code, drop annotations "imake style" (if we check
  for specific OSes, bad, instead of using mirtoconf checks proper) and
  "conditions correct?" (if I'm not entirely sure if that #if catches all
  cases and no false positives) where I can see it by grepping immediately
* bump mksh patchlevel
* refresh Makefiles
2009-07-25 21:31:27 +00:00
tg bcf4080793 improve MKSH_NOPWNAM handling, whether MKSH_SMALL or not; it will cause
the entire ~fac/ expansion code to be omitted
2009-07-25 20:26:33 +00:00
tg 5e3aba8b00 simplify MKSH_SMALL => MKSH_CONSERVATIVE_FDS handling 2009-07-25 20:18:13 +00:00
tg b42582689f ABI bump to R39: adhere to the future POSIX standard regarding -o nounset;
add appropriate regression test (except $_ *is* unset in non-interactive
shells). See the thread at:
http://article.gmane.org/gmane.os.miros.general/8863
2009-07-16 15:06:45 +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 3ba2780eb3 another fix from oksh for Vi Mode word erase handling, appears to unbreak
more from cid 1004A2D72DD5A4E4B4F tried to be fixed in 1004A300A72701188E3
but I’d appreciate someone who actually uses Vi Mode to test it:

   Revision 1.26: [7]download - view: [8]text, [9]markup, [10]annotated - [11]select for diffs
   Mon Jun 29 22:50:19 2009 UTC (5 days, 14 hours ago) by martynas
   Branches: [12]MAIN
   CVS tags: [13]OPENBSD_4_6_BASE, [14]OPENBSD_4_6, [15]HEAD
   Diff to: previous 1.25: [16]preferred, [17]coloured
   Changes since revision 1.25: +10 -5 lines
make VSEARCH werase act like regular werase after the last change.
vi back-words and emacs kill-region are not completely the same.
ok merdely@, millert@.  "Get it in" Darrin Chandler
2009-07-05 13:56:48 +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 39bb71fc54 Save another couple of bytes in the !ulimit case 2009-06-10 18:11:27 +00:00
tg 571546c562 • Check if killpg(3) is available; if not, use kill(2) with negative
process ID and hope it works (is POSIXly killpg-endowed)
• bump version
• sync clog
2009-06-08 20:34:40 +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 848e237b76 new feature: -DMKSH_ASSUME_UTF8=0 assumes utf-8 is *not* set and skips
environment inspection; useful for initrd and the likes
2009-06-07 22:28:05 +00:00
tg 16c47bbe91 fix bug exhibited by t0000-basic.sh introduced in R38 shortly before the
release: sometimes, a “cd -P” would cause memory corruption because lalloc
internal data was overwritten due to accidentally losing a “continue;”
2009-05-31 15:10:07 +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 9179c10119 pgas mentioned ksh93 does [[ $foo ]] (ipv forced [[ -n $foo ]])
and it actually REDUCES code size to allow it as well; mention
in the manpage that it’s merely unportable (and of course exe-
cution time differs); sync clog
2009-05-21 14:28:35 +00:00
tg ae8d54284a commit Syllable-related improvement: simplify p_time 2009-05-20 10:10:02 +00:00
tg 361dee04f3 laffer1 agreed they will need -DMKSH_MIDNIGHTBSD01ASH_COMPAT in the
short term, but only for /bin/sh – thus recommend to also define
-DMKSH_BINSHREDUCED and make it dependent on FPOSIX
2009-05-16 21:00:52 +00:00
tg 8a2557f846 pcc cought a bad programming idiom I accidentally used
(without realising that it’s a macro expansion, that is)
2009-05-16 19:34:07 +00:00
tg b6ce748064 • remove “#if 0” and “#ifdef notdef” style old debugging code
• expose “#ifdef MKSH_MIDNIGHTBSD01ASH_COMPAT” just in case they decide to
  require it and show it in the ksh version automatically
• sync the use of non-ASCII characters over files (unification)
2009-05-16 18:40:09 +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 cc783807d3 this began as a one-word change to the spec (manpage): that
${foo:1:2} operates on characters ipv bytes – which means:
‣ set +U: octets
‣ set -U: MirOS OPTU-8 characters

for consistency I also adapted ${#stringname} to deliver the
length in characters ipv bytes; more may follow; for example
I’d like a way to expose the string width.

you can already get the MirOS OPTU-16 of a character in the
WTF-8 (「set -U」) mode with something like
│ typeset -Uui16 -Z7 x=1#${stringname:position:1}
which will correctly use the PUA EF80‥EFFF mapping for octets.

due to this being an incompatible change, bump to R38

also change the unicode-hexdump sample regression test and
add two news for ${x:1:2} and ${#x} checks in A/W mode ☺
2009-05-16 15:53:02 +00:00
tg 8a7223d4cd split utf_ptradjx into utf_ptradj function (to save space) and
self-assignment macro; remove some uses of the macro in favour
of foo += utf_ptradj(foo)
2009-05-16 15:09:07 +00:00
tg 747cc12184 Add search-history-up and search-history-down keybindings (both unbound
by default) to the Emacs command line editing mode; patch originally by
James Butler <sweetnavelorange@gmail.com> but slightly modified

10x
2009-05-16 14:19:23 +00:00
tg 8cc7fdb834 "evil" workaround to the alignment issues: embed an ALLOC_ITEM into
struct env (other structures defined have no "foreign type with pos-
sible alignment constraints" members) and take care of it while dea-
ling in a struct env instance
2009-04-07 19:43:28 +00:00
tg d43f4efe60 employ some "nice" constants and comment lalloc.c 2009-04-07 18:56:51 +00:00
tg 4de58fe6fa globalise SIZE_MAX definition 2009-04-07 18:46:07 +00:00
tg 9e83002841 try to do some optimum struct packing except for struct env
(pointers, longs, size_t first; time_t next; int etc. then enum, bool)
2009-04-07 18:41:37 +00:00
tg e88736b5ef decouple conservative file descriptor use from MKSH_SMALL, with the
new MKSH_CONSERVATIVE_FDS præprocessor flag, because Minix 3, for
example, needs it (otherwise “mksh Build.sh” fails)
2009-04-06 08:33:37 +00:00
tg 398be9867a fix jobless mksh so much to make it work on Minix 3 2009-04-05 12:35:32 +00:00
tg 56c6e384e6 (experimental) implement getrusage via times if not found 2009-04-03 09:39:07 +00:00
tg db6ed8be7c ... and it did in fact require DEC ucode cc to spot this!
gcc, SUNWcc, pcc, llvm-gcc, clang, etc. all didn't say a thing!

now compiles warning-free (testsuite pass) on ULTRIX 4.5 (1986),
and OSF/1 X2.0-8 (testsuite norun: perl missing) has only the usual
bitchings about "volatile sig_atomic_t" because the latter part is
already volatile, but otherwise warning-free compile, works fine
2009-03-25 21:45:28 +00:00
tg c7b2af502e further simplify
XXX check whose platforms’ realloc(3) don’t take NULL
2009-03-24 08:53:45 +00:00
tg 99a8c2a814 bump to R37; the ;& and ;;& are postponed indefinitively for now,
as I don't get to it and it's nontrivial
2009-03-22 18:50:43 +00:00
tg 62b28858d4 sync; fold oksh-seterror test into errexit-*; use print not printf 2009-03-22 18:28:35 +00:00
tg b20f49adae patch from oksh (except manpage, I'll merge that later):
pass "xerrok" status across the execution call stack to more closely
match what both POSIX and [18]ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to &&' and ||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed !'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.
2009-03-22 17:47:38 +00:00
tg 0fe20ab25f sync with oksh (nop) 2009-03-22 17:31:17 +00:00
tg ca539f08f0 remove espie's double-linked-list based allocator and write a
similarily simple one from scratch, which however performs
better than espie's with AFREE_DEBUG enabled which took away
the benefit of the double-linked-list approach

all of (core) mksh is now MirOS licenced
2009-03-22 16:55:38 +00:00
tg d8c3d6e9c1 another off-by-one, reported by «macaronyde:#!/bin/mksh» 2009-03-17 13:56:47 +00:00
tg d99541d7c8 revert previous commit for now. testscript which breaks:
H4sIAAAAAAACA31TTUvDQBC951c804DtIQ0iiFhSPHiwiCDqzUpIuhO6JN2ETSS16n93Np+GFiGE
zM6bN2/fTPQOro5xENYuEVLzBz9eaF6RlWupSpyHaXqzVuvyljbbDCRV0UR7WeLiHEtT4D2GCcUy
pdNFh4pkg4wGZCV8Z6opTPOw3GI+swoq4ZIVZxqkSv0JqRAiWkBkmAJNegHIGG9vcAWcSnjM6dTo
uby8vsL7+wLllhQQKKr4SoFv/8nbXE5pQcdpk4nlwH6AE7zer17uVs/BmHVftnUdxYh0yHbV3ghY
9wh2rQlBkdMm8PmIe57Bjfs7dTW9X/OoEG6lwzwnzYKA7+8jHpsJTuFN4+IjKhKZM6dpZ0xuQ2Nz
7bGB1F74zlebmzTm/PS+OB0GZz4HLcPgz+BeDxyS9S7YU6e3qZaQk5gZgRHvQtI59Eet7QwBWFnL
O/F+ej9Fpmg0ug7OHrnqHy2+7y8x6DGEG3E0Az41RuPlYfXEEx0psrl8PAUebzf6ZklabgD8V3SS
Z7Vo6xfOuQS6gQMAAA==

「mksh -o posix z」 failed in that it continues; 「mksh z」 correctly aborts
let’s see what the obsd people have to say herefore
2009-03-16 15:50:13 +00:00
tg e39c1f860d bring back the backed-out Debian patch if FPOSIX; test programmes fixed:
H4sIAAAAAAACAz1PywrDIBA8m68YgoT20EN7TMixX1F6yGNFIWhRSw2h/95VmuDB2XmsY2oDRVyo
Si1N2uHlMzQK0b8JHaImy4RQwxIITYPiUs4xqcyeGgdfrfumtWX5dMbGSHy0WQgP1PJa49lhdpkV
ynncYSxkOjjxd/V83dmcX9sQtFGRi0zORmO5042HbwnMzlIBqa9lAmfLVBIZ7XqpKBPDnDu+WXpi
wMhnOgQXYvUD+oKHAhUBAAA=

XXX OpenBSD has something different which may DTST or even DTRT (not break
XXX our make(1) wrt <bsd.subdir.mk>), check that
2009-03-16 15:14:23 +00:00
tg 7c040d98f9 sprinkle a few static and clean up the internal APIs 2009-03-15 16:13:40 +00:00
tg 32bc1dc40e sprinkle mksh_ari_t to limit arithmetics to 32 bit even
on Debian Lenny/amd64 (XXX need more verification; this
can be used for 64 bit arithmetics later too)

PPID, PGRP, RANDOM, USER_ID are now unsigned by default
2009-03-14 18:12:55 +00:00
tg 1b3e4a3a2e when outputting in a row x column formatted way, but the available space
on the screen is not enough for two columns, just output the text line by
line, instead of trying to format it; gets rid of superfluous empty lines
if we did not even have space for one column on the screen (x_cols)

noticed by Gábor Gergely in irc, thanks!
2009-02-22 18:02:31 +00:00
tg 5e22cb486f <sys/file.h> is only required for, and only contains, flock(2) 2009-02-20 13:25:10 +00:00
tg 177b1b4cf9 always set COLUMNS and LINES; make use of the fact in dot.mkshrc 2008-12-29 21:34:22 +00:00
tg de9fe12a4c use a more common/generic routine for TIOCGWINSZ;
ensure x_cols and x_lins always have a sane value
after them (even if not tty_fd)
2008-12-29 21:05:15 +00:00
tg 5e3fcc7ab9 new global x_lins (like x_cols), MIN_LINS (like MIN_COLS) 2008-12-29 20:53:48 +00:00
tg 2fb7225499 give tty_init() another argument for silent initialisation 2008-12-29 20:47:16 +00:00
tg 858d8e8b5a implement unsigned arithmetics as an mksh extension 2008-12-17 19:39:23 +00:00
tg c62d5791ae fix signedness issue wrecking havoc on 64 bit architectures, oops 2008-12-13 18:32:27 +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 a19bf7253a * sh.h: note that file descriptors SHALL be <100
* syn.c: fix bashiop-4 regression test; failed due to me using a
  simple string when a wdstring was expected, sorry; the new code
  assumes file descriptors take up a maximum of two characters
2008-12-02 13:20:40 +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 c0703f5f26 if MKSH_SMALL and HAVE_ARC4RANDOM, there is no need to use rand()/srand(3)
ever, since MKSH_SMALL is not required to be as close to compatibility as
normal/generic shells; we can also get rid of time(3) calls
2008-11-30 10:33:40 +00:00
tg 6be05862db meet AALLOC_STATS 2008-11-15 08:52:01 +00:00
tg 6b9cdbbfd6 globalise internal_verrorf() 2008-11-15 08:42:36 +00:00
tg cd716426e4 introduce AALLOC_STATS, which somewhat breaks the encapsulation for need
of a friendly name
2008-11-15 08:03:24 +00:00
tg 32e1ecf5b3 enable passing of a hint how many pointers we’ll need to anew()
if 0, the default is used
2008-11-15 07:35:25 +00:00
tg 3c1e46ee4d prepare for aalloc.c, which I have just written myself, as an area-based
allocator using malloc and free, with mmap malloc and omalloc in mind,
not counterfeiting its security measures such as guard pages, and having
some of our own, e.g. XOR random cookies, optional mprotect, etc.

zero cost (for we have arc4random())
2008-11-12 04:55:19 +00:00
tg 8d5d720f08 get rid of tempting sizeofN macro 2008-11-12 00:55:32 +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 246b762af7 isolate all knowledge of the area-based allocator from the rest of the code
cost: bss -= (0, 0, 16, 16); text += (520, 504, 516, 480)
[ gcc,pcc X full,small ]
2008-11-12 00:27:57 +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 2a0e181a70 work around even more format string warning stuff 2008-11-10 19:33:08 +00:00
tg 65b1923b61 build warning-free with LLVM+Clang on MirBSD itself
$ (CCC_LD=mgcc CC=ccc sh Build.sh -r && ./test.sh -v) 2>&1 | tee log
Total failed: 2 (as expected)
Total passed: 278

Just the result is huge, and we could of course build to intermediate
byte code to optimise globally…
2008-11-09 20:32:18 +00:00
tg 89e96b6c86 experimental support for <strings.h>
cf. http://www.opengroup.org/onlinepubs/009695399/basedefs/strings.h.html
QNX seems to bury some functions in there
2008-11-02 22:29:36 +00:00
tg bf3194e937 save 1640 .text bytes in MKSH_SMALL case by not inlining strdupx, strndupx 2008-10-28 14:51:06 +00:00