Yasuo Ohgaki
yohga****@users*****
2002年 8月 3日 (土) 17:55:51 JST
yohgaki 02/08/03 17:55:51 Modified: . ChangeLog Zend.m4 acconfig.h zend.c zend.h zend_API.h zend_alloc.c zend_alloc.h zend_builtin_functions.c zend_compile.h zend_constants.c zend_constants.h zend_execute.h zend_globals.h zend_ini_scanner.l zend_language_parser.y zend_list.h zend_llist.c zend_modules.h zend_operators.c zend_variables.c zend_variables.h Log: revert recent bogus commits Revision Changes Path 1.8 +1 -127 Zend/ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/php-i18n/Zend/ChangeLog,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ChangeLog 2 Aug 2002 09:47:56 -0000 1.7 +++ ChangeLog 3 Aug 2002 08:55:51 -0000 1.8 @@ -1,129 +1,3 @@ -2002-06-29 Andi Gutmans <andi****@zend*****> - - * zend_language_parser.y: - Add missing semi-colon. - - * zend_compile.c: - Revert previous patch. - - * zend_compile.c: - Fix for bug 17882 - - * zend_operators.c: - Fix bug 15037 - -2002-06-28 Jani Taskinen <snipe****@iki*****> - - * zend_modules.h: - Updated the API number (to be at least same as it is in PHP_4_2_0 branch) - -2002-06-26 Andi Gutmans <andi****@zend*****> - - * zend_alloc.c: - - Put back the optimization which releases heaps in non-debug mode before - - trying to detect leaks - -2002-06-24 Andi Gutmans <andi****@zend*****> - - * zend_alloc.c: - - MFZE2 (Fixes some warnings and a bug introduced in an earlier patch) - - * zend_alloc.c: - Clean up shutdown_memory_manager(). - -2002-06-24 Sebastian Bergmann <sb****@sebas*****> - - * Zend.m4: IMHO, ZTS should no longer be labeled experimental. - -2002-06-24 Andi Gutmans <andi****@zend*****> - - * zend_alloc.c: - Only do some initializations when needed - - Nuke some old commented code - - * zend.h - zend_types.h: - - Move type definitions out of zend.h so that we can include them without - - having to include all of zend.h (which sometimes causes circular - - dependencies) - -2002-06-22 Andi Gutmans <andi****@zend*****> - - * zend_language_parser.y: - MFH - - * zend_language_parser.y: - - This typo has survived for a loooooooooong time. - - * zend_alloc.c - zend_alloc.h - zend_globals.h: - Completely nuke the persist_alloc() stuff - - * zend_alloc.c - zend_alloc.h - zend_constants.c - zend_constants.h - zend_variables.c - zend_variables.h: - Nuke persist_alloc() - -2002-06-19 Andi Gutmans <andi****@zend*****> - - * zend_constants.c: - - Fix problem where you couldn't define constants with different cases but - - the same name. - -2002-06-18 Derick Rethans <d.ret****@jdime*****> - - * zend.c: - - Change the order of which modules are unloaded to the reverse order of - which they were loaded. - - Change the order of which modules are unloaded to the reverse order of - which they were loaded. (Derick, Zend Engine) - -2002-06-12 Andrei Zmievski <andre****@php*****> - - * zend_builtin_functions.c: - set_error_handler() should take methods as callbacks. Also fixed it to report - invalid callbacks. - -2002-06-08 Andrei Zmievski <andre****@php*****> - - * zend_builtin_functions.c: - Extension registered classes preserve their case in the class entries, - so we need to use case-insensitive comparison. A bit slower, but more - right. - -2002-06-05 Derick Rethans <d.ret****@jdime*****> - - * zend_llist.c: - MFH - - * zend_globals.h - zend_llist.c: - MFZE2 (memleak fix by Stefan Sesser) - -2002-06-04 Derick Rethans <d.ret****@jdime*****> - - * zend_ini_scanner.l: - oops - - * zend_ini_scanner.l: - MFZE2 - -2002-05-29 Venkat Raghavan S <rvenk****@novel*****> - - * acconfig.h: Changes to build Zend on NetWare - -2002-05-28 Venkat Raghavan S <rvenk****@novel*****> - - * zend.h: Basic NetWare changes - -2002-05-20 Zeev Suraski <zeev****@zend*****> - - * zend_execute.h - zend_list.h - zend_API.h: Expose more C++ API's (Wez) - -2002-05-20 Masaki Fujimoto <fujim****@studi*****> - - * zend_compile.h: removed unused prototype. - -2002-05-19 Masaki Fujimoto <fujim****@studi*****> - - * zend_compile.c - zend_language_parser.y - zend_language_scanner.l: - replaced encoding directive by declare directive. - 2002-05-18 Masaki Fujimoto <fujim****@studi*****> * zend_compile.c @@ -140,7 +14,7 @@ 2002-05-13 Sterling Hughes <sterl****@bumbl*****> - * zend_qsort.c: add $Id: ChangeLog,v 1.48 2002/06/30 00:22:28 changelog Exp $ tag + * zend_qsort.c: add $Id: ChangeLog,v 1.33 2002/05/19 00:22:20 changelog Exp $ tag 2002-05-13 Derick Rethans <d.ret****@jdime*****> 1.5 +2 -2 Zend/Zend.m4 Index: Zend.m4 =================================================================== RCS file: /cvsroot/php-i18n/Zend/Zend.m4,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Zend.m4 2 Aug 2002 09:47:56 -0000 1.4 +++ Zend.m4 3 Aug 2002 08:55:51 -0000 1.5 @@ -1,5 +1,5 @@ dnl -dnl $Id: Zend.m4,v 1.34 2002/06/24 16:10:33 sebastian Exp $ +dnl $Id: Zend.m4,v 1.33 2002/05/08 12:29:51 hirokawa Exp $ dnl dnl This file contains Zend specific autoconf functions. dnl @@ -147,7 +147,7 @@ ZEND_MULTIBYTE=no ]) -AC_MSG_CHECKING(whether to enable thread-safety) +AC_MSG_CHECKING(whether to enable experimental ZTS) AC_MSG_RESULT($ZEND_EXPERIMENTAL_ZTS) AC_MSG_CHECKING(whether to enable inline optimization for GCC) 1.4 +0 -4 Zend/acconfig.h Index: acconfig.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/acconfig.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- acconfig.h 2 Aug 2002 09:47:56 -0000 1.3 +++ acconfig.h 3 Aug 2002 08:55:51 -0000 1.4 @@ -1,9 +1,7 @@ #define ZEND_API #define ZEND_DLEXPORT -#ifndef NETWARE @TOP@ -#endif #undef uint #undef ulong @@ -11,9 +9,7 @@ /* Define if you want to enable memory limit support */ #define MEMORY_LIMIT 0 -#ifndef NETWARE @BOTTOM@ -#endif #ifdef HAVE_STDLIB_H # include <stdlib.h> 1.4 +1 -1 Zend/zend.c Index: zend.c =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend.c 2 Aug 2002 09:47:56 -0000 1.3 +++ zend.c 3 Aug 2002 08:55:51 -0000 1.4 @@ -487,7 +487,7 @@ zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); - zend_hash_graceful_reverse_destroy(&module_registry); + zend_hash_destroy(&module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); 1.4 +7 -7 Zend/zend.h Index: zend.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend.h 2 Aug 2002 09:47:56 -0000 1.3 +++ zend.h 3 Aug 2002 08:55:51 -0000 1.4 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.155 2002/06/24 07:10:19 andi Exp $ */ +/* $Id: zend.h,v 1.153 2002/04/04 00:24:33 sniper Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -41,10 +41,6 @@ #ifdef ZEND_WIN32 # include "zend_config.w32.h" # define ZEND_PATHS_SEPARATOR ';' -#elif defined(NETWARE) -# include "zend_config.nw.h" -# include "acconfig.h" -# define ZEND_PATHS_SEPARATOR ';' #elif defined(__riscos__) # include "zend_config.h" # define ZEND_PATHS_SEPARATOR ';' @@ -132,7 +128,7 @@ # endif #endif -#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) +#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) # define do_alloca(p) alloca(p) # define free_alloca(p) #else @@ -177,7 +173,11 @@ #include "zend_errors.h" #include "zend_alloc.h" -#include "zend_types.h" +typedef unsigned char zend_bool; +typedef unsigned char zend_uchar; +typedef unsigned int zend_uint; +typedef unsigned long zend_ulong; +typedef unsigned short zend_ushort; #ifdef HAVE_LIMITS_H # include <limits.h> 1.4 +0 -4 Zend/zend_API.h Index: zend_API.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_API.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_API.h 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_API.h 3 Aug 2002 08:55:51 -0000 1.4 @@ -29,8 +29,6 @@ #include "zend_variables.h" #include "zend_execute.h" - -BEGIN_EXTERN_C() #define ZEND_FN(name) zif_##name #define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS) #define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name)) @@ -418,8 +416,6 @@ #define ZEND_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D #define ZEND_MINFO_FUNCTION ZEND_MODULE_INFO_D -END_EXTERN_C() - #endif /* ZEND_API_H */ 1.5 +73 -23 Zend/zend_alloc.c Index: zend_alloc.c =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_alloc.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_alloc.c 2 Aug 2002 09:47:56 -0000 1.4 +++ zend_alloc.c 3 Aug 2002 08:55:51 -0000 1.5 @@ -88,8 +88,10 @@ #define REMOVE_POINTER_FROM_LIST(p) \ - if (p==AG(head)) { \ + if (!p->persistent && p==AG(head)) { \ AG(head) = p->pNext; \ + } else if (p->persistent && p==AG(phead)) { \ + AG(phead) = p->pNext; \ } else { \ p->pLast->pNext = p->pNext; \ } \ @@ -98,11 +100,19 @@ } #define ADD_POINTER_TO_LIST(p) \ - p->pNext = AG(head); \ - if (AG(head)) { \ - AG(head)->pLast = p; \ + if (p->persistent) { \ + p->pNext = AG(phead); \ + if (AG(phead)) { \ + AG(phead)->pLast = p; \ + } \ + AG(phead) = p; \ + } else { \ + p->pNext = AG(head); \ + if (AG(head)) { \ + AG(head)->pLast = p; \ + } \ + AG(head) = p; \ } \ - AG(head) = p; \ p->pLast = (zend_mem_header *) NULL; #define DECLARE_CACHE_VARS() \ @@ -142,6 +152,7 @@ AG(cache_stats)[CACHE_INDEX][1]++; memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long)); #endif + p->persistent = 0; p->cached = 0; p->size = size; return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING); @@ -166,7 +177,7 @@ HANDLE_UNBLOCK_INTERRUPTIONS(); return (void *)p; } - p->cached = 0; + p->persistent = p->cached = 0; ADD_POINTER_TO_LIST(p); p->size = size; /* Save real size for correct cache output */ #if ZEND_DEBUG @@ -217,7 +228,7 @@ #endif if (!ZEND_DISABLE_MEMORY_CACHE - && (CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX] < MAX_CACHED_ENTRIES)) { + && !p->persistent && (CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX] < MAX_CACHED_ENTRIES)) { AG(cache)[CACHE_INDEX][AG(cache_count)[CACHE_INDEX]++] = p; p->cached = 1; #if ZEND_DEBUG @@ -369,7 +380,14 @@ ZEND_API void start_memory_manager(TSRMLS_D) { - AG(head) = NULL; +#if 0 +#ifndef ZTS + int i, j; + void *cached_entries[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES]; +#endif +#endif + + AG(phead) = AG(head) = NULL; #if MEMORY_LIMIT AG(memory_limit) = 1<<30; /* ridiculous limit, effectively no limit */ @@ -377,17 +395,33 @@ AG(memory_exhausted) = 0; AG(allocated_memory_peak) = 0; #endif -#if ZEND_ENABLE_FAST_CACHE + memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head))); -#endif -#if !ZEND_DISABLE_MEMORY_CACHE memset(AG(cache_count), 0, sizeof(AG(cache_count))); -#endif #ifdef ZEND_WIN32 AG(memory_heap) = HeapCreate(HEAP_NO_SERIALIZE, 256*1024, 0); #endif +#if 0 +#ifndef ZTS + /* Initialize cache, to prevent fragmentation */ + /* We can't do this in ZTS mode, because calling emalloc() from within start_memory_manager() + * will yield an endless recursion calling to alloc_globals_ctor() + */ + for (i=1; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<PRE_INIT_CACHE_ENTRIES; j++) { + cached_entries[i][j] = emalloc(8*i); + } + } + for (i=1; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<PRE_INIT_CACHE_ENTRIES; j++) { + efree(cached_entries[i][j]); + } + } +#endif +#endif + #if ZEND_DEBUG memset(AG(cache_stats), 0, sizeof(AG(cache_stats))); memset(AG(fast_cache_stats), 0, sizeof(AG(fast_cache_stats))); @@ -398,10 +432,11 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache TSRMLS_DC) { zend_mem_header *p, *t; - + unsigned int fci, i, j; #if ZEND_DEBUG int had_leaks = 0; #endif + zend_fast_cache_list_entry *fast_cache_list_entry, *next_fast_cache_list_entry; #if defined(ZEND_WIN32) && !ZEND_DEBUG if (clean_cache && AG(memory_heap)) { @@ -410,10 +445,6 @@ } #endif -#if ZEND_ENABLE_FAST_CACHE - zend_fast_cache_list_entry *fast_cache_list_entry, *next_fast_cache_list_entry; - unsigned int fci; - for (fci=0; fci<MAX_FAST_CACHE_TYPES; fci++) { fast_cache_list_entry = AG(fast_cache_list_head)[fci]; while (fast_cache_list_entry) { @@ -423,11 +454,8 @@ } AG(fast_cache_list_head)[fci] = NULL; } -#endif /* ZEND_ENABLE_FAST_CACHE */ -#if !ZEND_DISABLE_MEMORY_CACHE if (1 || clean_cache) { - unsigned int i, j; zend_mem_header *ptr; for (i=1; i<MAX_CACHED_MEMORY; i++) { @@ -442,7 +470,6 @@ AG(cache_count)[i] = 0; } } -#endif /* !ZEND_DISABLE_MEMORY_CACHE */ p = AG(head); t = AG(head); @@ -527,14 +554,14 @@ } } while (0); -#endif #if defined(ZEND_WIN32) && ZEND_DEBUG if (clean_cache && AG(memory_heap)) { HeapDestroy(AG(memory_heap)); - return; } #endif + +#endif } @@ -691,6 +718,29 @@ zend_debug_alloc_output("------------------------------------------------\n"); } #endif + + +ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) +{ + zend_mem_header *p = (zend_mem_header *) ((char *)ptr-sizeof(zend_mem_header)-MEM_HEADER_PADDING); + TSRMLS_FETCH(); + +#if ZEND_DEBUG + _mem_block_check(ptr, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); +#endif + + HANDLE_BLOCK_INTERRUPTIONS(); + + /* remove the block from the non persistent list */ + REMOVE_POINTER_FROM_LIST(p); + + p->persistent = 1; + + /* add the block to the persistent list */ + ADD_POINTER_TO_LIST(p); + HANDLE_UNBLOCK_INTERRUPTIONS(); + return REAL_SIZE(p->size)+sizeof(zend_mem_header)+MEM_HEADER_PADDING; +} /* 1.5 +5 -1 Zend/zend_alloc.h Index: zend_alloc.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_alloc.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_alloc.h 2 Aug 2002 09:47:56 -0000 1.4 +++ zend_alloc.h 3 Aug 2002 08:55:51 -0000 1.5 @@ -45,7 +45,8 @@ #endif struct _zend_mem_header *pNext; struct _zend_mem_header *pLast; - unsigned int size:31; + unsigned int size:30; + unsigned int persistent:1; unsigned int cached:1; } zend_mem_header; @@ -77,6 +78,7 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); /* Standard wrapper macros */ #define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) @@ -86,6 +88,7 @@ #define erealloc_recoverable(ptr, size) _erealloc((ptr), (size), 1 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) #define estrdup(s) _estrdup((s) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) #define estrndup(s, length) _estrndup((s), (length) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define persist_alloc(p) _persist_alloc((p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) /* Relay wrapper macros */ #define emalloc_rel(size) _emalloc((size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) @@ -95,6 +98,7 @@ #define erealloc_recoverable_rel(ptr, size) _erealloc((ptr), (size), 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) #define estrdup_rel(s) _estrdup((s) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) #define estrndup_rel(s, length) _estrndup((s), (length) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) +#define persist_alloc_rel(p) _persist_alloc((p) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) /* Selective persistent/non persistent allocation macros */ #define pemalloc(size, persistent) ((persistent)?malloc(size):emalloc(size)) 1.6 +2 -10 Zend/zend_builtin_functions.c Index: zend_builtin_functions.c =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_builtin_functions.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- zend_builtin_functions.c 2 Aug 2002 09:47:56 -0000 1.5 +++ zend_builtin_functions.c 3 Aug 2002 08:55:51 -0000 1.6 @@ -561,7 +561,7 @@ else ce = Z_OBJCE_PP(obj); for (; ce != NULL; ce = ce->parent) { - if ((ce->name_length == (uint)Z_STRLEN_PP(class_name)) && !zend_binary_strcasecmp(ce->name, ce->name_length, lcname, Z_STRLEN_PP(class_name))) { + if ((ce->name_length == (uint)Z_STRLEN_PP(class_name)) && !memcmp(ce->name, lcname, ce->name_length)) { efree(lcname); RETURN_TRUE; } @@ -851,21 +851,13 @@ ZEND_FUNCTION(set_error_handler) { zval **error_handler; - char *error_handler_name; zend_bool had_orig_error_handler=0; if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &error_handler)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); } - if (!zend_is_callable(*error_handler, 0, &error_handler_name)) { - zend_error(E_WARNING, "%s() expects argument 1, '%s', to be a valid callback", - get_active_function_name(TSRMLS_C), error_handler_name); - efree(error_handler_name); - return; - } - efree(error_handler_name); - + convert_to_string_ex(error_handler); if (EG(user_error_handler)) { had_orig_error_handler = 1; *return_value = *EG(user_error_handler); 1.5 +2 -0 Zend/zend_compile.h Index: zend_compile.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_compile.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_compile.h 2 Aug 2002 09:47:56 -0000 1.4 +++ zend_compile.h 3 Aug 2002 08:55:51 -0000 1.5 @@ -350,6 +350,8 @@ void zend_do_ticks(TSRMLS_D); +void zend_do_encoding(znode *result, znode *arg TSRMLS_DC); + ZEND_API void function_add_ref(zend_function *function); #define INITIAL_OP_ARRAY_SIZE 64 1.4 +25 -28 Zend/zend_constants.c Index: zend_constants.c =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_constants.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_constants.c 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_constants.c 3 Aug 2002 08:55:51 -0000 1.4 @@ -27,7 +27,8 @@ void free_zend_constant(zend_constant *c) { - if (!(c->flags & CONST_PERSISTENT)) { + if (!(c->flags & CONST_PERSISTENT) + || (c->flags & CONST_EFREE_PERSISTENT)) { zval_dtor(&c->value); } free(c->name); @@ -39,6 +40,9 @@ c->name = zend_strndup(c->name, c->name_len); if (!(c->flags & CONST_PERSISTENT)) { zval_copy_ctor(&c->value); + if (c->flags & CONST_EFREE_PERSISTENT) { /* persist_alloc()'d data */ + persist_alloc(&c->value); + } } } @@ -217,27 +221,26 @@ { zend_constant *c; char *lookup_name; - int retval = 1; + int retval; - if (zend_hash_find(EG(zend_constants), name, name_len+1, (void **) &c) == FAILURE) { - lookup_name = do_alloca(name_len+1); - memcpy(lookup_name, name, name_len+1); - zend_str_tolower(lookup_name, name_len); - - if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) { - if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len)!=0) { - retval=0; - } - } else { + lookup_name = do_alloca(name_len+1); + memcpy(lookup_name, name, name_len+1); + + zend_str_tolower(lookup_name, name_len); + + if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) { + if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len)!=0) { retval=0; + } else { + retval=1; + *result = c->value; + zval_copy_ctor(result); } - free_alloca(lookup_name); + } else { + retval=0; } - if (retval) { - *result = c->value; - zval_copy_ctor(result); - } + free_alloca(lookup_name); return retval; } @@ -245,30 +248,24 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC) { - char *lowercase_name; + char *lowercase_name = zend_strndup(c->name, c->name_len); int ret = SUCCESS; #if 0 printf("Registering constant for module %d\n", c->module_number); #endif - lowercase_name = do_alloca(c->name_len); - - memcpy(lowercase_name, c->name, c->name_len); - - if (!(c->flags & CONST_CS)) { - zend_str_tolower(lowercase_name, c->name_len); - } - + zend_str_tolower(lowercase_name, c->name_len); if (zend_hash_add(EG(zend_constants), lowercase_name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { free(c->name); - if (!(c->flags & CONST_PERSISTENT)) { + if (!(c->flags & CONST_PERSISTENT) + || (c->flags & CONST_EFREE_PERSISTENT)) { zval_dtor(&c->value); } zend_error(E_NOTICE,"Constant %s already defined", lowercase_name); ret = FAILURE; } - free_alloca(lowercase_name); + free(lowercase_name); return ret; } 1.4 +4 -0 Zend/zend_constants.h Index: zend_constants.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_constants.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_constants.h 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_constants.h 3 Aug 2002 08:55:51 -0000 1.4 @@ -25,6 +25,10 @@ #define CONST_CS (1<<0) /* Case Sensitive */ #define CONST_PERSISTENT (1<<1) /* Persistent */ +#define CONST_EFREE_PERSISTENT (1<<2) /* In conjunction with CONST_PERSISTENT, + * means that the constant should be freed + * using zval_dtor() on shutdown. + */ typedef struct _zend_constant { zval value; 1.5 +0 -3 Zend/zend_execute.h Index: zend_execute.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_execute.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_execute.h 2 Aug 2002 09:47:56 -0000 1.4 +++ zend_execute.h 3 Aug 2002 08:55:51 -0000 1.5 @@ -27,7 +27,6 @@ #include "zend_operators.h" #include "zend_execute_globals.h" -BEGIN_EXTERN_C() ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC); void init_executor(TSRMLS_D); @@ -137,7 +136,5 @@ #define IS_OVERLOADED_OBJECT 1 #define IS_STRING_OFFSET 2 - -END_EXTERN_C() #endif /* ZEND_EXECUTE_H */ 1.6 +2 -1 Zend/zend_globals.h Index: zend_globals.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_globals.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- zend_globals.h 2 Aug 2002 09:47:56 -0000 1.5 +++ zend_globals.h 3 Aug 2002 08:55:51 -0000 1.6 @@ -152,7 +152,7 @@ zend_op **opline_ptr; - zend_execute_data *execute_data_ptr; + zend_execute_data *execute_data_ptr; HashTable *active_symbol_table; HashTable symbol_table; /* main symbol table */ @@ -213,6 +213,7 @@ struct _zend_alloc_globals { zend_mem_header *head; /* standard list */ + zend_mem_header *phead; /* persistent list */ void *cache[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES]; unsigned int cache_count[MAX_CACHED_MEMORY]; void *fast_cache_list_head[MAX_FAST_CACHE_TYPES]; 1.4 +3 -3 Zend/zend_ini_scanner.l Index: zend_ini_scanner.l =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_ini_scanner.l,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_ini_scanner.l 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_ini_scanner.l 3 Aug 2002 08:55:51 -0000 1.4 @@ -125,11 +125,11 @@ return CFG_FALSE; } -<INITIAL>[[][^[]+[\]][ ]*{NEWLINE}? { +<INITIAL>[[][^[]+[\]]{NEWLINE}? { /* SECTION */ - /* eat trailing ] and spaces */ - while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']' || yytext[yyleng-1]==' ')) { + /* eat trailng ] */ + while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']')) { yyleng--; yytext[yyleng]=0; } 1.6 +1 -2 Zend/zend_language_parser.y Index: zend_language_parser.y =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_language_parser.y,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- zend_language_parser.y 2 Aug 2002 09:47:56 -0000 1.5 +++ zend_language_parser.y 3 Aug 2002 08:55:51 -0000 1.6 @@ -390,7 +390,6 @@ is_reference: /* empty */ { $$.op_type = ZEND_RETURN_VAL; } | '&' { $$.op_type = ZEND_RETURN_REF; } -; class_variable_decleration: class_variable_decleration ',' T_VARIABLE { zend_do_declare_property(&$3, NULL TSRMLS_CC); } @@ -534,7 +533,7 @@ static_scalar: /* compile-time evaluated scalars */ common_scalar { $$ = $1; } | T_STRING { zend_do_fetch_constant(&$$, &$1, ZEND_CT TSRMLS_CC); } - | '+' static_scalar { $$ = $2; } + | '+' static_scalar { $$ = $1; } | '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval = -1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one TSRMLS_CC); $$ = $2; } | T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = IS_CONSTANT_ARRAY; } ; 1.4 +0 -2 Zend/zend_list.h Index: zend_list.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_list.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_list.h 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_list.h 3 Aug 2002 08:55:51 -0000 1.4 @@ -24,7 +24,6 @@ #include "zend_hash.h" #include "zend_globals.h" -BEGIN_EXTERN_C() #define ZEND_RESOURCE_LIST_TYPE_STD 1 #define ZEND_RESOURCE_LIST_TYPE_EX 2 @@ -106,6 +105,5 @@ if (le_id == 0) { \ le_id = zend_fetch_list_dtor_id(le_type_name); \ } -END_EXTERN_C() #endif 1.4 +0 -3 Zend/zend_llist.c Index: zend_llist.c =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_llist.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_llist.c 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_llist.c 3 Aug 2002 08:55:51 -0000 1.4 @@ -139,9 +139,6 @@ data = old_tail->data; l->tail = l->tail->prev; - if (l->dtor) { - l->dtor(data); - } pefree(old_tail, l->persistent); --l->count; 1.4 +1 -1 Zend/zend_modules.h Index: zend_modules.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_modules.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_modules.h 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_modules.h 3 Aug 2002 08:55:51 -0000 1.4 @@ -34,7 +34,7 @@ ZEND_API extern unsigned char second_arg_force_ref[]; ZEND_API extern unsigned char third_arg_force_ref[]; -#define ZEND_MODULE_API_NO 20020429 +#define ZEND_MODULE_API_NO 20010901 #ifdef ZTS #define USING_ZTS 1 #else 1.4 +10 -18 Zend/zend_operators.c Index: zend_operators.c =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_operators.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_operators.c 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_operators.c 3 Aug 2002 08:55:51 -0000 1.4 @@ -1501,7 +1501,6 @@ ZEND_API int decrement_function(zval *op1) { long lval; - double dval; switch (op1->type) { case IS_LONG: @@ -1521,23 +1520,16 @@ op1->value.lval = -1; op1->type = IS_LONG; break; - } - switch(is_numeric_string(op1->value.str.val, op1->value.str.len, &lval, &dval, 0)) { - case IS_LONG: - STR_FREE(op1->value.str.val); - if(lval == LONG_MIN) { - double d = (double)lval; - ZVAL_DOUBLE(op1, d-1); - } else { - op1->value.lval = lval-1; - op1->type = IS_LONG; - } - break; - case IS_DOUBLE: - STR_FREE(op1->value.str.val); - op1->value.dval = dval - 1; - op1->type = IS_DOUBLE; - break; + } else if (is_numeric_string(op1->value.str.val, op1->value.str.len, &lval, NULL, 0)==IS_LONG) { /* long */ + STR_FREE(op1->value.str.val); + if(lval == LONG_MIN) { + double d = (double)lval; + ZVAL_DOUBLE(op1, d-1); + } else { + op1->value.lval = lval-1; + op1->type = IS_LONG; + } + break; } break; default: 1.4 +31 -0 Zend/zend_variables.c Index: zend_variables.c =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_variables.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_variables.c 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_variables.c 3 Aug 2002 08:55:51 -0000 1.4 @@ -133,6 +133,37 @@ } +ZEND_API int zval_persist(zval *zvalue TSRMLS_DC) +{ + switch (zvalue->type) { + case IS_OBJECT: + case IS_RESOURCE: + return FAILURE; /* resources and objects cannot be persisted */ + break; + case IS_BOOL: + case IS_LONG: + case IS_NULL: + break; + case IS_CONSTANT: + case IS_STRING: + if (zvalue->value.str.val) { + if (zvalue->value.str.len==0) { + zvalue->value.str.val = empty_string; + return SUCCESS; + } + } + persist_alloc(zvalue->value.str.val); + break; + case IS_ARRAY: + case IS_CONSTANT_ARRAY: + persist_alloc(zvalue->value.ht); + zend_hash_apply(zvalue->value.ht, (apply_func_t) zval_persist TSRMLS_CC); + break; + } + return SUCCESS; +} + + ZEND_API int zend_print_variable(zval *var) { return zend_print_zval(var, 0); 1.4 +2 -0 Zend/zend_variables.h Index: zend_variables.h =================================================================== RCS file: /cvsroot/php-i18n/Zend/zend_variables.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_variables.h 2 Aug 2002 09:47:56 -0000 1.3 +++ zend_variables.h 3 Aug 2002 08:55:51 -0000 1.4 @@ -32,6 +32,8 @@ #define zval_dtor(zvalue) _zval_dtor((zvalue) ZEND_FILE_LINE_CC) #define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC) +ZEND_API int zval_persist(zval *zvalue TSRMLS_DC); + #if ZEND_DEBUG ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue); ZEND_API void _zval_dtor_wrapper(zval *zvalue);