cvs: php4 /ext/standard url_scanner_ex.c url_scanner_ex.re
| From: | Sascha Schumann | Date: | Tue, 19 Sep 2000 18:00:58 +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-1794@lists.php.net to get a copy of this message | ||
sas Tue Sep 19 11:00:58 2000 EDT
Modified files:
/php4/ext/standard url_scanner_ex.c url_scanner_ex.re
Log:
s/DEBUG/SCANNER_DEBUG/. "Convert" one macro to inline function to be more
consistent. Also use continue.
Index: php4/ext/standard/url_scanner_ex.c
diff -u php4/ext/standard/url_scanner_ex.c:1.2 php4/ext/standard/url_scanner_ex.c:1.3
--- php4/ext/standard/url_scanner_ex.c:1.2 Tue Sep 19 10:53:09 2000
+++ php4/ext/standard/url_scanner_ex.c Tue Sep 19 11:00:58 2000
@@ -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 @@
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,13 +83,18 @@
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;
if (strchr(url->c, '?'))
@@ -131,10 +136,10 @@
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 @@
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 @@
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 @@
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 @@
if(yych == ' ') goto yy12;
if(yych == '>') goto yy12;
yy10:
-#line 203
+#line 213
{
YYCURSOR--;
GO(STATE_PLAIN);
@@ -309,12 +316,12 @@
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 @@
case 0: goto yy10;
}
}
-#line 209
+#line 219
break;
@@ -385,14 +392,14 @@
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 @@
COPY_ALL;
}
}
-#line 224
+#line 234
break;
@@ -453,7 +460,7 @@
if(yych <= '<') goto yy30;
if(yych >= '?') goto yy30;
yy27:
-#line 239
+#line 252
{
arg_start = YYCURSOR;
ctx->state--;
@@ -492,10 +499,13 @@
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 @@
COPY_ALL;
}
}
-#line 244
+#line 257
break;
@@ -566,7 +576,7 @@
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '^') goto yy51;
yy41:
-#line 273
+#line 286
{
YYCURSOR--;
ctx->state = 2;
@@ -580,12 +590,12 @@
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 @@
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 @@
yy58: yych = *++YYCURSOR;
goto yy54;
}
-#line 278
+#line 291
break;
}
@@ -677,14 +687,12 @@
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)
{
Index: php4/ext/standard/url_scanner_ex.re
diff -u php4/ext/standard/url_scanner_ex.re:1.2 php4/ext/standard/url_scanner_ex.re:1.3
--- php4/ext/standard/url_scanner_ex.re:1.2 Tue Sep 19 10:53:09 2000
+++ php4/ext/standard/url_scanner_ex.re Tue Sep 19 11:00:58 2000
@@ -60,7 +60,7 @@
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,13 +81,18 @@
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;
if (strchr(url->c, '?'))
@@ -133,7 +138,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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,14 +317,12 @@
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)
{