Module Name: src
Committed By: christos
Date: Mon May 5 17:12:11 UTC 2014
Modified Files:
src/usr.bin/sed: compile.c
Log Message:
Handle a closing brace at the end of a command without a preceding semi-colon:
/foo/ {p;d}
To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/sed/compile.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/sed/compile.c
diff -u src/usr.bin/sed/compile.c:1.39 src/usr.bin/sed/compile.c:1.40
--- src/usr.bin/sed/compile.c:1.39 Fri Jun 28 11:04:35 2013
+++ src/usr.bin/sed/compile.c Mon May 5 13:12:11 2014
@@ -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 @@ nonsel: /* Now parse the command */
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 @@ nonsel: /* Now parse the command */
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;
}
}