]> granicus.if.org Git - php/commitdiff
Recognize single quotes around cdata.
authorSascha Schumann <sas@php.net>
Wed, 27 Sep 2000 15:26:39 +0000 (15:26 +0000)
committerSascha Schumann <sas@php.net>
Wed, 27 Sep 2000 15:26:39 +0000 (15:26 +0000)
Move smart_str functions to an extra file.

ext/standard/php_smart_str.h [new file with mode: 0644]
ext/standard/url_scanner_ex.c
ext/standard/url_scanner_ex.re

diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h
new file mode 100644 (file)
index 0000000..bbce731
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+   +----------------------------------------------------------------------+
+   | PHP version 4.0                                                      |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group                   |
+   +----------------------------------------------------------------------+
+   | This source file is subject to version 2.02 of the PHP license,      |
+   | that is bundled with this package in the file LICENSE, and is        |
+   | available at through the world-wide-web at                           |
+   | http://www.php.net/license/2_02.txt.                                 |
+   | If you did not receive a copy of the PHP license and are unable to   |
+   | obtain it through the world-wide-web, please send a note to          |
+   | license@php.net so we can mail you a copy immediately.               |
+   +----------------------------------------------------------------------+
+   | Authors: Sascha Schumann <sascha@schumann.cx>                        |
+   +----------------------------------------------------------------------+
+ */
+
+#ifndef PHP_SMART_STR_H
+#define PHP_SMART_STR_H
+
+#define smart_str_0(x) ((x)->c[(x)->len] = '\0')
+
+#define smart_str_alloc(d,n) {\
+       if (n >= d->a) {\
+               d->c = erealloc(d->c, n + 129); \
+               d->a = n + 128; \
+       }\
+}
+
+#define smart_str_appends(dest, src) smart_str_appendl(dest, src, sizeof(src)-1)
+
+static inline void smart_str_append(smart_str *dest, smart_str *src)
+{
+       size_t newlen;
+
+       if (!dest->c)
+               dest->len = dest->a = 0;
+       
+       newlen = dest->len + src->len;
+       smart_str_alloc(dest, newlen);
+       memcpy(dest->c + dest->len, src->c, src->len);
+       dest->len = newlen;
+}
+
+static inline void smart_str_appendc(smart_str *dest, char c)
+{
+       ++dest->len;
+       smart_str_alloc(dest, dest->len);
+       dest->c[dest->len - 1] = c;
+}
+
+static inline void smart_str_free(smart_str *s)
+{
+       if (s->c) {
+               efree(s->c);
+               s->c = NULL;
+       }
+       s->a = s->len = 0;
+}
+
+static inline void smart_str_copyl(smart_str *dest, const char *src, size_t len)
+{
+       smart_str_alloc(dest, len);
+       memcpy(dest->c, src, len);
+       dest->len = len;
+}
+
+static inline void smart_str_appendl(smart_str *dest, const char *src, size_t len)
+{
+       smart_str s;
+
+       s.c = (char *) src;
+       s.len = len;
+
+       smart_str_append(dest, &s);
+}
+
+static inline void smart_str_setl(smart_str *dest, const char *src, size_t len)
+{
+       dest->len = len;
+       dest->a = len + 1;
+       dest->c = (char *) src;
+}
+
+static inline void smart_str_sets(smart_str *dest, const char *src)
+{
+       smart_str_setl(dest, src, strlen(src));
+}
+
+#endif
index 592b57e27aeeaf2f8f053edb6ad304a601cc61c5..d639db30c6482e37a0550c8347f5b3247bf34a14 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.5 on Thu Sep 21 02:33:40 2000 */
+/* Generated by re2c 0.5 on Wed Sep 27 17:09:35 2000 */
 #line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
 /*
   +----------------------------------------------------------------------+
 #define url_adapt_ext url_adapt_ext_ex
 #define url_scanner url_scanner_ex
 
-#define smart_str_0(x) ((x)->c[(x)->len] = '\0')
-
-#define smart_str_alloc(d,n) {\
-       if (n >= d->a) {\
-               d->c = erealloc(d->c, n + 129); \
-               d->a = n + 128; \
-       }\
-}
-
-static inline void smart_str_append(smart_str *dest, smart_str *src)
-{
-       size_t newlen;
-
-       if (!dest->c)
-               dest->len = dest->a = 0;
-       
-       newlen = dest->len + src->len;
-       smart_str_alloc(dest, newlen);
-       memcpy(dest->c + dest->len, src->c, src->len);
-       dest->len = newlen;
-}
-
-static inline void smart_str_appendc(smart_str *dest, char c)
-{
-       ++dest->len;
-       smart_str_alloc(dest, dest->len);
-       dest->c[dest->len - 1] = c;
-}
-
-static inline void smart_str_free(smart_str *s)
-{
-       if (s->c) {
-               efree(s->c);
-               s->c = NULL;
-       }
-       s->a = s->len = 0;
-}
-
-static inline void smart_str_copyl(smart_str *dest, const char *src, size_t len)
-{
-       smart_str_alloc(dest, len);
-       memcpy(dest->c, src, len);
-       dest->len = len;
-}
-
-static inline void smart_str_appendl(smart_str *dest, const char *src, size_t len)
-{
-       smart_str s;
-
-       s.c = (char *) src;
-       s.len = len;
-
-       smart_str_append(dest, &s);
-}
-
-static inline void smart_str_setl(smart_str *dest, const char *src, size_t len)
-{
-       dest->len = len;
-       dest->a = len + 1;
-       dest->c = (char *) src;
-}
-
-#define smart_str_appends(dest, src) smart_str_appendl(dest, src, sizeof(src)-1)
-
-static inline void smart_str_sets(smart_str *dest, const char *src)
-{
-       smart_str_setl(dest, src, strlen(src));
-}
+#include "php_smart_str.h"
 
 static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *name, smart_str *val, const char *separator)
 {
@@ -264,7 +197,7 @@ 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 268
+#line 201
 
        
        while(1) {
@@ -284,14 +217,14 @@ yy0:
        if(yych != '<') goto yy4;
 yy2:   yych = *++YYCURSOR;
 yy3:
-#line 277
+#line 210
        { PASSTHRU(); STATE = STATE_TAG; continue; }
 yy4:   yych = *++YYCURSOR;
 yy5:
-#line 278
+#line 211
        { PASSTHRU(); continue; }
 }
-#line 279
+#line 212
 
                        break;
                        
@@ -345,11 +278,11 @@ yy6:
 yy8:   yych = *++YYCURSOR;
        goto yy13;
 yy9:
-#line 284
+#line 217
        { HANDLE_TAG() /* Sets STATE */; PASSTHRU(); continue; }
 yy10:  yych = *++YYCURSOR;
 yy11:
