cvs: ZendEngine2(PHP_5_3) / zend_ini.c zend_ini.h

From: Date: Mon, 07 Jul 2008 21:37:46 +0000
Subject: cvs: ZendEngine2(PHP_5_3) / zend_ini.c zend_ini.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6862@lists.php.net to get a copy of this message
scottmac Mon Jul 7 21:37:46 2008 UTC Modified files: (Branch: PHP_5_3) /ZendEngine2 zend_ini.c zend_ini.h Log: Add zend_ini_string_ex so that the you can differentiate between NULL as a value and its absence, this is important for ini_get. Related to bug #42657 and #43348 http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ini.c?r1=1.39.2.2.2.18.2.14&r2=1.39.2.2.2.18.2.15&diff_format=u Index: ZendEngine2/zend_ini.c diff -u ZendEngine2/zend_ini.c:1.39.2.2.2.18.2.14 ZendEngine2/zend_ini.c:1.39.2.2.2.18.2.15 --- ZendEngine2/zend_ini.c:1.39.2.2.2.18.2.14 Wed Mar 19 12:41:23 2008 +++ ZendEngine2/zend_ini.c Mon Jul 7 21:37:46 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_ini.c,v 1.39.2.2.2.18.2.14 2008/03/19 12:41:23 tony2001 Exp $ */ +/* $Id: zend_ini.c,v 1.39.2.2.2.18.2.15 2008/07/07 21:37:46 scottmac Exp $ */ #include "zend.h" #include "zend_qsort.h" @@ -367,18 +367,23 @@ } /* }}} */ -ZEND_API char *zend_ini_string(char *name, uint name_length, int orig) /* {{{ */ +ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists) /* {{{ */ { zend_ini_entry *ini_entry; TSRMLS_FETCH(); if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) { + if (exists) { + *exists = 1; + } + if (orig && ini_entry->modified) { - return ini_entry->orig_value ? ini_entry->orig_value : ""; + return ini_entry->orig_value; } else { - return ini_entry->value ? ini_entry->value : ""; + return ini_entry->value; } - } else { + } else if (exists) { + *exists = 0; return NULL; } @@ -386,6 +391,21 @@ } /* }}} */ +ZEND_API char *zend_ini_string(char *name, uint name_length, int orig) /* {{{ */ +{ + zend_bool exists = 1; + char *return_value; + + return_value = zend_ini_string_ex(name, name_length, orig, &exists); + if (!exists) { + return NULL; + } else if (!return_value) { + return_value = ""; + } + return return_value; +} +/* }}} */ + #if TONY_20070307 static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type) /* {{{ */ { http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ini.h?r1=1.34.2.1.2.6.2.5&r2=1.34.2.1.2.6.2.6&diff_format=u Index: ZendEngine2/zend_ini.h diff -u ZendEngine2/zend_ini.h:1.34.2.1.2.6.2.5 ZendEngine2/zend_ini.h:1.34.2.1.2.6.2.6 --- ZendEngine2/zend_ini.h:1.34.2.1.2.6.2.5 Thu Mar 13 16:01:31 2008 +++ ZendEngine2/zend_ini.h Mon Jul 7 21:37:46 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_ini.h,v 1.34.2.1.2.6.2.5 2008/03/13 16:01:31 iliaa Exp $ */ +/* $Id: zend_ini.h,v 1.34.2.1.2.6.2.6 2008/07/07 21:37:46 scottmac Exp $ */ #ifndef ZEND_INI_H #define ZEND_INI_H @@ -104,6 +104,7 @@ ZEND_API long zend_ini_long(char *name, uint name_length, int orig); ZEND_API double zend_ini_double(char *name, uint name_length, int orig); ZEND_API char *zend_ini_string(char *name, uint name_length, int orig); +ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists); ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)); @@ -157,7 +158,7 @@ #define INI_INT(name) zend_ini_long((name), sizeof(name), 0) #define INI_FLT(name) zend_ini_double((name), sizeof(name), 0) -#define INI_STR(name) zend_ini_string((name), sizeof(name), 0) +#define INI_STR(name) zend_ini_string_ex((name), sizeof(name), 0, NULL) #define INI_BOOL(name) ((zend_bool) INI_INT(name)) #define INI_ORIG_INT(name) zend_ini_long((name), sizeof(name), 1)

« previous php.zend-engine.cvs (#6862) next »