Commit Graph

382 Commits

Author SHA1 Message Date
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 97c9d172d7 add comments, remove dead code 2009-04-05 12:35:21 +00:00
tg 5e4ffcbedd From: Alexander Hall <alexander@beard.se>
when following bind key macros, do not so recursively
2009-04-05 12:28:55 +00:00
tg e8fad467cf From: Alexander Hall <alexander <at> beard.se>
support multi-line bind macros (part 1 of 2 of entire diff)
2009-04-05 11:18:34 +00:00
tg d8c3d6e9c1 another off-by-one, reported by «macaronyde:#!/bin/mksh» 2009-03-17 13:56:47 +00:00
tg 8a77cd5d6e attempt to get the C1 control character problem temporarily solved:
just output them. sometimes you'll see U+FFFD even. real fix later.
2009-03-15 18:48:43 +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 7c040d98f9 sprinkle a few static and clean up the internal APIs 2009-03-15 16:13:40 +00:00
tg bbaa186ec6 optimise utf_widthadj 2009-02-22 19:02:27 +00:00
tg 3d3a7e545a preliminary fix for the ${foo/@(%)/x} not working in UTFMODE problem:
the width for control characters (wcwidth(wc) == -1) was hard-coded
to 2 (!) in utf_widthadj, which is true for *only* one of the two x_zotc*
functions in Emacs editing mode, and none of the other functions which
use this piece of code

change to 1, to be more correct in the general case; use of the UTF C1
control characters U+0080‥U+009F is slightly broken anyway, and this
only shifts the brokenness to different places of code

XXX maybe we want to map U+0080‥U+009F into Unicode as if they were
XXX 0x80‥0x9F in ANSI cp1252 instead, at least for displaying?

the editing code is cruel…
2009-02-22 18:57:19 +00:00
tg 9f79293319 some systems’ (such as klibc) <termios.h> does not define _POSIX_VDISABLE 2009-02-20 13:19:04 +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 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 546d5d0def give hints to anew() according to aalloc stats output for testsuite and a
little interactive use, to reduce the number realloc(3) must be called
2008-11-15 09:00:19 +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 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 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 8230c9d8ae • do not use __typeof__ even if we have statements-as-expressions, to
please pcc, prompted for by Anders “ragge” Magnusson, problem spotted
  originally by Adam “replaced” Hoka
  ⇒ rewrote x_bs2() and utf_backch() into a combined x_bs3() function,
    since these are never used in any other way
• whitespace cleanup, while here
2008-10-26 20:59:40 +00:00
tg 2fc9fb99d7 when doing a history search (^R), restore old input line on
abortion (^G – ^C is SIGINT and doesn’t work like this, but
that’s actually good IMO)

prompted by enquiry about the Emacs editing mode by <smultron:#MidnightBSD>
2008-10-19 20:15:45 +00:00
tg c11187f993 fix some of the things scan-build[1] found (but not some false positives)
10x

From: Elias Pipping <elias@pipping.org>
[1] http://clang.llvm.org/StaticAnalysis.html
2008-10-13 23:06:04 +00:00
tg 5d9e4c9e16 unbreak MKSH_SMALL after x_histp related changes 2008-10-05 16:06:43 +00:00
tg 27ee1866fe implement Message-ID: <20081004171903.GA14184@boetes.org>
in a somewhat hackish way, and it’s still quite different from zsh,
but probably closer to a desired functionality

