summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/url_scanner_ex.c100
-rw-r--r--ext/standard/url_scanner_ex.re54
2 files changed, 111 insertions, 43 deletions
diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c
index 84021b07f4..a06e8f3262 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 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 @@ 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;
@@ -104,16 +111,43 @@ static inline void smart_str_sets(smart_str *dest, const char *src)
static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator)
{
- if (memchr(url->c, ':', url->len)) return;
-
- if (memchr(url->c, '?', url->len))
- smart_str_appendl(url, separator, 1);
- else
- smart_str_appendl(url, "?", 1);
+ 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;
+ }
+ }
- 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 @@ 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 254
+#line 288
while(1) {
@@ -272,14 +306,14 @@ yy0:
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 @@ yy6:
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 @@ yy12: ++YYCURSOR;
yy13: if(yybm[0+yych] & 128) goto yy12;
goto yy9;
}
-#line 274
+#line 308
break;
@@ -379,22 +413,22 @@ yy14:
}
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 @@ yy24:
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 @@ yy30: ++YYCURSOR;
yy31: if(yybm[0+yych] & 128) goto yy30;
goto yy27;
}
-#line 290
+#line 324
case STATE_BEFORE_VAL:
@@ -514,12 +548,12 @@ yy34: yyaccept = 0;
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 @@ yy43: YYCURSOR = YYMARKER;
case 0: goto yy35;
}
}
-#line 296
+#line 330
break;
@@ -599,14 +633,14 @@ yy44:
}
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 @@ yy55: YYCURSOR = YYMARKER;
}
yy56: yych = *++YYCURSOR;
yy57:
-#line 301
+#line 335
{ HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
}
-#line 304
+#line 338
break;
}
diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re
index 790f38ad62..18cc764411 100644
--- a/ext/standard/url_scanner_ex.re
+++ b/ext/standard/url_scanner_ex.re
@@ -79,6 +79,13 @@ 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;
@@ -102,16 +109,43 @@ static inline void smart_str_sets(smart_str *dest, const char *src)
static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator)
{
- if (memchr(url->c, ':', url->len)) return;
-
- if (memchr(url->c, '?', url->len))
- smart_str_appendl(url, separator, 1);
- else
- smart_str_appendl(url, "?", 1);
+ 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;
+ }
+ }
- 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 @@ alpha = [a-zA-Z];
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; }
*/