logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

cvs: ZendEngine2 / zend_ini_parser.y zend_ini_scanner.l php-src NEWS TODO-: msg#00042

Subject: cvs: ZendEngine2 / zend_ini_parser.y zend_ini_scanner.l php-src NEWS TODO-5.1
andrei          Wed Aug 18 12:58:20 2004 EDT

  Modified files:              
    /php-src    NEWS TODO-5.1 
    /ZendEngine2        zend_ini_parser.y zend_ini_scanner.l 
  Log:
  Re-add my patch for .ini variable access.
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1792&r2=1.1793&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1792 php-src/NEWS:1.1793
--- php-src/NEWS:1.1792 Fri Aug 13 08:35:56 2004
+++ php-src/NEWS        Wed Aug 18 12:58:19 2004
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2004, PHP 5.1.0
+- Implement access to INI variables from within .ini file. (Andrei)
 - Add SAPI hook to get the current request time. (Rasmus)
 - Fixed bug #29522 (accessing properties without connection) (Georg)
 - Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default) (Georg)
http://cvs.php.net/diff.php/php-src/TODO-5.1?r1=1.6&r2=1.7&ty=u
Index: php-src/TODO-5.1
diff -u php-src/TODO-5.1:1.6 php-src/TODO-5.1:1.7
--- php-src/TODO-5.1:1.6        Sun Jul 18 08:08:35 2004
+++ php-src/TODO-5.1    Wed Aug 18 12:58:19 2004
@@ -1,7 +1,6 @@
 Zend Engine
 -----------
   - Look at making zend_constant value member be a zval* instead of zval. 
(Andi)
-  - Add the patch for referring to existing .ini vars in .ini files. (Andrei)
   - Implement inheritance rules for type hints. (Marcus) 
   - Implement typehinting for arrays (apply the patch). (Andi, Marcus)
   - Find a keyword for the if-set-or operator (apply the patch). (Marcus, all)
http://cvs.php.net/diff.php/ZendEngine2/zend_ini_parser.y?r1=1.33&r2=1.34&ty=u
Index: ZendEngine2/zend_ini_parser.y
diff -u ZendEngine2/zend_ini_parser.y:1.33 ZendEngine2/zend_ini_parser.y:1.34
--- ZendEngine2/zend_ini_parser.y:1.33  Mon Jul 19 12:32:24 2004
+++ ZendEngine2/zend_ini_parser.y       Wed Aug 18 12:58:19 2004
@@ -17,15 +17,16 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_parser.y,v 1.33 2004/07/19 16:32:24 stas Exp $ */
+/* $Id: zend_ini_parser.y,v 1.34 2004/08/18 16:58:19 andrei Exp $ */
 
-#define DEBUG_CFG_PARSER 0
+#define DEBUG_CFG_PARSER 1
 #include "zend.h"
 #include "zend_API.h"
 #include "zend_ini.h"
 #include "zend_constants.h"
 #include "zend_ini_scanner.h"
 #include "zend_extensions.h"
+#include "SAPI.h"
 
 #define YYSTYPE zval
 
@@ -92,6 +93,24 @@
        result->type = 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;
+}
+
+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;
+}
 
 void zend_ini_get_constant(zval *result, zval *name)
 {
@@ -112,6 +131,24 @@
        }
 }
 
+void zend_ini_get_var(zval *result, zval *name)
+{
+       zval curval;
+       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 = sapi_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);
+       } else {
+               zend_ini_init_string(result);
+       }
+}
+
 
 static void ini_error(char *str)
 {
@@ -175,6 +212,7 @@
 %token SECTION
 %token CFG_TRUE
 %token CFG_FALSE
+%token TC_DOLLAR_CURLY
 %left '|' '&'
 %right '~' '!'
 
@@ -210,12 +248,24 @@
 
 string_or_value:
                expr { $$ = $1; }
-       |       TC_ENCAPSULATED_STRING { $$ = $1; }
        |       CFG_TRUE { $$ = $1; }
        |       CFG_FALSE { $$ = $1; }
-       |       '\n' { $$.value.str.val = strdup(""); $$.value.str.len=0; 
$$.type = IS_STRING; }
-       |       /* empty */ { $$.value.str.val = strdup(""); 
$$.value.str.len=0; $$.type = IS_STRING; }
+       |   var_string_list { $$ = $1; }
+       |       '\n' { zend_ini_init_string(&$$); }
+       |       /* empty */ { zend_ini_init_string(&$$); }
 ;
+
+
+var_string_list:
+               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); }
+       |       var_string_list constant_string { zend_ini_add_string(&$$, &$1, 
&$2); }
+       |       /* empty */ { zend_ini_init_string(&$$); }
+
+
+cfg_var_ref:
+               TC_DOLLAR_CURLY TC_STRING '}' { zend_ini_get_var(&$$, &$2); }
+
 
 expr:
                constant_string                 { $$ = $1; }
http://cvs.php.net/diff.php/ZendEngine2/zend_ini_scanner.l?r1=1.35&r2=1.36&ty=u
Index: ZendEngine2/zend_ini_scanner.l
diff -u ZendEngine2/zend_ini_scanner.l:1.35 ZendEngine2/zend_ini_scanner.l:1.36
--- ZendEngine2/zend_ini_scanner.l:1.35 Mon May 17 16:09:37 2004
+++ ZendEngine2/zend_ini_scanner.l      Wed Aug 18 12:58:20 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_scanner.l,v 1.35 2004/05/17 20:09:37 andrei Exp $ */
+/* $Id: zend_ini_scanner.l,v 1.36 2004/08/18 16:58:20 andrei Exp $ */
 
 #define yyleng SCNG(yy_leng)
 #define yytext SCNG(yy_text)
@@ -153,12 +153,20 @@
        return TC_ENCAPSULATED_STRING;
 }
 
-<INITIAL>[&|~()!] {
+<INITIAL>[&|~$(){}!] {
        return yytext[0];
 }
 
+<INITIAL>"${" {
+       return TC_DOLLAR_CURLY;
+}
+
+<INITIAL>"}" {
+       ini_lval->value.lval = (long) yytext[0];
+       return yytext[0];
+}
 
-<INITIAL>[^=\n\r\t;|&~()!"\[]+ {
+<INITIAL>[^=\n\r\t;|&$~(){}!"\[]+ {
        /* STRING */
        register int i;
 
@@ -189,8 +197,6 @@
                /* whitespace */
        }
 }
-
-
 
 <INITIAL>[=\n] {
        if (yytext[0] == '\n') {

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>