Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/gencat Improve the handling of quoted messages.
details: https://anonhg.NetBSD.org/src/rev/095bdf009355
branches: trunk
changeset: 777924:095bdf009355
user: ginsbach <ginsbach%NetBSD.org@localhost>
date: Fri Mar 09 18:54:28 2012 +0000
description:
Improve the handling of quoted messages.
- warn about messages with an unexpected quote character
- warn about extra characters after a quote character
- warn about an unterminated quoted message
diffstat:
usr.bin/gencat/gencat.c | 31 ++++++++++++++++++++++++++-----
1 files changed, 26 insertions(+), 5 deletions(-)
diffs (73 lines):
diff -r ca70ec38f0aa -r 095bdf009355 usr.bin/gencat/gencat.c
--- a/usr.bin/gencat/gencat.c Fri Mar 09 15:41:16 2012 +0000
+++ b/usr.bin/gencat/gencat.c Fri Mar 09 18:54:28 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gencat.c,v 1.34 2011/12/29 22:58:27 wiz Exp $ */
+/* $NetBSD: gencat.c,v 1.35 2012/03/09 18:54:28 ginsbach Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: gencat.c,v 1.34 2011/12/29 22:58:27 wiz Exp $");
+__RCSID("$NetBSD: gencat.c,v 1.35 2012/03/09 18:54:28 ginsbach Exp $");
#endif
/***********************************************************
@@ -345,11 +345,13 @@
{
static char *msg = NULL;
static size_t msglen = 0;
- size_t clen, i;
+ size_t clen, i;
+ int in_quote = 0;
char *tptr;
if (quote && *cptr == quote) {
++cptr;
+ in_quote = 1;
}
clen = strlen(cptr) + 1;
@@ -366,11 +368,26 @@
if (quote && *cptr == quote) {
char *tmp;
tmp = cptr + 1;
- if (*tmp && (!isspace((unsigned char) *tmp) || *wskip(tmp))) {
+ if (!in_quote) {
+ /* XXX hard error? */
warning(cptr, "unexpected quote character, ignoring");
*tptr++ = *cptr++;
} else {
- *cptr = '\0';
+ cptr++;
+ /* don't use wskip() */
+ while (*cptr && isspace((unsigned char) *cptr))
+#ifndef _BACKWARDS_COMPAT
+ cptr++;
+#else
+ *tptr++ = *cptr++;
+#endif
+ /* XXX hard error? */
+ if (*cptr)
+ warning(tmp, "unexpected extra characters, ignoring");
+ in_quote = 0;
+#ifndef _BACKWARDS_COMPAT
+ break;
+#endif
}
} else {
if (*cptr == '\\') {
@@ -437,6 +454,10 @@
}
}
}
+
+ if (in_quote)
+ warning(cptr, "unterminated quoted message, ignoring");
+
*tptr = '\0';
return (msg);
}
Home |
Main Index |
Thread Index |
Old Index