Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/nvi/dist/ex improve logic related to sh_prompt:
details: https://anonhg.NetBSD.org/src/rev/d9748a5137ee
branches: trunk
changeset: 349716:d9748a5137ee
user: rin <rin%NetBSD.org@localhost>
date: Mon Dec 19 17:51:40 2016 +0000
description:
improve logic related to sh_prompt:
- sscr_insert(): sh_prompt should be compared with t, not p
- replace strnstr(3) with memcmp(3)
now, nvi is free from strnstr(3); it can be safely pulled-up into netbsd-7
diffstat:
external/bsd/nvi/dist/ex/ex_script.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diffs (55 lines):
diff -r 87f90723b75e -r d9748a5137ee external/bsd/nvi/dist/ex/ex_script.c
--- a/external/bsd/nvi/dist/ex/ex_script.c Mon Dec 19 17:38:38 2016 +0000
+++ b/external/bsd/nvi/dist/ex/ex_script.c Mon Dec 19 17:51:40 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ex_script.c,v 1.6 2015/11/29 17:09:33 christos Exp $ */
+/* $NetBSD: ex_script.c,v 1.7 2016/12/19 17:51:40 rin Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -19,7 +19,7 @@
static const char sccsid[] = "Id: ex_script.c,v 10.38 2001/06/25 15:19:19 skimo Exp (Berkeley) Date: 2001/06/25 15:19:19 ";
#endif /* not lint */
#else
-__RCSID("$NetBSD: ex_script.c,v 1.6 2015/11/29 17:09:33 christos Exp $");
+__RCSID("$NetBSD: ex_script.c,v 1.7 2016/12/19 17:51:40 rin Exp $");
#endif
#include <sys/types.h>
@@ -274,7 +274,7 @@
return (1);
INT2CHAR(sp, ip, ilen, p, last_len);
if (last_len == sc->sh_prompt_len &&
- strnstr(p, sc->sh_prompt, last_len) == p) {
+ memcmp(p, sc->sh_prompt, last_len) == 0) {
matchprompt = 1;
GET_SPACE_RETC(sp, bp, blen, last_len + 128);
memmove(bp, p, last_len);
@@ -294,7 +294,8 @@
INT2CHAR(sp, ip, ilen, p, len);
/* Delete any prompt. */
- if (strnstr(p, sc->sh_prompt, len) == p) {
+ if (len >= sc->sh_prompt_len &&
+ memcmp(p, sc->sh_prompt, sc->sh_prompt_len) == 0) {
len -= sc->sh_prompt_len;
if (len == 0) {
empty: msgq(sp, M_BERR, "151|No command to execute");
@@ -473,7 +474,7 @@
*/
len = p - t;
if (sc->sh_prompt == NULL || len != sc->sh_prompt_len ||
- strnstr(p, sc->sh_prompt, len) == NULL) {
+ memcmp(t, sc->sh_prompt, len) != 0) {
tv.tv_sec = 0;
tv.tv_usec = 100000;
FD_ZERO(&rdfd);
@@ -509,7 +510,7 @@
/*
* sscr_setprompt --
*
- * Set the prompt to the last line we got from the shell.
+ * Set the prompt in external ("char") encoding.
*
*/
static int
Home |
Main Index |
Thread Index |
Old Index