XXX this makes state by abusing 「modified」 and 「xmp」 (“the mark”).
2008-10-04 23:08:04 +00:00
tg 051522c9ea optimise 2008-09-30 19:28:12 +00:00
tg 13231b50eb ignore more dups 2008-09-30 19:25:51 +00:00
tg f53a8196e4 däs isch ei buul, koa int… 2008-09-30 17:49:26 +00:00
tg a330895a2c implement ^Xe emacs history editing like ^[v vi history editing
cf. Message-ID: <Pine.BSM.4.64L.0809171944240.28480@herc.mirbsd.org>
2008-09-30 17:23:00 +00:00
tg 09bfec553e when using search-history, ESC ends the search, however, ESC often leads
in præfix sequences (like ANSI cursor keys), leading to annoying effects
if we forget that

this patch changes the behaviour so that another character is read/peeked
at (since this is done in the main loop after ESC anyway, no function loss
through the delay) if ESC leads in a prefix-1 sequence, and if the peeked
character leads in a prefix-1 or prefix-2 sequence when in state prefix-1,
it’s still enacted (XXX document this in manpage)
2008-09-20 15:59:23 +00:00
tg 0322c87457 EXPERIMENTAL: make it so that the last (not yet entered) line (even if
empty) appears pushed into the history, so that, when pressing cursor-up
or ^P, with a cursor-down or ^N you get it back, unless you modify a line
retrieved from the history, in which case it will overwrite the saved line
and place the current history pointer past the entered history lines

This is for Emacs mode; Vi mode had something similar already, and shares
some code and data

XXX there are several static buffers of size LINE (currently 4096) in here
2008-09-20 14:10:23 +00:00
tg 2ab0f09ed4 • since libc has OPTU-8 while mksh has CESU-8 for UTF-8 handling, we cannot
use the libc functions for converting between multibyte strings and wide
  strings in here any more, besides mksh has slightly different needs than
  SUSv3 compliance ⇒ hand-craft optimised and unrolled functions for that
• sync the mksh-internal wcwidth function with libc
2008-09-20 12:29:31 +00:00
tg 977237ad14 • merge vi_reset() and edit_reset() into x_vi() to allow for following:
• fix vi mode (which, however, is officially orphaned) multi-line $PS1 by
  using a similar algorithm for prompt skipping as emacs mode (changing
  the meaning of prompt_trunc variable and using prompt_redraw, just even
  more efficiently than vi mode); reported by asarch via IRC
• fix multi-line prompts if last line is “too large” by using emacs mode
  algorithm of just internally appending a newline, while here ☺ this even
  saves us having to re-add the prompt_skip variable…

WARNING: this is only barely tested, as almost nobody ever uses vi mode
⇒ test yourself, there may be bugs (e.g. off-by-ones); already known is
  that the vi input line editing mode is NOT multibyte safe…
2008-09-14 20:24:59 +00:00
tg 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 4230cf91de thinko: multibyte characters are not always 1 column wide 2008-05-02 18:55:37 +00:00
tg a96b40067b sync with updated libc functions 2008-04-20 02:01:42 +00:00
tg e20694eceb utf-8 function overhaul (size optimisation)
XXX maybe we can get more out of this?
2008-04-20 00:03:50 +00:00
tg 03ce610399 regression: interactive use didn’t work at all oO
the “fix” is to treat NUL bytes as width=len=1…
2008-04-19 22:50:01 +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 3e728f7797 invalid 3-octet multibyte sequences are stripped to 1 not 2 bytes 2008-04-19 17:25:49 +00:00
tg 7ddf56dbbc • new ksh_mbswidth
• fix: when printing menus (tab expansion, for instance), honour width of
  the multibyte characters printed
• some int→bool while here
2008-04-19 17:21:55 +00:00
tg 37af1f3087 more
• int → bool
• shprintf("foo") → shf_puts("foo", shl_stdout)
• shprintf("%s", foo) → shf_puts(foo, shl_stdout)
• shf_puts("x", foo) → shf_putc('x', foo)
2008-04-01 21:50:58 +00:00
tg 425410de19 make rcs ids ident(1) capable 2008-03-23 21:31:29 +00:00
tg 6976ed8bc3 get rid of u_char, u_int, u_long 2007-10-25 15:23:10 +00:00
tg 3b5bbaefcb optimise (struct padding, function→macro, etc.) 2007-10-25 15:19:16 +00:00
tg e2c2a1c1a0 clean up the CHARMASK mess 2007-10-14 13:43:41 +00:00
tg 52b9911ff6 revert the return type of x_e_getc() back from u_char to int
this change broke abortion on failure to read input, was not
needed for gcc warnings and is the fault of Intel’s compiler

this should fix the other busy-loop problem occuring only on
GNU/Linux so far – 10x spaetzle@freewrt.o for pointing me to
the problem; reproduced on my work craptop
2007-10-09 14:50:50 +00:00
tg 3d6f318d90 On Debian GNU/kFreeBSD, gcc version 4.2.1 (Debian 4.2.1-5):
../edit.c: In function ‘x_cf_glob’:
../edit.c:508: warning: ‘words’ may be used uninitialized in this function
2007-09-09 20:03:32 +00:00
tg c1c939e340 • fix memory leaks found by coverity
from netbsd via oksh
  we had the NULL pointer deref already fixed
• avoid a bogus not-setting the return value of edit.c:x_file_glob()
  introduced by the above change in oksh
• escape ? as well (but not ] because that’s wrong)
  reminded by cbiere@netbsd via oksh
