The NetBSD Project

CVS log for src/lib/libedit/read.c

[BACK] Up to [cvs.NetBSD.org] / src / lib / libedit

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.108 / (download) - annotate - [select for diffs], Sun Oct 30 19:11:31 2022 UTC (16 months, 4 weeks ago) by christos
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, HEAD
Changes since 1.107: +14 -11 lines
Diff to previous 1.107 (colored)

improvements in malloc/free handling.

Revision 1.107 / (download) - annotate - [select for diffs], Sun Aug 15 10:08:41 2021 UTC (2 years, 7 months ago) by christos
Branch: MAIN
Changes since 1.106: +3 -3 lines
Diff to previous 1.106 (colored)

Disable attempts to handle EINTR and non-blocking I/O by default. It is
confusing to other programs and unexpected behavior. Reported by Ingo Schwarze.
This behavior is now controlled with EL_SAFEREAD.

Revision 1.103.6.2 / (download) - annotate - [select for diffs], Mon Apr 13 08:03:12 2020 UTC (3 years, 11 months ago) by martin
Branch: phil-wifi
Changes since 1.103.6.1: +3 -4 lines
Diff to previous 1.103.6.1 (colored) to branchpoint 1.103 (colored) next main 1.104 (colored)

Mostly merge changes from HEAD upto 20200411

