Some packages (e.g., binutils 2.17) want to issue sed commands like
s,^.*/,,;s,^,avr-,;;s/$//
but OpenBSD's sed doesn't handle empty expressions as in this. The
patch below adds support for this.
(It also eliminates a useless null pointer check: p is checked for
nullity when it is set a few lines above the hunk, and p is also
dereferenced later without null checks.)
Index: src/usr.bin/sed/compile.c
===================================================================
RCS file: /cvs/src/usr.bin/sed/compile.c,v
retrieving revision 1.22
diff -p -u -r1.22 compile.c
--- src/usr.bin/sed/compile.c 9 Oct 2006 00:23:56 -0000 1.22
+++ src/usr.bin/sed/compile.c 2 Jan 2007 04:28:29 -0000
@@ -161,8 +161,12 @@ compile_stream(struct s_command **link)
}
semicolon: EATSPACE();
- if (p && (*p == '#' || *p == '\0'))
+ if (*p == '#' || *p == '\0')
continue;
+ if (*p == ';') {
+ p++;
+ goto semicolon;
+ }
*link = cmd = xmalloc(sizeof(struct s_command));
link = &cmd->next;
cmd->nonsel = cmd->inrange = 0;