+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) 1998-2006 Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright (c) 1998-2007 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
int i_op1, i_op2;
char str_result[MAX_LENGTH_OF_LONG];
- i_op1 = atoi(op1->value.str.val);
- free(op1->value.str.val);
+ i_op1 = atoi(Z_STRVAL_P(op1));
+ free(Z_STRVAL_P(op1));
if (op2) {
- i_op2 = atoi(op2->value.str.val);
- free(op2->value.str.val);
+ i_op2 = atoi(Z_STRVAL_P(op2));
+ free(Z_STRVAL_P(op2));
} else {
i_op2 = 0;
}
break;
}
- result->value.str.len = zend_sprintf(str_result, "%d", i_result);
- result->value.str.val = (char *) malloc(result->value.str.len+1);
- memcpy(result->value.str.val, str_result, result->value.str.len);
- result->value.str.val[result->value.str.len] = 0;
- result->type = IS_STRING;
+ Z_STRLEN_P(result) = zend_sprintf(str_result, "%d", i_result);
+ Z_STRVAL_P(result) = (char *) malloc(Z_STRLEN_P(result)+1);
+ memcpy(Z_STRVAL_P(result), str_result, Z_STRLEN_P(result));
+ Z_STRVAL_P(result)[Z_STRLEN_P(result)] = 0;
+ Z_TYPE_P(result) = IS_STRING;
}
void zend_ini_init_string(zval *result)
{
- result->value.str.val = malloc(1);
- result->value.str.val[0] = 0;
- result->value.str.len = 0;
- result->type = IS_STRING;
+ Z_STRVAL_P(result) = malloc(1);
+ Z_STRVAL_P(result)[0] = 0;
+ Z_STRLEN_P(result) = 0;
+ Z_TYPE_P(result) = IS_STRING;
}
void zend_ini_add_string(zval *result, zval *op1, zval *op2)
-{
- int length = op1->value.str.len + op2->value.str.len;
-
- result->value.str.val = (char *) realloc(op1->value.str.val, length+1);
- memcpy(result->value.str.val+op1->value.str.len, op2->value.str.val, op2->value.str.len);
- result->value.str.val[length] = 0;
- result->value.str.len = length;
- result->type = IS_STRING;
+{
+ int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
+
+ Z_STRVAL_P(result) = (char *) realloc(Z_STRVAL_P(op1), length+1);
+ memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
+ Z_STRVAL_P(result)[length] = 0;
+ Z_STRLEN_P(result) = length;
+ Z_TYPE_P(result) = IS_STRING;
}
void zend_ini_get_constant(zval *result, zval *name)
zval z_constant;
TSRMLS_FETCH();
- if (!memchr(name->value.str.val, ':', name->value.str.len)
- && zend_get_constant(name->value.str.val, name->value.str.len, &z_constant TSRMLS_CC)) {
+ if (!memchr(Z_STRVAL_P(name), ':', Z_STRLEN_P(name))
+ && zend_get_constant(Z_STRVAL_P(name), Z_STRLEN_P(name), &z_constant TSRMLS_CC)) {
/* z_constant is emalloc()'d */
convert_to_string(&z_constant);
- result->value.str.val = zend_strndup(z_constant.value.str.val, z_constant.value.str.len);
- result->value.str.len = z_constant.value.str.len;
- result->type = z_constant.type;
+ Z_STRVAL_P(result) = zend_strndup(Z_STRVAL(z_constant), Z_STRLEN(z_constant));
+ Z_STRLEN_P(result) = Z_STRLEN(z_constant);
+ Z_TYPE_P(result) = Z_TYPE(z_constant);
zval_dtor(&z_constant);
- free(name->value.str.val);
+ free(Z_STRVAL_P(name));
} else {
*result = *name;
}
char *envvar;
TSRMLS_FETCH();
- if (zend_get_configuration_directive(name->value.str.val, name->value.str.len+1, &curval) == SUCCESS) {
- result->value.str.val = zend_strndup(curval.value.str.val, curval.value.str.len);
- result->value.str.len = curval.value.str.len;
- } else if ((envvar = zend_getenv(name->value.str.val, name->value.str.len TSRMLS_CC)) != NULL ||
- (envvar = getenv(name->value.str.val)) != NULL) {
- result->value.str.val = strdup(envvar);
- result->value.str.len = strlen(envvar);
+ if (zend_get_configuration_directive(Z_STRVAL_P(name), Z_STRLEN_P(name)+1, &curval) == SUCCESS) {
+ Z_STRVAL_P(result) = zend_strndup(Z_STRVAL(curval), Z_STRLEN(curval));
+ Z_STRLEN_P(result) = Z_STRLEN(curval);
+ } else if ((envvar = zend_getenv(Z_STRVAL_P(name), Z_STRLEN_P(name) TSRMLS_CC)) != NULL ||
+ (envvar = getenv(Z_STRVAL_P(name))) != NULL) {
+ Z_STRVAL_P(result) = strdup(envvar);
+ Z_STRLEN_P(result) = strlen(envvar);
} else {
zend_ini_init_string(result);
}
statement:
TC_STRING '=' string_or_value {
#if DEBUG_CFG_PARSER
- printf("'%s' = '%s'\n", $1.value.str.val, $3.value.str.val);
+ printf("'%s' = '%s'\n", Z_STRVAL($1), Z_STRVAL($3));
#endif
ZEND_INI_PARSER_CB(&$1, &$3, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG);
- free($1.value.str.val);
- free($3.value.str.val);
+ free(Z_STRVAL($1));
+ free(Z_STRVAL($3));
}
| TC_STRING BRACK '=' string_or_value {
#if DEBUG_CFG_PARSER
- printf("'%s'[ ] = '%s'\n", $1.value.str.val, $4.value.str.val);
+ printf("'%s'[ ] = '%s'\n", Z_STRVAL($1), Z_STRVAL($4));
#endif
ZEND_INI_PARSER_CB(&$1, &$4, ZEND_INI_PARSER_POP_ENTRY, ZEND_INI_PARSER_ARG);
- free($1.value.str.val);
- free($4.value.str.val);
+ free(Z_STRVAL($1));
+ free(Z_STRVAL($4));
}
- | TC_STRING { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG); free($1.value.str.val); }
- | SECTION { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_SECTION, ZEND_INI_PARSER_ARG); free($1.value.str.val); }
+ | TC_STRING { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG); free(Z_STRVAL($1)); }
+ | SECTION { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_SECTION, ZEND_INI_PARSER_ARG); free(Z_STRVAL($1)); }
| '\n'
;
| TC_ENCAPSULATED_STRING { $$ = $1; }
| constant_string { $$ = $1; }
| var_string_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); free($2.value.str.val); }
- | var_string_list TC_ENCAPSULATED_STRING { zend_ini_add_string(&$$, &$1, &$2); free($2.value.str.val); }
+ | var_string_list TC_ENCAPSULATED_STRING { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
| var_string_list constant_string { zend_ini_add_string(&$$, &$1, &$2); free($2.value.str.val); }
;
ZEND_API zend_scanner_globals ini_scanner_globals;
#endif
+# define YY_INPUT(buf, result, max_size) \
+ if ( ((result = zend_stream_read(yyin, buf, max_size TSRMLS_CC)) == 0) \
+ && zend_stream_ferror( yyin TSRMLS_CC) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
static char *ini_filename;
SCNG(lineno)=1;
}
-
int zend_ini_scanner_get_lineno(TSRMLS_D)
{
return SCNG(lineno);
}
-
char *zend_ini_scanner_get_filename(TSRMLS_D)
{
return ini_filename;
}
-
int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC)
{
if (FAILURE == zend_stream_fixup(fh TSRMLS_CC)) {
return SUCCESS;
}
-
int zend_ini_prepare_string_for_scanning(char *str TSRMLS_DC)
{
int len = strlen(str);
return SUCCESS;
}
-
void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC)
{
zend_stream_close(fh);
}
<INITIAL>[ ]*("true"|"on"|"yes")[ ]* {
- ini_lval->value.str.val = zend_strndup("1", 1);
- ini_lval->value.str.len = 1;
- ini_lval->type = IS_STRING;
+ Z_STRVAL_P(ini_lval) = zend_strndup("1", 1);
+ Z_STRLEN_P(ini_lval) = 1;
+ Z_TYPE_P(ini_lval) = IS_STRING;
return CFG_TRUE;
}
-<INITIAL>[ ]*("false"|"off"|"no"|"none")[ ]* {
- ini_lval->value.str.val = zend_strndup("", 0);
- ini_lval->value.str.len = 0;
- ini_lval->type = IS_STRING;
+<INITIAL>[ ]*("false"|"off"|"no"|"none"|"null")[ ]* {
+ Z_STRVAL_P(ini_lval) = zend_strndup("", 0);
+ Z_STRLEN_P(ini_lval) = 0;
+ Z_TYPE_P(ini_lval) = IS_STRING;
return CFG_FALSE;
}
yytext++;
yyleng--;
- ini_lval->value.str.val = zend_strndup(yytext, yyleng);
- ini_lval->value.str.len = yyleng;
- ini_lval->type = IS_STRING;
+ Z_STRVAL_P(ini_lval) = zend_strndup(yytext, yyleng);
+ Z_STRLEN_P(ini_lval) = yyleng;
+ Z_TYPE_P(ini_lval) = IS_STRING;
return SECTION;
}
-
<INITIAL>["][^"]*["] {
char *p = yytext;
/* eat leading " */
yytext++;
- ini_lval->value.str.val = zend_strndup(yytext, yyleng - 2);
- ini_lval->value.str.len = yyleng - 2;
- ini_lval->type = IS_STRING;
+ Z_STRVAL_P(ini_lval) = zend_strndup(yytext, yyleng - 2);
+ Z_STRLEN_P(ini_lval) = yyleng - 2;
+ Z_TYPE_P(ini_lval) = IS_STRING;
return TC_ENCAPSULATED_STRING;
}
-<INITIAL>[&|~$(){}!] {
- return yytext[0];
-}
-
<INITIAL>"${" {
return TC_DOLLAR_CURLY;
}
<INITIAL>"}" {
- ini_lval->value.lval = (long) yytext[0];
+ Z_LVAL_P(ini_lval) = (long) yytext[0];
+ return yytext[0];
+}
+
+<INITIAL>[&|~$(){}!] {
return yytext[0];
}
}
}
if (yyleng!=0) {
- ini_lval->value.str.val = zend_strndup(yytext, yyleng);
- ini_lval->value.str.len = yyleng;
- ini_lval->type = IS_STRING;
+ Z_STRVAL_P(ini_lval) = zend_strndup(yytext, yyleng);
+ Z_STRLEN_P(ini_lval) = yyleng;
+ Z_TYPE_P(ini_lval) = IS_STRING;
return TC_STRING;
} else {
/* whitespace */