Module Name: src
Committed By: christos
Date: Fri Jul 10 20:34:24 UTC 2020
Modified Files:
src/lib/libedit: terminal.c
Log Message:
Fix numeric variable handling in settc (lyzliyuzhi at 163 dot com)
To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/lib/libedit/terminal.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/terminal.c
diff -u src/lib/libedit/terminal.c:1.42 src/lib/libedit/terminal.c:1.43
--- src/lib/libedit/terminal.c:1.42 Sun May 31 19:24:23 2020
+++ src/lib/libedit/terminal.c Fri Jul 10 16:34:24 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: terminal.c,v 1.42 2020/05/31 23:24:23 christos Exp $ */
+/* $NetBSD: terminal.c,v 1.43 2020/07/10 20:34:24 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
-__RCSID("$NetBSD: terminal.c,v 1.42 2020/05/31 23:24:23 christos Exp $");
+__RCSID("$NetBSD: terminal.c,v 1.43 2020/07/10 20:34:24 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1315,6 +1315,8 @@ terminal_settc(EditLine *el, int argc __
const struct termcapstr *ts;
const struct termcapval *tv;
char what[8], how[8];
+ long i;
+ char *ep;
if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
return -1;
@@ -1341,11 +1343,17 @@ terminal_settc(EditLine *el, int argc __
if (strcmp(tv->name, what) == 0)
break;
- if (tv->name != NULL)
+ if (tv->name == NULL) {
+ (void) fprintf(el->el_errfile,
+ "%ls: Bad capability `%s'.\n", argv[0], what);
return -1;
+ }
if (tv == &tval[T_pt] || tv == &tval[T_km] ||
tv == &tval[T_am] || tv == &tval[T_xn]) {
+ /*
+ * Booleans
+ */
if (strcmp(how, "yes") == 0)
el->el_terminal.t_val[tv - tval] = 1;
else if (strcmp(how, "no") == 0)
@@ -1356,28 +1364,30 @@ terminal_settc(EditLine *el, int argc __
return -1;
}
terminal_setflags(el);
- if (terminal_change_size(el, Val(T_li), Val(T_co)) == -1)
- return -1;
return 0;
- } else {
- long i;
- char *ep;
+ }
- i = strtol(how, &ep, 10);
- if (*ep != '\0') {
- (void) fprintf(el->el_errfile,
- "%ls: Bad value `%s'.\n", argv[0], how);
- return -1;
- }
- el->el_terminal.t_val[tv - tval] = (int) i;
+ /*
+ * Numerics
+ */
+ i = strtol(how, &ep, 10);
+ if (*ep != '\0') {
+ (void) fprintf(el->el_errfile,
+ "%ls: Bad value `%s'.\n", argv[0], how);
+ return -1;
+ }
+ el->el_terminal.t_val[tv - tval] = (int) i;
+ i = 0;
+ if (tv == &tval[T_co]) {
el->el_terminal.t_size.v = Val(T_co);
+ i++;
+ } else if (tv == &tval[T_li]) {
el->el_terminal.t_size.h = Val(T_li);
- if (tv == &tval[T_co] || tv == &tval[T_li])
- if (terminal_change_size(el, Val(T_li), Val(T_co))
- == -1)
- return -1;
- return 0;
+ i++;
}
+ if (i && terminal_change_size(el, Val(T_li), Val(T_co)) == -1)
+ return -1;
+ return 0;
}