Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jan 2015 14:22:16 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r277931 - stable/10/lib/libedit
Message-ID:  <201501301422.t0UEMGro061752@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Fri Jan 30 14:22:15 2015
New Revision: 277931
URL: https://svnweb.freebsd.org/changeset/base/277931

Log:
  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

Modified:
  stable/10/lib/libedit/map.c
  stable/10/lib/libedit/map.h
  stable/10/lib/libedit/parse.c
  stable/10/lib/libedit/read.c
  stable/10/lib/libedit/readline.c

Modified: stable/10/lib/libedit/map.c
==============================================================================
--- stable/10/lib/libedit/map.c	Fri Jan 30 14:13:29 2015	(r277930)
+++ stable/10/lib/libedit/map.c	Fri Jan 30 14:22:15 2015	(r277931)
@@ -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);

Modified: stable/10/lib/libedit/map.h
==============================================================================
--- stable/10/lib/libedit/map.h	Fri Jan 30 14:13:29 2015	(r277930)
+++ stable/10/lib/libedit/map.h	Fri Jan 30 14:22:15 2015	(r277931)
@@ -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

Modified: stable/10/lib/libedit/parse.c
==============================================================================
--- stable/10/lib/libedit/parse.c	Fri Jan 30 14:13:29 2015	(r277930)
+++ stable/10/lib/libedit/parse.c	Fri Jan 30 14:22:15 2015	(r277931)
@@ -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);
 }

Modified: stable/10/lib/libedit/read.c
==============================================================================
--- stable/10/lib/libedit/read.c	Fri Jan 30 14:13:29 2015	(r277930)
+++ stable/10/lib/libedit/read.c	Fri Jan 30 14:22:15 2015	(r277931)
@@ -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);

Modified: stable/10/lib/libedit/readline.c
==============================================================================
--- stable/10/lib/libedit/readline.c	Fri Jan 30 14:13:29 2015	(r277930)
+++ stable/10/lib/libedit/readline.c	Fri Jan 30 14:22:15 2015	(r277931)
@@ -1906,7 +1906,7 @@ rl_add_defun(const char *name, Function 
 	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 
 	 * 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 **



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501301422.t0UEMGro061752>