Browse Source

Cleanup SCANNER_DEBUG and don't NUL terminate work buffer

PHP-4.0.5
Sascha Schumann 26 years ago
parent
commit
854c0622f0
  1. 63
      ext/standard/url_scanner_ex.c
  2. 17
      ext/standard/url_scanner_ex.re

63
ext/standard/url_scanner_ex.c

@ -1,4 +1,4 @@
/* Generated by re2c 0.5 on Wed Sep 20 10:36:10 2000 */
/* Generated by re2c 0.5 on Wed Sep 20 10:58:28 2000 */
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
@ -246,6 +246,12 @@ enum {
tag_arg(ctx PLS_CC); \
}
#ifdef SCANNER_DEBUG
#define scdebug(x) printf x
#else
#define scdebug(x)
#endif
static inline void mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen)
{
char *end, *q;
@ -259,14 +265,12 @@ 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 263
#line 269
while(1) {
start = YYCURSOR;
#ifdef SCANNER_DEBUG
printf("state %d at %s\n", STATE, YYCURSOR);
#endif
scdebug(("state %d at %s\n", STATE, YYCURSOR));
switch(STATE) {
case STATE_PLAIN:
@ -281,14 +285,14 @@ yy0:
if(yych != '<') goto yy4;
yy2: yych = *++YYCURSOR;
yy3:
#line 274
#line 278
{ PASSTHRU(); STATE = STATE_TAG; continue; }
yy4: yych = *++YYCURSOR;
yy5:
#line 275
#line 279
{ PASSTHRU(); continue; }
}
#line 276
#line 280
break;
@ -342,11 +346,11 @@ yy6:
yy8: yych = *++YYCURSOR;
goto yy13;
yy9:
#line 281
#line 285
{ HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; }
yy10: yych = *++YYCURSOR;
yy11:
#line 282
#line 286
{ PASSTHRU(); continue; }
yy12: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
@ -354,7 +358,7 @@ yy12: ++YYCURSOR;
yy13: if(yybm[0+yych] & 128) goto yy12;
goto yy9;
}
#line 283
#line 287
break;
@ -388,22 +392,22 @@ yy14:
}
yy16: yych = *++YYCURSOR;
yy17:
#line 288
#line 292
{ PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; }
yy18: yych = *++YYCURSOR;
yy19:
#line 289
#line 293
{ PASSTHRU(); continue; }
yy20: yych = *++YYCURSOR;
yy21:
#line 290
#line 294
{ YYCURSOR--; STATE = STATE_ARG; continue; }
yy22: yych = *++YYCURSOR;
yy23:
#line 291
#line 295
{ PASSTHRU(); continue; }
}
#line 292
#line 296
break;
@ -457,11 +461,11 @@ yy24:
yy26: yych = *++YYCURSOR;
goto yy31;
yy27:
#line 297
#line 301
{ PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; }
yy28: yych = *++YYCURSOR;
yy29:
#line 298
#line 302
{ PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
yy30: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
@ -469,7 +473,7 @@ yy30: ++YYCURSOR;
yy31: if(yybm[0+yych] & 128) goto yy30;
goto yy27;
}
#line 299
#line 303
case STATE_BEFORE_VAL:
@ -523,12 +527,12 @@ yy34: yyaccept = 0;
if(yych == ' ') goto yy41;
if(yych == '=') goto yy39;
yy35:
#line 304
#line 308
{ YYCURSOR--; STATE = STATE_NEXT_ARG; continue; }
yy36: yych = *++YYCURSOR;
goto yy40;
yy37:
#line 303
#line 307
{ PASSTHRU(); STATE = STATE_VAL; continue; }
yy38: yych = *++YYCURSOR;
goto yy35;
@ -547,7 +551,7 @@ yy43: YYCURSOR = YYMARKER;
case 0: goto yy35;
}
}
#line 305
#line 309
break;
@ -610,12 +614,12 @@ yy46: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '>') goto yy54;
yy47:
#line 312
#line 316
{ PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
yy48: yych = *++YYCURSOR;
goto yy52;
yy49:
#line 311
#line 315
{ HANDLE_VAL(0); STATE = STATE_NEXT_ARG; continue; }
yy50: yych = *++YYCURSOR;
goto yy47;
@ -635,24 +639,21 @@ yy55: YYCURSOR = YYMARKER;
}
yy56: yych = *++YYCURSOR;
yy57:
#line 310
#line 314
{ HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
}
#line 313
#line 317
break;
}
}
stop:
#ifdef SCANNER_DEBUG
printf("stopped in state %d at pos %d (%d:%c)\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR);
#endif
scdebug(("stopped in state %d at pos %d (%d:%c)\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR));
rest = YYLIMIT - start;
memmove(ctx->buf.c, start, rest);
ctx->buf.c[rest] = '\0';
if (rest) memmove(ctx->buf.c, start, rest);
ctx->buf.len = rest;
}

17
ext/standard/url_scanner_ex.re

@ -244,6 +244,12 @@ enum {
tag_arg(ctx PLS_CC); \
}
#ifdef SCANNER_DEBUG
#define scdebug(x) printf x
#else
#define scdebug(x)
#endif
static inline void mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen)
{
char *end, *q;
@ -264,9 +270,7 @@ alpha = [a-zA-Z];
while(1) {
start = YYCURSOR;
#ifdef SCANNER_DEBUG
printf("state %d at %s\n", STATE, YYCURSOR);
#endif
scdebug(("state %d at %s\n", STATE, YYCURSOR));
switch(STATE) {
case STATE_PLAIN:
@ -316,14 +320,11 @@ alpha = [a-zA-Z];
}
stop:
#ifdef SCANNER_DEBUG
printf("stopped in state %d at pos %d (%d:%c)\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR);
#endif
scdebug(("stopped in state %d at pos %d (%d:%c)\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR));
rest = YYLIMIT - start;
memmove(ctx->buf.c, start, rest);
ctx->buf.c[rest] = '\0';
if (rest) memmove(ctx->buf.c, start, rest);
ctx->buf.len = rest;
}

Loading…
Cancel
Save