-/* Generated by re2c 0.5 on Wed Sep 20 04:00:49 2000 */
+/* Generated by re2c 0.5 on Wed Sep 20 10:04:05 2000 */
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
newlen = dest->len + src->len;
if (newlen >= dest->a) {
- dest->c = realloc(dest->c, newlen + 101);
- dest->a = newlen + 100;
+ dest->c = realloc(dest->c, newlen + 129);
+ dest->a = newlen + 128;
}
memcpy(dest->c + dest->len, src->c, src->len);
dest->c[dest->len = newlen] = '\0';
}
+static inline void smart_str_appendc(smart_str *dest, char c)
+{
+ size_t newlen;
+
+ newlen = dest->len + 1;
+ if (newlen >= dest->a) {
+ dest->c = realloc(dest->c, newlen + 129);
+ dest->a = newlen + 128;
+ }
+ dest->c[dest->len++] = c;
+ dest->c[dest->len] = '\0';
+}
+
static inline void smart_str_free(smart_str *s)
{
if (s->c) {
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;
#define smart_str_appends(dest, src) smart_str_appendl(dest, src, sizeof(src)-1)
-#if 0
-static inline void smart_str_copys(smart_str *dest, const char *src)
-{
- smart_str_copyl(dest, src, strlen(src));
-}
-#endif
-
static inline void smart_str_sets(smart_str *dest, const char *src)
{
smart_str_setl(dest, src, strlen(src));
}
-static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator)
+static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *name, smart_str *val, const char *separator)
{
register const char *p, *q;
const char *bash = NULL;
- const char *sep = "?";
+ char sep = "?";
q = url->c + url->len;
for (p = url->c; p < q; p++) {
switch(*p) {
case ':':
+ smart_str_append(dest, url);
return;
case '?':
- sep = separator;
+ sep = *separator;
break;
case '#':
bash = p;
}
}
- 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);
- }
+ if (bash)
+ smart_str_appendl(dest, url->c, bash - url->c);
+ else
+ smart_str_append(dest, url);
+
+ smart_str_appendc(dest, sep);
+ smart_str_append(dest, name);
+ smart_str_appendc(dest, '=');
+ smart_str_append(dest, val);
+
+ if (bash)
+ smart_str_appendl(dest, bash, q - bash);
}
struct php_tag_arg {
smart_str_appends(&ctx->result, "\"");
if (f) {
- attach_url(&ctx->val, &ctx->q_name, &ctx->q_value, PG(arg_separator));
+ 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_append(&ctx->result, &ctx->val);
smart_str_appends(&ctx->result, "\"");
}
*/
#define HANDLE_TAG() {\
- int __ok = 0; \
+ int ok = 0; \
int i; \
smart_str_setl(&ctx->tag, start, YYCURSOR - start); \
for (i = 0; check_tag_arg[i].tag; i++) { \
if (ctx->tag.len == check_tag_arg[i].taglen \
&& strncasecmp(ctx->tag.c, check_tag_arg[i].tag, ctx->tag.len) == 0) { \
- __ok = 1; \
+ ok = 1; \
break; \
} \
} \
- STATE = __ok ? STATE_NEXT_ARG : STATE_PLAIN; \
+ STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; \
}
#define HANDLE_ARG() {\
smart_str_setl(&ctx->arg, start, YYCURSOR - start); \
}
#define HANDLE_VAL(quotes) {\
- smart_str_copyl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \
+ smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \
tag_arg(ctx PLS_CC); \
}
YYCURSOR = ctx->buf.c;
YYLIMIT = ctx->buf.c + ctx->buf.len;
-#line 288
+#line 283
while(1) {
if(yych != '<') goto yy4;
yy2: yych = *++YYCURSOR;
yy3:
-#line 299
+#line 294
{ PASSTHRU(); STATE = STATE_TAG; continue; }
yy4: yych = *++YYCURSOR;
yy5:
-#line 300
+#line 295
{ PASSTHRU(); continue; }
}
-#line 301
+#line 296
break;
yy8: yych = *++YYCURSOR;
goto yy13;
yy9:
-#line 306
+#line 301
{ HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; }
yy10: yych = *++YYCURSOR;
yy11:
-#line 307
+#line 302
{ PASSTHRU(); continue; }
yy12: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yy13: if(yybm[0+yych] & 128) goto yy12;
goto yy9;
}
-#line 308
+#line 303
break;
}
yy16: yych = *++YYCURSOR;
yy17:
-#line 313
+#line 308
{ PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; }
yy18: yych = *++YYCURSOR;
yy19:
-#line 314
+#line 309
{ PASSTHRU(); continue; }
yy20: yych = *++YYCURSOR;
yy21:
-#line 315
+#line 310
{ YYCURSOR--; STATE = STATE_ARG; continue; }
yy22: yych = *++YYCURSOR;
yy23:
-#line 316
+#line 311
{ PASSTHRU(); continue; }
}
-#line 317
+#line 312
break;
yy26: yych = *++YYCURSOR;
goto yy31;
yy27:
-#line 322
+#line 317
{ PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; }
yy28: yych = *++YYCURSOR;
yy29:
-#line 323
+#line 318
{ PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
yy30: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yy31: if(yybm[0+yych] & 128) goto yy30;
goto yy27;
}
-#line 324
+#line 319
case STATE_BEFORE_VAL:
if(yych == ' ') goto yy41;
if(yych == '=') goto yy39;
yy35:
-#line 329
+#line 324
{ YYCURSOR--; STATE = STATE_NEXT_ARG; continue; }
yy36: yych = *++YYCURSOR;
goto yy40;
yy37:
-#line 328
+#line 323
{ PASSTHRU(); STATE = STATE_VAL; continue; }
yy38: yych = *++YYCURSOR;
goto yy35;
case 0: goto yy35;
}
}
-#line 330
+#line 325
break;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '>') goto yy54;
yy47:
-#line 337
+#line 332
{ PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
yy48: yych = *++YYCURSOR;
goto yy52;
yy49:
-#line 336
+#line 331
{ HANDLE_VAL(0); STATE = STATE_NEXT_ARG; continue; }
yy50: yych = *++YYCURSOR;
goto yy47;
}
yy56: yych = *++YYCURSOR;
yy57:
-#line 335
+#line 330
{ HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
}
-#line 338
+#line 333
break;
}
smart_str_free(&ctx->buf);
smart_str_free(&ctx->c_tag);
smart_str_free(&ctx->c_arg);
- smart_str_free(&ctx->val);
return SUCCESS;
}
newlen = dest->len + src->len;
if (newlen >= dest->a) {
- dest->c = realloc(dest->c, newlen + 101);
- dest->a = newlen + 100;
+ dest->c = realloc(dest->c, newlen + 129);
+ dest->a = newlen + 128;
}
memcpy(dest->c + dest->len, src->c, src->len);
dest->c[dest->len = newlen] = '\0';
}
+static inline void smart_str_appendc(smart_str *dest, char c)
+{
+ size_t newlen;
+
+ newlen = dest->len + 1;
+ if (newlen >= dest->a) {
+ dest->c = realloc(dest->c, newlen + 129);
+ dest->a = newlen + 128;
+ }
+ dest->c[dest->len++] = c;
+ dest->c[dest->len] = '\0';
+}
+
static inline void smart_str_free(smart_str *s)
{
if (s->c) {
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;
#define smart_str_appends(dest, src) smart_str_appendl(dest, src, sizeof(src)-1)
-#if 0
-static inline void smart_str_copys(smart_str *dest, const char *src)
-{
- smart_str_copyl(dest, src, strlen(src));
-}
-#endif
-
static inline void smart_str_sets(smart_str *dest, const char *src)
{
smart_str_setl(dest, src, strlen(src));
}
-static inline void attach_url(smart_str *url, smart_str *name, smart_str *val, const char *separator)
+static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *name, smart_str *val, const char *separator)
{
register const char *p, *q;
const char *bash = NULL;
- const char *sep = "?";
+ char sep = "?";
q = url->c + url->len;
for (p = url->c; p < q; p++) {
switch(*p) {
case ':':
+ smart_str_append(dest, url);
return;
case '?':
- sep = separator;
+ sep = *separator;
break;
case '#':
bash = p;
}
}
- 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);
- }
+ if (bash)
+ smart_str_appendl(dest, url->c, bash - url->c);
+ else
+ smart_str_append(dest, url);
+
+ smart_str_appendc(dest, sep);
+ smart_str_append(dest, name);
+ smart_str_appendc(dest, '=');
+ smart_str_append(dest, val);
+
+ if (bash)
+ smart_str_appendl(dest, bash, q - bash);
}
struct php_tag_arg {
smart_str_appends(&ctx->result, "\"");
if (f) {
- attach_url(&ctx->val, &ctx->q_name, &ctx->q_value, PG(arg_separator));
+ 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_append(&ctx->result, &ctx->val);
smart_str_appends(&ctx->result, "\"");
}
*/
#define HANDLE_TAG() {\
- int __ok = 0; \
+ int ok = 0; \
int i; \
smart_str_setl(&ctx->tag, start, YYCURSOR - start); \
for (i = 0; check_tag_arg[i].tag; i++) { \
if (ctx->tag.len == check_tag_arg[i].taglen \
&& strncasecmp(ctx->tag.c, check_tag_arg[i].tag, ctx->tag.len) == 0) { \
- __ok = 1; \
+ ok = 1; \
break; \
} \
} \
- STATE = __ok ? STATE_NEXT_ARG : STATE_PLAIN; \
+ STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; \
}
#define HANDLE_ARG() {\
smart_str_setl(&ctx->arg, start, YYCURSOR - start); \
}
#define HANDLE_VAL(quotes) {\
- smart_str_copyl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \
+ smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2); \
tag_arg(ctx PLS_CC); \
}
smart_str_free(&ctx->buf);
smart_str_free(&ctx->c_tag);
smart_str_free(&ctx->c_arg);
- smart_str_free(&ctx->val);
return SUCCESS;
}