Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit PR/50880: David Binderman: Remove redundant code.



details:   https://anonhg.NetBSD.org/src/rev/fdc593fce59b
branches:  trunk
changeset: 343911:fdc593fce59b
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 02 19:24:20 2016 +0000

description:
PR/50880: David Binderman: Remove redundant code.
While here, fix all debugging formats.

diffstat:

 lib/libedit/Makefile   |   6 +++---
 lib/libedit/chartype.h |   4 +++-
 lib/libedit/common.c   |   9 +++++----
 lib/libedit/read.c     |   6 +++---
 lib/libedit/refresh.c  |  41 ++++++++++++++++++++++-------------------
 lib/libedit/terminal.c |   8 ++++----
 lib/libedit/vi.c       |   7 ++++---
 7 files changed, 44 insertions(+), 37 deletions(-)

diffs (truncated from 320 to 300 lines):

diff -r 74916bc8fcda -r fdc593fce59b lib/libedit/Makefile
--- a/lib/libedit/Makefile      Wed Mar 02 19:11:28 2016 +0000
+++ b/lib/libedit/Makefile      Wed Mar 02 19:24:20 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.55 2016/02/24 14:25:38 christos Exp $
+#      $NetBSD: Makefile,v 1.56 2016/03/02 19:24:20 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=  yes
@@ -53,8 +53,8 @@
 CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c
 CPPFLAGS+=-I. -I${LIBEDITDIR}
 CPPFLAGS+=-I. -I${.CURDIR}
-CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
-CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT
+#CPPFLAGS+=-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
+#CPPFLAGS+=-DDEBUG_PASTE -DDEBUG_EDIT
 
 AHDR=vi.h emacs.h common.h
 ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c
diff -r 74916bc8fcda -r fdc593fce59b lib/libedit/chartype.h
--- a/lib/libedit/chartype.h    Wed Mar 02 19:11:28 2016 +0000
+++ b/lib/libedit/chartype.h    Wed Mar 02 19:24:20 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.h,v 1.23 2016/02/24 17:20:01 christos Exp $   */
+/*     $NetBSD: chartype.h,v 1.24 2016/03/02 19:24:20 christos Exp $   */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -70,6 +70,7 @@
 #define FUNW(type)             type ## _w
 #define TYPE(type)             type ## W
 #define FSTR                   "%ls"
+#define FSTARSTR               "%.*ls"
 #define STR(x)                 L ## x
 #define UC(c)                  c
 #define Isalpha(x)  iswalpha(x)
@@ -122,6 +123,7 @@
 #define FUNW(type)             type
 #define TYPE(type)             type
 #define FSTR                   "%s"
+#define FSTARSTR               "%.*s"
 #define STR(x)                 x
 #define UC(c)                  (unsigned char)(c)
 
diff -r 74916bc8fcda -r fdc593fce59b lib/libedit/common.c
--- a/lib/libedit/common.c      Wed Mar 02 19:11:28 2016 +0000
+++ b/lib/libedit/common.c      Wed Mar 02 19:24:20 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $     */
+/*     $NetBSD: common.c,v 1.40 2016/03/02 19:24:20 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)common.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.40 2016/03/02 19:24:20 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -147,8 +147,9 @@
 {
 #ifdef DEBUG_EDIT
 #define        EL      el->el_line
-       (void) fprintf(el->el_errlfile,
-           "\nD(b: %x(%s)  c: %x(%s) last: %x(%s) limit: %x(%s)\n",
+       (void) fprintf(el->el_errfile,
+           "\nD(b: %p(" FSTR ")  c: %p(" FSTR ") last: %p(" FSTR
+           ") limit: %p(" FSTR ")\n",
            EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
            EL.lastchar, EL.limit, EL.limit);
 #endif
diff -r 74916bc8fcda -r fdc593fce59b lib/libedit/read.c
--- a/lib/libedit/read.c        Wed Mar 02 19:11:28 2016 +0000
+++ b/lib/libedit/read.c        Wed Mar 02 19:24:20 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: read.c,v 1.85 2016/02/24 17:20:01 christos Exp $       */
+/*     $NetBSD: read.c,v 1.86 2016/03/02 19:24:20 christos Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)read.c     8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: read.c,v 1.85 2016/02/24 17:20:01 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.86 2016/03/02 19:24:20 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -615,7 +615,7 @@
                                        break;
                        if (b->name)
                                (void) fprintf(el->el_errfile,
-                                   "Executing %s\n", b->name);
+                                   "Executing " FSTR "\n", b->name);
                        else
                                (void) fprintf(el->el_errfile,
                                    "Error command = %d\n", cmdnum);
diff -r 74916bc8fcda -r fdc593fce59b lib/libedit/refresh.c
--- a/lib/libedit/refresh.c     Wed Mar 02 19:11:28 2016 +0000
+++ b/lib/libedit/refresh.c     Wed Mar 02 19:24:20 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $    */
+/*     $NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $    */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)refresh.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -61,7 +61,7 @@
 private void   re__copy_and_pad(Char *, const Char *, size_t);
 
 #ifdef DEBUG_REFRESH
