-/* Generated by re2c 0.5 on Thu Oct 19 19:46:51 2000 */
+/* Generated by re2c 0.5 on Thu Oct 26 20:28:43 2000 */
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
smart_str_appendl(dest, bash, q - bash);
}
-static inline void tag_arg(url_adapt_state_ex_t *ctx PLS_DC)
+static inline void tag_arg(url_adapt_state_ex_t *ctx, char quote PLS_DC)
{
char f = 0;
if (strncasecmp(ctx->arg.c, ctx->lookup_data, ctx->arg.len) == 0)
f = 1;
- smart_str_appendc(&ctx->result, '"');
+ smart_str_appendc(&ctx->result, quote);
if (f) {
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator));
} else {
smart_str_append(&ctx->result, &ctx->val);
}
- smart_str_appendc(&ctx->result, '"');
+ smart_str_appendc(&ctx->result, quote);
}
enum {
#define HANDLE_TAG() {\
int ok = 0; \
int i; \
- smart_str_copyl(&ctx->tag, start, YYCURSOR - start); \
+ ctx->tag.len = 0; \
+ smart_str_appendl(&ctx->tag, start, YYCURSOR - start); \
for (i = 0; i < ctx->tag.len; i++) \
ctx->tag.c[i] = tolower(ctx->tag.c[i]); \
- if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, &ctx->lookup_data) == SUCCESS) \
+ if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS) \
ok = 1; \
STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; \
}
#define HANDLE_ARG() {\
- smart_str_copyl(&ctx->arg, start, YYCURSOR - start); \
+ ctx->arg.len = 0; \
+ smart_str_appendl(&ctx->arg, start, YYCURSOR - start); \
}
-#define HANDLE_VAL(quotes) {\
+#define HANDLE_VAL(quotes, type) {\
smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \
- tag_arg(ctx PLS_CC); \
+ tag_arg(ctx, type PLS_CC); \
}
#ifdef SCANNER_DEBUG
YYCURSOR = ctx->buf.c;
YYLIMIT = ctx->buf.c + ctx->buf.len;
-#line 226
+#line 228
while(1) {
if(yych != '<') goto yy4;
yy2: yych = *++YYCURSOR;
yy3:
-#line 235
+#line 237
{ PASSTHRU(); STATE = STATE_TAG; continue; }
yy4: yych = *++YYCURSOR;
yy5:
-#line 236
+#line 238
{ PASSTHRU(); continue; }
}
-#line 237
+#line 239
break;
yy8: yych = *++YYCURSOR;
goto yy13;
yy9:
-#line 242
+#line 244
{ HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; }
yy10: yych = *++YYCURSOR;
yy11:
-#line 243
+#line 245
{ PASSTHRU(); STATE = STATE_PLAIN; continue; }
yy12: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yy13: if(yybm[0+yych] & 128) goto yy12;
goto yy9;
}
-#line 244
+#line 246
break;
}
yy16: yych = *++YYCURSOR;
yy17:
-#line 249
+#line 251
{ PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; }
yy18: yych = *++YYCURSOR;
yy19:
-#line 250
+#line 252
{ PASSTHRU(); continue; }
yy20: yych = *++YYCURSOR;
yy21:
-#line 251
+#line 253
{ YYCURSOR--; STATE = STATE_ARG; continue; }
yy22: yych = *++YYCURSOR;
yy23:
-#line 252
+#line 254
{ PASSTHRU(); continue; }
}
-#line 253
+#line 255
break;
yy26: yych = *++YYCURSOR;
goto yy31;
yy27:
-#line 258
+#line 260
{ PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; }
yy28: yych = *++YYCURSOR;
yy29:
-#line 259
+#line 261
{ PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
yy30: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yy31: if(yybm[0+yych] & 128) goto yy30;
goto yy27;
}
-#line 260
+#line 262
case STATE_BEFORE_VAL:
if(yych == ' ') goto yy41;
if(yych == '=') goto yy39;
yy35:
-#line 265
+#line 267
{ YYCURSOR--; STATE = STATE_NEXT_ARG; continue; }
yy36: yych = *++YYCURSOR;
goto yy40;
yy37:
-#line 264
+#line 266
{ PASSTHRU(); STATE = STATE_VAL; continue; }
yy38: yych = *++YYCURSOR;
goto yy35;
case 0: goto yy35;
}
}
-#line 266
+#line 268
break;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '>') goto yy63;
yy47:
-#line 274
+#line 276
{ PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
yy48: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
goto yy55;
yy49:
-#line 273
- { HANDLE_VAL(0); STATE = STATE_NEXT_ARG; continue; }
+#line 275
+ { HANDLE_VAL(0, '"'); STATE = STATE_NEXT_ARG; continue; }
yy50: yych = *++YYCURSOR;
goto yy53;
yy51: yych = *++YYCURSOR;
yy56: yych = *++YYCURSOR;
if(yybm[0+yych] & 16) goto yy52;
yy57:
-#line 272
- { HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
+#line 274
+ { HANDLE_VAL(1, '\''); STATE = STATE_NEXT_ARG; continue; }
yy58: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yych >= '>') goto yy60;
yy64: yych = *++YYCURSOR;
yy65:
-#line 271
- { HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
+#line 273
+ { HANDLE_VAL(1, '"'); STATE = STATE_NEXT_ARG; continue; }
}
-#line 275
+#line 277
break;
}
ctx->buf.len = rest;
}
+char *url_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen)
+{
+ smart_str surl = {0};
+ smart_str buf = {0};
+ smart_str sname = {0};
+ smart_str sval = {0};
+ PLS_FETCH();
+
+ smart_str_setl(&surl, url, urllen);
+ smart_str_sets(&sname, name);
+ smart_str_sets(&sval, value);
+
+ append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator));
+
+ smart_str_0(&buf);
+ if (newlen) *newlen = buf.len;
+
+ return buf.c;
+}
+
char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char *value, size_t *newlen)
{
char *ret;
mainloop(ctx, src, srclen);
*newlen = ctx->result.len;
-
if (ctx->result.len == 0) {
return strdup("");
}
smart_str_0(&ctx->result);
ret = malloc(ctx->result.len + 1);
memcpy(ret, ctx->result.c, ctx->result.len + 1);
-
ctx->result.len = 0;
return ret;
}
smart_str_appendl(dest, bash, q - bash);
}
-static inline void tag_arg(url_adapt_state_ex_t *ctx PLS_DC)
+static inline void tag_arg(url_adapt_state_ex_t *ctx, char quote PLS_DC)
{
char f = 0;
if (strncasecmp(ctx->arg.c, ctx->lookup_data, ctx->arg.len) == 0)
f = 1;
- smart_str_appendc(&ctx->result, '"');
+ smart_str_appendc(&ctx->result, quote);
if (f) {
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator));
} else {
smart_str_append(&ctx->result, &ctx->val);
}
- smart_str_appendc(&ctx->result, '"');
+ smart_str_appendc(&ctx->result, quote);
}
enum {
#define HANDLE_TAG() {\
int ok = 0; \
int i; \
- smart_str_copyl(&ctx->tag, start, YYCURSOR - start); \
+ ctx->tag.len = 0; \
+ smart_str_appendl(&ctx->tag, start, YYCURSOR - start); \
for (i = 0; i < ctx->tag.len; i++) \
ctx->tag.c[i] = tolower(ctx->tag.c[i]); \
- if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, &ctx->lookup_data) == SUCCESS) \
+ if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS) \
ok = 1; \
STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; \
}
#define HANDLE_ARG() {\
- smart_str_copyl(&ctx->arg, start, YYCURSOR - start); \
+ ctx->arg.len = 0; \
+ smart_str_appendl(&ctx->arg, start, YYCURSOR - start); \
}
-#define HANDLE_VAL(quotes) {\
+#define HANDLE_VAL(quotes, type) {\
smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \
- tag_arg(ctx PLS_CC); \
+ tag_arg(ctx, type PLS_CC); \
}
#ifdef SCANNER_DEBUG
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\[">])* ["] { 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; }
*/
break;
ctx->buf.len = rest;
}
+char *url_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen)
+{
+ smart_str surl = {0};
+ smart_str buf = {0};
+ smart_str sname = {0};
+ smart_str sval = {0};
+ PLS_FETCH();
+
+ smart_str_setl(&surl, url, urllen);
+ smart_str_sets(&sname, name);
+ smart_str_sets(&sval, value);
+
+ append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator));
+
+ smart_str_0(&buf);
+ if (newlen) *newlen = buf.len;
+
+ return buf.c;
+}
+
char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char *value, size_t *newlen)
{
char *ret;
mainloop(ctx, src, srclen);
*newlen = ctx->result.len;
-
if (ctx->result.len == 0) {
return strdup("");
}
smart_str_0(&ctx->result);
ret = malloc(ctx->result.len + 1);
memcpy(ret, ctx->result.c, ctx->result.len + 1);
-
ctx->result.len = 0;
return ret;
}