summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-01-30 14:22:15 +0000
committeremaste <emaste@FreeBSD.org>2015-01-30 14:22:15 +0000
commit2f8208fe7786625939fcd121b4e4289a8796786e (patch)
tree600dd99c25f840ddaeea654b05d28ab7e4c6c840 /lib
parent0a6db6b09eaecbd84ff23691f42dc39563edb5d7 (diff)
downloadFreeBSD-src-2f8208fe7786625939fcd121b4e4289a8796786e.zip
FreeBSD-src-2f8208fe7786625939fcd121b4e4289a8796786e.tar.gz
Merge libedit fixes from NetBSD
Add trailing NULL's to the varargs functions as required. (John Spencer) readline.c r1.106 Bounds search for reallocated index, from OpenBSD via Andreas Fett map.c 1.34 map.h 1.10 parse.c 1.27 read.c 1.71 This is a direct commit to stable/10 as these changes are included in a broader sync with NetBSD committed by bapt@ in r276881. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D1728
Diffstat (limited to 'lib')
-rw-r--r--lib/libedit/map.c2
-rw-r--r--lib/libedit/map.h2
-rw-r--r--lib/libedit/parse.c9
-rw-r--r--lib/libedit/read.c2
-rw-r--r--lib/libedit/readline.c12
5 files changed, 14 insertions, 13 deletions
diff --git a/lib/libedit/map.c b/lib/libedit/map.c
index c70904a..d4296e2 100644
--- a/lib/libedit/map.c
+++ b/lib/libedit/map.c
@@ -1395,7 +1395,7 @@ protected int
map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func)
{
void *p;
- int nf = el->el_map.nfunc + 1;
+ size_t nf = el->el_map.nfunc + 1;
if (name == NULL || help == NULL || func == NULL)
return (-1);
diff --git a/lib/libedit/map.h b/lib/libedit/map.h
index a76d872..f0297b2 100644
--- a/lib/libedit/map.h
+++ b/lib/libedit/map.h
@@ -57,7 +57,7 @@ typedef struct el_map_t {
int type; /* Emacs or vi */
el_bindings_t *help; /* The help for the editor functions */
el_func_t *func; /* List of available functions */
- int nfunc; /* The number of functions/help items */
+ size_t nfunc; /* The number of functions/help items */
} el_map_t;
#define MAP_EMACS 0
diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c
index 0ffe51d..1c42afe 100644
--- a/lib/libedit/parse.c
+++ b/lib/libedit/parse.c
@@ -252,10 +252,11 @@ parse__string(char *out, const char *in)
protected int
parse_cmd(EditLine *el, const char *cmd)
{
- el_bindings_t *b;
+ el_bindings_t *b = el->el_map.help;
+ size_t i;
- for (b = el->el_map.help; b->name != NULL; b++)
- if (strcmp(b->name, cmd) == 0)
- return (b->func);
+ for (i = 0; i < el->el_map.nfunc; i++)
+ if (strcmp(b[i].name, cmd) == 0)
+ return (b[i].func);
return (-1);
}
diff --git a/lib/libedit/read.c b/lib/libedit/read.c
index f0b5ef3..49810b3 100644
--- a/lib/libedit/read.c
+++ b/lib/libedit/read.c
@@ -517,7 +517,7 @@ el_gets(EditLine *el, int *nread)
#endif /* DEBUG_READ */
break;
}
- if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) { /* BUG CHECK command */
+ if ((size_t)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
#ifdef DEBUG_EDIT
(void) fprintf(el->el_errfile,
"ERROR: illegal command from key 0%o\r\n", ch);
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c
index 20a0f056..b6bf6fc 100644
--- a/lib/libedit/readline.c
+++ b/lib/libedit/readline.c
@@ -1906,7 +1906,7 @@ rl_add_defun(const char *name, Function *fun, int c)
map[(unsigned char)c] = fun;
el_set(e, EL_ADDFN, name, name, rl_bind_wrapper);
vis(dest, c, VIS_WHITE|VIS_NOSLASH, 0);
- el_set(e, EL_BIND, dest, name);
+ el_set(e, EL_BIND, dest, name, NULL);
return 0;
}
@@ -2014,7 +2014,7 @@ rl_variable_bind(const char *var, const char *value)
* The proper return value is undocument, but this is what the
* readline source seems to do.
*/
- return ((el_set(e, EL_BIND, "", var, value) == -1) ? 1 : 0);
+ return ((el_set(e, EL_BIND, "", var, value, NULL) == -1) ? 1 : 0);
}
void
@@ -2083,9 +2083,9 @@ void
rl_get_screen_size(int *rows, int *cols)
{
if (rows)
- el_get(e, EL_GETTC, "li", rows);
+ el_get(e, EL_GETTC, "li", rows, NULL);
if (cols)
- el_get(e, EL_GETTC, "co", cols);
+ el_get(e, EL_GETTC, "co", cols, NULL);
}
void
@@ -2093,9 +2093,9 @@ rl_set_screen_size(int rows, int cols)
{
char buf[64];
(void)snprintf(buf, sizeof(buf), "%d", rows);
- el_set(e, EL_SETTC, "li", buf);
+ el_set(e, EL_SETTC, "li", buf, NULL);
(void)snprintf(buf, sizeof(buf), "%d", cols);
- el_set(e, EL_SETTC, "co", buf);
+ el_set(e, EL_SETTC, "co", buf, NULL);
}
char **
OpenPOWER on IntegriCloud