version 1.32, 2010/07/01 17:02:02 |
version 1.33, 2010/07/01 17:04:24 |
|
|
|
|
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 *); |
|
|
* 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; |
|
|
|
|
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); |
|
|
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); |
|
|
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; |