Source-Changes-HG archive

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

[src/trunk]: src/dist/nvi Add a gcc printf attribute to the printf functions ...



details:   https://anonhg.NetBSD.org/src/rev/6902bb7828c1
branches:  trunk
changeset: 749037:6902bb7828c1
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 14 23:31:37 2009 +0000

description:
Add a gcc printf attribute to the printf functions and fix the lossage caught.

diffstat:

 dist/nvi/common/extern.h  |   8 +++++---
 dist/nvi/common/options.c |   6 +++---
 dist/nvi/ex/ex.c          |  22 +++++++++++++---------
 dist/nvi/ex/ex_global.c   |   7 +++----
 dist/nvi/ex/ex_read.c     |   5 +++--
 5 files changed, 27 insertions(+), 21 deletions(-)

diffs (148 lines):

diff -r 8bb9a1d853e0 -r 6902bb7828c1 dist/nvi/common/extern.h
--- a/dist/nvi/common/extern.h  Sat Nov 14 20:01:20 2009 +0000
+++ b/dist/nvi/common/extern.h  Sat Nov 14 23:31:37 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+/*     $NetBSD: extern.h,v 1.3 2009/11/14 23:31:37 christos Exp $ */
 
 /* Do not edit: automatically built by build/distrib. */
 SCR *api_fscreen __P((int, char *));
@@ -93,7 +93,8 @@
 int mark_get __P((SCR *, ARG_CHAR_T, MARK *, mtype_t));
 int mark_set __P((SCR *, ARG_CHAR_T, MARK *, int));
 int mark_insdel __P((SCR *, lnop_t, db_recno_t));
-void msgq __P((SCR *, mtype_t, const char *, ...));
+void msgq __P((SCR *, mtype_t, const char *, ...))
+    __attribute__((__format__(__printf__, 3, 4)));
 void msgq_wstr __P((SCR *, mtype_t, const CHAR_T *, const char *));
 void msgq_str __P((SCR *, mtype_t, const char *, const char *));
 void mod_rpt __P((SCR *));
@@ -158,7 +159,8 @@
 int e_memcmp __P((CHAR_T *, EVENT *, size_t));
 void vtrace_end __P((void));
 void vtrace_init __P((char *));
-void vtrace __P((const char *, ...));
+void vtrace __P((const char *, ...))
+    __attribute__((__format__(__printf__, 1, 2)));
 void *binc __P((SCR *, void *, size_t *, size_t));
 int nonblank __P((SCR *, db_recno_t, size_t *));
 const char *tail __P((const char *));
diff -r 8bb9a1d853e0 -r 6902bb7828c1 dist/nvi/common/options.c
--- a/dist/nvi/common/options.c Sat Nov 14 20:01:20 2009 +0000
+++ b/dist/nvi/common/options.c Sat Nov 14 23:31:37 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.c,v 1.6 2009/08/07 16:19:53 lukem Exp $ */
+/*     $NetBSD: options.c,v 1.7 2009/11/14 23:31:37 christos Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -475,8 +475,8 @@
        }
        return (0);
 
-err:   msgq(sp, M_ERR,
-           "031|Unable to set default %s option", optlist[optindx].name);
+err:   msgq_wstr(sp, M_ERR, optlist[optindx].name,
+           "031|Unable to set default %s option");
        return (1);
 }
 
diff -r 8bb9a1d853e0 -r 6902bb7828c1 dist/nvi/ex/ex.c
--- a/dist/nvi/ex/ex.c  Sat Nov 14 20:01:20 2009 +0000
+++ b/dist/nvi/ex/ex.c  Sat Nov 14 23:31:37 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ex.c,v 1.4 2009/01/18 03:45:50 lukem Exp $ */
+/*     $NetBSD: ex.c,v 1.5 2009/11/14 23:31:37 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -583,8 +583,8 @@
 
        /* Check for ex mode legality. */
        if (F_ISSET(sp, SC_EX) && (F_ISSET(ecp->cmd, E_VIONLY) || newscreen)) {
-               msgq(sp, M_ERR,
-                   "082|%s: command not available in ex mode", ecp->cmd->name);
+               msgq_wstr(sp, M_ERR, ecp->cmd->name,
+                   "082|%s: command not available in ex mode");
                goto err;
        }
 
@@ -1208,10 +1208,15 @@
                                        goto usage;
                        }
                        goto addr_verify;
-               default:
+               default: {
+                       const char *nstr;
+                       size_t nlen;
+                       INT2CHAR(sp, ecp->cmd->name, STRLEN(ecp->cmd->name) + 1,
+                           nstr, nlen);
                        msgq(sp, M_ERR,
                            "085|Internal syntax table error (%s: %s)",
-                           ecp->cmd->name, KEY_NAME(sp, *np));
+                           nstr, KEY_NAME(sp, *np));
+               }
                }
        }
 
@@ -2312,7 +2317,7 @@
                if (lno != 0) {
                        msgq(sp, M_ERR,
                            "102|Illegal address: only %lu lines in the file",
-                           lno);
+                           (unsigned long)lno);
                        break;
                }
                /* FALLTHROUGH */
@@ -2323,9 +2328,8 @@
                abort();
                /* NOTREACHED */
        case A_ZERO:
-               msgq(sp, M_ERR,
-                   "104|The %s command doesn't permit an address of 0",
-                   cp->name);
+               msgq_wstr(sp, M_ERR, cp->name,
+                   "104|The %s command doesn't permit an address of 0");
                break;
        }
        return;
diff -r 8bb9a1d853e0 -r 6902bb7828c1 dist/nvi/ex/ex_global.c
--- a/dist/nvi/ex/ex_global.c   Sat Nov 14 20:01:20 2009 +0000
+++ b/dist/nvi/ex/ex_global.c   Sat Nov 14 23:31:37 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ex_global.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+/*     $NetBSD: ex_global.c,v 1.3 2009/11/14 23:31:37 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -80,9 +80,8 @@
        NEEDFILE(sp, cmdp);
 
        if (F_ISSET(sp, SC_EX_GLOBAL)) {
-               msgq(sp, M_ERR,
-       "124|The %s command can't be used as part of a global or v command",
-                   cmdp->cmd->name);
+               msgq_wstr(sp, M_ERR, cmdp->cmd->name,
+       "124|The %s command can't be used as part of a global or v command");
                return (1);
        }
 
diff -r 8bb9a1d853e0 -r 6902bb7828c1 dist/nvi/ex/ex_read.c
--- a/dist/nvi/ex/ex_read.c     Sat Nov 14 20:01:20 2009 +0000
+++ b/dist/nvi/ex/ex_read.c     Sat Nov 14 23:31:37 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ex_read.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+/*     $NetBSD: ex_read.c,v 1.3 2009/11/14 23:31:37 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -345,7 +345,8 @@
        if (!silent) {
                char *q = msg_print(sp, name, &nf);
                msgq(sp, M_INFO,
-                   "148|%s: %lu lines, %lu characters", q, lcnt, ccnt);
+                   "148|%s: %lu lines, %lu characters", q, (unsigned long)lcnt,
+                   (unsigned long)ccnt);
                if (nf)
                        FREE_SPACE(sp, q, 0);
        }



Home | Main Index | Thread Index | Old Index