• Unsetting a non-existent variable is not an error. See
  http://www.opengroup.org/onlinepubs/009695399/utilities/unset.html
  report from Arkadiusz Miskiewicz; fixed based on
  http://cvs.pld-linux.org diff via oksh but modified slightly
• Be more smart waiting for input for non-interactive scripts.  Fix
  based on a diff from debian:  see their bug#296446 (via oksh)
  modified slightly
  this also fixes cnuke@’s “mksh busy loop” problem, for which I never
  received a bug report, but the Debian bug page contains a set of two
  scripts to reproduce this before (and no longer after) this commit
• some KNF
• bump version
2007-09-09 18:06:42 +00:00
tg 49c95a8938 put clear-screen on ESC ^L as suggested by the AT&T ksh people in
http://www.opensolaris.org/os/community/on/flag-days/pages/2007081701/
2007-08-18 01:20:28 +00:00
tg 45cadd2abf make sure we don't show any junk in MKSH_CLS_STRING even if the terminal is
not standards compatible
2007-07-31 15:42:50 +00:00
tg 47836e45e7 add a new bindable command “clear-screen”, which can be bound to the ^L key
so that archite@midnightbsd won’t have to add evil kludges to oksh again if
they switch their ksh to mksh ☺

both “clear-screen” and “error” aren’t bound; default binding for ^L stays,
as usual, “redraw” (principle of least surprise); however GNU bash converts
also might want to put “bind ^L=clear-screen” into their ~/.mkshrc.
2007-07-31 15:29:40 +00:00
tg 809c1446b2 some steps towards building with tcc 2007-07-31 10:42:15 +00:00
tg cf5fc9eac2 some null/NUL 2007-07-22 13:38:26 +00:00
tg 979406bba7 • support IBM xlC on AIX
• fix all bugs it could find ☺
2007-07-22 13:34:52 +00:00
tg 2e42fa62b6 Borland C++ found these 2007-07-01 21:10:29 +00:00
tg d42f966d22 rewrite some code; bug found by HP's C compiler 2007-06-21 16:04:46 +00:00
tg a7ce246a37 if invoked as /bin/sh, -sh, sh.static, whatever, activate FPOSIX
this should help inferiour operating systems like Debian… (where
some of the devs, hi waldi@, don't consider stop() { } invalid…)
2007-06-15 22:00:00 +00:00
tg bf671f42fa don't use __extension__, cought by sunpro on linux 2007-06-09 22:01:42 +00:00
tg 3dcf22a319 ok, icc _did_ track down a few ones, and I fixed errno abuse a little too
however, bad S/N ratio

side effect bonus: smaller code size now
2007-06-06 23:28:17 +00:00
tg 1e0ca54bf6 out of a 50-line diff which STILL didn't shut up icc, these are the actual
problems. icc's warnings are bogus:
• it says int x_getc(void); is invalid (hm well, it may be static?)
• char c, d; d = c | 0x40; -> warning because (c | 0x40) is an int
  (it apparently can't track value bounds)
2007-06-06 22:26:26 +00:00
tg 63c31c43e3 fix for the SUNpro 8 on yofuh's E420:
cc: Sun C 5.8 Patch 121015-04 2007/01/10
2007-06-05 19:48:47 +00:00
tg 15515cfe06 fix Message-ID: <e3fded850705240816s50544d04u5c87edb905f1c123@mail.gmail.com>
(maybe) by only emitting the >*< if we're at EOL
2007-05-24 19:15:46 +00:00
tg 8c986282ce optimise 2007-05-22 21:13:56 +00:00
tg fec876cdcf fix Message-ID: <e3fded850705221323w1442f15cr4375a5590acf8088@mail.gmail.com>
(by dramsey again, you're DA MAN) by replicating some of the x_redraw() logic

Note that this is correct, a construct like the full-fledged
| x_e_putc2((xep > xlp) ? ((xbp > xbuf) ? '*' : '>') : (xbp > xbuf) ? '<' : ' ');
is not needed since if (xep > xlp) && (xbp > xbuf) – i.e. in the '*' case –
x_redraw() will be called anyway and because (xx_cols - 2 - x_col) == 0 the
code won't be triggered.
2007-05-22 21:01:38 +00:00
tg d8b210fd16 dramsey bug #4: regression introduced in 1004651F21443013C37 (fix for bug #3)
cf. Message-ID: <e3fded850705211623n20d2c695ke7b41d75ac439a6c@mail.gmail.com>

this one was harder to track down, additional variables coming into the play…
2007-05-22 19:27:05 +00:00
tg f5d4e21aa2 • fix the third dramsey scrolling bug for both ^D at BOL and ^W at EOL
(I hope)
• fix another one I found: after ^D'ing, insert at BOL, the > is displayed
  one character too late
2007-05-21 19:25:32 +00:00
tg 5323f6023b unify the move-backwards redrawing bug fixes
cf. Message-ID: <Pine.BSM.4.64L.0705211156060.16459@odem.66h.42h.de>
tested to not slow down _even_ more a 75 MHz sparc (neko.haemoglobin.org)
thanks to dramsey again for testing
2007-05-21 12:24:44 +00:00
tg 252861b156 fix the latest appearance of the dramsey backwards movement bug, cf.
Message-ID: <e3fded850705200935h6ac2c9ebgbc7a9b10ac034a49@mail.gmail.com>
and Message-ID: <Pine.BSM.4.64L.0705201659500.8619@odem.66h.42h.de>
2007-05-20 17:53:13 +00:00
tg 0989f7da67 Fix for Coverity CID#2: false bug, but still a problem.
Analysis:
internal_errorf(int, fmt, ...) was only a __dead function if the int argument
was non-0, which the Prevent probably was unable to follow. Change all uses of
internal_errorf(0, fmt, ...) to internal_warningf(fmt, ...); change the pro-
totype of internal_errorf() to internal_errorf(fmt, ...) and all remaining
uses remove the non-0 int argument; add __dead to internal_errorf() proto;
flesh out guts of internal_errorf() and internal_warningf() into a new local
function for optimisation purposes.

Some whitespace cleanup and dead code removal (return after internal_errorf(1))
2007-05-13 17:51:24 +00:00
tg 384032b729 fix the “dramsey horizontal scrolling bug” – time for you to find another ☺ 2007-05-10 19:08:48 +00:00
tg d89613399b const 2007-05-10 18:58:31 +00:00
tg 25bb4815d2 remove a redundant function 2007-05-10 18:46:38 +00:00
tg 377dbe464a some gcc 4.1.2pre warning shutup 2007-03-10 18:16:28 +00:00
tg db81d72dea in the utf-8 mode, invalid multibytes are now handled more strongly:
• if it's in x_literal() (“quote” / ^V) mode, it's accepted like now
• if it's a mb sequence start, it's rejected with a beep
• if it's a mb continuation, the whole sequence is silently rejected

this makes command line editing when accidentally hitting, e.g. with
my mircvs://contrib/samples/dot.Xmodmap, Mode_switch-x much more ro-
bust.
2007-03-10 00:36:44 +00:00
tg 08ccbacdf6 bugfix: display UTF-8 control characters (U+0080..U+009F, i.e. width == -1)
the same as ASCII control characters (U+0001..U+001F), i.e. with a ctrl ca-
ret and its value XOR U+0040; treat their width as 2

fixes crash+cpu hog on 'meta-tab backspace'
2007-03-10 00:23:31 +00:00
tg 83c2ee87f4 • remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
  that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
  only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
  to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version

¹) side effect from creating API-correct cstrchr, cstrstr, etc.
   uses goto so it must be better ☻

tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 03:04:28 +00:00
tg 62b347a1b0 merge the const branch +- a few 2007-03-04 00:13:17 +00:00
tg ad05a2414b * edit.c: when tabcompleting a newline to backslash+newline, this
sequence is eaten before the command is called; cought by <TGEN>
  (Thomas E. Spanjaard) via IRC
  fix is to tabcomplete a newline to singlequote+newline+singlequote
* bump version
2007-02-16 17:46:42 +00:00
tg dd462f00d3 repair 'bind' builtin with no args output; damage taken in -r1.80 2007-02-07 02:01:43 +00:00
tg dc10f66070 optimise 2007-01-15 02:14:02 +00:00
tg 0c809f3db9 static int (which was const) -> integrated into its only use 2007-01-15 02:11:34 +00:00
tg 29b62b186d okay, this didn't work out; changing window sizes when we're
actually within a (the emacs) editing mode does not work at
all, whether forced or not, only if we leave the editing mode
(at end of input); probably due to it saving stuff from e.g.
x_cols into xx_cols, etc.

-> remove SIGWINCH handling(!)
-> TIOCGWINSZ is now executed at end of every input line
-> use 'ESC #' if you direly need to change line size
2007-01-14 01:56:23 +00:00
tg 36e761840e * do *not* check the terminal size after each line processing,
only if we got a SIGWINCH -> interactive use speed-up on the
  slower boxen (slowness courtesy of otto@obsd)
* ^L (redraw line) now (always) checks window size; use this
  instead if required while editing the prompt; changes to the
  variables will still be propagated after the line is entered
2007-01-14 01:09:09 +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 5891915f1b * Scan for __attribute__((...)) in general (the earliest was 2.5,
where we had 'noreturn' etc. but no '__noreturn__')
* Scan for __attribute__((bounded)) and __attribute__((used))
  if we have __attribute__((noreturn))
* To be able to scan if certain attributes give warnings,
  scan for -Werror with a simple programme which hopefully triggers none
* Convert __attribute__((unused)) to __unused, noreturn -> __dead
* Unify other attributes
* Clean up typography a little more
2007-01-12 01:49:29 +00:00
tg 98e9111bbc remove the "set -o sh" option (dummy anyway),
"set +o emacs-usemeta" and "set -o vi-show8" which are always on now,
since we have proper internationalisation (i.e. utf-8) support, and
assume the user either has a 'C' locale and can't enter 8-bit chars,
his terminal is 8bit-transparent, or he has a 'UTF-8' locale.
2006-11-19 20:43:14 +00:00
tg 151d913115 remove all but these __CRAZY=Yes build warnings:
main.c: In function 'main':
 main.c:208: warning: cast discards qualifiers from pointer target type
 main.c:329: warning: cast discards qualifiers from pointer target type

no warnings at autoconf time left either; will take care of these two later
(might revisit changes from this commit), maybe change declararion for the
builtins to have their argv[] be const strings, and go through strict type
and qualifier checking again. this'll further improve stability.

XXX these changes might have introduced (more?) memory leaks,
XXX someone who knows about these tools should verify with
XXX automatic memory usage analysers (valgrind?)

still passes testsuite
2006-11-12 14:58:16 +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 35b30679c7 since so many internal things hardcode 'C' locale anyway,
use own is{digit,lower,upper} macros that go via byte ranges

doesn't affect utf-8 hack because these only operate on single bytes anyway
saves 224t
2006-11-10 06:53:27 +00:00
tg b323a22b59 use tolower_() and toupper_() macros (if not available, our quick 'C' ones)
76t 8d 2i
2006-11-10 06:45:28 +00:00
tg ca2b1d88ca kill two others, saves 55t 8d 2i 2006-11-10 06:40:05 +00:00
tg d5e4c261db simplify. and, a few byte compares are cheaper than a structure
copy and a structure compare
gain: 103t 4d 1i
loss: had to move some code even though no diff (cvs issue)
2006-11-10 04:31:04 +00:00
tg f8e7fdbb71 use qsort(3) instead of rolling our own
saves 284 in .text, no added import since we already use qsort(3) once
2006-11-10 03:23:50 +00:00
tg f1e29cb1a1 use NELEM 2006-11-10 01:24:38 +00:00
tg 273ca89019 * check.t: add new regression test "typeset-padding-1" according to TFM
* edit.c: remove debug stuff again; next time better use shl.c functions ;)
* sh.h: add format attributes to a few shf functions
* histrap.c, var.c: fix format string mistakes
* main.c, sh.h: error_prefix and warningf take bool not int
* misc.c: make chvt() stuff use shf_* functions
* misc.c: rewrite the TIOCSTTY stuff to be better integrated in mksh,
  since it originally was an external patch
* misc.c: chvt() no longer fails if e.g. chown fails due to e.g. R/O / fs
* var.c: fix typeset padding for right-justified zero-filled
2006-11-10 01:13:52 +00:00
tg 68caa9afdd save 464 text with restructuring 2006-11-09 22:38:31 +00:00
tg bc215df211 make a few functions static that should be, and optimise a little 2006-11-09 21:20:49 +00:00
tg 36ac8dc0f7 get rid of the need of strlcat() altogether (only one use was left) 2006-11-09 15:02:31 +00:00
tg 39057dd592 add the new function utf_ptradj() which does the same as utf_widthadj()
except it doesn't return a value and is much cheaper (no internal con-
version to UCS-2, just range checking on the multibytes)
2006-11-09 00:39:27 +00:00
tg fb9c6e30bb fix another warning
now builds on MirOS, DragonFly, NetBSD, Debian stale (i386), Solaris 8,
Debian testing (s390x) - Solaris /bin/sh, bash, ksh93, mksh
2006-11-09 00:28:36 +00:00
tg dc9f457f24 don't use __predict_false() here either 2006-11-09 00:01:36 +00:00
tg 3d61efea7d fix backward deletion off-by-one in non-border case
take #if 0'd back debugging code for a while, until
the next release comes out… you never know…
2006-11-06 19:57:19 +00:00
tg 230d52135d remove debugging, simplify 2006-11-05 21:11:17 +00:00
tg 1b55015772 fix that inherited pdksh buglet as well... the xlp wasn't invalidated once… 2006-11-05 21:00:08 +00:00
tg 45f1602850 nuke some of the dbg 2006-11-05 19:56:20 +00:00
tg a3331fd8e9 fix another cursor positioning glitch (cause for \b at x_col == 0) 2006-11-05 19:48:58 +00:00
tg b03ed7b315 * catch limit off in x_redraw (bytes vs chars vs curpos)
XXX should probably be screenpos, might need to use x_size* here
  XXX this seems to be the tab bug I noticed which we inherited from obsd
