|
|
|
@ -1,4 +1,4 @@ |
|
|
|
/* Generated by re2c 0.5 on Wed Sep 20 04:00:49 2000 */ |
|
|
|
/* Generated by re2c 0.5 on Wed Sep 20 10:04:05 2000 */ |
|
|
|
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re" |
|
|
|
/* |
|
|
|
+----------------------------------------------------------------------+ |
|
|
|
@ -47,13 +47,26 @@ static inline void smart_str_append(smart_str *dest, smart_str *src) |
|
|
|
|
|
|
|
newlen = dest->len + src->len; |
|
|
|
if (newlen >= dest->a) { |
|
|
|
dest->c = realloc(dest->c, newlen + 101); |
|
|
|
dest->a = newlen + 100; |
|
|
|
dest->c = realloc(dest->c, newlen + 129); |
|
|
|
dest->a = newlen + 128; |
|
|
|
} |
|
|
|
memcpy(dest->c + dest->len, src->c, src->len); |
|
|
|
dest->c[dest->len = newlen] = '\0'; |
|
|
|
} |
|
|
|
|
|
|
|
static inline void smart_str_appendc(smart_str *dest, char c) |
|
|
|
{ |
|
|
|
size_t newlen; |
|
|
|
|
|
|
|
newlen = dest->len + 1; |
|
|
|
if (newlen >= dest->a) { |
|
|
|
dest->c = realloc(dest->c, newlen + 129); |
|
|
|
dest->a = newlen + 128; |
|
|
|
} |
|
|
|
dest->c[dest->len++] = c; |
|
|
|
dest->c[dest->len] = '\0'; |
|
|
|
} |
|
|
|
|
|
|
|
static inline void smart_str_free(smart_str *s) |
|
|
|
{ |
|
|
|
if (s->c) { |
|
|
|
@ -81,13 +94,6 @@ static inline void smart_str_appendl(smart_str *dest, const char *src, size_t le |
|
|
|
smart_str_append(dest, &s); |
|
|
|
} |
|
|
|
|
|
|
|
static inline void smart_str_set(smart_str *dest, smart_str *src) |
|
|
|
{ |
|
|
|
dest->len = src->len; |
|
|
|
dest->a = src->a; |
|
|
|
dest->c = src->c; |
|
|
|
} |
|
|
|
|
|
|
|
static inline void smart_str_setl(smart_str *dest, const char *src, size_t len) |
|
|
|
{ |
|
|
|
dest->len = len; |
|
|
|
@ -97,32 +103,26 @@ static inline void smart_str_setl(smart_str *dest, const char *src, size_t len) |
|
|
|
|
|
|
|
#define smart_str_appends(dest, src) smart_str_appendl(dest, src, sizeof(src)-1) |
|
|
|
|
|
|
|
#if 0 |
|
|
|
static inline void smart_str_copys(smart_str *dest, const char *src) |
|
|
|
{ |
|
|
|
smart_str_copyl(dest, src, strlen(src)); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
static inline void smart_str_sets(smart_str *dest, const char *src) |
|
|
|
{ |
|
|
|
smart_str_setl(dest, src, strlen(src)); |
|
|
|
} |
|
|
|
|
|
|
|
static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator) |
|
|
|
static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *name, smart_str *val, const char *separator) |
|
|
|
{ |
|
|
|
register const char *p, *q; |
|
|
|
const char *bash = NULL; |
|
|
|
const char *sep = "?"; |
|
|
|
char sep = "?"; |
|
|
|
|
|
|
|
q = url->c + url->len; |
|
|
|
|
|
|
|
for (p = url->c; p < q; p++) { |
|
|
|
switch(*p) { |
|
|
|
case ':': |
|
|
|
smart_str_append(dest, url); |
|
|
|
return; |
|
|
|
case '?': |
|
|
|
sep = separator; |
|
|
|
sep = *separator; |
|
|
|
break; |
|
|
|
case '#': |
|
|
|
bash = p; |
|
|
|
@ -130,24 +130,18 @@ static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, c |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (bash) { |
|
|
|
smart_str new = {0}; |
|
|
|
|
|
|
|
smart_str_copyl(&new, url->c, bash - url->c); |
|
|
|
smart_str_appendl(&new, sep, 1); |
|
|
|
smart_str_append(&new, name); |
|
|
|
smart_str_appendl(&new, "=", 1); |
|
|
|
smart_str_append(&new, val); |
|
|
|
smart_str_appendl(&new, bash, q - bash); |
|
|
|
|
|
|
|
smart_str_free(url); |
|
|
|
smart_str_set(url, &new); |
|
|
|
} else { |
|
|
|
smart_str_appendl(url, sep, 1); |
|
|
|
smart_str_append(url, name); |
|
|
|
smart_str_appendl(url, "=", 1); |
|
|
|
smart_str_append(url, val); |
|
|
|
} |
|
|
|
if (bash) |
|
|
|
smart_str_appendl(dest, url->c, bash - url->c); |
|
|
|
else |
|
|
|
smart_str_append(dest, url); |
|
|
|
|
|
|
|
smart_str_appendc(dest, sep); |
|
|
|
smart_str_append(dest, name); |
|
|
|
smart_str_appendc(dest, '='); |
|
|
|
smart_str_append(dest, val); |
|
|
|
|
|
|
|
if (bash) |
|
|
|
smart_str_appendl(dest, bash, q - bash); |
|
|
|
} |
|
|
|
|
|
|
|
struct php_tag_arg { |
|
|
|
@ -186,9 +180,10 @@ static inline void tag_arg(url_adapt_state_ex_t *ctx PLS_DC) |
|
|
|
|
|
|
|
smart_str_appends(&ctx->result, "\""); |
|
|
|
if (f) { |
|
|
|
attach_url(&ctx->val, &ctx->q_name, &ctx->q_value, PG(arg_separator)); |
|
|
|
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator)); |
|
|
|
} else { |
|
|
|
smart_str_append(&ctx->result, &ctx->val); |
|
|
|
} |
|
|
|
smart_str_append(&ctx->result, &ctx->val); |
|
|
|
smart_str_appends(&ctx->result, "\""); |
|
|
|
} |
|
|
|
|
|
|
|
@ -230,24 +225,24 @@ enum { |
|
|
|
*/ |
|
|
|
|
|
|
|
#define HANDLE_TAG() {\ |
|
|
|
int __ok = 0; \ |
|
|
|
int ok = 0; \ |
|
|
|
int i; \ |
|
|
|
smart_str_setl(&ctx->tag, start, YYCURSOR - start); \ |
|
|
|
for (i = 0; check_tag_arg[i].tag; i++) { \ |
|
|
|
if (ctx->tag.len == check_tag_arg[i].taglen \ |
|
|
|
&& strncasecmp(ctx->tag.c, check_tag_arg[i].tag, ctx->tag.len) == 0) { \ |
|
|
|
__ok = 1; \ |
|
|
|
ok = 1; \ |
|
|
|
break; \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
STATE = __ok ? STATE_NEXT_ARG : STATE_PLAIN; \ |
|
|
|
STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; \ |
|
|
|
} |
|
|
|
|
|
|
|
#define HANDLE_ARG() {\ |
|
|
|
smart_str_setl(&ctx->arg, start, YYCURSOR - start); \ |
|
|
|
} |
|
|
|
#define HANDLE_VAL(quotes) {\ |
|
|
|
smart_str_copyl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \ |
|
|
|
smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \ |
|
|
|
tag_arg(ctx PLS_CC); \ |
|
|
|
} |
|
|
|
|
|
|
|
@ -284,7 +279,7 @@ static inline void mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size |
|
|
|
YYCURSOR = ctx->buf.c; |
|
|
|
YYLIMIT = ctx->buf.c + ctx->buf.len; |
|
|
|
|
|
|
|
#line 288 |
|
|
|
#line 283 |
|
|
|
|
|
|
|
|
|
|
|
while(1) { |
|
|
|
@ -306,14 +301,14 @@ yy0: |
|
|
|
if(yych != '<') goto yy4; |
|
|
|
yy2: yych = *++YYCURSOR; |
|
|
|
yy3: |
|
|
|
#line 299 |
|
|
|
#line 294 |
|
|
|
{ PASSTHRU(); STATE = STATE_TAG; continue; } |
|
|
|
yy4: yych = *++YYCURSOR; |
|
|
|
yy5: |
|
|
|
#line 300 |
|
|
|
#line 295 |
|
|
|
{ PASSTHRU(); continue; } |
|
|
|
} |
|
|
|
#line 301 |
|
|
|
#line 296 |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
@ -367,11 +362,11 @@ yy6: |
|
|
|
yy8: yych = *++YYCURSOR; |
|
|
|
goto yy13; |
|
|
|
yy9: |
|
|
|
#line 306 |
|
|
|
#line 301 |
|
|
|
{ HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; } |
|
|
|
yy10: yych = *++YYCURSOR; |
|
|
|
yy11: |
|
|
|
#line 307 |
|
|
|
#line 302 |
|
|
|
{ PASSTHRU(); continue; } |
|
|
|
yy12: ++YYCURSOR; |
|
|
|
if(YYLIMIT == YYCURSOR) YYFILL(1); |
|
|
|
@ -379,7 +374,7 @@ yy12: ++YYCURSOR; |
|
|
|
yy13: if(yybm[0+yych] & 128) goto yy12; |
|
|
|
goto yy9; |
|
|
|
} |
|
|
|
#line 308 |
|
|
|
#line 303 |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
@ -413,22 +408,22 @@ yy14: |
|
|
|
} |
|
|
|
yy16: yych = *++YYCURSOR; |
|
|
|
yy17: |
|
|
|
#line 313 |
|
|
|
#line 308 |
|
|
|
{ PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; } |
|
|
|
yy18: yych = *++YYCURSOR; |
|
|
|
yy19: |
|
|
|
#line 314 |
|
|
|
#line 309 |
|
|
|
{ PASSTHRU(); continue; } |
|
|
|
yy20: yych = *++YYCURSOR; |
|
|
|
yy21: |
|
|
|
#line 315 |
|
|
|
#line 310 |
|
|
|
{ YYCURSOR--; STATE = STATE_ARG; continue; } |
|
|
|
yy22: yych = *++YYCURSOR; |
|
|
|
yy23: |
|
|
|
#line 316 |
|
|
|
#line 311 |
|
|
|
{ PASSTHRU(); continue; } |
|
|
|
} |
|
|
|
#line 317 |
|
|
|
#line 312 |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
@ -482,11 +477,11 @@ yy24: |
|
|
|
yy26: yych = *++YYCURSOR; |
|
|
|
goto yy31; |
|
|
|
yy27: |
|
|
|
#line 322 |
|
|
|
#line 317 |
|
|
|
{ PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; } |
|
|
|
yy28: yych = *++YYCURSOR; |
|
|
|
yy29: |
|
|
|
#line 323 |
|
|
|
#line 318 |
|
|
|
{ PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } |
|
|
|
yy30: ++YYCURSOR; |
|
|
|
if(YYLIMIT == YYCURSOR) YYFILL(1); |
|
|
|
@ -494,7 +489,7 @@ yy30: ++YYCURSOR; |
|
|
|
yy31: if(yybm[0+yych] & 128) goto yy30; |
|
|
|
goto yy27; |
|
|
|
} |
|
|
|
#line 324 |
|
|
|
#line 319 |
|
|
|
|
|
|
|
|
|
|
|
case STATE_BEFORE_VAL: |
|
|
|
@ -548,12 +543,12 @@ yy34: yyaccept = 0; |
|
|
|
if(yych == ' ') goto yy41; |
|
|
|
if(yych == '=') goto yy39; |
|
|
|
yy35: |
|
|
|
#line 329 |
|
|
|
#line 324 |
|
|
|
{ YYCURSOR--; STATE = STATE_NEXT_ARG; continue; } |
|
|
|
yy36: yych = *++YYCURSOR; |
|
|
|
goto yy40; |
|
|
|
yy37: |
|
|
|
#line 328 |
|
|
|
#line 323 |
|
|
|
{ PASSTHRU(); STATE = STATE_VAL; continue; } |
|
|
|
yy38: yych = *++YYCURSOR; |
|
|
|
goto yy35; |
|
|
|
@ -572,7 +567,7 @@ yy43: YYCURSOR = YYMARKER; |
|
|
|
case 0: goto yy35; |
|
|
|
} |
|
|
|
} |
|
|
|
#line 330 |
|
|
|
#line 325 |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
@ -635,12 +630,12 @@ yy46: yyaccept = 0; |
|
|
|
yych = *(YYMARKER = ++YYCURSOR); |
|
|
|
if(yych != '>') goto yy54; |
|
|
|
yy47: |
|
|
|
#line 337 |
|
|
|
#line 332 |
|
|
|
{ PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } |
|
|
|
yy48: yych = *++YYCURSOR; |
|
|
|
goto yy52; |
|
|
|
yy49: |
|
|
|
#line 336 |
|
|
|
#line 331 |
|
|
|
{ HANDLE_VAL(0); STATE = STATE_NEXT_ARG; continue; } |
|
|
|
yy50: yych = *++YYCURSOR; |
|
|
|
goto yy47; |
|
|
|
@ -660,10 +655,10 @@ yy55: YYCURSOR = YYMARKER; |
|
|
|
} |
|
|
|
yy56: yych = *++YYCURSOR; |
|
|
|
yy57: |
|
|
|
#line 335 |
|
|
|
#line 330 |
|
|
|
{ HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; } |
|
|
|
} |
|
|
|
#line 338 |
|
|
|
#line 333 |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
@ -731,7 +726,6 @@ PHP_RSHUTDOWN_FUNCTION(url_scanner) |
|
|
|
smart_str_free(&ctx->buf); |
|
|
|
smart_str_free(&ctx->c_tag); |
|
|
|
smart_str_free(&ctx->c_arg); |
|
|
|
smart_str_free(&ctx->val); |
|
|
|
|
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
|