-#line 285
+#line 218
        { PASSTHRU(); continue; }
 yy12:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -357,7 +290,7 @@ yy12:       ++YYCURSOR;
 yy13:  if(yybm[0+yych] & 128)  goto yy12;
        goto yy9;
 }
-#line 286
+#line 219
 
                        break;
                        
@@ -391,22 +324,22 @@ yy14:
        }
 yy16:  yych = *++YYCURSOR;
 yy17:
-#line 291
+#line 224
        { PASSTHRU(); HANDLE_FORM(); STATE = STATE_PLAIN; continue; }
 yy18:  yych = *++YYCURSOR;
 yy19:
-#line 292
+#line 225
        { PASSTHRU(); continue; }
 yy20:  yych = *++YYCURSOR;
 yy21:
-#line 293
+#line 226
        { YYCURSOR--; STATE = STATE_ARG; continue; }
 yy22:  yych = *++YYCURSOR;
 yy23:
-#line 294
+#line 227
        { PASSTHRU(); continue; }
 }
-#line 295
+#line 228
 
                        break;
 
@@ -460,11 +393,11 @@ yy24:
 yy26:  yych = *++YYCURSOR;
        goto yy31;
 yy27:
-#line 300
+#line 233
        { PASSTHRU(); HANDLE_ARG(); STATE = STATE_BEFORE_VAL; continue; }
 yy28:  yych = *++YYCURSOR;
 yy29:
