cvs: php4 /ext/standard url_scanner_ex.c url_scanner_ex.re

From: Date: Wed, 20 Sep 2000 02:04:19 +0000
Subject: cvs: php4 /ext/standard url_scanner_ex.c url_scanner_ex.re
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1809@lists.php.net to get a copy of this message
sas Tue Sep 19 19:04:19 2000 EDT Modified files: /php4/ext/standard url_scanner_ex.c url_scanner_ex.re Log: Add support for URLs containing NAME info (for scrolling; #name). Index: php4/ext/standard/url_scanner_ex.c diff -u php4/ext/standard/url_scanner_ex.c:1.8 php4/ext/standard/url_scanner_ex.c:1.9 --- php4/ext/standard/url_scanner_ex.c:1.8 Tue Sep 19 18:15:10 2000 +++ php4/ext/standard/url_scanner_ex.c Tue Sep 19 19:04:19 2000 @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Wed Sep 20 03:07:32 2000 */ +/* Generated by re2c 0.5 on Wed Sep 20 04:00:49 2000 */ #line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re" /* +----------------------------------------------------------------------+ @@ -81,6 +81,13 @@ 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; @@ -104,16 +111,43 @@ static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator) { - if (memchr(url->c, ':', url->len)) return; + register const char *p, *q; + const char *bash = NULL; + const char *sep = "?"; + + q = url->c + url->len; + + for (p = url->c; p < q; p++) { + switch(*p) { + case ':': + return; + case '?': + sep = separator; + break; + case '#': + bash = p; + break; + } + } - if (memchr(url->c, '?', url->len)) - smart_str_appendl(url, separator, 1); - else - smart_str_appendl(url, "?", 1); - - smart_str_append(url, name); - smart_str_appendl(url, "=", 1); - smart_str_append(url, val); + 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); + } } struct php_tag_arg { @@ -250,7 +284,7 @@ YYCURSOR = ctx->buf.c; YYLIMIT = ctx->buf.c + ctx->buf.len; -#line 254 +#line 288 while(1) { @@ -272,14 +306,14 @@ if(yych != '<') goto yy4; yy2: yych = *++YYCURSOR; yy3: -#line 265 +#line 299 { PASSTHRU(); STATE = STATE_TAG; continue; } yy4: yych = *++YYCURSOR; yy5: -#line 266 +#line 300 { PASSTHRU(); continue; } } -#line 267 +#line 301 break; @@ -333,11 +367,11 @@ yy8: yych = *++YYCURSOR; goto yy13; yy9: -#line 272 +#line 306 { HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; } yy10: yych = *++YYCURSOR; yy11: -#line 273 +#line 307 { PASSTHRU(); continue; } yy12: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -345,7 +379,7 @@ yy13: if(yybm[0+yych] & 128) goto yy12; goto yy9; } -#line 274 +#line 308 break; @@ -379,22 +413,22 @@ } yy16: yych = *++YYCURSOR; yy17: -#line 279 +#line 313 { PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; } yy18: yych = *++YYCURSOR; yy19: -#line 280 +#line 314 { PASSTHRU(); continue; } yy20: yych = *++YYCURSOR; yy21: -#line 281 +#line 315 { YYCURSOR--; STATE = STATE_ARG; continue; } yy22: yych = *++YYCURSOR; yy23: -#line 282 +#line 316 { PASSTHRU(); continue; } } -#line 283 +#line 317 break; @@ -448,11 +482,11 @@ yy26: yych = *++YYCURSOR; goto yy31; yy27: -#line 288 +#line 322 { PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; } yy28: yych = *++YYCURSOR; yy29: -#line 289 +#line 323 { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } yy30: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -460,7 +494,7 @@ yy31: if(yybm[0+yych] & 128) goto yy30; goto yy27; } -#line 290 +#line 324 case STATE_BEFORE_VAL: @@ -514,12 +548,12 @@ if(yych == ' ') goto yy41; if(yych == '=') goto yy39; yy35: -#line 295 +#line 329 { YYCURSOR--; STATE = STATE_NEXT_ARG; continue; } yy36: yych = *++YYCURSOR; goto yy40; yy37: -#line 294 +#line 328 { PASSTHRU(); STATE = STATE_VAL; continue; } yy38: yych = *++YYCURSOR; goto yy35; @@ -538,7 +572,7 @@ case 0: goto yy35; } } -#line 296 +#line 330 break; @@ -599,14 +633,14 @@ } yy46: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yybm[0+yych] & 128) goto yy53; + if(yych != '>') goto yy54; yy47: -#line 303 +#line 337 { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; } yy48: yych = *++YYCURSOR; goto yy52; yy49: -#line 302 +#line 336 { HANDLE_VAL(0); STATE = STATE_NEXT_ARG; continue; } yy50: yych = *++YYCURSOR; goto yy47; @@ -626,10 +660,10 @@ } yy56: yych = *++YYCURSOR; yy57: -#line 301 +#line 335 { HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; } } -#line 304 +#line 338 break; } Index: php4/ext/standard/url_scanner_ex.re diff -u php4/ext/standard/url_scanner_ex.re:1.8 php4/ext/standard/url_scanner_ex.re:1.9 --- php4/ext/standard/url_scanner_ex.re:1.8 Tue Sep 19 18:15:10 2000 +++ php4/ext/standard/url_scanner_ex.re Tue Sep 19 19:04:19 2000 @@ -79,6 +79,13 @@ 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; @@ -102,16 +109,43 @@ static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator) { - if (memchr(url->c, ':', url->len)) return; + register const char *p, *q; + const char *bash = NULL; + const char *sep = "?"; + + q = url->c + url->len; + + for (p = url->c; p < q; p++) { + switch(*p) { + case ':': + return; + case '?': + sep = separator; + break; + case '#': + bash = p; + break; + } + } - if (memchr(url->c, '?', url->len)) - smart_str_appendl(url, separator, 1); - else - smart_str_appendl(url, "?", 1); - - smart_str_append(url, name); - smart_str_appendl(url, "=", 1); - smart_str_append(url, val); + 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); + } } struct php_tag_arg { @@ -298,7 +332,7 @@ 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; } */

« previous php.cvs (#1809) next »