Commit Graph

169 Commits

Author SHA1 Message Date
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