-#line 301
+#line 234
        { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
 yy30:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -472,7 +405,7 @@ yy30:       ++YYCURSOR;
 yy31:  if(yybm[0+yych] & 128)  goto yy30;
        goto yy27;
 }
-#line 302
+#line 235
 
 
                case STATE_BEFORE_VAL:
@@ -526,12 +459,12 @@ yy34:     yyaccept = 0;
        if(yych == ' ') goto yy41;
        if(yych == '=') goto yy39;
 yy35:
-#line 307
+#line 240
        { YYCURSOR--; STATE = STATE_NEXT_ARG; continue; }
 yy36:  yych = *++YYCURSOR;
        goto yy40;
 yy37:
-#line 306
+#line 239
        { PASSTHRU(); STATE = STATE_VAL; continue; }
 yy38:  yych = *++YYCURSOR;
        goto yy35;
@@ -550,7 +483,7 @@ yy43:       YYCURSOR = YYMARKER;
        case 0: goto yy35;
        }
 }
-#line 308
+#line 241
 
                        break;
 
@@ -559,89 +492,118 @@ yy43:    YYCURSOR = YYMARKER;
        YYCTYPE yych;
        unsigned int yyaccept;
        static unsigned char yybm[] = {
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 128, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       128, 192,   0, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192,   0, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
-       192, 192, 192, 192, 192, 192, 192, 192
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 192, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       192, 240,  64, 240, 240, 240, 240, 144
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240,   0, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
+       240, 240, 240, 240, 240, 240, 240, 240
        };
        goto yy44;
 yy45:  ++YYCURSOR;
 yy44:
-       if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
        yych = *YYCURSOR;
