Commit Graph

780 Commits

Author SHA1 Message Date
christos ef72f68d26 Follow the man page for EL_GETTC and not require a NULL terminated argument
list: https://reviews.llvm.org/D61191
2019-04-26 16:56:57 +00:00
abhinav 63147cb59c PR lib/54131 - declare the loop variable outside the for loop 2019-04-20 08:44:10 +00:00
christos 2f37aad7a2 PR/52359: Benjamin Lorenz: When resizing because of a signal save and restore
the cursor position, since it does not change.
2019-04-12 17:30:49 +00:00
christos 7512edc245 PR/54117: Paavo Helde: Fix memory overrun: Account for the closing quote
in memory allocation if quoted.
2019-04-12 15:12:29 +00:00
abhinav c93cba3ab2 Perform quoting of filename completions when there are multiple matches as well
Quoting of special characters in filename completion was implemented for single match
case, this enables it for multiple matches as well. For example:

$ touch 'foo bar'
$ touch 'foo baz'
$ ls fo<TAB>
autocompletes to =>
$ ls foo\ ba
hitting <TAB> again shows:
foo bar foo baz

This required unescaping escape sequences generated during last completion
in order to find the word to complete.

While there, also update the test to include cases for multiple matches.

Reviewed by christos
2019-03-31 03:04:57 +00:00
abhinav e09538bda2 Only quote the completion matches if we are doing filename completion
If the user supplies a value for the attempted_completion_function parameter
then we cannot be sure if the completion is for filename or something else, in such
a case don't attempt to quote the completion matches.

Reviewed by christos

This should address PR lib/54067
2019-03-24 16:42:49 +00:00
christos 52b10dfde0 PR/53983: Jonathan Perkins: Fix types for readline compatibility 2019-02-15 23:20:35 +00:00
christos ccbb6255be PR/53981: Jonathan Perkins: history_list should null-terminate 2019-02-14 20:09:12 +00:00
christos 11e9eb638e PR/53856: F. Aragon: editline/libedit not prompting colors in readline mode 2019-01-10 18:41:56 +00:00
uwe 13b962ac1e Fix mis-applied change in previous. Don't increment r_oldcv twice.
PR lib/53803
2019-01-04 03:03:44 +00:00
christos 85390d7315 Add a couple more readline compat functions. 2018-12-02 16:58:13 +00:00
christos f04c2e3e34 Fix off by one <tsahara at iij> 2018-11-29 03:10:20 +00:00
christos e9933f923a From Yuichiro Naito (FreeBSD):
hrs@ says that
(cbp >= MB_LEN_MAX) condition is necessary for checking invalid
byte sequences.  If malicious input was given, libedit would read
byte sequences forever.
2018-11-25 16:21:04 +00:00
christos 2cb4fa4296 From Yuichiro Naito (FreeBSD):
hrs@ says that wctomb(3) has an internal shift state,
if wctomb(3) is called outside of libedit,
the internal state can be changed and causes miscalculate multibyte size.

So in this part, wcrtomb(3) should be used.
wcrtomb(3) requires that shift state is given in the argument.
We always initialize the shift state in ct_enc_width() to keep independent
from outside of libedit.
2018-11-25 16:20:28 +00:00
christos e06500e20d PR/53682: Jordan Lewis: use newlines instead of padded spaces when restoring
multi-line histories.
2018-11-24 12:17:35 +00:00
christos e91c30539f fix compilation 2018-11-18 17:15:41 +00:00
christos 18bb6ea433 Remove utf-8 requirement (Yuichiro NAITO) 2018-11-18 17:09:39 +00:00
christos b15150dc5e Apply revisions 1.21, 1.22 from OpenBSD:
In re_fastputc(), set lastline to the new line, not the previous
line so it gets initialized properly.  Fixes a crash in bc with
MALLOC_OPTIONS=UJ.  OK deraadt@, committing on behalf of yasuoka@

Initialize "old" screen buffer lines before use; otherwise, they would
never get NUL-terminated and cause read buffer overruns.
This fixes for example segfaults in sftp(1) that could be triggered
by typing in an extremely long string (more than one line - the longer,
the likelier to crash), then hitting backspace once.
Problem reported and patch OK'ed by sthen@.

XXX: pullup-8
2018-10-23 16:49:13 +00:00
kre b8b0289d66 Fix editing mistake, remove ) from func call that is now gone. 2018-09-13 09:03:40 +00:00
christos 26f83385d3 more efficient to use decode_result :-) Pointed out by kre@ 2018-09-13 01:26:33 +00:00
christos 6da79ee096 PR/53597: Yasuhiro Horimoto: Avoid segmentation fault in bad history file. 2018-09-12 22:10:35 +00:00
christos a3c16b5549 Provide more compatibility with readline headers; now python-3.6.5 works
when changing 'readline' -> 'edit' in setup.py.
Revert previous conditional setting of unbuffered.
2018-06-09 17:41:55 +00:00
christos 01f10711d4 fix uninitialized 2018-05-04 20:38:26 +00:00
abhinav 2afc179c8f Handle filename autocompletion when the cursor is at a backslash or quote character
For example, handle following case:
	$ touch 'foo bar'
	$ ls foo\<TAB> --> $ ls foo\ bar

Also add test cases for this.