Revision 1.106 / (download) - annotate - [select for diffs], Tue Jul 23 10:18:52 2019 UTC (4 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Changes since 1.105: +3 -4 lines
Diff to previous 1.105 (colored)

PR/54399: Sen Tempel: Uninitialized memory access in libedit history.
Initialize the buffer using calloc. While here change all malloc(a * sizeof(b))
to calloc(a, sizeof(b)). XXX: should fix realloc similarly.

Revision 1.103.6.1 / (download) - annotate - [select for diffs], Mon Jun 10 22:05:23 2019 UTC (4 years, 9 months ago) by christos
Branch: phil-wifi
Changes since 1.103: +3 -9 lines
Diff to previous 1.103 (colored)

Sync with HEAD

Revision 1.103.4.1 / (download) - annotate - [select for diffs], Mon Nov 26 01:52:12 2018 UTC (5 years, 4 months ago) by pgoyette
Branch: pgoyette-compat
CVS Tags: pgoyette-compat-merge-20190127
Changes since 1.103: +3 -9 lines
Diff to previous 1.103 (colored) next main 1.104 (colored)

Sync with HEAD, resolve a couple of conflicts

Revision 1.105 / (download) - annotate - [select for diffs], Sun Nov 25 16:21:04 2018 UTC (5 years, 4 months ago) by christos
Branch: MAIN
CVS Tags: phil-wifi-20190609, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126
Changes since 1.104: +7 -2 lines
Diff to previous 1.104 (colored)

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.

Revision 1.104 / (download) - annotate - [select for diffs], Sun Nov 18 17:09:39 2018 UTC (5 years, 4 months ago) by christos
Branch: MAIN
Changes since 1.103: +2 -13 lines
Diff to previous 1.103 (colored)

Remove utf-8 requirement (Yuichiro NAITO)

Revision 1.102.6.1 / (download) - annotate - [select for diffs], Sun Jul 23 14:41:26 2017 UTC (6 years, 8 months ago) by snj
Branch: netbsd-8
CVS Tags: netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, matt-nb8-mediatek-base, matt-nb8-mediatek
Changes since 1.102: +3 -4 lines
Diff to previous 1.102 (colored) next main 1.103 (colored)

Pull up following revision(s) (requested by kre in ticket #102):
	lib/libedit/Makefile: 1.64-1.65
	lib/libedit/editline.3: 1.94-1.96
	lib/libedit/editrc.5: 1.33
	lib/libedit/el.c: 1.93-1.94
	lib/libedit/el.h: 1.42
	lib/libedit/literal.c: 1.1-1.3
	lib/libedit/literal.h: 1.1-1.2
	lib/libedit/prompt.c: 1.27
	lib/libedit/read.c: 1.103
	lib/libedit/refresh.c: 1.52-1.54
	lib/libedit/refresh.h: 1.11
	lib/libedit/terminal.c: 1.33
Make the default editrc file be $EDITRC (from env) if set, falling back
to $HOME/.editrc otherwise.    Better support for this in sh coming.
--
Include EDITRC in doc.
--
mention the limitation of the literal sequence delimiter.
--
- handle literal escape sequence printing.
- factor out common code in allocation and freeing of the display.
--
- add literal sequence handling.
--
remove unused variable
--
add literal escape sequence support, patterned after the tcsh ones.
--
fix comment
--
Fix an obvious, but almost invisible typo (avoid some core dumps).
--
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).
--
Remove workaround for ancient HTML generation code.

Revision 1.103 / (download) - annotate - [select for diffs], Tue Jun 27 23:24:19 2017 UTC (6 years, 9 months ago) by christos
Branch: MAIN
CVS Tags: phil-wifi-base, pgoyette-compat-base, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, perseant-stdc-iso10646-base, perseant-stdc-iso10646
Branch point for: phil-wifi, pgoyette-compat
Changes since 1.102: +3 -4 lines
Diff to previous 1.102 (colored)

remove unused variable

Revision 1.101.2.1 / (download) - annotate - [select for diffs], Sat Jan 7 08:56:04 2017 UTC (7 years, 2 months ago) by pgoyette
Branch: pgoyette-localcount
Changes since 1.101: +3 -2 lines
Diff to previous 1.101 (colored) next main 1.102 (colored)

Sync with HEAD.  (Note that most of these changes are simply $NetBSD$
tag issues.)

Revision 1.102 / (download) - annotate - [select for diffs], Sun Dec 11 15:47:06 2016 UTC (7 years, 3 months ago) by christos
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, netbsd-8-base, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: netbsd-8
Changes since 1.101: +3 -2 lines
Diff to previous 1.101 (colored)

PR/51706: Amir Plivatsky: Fix memory leak

Revision 1.101 / (download) - annotate - [select for diffs], Wed May 25 13:01:11 2016 UTC (7 years, 10 months ago) by christos
Branch: MAIN
CVS Tags: pgoyette-localcount-base, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, localcount-20160914
Branch point for: pgoyette-localcount
Changes since 1.100: +35 -63 lines
Diff to previous 1.100 (colored)

abstract read code to a single function (Ingo Schwarze)

Revision 1.100 / (download) - annotate - [select for diffs], Tue May 24 19:31:27 2016 UTC (7 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.99: +2 -4 lines
Diff to previous 1.99 (colored)

el_map.alt can't be NULL here (Ingo Schwarze)

Revision 1.99 / (download) - annotate - [select for diffs], Tue May 24 17:42:54 2016 UTC (7 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.98: +4 -71 lines
Diff to previous 1.98 (colored)

remove debug read (Ingo Schwarze)

Revision 1.98 / (download) - annotate - [select for diffs], Tue May 24 15:00:45 2016 UTC (7 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.97: +21 -27 lines
Diff to previous 1.97 (colored)

From Ingo Schwarze:

Reduce obfuscation of errno handling. There is only one purpose
non-local errno handling is needed for:  Inside el_wgets(), several
functions call down indirectly to el_wgetc(), many of them via the
dispatch table.  When el_wgetc() fails, it does properly report
failure, but then various cleanup is done which may clobber errno.
But when returning due to failure, el_wgets() wants to have errno
set to the reason of the original read failure, not to the reason
of some subsequent failure of some cleanup operation.  So el_wgetc()
needs to save errno, and if it's non-zero, el_wgets() needs to
restore it on failure.

This core logic is currently obscured by the fact that el_errno
is set and inspected at some additional places where it isn't needed.
Besides, since el_wgetc() and and el_wgets() are both in read.c,
el_errno does not need to be in struct editline, it can and should
be local to read.c in struct el_read_t.

Let's look at what can be simplified.

 1. keymacro_get() abuses el_errno instead of having a proper
    error return code.  Adding that error return code is easy
    because node_trav() already detects the condition and an
    adequate code is already defined.  Returning it, testing
    for it in read_getcmd(), and returning with error from there
    removes the need to inspect el_errno from el_wgets() after
    calling read_getcmd().
    Note that resetting lastchar and cursor and clearing buffer[0]
    is irrelevant.  The code returns from el_wgets() right afterwards.
    Outside el_wgets(), these variables are no longer relevant.
    When el_wgets() is called the next time, it will call ch_reset()
    anyway, resetting the two pointers.  And as long as lastchar
    points to the beginning of the buffer, the contents of the
    buffer won't be used for anything.

 2. read_getcmd() doesn't need to set el_errno again after el_wgetc()
    failure since el_wgetc() already did so.  While here, remove
    the silly "if EOF or error" comments from the el_wgetc()
    return value tests.  It's a public interface documented in a
    manual, so people working on the implementation can obviously
    be expected to know how it works.  It's a case of

      count++;  /* Increment count. */

 3. In the two code paths of el_wgets() that lead up to "goto noedit",
    there is no need to save the errno because nothing that might
    change it happens before returning.

For clarity, since el_wgets() is the function restoring the errno,
also move initializing it to the same function.

Finally, note that restoring errno when the saved value is zero is
wrong.  No library code is ever allowed to clear a previously set
value of errno.  Only application programs are allowed to do that,
and even they usually don't need to do so, except when using certain
ill-designed interfaces like strtol(3).

I tested that the behaviour remains sane in the following cases,
all during execution of el_wgets(3) and with a signal handler
for USR1 installed without SA_RESTART.

 * Enter some text and maybe move around a bit.
   Then send a USR1 signal.
   The signal gets processed, then read_char() resumes reading.
   Send another USR1 signal.
   Now el_wgets() sets errno=EINTR and returns -1.

 * Press Ctrl-V to activate ed-quoted-insert.
   Then send a USR1 signal.
   The signal gets processed, then read_char() resumes reading.
   Send another USR1 signal.
   ed_quoted_insert() returns ed_end_of_file(), i.e. CC_EOF,
   and el_wgets() returns 0.

 * Press a key starting a keyboard macro.
   Then send a USR1 signal.
   The signal gets processed, then read_char() resumes reading.
   Send another USR1 signal.
   Now el_wgets() sets errno=EINTR and returns -1.

 * Press : to enter builtin command mode.
   Start typing a command.
   Then send a USR1 signal.
   The signal gets processed, then read_char() resumes reading.
   Send another USR1 signal.
   Now c_gets() returns -1, ed_command() beeps and returns CC_REFRESH,
   and el_wgets() resumes operation as it should.

I also tested with "el_set(el, EL_EDITMODE, 0)", and it returns
the right value and sets errno correctly.

Revision 1.97 / (download) - annotate - [select for diffs], Sun May 22 19:44:26 2016 UTC (7 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.96: +50 -9 lines
Diff to previous 1.96 (colored)

Stop the read module from poking the el_chared.c_macro data structure
currently belonging to the chared module.  The read module does so
from three of its functions, while no other module uses the macro
data, not even the chared module itself.  That's quite logical
because macros are a feature of input handling, all of which is
done by the read module, and none by the chared module.  So move
the data into the read modules's own opaque data structure, struct
el_read_t.

That simplifies internal interfaces in several respects: The
semi-public chared.h has one fewer struct, one fewer #define, and
one fewer member in struct el_chared_t; all three move to one single
C file, read.c, and are now module-local.  And the internal interface
function ch_reset() needs one fewer argument, making the code of many
functions in various modules more readable.

The price is one additional internal interface function, read_end(),
10 lines long including comments, called publicly from exactly one
place: el_end() in el.c.  That's hardly an increase in complexity
since most other modules already have their *_end() function, read.c
was the odd one out not having one.

From Ingo Schwarze

Revision 1.96 / (download) - annotate - [select for diffs], Mon May 9 21:46:56 2016 UTC (7 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.95: +7 -7 lines
Diff to previous 1.95 (colored)

s/protected/libedit_private/g

Revision 1.95 / (download) - annotate - [select for diffs], Tue Apr 19 19:50:53 2016 UTC (7 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.94: +18 -11 lines
Diff to previous 1.94 (colored)

From Ingo Schwarze:
 - Put the data type el_rfunc_t into the public header <histedit.h>.
 - Make el_read in struct editline an opaque pointer rather
   than an embedded struct.
 - Do not include "read.h" everywhere, but only in the two files
   needing access to el_read, read.c and el.c.
 - To functions that don't need more, pass the struct el_read_t *
   rather than the full EditLine *.
 - Of course, that means that read_init() can now fail from
   memory exhaustion, but it's easy to clean up after that.

Revision 1.94 / (download) - annotate - [select for diffs], Mon Apr 18 17:01:19 2016 UTC (7 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.93: +3 -2 lines
Diff to previous 1.93 (colored)

From Ingo Schwarze:
 * Replace fcns.c by a shorter and simpler func.h
   and include it only in the one file needing it, map.c.
 * Combine help.h and help.c into a simplified help.h
   and include it only in the one file needing it, map.c.
 * Check the very simple, static files editline.c, historyn.c, and
   tokenizern.c into CVS rather than needlessly generating them.
 * So we no longer autogenerate any C files.  :-)
 * Shorten and simplify makelist by deleting the options -n, -e, -bc,
   and -m; the latter was unused and useless in the first place.
 * Move the declaration of el_func_t from fcns.h to the header
   actually needing it, map.h.  Since that header is already
   included by el.h for unrelated reasons, that makes el_func_t
   just as globally available as before.
 * No longer include the simplified fcns.h into el.h,
   include it directly into the *.c files needing it.

Revision 1.93 / (download) - annotate - [select for diffs], Tue Apr 12 11:15:46 2016 UTC (7 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.92: +3 -3 lines
Diff to previous 1.92 (colored)

FIONREAD takes int as an argument (Ingo Schwarze)

Revision 1.92 / (download) - annotate - [select for diffs], Tue Apr 12 00:16:06 2016 UTC (7 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.91: +10 -26 lines
Diff to previous 1.91 (colored)

From Ingo Schwarze:

 * Delete the stubs of the XK_EXE mechanism that was never implemented.
   From a security, stability, and simplicity perspective, i would
   consider implementing it a truly terrible idea, so let's better
   get rid of it.

 * Do not use the local variable "num" in el_wgets() alternately for
   two completely different purposes.  Only use it for the number
   of characters read, as stated in the comment (or -1 as long as
   that number is still unknown), not for the (more or less boolean)
   return value of read_getcmd().  Actually, there is no need at
   all to save the latter return value after testing it once.

 * The function read_getcmd() has very unusual return values:
   It returns -1 for success and 0 for EOF/error.  Switch that around
   to 0 for success and -1 for EOF/error to be less confusing, and
   get rid of the OKCMD preprocessor macro.

 * Get rid of one #ifdef section in el_wgets() by using
   el->el_chared.c_macro directly at the only place
   where it is used.

 * Delete the unused MIN() macro.

Revision 1.91 / (download) - annotate - [select for diffs], Mon Apr 11 18:56:31 2016 UTC (7 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.90: +14 -14 lines
Diff to previous 1.90 (colored)

Get rid of private/public; keep protected (Ingo Schwarze)

Revision 1.90 / (download) - annotate - [select for diffs], Mon Apr 11 00:50:13 2016 UTC (7 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.89: +11 -13 lines
Diff to previous 1.89 (colored)

Char -> wchar_t from Ingo Schwarze.

Revision 1.89 / (download) - annotate - [select for diffs], Mon Apr 11 00:22:48 2016 UTC (7 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.88: +7 -7 lines
Diff to previous 1.88 (colored)

more macro WIDECHAR undoing from Ingo Schwarze.

Revision 1.88 / (download) - annotate - [select for diffs], Sat Apr 9 18:43:17 2016 UTC (7 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.87: +8 -5 lines
Diff to previous 1.87 (colored)

More WIDECHAR elimination (Ingo Schwarze)

Revision 1.87 / (download) - annotate - [select for diffs], Wed Mar 23 22:27:48 2016 UTC (8 years ago) by christos
Branch: MAIN
Changes since 1.86: +2 -42 lines
Diff to previous 1.86 (colored)

Start removing the WIDECHAR ifdefs; building without it has stopped working
anyway. (Ingo Schwarze)

Revision 1.86 / (download) - annotate - [select for diffs], Wed Mar 2 19:24:20 2016 UTC (8 years ago) by christos
Branch: MAIN
Changes since 1.85: +3 -3 lines
Diff to previous 1.85 (colored)

PR/50880: David Binderman: Remove redundant code.
While here, fix all debugging formats.

Revision 1.85 / (download) - annotate - [select for diffs], Wed Feb 24 17:20:01 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.84: +3 -6 lines
Diff to previous 1.84 (colored)

Tuck in mbstate_t to the wide char version only to avoid exposing the zeroing
hack and doing it in the narrow case.

Revision 1.84 / (download) - annotate - [select for diffs], Wed Feb 24 17:13:22 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.83: +13 -16 lines
Diff to previous 1.83 (colored)

Make the read_char function always take a wchar_t * argument (Ingo Schwarze)

Revision 1.83 / (download) - annotate - [select for diffs], Wed Feb 24 14:25:38 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.82: +12 -8 lines
Diff to previous 1.82 (colored)

Get split el_getc and el_wgetc completely and call el_wgetc internally.
Change some character constants to they wide versions. (Ingo Schwarze)

Revision 1.82 / (download) - annotate - [select for diffs], Wed Feb 17 19:47:49 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.81: +4 -4 lines
Diff to previous 1.81 (colored)

whitespace and header sorting changes (Ingo Schwarze). No functional changes.

Revision 1.81 / (download) - annotate - [select for diffs], Tue Feb 16 22:53:14 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.80: +5 -2 lines
Diff to previous 1.80 (colored)

More header cleanups from Ingo Schwarze.

Revision 1.80 / (download) - annotate - [select for diffs], Tue Feb 16 15:53:48 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.79: +2 -5 lines
Diff to previous 1.79 (colored)

From Ingo Scharze:
Let "el.h" include everything needed for struct editline,
and don't include that stuff multiple times.  That also improves
consistency, also avoids circular inclusions, and also makes it
easier to follow what is going on, even though not quite as nice.
But it seems like the best we can do...

Revision 1.79 / (download) - annotate - [select for diffs], Tue Feb 16 14:08:25 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.78: +3 -2 lines
Diff to previous 1.78 (colored)

cleanup chartype.h includes (Ingo Schwarze)

Revision 1.78 / (download) - annotate - [select for diffs], Tue Feb 16 14:06:05 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.77: +4 -2 lines
Diff to previous 1.77 (colored)

cleanup inclusion of histedit.h (Ingo Schwarze)

Revision 1.77 / (download) - annotate - [select for diffs], Sun Feb 14 14:47:48 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.76: +7 -13 lines
Diff to previous 1.76 (colored)

From Ingo Schwartze:

Next step:  Remove #ifdef'ing in read_char(), in the same style
as we did for setlocale(3) in el.c.

A few remarks are required to explain the choices made.

 * On first sight, handling mbrtowc(3) seems a bit less trivial
   than handling setlocale(3) because its prototype uses the data
   type mbstate_t from <wchar.h>.  However, it turns out that
   "histedit.h" already includes <wchar.h> unconditionally (i don't
   like headers including other headers, but that ship has sailed,
   people are by now certainly used to the fact that including
   "histedit.h" doesn't require including <wchar.h> before), and
   "histedit.h" is of course included all over the place.  So from
   that perspective, there is no problem with using mbrtowc(3)
   unconditionally ever for !WIDECHAR.

 * However, <wchar.h> also defines the mbrtowc(3) prototype,
   so we cannot just #define mbrtowc away, or including the header
   will break.  It would also be a bad idea to porovide a local
   implementation of mbrtowc() and hope that it overrides the one
   in libc.  Besides, the required prototype is subtly different:
   While mbrtowc(3) takes "wchar_t *" as its first argument, we
   need a function that takes "Char *".  So unfortunately, we have
   to keep a ct_mbrtowc #define, at least until we can maybe get
   rid of "Char *" in the more remote future.

 * After getting rid of the #else clause in read_char(), we can
   pull "return 1;" into the default: clause.  After that, we can
   get rid of the ugly "goto again_lastbyte;" and just "break;".
   As a bonus, that also gets rid of the ugly CONSTCOND.

 * While here, delete the unused ct_mbtowc() from chartype.h.

Revision 1.76 / (download) - annotate - [select for diffs], Fri Feb 12 15:36:08 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.75: +5 -13 lines
Diff to previous 1.75 (colored)

GC IGNORE_EXTCHARS and simplify code (Ingo Schwarze)

Revision 1.75 / (download) - annotate - [select for diffs], Fri Feb 12 15:11:09 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.74: +16 -12 lines
Diff to previous 1.74 (colored)

From Ingo Schwarze:

If CHARSET_IS_UTF8 is not set, read_char() is broken in a large
number of ways:

 1. The isascii(3) check can yield false positives.  If a string in
    an arbitrary encoding contains a byte in the range 0..127,
    that does not at all imply that it forms a character all by
    itself, and even less that it represents the same character
    as in ASCII.  Consequently, read_char() may return characters
    the user never typed.
    Even if the encoding is not state dependent, the assumption that
    bytes in the range 0..127 represent ASCII characters is broken.
    Consider UTF-16, for example.

 2. The reverse problem can also occur.  In an arbitrary encoding,
    there is no guarantee that a character that can be represented
    by ASCII is represented by a seven-bit byte, and even less by
    the same byte as in ASCII.
    Even for single-byte encodings, these assumptions are broken.
    Consider the ISO 646 national variants, for example.
    Consequently, the current code is insufficient to keep ASCII
    characters working even for single-byte encodings.

 3. The condition "++cbp != 1" can never trigger (because initially,
    cbp is 0, and the code can only go back up via the final goto,
    which has another cbp = 0 right before it) and it has no effect
    (because cbp isn't used afterwards).

 4. bytes = ct_mbtowc(cp, cbuf, cbp) is broken.  If this returns -1,
    the code assumes that is can just call mbtowc(3) again for later
    input bytes.  In some implementations, that may even be broken
    for state-independent encodings, but trying again after mbtowc(3)
    failure certainly produces completely erratic and meaningless
    results in state-dependent encodings.

 5. The assignment "*cp = (Char)(unsigned char)cbuf[0]" is
    completely bogus.  Even if the byte cbuf[0] represents a
    character all by itself, which it usually will not, whether
    or not the cast produces the desired result depends on the
    internal representation of wchar_t in the C library, which
    the application program can know nothing about.  Even for ASCII
    in the C/POSIX locale, an ASCII character other than '\0' ==
    L'\0' == 0 need not have the same numeric value as a char and
    as a wchar_t.

To summarize, this code only works if all of the following
conditions hold:

 - The encoding is a single-byte encoding.
 - ASCII is a subset of the encoding.
 - The implementation of mbtowc(3) in the C library does not
   require re-initialization after encoding errors.
 - The implementation of wchar_t in the C library uses the
   same numerical values as ASCII.

Otherwise, it silently produces wrong results.

The simplest way to fix this is to just use the same code as for
UTF-8 (right above).  Of course, that causes functional changes
but that shouldn't matter since current behaviour is undefined.

The patch below provides the following improvements:

 - It works for all stateless single-byte encodings, no matter
   whether they are somehow related to ASCII, no matter how
   mb[r]towc(3) are internally implemented, and no matter how
   wchar_t is internally represented.
 - Instead of producing unpredictable and definitely wrong
   results for non-UTF-8 multibyte characters, it behaves in
   a well-defined way: It aborts input processing, sets errno,
   and returns failure.
   Note that short of providing full support for arbitrary locales,
   it is impossible to do better.  We cannot know whether a given
   unsupported locale is state-dependent, and for a state-dependent
   locale, it makes no sense to retry parsing after an encoding
   error, so the best we can do is abort processing for *any*
   unsupported multi-byte character.
 - Note that single-byte characters in arbitrary state-independent
   locales still work, even in locales that may potentially also
   contain multibyte characters, as long as those don't occur in
   input.  I'm not sure whether any such locales exist in practice...

Tested with UTF-8 and C/POSIX on OpenBSD.  Also tested that in the
C/POSIX locale, non-ASCII bytes get through unmangled.  You may
wish to test with ISO-LATIN on NetBSD if NetBSD supports that.

----
Also use a constant for meta to avoid warnings.

Revision 1.74 / (download) - annotate - [select for diffs], Thu Feb 11 19:21:04 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.73: +4 -4 lines
Diff to previous 1.73 (colored)

- Add some more Char casts
- reduce ifdefs by providing empty defs for nls functions (Ingo Schwarze)

Revision 1.73 / (download) - annotate - [select for diffs], Thu Feb 11 16:08:47 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.72: +2 -16 lines
Diff to previous 1.72 (colored)

Remove utf8_islead() mbrtowc() handles this just fine (Ingo Schwarze)

Revision 1.72 / (download) - annotate - [select for diffs], Mon Feb 8 17:18:43 2016 UTC (8 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.71: +32 -7 lines
Diff to previous 1.71 (colored)

UTF-8 fixes from Ingo Schwarze:

 1. Assume that errno is non-zero when entering read_char()
    and that read(2) returns 0 (indicating end of file).
    Then, the code will clear errno before returning.
    (Obviously, the statement "errno = 0" is almost always
     a bug unless there is save_errno = errno right before it
     and the previous value is properly restored later,
     in all reachable code paths.)

 2. When encountering an invalid byte sequence, the code discards
    all following bytes until MB_LEN_MAX overflows; consider, for
    example, 0xc2 immediately followed by a few valid ASCII bytes.
    Three of those ASCII bytes will be discarded.

 3. On a POSIX system, EILSEQ will always be set after reading a
    valid (yes, valid, not invalid!) UTF-8 character.  The reason
    is that mbtowc(3) will first be called with a length limit
    (third argument) of 1, which will fail, return -1, and - on
    a POSIX system - set errno to EILSEQ.
    This third bug is mitigated a bit because i couldn't find any
    system that actually conforms to POSIX in this respect:  None
    of OpenBSD, NetBSD, FreeBSD, Solaris 11, and glibc set errno
    when an incomplete character is passed to mbtowc(3), even though
    that is required by POSIX.
    Anyway, that mbtowc(3) bug will be fixed at least in OpenBSD
    after release unlock, so it would be good to fix this bug in
    libedit before fixing the bug in mbtowc(3).

How can these three bugs be fixed?

 1. As far as i understand it, the intention of the bogus errno = 0
    is to undo the effects of failing system calls in el_wset(),
    sig_set(), and read__fixio() if the subsequent read(2) indicates
    end of file.  So, restoring errno has to be moved right after
    read__fixio().  Of course, neither 0 nor e is the right value
    to restore: 0 is wrong if errno happened to be set on entry, e
    would be wrong because if one read(2) fails but a second attempt
    succeeds after read__fixio(), errno should not be touched.  So,
    the errno to be restored in this case has to be saved before
    calling read(2) for the first time.

 2. Solving the second issue requires distinguishing invalid and
    incomplete characters, but that is impossible with the function
    mbtowc(3) because it returns -1 in both cases and sets errno
    to EILSEQ in both cases (once properly implemented).

    It is vital that each input character is processed right away.
    It is not acceptable to wait for the next input character before
    processing the previous one because this is an interactive
    library, not a batch system.  Consequently, the only situation
    where it is acceptable to wait for the next byte without first
    processing the previous one(s) is when the previous one(s) form
    an incomplete sequence that can be continued to form a valid
    character.

    Consequently, short of reimplementing a full UTF-8 state machine
    by hand, the only correct way forward is to use mbrtowc(3).
    Even then, care is needed to always have the state object
    properly initialized before using it, and to not discard a valid
    ASCII or UTF-8 lead byte if it happens to follow an invalid
    sequence.

 3. Fortunately, solution 2. also solves issue 3. as a side effect,
    by no longer using mbtowc(3) in the first place.

Revision 1.69.2.2 / (download) - annotate - [select for diffs], Wed Aug 20 00:02:17 2014 UTC (9 years, 7 months ago) by tls
Branch: tls-maxphys
Changes since 1.69.2.1: +1 -1 lines
Diff to previous 1.69.2.1 (colored) to branchpoint 1.69 (colored) next main 1.70 (colored)

Rebase to HEAD as of a few days ago.

Revision 1.70.4.1 / (download) - annotate - [select for diffs], Sun Aug 10 06:51:57 2014 UTC (9 years, 7 months ago) by tls
Branch: tls-earlyentropy
Changes since 1.70: +3 -3 lines
Diff to previous 1.70 (colored) next main 1.71 (colored)

Rebase.

Revision 1.71 / (download) - annotate - [select for diffs], Sun Jul 6 18:15:34 2014 UTC (9 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: tls-maxphys-base, tls-earlyentropy-base, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7
Changes since 1.70: +3 -3 lines
Diff to previous 1.70 (colored)

Bounds search for reallocated index, from OpenBSD via Andreas Fett

Revision 1.67.2.2 / (download) - annotate - [select for diffs], Thu May 22 11:36:55 2014 UTC (9 years, 10 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.67.2.1: +9 -2 lines
Diff to previous 1.67.2.1 (colored) to branchpoint 1.67 (colored) next main 1.68 (colored)

sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")

Revision 1.69.2.1 / (download) - annotate - [select for diffs], Sun Jun 23 06:21:06 2013 UTC (10 years, 9 months ago) by tls
Branch: tls-maxphys
Changes since 1.69: +9 -2 lines
Diff to previous 1.69 (colored)

resync from head

Revision 1.70 / (download) - annotate - [select for diffs], Mon May 27 23:55:55 2013 UTC (10 years, 10 months ago) by christos
Branch: MAIN
CVS Tags: yamt-pagecache-base9, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2
Branch point for: tls-earlyentropy
Changes since 1.69: +9 -2 lines
Diff to previous 1.69 (colored)

Test early for EOF to avoid infinite loop in the wide char case. From
Linas Vepstas: linasvepstas at gmail dot com

Revision 1.67.2.1 / (download) - annotate - [select for diffs], Tue Oct 30 18:59:09 2012 UTC (11 years, 4 months ago) by yamt
Branch: yamt-pagecache
CVS Tags: yamt-pagecache-tag8
Changes since 1.67: +11 -5 lines
Diff to previous 1.67 (colored)

sync with head

Revision 1.69 / (download) - annotate - [select for diffs], Tue Sep 11 12:31:08 2012 UTC (11 years, 6 months ago) by christos
Branch: MAIN
CVS Tags: yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, agc-symver-base, agc-symver
Branch point for: tls-maxphys
Changes since 1.68: +4 -4 lines
Diff to previous 1.68 (colored)

return !OKCMD on error.

Revision 1.68 / (download) - annotate - [select for diffs], Mon Sep 10 20:53:18 2012 UTC (11 years, 6 months ago) by christos
Branch: MAIN
Changes since 1.67: +9 -3 lines
Diff to previous 1.67 (colored)

PR/46935: Steffen Nurpmeso: editline(3) (libedit): faulty errno handling,
faulty reuse of val in wrong context

Revision 1.67 / (download) - annotate - [select for diffs], Tue Aug 16 16:25:15 2011 UTC (12 years, 7 months ago) by christos
Branch: MAIN
CVS Tags: yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus
Branch point for: yamt-pagecache
Changes since 1.66: +4 -4 lines
Diff to previous 1.66 (colored)

re-enable -Wconversion

Revision 1.66 / (download) - annotate - [select for diffs], Fri Jul 29 23:44:44 2011 UTC (12 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.65: +19 -19 lines
Diff to previous 1.65 (colored)

pass -Wconversion

Revision 1.65 / (download) - annotate - [select for diffs], Fri Jul 29 15:16:33 2011 UTC (12 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.64: +20 -20 lines
Diff to previous 1.64 (colored)

KNF return (\1); -> return \1;

Revision 1.64 / (download) - annotate - [select for diffs], Thu Jul 28 20:50:55 2011 UTC (12 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.63: +5 -5 lines
Diff to previous 1.63 (colored)

kill ptr_t and ioctl_t, add  * sizeof(*foo) to all allocations.

Revision 1.63 / (download) - annotate - [select for diffs], Thu Jul 28 01:56:27 2011 UTC (12 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.62: +4 -4 lines
Diff to previous 1.62 (colored)

Rename key to keymacro to avoid conflicts with term.h. The renaming of term
to terminal was again to avoid conflicts with term.h. term.h is a moving
namespace violation.

Revision 1.62 / (download) - annotate - [select for diffs], Thu Jul 28 00:44:35 2011 UTC (12 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.61: +12 -12 lines
Diff to previous 1.61 (colored)

term -> terminal
fix wide function confusion

Revision 1.61 / (download) - annotate - [select for diffs], Sat Jul 9 23:54:39 2011 UTC (12 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.60: +3 -3 lines
Diff to previous 1.60 (colored)

make obvious what we are trying to do...

Revision 1.60 / (download) - annotate - [select for diffs], Sat Jul 9 16:04:34 2011 UTC (12 years, 8 months ago) by tron
Branch: MAIN
Changes since 1.59: +3 -3 lines
Diff to previous 1.59 (colored)

Try to fix build of port where "char" is unsigned.

Revision 1.59 / (download) - annotate - [select for diffs], Fri Jul 8 15:54:56 2011 UTC (12 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.58: +7 -3 lines
Diff to previous 1.58 (colored)

Support other non-latin1 single byte character sets.
From: Alexander Barkov and Nirbhay Choubey at oracle dot com

Revision 1.57.2.1 / (download) - annotate - [select for diffs], Sat Mar 5 15:09:21 2011 UTC (13 years ago) by bouyer
Branch: bouyer-quota2
Changes since 1.57: +11 -12 lines
Diff to previous 1.57 (colored) next main 1.58 (colored)

Sync with HEAD

Revision 1.58 / (download) - annotate - [select for diffs], Fri Feb 18 20:53:05 2011 UTC (13 years, 1 month ago) by christos
Branch: MAIN
CVS Tags: cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase
Changes since 1.57: +11 -12 lines
Diff to previous 1.57 (colored)

PR/44599: Steven Vernon: libedit acts as if no data read if editmode is turned
off because nread is uninitialized in the edit disabled case.

Revision 1.57 / (download) - annotate - [select for diffs], Wed Jul 21 18:18:52 2010 UTC (13 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: matt-mips64-premerge-20101231, bouyer-quota2-base
Branch point for: bouyer-quota2
Changes since 1.56: +4 -3 lines
Diff to previous 1.56 (colored)

refresh only on SIGCONT not SIGWINCH from Edward Sheldrake

Revision 1.56 / (download) - annotate - [select for diffs], Mon Jul 19 17:18:13 2010 UTC (13 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.55: +7 -3 lines
Diff to previous 1.55 (colored)

retry the read after sigwinch too, from Edward Sheldrake

Revision 1.55 / (download) - annotate - [select for diffs], Mon Mar 22 22:59:06 2010 UTC (14 years ago) by christos
Branch: MAIN
Changes since 1.54: +3 -3 lines
Diff to previous 1.54 (colored)

https://bugzilla.redhat.com/show_bug.cgi?id=575383
Handle EINTR properly.

Revision 1.54 / (download) - annotate - [select for diffs], Thu Dec 31 15:58:26 2009 UTC (14 years, 2 months ago) by christos
Branch: MAIN
Changes since 1.53: +6 -2 lines
Diff to previous 1.53 (colored)

- Document and enable wide character support.
- Fix read function compatibility.

Revision 1.53 / (download) - annotate - [select for diffs], Wed Dec 30 22:37:40 2009 UTC (14 years, 3 months ago) by christos
Branch: MAIN
Changes since 1.52: +68 -21 lines
Diff to previous 1.52 (colored)

Wide character support (UTF-8) from Johny Mattsson; currently disabled.

Revision 1.52 / (download) - annotate - [select for diffs], Wed Jul 22 15:57:00 2009 UTC (14 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: matt-premerge-20091211
Changes since 1.51: +3 -2 lines
Diff to previous 1.51 (colored)

Always initialize nread since it is an out param.
From Michael Cook mcook at bbn dot com

Revision 1.51 / (download) - annotate - [select for diffs], Tue Jun 9 13:04:33 2009 UTC (14 years, 9 months ago) by christos
Branch: MAIN
Changes since 1.50: +3 -3 lines
Diff to previous 1.50 (colored)

decrement the number of levels after the loop (Julien Torres)

Revision 1.50 / (download) - annotate - [select for diffs], Mon Jun 8 15:10:53 2009 UTC (14 years, 9 months ago) by christos
Branch: MAIN
Changes since 1.49: +5 -4 lines
Diff to previous 1.49 (colored)

from Julien Torres, flip the order we pop in the macro array.

Revision 1.43.2.1 / (download) - annotate - [select for diffs], Wed May 13 19:18:29 2009 UTC (14 years, 10 months ago) by jym
Branch: jym-xensuspend
Changes since 1.43: +60 -27 lines
Diff to previous 1.43 (colored) next main 1.44 (colored)

Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html

Revision 1.49 / (download) - annotate - [select for diffs], Tue Mar 10 20:46:15 2009 UTC (15 years ago) by christos
Branch: MAIN
CVS Tags: jym-xensuspend-nbase, jym-xensuspend-base
Changes since 1.48: +34 -22 lines
Diff to previous 1.48 (colored)

make el_gets set the count to -1 on error to distinguish between EOF and
error.

Revision 1.48 / (download) - annotate - [select for diffs], Sat Feb 21 23:35:10 2009 UTC (15 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.47: +2 -4 lines
Diff to previous 1.47 (colored)

remove VEOF test. the tty is in cooked mode when we are not editing and
the tty driver does the check for us.

Revision 1.47 / (download) - annotate - [select for diffs], Sat Feb 21 23:31:29 2009 UTC (15 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.46: +3 -3 lines
Diff to previous 1.46 (colored)

use the VEOF character from the terminal, instead of hard-coding 4.

Revision 1.46 / (download) - annotate - [select for diffs], Thu Feb 19 15:20:22 2009 UTC (15 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.45: +11 -4 lines
Diff to previous 1.45 (colored)

reset and redraw on sigcont. From Anon Ymous.

Revision 1.45 / (download) - annotate - [select for diffs], Sun Feb 15 21:55:23 2009 UTC (15 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.44: +9 -8 lines
Diff to previous 1.44 (colored)

pass lint on _LP64.

Revision 1.44 / (download) - annotate - [select for diffs], Sun Feb 15 21:24:13 2009 UTC (15 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.43: +24 -9 lines
Diff to previous 1.43 (colored)

don't restart on EINTR, instead return NULL immediately. From Anon Ymous

Revision 1.43 / (download) - annotate - [select for diffs], Thu Feb 5 19:15:44 2009 UTC (15 years, 1 month ago) by christos
Branch: MAIN
Branch point for: jym-xensuspend
Changes since 1.42: +3 -3 lines
Diff to previous 1.42 (colored)

match documentation in el_push

Revision 1.42 / (download) - annotate - [select for diffs], Sun Jan 18 12:17:24 2009 UTC (15 years, 2 months ago) by lukem
Branch: MAIN
Changes since 1.41: +3 -3 lines
Diff to previous 1.41 (colored)

fix -Wsign-compare issues

Revision 1.40.12.1 / (download) - annotate - [select for diffs], Wed Sep 24 16:35:09 2008 UTC (15 years, 6 months ago) by wrstuden
Branch: wrstuden-revivesa
Changes since 1.40: +8 -8 lines
Diff to previous 1.40 (colored) next main 1.41 (colored)

Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.

Revision 1.41 / (download) - annotate - [select for diffs], Wed Sep 10 15:45:37 2008 UTC (15 years, 6 months ago) by christos
Branch: MAIN
CVS Tags: wrstuden-revivesa-base-3, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-base2
Changes since 1.40: +8 -8 lines
Diff to previous 1.40 (colored)

Allow a single process to control multiple ttys (for pthreads using _REENTRANT)
using multiple EditLine objects. Mostly from Preston A. Elder.

Revision 1.40 / (download) - annotate - [select for diffs], Thu Mar 1 21:41:45 2007 UTC (17 years, 1 month ago) by christos
Branch: MAIN
CVS Tags: yamt-pf42-baseX, yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pf42-base, yamt-pf42, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-nbase, matt-armv6-base, matt-armv6, keiichi-mipv6-base, keiichi-mipv6, hpcarm-cleanup-nbase, hpcarm-cleanup-base, hpcarm-cleanup, cube-autoconf-base, cube-autoconf
Branch point for: wrstuden-revivesa
Changes since 1.39: +25 -9 lines
Diff to previous 1.39 (colored)

Fix bug with multiple pending el_pushes. Reported by Julien Torres.

Revision 1.39 / (download) - annotate - [select for diffs], Tue Aug 2 12:11:14 2005 UTC (18 years, 7 months ago) by christos
Branch: MAIN
CVS Tags: wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4, abandoned-netbsd-4-base, abandoned-netbsd-4
Changes since 1.38: +3 -3 lines
Diff to previous 1.38 (colored)

On a fatal error, we want to stop processing the macro buffers.

Revision 1.38 / (download) - annotate - [select for diffs], Tue Aug 2 10:20:33 2005 UTC (18 years, 7 months ago) by tron
Branch: MAIN
Changes since 1.37: +3 -3 lines
Diff to previous 1.37 (colored)

Add missing second argument to another call of ch_reset().

Revision 1.37 / (download) - annotate - [select for diffs], Mon Aug 1 23:00:15 2005 UTC (18 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.36: +3 -3 lines
Diff to previous 1.36 (colored)

Don't reset the macro strings each time we enter el_gets(), otherwise
el_push() is unusable programmatically.

Revision 1.36 / (download) - annotate - [select for diffs], Wed Jun 1 11:37:52 2005 UTC (18 years, 10 months ago) by lukem
Branch: MAIN
Changes since 1.35: +3 -3 lines
Diff to previous 1.35 (colored)

Don't use non-standard uint or u_int.

Revision 1.35 / (download) - annotate - [select for diffs], Wed Mar 9 23:55:02 2005 UTC (19 years ago) by christos
Branch: MAIN
CVS Tags: netbsd-3-base, netbsd-3-1-RELEASE, netbsd-3-1-RC4, netbsd-3-1-RC3, netbsd-3-1-RC2, netbsd-3-1-RC1, netbsd-3-1-1-RELEASE, netbsd-3-1, netbsd-3-0-RELEASE, netbsd-3-0-RC6, netbsd-3-0-RC5, netbsd-3-0-RC4, netbsd-3-0-RC3, netbsd-3-0-RC2, netbsd-3-0-RC1, netbsd-3-0-3-RELEASE, netbsd-3-0-2-RELEASE, netbsd-3-0-1-RELEASE, netbsd-3-0, netbsd-3
Changes since 1.34: +5 -2 lines
Diff to previous 1.34 (colored)

Make sure we flush after we prepare when we are unbuffered otherwise the
prompt will not appear immediately.

Revision 1.33.2.1 / (download) - annotate - [select for diffs], Sat Jul 10 09:28:04 2004 UTC (19 years, 8 months ago) by tron
Branch: netbsd-2-0
CVS Tags: netbsd-2-base, netbsd-2-1-RELEASE, netbsd-2-1-RC6, netbsd-2-1-RC5, netbsd-2-1-RC4, netbsd-2-1-RC3, netbsd-2-1-RC2, netbsd-2-1-RC1, netbsd-2-1, netbsd-2-0-RELEASE, netbsd-2-0-RC5, netbsd-2-0-RC4, netbsd-2-0-RC3, netbsd-2-0-RC2, netbsd-2-0-RC1, netbsd-2-0-3-RELEASE, netbsd-2-0-2-RELEASE, netbsd-2-0-1-RELEASE, netbsd-2
Changes since 1.33: +7 -3 lines
Diff to previous 1.33 (colored) next main 1.34 (colored)

Pull up revision 1.34 (requested by christos in ticket #620):
PR/23486: Andreas Gustafsson: gdb no longer works with emacs
- make sure that we keep previous contents of the buffer in unbuffered mode.
- when turning editing on and off keep tty consistent.

Revision 1.34 / (download) - annotate - [select for diffs], Thu Jul 8 00:51:36 2004 UTC (19 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.33: +7 -3 lines
Diff to previous 1.33 (colored)

PR/23486: Andreas Gustafsson: gdb no longer works with emacs
- make sure that we keep previous contents of the buffer in unbuffered mode.
- when turning editing on and off keep tty consistent.

Revision 1.33 / (download) - annotate - [select for diffs], Fri Feb 27 14:52:18 2004 UTC (20 years, 1 month ago) by christos
Branch: MAIN
CVS Tags: netbsd-2-0-base
Branch point for: netbsd-2-0
Changes since 1.32: +3 -11 lines
Diff to previous 1.32 (colored)

Better fix for rl_prep_terminal() from Gerry Swislow.

Revision 1.32 / (download) - annotate - [select for diffs], Sat Feb 21 16:42:30 2004 UTC (20 years, 1 month ago) by christos
Branch: MAIN
Changes since 1.31: +11 -3 lines
Diff to previous 1.31 (colored)

Separate tty separation from the prompt printing function. From Gerry Swislow.

Revision 1.31 / (download) - annotate - [select for diffs], Sat Jan 17 17:57:40 2004 UTC (20 years, 2 months ago) by christos
Branch: MAIN
Changes since 1.30: +4 -4 lines
Diff to previous 1.30 (colored)

portability fixes.

Revision 1.30 / (download) - annotate - [select for diffs], Sat Oct 18 23:48:42 2003 UTC (20 years, 5 months ago) by christos
Branch: MAIN
Changes since 1.29: +16 -18 lines
Diff to previous 1.29 (colored)

change allocation policy in el_push to allocate the string itself.
fix issues with strdup.

Revision 1.29 / (download) - annotate - [select for diffs], Thu Oct 9 00:42:28 2003 UTC (20 years, 5 months ago) by christos
Branch: MAIN
Changes since 1.28: +9 -3 lines
Diff to previous 1.28 (colored)

PR/23107: Nathan Williams: ^D as the first char on the command line does
not DTRT in readline compatibility mode

Revision 1.28 / (download) - annotate - [select for diffs], Fri Sep 26 17:44:51 2003 UTC (20 years, 6 months ago) by christos
Branch: MAIN
Changes since 1.27: +47 -18 lines
Diff to previous 1.27 (colored)

Implement enough of readline's 4.0 async mode to make gdb happy. This is
not complete yet, but it seems to work...
This required to introduce an unbuffered mode to el_gets(), but that was
a minor change.

Revision 1.27 / (download) - annotate - [select for diffs], Sat Sep 13 04:18:00 2003 UTC (20 years, 6 months ago) by mycroft
Branch: MAIN
Changes since 1.26: +3 -2 lines
Diff to previous 1.26 (colored)

Fix something that's been annoying me for a while...
Pull in <fcntl.h>, so that the fcntl #defines are present, and we build in the
automatic reset of non-blocking mode, rather than beeping like mad.

Revision 1.26 / (download) - annotate - [select for diffs], Thu Aug 7 16:44:32 2003 UTC (20 years, 7 months ago) by agc
Branch: MAIN
Changes since 1.25: +3 -7 lines
Diff to previous 1.25 (colored)

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.

Revision 1.25 / (download) - annotate - [select for diffs], Thu Jun 19 15:55:06 2003 UTC (20 years, 9 months ago) by christos
Branch: MAIN
Changes since 1.24: +7 -3 lines
Diff to previous 1.24 (colored)

From michael@moria.de:
- use __attribute__((__unused__)) in arguments where appropriate.
- some int -> size_t and char * to const char * conversions.

Revision 1.24 / (download) - annotate - [select for diffs], Wed Nov 20 16:50:08 2002 UTC (21 years, 4 months ago) by christos
Branch: MAIN
CVS Tags: fvdl_fs64_base
Changes since 1.23: +4 -2 lines
Diff to previous 1.23 (colored)

Fix problem with previous patches that broke vi history.
- c_gets() was usually returning a length, but sometimes
  one of the CC_xxx values (which are small +ve integers)!
- fixed c_gets() by putting a ' ' under the cursor.
From David Laight.

Revision 1.23 / (download) - annotate - [select for diffs], Fri Nov 15 14:32:34 2002 UTC (21 years, 4 months ago) by christos
Branch: MAIN
Changes since 1.22: +23 -19 lines
Diff to previous 1.22 (colored)

PR/18995: David Laight: libedit fixes for posix conformant sh

The posix 'sh' specification defines vi-mode editing quite tightly.
The netbsd libedit code (used by sh to do this) was missing several
features, there were also minor errors in others.

Compare netbsd sh to the definition available from:
http://www.opengroup.org/onlinepubs/007904975/utilities/sh.html
In particular the following were not supported:
	U - undo all changes to line
	| - goto column
	Y - yank to end of line
	y - yank
	# - comment out current line
	@ - take input from shell alias [1]
	G - goto numbered line in history buffer
	v - edit history line with vi
	_ - append word from last input line
	. - redo last command
Other minor changes have also been made.

[1] This needs the shell to define an appropriate routine to
return the text of the alias.  There is no requirement that
such a function exist.

Revision 1.22 / (download) - annotate - [select for diffs], Sun Oct 27 21:41:50 2002 UTC (21 years, 5 months ago) by christos
Branch: MAIN
Changes since 1.21: +14 -4 lines
Diff to previous 1.21 (colored)

vi mode and memory fixes from david laight.

Revision 1.21 / (download) - annotate - [select for diffs], Mon Mar 18 16:00:57 2002 UTC (22 years ago) by christos
Branch: MAIN
CVS Tags: netbsd-1-6-base, netbsd-1-6-RELEASE, netbsd-1-6-RC3, netbsd-1-6-RC2, netbsd-1-6-RC1, netbsd-1-6-PATCH002-RELEASE, netbsd-1-6-PATCH002-RC4, netbsd-1-6-PATCH002-RC3, netbsd-1-6-PATCH002-RC2, netbsd-1-6-PATCH002-RC1, netbsd-1-6-PATCH002, netbsd-1-6-PATCH001-RELEASE, netbsd-1-6-PATCH001-RC3, netbsd-1-6-PATCH001-RC2, netbsd-1-6-PATCH001-RC1, netbsd-1-6-PATCH001, netbsd-1-6
Changes since 1.20: +5 -7 lines
Diff to previous 1.20 (colored)

- constify; passes all gcc and lint strict checks.
- add config.h [Jason Evans], to create a portable version of libedit that
  can be easily compiled on other OS's.

Revision 1.20 / (download) - annotate - [select for diffs], Thu Sep 27 19:29:50 2001 UTC (22 years, 6 months ago) by christos
Branch: MAIN
Changes since 1.19: +42 -6 lines
Diff to previous 1.19 (colored)

PR/14067: Anthony Mallet: Provide a programmatic way to set the read_char
function via a new el_set() operation.
Thanks, nicely done :-)

Revision 1.19 / (download) - annotate - [select for diffs], Wed Jan 10 07:45:41 2001 UTC (23 years, 2 months ago) by jdolecek
Branch: MAIN
Changes since 1.18: +20 -11 lines
Diff to previous 1.18 (colored)

Enlarge editline buffers as needed to support arbitrary length lines.
This also addresses lib/9712 by Phil Nelson.

Revision 1.18 / (download) - annotate - [select for diffs], Sat Nov 11 22:18:58 2000 UTC (23 years, 4 months ago) by christos
Branch: MAIN
Changes since 1.17: +3 -3 lines
Diff to previous 1.17 (colored)

- add support for home and end keys.
- improve debugging support

Revision 1.17 / (download) - annotate - [select for diffs], Mon Sep 4 22:06:31 2000 UTC (23 years, 6 months ago) by lukem
Branch: MAIN
Changes since 1.16: +319 -330 lines
Diff to previous 1.16 (colored)

convert to new style guide, which includes:
- ansi prototypes & features (such as stdargs)
- 8 space indents

Revision 1.16 / (download) - annotate - [select for diffs], Wed Jan 19 18:30:19 2000 UTC (24 years, 2 months ago) by christos
Branch: MAIN
CVS Tags: netbsd-1-5-base, netbsd-1-5-RELEASE, netbsd-1-5-PATCH003, netbsd-1-5-PATCH002, netbsd-1-5-PATCH001, netbsd-1-5-BETA2, netbsd-1-5-BETA, netbsd-1-5-ALPHA2, netbsd-1-5, minoura-xpg4dl-base, minoura-xpg4dl
Changes since 1.15: +5 -5 lines
Diff to previous 1.15 (colored)

PR/9243: Kevin Schoedel: libedit ignores repeat count

Revision 1.14.2.1 / (download) - annotate - [select for diffs], Mon Dec 27 18:29:58 1999 UTC (24 years, 3 months ago) by wrstuden
Branch: wrstuden-devbsize
Changes since 1.14: +3 -3 lines
Diff to previous 1.14 (colored) next main 1.15 (colored)

Pull up to last week's -current.

Revision 1.15 / (download) - annotate - [select for diffs], Mon Oct 4 23:23:21 1999 UTC (24 years, 5 months ago) by lukem
Branch: MAIN
CVS Tags: wrstuden-devbsize-base, wrstuden-devbsize-19991221, comdex-fall-1999-base, comdex-fall-1999
Changes since 1.14: +3 -3 lines
Diff to previous 1.14 (colored)

remove some lint

Revision 1.14 / (download) - annotate - [select for diffs], Sun Aug 8 01:25:05 1999 UTC (24 years, 7 months ago) by sommerfeld
Branch: MAIN
Branch point for: wrstuden-devbsize
Changes since 1.13: +9 -4 lines
Diff to previous 1.13 (colored)

minor tweak to previous fix: don't spuriously truncate final newline
under emacs.

Revision 1.13 / (download) - annotate - [select for diffs], Mon Aug 2 01:01:55 1999 UTC (24 years, 8 months ago) by sommerfeld
Branch: MAIN
Changes since 1.12: +23 -3 lines
Diff to previous 1.12 (colored)

Fix PR7685 (gdb under emacs prints spurious ^M and messes up terminal)
plus a few bogons noted along the way:
	1) Set EDIT_DISABLED if terminal type is emacs.
	2) fix bug in NO_TTY mode which caused it to not notice CR or LF
	3) implement EDIT_DISABLED within libedit to be somewhat like NO_TTY,
		except that a prompt is printed first.

Revision 1.12 / (download) - annotate - [select for diffs], Fri Jul 2 15:21:26 1999 UTC (24 years, 9 months ago) by simonb
Branch: MAIN
Changes since 1.11: +8 -8 lines
Diff to previous 1.11 (colored)

More trailing white space.

Revision 1.11 / (download) - annotate - [select for diffs], Mon Jan 11 22:40:00 1999 UTC (25 years, 2 months ago) by kleink
Branch: MAIN
CVS Tags: netbsd-1-4-base, netbsd-1-4-RELEASE, netbsd-1-4-PATCH003, netbsd-1-4-PATCH002, netbsd-1-4-PATCH001, netbsd-1-4
Changes since 1.10: +3 -4 lines
Diff to previous 1.10 (colored)

In userland, pull in <errno.h> instead of <sys/errno.h> for the declaration
of errno.

Revision 1.10 / (download) - annotate - [select for diffs], Sat Dec 12 20:08:22 1998 UTC (25 years, 3 months ago) by christos
Branch: MAIN
Changes since 1.9: +4 -2 lines
Diff to previous 1.9 (colored)

delint

Revision 1.9 / (download) - annotate - [select for diffs], Mon Jun 1 14:31:26 1998 UTC (25 years, 10 months ago) by lukem
Branch: MAIN
Changes since 1.8: +9 -2 lines
Diff to previous 1.8 (colored)

* implement CC_REFRESH_BEEP; as per CC_REFRESH but beep as well. this
  is useful in completion when a partial completion is found
* remove entry in BUGS about el_parse(); that was fixed a while ago

Revision 1.8 / (download) - annotate - [select for diffs], Wed Jan 21 10:12:22 1998 UTC (26 years, 2 months ago) by lukem
Branch: MAIN
Changes since 1.7: +6 -3 lines
Diff to previous 1.7 (colored)

fix compile errors if FIONREAD is defined.  noted by
David Holland <dholland@bordeaux.eecs.harvard.edu> in [bin/4012].

Revision 1.7 / (download) - annotate - [select for diffs], Sat Dec 20 19:15:52 1997 UTC (26 years, 3 months ago) by christos
Branch: MAIN
Changes since 1.6: +7 -5 lines
Diff to previous 1.6 (colored)

Small optimization. Don't call isatty() on every invocation of el_gets, but
remember if the tty setup failed... Also trim the input line of trailing \r's.

Revision 1.6 / (download) - annotate - [select for diffs], Sun Oct 26 20:19:48 1997 UTC (26 years, 5 months ago) by christos
Branch: MAIN
Changes since 1.5: +42 -14 lines
Diff to previous 1.5 (colored)

Make el_gets() work when the input is not a tty.

Revision 1.5 / (download) - annotate - [select for diffs], Sun Jul 6 18:25:32 1997 UTC (26 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: netbsd-1-3-base, netbsd-1-3-RELEASE, netbsd-1-3-PATCH003-CANDIDATE2, netbsd-1-3-PATCH003-CANDIDATE1, netbsd-1-3-PATCH003-CANDIDATE0, netbsd-1-3-PATCH003, netbsd-1-3-PATCH002, netbsd-1-3-PATCH001, netbsd-1-3-BETA, netbsd-1-3
Changes since 1.4: +11 -6 lines
Diff to previous 1.4 (colored)

Fix compiler warnings.

Revision 1.4 / (download) - annotate - [select for diffs], Fri Apr 11 17:52:47 1997 UTC (26 years, 11 months ago) by christos
Branch: MAIN
Changes since 1.3: +8 -4 lines
Diff to previous 1.3 (colored)

Portability fixes:
__const		-> const
BADSIG		-> SIG_ERR
int flags	-> u_int flags
#if __STDC__	-> #ifdef __STDC__

Revision 1.3 / (download) - annotate - [select for diffs], Tue Jan 14 04:17:25 1997 UTC (27 years, 2 months ago) by lukem
Branch: MAIN
Changes since 1.2: +7 -2 lines
Diff to previous 1.2 (colored)

Implement CC_REDISPLAY, which (unlink 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)

Revision 1.2 / (download) - annotate - [select for diffs], Sat Jan 11 06:48:06 1997 UTC (27 years, 2 months ago) by lukem
Branch: MAIN
Changes since 1.1: +7 -1 lines
Diff to previous 1.1 (colored)

RCSid police
editline first appeared in 4.4BSD not NetBSD1.0

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Fri May 6 06:01:43 1994 UTC (29 years, 10 months ago) by cgd
Branch: CSRG
CVS Tags: netbsd-1-2-base, netbsd-1-2-RELEASE, netbsd-1-2-PATCH001, netbsd-1-2-BETA, netbsd-1-2, netbsd-1-1-base, netbsd-1-1-RELEASE, netbsd-1-1-PATCH001, netbsd-1-1, netbsd-1-0-base, netbsd-1-0-RELEASE, netbsd-1-0-PATCH1, netbsd-1-0-PATCH06, netbsd-1-0-PATCH05, netbsd-1-0-PATCH04, netbsd-1-0-PATCH03, netbsd-1-0-PATCH02, netbsd-1-0-PATCH0, netbsd-1-0, lite-2, lite-1
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

libedit!

Revision 1.1 / (download) - annotate - [select for diffs], Fri May 6 06:01:42 1994 UTC (29 years, 10 months ago) by cgd
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.




CVSweb <webmaster@jp.NetBSD.org>