-       if(yych <= ' '){
-               if(yych == '\n')        goto yy50;
-               if(yych <= '\037')      goto yy48;
-               goto yy50;
-       } else {
-               if(yych <= '"'){
-                       if(yych <= '!') goto yy48;
+       if(yych <= '!'){
+               if(yych <= '\n'){
+                       if(yych <= '\t')        goto yy50;
+                       goto yy51;
                } else {
-                       if(yych == '>') goto yy50;
+                       if(yych == ' ') goto yy51;
+                       goto yy50;
+               }
+       } else {
+               if(yych <= '\''){
+                       if(yych <= '"') goto yy46;
+                       if(yych <= '&') goto yy50;
                        goto yy48;
+               } else {
+                       if(yych == '>') goto yy51;
+                       goto yy50;
                }
        }
 yy46:  yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
-       if(yych != '>') goto yy54;
+       if(yych != '>') goto yy63;
 yy47:
-#line 315
+#line 249
        { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
-yy48:  yych = *++YYCURSOR;
-       goto yy52;
+yy48:  yyaccept = 1;
+       yych = *(YYMARKER = ++YYCURSOR);
+       goto yy55;
 yy49:
-#line 314
+#line 248
        { HANDLE_VAL(0); STATE = STATE_NEXT_ARG; continue; }
 yy50:  yych = *++YYCURSOR;
+       goto yy53;
+yy51:  yych = *++YYCURSOR;
        goto yy47;
-yy51:  ++YYCURSOR;
+yy52:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
-yy52:  if(yybm[0+yych] & 64)   goto yy51;
+yy53:  if(yybm[0+yych] & 16)   goto yy52;
        goto yy49;
-yy53:  ++YYCURSOR;
+yy54:  yyaccept = 1;
+       YYMARKER = ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
-yy54:  if(yybm[0+yych] & 128)  goto yy53;
-       if(yych <= '=') goto yy56;
-yy55:  YYCURSOR = YYMARKER;
+yy55:  if(yybm[0+yych] & 32)   goto yy54;
+       if(yych <= '&') goto yy58;
+       if(yych >= '(') goto yy49;
+yy56:  yych = *++YYCURSOR;
+       if(yybm[0+yych] & 16)   goto yy52;
+yy57:
+#line 247
+       { HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
+yy58:  ++YYCURSOR;
+       if(YYLIMIT == YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+yy59:  if(yybm[0+yych] & 64)   goto yy58;
+       if(yych <= '=') goto yy61;
+yy60:  YYCURSOR = YYMARKER;
        switch(yyaccept){
+       case 1: goto yy49;
        case 0: goto yy47;
        }
-yy56:  yych = *++YYCURSOR;
-yy57:
-#line 313
+yy61:  yych = *++YYCURSOR;
+       goto yy57;
+yy62:  ++YYCURSOR;
+       if(YYLIMIT == YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+yy63:  if(yybm[0+yych] & 128)  goto yy62;
+       if(yych >= '>') goto yy60;
+yy64:  yych = *++YYCURSOR;
+yy65:
+#line 246
        { HANDLE_VAL(1); STATE = STATE_NEXT_ARG; continue; }
 }
-#line 316
+#line 250
 
                        break;
        }
index 4fe6d2512432ed9bfa7f7cbb57117313110bdf79..7fe1c38cda1278af7ff9f2da4371bedb23b938be 100644 (file)
 #define url_adapt_ext url_adapt_ext_ex
 #define url_scanner url_scanner_ex
 
-#define smart_str_0(x) ((x)->c[(x)->len] = '\0')
-
-#define smart_str_alloc(d,n) {\
-       if (n >= d->a) {\
-               d->c = erealloc(d->c, n + 129); \
-               d->a = n + 128; \
-       }\
-}
-
-static inline void smart_str_append(smart_str *dest, smart_str *src)
-{
-       size_t newlen;
-
-       if (!dest->c)
-               dest->len = dest->a = 0;
-       
-       newlen = dest->len + src->len;
-       smart_str_alloc(dest, newlen);
-       memcpy(dest->c + dest->len, src->c, src->len);
-       dest->len = newlen;
-}
-
-static inline void smart_str_appendc(smart_str *dest, char c)
-{
-       ++dest->len;
-       smart_str_alloc(dest, dest->len);
-       dest->c[dest->len - 1] = c;
-}
-
-static inline void smart_str_free(smart_str *s)
-{
-       if (s->c) {
-               efree(s->c);
-               s->c = NULL;
-       }
-       s->a = s->len = 0;
-}
-
-static inline void smart_str_copyl(smart_str *dest, const char *src, size_t len)
-{
-       smart_str_alloc(dest, len);
-       memcpy(dest->c, src, len);
-       dest->len = len;
-}
-
-static inline void smart_str_appendl(smart_str *dest, const char *src, size_t len)
-{
-       smart_str s;
-
-       s.c = (char *) src;
-       s.len = len;
-
-       smart_str_append(dest, &s);
-}
-
-static inline void smart_str_setl(smart_str *dest, const char *src, size_t len)
-{
-       dest->len = len;
-       dest->a = len + 1;
-       dest->c = (char *) src;
-}
-
-#define smart_str_appends(dest, src) smart_str_appendl(dest, src, sizeof(src)-1)
-
-static inline void smart_str_sets(smart_str *dest, const char *src)
-{
-       smart_str_setl(dest, src, strlen(src));
-}
+#include "php_smart_str.h"
 
 static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *name, smart_str *val, const char *separator)
 {
@@ -311,6 +244,7 @@ alpha = [a-zA-Z];
                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                                  { PASSTHRU(); STATE = STATE_NEXT_ARG; continue; }
 */