Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/sed Handle a closing brace at the end of a command w...
details: https://anonhg.NetBSD.org/src/rev/751a7bf54d6b
branches: trunk
changeset: 329078:751a7bf54d6b
user: christos <christos%NetBSD.org@localhost>
date: Mon May 05 17:12:11 2014 +0000
description:
Handle a closing brace at the end of a command without a preceding semi-colon:
/foo/ {p;d}
diffstat:
usr.bin/sed/compile.c | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
diffs (64 lines):
diff -r 561fd7f0b19b -r 751a7bf54d6b usr.bin/sed/compile.c
--- a/usr.bin/sed/compile.c Mon May 05 15:59:11 2014 +0000
+++ b/usr.bin/sed/compile.c Mon May 05 17:12:11 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compile.c,v 1.39 2013/06/28 15:04:35 joerg Exp $ */
+/* $NetBSD: compile.c,v 1.40 2014/05/05 17:12:11 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -76,7 +76,7 @@
#if 0
static char sccsid[] = "@(#)compile.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: compile.c,v 1.39 2013/06/28 15:04:35 joerg Exp $");
+__RCSID("$NetBSD: compile.c,v 1.40 2014/05/05 17:12:11 christos Exp $");
#endif
#endif /* not lint */
@@ -281,14 +281,19 @@
case EMPTY: /* d D g G h H l n N p P q x = \0 */
p++;
EATSPACE();
- if (*p == ';') {
+ switch (*p) {
+ case ';':
p++;
link = &cmd->next;
goto semicolon;
- }
- if (*p)
+ case '}':
+ goto semicolon;
+ case '\0':
+ break;
+ default:
err(COMPILE,
"extra characters at the end of %c command", cmd->code);
+ }
break;
case TEXT: /* a c i */
p++;
@@ -365,14 +370,19 @@
p++;
p = compile_tr(p, (char **)(void *)&cmd->u.y);
EATSPACE();
- if (*p == ';') {
+ switch (*p) {
+ case ';':
p++;
link = &cmd->next;
goto semicolon;
- }
- if (*p)
+ case '}':
+ goto semicolon;
+ case '\0':
+ break;
+ default:
err(COMPILE,
"extra text at the end of a transform command");
+ }
break;
}
}
Home |
Main Index |
Thread Index |
Old Index