Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit patbuf must be updated if the length of patbuf i...



details:   https://anonhg.NetBSD.org/src/rev/cde8175d6a3b
branches:  trunk
changeset: 970623:cde8175d6a3b
user:      ryo <ryo%NetBSD.org@localhost>
date:      Mon Mar 30 06:56:38 2020 +0000

description:
patbuf must be updated if the length of patbuf is greater than or equal to 0. (that is always)
fix of r1.7 was incorrect.

diffstat:

 lib/libedit/search.c |  13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diffs (34 lines):

diff -r f298c6d6b547 -r cde8175d6a3b lib/libedit/search.c
--- a/lib/libedit/search.c      Mon Mar 30 06:54:37 2020 +0000
+++ b/lib/libedit/search.c      Mon Mar 30 06:56:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: search.c,v 1.50 2020/03/30 06:54:37 ryo Exp $  */
+/*     $NetBSD: search.c,v 1.51 2020/03/30 06:56:38 ryo Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)search.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: search.c,v 1.50 2020/03/30 06:54:37 ryo Exp $");
+__RCSID("$NetBSD: search.c,v 1.51 2020/03/30 06:56:38 ryo Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -182,12 +182,9 @@
                    (size_t)(EL_CURSOR(el) - el->el_line.buffer);
                if (el->el_search.patlen >= EL_BUFSIZ)
                        el->el_search.patlen = EL_BUFSIZ - 1;
-               if (el->el_search.patlen != 0) {
-                       (void) wcsncpy(el->el_search.patbuf, el->el_line.buffer,
-                           el->el_search.patlen);
-                       el->el_search.patbuf[el->el_search.patlen] = '\0';
-               } else
-                       el->el_search.patlen = wcslen(el->el_search.patbuf);
+               (void) wcsncpy(el->el_search.patbuf, el->el_line.buffer,
+                   el->el_search.patlen);
+               el->el_search.patbuf[el->el_search.patlen] = '\0';
        }
 #ifdef SDEBUG
        (void) fprintf(el->el_errfile, "\neventno = %d\n",



Home | Main Index | Thread Index | Old Index