[BACK]Return to compile.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sed

Diff for /src/usr.bin/sed/compile.c between version 1.48 and 1.49

version 1.48, 2018/07/09 09:43:54 version 1.49, 2018/08/14 18:10:09
Line 362 
Line 362 
                 error(COMPILE, "\\ can not be used as a string delimiter");                  error(COMPILE, "\\ can not be used as a string delimiter");
         else if (c == '\n')          else if (c == '\n')
                 error(COMPILE, "newline can not be used as a string delimiter");                  error(COMPILE, "newline can not be used as a string delimiter");
         while (*p) {  
                 if (*p == '[' && *p != c) {          while (p[0]) {
                         if ((d = compile_ccl(&p, d)) == NULL)                  /* Unescaped delimiter: We are done. */
                                 error(COMPILE, "unbalanced brackets ([])");                  if (p[0] == c) {
                         continue;  
                 } else if (*p == '\\' && p[1] == c) {  
                         p++;  
                 } else if (*p == '\\' && p[1] == '[') {  
                         *d++ = *p++;  
                 } else if (*p == '\\' && p[1] == 'n') {  
                         *d++ = '\n';  
                         p += 2;  
                         continue;  
                 } else if (*p == '\\' && p[1] == '\\') {  
                         *d++ = *p++;  
                 } else if (*p == c) {  
                         *d = '\0';                          *d = '\0';
                         return (p + 1);                          return p + 1;
                 }                  }
                 *d++ = *p++;                  if (p[0] == '\\') {
                           /* Escaped delimiter: Skip the backslash. */
                           if (p[1] == c) {
                                   p++;
                           } else {
                                   /* Backslash-n: Match linefeed. */
                                   if (p[1] == 'n') {
                                           *d++ = '\n';
                                           p += 2;
                                   /* Other escapes remain unchanged. */
                                   } else {
                                           *d++ = *p++;
                                           *d++ = *p++;
                                   }
                                   continue;
                           }
                   }
                   if (p[0] != '[')
                           *d++ = *p++;
                   /*
                    * Bracket expression:
                    * It may contain the delimiter without escaping.
                    */
                   else if ((d = compile_ccl(&p, d)) == NULL)
                           error(COMPILE, "unbalanced brackets ([])");
         }          }
         return (NULL);          return NULL;
 }  }
   
   

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49