[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.32 and 1.33

version 1.32, 2010/07/01 17:02:02 version 1.33, 2010/07/01 17:04:24
Line 59 
Line 59 
   
 static char      *compile_addr(char *, struct s_addr *);  static char      *compile_addr(char *, struct s_addr *);
 static char      *compile_ccl(char **, char *);  static char      *compile_ccl(char **, char *);
 static char      *compile_delimited(char *, char *);  static char      *compile_delimited(char *, char *, int);
 static char      *compile_flags(char *, struct s_subst *);  static char      *compile_flags(char *, struct s_subst *);
 static char      *compile_re(char *, regex_t **);  static char      *compile_re(char *, regex_t **);
 static char      *compile_subst(char *, struct s_subst *);  static char      *compile_subst(char *, struct s_subst *);
Line 345 
Line 345 
  * with the processed string.   * with the processed string.
  */   */
 static char *  static char *
 compile_delimited(char *p, char *d)  compile_delimited(char *p, char *d, int is_tr)
 {  {
         char c;          char c;
   
Line 370 
Line 370 
                         p += 2;                          p += 2;
                         continue;                          continue;
                 } else if (*p == '\\' && p[1] == '\\') {                  } else if (*p == '\\' && p[1] == '\\') {
                         *d++ = *p++;                          if (is_tr)
                                   p++;
                           else
                                   *d++ = *p++;
                 } else if (*p == c) {                  } else if (*p == c) {
                         *d = '\0';                          *d = '\0';
                         return (p + 1);                          return (p + 1);
Line 427 
Line 430 
         char *re;          char *re;
   
         re = xmalloc(strlen(p) + 1); /* strlen(re) <= strlen(p) */          re = xmalloc(strlen(p) + 1); /* strlen(re) <= strlen(p) */
         p = compile_delimited(p, re);          p = compile_delimited(p, re, 0);
         if (p && strlen(re) == 0) {          if (p && strlen(re) == 0) {
                 *repp = NULL;                  *repp = NULL;
                 free(re);                  free(re);
Line 617 
Line 620 
                 err(COMPILE,                  err(COMPILE,
 "transform pattern can not be delimited by newline or backslash");  "transform pattern can not be delimited by newline or backslash");
         old = xmalloc(strlen(p) + 1);          old = xmalloc(strlen(p) + 1);
         p = compile_delimited(p, old);          p = compile_delimited(p, old, 1);
         if (p == NULL) {          if (p == NULL) {
                 err(COMPILE, "unterminated transform source string");                  err(COMPILE, "unterminated transform source string");
                 goto bad;                  goto bad;
         }          }
         new = xmalloc(strlen(p) + 1);          new = xmalloc(strlen(p) + 1);
         p = compile_delimited(--p, new);          p = compile_delimited(--p, new, 1);
         if (p == NULL) {          if (p == NULL) {
                 err(COMPILE, "unterminated transform target string");                  err(COMPILE, "unterminated transform target string");
                 goto bad;                  goto bad;

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33