From 449ddbccb14469638cf2933dcfff0a5ae2458da1 Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Mon, 4 Dec 2000 12:27:47 +0000 Subject: [PATCH] Merge from HEAD --- ext/standard/url_scanner_ex.c | 138 ++++++++++++++++++--------------- ext/standard/url_scanner_ex.re | 90 +++++++++++---------- 2 files changed, 124 insertions(+), 104 deletions(-) diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index eaf8249d8a..e2cdda67c7 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Fri Nov 17 17:26:38 2000 */ +/* Generated by re2c 0.5 on Mon Dec 4 13:26:39 2000 */ #line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re" /* +----------------------------------------------------------------------+ @@ -163,18 +163,23 @@ enum { #define YYMARKER q #define STATE ctx->state -#define PASSTHRU() {\ - smart_str_appendl(&ctx->result, start, YYCURSOR - start); \ +#define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR +#define STD_ARGS ctx, start, xp + +static inline void passthru(STD_PARA) +{ + smart_str_appendl(&ctx->result, start, YYCURSOR - start); } -#define HANDLE_FORM() {\ - if (ctx->tag.len == 4 && strncasecmp(ctx->tag.c, "form", 4) == 0) {\ - smart_str_appends(&ctx->result, "result, &ctx->q_name); \ - smart_str_appends(&ctx->result, "\" VALUE=\""); \ - smart_str_append(&ctx->result, &ctx->q_value); \ - smart_str_appends(&ctx->result, "\">"); \ - } \ +static inline void handle_form(STD_PARA) +{ + if (ctx->tag.len == 4 && strncasecmp(ctx->tag.c, "form", 4) == 0) { + smart_str_appends(&ctx->result, "result, &ctx->q_name); + smart_str_appends(&ctx->result, "\" VALUE=\""); + smart_str_append(&ctx->result, &ctx->q_value); + smart_str_appends(&ctx->result, "\">"); + } } /* @@ -184,25 +189,30 @@ enum { * HTML stuff to the result buffer. */ -#define HANDLE_TAG() {\ - int ok = 0; \ - int i; \ - ctx->tag.len = 0; \ - smart_str_appendl(&ctx->tag, start, YYCURSOR - start); \ - for (i = 0; i < ctx->tag.len; i++) \ - ctx->tag.c[i] = tolower(ctx->tag.c[i]); \ - if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS) \ - ok = 1; \ - STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; \ +static inline void handle_tag(STD_PARA) +{ + int ok = 0; + int i; + + ctx->tag.len = 0; + smart_str_appendl(&ctx->tag, start, YYCURSOR - start); + for (i = 0; i < ctx->tag.len; i++) + ctx->tag.c[i] = tolower(ctx->tag.c[i]); + if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS) + ok = 1; + STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; } -#define HANDLE_ARG() {\ - ctx->arg.len = 0; \ - smart_str_appendl(&ctx->arg, start, YYCURSOR - start); \ +static inline void handle_arg(STD_PARA) +{ + ctx->arg.len = 0; + smart_str_appendl(&ctx->arg, start, YYCURSOR - start); } -#define HANDLE_VAL(quotes, type) {\ - smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \ - tag_arg(ctx, type PLS_CC); \ + +static inline void handle_val(STD_PARA, char quotes, char type) +{ + smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); + tag_arg(ctx, type PLS_CC); } #ifdef SCANNER_DEBUG @@ -224,7 +234,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 228 +#line 238 while(1) { @@ -244,14 +254,14 @@ yy0: if(yych != '<') goto yy4; yy2: yych = *++YYCURSOR; yy3: -#line 237 - { PASSTHRU(); STATE = STATE_TAG; continue; } +#line 247 + { passthru(STD_ARGS); STATE = STATE_TAG; continue; } yy4: yych = *++YYCURSOR; yy5: -#line 238 - { PASSTHRU(); continue; } +#line 248 + { passthru(STD_ARGS); continue; } } -#line 239 +#line 249 break; @@ -305,19 +315,19 @@ yy6: yy8: yych = *++YYCURSOR; goto yy13; yy9: -#line 244 - { HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; } +#line 254 + { handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); continue; } yy10: yych = *++YYCURSOR; yy11: -#line 245 - { PASSTHRU(); STATE = STATE_PLAIN; continue; } +#line 255 + { passthru(STD_ARGS); STATE = STATE_PLAIN; continue; } yy12: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy13: if(yybm[0+yych] & 128) goto yy12; goto yy9; } -#line 246 +#line 256 break; @@ -351,22 +361,22 @@ yy14: } yy16: yych = *++YYCURSOR; yy17: -#line 251 - { PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; } +#line 261 + { passthru(STD_ARGS); handle_form(STD_ARGS); STATE = STATE_PLAIN; continue; } yy18: yych = *++YYCURSOR; yy19: -#line 252 - { PASSTHRU(); continue; } +#line 262 + { passthru(STD_ARGS); continue; } yy20: yych = *++YYCURSOR; yy21: -#line 253 +#line 263 { YYCURSOR--; STATE = STATE_ARG; continue; } yy22: yych = *++YYCURSOR; yy23: -#line 254 - { PASSTHRU(); STATE = STATE_PLAIN; continue; } +#line 264 + { passthru(STD_ARGS); STATE = STATE_PLAIN; continue; } } -#line 255 +#line 265 break; @@ -420,19 +430,19 @@ yy24: yy26: yych = *++YYCURSOR; goto yy31; yy27: -#line 260 - { PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; } +#line 270 + { passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; continue; } yy28: yych = *++YYCURSOR; yy29: -#line 261 - { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } +#line 271 + { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; continue; } yy30: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy31: if(yybm[0+yych] & 128) goto yy30; goto yy27; } -#line 262 +#line 272 case STATE_BEFORE_VAL: @@ -486,13 +496,13 @@ yy34: yyaccept = 0; if(yych == ' ') goto yy41; if(yych == '=') goto yy39; yy35: -#line 267 +#line 277 { YYCURSOR--; STATE = STATE_NEXT_ARG; continue; } yy36: yych = *++YYCURSOR; goto yy40; yy37: -#line 266 - { PASSTHRU(); STATE = STATE_VAL; continue; } +#line 276 + { passthru(STD_ARGS); STATE = STATE_VAL; continue; } yy38: yych = *++YYCURSOR; goto yy35; yy39: ++YYCURSOR; @@ -510,7 +520,7 @@ yy43: YYCURSOR = YYMARKER; case 0: goto yy35; } } -#line 268 +#line 278 break; @@ -579,14 +589,14 @@ yy46: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if(yych != '>') goto yy63; yy47: -#line 276 - { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } +#line 286 + { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; continue; } yy48: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); goto yy55; yy49: -#line 275 - { HANDLE_VAL(0, '"'); STATE = STATE_NEXT_ARG; continue; } +#line 285 + { handle_val(STD_ARGS, 0, '"'); STATE = STATE_NEXT_ARG; continue; } yy50: yych = *++YYCURSOR; goto yy53; yy51: yych = *++YYCURSOR; @@ -606,8 +616,8 @@ yy55: if(yybm[0+yych] & 32) goto yy54; yy56: yych = *++YYCURSOR; if(yybm[0+yych] & 16) goto yy52; yy57: -#line 274 - { HANDLE_VAL(1, '\''); STATE = STATE_NEXT_ARG; continue; } +#line 284 + { handle_val(STD_ARGS, 1, '\''); STATE = STATE_NEXT_ARG; continue; } yy58: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -627,10 +637,10 @@ yy63: if(yybm[0+yych] & 128) goto yy62; if(yych >= '>') goto yy60; yy64: yych = *++YYCURSOR; yy65: -#line 273 - { HANDLE_VAL(1, '"'); STATE = STATE_NEXT_ARG; continue; } +#line 283 + { handle_val(STD_ARGS, 1, '"'); STATE = STATE_NEXT_ARG; continue; } } -#line 277 +#line 287 break; } diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 997a29ebc0..40ba4fb0fb 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -161,18 +161,23 @@ enum { #define YYMARKER q #define STATE ctx->state -#define PASSTHRU() {\ - smart_str_appendl(&ctx->result, start, YYCURSOR - start); \ +#define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR +#define STD_ARGS ctx, start, xp + +static inline void passthru(STD_PARA) +{ + smart_str_appendl(&ctx->result, start, YYCURSOR - start); } -#define HANDLE_FORM() {\ - if (ctx->tag.len == 4 && strncasecmp(ctx->tag.c, "form", 4) == 0) {\ - smart_str_appends(&ctx->result, "result, &ctx->q_name); \ - smart_str_appends(&ctx->result, "\" VALUE=\""); \ - smart_str_append(&ctx->result, &ctx->q_value); \ - smart_str_appends(&ctx->result, "\">"); \ - } \ +static inline void handle_form(STD_PARA) +{ + if (ctx->tag.len == 4 && strncasecmp(ctx->tag.c, "form", 4) == 0) { + smart_str_appends(&ctx->result, "result, &ctx->q_name); + smart_str_appends(&ctx->result, "\" VALUE=\""); + smart_str_append(&ctx->result, &ctx->q_value); + smart_str_appends(&ctx->result, "\">"); + } } /* @@ -182,25 +187,30 @@ enum { * HTML stuff to the result buffer. */ -#define HANDLE_TAG() {\ - int ok = 0; \ - int i; \ - ctx->tag.len = 0; \ - smart_str_appendl(&ctx->tag, start, YYCURSOR - start); \ - for (i = 0; i < ctx->tag.len; i++) \ - ctx->tag.c[i] = tolower(ctx->tag.c[i]); \ - if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS) \ - ok = 1; \ - STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; \ +static inline void handle_tag(STD_PARA) +{ + int ok = 0; + int i; + + ctx->tag.len = 0; + smart_str_appendl(&ctx->tag, start, YYCURSOR - start); + for (i = 0; i < ctx->tag.len; i++) + ctx->tag.c[i] = tolower(ctx->tag.c[i]); + if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS) + ok = 1; + STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; } -#define HANDLE_ARG() {\ - ctx->arg.len = 0; \ - smart_str_appendl(&ctx->arg, start, YYCURSOR - start); \ +static inline void handle_arg(STD_PARA) +{ + ctx->arg.len = 0; + smart_str_appendl(&ctx->arg, start, YYCURSOR - start); } -#define HANDLE_VAL(quotes, type) {\ - smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \ - tag_arg(ctx, type PLS_CC); \ + +static inline void handle_val(STD_PARA, char quotes, char type) +{ + smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); + tag_arg(ctx, type PLS_CC); } #ifdef SCANNER_DEBUG @@ -234,46 +244,46 @@ alpha = [a-zA-Z]; case STATE_PLAIN: /*!re2c - [<] { PASSTHRU(); STATE = STATE_TAG; continue; } - (any\[<]) { PASSTHRU(); continue; } + [<] { passthru(STD_ARGS); STATE = STATE_TAG; continue; } + (any\[<]) { passthru(STD_ARGS); continue; } */ break; case STATE_TAG: /*!re2c - alpha+ { HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; } - any { PASSTHRU(); STATE = STATE_PLAIN; continue; } + alpha+ { handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); continue; } + any { passthru(STD_ARGS); STATE = STATE_PLAIN; continue; } */ break; case STATE_NEXT_ARG: /*!re2c - ">" { PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; } - [ \n] { PASSTHRU(); continue; } + ">" { passthru(STD_ARGS); handle_form(STD_ARGS); STATE = STATE_PLAIN; continue; } + [ \n] { passthru(STD_ARGS); continue; } alpha { YYCURSOR--; STATE = STATE_ARG; continue; } - any { PASSTHRU(); STATE = STATE_PLAIN; continue; } + any { passthru(STD_ARGS); STATE = STATE_PLAIN; continue; } */ break; case STATE_ARG: /*!re2c - alpha+ { PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; } - any { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } + alpha+ { passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; continue; } + any { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; continue; } */ case STATE_BEFORE_VAL: /*!re2c - [ ]* "=" [ ]* { PASSTHRU(); STATE = STATE_VAL; continue; } + [ ]* "=" [ ]* { passthru(STD_ARGS); STATE = STATE_VAL; continue; } any { YYCURSOR--; STATE = STATE_NEXT_ARG; continue; } */ break; case STATE_VAL: /*!re2c - ["] (any\[">])* ["] { HANDLE_VAL(1, '"'); STATE = STATE_NEXT_ARG; continue; } - ['] (any\['>])* ['] { HANDLE_VAL(1, '\''); STATE = STATE_NEXT_ARG; continue; } - (any\[ \n>"])+ { HANDLE_VAL(0, '"'); STATE = STATE_NEXT_ARG; continue; } - any { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } + ["] (any\[">])* ["] { handle_val(STD_ARGS, 1, '"'); STATE = STATE_NEXT_ARG; continue; } + ['] (any\['>])* ['] { handle_val(STD_ARGS, 1, '\''); STATE = STATE_NEXT_ARG; continue; } + (any\[ \n>"])+ { handle_val(STD_ARGS, 0, '"'); STATE = STATE_NEXT_ARG; continue; } + any { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; continue; } */ break; } -- 2.40.0