-/* Generated by re2c 0.5 on Tue Sep 19 21:17:19 2000 */
+/* Generated by re2c 0.5 on Tue Sep 19 22:11:37 2000 */
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
{
dest->len = len;
dest->a = len + 1;
- dest->c = src;
+ dest->c = (char *) src;
}
static inline void smart_str_appends(smart_str *dest, const char *src)
smart_str_append(url, val);
}
-static char *check_tag_arg[] = {
- "a", "href",
- "area", "href",
- "frame", "source",
- "img", "src",
- NULL
+struct php_tag_arg {
+ char *tag;
+ int taglen;
+ char *arg;
+ int arglen;
+};
+
+#define TAG_ARG_ENTRY(a,b) {#a,sizeof(#a)-1,#b,sizeof(#b)-1},
+
+static struct php_tag_arg check_tag_arg[] = {
+ TAG_ARG_ENTRY(a, href)
+ TAG_ARG_ENTRY(area, href)
+ TAG_ARG_ENTRY(frame, source)
+ TAG_ARG_ENTRY(img, src)
+ {0}
};
static inline void tag_arg(url_adapt_state_t *ctx PLS_DC)
char f = 0;
int i;
- for (i = 0; check_tag_arg[i]; i += 2) {
- if (strcasecmp(ctx->tag.c, check_tag_arg[i]) == 0
- && strcasecmp(ctx->arg.c, check_tag_arg[i + 1]) == 0) {
+ for (i = 0; check_tag_arg[i].tag; i++) {
+ if (check_tag_arg[i].arglen == ctx->arg.len
+ && check_tag_arg[i].taglen == ctx->tag.len
+ && strncasecmp(ctx->tag.c, check_tag_arg[i].tag, ctx->tag.len) == 0
+ && strncasecmp(ctx->arg.c, check_tag_arg[i].arg, ctx->arg.len) == 0) {
f = 1;
break;
}
smart_str_appends(&ctx->result, "\"");
}
-#line 151
+#line 162
#define NEXT continue
#define YYFILL(n) goto finish
#define YYCTYPE unsigned char
-#define YYLIMIT (ctx->work.c+ctx->work.len)
+#define YYLIMIT endptr
#define YYCURSOR cursor
#define YYMARKER marker
#define HANDLE_FORM \
- if (strcasecmp(ctx->tag.c, "form") == 0) { \
+ if (ctx->tag.len == 4 && strncasecmp(ctx->tag.c, "form", ctx->tag.len) == 0) { \
smart_str_appends(&ctx->result, "><INPUT TYPE=HIDDEN NAME=\""); \
smart_str_append(&ctx->result, &ctx->name); \
smart_str_appends(&ctx->result, "\" VALUE=\""); \
{
char *para_start, *arg_start, *tag_start;
char *start = NULL;
- char *cursor, *marker;
+ char *cursor;
+ char *marker;
+ char *endptr;
PLS_FETCH();
arg_start = para_start = tag_start = NULL;
smart_str_append(&ctx->work, newstuff);
smart_str_free(&ctx->result);
+ smart_str_setl(&ctx->arg, ctx->c_arg.c, ctx->c_arg.len);
+ smart_str_setl(&ctx->tag, ctx->c_tag.c, ctx->c_tag.len);
+
cursor = ctx->work.c;
+ endptr = ctx->work.c + ctx->work.len;
while (YYCURSOR < YYLIMIT) {
start = YYCURSOR;
if(yybm[0+yych] & 128) goto yy4;
yy2: yych = *++YYCURSOR;
yy3:
-#line 208
+#line 225
{ 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 209
+#line 226
{ COPY_ALL; }
}
-#line 210
+#line 227
break;
if(yych == ' ') goto yy12;
if(yych == '>') goto yy12;
yy10:
-#line 225
+#line 242
{
YYCURSOR--;
GO(STATE_PLAIN);
goto yy10;
yy12: yych = *++YYCURSOR;
yy13:
-#line 215
+#line 232
{
YYCURSOR--;
arg_start = YYCURSOR;
- smart_str_copyl(&ctx->tag, start, YYCURSOR - start);
+ smart_str_setl(&ctx->tag, start, YYCURSOR - start);
#ifdef SCANNER_DEBUG
printf("TAG(%s)\n", ctx->tag.c);
#endif
case 0: goto yy10;
}
}
-#line 231
+#line 248
break;
yych = *YYCURSOR;
yy21: if(yybm[0+yych] & 128) goto yy20;
yy22:
-#line 236
+#line 253
{
GO(STATE_ARG);
NEXT;
}
yy23: yych = *++YYCURSOR;
yy24:
-#line 240
+#line 257
{
HANDLE_FORM;
GO(STATE_PLAIN);
COPY_ALL;
}
}
-#line 246
+#line 263
break;
if(yych <= '<') goto yy30;
if(yych >= '?') goto yy30;
yy27:
-#line 264
+#line 281
{
arg_start = YYCURSOR;
ctx->state--;
yych = *YYCURSOR;
yy36: if(yych == ' ') goto yy35;
yy37:
-#line 252
+#line 269
{
char *p;
for (p = start; isalpha(*p); p++);
- smart_str_copyl(&ctx->arg, start, p - start);
+ smart_str_setl(&ctx->arg, start, p - start);
#ifdef SCANNER_DEBUG
printf("ARG(%s)\n", ctx->arg.c);
#endif
COPY_ALL;
}
}
-#line 269
+#line 286
break;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '^') goto yy51;
yy41:
-#line 298
+#line 315
{
YYCURSOR--;
ctx->state = 2;
goto yy41;
yy44: yych = *++YYCURSOR;
yy45:
-#line 286
+#line 303
{
YYCURSOR--;
para_start = NULL;
if(yych != '>') goto yy47;
yy53: yych = *++YYCURSOR;
yy54:
-#line 274
+#line 291
{
YYCURSOR--;
para_start = NULL;
yy58: yych = *++YYCURSOR;
goto yy54;
}
-#line 303
+#line 320
break;
}
ctx->work.len = n
finish:
+ if (ctx->arg.c)
+ smart_str_copyl(&ctx->c_arg, ctx->arg.c, ctx->arg.len);
+ else
+ smart_str_free(&ctx->c_arg);
+ if (ctx->tag.c)
+ smart_str_copyl(&ctx->c_tag, ctx->tag.c, ctx->tag.len);
+ else
+ smart_str_free(&ctx->c_tag);
+
if (ctx->state >= 2) {
if (para_start) {
PRESERVE(para_start);
smart_str_free(&BG(url_adapt_state).result);
smart_str_free(&BG(url_adapt_state).work);
- smart_str_free(&BG(url_adapt_state).tag);
- smart_str_free(&BG(url_adapt_state).arg);
+ smart_str_free(&BG(url_adapt_state).c_tag);
+ smart_str_free(&BG(url_adapt_state).c_arg);
smart_str_free(&BG(url_adapt_state).para);
return SUCCESS;
{
dest->len = len;
dest->a = len + 1;
- dest->c = src;
+ dest->c = (char *) src;
}
static inline void smart_str_appends(smart_str *dest, const char *src)
smart_str_append(url, val);
}
-static char *check_tag_arg[] = {
- "a", "href",
- "area", "href",
- "frame", "source",
- "img", "src",
- NULL
+struct php_tag_arg {
+ char *tag;
+ int taglen;
+ char *arg;
+ int arglen;
+};
+
+#define TAG_ARG_ENTRY(a,b) {#a,sizeof(#a)-1,#b,sizeof(#b)-1},
+
+static struct php_tag_arg check_tag_arg[] = {
+ TAG_ARG_ENTRY(a, href)
+ TAG_ARG_ENTRY(area, href)
+ TAG_ARG_ENTRY(frame, source)
+ TAG_ARG_ENTRY(img, src)
+ {0}
};
static inline void tag_arg(url_adapt_state_t *ctx PLS_DC)
char f = 0;
int i;
- for (i = 0; check_tag_arg[i]; i += 2) {
- if (strcasecmp(ctx->tag.c, check_tag_arg[i]) == 0
- && strcasecmp(ctx->arg.c, check_tag_arg[i + 1]) == 0) {
+ for (i = 0; check_tag_arg[i].tag; i++) {
+ if (check_tag_arg[i].arglen == ctx->arg.len
+ && check_tag_arg[i].taglen == ctx->tag.len
+ && strncasecmp(ctx->tag.c, check_tag_arg[i].tag, ctx->tag.len) == 0
+ && strncasecmp(ctx->arg.c, check_tag_arg[i].arg, ctx->arg.len) == 0) {
f = 1;
break;
}
#define YYFILL(n) goto finish
#define YYCTYPE unsigned char
-#define YYLIMIT (ctx->work.c+ctx->work.len)
+#define YYLIMIT endptr
#define YYCURSOR cursor
#define YYMARKER marker
#define HANDLE_FORM \
- if (strcasecmp(ctx->tag.c, "form") == 0) { \
+ if (ctx->tag.len == 4 && strncasecmp(ctx->tag.c, "form", ctx->tag.len) == 0) { \
smart_str_appends(&ctx->result, "><INPUT TYPE=HIDDEN NAME=\""); \
smart_str_append(&ctx->result, &ctx->name); \
smart_str_appends(&ctx->result, "\" VALUE=\""); \
{
char *para_start, *arg_start, *tag_start;
char *start = NULL;
- char *cursor, *marker;
+ char *cursor;
+ char *marker;
+ char *endptr;
PLS_FETCH();
arg_start = para_start = tag_start = NULL;
smart_str_append(&ctx->work, newstuff);
smart_str_free(&ctx->result);
+ smart_str_setl(&ctx->arg, ctx->c_arg.c, ctx->c_arg.len);
+ smart_str_setl(&ctx->tag, ctx->c_tag.c, ctx->c_tag.len);
+
cursor = ctx->work.c;
+ endptr = ctx->work.c + ctx->work.len;
while (YYCURSOR < YYLIMIT) {
start = YYCURSOR;
[a-zA-Z]+ [ >] {
YYCURSOR--;
arg_start = YYCURSOR;
- smart_str_copyl(&ctx->tag, start, YYCURSOR - start);
+ smart_str_setl(&ctx->tag, start, YYCURSOR - start);
#ifdef SCANNER_DEBUG
printf("TAG(%s)\n", ctx->tag.c);
#endif
char *p;
for (p = start; isalpha(*p); p++);
- smart_str_copyl(&ctx->arg, start, p - start);
+ smart_str_setl(&ctx->arg, start, p - start);
#ifdef SCANNER_DEBUG
printf("ARG(%s)\n", ctx->arg.c);
#endif
ctx->work.len = n
finish:
+ if (ctx->arg.c)
+ smart_str_copyl(&ctx->c_arg, ctx->arg.c, ctx->arg.len);
+ else
+ smart_str_free(&ctx->c_arg);
+ if (ctx->tag.c)
+ smart_str_copyl(&ctx->c_tag, ctx->tag.c, ctx->tag.len);
+ else
+ smart_str_free(&ctx->c_tag);
+
if (ctx->state >= 2) {
if (para_start) {
PRESERVE(para_start);
smart_str_free(&BG(url_adapt_state).result);
smart_str_free(&BG(url_adapt_state).work);
- smart_str_free(&BG(url_adapt_state).tag);
- smart_str_free(&BG(url_adapt_state).arg);
+ smart_str_free(&BG(url_adapt_state).c_tag);
+ smart_str_free(&BG(url_adapt_state).c_arg);
smart_str_free(&BG(url_adapt_state).para);
return SUCCESS;