Date: 10/16/00
- Next message: Sascha Schumann: "[PHP-DEV] Re: [PHP-CVS] cvs: php4 / php.ini-dist /ext/standard basic_functions.c url_scanner_ex.c url_scanner_ex.h url_scanner_ex.re"
- Previous message: pointer <email protected>: "[PHP-DEV] PHP 4.0 Bug #7263: php 4.0.3pl1 compile problem with url_scanner_ex.lo"
- Next in thread: Sascha Schumann: "[PHP-DEV] Re: [PHP-CVS] cvs: php4 / php.ini-dist /ext/standard basic_functions.c url_scanner_ex.c url_scanner_ex.h url_scanner_ex.re"
- Reply: Sascha Schumann: "[PHP-DEV] Re: [PHP-CVS] cvs: php4 / php.ini-dist /ext/standard basic_functions.c url_scanner_ex.c url_scanner_ex.h url_scanner_ex.re"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 16 Oct 2000, Sascha Schumann wrote:
>-#line 201
>+#line 226
Are these #line directives really needed? Since they cause
trouble when using e.g. Sun CC. Isn't there some modifier
for re2c which disables these? At least the distributions
should have these stripped off.
--Jani
>
> while(1) {
>@@ -217,14 +242,14 @@
> if(yych != '<') goto yy4;
> yy2: yych = *++YYCURSOR;
> yy3:
>-#line 210
>+#line 235
> { PASSTHRU(); STATE = STATE_TAG; continue; }
> yy4: yych = *++YYCURSOR;
> yy5:
>-#line 211
>+#line 236
> { PASSTHRU(); continue; }
> }
>-#line 212
>+#line 237
>
> break;
>
>@@ -278,11 +303,11 @@
> yy8: yych = *++YYCURSOR;
> goto yy13;
> yy9:
>-#line 217
>+#line 242
> { HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; }
> yy10: yych = *++YYCURSOR;
> yy11:
>-#line 218
>+#line 243
> { PASSTHRU(); STATE = STATE_PLAIN; continue; }
> yy12: ++YYCURSOR;
> if(YYLIMIT == YYCURSOR) YYFILL(1);
>@@ -290,7 +315,7 @@
> yy13: if(yybm[0+yych] & 128) goto yy12;
> goto yy9;
> }
>-#line 219
>+#line 244
>
> break;
>
>@@ -324,22 +349,22 @@
> }
> yy16: yych = *++YYCURSOR;
> yy17:
>-#line 224
>+#line 249
> { PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; }
> yy18: yych = *++YYCURSOR;
> yy19:
>-#line 225
>+#line 250
> { PASSTHRU(); continue; }
> yy20: yych = *++YYCURSOR;
> yy21:
>-#line 226
>+#line 251
> { YYCURSOR--; STATE = STATE_ARG; continue; }
> yy22: yych = *++YYCURSOR;
> yy23:
>-#line 227
>+#line 252
> { PASSTHRU(); continue; }
> }
>-#line 228
>+#line 253
>
> break;
>
>@@ -393,11 +418,11 @@
> yy26: yych = *++YYCURSOR;
> goto yy31;
> yy27:
>-#line 233
>+#line 258
> { PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; }
> yy28: yych = *++YYCURSOR;
> yy29:
>-#line 234
>+#line 259
> { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
> yy30: ++YYCURSOR;
> if(YYLIMIT == YYCURSOR) YYFILL(1);
>@@ -405,7 +430,7 @@
> yy31: if(yybm[0+yych] & 128) goto yy30;
> goto yy27;
> }
>-#line 235
>+#line 260
>
>
> case STATE_BEFORE_VAL:
>@@ -459,12 +484,12 @@
> if(yych == ' ') goto yy41;
> if(yych == '=') goto yy39;
> yy35:
>-#line 240
>+#line 265
> { YYCURSOR--; STATE = STATE_NEXT_ARG; continue; }
> yy36: yych = *++YYCURSOR;
> goto yy40;
> yy37:
>-#line 239
>+#line 264
> { PASSTHRU(); STATE = STATE_VAL; continue; }
> yy38: yych = *++YYCURSOR;
> goto yy35;
>@@ -483,7 +508,7 @@
> case 0: goto yy35;
> }
> }
>-#line 241
>+#line 266
>
> break;
>
>@@ -552,13 +577,13 @@
> yych = *(YYMARKER = ++YYCURSOR);
> if(yych != '>') goto yy63;
> yy47:
>-#line 249
>+#line 274
> { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
> yy48: yyaccept = 1;
> yych = *(YYMARKER = ++YYCURSOR);
> goto yy55;
> yy49:
>-#line 248
>+#line 273
> { HANDLE_VAL(0); STATE = STATE_NEXT_ARG; continue; }
> yy50: yych = *++YYCURSOR;
> goto yy53;
>@@ -579,7 +604,7 @@
> yy56: yych = *++YYCURSOR;
> if(yybm[0+yych] & 16) goto yy52;
> yy57:
>-#line 247
>+#line 272
> { HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
> yy58: ++YYCURSOR;
> if(YYLIMIT == YYCURSOR) YYFILL(1);
>@@ -600,10 +625,10 @@
> if(yych >= '>') goto yy60;
> yy64: yych = *++YYCURSOR;
> yy65:
>-#line 246
>+#line 271
> { HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
> }
>-#line 250
>+#line 275
>
> break;
> }
>@@ -650,7 +675,7 @@
>
> ctx = &BG(url_adapt_state_ex);
>
>- memset(ctx, 0, sizeof(*ctx));
>+ memset(ctx, 0, ((size_t) &((url_adapt_state_ex_t *)0)->tags));
>
> return SUCCESS;
> }
>@@ -667,6 +692,20 @@
> smart_str_free(&ctx->tag);
> smart_str_free(&ctx->arg);
>
>+ return SUCCESS;
>+}
>+
>+PHP_MINIT_FUNCTION(url_scanner)
>+{
>+ REGISTER_INI_ENTRIES();
>+ return SUCCESS;
>+}
>+
>+PHP_MSHUTDOWN_FUNCTION(url_scanner)
>+{
>+ UNREGISTER_INI_ENTRIES();
>+ zend_hash_destroy(BG(url_adapt_state_ex).tags);
>+ free(BG(url_adapt_state_ex).tags);
> return SUCCESS;
> }
>
>Index: php4/ext/standard/url_scanner_ex.h
>diff -u php4/ext/standard/url_scanner_ex.h:1.7 php4/ext/standard/url_scanner_ex.h:1.8
>--- php4/ext/standard/url_scanner_ex.h:1.7 Wed Oct 11 17:48:12 2000
>+++ php4/ext/standard/url_scanner_ex.h Mon Oct 16 10:25:36 2000
>@@ -19,6 +19,8 @@
> #ifndef URL_SCANNER_EX_H
> #define URL_SCANNER_EX_H
>
>+PHP_MINIT_FUNCTION(url_scanner_ex);
>+PHP_MSHUTDOWN_FUNCTION(url_scanner_ex);
> PHP_RSHUTDOWN_FUNCTION(url_scanner_ex);
> PHP_RINIT_FUNCTION(url_scanner_ex);
>
>@@ -40,7 +42,11 @@
> smart_str q_name;
> smart_str q_value;
>
>+ char *lookup_data;
> int state;
>+
>+ /* Everything above is zeroed in RINIT */
>+ HashTable *tags;
> } url_adapt_state_ex_t;
>
> #endif
>Index: php4/ext/standard/url_scanner_ex.re
>diff -u php4/ext/standard/url_scanner_ex.re:1.16 php4/ext/standard/url_scanner_ex.re:1.17
>--- php4/ext/standard/url_scanner_ex.re:1.16 Wed Oct 4 11:06:20 2000
>+++ php4/ext/standard/url_scanner_ex.re Mon Oct 16 10:25:36 2000
>@@ -28,6 +28,7 @@
> #include <stdlib.h>
> #include <string.h>
>
>+#include "php_ini.h"
> #include "php_globals.h"
> #define STATE_TAG SOME_OTHER_STATE_TAG
> #include "basic_functions.h"
>@@ -38,6 +39,54 @@
>
> #include "php_smart_str.h"
>
>+static PHP_INI_MH(OnUpdateTags)
>+{
>+ url_adapt_state_ex_t *ctx;
>+ char *key;
>+ char *lasts;
>+ char *tmp;
>+ BLS_FETCH();
>+
>+ ctx = &BG(url_adapt_state_ex);
>+
>+ tmp = estrndup(new_value, new_value_length);
>+
>+ if (ctx->tags)
>+ zend_hash_destroy(ctx->tags);
>+ else
>+ ctx->tags = malloc(sizeof(HashTable));
>+
>+ zend_hash_init(ctx->tags, 0, NULL, NULL, 1);
>+
>+ for (key = php_strtok_r(tmp, ",", &lasts);
>+ key;
>+ key = php_strtok_r(NULL, ",", &lasts)) {
>+ char *val;
>+
>+ val = strchr(key, '=');
>+ if (val) {
>+ char *q;
>+ int keylen;
>+
>+ *val++ = '\0';
>+ for (q = key; *q; q++)
>+ *q = tolower(*q);
>+ keylen = q - key;
>+ /* key is stored withOUT NUL
>+ val is stored WITH NUL */
>+ zend_hash_add(ctx->tags, key, keylen, val, strlen(val)+1, NULL);
>+ }
>+ }
>+
>+ efree(tmp);
>+
>+ return SUCCESS;
>+}
>+
>+PHP_INI_BEGIN()
>+ STD_PHP_INI_ENTRY("url_rewriter.tags", "a=href,area=href,frame=src,form=fakeentry", PHP_INI_ALL, OnUpdateTags, url_adapt_state_ex, php_basic_globals, basic_globals)
>+PHP_INI_END()
>+
> 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;
>@@ -60,6 +109,12 @@
> }
> }
>
>+ /* Don't modify URLs of the format "#mark" */
>+ if (bash - url->c == 0) {
>+ smart_str_append(dest, url);
>+ return;
>+ }
>+
> if (bash)
> smart_str_appendl(dest, url->c, bash - url->c);
> else
>@@ -74,47 +129,20 @@
> smart_str_appendl(dest, bash, q - bash);
> }
>
>-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, src)
>- TAG_ARG_ENTRY(img, src)
>- TAG_ARG_ENTRY(input, src)
>- TAG_ARG_ENTRY(form, fake_entry_for_passing_on_form_tag)
>- {0}
>-};
>-
> static inline void tag_arg(url_adapt_state_ex_t *ctx PLS_DC)
> {
> char f = 0;
>- int i;
>
>- 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;
>- }
>- }
>+ if (strncasecmp(ctx->arg.c, ctx->lookup_data, ctx->arg.len) == 0)
>+ f = 1;
>
>- smart_str_appends(&ctx->result, "\"");
>+ smart_str_appendc(&ctx->result, '"');
> 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_appends(&ctx->result, "\"");
>+ smart_str_appendc(&ctx->result, '"');
> }
>
> enum {
>@@ -158,13 +186,10 @@
> int ok = 0; \
> int i; \
> smart_str_copyl(&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; \
>- break; \
>- } \
>- } \
>+ 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) \
>+ ok = 1; \
> STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; \
> }
>
>@@ -293,7 +318,7 @@
>
> ctx = &BG(url_adapt_state_ex);
>
>- memset(ctx, 0, sizeof(*ctx));
>+ memset(ctx, 0, ((size_t) &((url_adapt_state_ex_t *)0)->tags));
>
> return SUCCESS;
> }
>@@ -310,6 +335,20 @@
> smart_str_free(&ctx->tag);
> smart_str_free(&ctx->arg);
>
>+ return SUCCESS;
>+}
>+
>+PHP_MINIT_FUNCTION(url_scanner)
>+{
>+ REGISTER_INI_ENTRIES();
>+ return SUCCESS;
>+}
>+
>+PHP_MSHUTDOWN_FUNCTION(url_scanner)
>+{
>+ UNREGISTER_INI_ENTRIES();
>+ zend_hash_destroy(BG(url_adapt_state_ex).tags);
>+ free(BG(url_adapt_state_ex).tags);
> return SUCCESS;
> }
>
>
>
>
>
-- Joo.-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Sascha Schumann: "[PHP-DEV] Re: [PHP-CVS] cvs: php4 / php.ini-dist /ext/standard basic_functions.c url_scanner_ex.c url_scanner_ex.h url_scanner_ex.re"
- Previous message: pointer <email protected>: "[PHP-DEV] PHP 4.0 Bug #7263: php 4.0.3pl1 compile problem with url_scanner_ex.lo"
- Next in thread: Sascha Schumann: "[PHP-DEV] Re: [PHP-CVS] cvs: php4 / php.ini-dist /ext/standard basic_functions.c url_scanner_ex.c url_scanner_ex.h url_scanner_ex.re"
- Reply: Sascha Schumann: "[PHP-DEV] Re: [PHP-CVS] cvs: php4 / php.ini-dist /ext/standard basic_functions.c url_scanner_ex.c url_scanner_ex.h url_scanner_ex.re"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

