On Sat, Dec 13, 2014 at 10:57:42AM -0500, Daniel Dickman wrote:
> > -                   (*t == 'a' || *t == 'c' || *t == 'd' || *t == 'i' || *t 
> > == 's')) {
> > +                   strchr("acdis", *t) != NULL) {
> 
> 
> doesn't this change the semantics slightly? i haven't looked at the
> context beyond what's in your patch but if *t is somehow equal to NUL,
> won't strchr return the position of the terminating NUL since "The
> terminating NUL character is considered to be part of the string."?

Indeed, thanks for pointing it out.

Updated diff below:


Index: pch.c
===================================================================
RCS file: /cvs/src/usr.bin/patch/pch.c,v
retrieving revision 1.49
diff -u -p -u -p -r1.49 pch.c
--- pch.c       13 Dec 2014 10:31:07 -0000      1.49
+++ pch.c       13 Dec 2014 16:17:01 -0000
@@ -1398,10 +1398,10 @@ do_ed_script(void)
                        ;
                /* POSIX defines allowed commands as {a,c,d,i,s} */
                if (isdigit((unsigned char)*buf) &&
-                   (*t == 'a' || *t == 'c' || *t == 'd' || *t == 'i' || *t == 
's')) {
+                   *t != '\0' && strchr("acdis", *t) != NULL) {
                        if (pipefp != NULL)
                                fputs(buf, pipefp);
-                       if (*t != 'd') {
+                       if (*t != 'd' && *t != 's') {
                                while (pgets(buf, sizeof buf, pfp) != NULL) {
                                        p_input_line++;
                                        if (pipefp != NULL)

Reply via email to