From: Sascha Schumann Date: Tue, 19 Sep 2000 18:00:58 +0000 (+0000) Subject: s/DEBUG/SCANNER_DEBUG/. "Convert" one macro to inline function to be more X-Git-Tag: php-4.0.3RC1~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f86b7224ce17e79ad08b618ae487aea088644a0;p=php s/DEBUG/SCANNER_DEBUG/. "Convert" one macro to inline function to be more consistent. Also use continue. --- diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index ebf82926da..98b083ec66 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 Tue Sep 19 19:28:00 2000 */ +/* Generated by re2c 0.5 on Tue Sep 19 20:00:09 2000 */ #line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re" /* +----------------------------------------------------------------------+ @@ -62,7 +62,7 @@ static inline void smart_str_free(smart_str *s) free(s->c); s->c = NULL; } - s->len = 0; + s->a = s->len = 0; } static inline void smart_str_copyl(smart_str *dest, const char *src, size_t len) @@ -83,12 +83,17 @@ 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_appends(smart_str *dest, char *src) +static inline void smart_str_appends(smart_str *dest, const char *src) { smart_str_appendl(dest, src, strlen(src)); } -static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, char *separator) +static inline void smart_str_copys(smart_str *dest, const char *src) +{ + smart_str_copyl(dest, src, strlen(src)); +} + +static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator) { if (strchr(url->c, ':')) return; @@ -131,10 +136,10 @@ static inline void tag_arg(url_adapt_state_t *ctx PLS_DC) smart_str_appends(&ctx->result, "\""); } -#line 131 +#line 139 -#define NEXT goto nextiter +#define NEXT continue #define COPY_ALL \ smart_str_appendl(&ctx->result, start, YYCURSOR - start); \ @@ -169,7 +174,7 @@ enum { static void mainloop(url_adapt_state_t *ctx, smart_str *newstuff) { char *para_start, *arg_start, *tag_start; - char *start; + char *start = NULL; char *cursor, *marker; PLS_FETCH(); @@ -182,7 +187,9 @@ static void mainloop(url_adapt_state_t *ctx, smart_str *newstuff) while (YYCURSOR < YYLIMIT) { start = YYCURSOR; -// printf("state %d:%s'\n", ctx->state, YYCURSOR); +#ifdef SCANNER_DEBUG + printf("state %d:%s'\n", ctx->state, YYCURSOR); +#endif switch (ctx->state) { case STATE_PLAIN: @@ -231,17 +238,17 @@ yy0: if(yybm[0+yych] & 128) goto yy4; yy2: yych = *++YYCURSOR; yy3: -#line 186 +#line 196 { tag_start = YYCURSOR; GO(STATE_TAG); COPY_ALL;} yy4: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; yy5: if(yybm[0+yych] & 128) goto yy4; yy6: -#line 187 +#line 197 { COPY_ALL; } } -#line 188 +#line 198 break; @@ -298,7 +305,7 @@ yy9: yyaccept = 0; if(yych == ' ') goto yy12; if(yych == '>') goto yy12; yy10: -#line 203 +#line 213 { YYCURSOR--; GO(STATE_PLAIN); @@ -309,12 +316,12 @@ yy11: yych = *++YYCURSOR; goto yy10; yy12: yych = *++YYCURSOR; yy13: -#line 193 +#line 203 { YYCURSOR--; arg_start = YYCURSOR; smart_str_copyl(&ctx->tag, start, YYCURSOR - start); -#ifdef DEBUG +#ifdef SCANNER_DEBUG printf("TAG(%s)\n", ctx->tag.c); #endif GO(STATE_NEXT_ARG); @@ -331,7 +338,7 @@ yy16: YYCURSOR = YYMARKER; case 0: goto yy10; } } -#line 209 +#line 219 break; @@ -385,14 +392,14 @@ yy19:yy20: ++YYCURSOR; yych = *YYCURSOR; yy21: if(yybm[0+yych] & 128) goto yy20; yy22: -#line 214 +#line 224 { GO(STATE_ARG); NEXT; } yy23: yych = *++YYCURSOR; yy24: -#line 218 +#line 228 { HANDLE_FORM; GO(STATE_PLAIN); @@ -400,7 +407,7 @@ yy24: COPY_ALL; } } -#line 224 +#line 234 break; @@ -453,7 +460,7 @@ yy25: if(yych <= '<') goto yy30; if(yych >= '?') goto yy30; yy27: -#line 239 +#line 252 { arg_start = YYCURSOR; ctx->state--; @@ -492,10 +499,13 @@ yy35: ++YYCURSOR; yych = *YYCURSOR; yy36: if(yych == ' ') goto yy35; yy37: -#line 230 +#line 240 { - smart_str_copyl(&ctx->arg, start, YYCURSOR - start - 1); -#ifdef DEBUG + char *p; + + for (p = start; isalpha(*p); p++); + smart_str_copyl(&ctx->arg, start, p - start); +#ifdef SCANNER_DEBUG printf("ARG(%s)\n", ctx->arg.c); #endif para_start = YYCURSOR; @@ -503,7 +513,7 @@ yy37: COPY_ALL; } } -#line 244 +#line 257 break; @@ -566,7 +576,7 @@ yy40: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if(yych != '^') goto yy51; yy41: -#line 273 +#line 286 { YYCURSOR--; ctx->state = 2; @@ -580,12 +590,12 @@ yy43: yych = *++YYCURSOR; goto yy41; yy44: yych = *++YYCURSOR; yy45: -#line 261 +#line 274 { YYCURSOR--; para_start = NULL; smart_str_copyl(&ctx->para, start, YYCURSOR - start); -#ifdef DEBUG +#ifdef SCANNER_DEBUG printf("PARA(%s)\n", ctx->para.c); #endif tag_arg(ctx PLS_CC); @@ -621,12 +631,12 @@ yy52: yych = *++YYCURSOR; if(yych != '>') goto yy47; yy53: yych = *++YYCURSOR; yy54: -#line 249 +#line 262 { YYCURSOR--; para_start = NULL; smart_str_copyl(&ctx->para, start + 1, YYCURSOR - start - 2); -#ifdef DEBUG +#ifdef SCANNER_DEBUG printf("PARA(%s)\n", ctx->para.c); #endif tag_arg(ctx PLS_CC); @@ -647,7 +657,7 @@ yy57: if(yybm[0+yych] & 128) goto yy56; yy58: yych = *++YYCURSOR; goto yy54; } -#line 278 +#line 291 break; } @@ -677,15 +687,13 @@ finish: smart_str_free(&ctx->work); } -#ifdef DEBUG +#ifdef SCANNER_DEBUG if (ctx->work.c) { printf("PRESERVING %s'\n", ctx->work.c); } #endif } -#define smart_str_copys(a,b) smart_str_copyl(a,b,strlen(b)) - char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char *value, size_t *newlen) { smart_str str = {0,0}; diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index c51f30c3ae..4859dbe36c 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -60,7 +60,7 @@ static inline void smart_str_free(smart_str *s) free(s->c); s->c = NULL; } - s->len = 0; + s->a = s->len = 0; } static inline void smart_str_copyl(smart_str *dest, const char *src, size_t len) @@ -81,12 +81,17 @@ 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_appends(smart_str *dest, char *src) +static inline void smart_str_appends(smart_str *dest, const char *src) { smart_str_appendl(dest, src, strlen(src)); } -static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, char *separator) +static inline void smart_str_copys(smart_str *dest, const char *src) +{ + smart_str_copyl(dest, src, strlen(src)); +} + +static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator) { if (strchr(url->c, ':')) return; @@ -133,7 +138,7 @@ static inline void tag_arg(url_adapt_state_t *ctx PLS_DC) all = [\000-\377]; */ -#define NEXT goto nextiter +#define NEXT continue #define COPY_ALL \ smart_str_appendl(&ctx->result, start, YYCURSOR - start); \ @@ -168,7 +173,7 @@ enum { static void mainloop(url_adapt_state_t *ctx, smart_str *newstuff) { char *para_start, *arg_start, *tag_start; - char *start; + char *start = NULL; char *cursor, *marker; PLS_FETCH(); @@ -181,7 +186,9 @@ static void mainloop(url_adapt_state_t *ctx, smart_str *newstuff) while (YYCURSOR < YYLIMIT) { start = YYCURSOR; -// printf("state %d:%s'\n", ctx->state, YYCURSOR); +#ifdef SCANNER_DEBUG + printf("state %d:%s'\n", ctx->state, YYCURSOR); +#endif switch (ctx->state) { case STATE_PLAIN: @@ -197,7 +204,7 @@ static void mainloop(url_adapt_state_t *ctx, smart_str *newstuff) YYCURSOR--; arg_start = YYCURSOR; smart_str_copyl(&ctx->tag, start, YYCURSOR - start); -#ifdef DEBUG +#ifdef SCANNER_DEBUG printf("TAG(%s)\n", ctx->tag.c); #endif GO(STATE_NEXT_ARG); @@ -231,8 +238,11 @@ static void mainloop(url_adapt_state_t *ctx, smart_str *newstuff) smart_str_appendl(&ctx->result, " ", 1); /*!re2c [a-zA-Z]+ [ ]* "=" [ ]* { - smart_str_copyl(&ctx->arg, start, YYCURSOR - start - 1); -#ifdef DEBUG + char *p; + + for (p = start; isalpha(*p); p++); + smart_str_copyl(&ctx->arg, start, p - start); +#ifdef SCANNER_DEBUG printf("ARG(%s)\n", ctx->arg.c); #endif para_start = YYCURSOR; @@ -253,7 +263,7 @@ static void mainloop(url_adapt_state_t *ctx, smart_str *newstuff) YYCURSOR--; para_start = NULL; smart_str_copyl(&ctx->para, start + 1, YYCURSOR - start - 2); -#ifdef DEBUG +#ifdef SCANNER_DEBUG printf("PARA(%s)\n", ctx->para.c); #endif tag_arg(ctx PLS_CC); @@ -265,7 +275,7 @@ static void mainloop(url_adapt_state_t *ctx, smart_str *newstuff) YYCURSOR--; para_start = NULL; smart_str_copyl(&ctx->para, start, YYCURSOR - start); -#ifdef DEBUG +#ifdef SCANNER_DEBUG printf("PARA(%s)\n", ctx->para.c); #endif tag_arg(ctx PLS_CC); @@ -307,15 +317,13 @@ finish: smart_str_free(&ctx->work); } -#ifdef DEBUG +#ifdef SCANNER_DEBUG if (ctx->work.c) { printf("PRESERVING %s'\n", ctx->work.c); } #endif } -#define smart_str_copys(a,b) smart_str_copyl(a,b,strlen(b)) - char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char *value, size_t *newlen) { smart_str str = {0,0};