Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/dist/nvi one more printf like function, and fix the lossage.
details: https://anonhg.NetBSD.org/src/rev/6b4b28cb4826
branches: trunk
changeset: 749038:6b4b28cb4826
user: christos <christos%NetBSD.org@localhost>
date: Sat Nov 14 23:40:11 2009 +0000
description:
one more printf like function, and fix the lossage.
diffstat:
dist/nvi/ex/ex_bang.c | 5 +++--
dist/nvi/ex/ex_equal.c | 4 ++--
dist/nvi/ex/ex_read.c | 10 ++++++----
dist/nvi/ex/ex_txt.c | 10 +++++++---
dist/nvi/ex/ex_usage.c | 9 +++++++--
dist/nvi/ex/extern.h | 5 +++--
dist/nvi/vi/vs_msg.c | 4 ++--
7 files changed, 30 insertions(+), 17 deletions(-)
diffs (148 lines):
diff -r 6902bb7828c1 -r 6b4b28cb4826 dist/nvi/ex/ex_bang.c
--- a/dist/nvi/ex/ex_bang.c Sat Nov 14 23:31:37 2009 +0000
+++ b/dist/nvi/ex/ex_bang.c Sat Nov 14 23:40:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ex_bang.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+/* $NetBSD: ex_bang.c,v 1.3 2009/11/14 23:40:11 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -90,7 +90,8 @@
if (F_ISSET(sp, SC_VI))
vs_update(sp, "!", ap->bp);
else {
- (void)ex_printf(sp, "!%s\n", ap->bp);
+ INT2CHAR(sp, ap->bp, ap->len+1, np, nlen);
+ (void)ex_printf(sp, "!%s\n", np);
(void)ex_fflush(sp);
}
}
diff -r 6902bb7828c1 -r 6b4b28cb4826 dist/nvi/ex/ex_equal.c
--- a/dist/nvi/ex/ex_equal.c Sat Nov 14 23:31:37 2009 +0000
+++ b/dist/nvi/ex/ex_equal.c Sat Nov 14 23:40:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ex_equal.c,v 1.1.1.2 2008/05/18 14:31:14 aymeric Exp $ */
+/* $NetBSD: ex_equal.c,v 1.2 2009/11/14 23:40:11 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -54,6 +54,6 @@
} else
lno = cmdp->addr1.lno;
- (void)ex_printf(sp, "%ld\n", lno);
+ (void)ex_printf(sp, "%ld\n", (unsigned long)lno);
return (0);
}
diff -r 6902bb7828c1 -r 6b4b28cb4826 dist/nvi/ex/ex_read.c
--- a/dist/nvi/ex/ex_read.c Sat Nov 14 23:31:37 2009 +0000
+++ b/dist/nvi/ex/ex_read.c Sat Nov 14 23:40:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ex_read.c,v 1.3 2009/11/14 23:31:37 christos Exp $ */
+/* $NetBSD: ex_read.c,v 1.4 2009/11/14 23:40:11 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -133,10 +133,12 @@
if (F_ISSET(cmdp, E_MODIFY))
(void)vs_update(sp, "!", cmdp->argv[argc]->bp);
} else {
- if (F_ISSET(cmdp, E_MODIFY))
+ if (F_ISSET(cmdp, E_MODIFY)) {
+ INT2CHAR(sp, cmdp->argv[argc]->bp,
+ cmdp->argv[argc]->len + 1, name, nlen);
(void)ex_printf(sp,
- "!%s\n", cmdp->argv[argc]->bp);
- else
+ "!%s\n", name);
+ } else
(void)ex_puts(sp, "!\n");
(void)ex_fflush(sp);
}
diff -r 6902bb7828c1 -r 6b4b28cb4826 dist/nvi/ex/ex_txt.c
--- a/dist/nvi/ex/ex_txt.c Sat Nov 14 23:31:37 2009 +0000
+++ b/dist/nvi/ex/ex_txt.c Sat Nov 14 23:40:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ex_txt.c,v 1.4 2009/08/07 16:19:54 lukem Exp $ */
+/* $NetBSD: ex_txt.c,v 1.5 2009/11/14 23:40:11 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -363,8 +363,12 @@
(void)ex_printf(sp, "%6lu ", (u_long)tp->lno);
/* Print out autoindent string. */
- if (LF_ISSET(TXT_AUTOINDENT))
- (void)ex_printf(sp, "%.*s", (int)tp->ai, tp->lb);
+ if (LF_ISSET(TXT_AUTOINDENT)) {
+ const char *nstr;
+ size_t nlen;
+ INT2CHAR(sp, tp->lb, tp->ai + 1, nstr, nlen);
+ (void)ex_printf(sp, "%.*s", (int)tp->ai, nstr);
+ }
(void)ex_fflush(sp);
}
diff -r 6902bb7828c1 -r 6b4b28cb4826 dist/nvi/ex/ex_usage.c
--- a/dist/nvi/ex/ex_usage.c Sat Nov 14 23:31:37 2009 +0000
+++ b/dist/nvi/ex/ex_usage.c Sat Nov 14 23:40:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ex_usage.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+/* $NetBSD: ex_usage.c,v 1.3 2009/11/14 23:40:11 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -77,10 +77,15 @@
memcmp(ap->bp, cp->name, ap->len); ++cp);
if (cp->name == NULL ||
(newscreen && !F_ISSET(cp, E_NEWSCREEN))) {
+ const char *nstr;
+ size_t nlen;
+
if (newscreen)
ap->bp[0] = toupper(ap->bp[0]);
+
+ INT2CHAR(sp, ap->bp, ap->len + 1, nstr, nlen);
(void)ex_printf(sp, "The %.*s command is unknown\n",
- (int)ap->len, ap->bp);
+ (int)ap->len, nstr);
} else {
(void)ex_printf(sp,
"Command: %s\n Usage: %s\n", cp->help, cp->usage);
diff -r 6902bb7828c1 -r 6b4b28cb4826 dist/nvi/ex/extern.h
--- a/dist/nvi/ex/extern.h Sat Nov 14 23:31:37 2009 +0000
+++ b/dist/nvi/ex/extern.h Sat Nov 14 23:40:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.3 2008/12/05 22:51:42 christos Exp $ */
+/* $NetBSD: extern.h,v 1.4 2009/11/14 23:40:11 christos Exp $ */
/* Do not edit: automatically built by build/distrib. */
int ex __P((SCR **));
@@ -62,7 +62,8 @@
int ex_print __P((SCR *, EXCMD *, MARK *, MARK *, u_int32_t));
int ex_ldisplay __P((SCR *, const CHAR_T *, size_t, size_t, u_int));
int ex_scprint __P((SCR *, MARK *, MARK *));
-int ex_printf __P((SCR *, const char *, ...));
+int ex_printf __P((SCR *, const char *, ...))
+ __attribute__((__format__(__printf__, 2, 3)));
int ex_puts __P((SCR *, const char *));
int ex_fflush __P((SCR *sp));
int ex_put __P((SCR *, EXCMD *));
diff -r 6902bb7828c1 -r 6b4b28cb4826 dist/nvi/vi/vs_msg.c
--- a/dist/nvi/vi/vs_msg.c Sat Nov 14 23:31:37 2009 +0000
+++ b/dist/nvi/vi/vs_msg.c Sat Nov 14 23:40:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vs_msg.c,v 1.2 2008/12/05 22:51:43 christos Exp $ */
+/* $NetBSD: vs_msg.c,v 1.3 2009/11/14 23:40:11 christos Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -179,7 +179,7 @@
if (m2 != NULL)
INT2CHAR(sp, m2, STRLEN(m2) + 1, np, nlen);
(void)ex_printf(sp,
- "%s\n", m1 == NULL? "" : m1, m2 == NULL ? "" : np);
+ "%s%s\n", m1 == NULL? "" : m1, m2 == NULL ? "" : np);
(void)ex_fflush(sp);
}
Home |
Main Index |
Thread Index |
Old Index