summaryrefslogtreecommitdiffstats
path: root/lib/libedit/read.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* el_map.alt can never be NULL, delete dead codeschwarze2016-05-251-4/+2
| | | | OK czarkoff@
* Saving errno in el_errno is only needed for one purpose:schwarze2016-05-251-26/+20
| | | | | | | | | | | | | | | | | Restoring the original errno found in el_wgetc() after el_wgets() did some cleanup that may have changed errno. Improve clarity and robustness of the code by not setting and inspecting el_errno where it isn't needed; in particular, let keymacro_get() properly report read failure to read_getcmd(). Move el_errno to el_read_t because it's only used in read.c. Never set errno back to zero. Checked with a test program installing a USR1 signal handler without SA_RESTART, for the cases read_getcmd(), ed_quoted_insert(), keymacro_get(), ed_command(), and EL_EDITMODE=0. OK czarkoff@
* Remove debugging ifdefs.schwarze2016-05-241-70/+3
| | | | | | I'm debugging the read module for weeks now, but these ifdefs aren't helpful. OK cpp(1).
* Improve modularization at the chared/read boundary, no functional change.schwarze2016-05-221-9/+50
| | | | | | | | | | | | Stop the read.c module from poking the el_chared.c_macro data structure that used to belong to the chared.c module. Given that no other module, not even chared itself, is using that data, move it into the read modules's own opaque data structure, struct el_read_t. That gets rid of one struct, one #define, one struct member, and one function argument in the chared.h interface. OK czarkoff@
* Move the declaration of the function pointer type el_rfunc_tschwarze2016-05-201-10/+17
| | | | | | | | | | | | | | | from the private header "read.h" to the public header <histedit.h>. That's not an interface change, it was already used and documented publicly, merely not properly declared. Improve encapsulation: Make el_read a pointer to an opaque struct in struct editline, such that "read.h" no longer needs to be included from "el.h" but only from the two files using it, read.c and el.c. Only pass the required el_read_t to el_read_{s,g}etfn(), do not pass the full struct editline. OK czarkoff@, also proofread by Christian Heckendorf <mbie at ulmus dot me>.
* Replace the generated file "fcns.c" by a simpler header "func.h"schwarze2016-05-061-2/+3
| | | | | | | | | | | included only in the one file needing it, "map.c". That allows to define el_action_t directly in "map.h", which in turn allows to stop including "fcns.h" from "el.h" and include it only in the modules needing it. Now we no longer autogenerate any C files. Feedback and OK martijn@. First version also proofread by Christian Heckendorf <mbie at ulmus dot me>.
* Re-introduce the following commit:schwarze2016-04-131-2/+2
| | | | | | | | | | OpenBSD read.c rev. 1.4 1997/06/10 20:10:13 millert FIONREAD takes int *, not long * It got lost in the following merge from NetBSD: OpenBSD read.c rev. 1.10 2003/10/31 08:42:24 otto OK millert@ martijn@
* Cleanup, no functional change:schwarze2016-04-121-16/+10
| | | | | | | * Make the return value from read_getcmd() less confusing. * No need to store that return value; testing it once is enough. * Get rid of one #ifdef section in el_wgets(). OK czarkoff@ martijn@
* * Delete the unimplemented feature XK_EXE.schwarze2016-04-121-11/+1
| | | | | | * Delete the unused macro MIN(). No functional change. OK czarkoff@ martijn@
* delete the "private" and "public" preprocessor macros, just use standard C;schwarze2016-04-111-14/+14
| | | | OK martijn@
* get rid of the non-standard data type "Char" in almost all files;schwarze2016-04-111-13/+11
| | | | ok martijn@
* Move wrapper macros to the two files actually needing them:schwarze2016-04-111-5/+5
| | | | | | | | | | | FUNW, Strlen, Strdup, Strcmp, Strncmp, Strncpy, Strncat -> history.c Strchr, tok_strdup -> tokenizer.c FUN, TYPE, STR -> both of these files OK martijn@ Also proofread by Christian Heckendorf <mbie at ulmus dot me> who reported some whitespace issues in parse.c.
* Delete 26 wrapper macros and two wrapper functions that are noschwarze2016-04-091-6/+6
| | | | | | | | longer needed now that we always compile with wide character support, reducing code obfuscation. OK czarkoff@ martijn@. Diff also proofread by Christian Heckendorf <mbie at ulmus dot me>.
* Always compile with WIDECHAR on and delete that preprocessor switch.schwarze2016-04-091-41/+1
| | | | | OK martijn@. Diff also proofread by Christian Heckendorf <mbie at ulmus dot me>.
* Move more fcntl(,F_GETFL,0) -> fcntl(,F_GETFL).krw2016-04-051-2/+2
| | | | | | No functional change. ok guenther@
* format string fixes in debug code;schwarze2016-03-221-2/+2
| | | | committing right away because this code is not even compiled by default
* Make the read_char() function always take a wchar_t * argument.schwarze2016-03-211-15/+12
| | | | | | | | | | | On first sight, it might look as if this required a bump because it seems to change the public type el_rfunc_t. But we only compile with WIDECHAR, and in that case, there is no change in the interface. This also simplifies some logic by getting rid of the NARROW_READ flag which was broken anyway. OK czarkoff@
* Reduce the FUN() macro madness by no longer applying it to el_[w]getc(3).schwarze2016-03-211-7/+11
| | | | | | | | | Always use el_wgetc(3) internally. In the !WIDECHAR case, casting the result to (Char) is safe because the function returns a byte rather than a character in that case. No functional change except for fixing a printf(3) format string issue when compiled with DEBUG_READ and WIDECHAR. OK czarkoff@
* Merge a few simple fixes from NetBSD:schwarze2016-03-211-6/+10
| | | | | | | | | | NetBSD rev. 1.68 2012/09/10 christos (bugfixes from Steffen Nurpmeso) * el_wgetc(): set el_errno after read_char() failure * el_wgets(): flag error condition after read_getcmd() failure NetBSD rev. 1.69 2012/09/11 christos (bugfix from Christos Zoulas) * read_getcmd(): return failure after el_wgetc() failure NetBSD rev. 1.75 2016/02/12 christos (cleanup from Christos Zoulas) * read_getcmd(): use a constant rather than a magical number
* Cleanup of standard header inclusion:schwarze2016-03-201-3/+6
| | | | | | | | | | | | | 1. Add the missing <errno.h> to sig.c. 2. Do not include standard headers from private headers "chared.h" and "el.h", include them directly where needed. 3. Delete a few needless inclusions of <ctype.h>. 4. Sort the standard headers. 5. Delete _GNU_SOURCE weirdness from histedit.h, that file doesn't even need the access to wcsdup(3) mentioned in the comment. 6. Delete some trailing blanks and blanks before tabs. OK czarkoff@
* Get rid of "#ifdef WIDECHAR" and one goto in read_char(),schwarze2016-03-201-12/+6
| | | | | | | making the code more readable. Instead, provide an mbrtowc(3) replacement function in chartype.[hc], files that encapsulate such system dependencies anyway. No functional change. OK czarkoff@
* Delete the weird IGNORE_EXTCHARS flag, simplifying the codeschwarze2016-03-201-11/+3
| | | | | | | | in the generic low-level function read_char(). Until we fully enable UTF-8 support, instead filter out non-ASCII characters in the more logical place in the high-level function el_gets(3). OK czarkoff@.
* Fix read_char() for the non-UTF-8 case, in particular for systemsschwarze2016-03-201-5/+12
| | | | | | | supporting other multibyte locales or having an internal representation of wchar_t that doesn't match UCS-4. No functional change on OpenBSD, but it makes the code less confusing. OK czarkoff@.
* Fix the CHARSET_IS_UTF8 case in read_char().schwarze2016-03-201-19/+40
| | | | | | | | | | | | | | | | | For now, this mainly help programs explicitly using wide-character functions like el_wgetc(3) and el_wgets(3). 1. After reading an invalid byte sequence, do not throw away additional valid bytes; fix by me using mbrtowc(3), obsoleting utf8_islead(). 2. When read(2) returns EOF, return that information to the caller, do not prod on and potentially access garbage data in the buffer; from Linas Vepstas via NetBSD read.c rev. 1.70 2013/05/27. 3. After read__fixio() failure, restore errno to the one set by read(); from Steffen Nurpmeso via NetBSD read.c rev. 1.68 2012/09/10. 4. After read__fixio() success, restore errno to the initial state upon function entry; fix by me. OK czarkoff@. Also committed to NetBSD.
* remove some whitespace differences with NetBSD; no change with diff -bschwarze2016-01-311-12/+12
|
* Fifth step in synching with NetBSD:schwarze2016-01-301-4/+4
| | | | | | | | | Delete the silly ptr_t and ioctl_t typedefs and delete some "#ifdef notdef" code from "sys.h". No functional change. This makes hist.h identical to the NetBSD version. It reduces the remaining diff from +1526 -734 to +1430 -592. OK czarkoff@
* Fourth step in synching with NetBSD:schwarze2016-01-301-20/+20
| | | | | | | KNF: Remove parentheses from return lines. No object change. This makes emacs.c and prompt.c identical to the NetBSD versions. It reduces the remaining diff from +2053 -1261 to +1526 -734. OK czarkoff@
* Third step in synching with NetBSD:schwarze2016-01-301-10/+10
| | | | | | | | | | | * rename fkey_t to funckey_t and el_term_t to el_terminal_t * rename struct editline member el_term to el_terminal * rename many functions in terminal.c from term_*() to terminal_*(), for consistency with the file name and to not look related to <term.h> No functional change. This makes refresh.c and sig.c almost identical to the NetBSD versions. It reduces the remaining diff from +2446 -1805 to +2053 -1420. OK czarkoff@
* Second step in synching with NetBSD:schwarze2016-01-291-3/+3
| | | | | | | | | | | * Rename some types from *key*_t to *keymacro*_t. * Rename struct editline member el_key to el_keymacro. * Rename some functions in keymacro.c from key*() to keymacro*(). This removes the conflict of key_clear(), key_end(), and key_print() with macros in <term.h>. No functional change. This makes keymacro.h identical to the NetBSD version. It reduces the remaining diff from +2640 -1998 to +2446 -1805. OK czarkoff@
* Remove non-exposed malloc/realloc/free wrappers, and then substitutederaadt2014-10-171-2/+2
| | | | | reallocarray() where it helps. ok doug
* sync with upstream, retaining local modifications.okan2011-07-071-14/+18
| | | | ok nicm@
* Update libedit to bring it into sync with the latest version from NetBSD.nicm2010-06-301-58/+167
| | | | ok deraadt
* rcsid[] and sccsid[] and copyright[] are essentially unmaintained (andderaadt2009-10-271-8/+1
| | | | | | | unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
* Sync libedit to NetBSD libedit as of Nov 8, 2003.otto2003-11-251-20/+24
| | | | Tested by jmc@ djm@ and myself
* Update to NetBSD libedit (from Oct 1, 2003), adding some stringotto2003-10-311-293/+443
| | | | | | | | | | | | | | | | | | cleaning and history bug fixes. The code includes GNU libreadline functionality, but the corresponding header files are not installed, since some libreadline functions are missing. There are some minor API changes, notably: old: EditLine *el_init(const char *, FILE *, FILE *); new: EditLine *el_init(const char *, FILE *, FILE *, FILE *); old: HistEvent *history(History *h, int op, ...); new: int history(History *h, HistEvent *ev, int op, ...); plus some changes in operation names. See editline(3) for details. Tested by djm@, mouring@, jmc@. ok deraadt@
* Remove the advertising clause in the UCB license which Berkeleymillert2003-06-021-7/+3
| | | | rescinded 22 July 1999. Proofed by myself and Theo.
* is -Wall clean by making rcsid constavsm2003-05-011-2/+2
|
* Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.millert2002-02-161-5/+5
|
* Make this compile is FIONREAD is defined. Guess this wasmillert1997-08-201-3/+6
| | | | | never tested. Closed NetBSD PR#4012 from David Holland <dholland@bordeaux.eecs.harvard.edu>.
* Updates from NetBSD (christos@netbsd.org)millert1997-06-291-5/+9
| | | | | | | | | | | | | * Portability fixes: __const -> const BADSIG -> SIG_ERR int flags -> u_int flags #if __STDC__ -> #ifdef __STDC__ * Don't allow CSWTCH to interfere with CSUSP on __SVR4 systems. * Return -1 if the terminal set operation resulted in dumb terminal settings. * Handle properly the case where the last line in the sourced file does not have a trailing '\n'. From Jeffrey C Honig. * editrc -> editline in editline(3)
* Change a long to and int.millert1997-06-101-3/+3
|
* fix el_source() - a block needed braces around it (from NetBSD)millert1997-03-141-19/+20
| | | | | | Some strcpy() -> strncpy (from NetBSD) Some KNF Add current NetBSD tags
* Merge in NetBSD libedit changes and new man pages. Also fix somemillert1997-01-161-1/+12
| | | | | | | | | | | | | | | | | | strncpy() usage in their code. NetBSD change log was: * add a man page for the editline routines * add a man page describing editrc * fix bugs in el_parse(): * didn't execute command when program name matched (test reversed) * was checking against empty string instead of program name * after checks, command to run also pointed to empty string * document ^char and \ escape sequences * when parsing ^char control chars, check the correct char when determining validity (previously, ^char was a NOP interpreted as the literal string because of this bug) * Implement CC_REDISPLAY, which (unlike CC_REFRESH) redraws the entire input * line (a la ^R). This is useful if the binding outputs information and * mucks up the input line. To be used in ``list-choices'' bindings (refer * to the ^D binding in csh when filec is set)
* initial import of NetBSD treederaadt1995-10-181-0/+437