Thanks to Christos for review
2018-05-04 16:39:14 +00:00
abhinav b36e4c8fbf Add '*' and '[' to the list of characters which need escaping during autocompletion 2018-05-02 08:45:03 +00:00
christos 7767204c93 PR/53058: Nikhil Benesch: use correctly typed variables (wchar_t vs wint_t)
as parameters.
2018-02-26 17:36:14 +00:00
christos ff1a7c8cc8 Only FLUSH if we are ending libedit; DRAIN if we suspend for readline.
This allows pasting multiline buffers (Gerry Swislow)
2018-01-01 22:32:46 +00:00
uwe ec59efb2b5 The order in which the arguments to a function are evaluated is
undefined, so don't use va_arg() twice.

PR lib/52849
2017-12-23 18:25:03 +00:00
christos 47abce8f3f For applications that don't issue their own prompt (like python)
don't set unbuffered unless they've already printed the prompt.
This avoids printing the prompt before the application has a chance
to process the input line.
From sjg@
2017-12-08 16:56:23 +00:00
abhinav 3c9fe72fbc Add NULL check after doing memory allocation at a couple of places
ok christos@
2017-10-27 18:16:09 +00:00
abhinav 92a9b5c3ba Add copyright and rcs header to the test program.
Also, remove a test case which was not supposed to be there.
(While that test case works with the changes I committed, testing that
 test case with the test program is not possible in its current form. I'm
 working on that.)
2017-10-15 19:17:30 +00:00
abhinav fa61555626 Add support for escaping special characters when doing filename completion.
For instance if the file name is "foo bar":
$ ls foo<TAB>
should get autocompleted to:
$ ls foo\ bar

Works for similar other characters too, which need escaping.

Also, add an accompanying test program to ensure the escaping is correct
in various scenarios (within quotes, without quotes, with other special characeters)

Thanks to Christos for reviews, help and feedback.
2017-10-15 18:59:00 +00:00
abhinav cf2b6f694e Fix typo in comment 2017-10-11 06:49:03 +00:00
kre 5312bfd48d PR lib/52547 - read_history (readline.c) should now sets history_length.
Patch from Yen Chi Hsuan in the PR, extracted from Apple's version of
readline.c, then modified by me to be consistent about what the return
value really is.
2017-09-17 08:10:08 +00:00
abhinav 7a99333ffa Fix indentation (convert spaces to tab) 2017-09-16 20:40:34 +00:00
christos b2ad969a13 For readline emulation, don't reset the tty to "sane" (cooked) mode if we
did not start this way. Also set and reset the tty on entry and exit from
readline() since this is what readline does.
2017-09-05 18:07:59 +00:00
wiz 3e39477b0a Remove trailing whitespace; convert Xr readline to Nm readline, since
we won't get a readline man page in base.
2017-09-02 06:48:10 +00:00
christos 27916d7c22 PR/51517: Jay West: Tty settings not restored on exit
PR/51518: Jay West: prompt is interleaved with client output

Both these issues are caused by rl_restore_handler not DTRT; fix
it so that it kills the internal libedit state completely. This is
inefficient, but it works.

Also fix:
1. add append_history()/H_NSAVE_FP
2. call the rl_startup_hook before printing the first prompt as documented.
   callint it from rl_initialize breaks python, because the callback ends
   up being invoked before the readline module is installed, and we end up
   dereferencing a NULL pointer.
3. add el_resize_terminal.

With those changes, s/lreadline/ledit/g in python works.
2017-09-01 10:19:10 +00:00
wiz 01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
kre e3112e6cea Allow wide characters (properly encoded as byte strings according to LC_CTYPE)
to be (perhaps part of) the "invisible" characters in a prompt, or the
required prompt character which follows the literal sequence (this character
must be one with a printing column width >= 1).  The literal indicator
character (which is just a marker, and not printed anywhere) (the PSlit
parameter in sh(1)) can also be a wide char (passed to libedit as a wchar_t,
encoded as that by sh(1) or other applications that support this.)

Note: this has currently only been tested with everything ascii (C locale).
2017-06-30 20:26:52 +00:00
kre 2977f4314f Fix an obvious, but almost invisible typo (avoid some core dumps). 2017-06-29 02:54:40 +00:00
christos f51c99da13 fix comment 2017-06-27 23:29:12 +00:00
christos 9abf018dda add literal escape sequence support, patterned after the tcsh ones. 2017-06-27 23:25:13 +00:00
christos bec29a0714 remove unused variable 2017-06-27 23:24:19 +00:00
christos 3d09ba7b3f - add literal sequence handling. 2017-06-27 23:23:48 +00:00
christos 06d596a8e9 - handle literal escape sequence printing.
- factor out common code in allocation and freeing of the display.
2017-06-27 23:23:09 +00:00
christos 0a321818f6 mention the limitation of the literal sequence delimiter. 2017-06-27 23:22:20 +00:00
kre 00f36e26a6 Include EDITRC in doc. 2017-06-27 01:22:58 +00:00
kre 4fa1b5993a Make the default editrc file be $EDITRC (from env) if set, falling back
to $HOME/.editrc otherwise.    Better support for this in sh coming.
2017-06-27 00:47:37 +00:00
christos c74ab69c28 Add DragonFly. 2017-05-22 19:16:25 +00:00