-private void   re_printstr(EditLine *, const char *, char *, char *);
+private void   re_printstr(EditLine *, const char *, Char *, Char *);
 #define        __F el->el_errfile
 #define        ELRE_ASSERT(a, b, c)    do                              \
                                    if (/*CONSTCOND*/ a) {      \
@@ -75,7 +75,7 @@
  *     Print a string on the debugging pty
  */
 private void
-re_printstr(EditLine *el, const char *str, char *f, char *t)
+re_printstr(EditLine *el, const char *str, Char *f, Char *t)
 {
 
        ELRE_DEBUG(1, (__F, "%s:\"", str));
@@ -205,7 +205,7 @@
        size_t termsz;
 #endif
 
-       ELRE_DEBUG(1, (__F, "el->el_line.buffer = :%s:\r\n",
+       ELRE_DEBUG(1, (__F, "el->el_line.buffer = :" FSTR ":\r\n",
            el->el_line.buffer));
 
        /* reset the Drawing cursor */
@@ -293,7 +293,8 @@
        ELRE_DEBUG(1, (__F,
                "term.h=%d vcur.h=%d vcur.v=%d vdisplay[0]=\r\n:%80.80s:\r\n",
                el->el_terminal.t_size.h, el->el_refresh.r_cursor.h,
-               el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0])));
+               el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0],
+               &el->el_scratch)));
 
        ELRE_DEBUG(1, (__F, "updating %d lines.\r\n", el->el_refresh.r_newcv));
        for (i = 0; i <= el->el_refresh.r_newcv; i++) {
@@ -321,7 +322,7 @@
                         /* This Strlen should be safe even with MB_FILL_CHARs */
                        terminal_clear_EOL(el, (int) Strlen(el->el_display[i]));
 #ifdef DEBUG_REFRESH
-                       terminal_overwrite(el, "C\b", (size_t)2);
+                       terminal_overwrite(el, STR("C\b"), 2);
 #endif /* DEBUG_REFRESH */
                        el->el_display[i][0] = '\0';
                }
@@ -368,8 +369,9 @@
 
        ELRE_DEBUG(1,
            (__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n",
-           num, dat, dlen, ct_encode_string(d)));
-       ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s)));
+           num, dat, dlen, ct_encode_string(d, &el->el_scratch)));
+       ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s,
+           &el->el_scratch)));
 
        /* open up the space for num chars */
        if (num > 0) {
@@ -382,8 +384,9 @@
 
        ELRE_DEBUG(1, (__F,
                "re_insert() after insert: %d at %d max %d, d == \"%s\"\n",
-               num, dat, dlen, ct_encode_string(d)));
-       ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s)));
+               num, dat, dlen, ct_encode_string(d, &el->el_scratch)));
+       ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s,
+               &el->el_scratch)));
 
        /* copy the characters */
        for (a = d + dat; (a < d + dlen) && (num > 0); num--)
@@ -418,7 +421,7 @@
        }
        ELRE_DEBUG(1,
            (__F, "re_delete() starting: %d at %d max %d, d == \"%s\"\n",
-           num, dat, dlen, ct_encode_string(d)));
+           num, dat, dlen, ct_encode_string(d, &el->el_scratch)));
 
        /* open up the space for num chars */
        if (num > 0) {
@@ -430,7 +433,7 @@
        }
        ELRE_DEBUG(1,
            (__F, "re_delete() after delete: %d at %d max %d, d == \"%s\"\n",
-           num, dat, dlen, ct_encode_string(d)));
+           num, dat, dlen, ct_encode_string(d, &el->el_scratch)));
 }
 
 
