Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit Fix numeric variable handling in settc (lyzliyuz...
details: https://anonhg.NetBSD.org/src/rev/97591fdc002c
branches: trunk
changeset: 1011777:97591fdc002c
user: christos <christos%NetBSD.org@localhost>
date: Fri Jul 10 20:34:24 2020 +0000
description:
Fix numeric variable handling in settc (lyzliyuzhi at 163 dot com)
diffstat:
lib/libedit/terminal.c | 56 +++++++++++++++++++++++++++++--------------------
1 files changed, 33 insertions(+), 23 deletions(-)
diffs (97 lines):
diff -r d445d9122cbf -r 97591fdc002c lib/libedit/terminal.c
--- a/lib/libedit/terminal.c Fri Jul 10 16:02:00 2020 +0000
+++ b/lib/libedit/terminal.c Fri Jul 10 20:34:24 2020 +0000
@@ -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 @@
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 @@
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 @@
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;
- el->el_terminal.t_size.v = Val(T_co);
- 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;
}
+
+ /*
+ * 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);
+ i++;
+ }
+ if (i && terminal_change_size(el, Val(T_li), Val(T_co)) == -1)
+ return -1;
+ return 0;
}
Home |
Main Index |
Thread Index |
Old Index