PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - lcov_data/Zend - zend_ini_scanner.l (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 193 206 93.7 %
Date: 2014-11-22 Functions: 13 13 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Zeev Suraski <zeev@zend.com>                                |
      16             :    |          Jani Taskinen <jani@php.net>                                |
      17             :    |          Marcus Boerger <helly@php.net>                              |
      18             :    |          Nuno Lopes <nlopess@php.net>                                |
      19             :    |          Scott MacVicar <scottmac@php.net>                           |
      20             :    +----------------------------------------------------------------------+
      21             : */
      22             : 
      23             : /* $Id$ */
      24             : 
      25             : #include <errno.h>
      26             : #include "zend.h"
      27             : #include "zend_API.h"
      28             : #include "zend_globals.h"
      29             : #include <zend_ini_parser.h>
      30             : #include "zend_ini_scanner.h"
      31             : 
      32             : #if 0
      33             : # define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
      34             : #else
      35             : # define YYDEBUG(s, c)
      36             : #endif
      37             : 
      38             : #include "zend_ini_scanner_defs.h"
      39             : 
      40             : #define YYCTYPE   unsigned char
      41             : /* allow the scanner to read one null byte after the end of the string (from ZEND_MMAP_AHEAD)
      42             :  * so that if will be able to terminate to match the current token (e.g. non-enclosed string) */
      43             : #define YYFILL(n) { if (YYCURSOR > YYLIMIT) return 0; }
      44             : #define YYCURSOR  SCNG(yy_cursor)
      45             : #define YYLIMIT   SCNG(yy_limit)
      46             : #define YYMARKER  SCNG(yy_marker)
      47             : 
      48             : #define YYGETCONDITION()  SCNG(yy_state)
      49             : #define YYSETCONDITION(s) SCNG(yy_state) = s
      50             : 
      51             : #define STATE(name)  yyc##name
      52             : 
      53             : /* emulate flex constructs */
      54             : #define BEGIN(state) YYSETCONDITION(STATE(state))
      55             : #define YYSTATE      YYGETCONDITION()
      56             : #define yytext       ((char*)SCNG(yy_text))
      57             : #define yyleng       SCNG(yy_leng)
      58             : #define yyless(x)    do {       YYCURSOR = (unsigned char*)yytext + x; \
      59             :                                                         yyleng   = (unsigned int)x; } while(0)
      60             : 
      61             : /* #define yymore()     goto yymore_restart */
      62             : 
      63             : /* perform sanity check. If this message is triggered you should
      64             :    increase the ZEND_MMAP_AHEAD value in the zend_streams.h file */
      65             : /*!max:re2c */
      66             : #if ZEND_MMAP_AHEAD < (YYMAXFILL + 1)
      67             : # error ZEND_MMAP_AHEAD should be greater than YYMAXFILL
      68             : #endif
      69             : 
      70             : 
      71             : /* How it works (for the core ini directives):
      72             :  * ===========================================
      73             :  *
      74             :  * 1. Scanner scans file for tokens and passes them to parser.
      75             :  * 2. Parser parses the tokens and passes the name/value pairs to the callback
      76             :  *    function which stores them in the configuration hash table.
      77             :  * 3. Later REGISTER_INI_ENTRIES() is called which triggers the actual
      78             :  *    registering of ini entries and uses zend_get_configuration_directive()
      79             :  *    to fetch the previously stored name/value pair from configuration hash table
      80             :  *    and registers the static ini entries which match the name to the value
      81             :  *    into EG(ini_directives) hash table.
      82             :  * 4. PATH section entries are used per-request from down to top, each overriding
      83             :  *    previous if one exists. zend_alter_ini_entry() is called for each entry.
      84             :  *    Settings in PATH section are ZEND_INI_SYSTEM accessible and thus mimics the
      85             :  *    php_admin_* directives used within Apache httpd.conf when PHP is compiled as
      86             :  *    module for Apache.
      87             :  * 5. User defined ini files (like .htaccess for apache) are parsed for each request and
      88             :  *    stored in separate hash defined by SAPI.
      89             :  */
      90             : 
      91             : /* TODO: (ordered by importance :-)
      92             :  * ===============================================================================
      93             :  *
      94             :  *  - Separate constant lookup totally from plain strings (using CONSTANT pattern)
      95             :  *  - Add #if .. #else .. #endif and ==, !=, <, > , <=, >= operators
      96             :  *  - Add #include "some.ini"
      97             :  *  - Allow variables to refer to options also when using parse_ini_file()
      98             :  *
      99             :  */
     100             : 
     101             : /* Globals Macros */
     102             : #define SCNG    INI_SCNG
     103             : #ifdef ZTS
     104             : ZEND_API ts_rsrc_id ini_scanner_globals_id;
     105             : #else
     106             : ZEND_API zend_ini_scanner_globals ini_scanner_globals;
     107             : #endif
     108             : 
     109             : /* Eat leading whitespace */
     110             : #define EAT_LEADING_WHITESPACE()                     \
     111             :         while (yytext[0]) {                              \
     112             :                 if (yytext[0] == ' ' || yytext[0] == '\t') { \
     113             :                         SCNG(yy_text)++;                         \
     114             :                         yyleng--;                                \
     115             :                 } else {                                     \
     116             :                         break;                                   \
     117             :                 }                                            \
     118             :         }
     119             : 
     120             : /* Eat trailing whitespace + extra char */
     121             : #define EAT_TRAILING_WHITESPACE_EX(ch)              \
     122             :         while (yyleng > 0 && (                          \
     123             :                 (ch != 'X' && yytext[yyleng - 1] ==  ch) || \
     124             :                 yytext[yyleng - 1] == '\n' ||               \
     125             :                 yytext[yyleng - 1] == '\r' ||               \
     126             :                 yytext[yyleng - 1] == '\t' ||               \
     127             :                 yytext[yyleng - 1] == ' ')                  \
     128             :         ) {                                             \
     129             :                 yyleng--;                                   \
     130             :         }
     131             : 
     132             : /* Eat trailing whitespace */
     133             : #define EAT_TRAILING_WHITESPACE()       EAT_TRAILING_WHITESPACE_EX('X')
     134             : 
     135             : #define zend_ini_copy_value(retval, str, len)   \
     136             :         ZVAL_NEW_STR(retval, zend_string_init(str, len, 1))
     137             : 
     138             : 
     139             : #define RETURN_TOKEN(type, str, len) {                       \
     140             :         if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED) {      \
     141             :                 zend_ini_copy_typed_value(ini_lval, type, str, len); \
     142             :         } else {                                                 \
     143             :                 zend_ini_copy_value(ini_lval, str, len);             \
     144             :         }                                                        \
     145             :         return type;                                             \
     146             : }
     147             : 
     148           2 : static inline int convert_to_number(zval *retval, const char *str, const int str_len)
     149             : {
     150             :         zend_uchar type;
     151             :         int overflow;
     152             :         zend_long lval;
     153             :         double dval;
     154             : 
     155           4 :         if ((type = is_numeric_string_ex(str, str_len, &lval, &dval, 0, &overflow)) != 0) {
     156           2 :                 if (type == IS_LONG) {
     157           1 :                         ZVAL_LONG(retval, lval);
     158           1 :                         return SUCCESS;
     159           1 :                 } else if (type == IS_DOUBLE && !overflow) {
     160           1 :                         ZVAL_DOUBLE(retval, dval);
     161           1 :                         return SUCCESS;
     162             :                 }
     163             :         }
     164             : 
     165           0 :         return FAILURE;
     166             : }
     167             : 
     168          13 : static void zend_ini_copy_typed_value(zval *retval, const int type, const char *str, int len)
     169             : {
     170          13 :         switch (type) {
     171             :                 case BOOL_FALSE:
     172             :                 case BOOL_TRUE:
     173           2 :                         ZVAL_BOOL(retval, type == BOOL_TRUE);
     174           2 :                         break;
     175             : 
     176             :                 case NULL_NULL:
     177           1 :                         ZVAL_NULL(retval);
     178           1 :                         break;
     179             : 
     180             :                 case TC_NUMBER:
     181           2 :                         if (convert_to_number(retval, str, len) == SUCCESS) {
     182           2 :                                 break;
     183             :                         }
     184             :                         /* intentional fall-through */
     185             :                 default:
     186          16 :                         zend_ini_copy_value(retval, str, len);
     187             :         }
     188          13 : }
     189             : 
     190      905021 : static void _yy_push_state(int new_state TSRMLS_DC)
     191             : {
     192      905021 :         zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION());
     193      905021 :         YYSETCONDITION(new_state);
     194      905021 : }
     195             : 
     196             : #define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm)
     197             : 
     198       61724 : static void yy_pop_state(TSRMLS_D)
     199             : {
     200       61724 :         int *stack_state = zend_stack_top(&SCNG(state_stack));
     201       61724 :         YYSETCONDITION(*stack_state);
     202       61724 :         zend_stack_del_top(&SCNG(state_stack));
     203       61724 : }
     204             : 
     205       40943 : static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC)
     206             : {
     207       40943 :         YYCURSOR = (YYCTYPE*)str;
     208       40943 :         SCNG(yy_start) = YYCURSOR;
     209       40943 :         YYLIMIT  = YYCURSOR + len;
     210       40943 : }
     211             : 
     212             : #define ini_filename SCNG(filename)
     213             : 
     214             : /* {{{ init_ini_scanner()
     215             : */
     216       40944 : static int init_ini_scanner(int scanner_mode, zend_file_handle *fh TSRMLS_DC)
     217             : {
     218             :         /* Sanity check */
     219       40944 :         if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) {
     220           1 :                 zend_error(E_WARNING, "Invalid scanner mode");
     221           1 :                 return FAILURE;
     222             :         }
     223             : 
     224       40943 :         SCNG(lineno) = 1;
     225       40943 :         SCNG(scanner_mode) = scanner_mode;
     226       40943 :         SCNG(yy_in) = fh;
     227             : 
     228       40943 :         if (fh != NULL) {
     229       20422 :                 ini_filename = zend_strndup(fh->filename, strlen(fh->filename));
     230             :         } else {
     231       20521 :                 ini_filename = NULL;
     232             :         }
     233             : 
     234       40943 :         zend_stack_init(&SCNG(state_stack), sizeof(int));
     235       40943 :         BEGIN(INITIAL);
     236             : 
     237       40943 :         return SUCCESS;
     238             : }
     239             : /* }}} */
     240             : 
     241             : /* {{{ shutdown_ini_scanner()
     242             : */
     243       40943 : void shutdown_ini_scanner(TSRMLS_D)
     244             : {
     245       40943 :         zend_stack_destroy(&SCNG(state_stack));
     246       40943 :         if (ini_filename) {
     247       20422 :                 free(ini_filename);
     248             :         }
     249       40943 : }
     250             : /* }}} */
     251             : 
     252             : /* {{{ zend_ini_scanner_get_lineno()
     253             : */
     254           4 : int zend_ini_scanner_get_lineno(TSRMLS_D)
     255             : {
     256           4 :         return SCNG(lineno);
     257             : }
     258             : /* }}} */
     259             : 
     260             : /* {{{ zend_ini_scanner_get_filename()
     261             : */
     262           5 : char *zend_ini_scanner_get_filename(TSRMLS_D)
     263             : {
     264           5 :         return ini_filename ? ini_filename : "Unknown";
     265             : }
     266             : /* }}} */
     267             : 
     268             : /* {{{ zend_ini_open_file_for_scanning()
     269             : */
     270       20442 : int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRMLS_DC)
     271             : {
     272             :         char *buf;
     273             :         size_t size;
     274             : 
     275       20442 :         if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE) {
     276          19 :                 return FAILURE;
     277             :         }
     278             : 
     279       20423 :         if (init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE) {
     280           1 :                 zend_file_handle_dtor(fh TSRMLS_CC);
     281           1 :                 return FAILURE;
     282             :         }
     283             : 
     284       20422 :         yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC);
     285             : 
     286       20422 :         return SUCCESS;
     287             : }
     288             : /* }}} */
     289             : 
     290             : /* {{{ zend_ini_prepare_string_for_scanning()
     291             : */
     292       20521 : int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC)
     293             : {
     294       20521 :         int len = (int)strlen(str);
     295             : 
     296       20521 :         if (init_ini_scanner(scanner_mode, NULL TSRMLS_CC) == FAILURE) {
     297           0 :                 return FAILURE;
     298             :         }
     299             : 
     300       20521 :         yy_scan_buffer(str, len TSRMLS_CC);
     301             : 
     302       20521 :         return SUCCESS;
     303             : }
     304             : /* }}} */
     305             : 
     306             : /* {{{ zend_ini_escape_string()
     307             :  */
     308       61693 : static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type TSRMLS_DC)
     309             : {
     310             :         register char *s, *t;
     311             :         char *end;
     312             : 
     313      123386 :         zend_ini_copy_value(lval, str, len);
     314             : 
     315             :         /* convert escape sequences */
     316       61693 :         s = t = Z_STRVAL_P(lval);
     317       61693 :         end = s + Z_STRLEN_P(lval);
     318             : 
     319     1702735 :         while (s < end) {
     320     1579349 :                 if (*s == '\\') {
     321          16 :                         s++;
     322          16 :                         if (s >= end) {
     323           1 :                                 *t++ = '\\';
     324           1 :                                 continue;
     325             :                         }
     326          15 :                         switch (*s) {
     327             :                                 case '"':
     328           1 :                                         if (*s != quote_type) {
     329           0 :                                                 *t++ = '\\';
     330           0 :                                                 *t++ = *s;
     331           0 :                                                 break;
     332             :                                         }
     333             :                                 case '\\':
     334             :                                 case '$':
     335           3 :                                         *t++ = *s;
     336           3 :                                         Z_STRLEN_P(lval)--;
     337           3 :                                         break;
     338             :                                 default:
     339          12 :                                         *t++ = '\\';
     340          12 :                                         *t++ = *s;
     341             :                                         break;
     342             :                         }
     343             :                 } else {
     344     1579333 :                         *t++ = *s;
     345             :                 }
     346     1579348 :                 if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) {
     347          30 :                         SCNG(lineno)++;
     348             :                 }
     349     1579348 :                 s++;
     350             :         }
     351       61693 :         *t = 0;
     352       61693 : }
     353             : /* }}} */
     354             : 
     355     3398807 : int ini_lex(zval *ini_lval TSRMLS_DC)
     356             : {
     357             : restart:
     358     3398807 :         SCNG(yy_text) = YYCURSOR;
     359             : 
     360             : /* yymore_restart: */
     361             :         /* detect EOF */
     362     3398807 :         if (YYCURSOR >= YYLIMIT) {
     363       40987 :                 if (YYSTATE == STATE(ST_VALUE) || YYSTATE == STATE(ST_RAW)) {
     364          56 :                         BEGIN(INITIAL);
     365          56 :                         return END_OF_LINE;
     366             :                 }
     367       40931 :                 return 0;
     368             :         }
     369             : 
     370             :         /* Eat any UTF-8 BOM we find in the first 3 bytes */
     371     3357820 :         if (YYCURSOR == SCNG(yy_start) && YYCURSOR + 3 < YYLIMIT) {
     372       20588 :                 if (memcmp(YYCURSOR, "\xef\xbb\xbf", 3) == 0) {
     373           0 :                         YYCURSOR += 3;
     374           0 :                         goto restart;
     375             :                 }
     376             :         }
     377             : /*!re2c
     378             : re2c:yyfill:check = 0;
     379             : LNUM [0-9]+
     380             : DNUM ([0-9]*[\.][0-9]+)|([0-9]+[\.][0-9]*)
     381             : NUMBER [-]?{LNUM}|{DNUM}
     382             : ANY_CHAR (.|[\n\t])
     383             : NEWLINE ("\r"|"\n"|"\r\n")
     384             : TABS_AND_SPACES [ \t]
     385             : WHITESPACE [ \t]+
     386             : CONSTANT [a-zA-Z_][a-zA-Z0-9_]*
     387             : LABEL [^=\n\r\t;&|^$~(){}!"\[]+
     388             : TOKENS [:,.\[\]"'()&|^+-/*=%$!~<>?@{}]
     389             : OPERATORS [&|^~()!]
     390             : DOLLAR_CURLY "${"
     391             : 
     392             : SECTION_RAW_CHARS [^\]\n\r]
     393             : SINGLE_QUOTED_CHARS [^']
     394             : RAW_VALUE_CHARS [^\n\r;\000]
     395             : 
     396             : LITERAL_DOLLAR ("$"([^{\000]|("\\"{ANY_CHAR})))
     397             : VALUE_CHARS         ([^$= \t\n\r;&|^~()!"'\000]|{LITERAL_DOLLAR})
     398             : SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
     399             : 
     400             : <!*> := yyleng = YYCURSOR - SCNG(yy_text);
     401             : 
     402             : <INITIAL>"[" { /* Section start */
     403             :         /* Enter section data lookup state */
     404       19308 :         if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
     405       19189 :                 yy_push_state(ST_SECTION_RAW TSRMLS_CC);
     406             :         } else {
     407         119 :                 yy_push_state(ST_SECTION_VALUE TSRMLS_CC);
     408             :         }
     409       19308 :         return TC_SECTION;
     410             : }
     411             : 
     412             : <ST_VALUE,ST_SECTION_VALUE,ST_OFFSET>"'"{SINGLE_QUOTED_CHARS}+"'" { /* Raw string */
     413             :         /* Eat leading and trailing single quotes */
     414           9 :         if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
     415           9 :                 SCNG(yy_text)++;
     416           9 :                 yyleng = yyleng - 2;
     417             :         }
     418          18 :         RETURN_TOKEN(TC_RAW, yytext, yyleng);
     419             : }
     420             : 
     421             : <ST_SECTION_RAW,ST_SECTION_VALUE>"]"{TABS_AND_SPACES}*{NEWLINE}? { /* End of section */
     422       19308 :         BEGIN(INITIAL);
     423       19308 :         SCNG(lineno)++;
     424       19308 :         return ']';
     425             : }
     426             : 
     427             : <INITIAL>{LABEL}"["{TABS_AND_SPACES}* { /* Start of option with offset */
     428             :         /* Eat leading whitespace */
     429          25 :         EAT_LEADING_WHITESPACE();
     430             :         
     431             :         /* Eat trailing whitespace and [ */
     432          25 :         EAT_TRAILING_WHITESPACE_EX('[');
     433             : 
     434             :         /* Enter offset lookup state */
     435          25 :         yy_push_state(ST_OFFSET TSRMLS_CC);
     436             : 
     437          46 :         RETURN_TOKEN(TC_OFFSET, yytext, yyleng);
     438             : }
     439             : 
     440             : <ST_OFFSET>{TABS_AND_SPACES}*"]" { /* End of section or an option offset */
     441          25 :         BEGIN(INITIAL);
     442          25 :         return ']';
     443             : }
     444             : 
     445             : <ST_DOUBLE_QUOTES,ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{DOLLAR_CURLY} { /* Variable start */
     446          26 :         yy_push_state(ST_VARNAME TSRMLS_CC);
     447          26 :         return TC_DOLLAR_CURLY;
     448             : }
     449             : 
     450             : <ST_VARNAME>{LABEL} { /* Variable name */
     451             :         /* Eat leading whitespace */
     452          26 :         EAT_LEADING_WHITESPACE();
     453             : 
     454             :         /* Eat trailing whitespace */
     455          26 :         EAT_TRAILING_WHITESPACE();
     456             : 
     457          52 :         RETURN_TOKEN(TC_VARNAME, yytext, yyleng);
     458             : }
     459             : 
     460             : <ST_VARNAME>"}" { /* Variable end */
     461          26 :         yy_pop_state(TSRMLS_C);
     462          26 :         return '}';
     463             : }
     464             : 
     465             : <INITIAL,ST_VALUE>("true"|"on"|"yes"){TABS_AND_SPACES}* { /* TRUE value (when used outside option value/offset this causes parse error!) */
     466         334 :         RETURN_TOKEN(BOOL_TRUE, "1", 1);
     467             : }
     468             : 
     469             : <INITIAL,ST_VALUE>("false"|"off"|"no"|"none"){TABS_AND_SPACES}* { /* FALSE value (when used outside option value/offset this causes parse error!)*/
     470       81404 :         RETURN_TOKEN(BOOL_FALSE, "", 0);
     471             : }
     472             : 
     473             : <INITIAL,ST_VALUE>("null"){TABS_AND_SPACES}* {
     474          37 :         RETURN_TOKEN(NULL_NULL, "", 0);
     475             : }
     476             : 
     477             : <INITIAL>{LABEL} { /* Get option name */
     478             :         /* Eat leading whitespace */
     479      823936 :         EAT_LEADING_WHITESPACE();
     480             : 
     481             :         /* Eat trailing whitespace */
     482      823936 :         EAT_TRAILING_WHITESPACE();
     483             : 
     484     1647869 :         RETURN_TOKEN(TC_LABEL, yytext, yyleng);
     485             : }
     486             : 
     487             : <INITIAL>{TABS_AND_SPACES}*[=]{TABS_AND_SPACES}* { /* Start option value */
     488      823964 :         if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
     489       60613 :                 yy_push_state(ST_RAW TSRMLS_CC);
     490             :         } else {
     491      763351 :                 yy_push_state(ST_VALUE TSRMLS_CC);
     492             :         }
     493      823964 :         return '=';
     494             : }
     495             : 
     496             : <ST_RAW>{RAW_VALUE_CHARS} { /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
     497       60606 :         unsigned char *sc = NULL;
     498      508830 :         while (YYCURSOR < YYLIMIT) {
     499      448218 :                 switch (*YYCURSOR) {
     500             :                         case '\n':
     501             :                         case '\r':
     502       60600 :                                 goto end_raw_value_chars;
     503             :                                 break;
     504             :                         case ';':
     505           3 :                                 if (sc == NULL) {
     506           3 :                                         sc = YYCURSOR;
     507             :                                 }
     508             :                                 /* no break */
     509             :                         default:
     510      387618 :                                 YYCURSOR++;
     511             :                                 break;
     512             :                 }
     513             :         }
     514             : end_raw_value_chars:
     515       60606 :         yyleng = YYCURSOR - SCNG(yy_text);
     516             : 
     517             :         /* Eat trailing semicolons */
     518      121212 :         while (yytext[yyleng - 1] == ';') {
     519           0 :                 yyleng--;
     520             :         }
     521             : 
     522             :         /* Eat leading and trailing double quotes */
     523       67993 :         if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
     524        7387 :                 SCNG(yy_text)++;
     525        7387 :                 yyleng = yyleng - 2;
     526       53219 :         } else if (sc) {
     527           2 :                 YYCURSOR = sc;
     528           2 :                 yyleng = YYCURSOR - SCNG(yy_text);
     529             :         }
     530      121212 :         RETURN_TOKEN(TC_RAW, yytext, yyleng);
     531             : }
     532             : 
     533             : <ST_SECTION_RAW>{SECTION_RAW_CHARS}+ { /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
     534       38378 :         RETURN_TOKEN(TC_RAW, yytext, yyleng);
     535             : }
     536             : 
     537             : <ST_VALUE,ST_RAW>{TABS_AND_SPACES}*{NEWLINE} { /* End of option value */
     538      823888 :         BEGIN(INITIAL);
     539      823888 :         SCNG(lineno)++;
     540      823888 :         return END_OF_LINE;
     541             : }
     542             : 
     543             : <ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{CONSTANT} { /* Get constant option value */
     544        2845 :         RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
     545             : }
     546             : 
     547             : <ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{NUMBER} { /* Get number option value as string */
     548      951936 :         RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
     549             : }
     550             : 
     551             : <INITIAL>{TOKENS} { /* Disallow these chars outside option values */
     552           0 :         return yytext[0];
     553             : }
     554             : 
     555             : <ST_VALUE>{OPERATORS}{TABS_AND_SPACES}* { /* Boolean operators */
     556         252 :         return yytext[0];
     557             : }
     558             : 
     559             : <ST_VALUE>[=] { /* Make = used in option value to trigger error */
     560           4 :         yyless(0);
     561           4 :         BEGIN(INITIAL);
     562           4 :         return END_OF_LINE;
     563             : }
     564             : 
     565             : <ST_VALUE>{VALUE_CHARS}+ { /* Get everything else as option/offset value */
     566       41922 :         RETURN_TOKEN(TC_STRING, yytext, yyleng);
     567             : }
     568             : 
     569             : <ST_SECTION_VALUE,ST_OFFSET>{SECTION_VALUE_CHARS}+ { /* Get rest as section/offset value */
     570          64 :         RETURN_TOKEN(TC_STRING, yytext, yyleng);
     571             : }
     572             : 
     573             : <ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{TABS_AND_SPACES}*["] { /* Double quoted '"' string start */
     574       61698 :         yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
     575       61698 :         return '"';
     576             : }
     577             : 
     578             : <ST_DOUBLE_QUOTES>["]{TABS_AND_SPACES}* { /* Double quoted '"' string ends */
     579       61698 :         yy_pop_state(TSRMLS_C);
     580       61698 :         return '"';
     581             : }
     582             : 
     583             : <ST_DOUBLE_QUOTES>[^] { /* Escape double quoted string contents */
     584       61693 :         if (YYCURSOR > YYLIMIT) {
     585           0 :                 return 0;
     586             :         }
     587             :         
     588     1641043 :         while (YYCURSOR < YYLIMIT) {
     589     1579350 :                 switch (*YYCURSOR++) {
     590             :                         case '"':
     591       61687 :                                 if (YYCURSOR < YYLIMIT && YYCURSOR[-2] == '\\' && *YYCURSOR != '\r' && *YYCURSOR != '\n') {
     592           1 :                                         continue;
     593             :                                 }
     594       61686 :                                 break;
     595             :                         case '$':
     596          13 :                                 if (*YYCURSOR == '{') {
     597           7 :                                         break;
     598             :                                 }
     599           6 :                                 continue;
     600             :                         case '\\':
     601          16 :                                 if (YYCURSOR < YYLIMIT && *YYCURSOR != '"') {
     602          14 :                                         YYCURSOR++;
     603             :                                 }
     604             :                                 /* fall through */
     605             :                         default:
     606     1517650 :                                 continue;
     607             :                 }
     608             :                 
     609       61693 :                 YYCURSOR--;
     610       61693 :                 break;
     611             :         }
     612             : 
     613       61693 :         yyleng = YYCURSOR - SCNG(yy_text);
     614             :         
     615       61693 :         zend_ini_escape_string(ini_lval, yytext, yyleng, '"' TSRMLS_CC);
     616       61693 :         return TC_QUOTED_STRING;
     617             : }
     618             : 
     619             : <ST_SECTION_VALUE,ST_VALUE,ST_OFFSET>{WHITESPACE} {
     620         754 :         RETURN_TOKEN(TC_WHITESPACE, yytext, yyleng);
     621             : }
     622             : 
     623             : <INITIAL,ST_RAW>{TABS_AND_SPACES}+ {
     624             :         /* eat whitespace */
     625           7 :         goto restart;
     626             : }
     627             : 
     628             : <INITIAL>{TABS_AND_SPACES}*{NEWLINE} {
     629       40945 :         SCNG(lineno)++;
     630       40945 :         return END_OF_LINE;
     631             : }
     632             : 
     633             : <INITIAL,ST_VALUE,ST_RAW>{TABS_AND_SPACES}*[;][^\r\n]*{NEWLINE} { /* Comment */
     634        1527 :         BEGIN(INITIAL);
     635        1527 :         SCNG(lineno)++;
     636        1527 :         return END_OF_LINE;
     637             : }
     638             : 
     639             : <INITIAL>{TABS_AND_SPACES}*[#][^\r\n]*{NEWLINE} { /* #Comment */
     640           1 :         zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(TSRMLS_C), SCNG(lineno));
     641           1 :         BEGIN(INITIAL);
     642           1 :         SCNG(lineno)++;
     643           1 :         return END_OF_LINE;
     644             : }
     645             : 
     646             : <ST_VALUE,ST_RAW>[^] { /* End of option value (if EOF is reached before EOL */
     647           0 :         BEGIN(INITIAL);
     648           0 :         return END_OF_LINE;
     649             : }
     650             : 
     651             : <*>[^] {
     652           0 :         return 0;
     653             : }
     654             : 
     655             : */
     656             : }

Generated by: LCOV version 1.10

Generated at Sat, 22 Nov 2014 23:01:28 +0000 (5 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.