Commit Graph

329 Commits

Author SHA1 Message Date
tg b868c517b7 remove *all* nonnull assertions and other workarounds for clang scan-build
this beast evolved in the last 2½ years, and we’ve had trouble with
some of them earlier
2012-12-01 01:36:30 +00:00
tg b58d7b8053 fix regression wrt. pdksh (introduced between R40e and R40f)
about how and when the display is redrawn by reverting one
bool back to an int, as it’s used as a counter (hm, should
be an unsigned I guess but…)

on the other hand, xlp_valid should’ve been a bool, make it so
2012-11-26 22:39:14 +00:00
tg 1f43cc907d fix backslash-asterisk glob noise for nōn-existant targets and tilde
expansion completion; problem analysis and solution draft by Andrew
Kudryashov (thanks a lot!); this fix instead re-uses existing code
for solving the problem with multiple matches

debugged using “make d dr” targets, yay!
2012-10-21 18:33:46 +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 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 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 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 829cd0cc70 leak less memory from tab completion 2012-08-24 19:14:56 +00:00
tg beca8ed86f more int → bool 2012-08-24 19:02:57 +00:00
tg 403c7c8e50 remove misleading comment fixed in last commit 2012-07-20 22:47:22 +00:00
tg b90a11f6c5 fix more cases of x_delete() bytes vs. characters abuse (tested!); fix some int vs. size_t issues (XXX also fix x_cf_glob and friends some day…) 2012-07-20 20:50:07 +00:00
tg bea2b756b3 factor out common code (convert from "byte offset from cursor" to number of characters) 2012-07-20 20:33:15 +00:00
tg 98ff25a001 fix no less than two more bugs and one regression in the Emacs tab completion code (LP#1025843) 2012-07-20 20:16:26 +00:00
tg 2aceb6893d make QCHAR-for-glob {,un}escaping code into helper functions
no code change
2012-07-20 18:39:53 +00:00
tg 1e2755edc1 x_lastcp(); done by x_zots already 2012-07-20 18:08:23 +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 c6edd7ebe6 lessons learned during nullperf tests: inlining this is always bad 2012-07-01 15:36:18 +00:00
tg 29e36ed2a2 move x_mkraw() to main.c from edit.c in order to be able to skip the latter 2012-05-05 17:32:33 +00:00
tg e6ace01f12 last parts of Coherent patchkit: O_ACCMODE and termio 2012-05-04 22:18:27 +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 8ac32ba793 fix some comments 2012-04-06 15:06:42 +00:00
tg 2a833165a0 add xep bounds check in x_goto, maybe this will fix the problem the Motorola guys are havink 2012-03-31 19:52:34 +00:00
tg bb1c1e7dba a few more int → bool 2012-03-31 19:20:12 +00:00
tg 86c4ea4619 add (#ifdef DEBUG) an assertion that xcp <= xep before doing an Emacs mode
command; DONG-DONG YANG reports they hit this condition
2012-03-31 17:29:04 +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 69e1312265 fix real-life example From: Andrew Kudryashov <andrewinsilenthill@gmail.com>
in <CABNd6wz3SSRWamUNQ-BNcp7z0pthOR156=Zy3qBYmXhTjvoYsg@mail.gmail.com> but
by a different (cheaper) method than the one in his patch from message-id
<CABNd6ww7zFUQ4Ho2zQQzQyERy==8Hqg_y12Acmj1sF6ka4b4KQ@mail.gmail.com>:

when completing, always replace the olen text with the new one, and only
then take the length of the x_expand()ed nlen text to compare and check
whether to set completed=true; this also means:

$ ls foo\+/<tab>
          ↓
$ ls foo+/

this matches reality even better and saves us a couple of string traversals
2012-03-23 21:34:47 +00:00
tg 8e2d84f455 address <CABNd6wz3SSRWamUNQ-BNcp7z0pthOR156=Zy3qBYmXhTjvoYsg@mail.gmail.com>
From: Andrew Kudryashov <andrewinsilenthill@gmail.com>

Hunk 1: “Also, I found that x_escape() does funny things to sequences
of backslashes” which was caused by improper quoting; use an empirical
list of chars to escape (only 0x20‥0x7E, everything else is SOL anyway)

Hunk 2: “and "\*" will be appended” was actually correct, but not in
all cases; handle these cases (and break 0x02 in filename)
2012-03-23 21:15:34 +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 bb51eee63c when doing tab completion partial inserts in UTFMODE, honour multibyte character boundaries (LP: #909025) 2011-12-29 23:36:10 +00:00
tg 4748739523 eek, mira, don’t leave debugging code lying around 2011-12-11 18:07:45 +00:00
tg 986d999e58 make ^O work like it did before we introduced x_modified(), that is,
editing the refetched input line doesn’t let it restart (but ^R does)
2011-12-11 18:01:03 +00:00
tg 44d072a879 beautify a Vi function (no code change), from tech@ discussion 2011-12-04 23:22:59 +00:00
tg 23afb6dbb8 merge “upper bound Emacs mode command repeat by input line length” from
oksh (slightly different implementation) and remark better plans (which
doesn’t mean bounding the repeat counter is bad, though…)
2011-10-07 19:45:08 +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 ac814611f1 somebody (who is probably inlining) complains about memset with the
third argument being 0; maybe (I think can only be this) fix that
2011-07-16 18:15:45 +00:00
tg 0785c2d71c fix tab completion of "~/M↹" 2011-07-02 17:57:12 +00:00
tg 257021e510 fix, even removing code, good… 2011-06-30 14:09:04 +00:00
tg edaab2cafe tabcomplete ~ and ~foo like $FOO (idea by yofuh) 2011-06-30 13:48:13 +00:00
tg 50bb6e0ec7 typo in comment, from obsd 2011-06-04 16:44:30 +00:00
tg e0a913181b fix regression found by hondza: the full path was shown when tab-completing 2011-06-04 15:11:29 +00:00
tg bef346b938 we use tobool() nowadays 2011-06-04 15:06:50 +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 d72669c66b this one is trickier 2011-04-22 12:16:38 +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 c0e1e7645a static initialisers implicitly null out a variable (I think)
so take care of that (for global variables) to avoid them
moving from .bss to .data
2011-04-22 12:10:14 +00:00
tg 6c45e3e764 avoid namespace conflicts with __attribute__(…) 2011-04-09 21:01:03 +00:00
tg b7824978ad RCSID sync with openbsd, one we had already, one Okan Demirmen stole
from mksh (but attributed, so it’s okay, considering the amount of
patch is not large enough to warrant copyright stuff)
2011-03-16 20:31:33 +00:00
tg 2a3d4db123 lint is your friend 2011-03-13 01:20:25 +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 4e0f597b5d fix prev-hist-word again, thanks Jörg-Volker Peetz 2011-02-09 13:08:18 +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 9b02e15d26 For prev-hist-word, when doing other things in between reset the counter 2011-01-21 22:43:17 +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 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 297e2ced89 fix blocking_read prototype 2010-08-28 16:47:11 +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 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 31b288561f this one was found by scan-build from llvm+clang 2010-07-04 18:52:52 +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 2a72f0e2f0 RCSID sync with oksh, and apply a simplification of theirs, but WITH a
comment what/why added (to aid understanding this code)

I wonder, though, why their x_escape now almost¹ looks like ours… is
that a coïncidence, or do they steal again (without understanding why)?

① they’re missing the semicolon but falsely added the closing bracket
2010-05-22 12:37:49 +00:00
tg c00f87bdb3 Let hi-bit7 characters be “motion characters” for the Emacs editing mode;
this fixes the asymmetry of Esc+b/Esc+f on 「ls ディレクトリ」 as well as
doing ^W on it
2010-03-27 15:26: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 4eb17f8752 remove some more of this ugliness 2010-01-29 09:34:31 +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 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 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 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 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 08ec9ca3ab fix (another… *sigh*) inverse logic error 2009-09-20 17:18:53 +00:00
tg 2ef07a6cc9 shrink MKSH_SMALL by removing certain editor functionality (e.g. the tilde
hack) and functions (up/down/titlecase words; search history PgUp/PgDn)
2009-09-20 17:00:53 +00:00
tg 0cf2df79e9 if things need to be in a specific order, use automated means to provide
such order, instead of relying on manually retaining it…
2009-09-20 15:38:07 +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 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 ed0299042c more use of memcpy(3) when we know destination and source sizes 2009-08-01 20:32:45 +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 e1d8d7ed01 capitalise AT&T® 2009-06-11 12:42:21 +00:00
tg ac6bdf61a4 get rid of a redefinition warning 2009-06-10 19:34:18 +00:00
tg 3cec01a6fd • Fix problem with ^w fix that broke 'B'
Found by Daniel LEVAI
  Fix by Darrin Chandler
  ok millert@
  From merdely@obsd
• more tabs→spaces while here
2009-06-10 19:33:16 +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 5613b3a5ac and today’s last oksh merge, from merdely: I quote:
"make ksh vi mode handle werase more like vi. It's really irritating to
have whole paths go away on ^W instead of just the last bit."

"That looks right to me" millert@, "YES kthx bye!" thib@


.oO(there are vi mode users?) We are not GNU bash, good idea! tg@
2009-06-08 20:22:19 +00:00
tg 0e7b44814b RCSID sync with oksh: cid 10049D8938D01A15AB7, 10049D8A41E43689C5A
already provided this functionality with much more verbose ci msgs
2009-06-08 20:16:01 +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 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 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 2ebd816d63 bind new search-history-{up,down} to ANSI PgUp and PgDn keys
“because we can”
2009-05-16 14:34:57 +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 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