* catch backspace if x_col == 0 (XXX better)
2006-11-05 19:35:52 +00:00
tg 47daa0eadc fix issue with line splits inmidst of multibyte characters 2006-11-05 19:15:15 +00:00
tg 6b02a01833 track down an off-by-one and a segfault 2006-11-05 19:12:41 +00:00
tg 33ac6cb0d9 multibyte search-character-{for,back}ward 2006-11-05 17:54:46 +00:00
tg 72f958edea fix deleting AND moving left 2006-11-05 17:34:39 +00:00
tg 15fd277841 delete and move word fore- and backwards by the right amount, too 2006-11-05 17:24:00 +00:00
tg 260eaa9d51 eliminate segfault 2006-11-05 17:11:25 +00:00
tg abe860d486 fix deleting forward with count 2006-11-05 16:53:34 +00:00
tg aa867d19bb if we can't delete, keep position, as before 2006-11-05 16:48:17 +00:00
tg dba2dec094 backspace counting
rest'll follow
2006-11-05 16:43:57 +00:00
tg cc261c7968 make backspacing (and moving forward and backward) work perfectly
(in Emacs mode, of course) - for count=1 only though (yet)
2006-11-05 16:41:02 +00:00
tg 4787566fb6 multibyte insertion, the Plan 9 way 2006-11-05 16:10:10 +00:00
tg 08d3457cff utf hack depends on emacs-usemeta off (the default) 2006-11-05 15:36:09 +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 c81966621a merge non-Plan9-specific stuff from the branch, add KNF, etc. 2006-08-24 20:32:53 +00:00
tg 4fac7ec24b * remove redundancy
* integrate compat.h, version.h into sh.h (dependency trick didn't work anyway)
* mention #ksh in mksh(1) since the founder (twkm) said it's on topic too
  (don't remove mention of #mksh despite it's usually empty because of control)
2006-08-22 22:49:38 +00:00
tg 4661992d5b remove the 'stuff' functionality altogether,
ksh93 doesn't have it, and I don't know, nor
do I care about what "the BRL ^T mini-systat
feature" is.
2006-08-08 20:17:22 +00:00
tg 5176249248 * bind ^T to transpose-chars as documented in the manual page,
not to stuff, even if TIOCSTI is available
* it's transpose-chars not transpose

bug spotted by hondza who wondered that on ^T the line repeats itself forever
2006-08-08 20:07:53 +00:00
tg 174b4c5a1d the 'delete' key does *not* act as Ctrl-D (EOT, cf. ascii(7)) 2006-08-02 14:02:55 +00:00
tg 58e5606710 bind xterm-xfree86 and wscons (NetBSD®) wsvt25/vt220 too 2006-08-02 14:00:19 +00:00
tg c96e31a707 implement a hack whereas you can now bind functions (and macros)
to keys with a trailing tilde (after prefix + control char); the
function is then invoked after prefices, control char and one more
character X are entered; if X is not a tilde, it is ungetc(3)d
2006-08-02 13:32:18 +00:00
tg b99aa06d9b save whitespace 2006-08-02 12:54:48 +00:00
tg 99007d97e7 cry if the 'bind' editing command gets too long arguments
minor KNF while here
2006-08-02 12:49:04 +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 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 db107a9b05 bring back the 'version' editing command at "ESC ^V" like AT&T ksh93+r 2006-08-01 12:44:17 +00:00
tg 64598758fb * TNF needs more to silence char subscript warnings (on 3.0-stable)
* bump vsn
2006-07-11 14:51:01 +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 9e838e765c * convert most of the interna of edit.c to unsigned where it's
important for the signedness of the target, to enable using
  high-bit7 characters on the command line (eg. in UTF-8 locales)
* make emacs-usemeta and vi-show8 equivalent and document that
  in the manual page (i.e. beware if you're in a latin1 locale)
* do not reference SUSv3 (helps GNU groff), write \&" out instead
2006-02-16 11:48:32 +00:00
tg 3f2912d717 * update to mksh R26c
* there is no comma in front of "which" in English, I was taught
2006-01-30 12:37:24 +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 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 892c6123c5 Fix a redraw problem that occurs when a recalled history line has
length equal to screen width - 2. Spotted by jmc@, tested by various.
ok deraadt@
From otto@obsd
2005-10-07 18:34:18 +00:00
tg b2bea18ea3 Process window size changes after xread(). [change window size]
echo $COLUMS $LINES; will now print the new sizes immediately, instead
of after the second echo. ok millert@
From otto@obsd
2005-10-07 18:32:23 +00:00
tg 309b8d635f * make 64-bit clean on GNU/Linux by default
* clean up and remove some .Xr from the man page
* bump version
2005-08-21 13:02:17 +00:00
tg 0651ba008e ^V now is quote, not version, even in emacs mode. (From OpenBSD.)
Also, the "version" command got removed in its entirety.
Shaves off another global variable, even.
2005-08-02 12:35:27 +00:00
tg 35f1a9b29f please ISO C99 2005-07-12 13:30:38 +00:00
tg c02f87e61c gcc 4.0 with -O2 -Wall thinks it finds these uninitialised variables,
so quieten gcc

found by Bastian "waldi" Blank
2005-07-12 13:24:00 +00:00
tg 3fb44287d4 mksh now does not look at $EDITOR and $VISUAL any more to determine
the editing mode; default is emacs (vi and gmacs off).
mksh also defaults to emacs-usemeta=OFF now.
2005-07-04 12:07:41 +00:00
tg a21be8d676 some lint cleanup 2005-06-08 22:34:03 +00:00
tg d518ab0023 run a bit of indent over it
not really suitable tho
2005-06-08 22:22:24 +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 541c0caead some KNF 2005-05-25 23:39:10 +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 16fb264efc aaaand: Interix. 2005-05-23 16:23:19 +00:00
tg b8a06e0fbe * Solaris misses sig_t
* our gmatch becomes gmatchx, it's extended against sh(C)
2005-05-23 15:18:17 +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 665202f561 Use struct termios instead of TTY_state typedef
Use tc[gs]etattr() instead of [gs]et_tty() abstraction
From: Todd C. Miller <millert@cvs.openbsd.org>
2004-12-31 17:39:12 +00:00
tg 791337c8a3 Use _POSIX_VDISABLE directly instead of assigning it to a variable.
From: Todd C. Miller <millert@cvs.openbsd.org>
2004-12-31 17:11:11 +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 cddaa62a46 Flags set in signal handlers should be volatile sig_atomic_t
From: Todd C. Miller <millert@cvs.openbsd.org>
2004-12-28 22:28:01 +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 c34add61ff un-OS/2 (sorry)
no binary change
2004-12-13 19:05:09 +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
tg b2de14e57c run GNU protoize
protect header files
nuke some dead code
regenerate configure script
let silly code die
2004-10-28 11:53:44 +00:00
tg 75e25d6e50 de-register, de-inline, de-__P 2004-10-28 11:11:19 +00:00
tg 7ad780aa98 -Wall -Werror -W -pedantic clean 2004-10-28 11:03:24 +00:00
tg ecdd4d5568 unify spacing of RCS IDs 2004-09-21 11:57:17 +00:00
tg 6c8eabf72e polish, mop up whitespace, etc.
passes regressions on MirOS
2004-05-24 19:56:25 +00:00
tg 8d3634d008 throw out a bunch more of 0x60 characters throughout code and comments 2004-04-17 00:47:20 +00:00
tg 4ea65e6edc Merge import of OpenBSD source, ports and XF4 tree.
While here,
o clean up differences where possible
o whitespace cleanup
o ifdef ./. if defined()
o '...' ./. "..."
o echo foo > bar ./. echo foo >bar
o `...` ./. $(...) ./. $$(...)
o `...' ./. '...'
o modernize "our" tree, e.g. WWW in ports
o fix some typos and brainos introduced when renaming OpenBSD to MirBSD
o use hardware 80387 by default
o migrate Apache 1.3.28 OpenBSD ./. MirBSD ./. KAME
o work around as many CVS bugs as possible (add back/delete files, ...)

Synchronize stuff, ready for ongoing changes.
2003-08-31 20:54:03 +00:00
tg 9a5869a50b merge the import
amd (automount dæmon) bites the dust
rewrite fake-NLS emulation, copyright to me
foobar! fnord!
2003-06-29 19:45:40 +00:00
tg 1d75ca6305 escape [ and ] while tab completing, too 2003-06-23 17:33:11 +00:00
tg 7ebc0530d6 Import OpenBSD source tree of short before 17:00 UTC today 2003-05-07 17:15:23 +00:00
tg a34b05d2e6 Import OpenBSD 3.3 source repository from CTM 3132 the first time
This opens an OpenBSD-mirabile (aka MirBSD) repository.

### MirBSD is:
# Copyright (c) 1982-2003 by Thorsten "mirabile" Glaser <x86@ePost.de>
# Copyright © 1968-2003  The authors of And contributors to UNIX®, the
#       C Language, BSD/Berkeley Unix; 386BSD, NetBSD 1.1 and OpenBSD.
#
# Anyone who obtained a copy of this work is hereby permitted to freely use,
# distribute, modify, merge, sublicence, give away or sell it as long as the
# authors are given due credit and the following notice is retained:
#
# This work is provided "as is", with no explicit or implicit warranty what-
# soever. Use it only at your own risk. In no event may an author or contri-
# butor be held liable for any damage, directly or indirectly, that origina-
# ted through or is caused by creation or modification of this work.

MirBSD is my private tree. MirBSD does not differ very much from OpenBSD
and intentionally tracks OpenBSD. That's why it _is_ OpenBSD, just not the
official one. It's like with DarrenBSD.

At time of this writing, no advertising for MirBSD must be done,
because the advertising clause has not yet been sorted out.

http://templeofhate.com/tglaser/MirBSD/index.php
2003-03-22 17:35:03 +00:00