@@ -688,9 +691,9 @@
        sx = (int)((nls - nse) - (ols - ose));
 
        ELRE_DEBUG(1, (__F, "fx %d, sx %d\n", fx, sx));
-       ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n",
+       ELRE_DEBUG(1, (__F, "ofd %td, osb %td, ose %td, ols %td, oe %td\n",
                ofd - old, osb - old, ose - old, ols - old, oe - old));
-       ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
+       ELRE_DEBUG(1, (__F, "nfd %td, nsb %td, nse %td, nls %td, ne %td\n",
                nfd - new, nsb - new, nse - new, nls - new, ne - new));
        ELRE_DEBUG(1, (__F,
                "xxx-xxx:\"00000000001111111111222222222233333333334\"\r\n"));
@@ -764,7 +767,7 @@
        if ((nsb != nfd) && fx > 0 &&
            ((p - old) + fx <= el->el_terminal.t_size.h)) {
                ELRE_DEBUG(1,
-                   (__F, "first diff insert at %d...\r\n", nfd - new));
+                   (__F, "first diff insert at %td...\r\n", nfd - new));
                /*
                 * Move to the first char to insert, where the first diff is.
                 */
@@ -803,7 +806,7 @@
                }
        } else if (fx < 0) {
                ELRE_DEBUG(1,
-                   (__F, "first diff delete at %d...\r\n", ofd - old));
+                   (__F, "first diff delete at %td...\r\n", ofd - old));
                /*
                 * move to the first char to delete where the first diff is
                 */
@@ -850,7 +853,7 @@
 
        if (sx < 0 && (ose - old) + fx < el->el_terminal.t_size.h) {
                ELRE_DEBUG(1, (__F,
-                   "second diff delete at %d...\r\n", (ose - old) + fx));
+                   "second diff delete at %td...\r\n", (ose - old) + fx));
                /*
                 * Check if we have stuff to delete
                 */
@@ -888,7 +891,7 @@
          * if we have a first insert AND WE HAVEN'T ALREADY DONE IT...
          */
        if ((nsb != nfd) && (osb - ofd) <= (nsb - nfd) && (fx == 0)) {
-               ELRE_DEBUG(1, (__F, "late first diff insert at %d...\r\n",
+               ELRE_DEBUG(1, (__F, "late first diff insert at %td...\r\n",
                    nfd - new));
 
                terminal_move_to_char(el, (int)(nfd - new));
diff -r 74916bc8fcda -r fdc593fce59b lib/libedit/terminal.c
--- a/lib/libedit/terminal.c    Wed Mar 02 19:11:28 2016 +0000
+++ b/lib/libedit/terminal.c    Wed Mar 02 19:24:20 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 christos Exp $   */
+/*     $NetBSD: terminal.c,v 1.23 2016/03/02 19:24:20 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.22 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: terminal.c,v 1.23 2016/03/02 19:24:20 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -378,7 +378,7 @@
          */
        tlen = 0;
        for (tmp = tlist; tmp < &tlist[T_str]; tmp++)
-               if (*tmp != NULL && *tmp != '\0' && *tmp != *str) {
+               if (*tmp != NULL && *tmp != *str) {
                        char *ptr;
 
                        for (ptr = *tmp; *ptr != '\0'; termbuf[tlen++] = *ptr++)
@@ -666,7 +666,7 @@
        if (n > (size_t)el->el_terminal.t_size.h) {
 #ifdef DEBUG_SCREEN
                (void) fprintf(el->el_errfile,
-                   "%s: n is ridiculous: %d\r\n", __func__, n);
+                   "%s: n is ridiculous: %zu\r\n", __func__, n);
 #endif /* DEBUG_SCREEN */
                return;
        }
diff -r 74916bc8fcda -r fdc593fce59b lib/libedit/vi.c
--- a/lib/libedit/vi.c  Wed Mar 02 19:11:28 2016 +0000
+++ b/lib/libedit/vi.c  Wed Mar 02 19:24:20 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 christos Exp $ */
+/*     $NetBSD: vi.c,v 1.55 2016/03/02 19:24:20 christos Exp $ */
 
 /*-



Home | Main Index | Thread Index | Old Index