diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-03-22 11:32:19 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-03-22 11:32:19 +0000 |
commit | ac3b2e8571fc98ff6bdd16b9ab77fae32c648838 (patch) | |
tree | bec0c8a36e7b5e816bb37a3a649fd8e5a7e5d927 /lib | |
parent | c2f1a9820918a255ea08f9255537d495c2a9311d (diff) |
format string fixes in debug code;
committing right away because this code is not even compiled by default
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libedit/Makefile | 6 | ||||
-rw-r--r-- | lib/libedit/chartype.h | 4 | ||||
-rw-r--r-- | lib/libedit/common.c | 7 | ||||
-rw-r--r-- | lib/libedit/read.c | 4 | ||||
-rw-r--r-- | lib/libedit/refresh.c | 41 | ||||
-rw-r--r-- | lib/libedit/terminal.c | 4 | ||||
-rw-r--r-- | lib/libedit/vi.c | 5 |
7 files changed, 39 insertions, 32 deletions
diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile index 29d8d573b3f..8a1442c6185 100644 --- a/lib/libedit/Makefile +++ b/lib/libedit/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.17 2016/03/21 15:25:39 schwarze Exp $ +# $OpenBSD: Makefile,v 1.18 2016/03/22 11:32:18 schwarze Exp $ # $NetBSD: Makefile,v 1.41 2010/02/03 15:34:43 roy Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 @@ -55,8 +55,8 @@ CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp tc1.o tc1 CFLAGS+=-Wall 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 --git a/lib/libedit/chartype.h b/lib/libedit/chartype.h index cf648516a2a..1f952c403a4 100644 --- a/lib/libedit/chartype.h +++ b/lib/libedit/chartype.h @@ -1,4 +1,4 @@ -/* $OpenBSD: chartype.h,v 1.12 2016/03/21 18:40:25 schwarze Exp $ */ +/* $OpenBSD: chartype.h,v 1.13 2016/03/22 11:32:18 schwarze Exp $ */ /* $NetBSD: chartype.h,v 1.5 2010/04/15 00:55:57 christos Exp $ */ /*- @@ -66,6 +66,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) @@ -114,6 +115,7 @@ size_t ct_mbrtowc(wchar_t *, const char *, size_t, void *); #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 --git a/lib/libedit/common.c b/lib/libedit/common.c index ff9faf7562e..f6988df9878 100644 --- a/lib/libedit/common.c +++ b/lib/libedit/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.15 2016/03/21 15:25:39 schwarze Exp $ */ +/* $OpenBSD: common.c,v 1.16 2016/03/22 11:32:18 schwarze Exp $ */ /* $NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -141,8 +141,9 @@ ed_delete_next_char(EditLine *el, wint_t c) { #ifdef notdef /* XXX */ #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 --git a/lib/libedit/read.c b/lib/libedit/read.c index 45c72de3b1d..cf3186d327c 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.28 2016/03/21 17:28:10 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.29 2016/03/22 11:32:18 schwarze Exp $ */ /* $NetBSD: read.c,v 1.81 2016/02/16 22:53:14 christos Exp $ */ /*- @@ -612,7 +612,7 @@ FUN(el,gets)(EditLine *el, int *nread) 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 --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c index bbd4f2f2cf6..16088ec346d 100644 --- a/lib/libedit/refresh.c +++ b/lib/libedit/refresh.c @@ -1,5 +1,5 @@ -/* $OpenBSD: refresh.c,v 1.14 2016/03/20 23:48:27 schwarze Exp $ */ -/* $NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $ */ +/* $OpenBSD: refresh.c,v 1.15 2016/03/22 11:32:18 schwarze Exp $ */ +/* $NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -55,7 +55,7 @@ private void re__strncopy(Char *, Char *, size_t); 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) { \ @@ -69,7 +69,7 @@ private void re_printstr(EditLine *, const char *, char *, char *); * 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)); @@ -199,7 +199,7 @@ re_refresh(EditLine *el) 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 */ @@ -287,7 +287,8 @@ re_refresh(EditLine *el) 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++) { @@ -315,7 +316,7 @@ re_refresh(EditLine *el) /* 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'; } @@ -362,8 +363,9 @@ re_insert(EditLine *el __attribute__((__unused__)), 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) { @@ -376,8 +378,9 @@ re_insert(EditLine *el __attribute__((__unused__)), 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--) @@ -412,7 +415,7 @@ re_delete(EditLine *el __attribute__((__unused__)), } 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) { @@ -424,7 +427,7 @@ re_delete(EditLine *el __attribute__((__unused__)), } 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))); } @@ -682,9 +685,9 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) 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")); @@ -758,7 +761,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) 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. */ @@ -797,7 +800,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) } } 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 */ @@ -844,7 +847,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) 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 */ @@ -882,7 +885,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) * 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 --git a/lib/libedit/terminal.c b/lib/libedit/terminal.c index 54f80bdc36c..0271c2243f4 100644 --- a/lib/libedit/terminal.c +++ b/lib/libedit/terminal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: terminal.c,v 1.10 2016/03/22 11:10:57 schwarze Exp $ */ +/* $OpenBSD: terminal.c,v 1.11 2016/03/22 11:32:18 schwarze Exp $ */ /* $NetBSD: terminal.c,v 1.17 2016/02/15 15:35:03 christos Exp $ */ /*- @@ -652,7 +652,7 @@ terminal_overwrite(EditLine *el, const Char *cp, size_t n) if (n > (size_t)el->el_terminal.t_size.h) { #ifdef DEBUG_SCREEN (void) fprintf(el->el_errfile, - "terminal_overwrite: n is riduculous: %d\r\n", n); + "terminal_overwrite: n is riduculous: %zu\r\n", n); #endif /* DEBUG_SCREEN */ return; } diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c index ec3c726dd47..fe06c14d09f 100644 --- a/lib/libedit/vi.c +++ b/lib/libedit/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.18 2016/03/20 23:48:27 schwarze Exp $ */ +/* $OpenBSD: vi.c,v 1.19 2016/03/22 11:32:18 schwarze Exp $ */ /* $NetBSD: vi.c,v 1.33 2011/02/17 16:44:48 joerg Exp $ */ /*- @@ -97,7 +97,8 @@ cv_paste(EditLine *el, wint_t c) if (k->buf == NULL || len == 0) return CC_ERROR; #ifdef DEBUG_PASTE - (void) fprintf(el->el_errfile, "Paste: \"%.*s\"\n", (int)len, k->buf); + (void) fprintf(el->el_errfile, "Paste: \"" FSTARSTR "\"\n", (int)len, + k->buf); #endif cv_undo(el); |