diff -ruN php-4.3.3.orig/configure php-4.3.3/configure --- php-4.3.3.orig/configure Sun Aug 24 17:15:34 2003 +++ php-4.3.3/configure Thu Aug 28 21:30:26 2003 @@ -88776,10 +88776,10 @@ # cross-compilation, but unfortunately the echo tests do not # yet detect zsh echo's removal of \ escapes. Also zsh mangles # `"' quotes if we put them in here... so don't! - archive_cmds='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs && $CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib ${lib}-master.o $deplibs$linker_flags $(test .$module != .yes && echo -install_name $rpath/$soname $verstring)' + archive_cmds='$nonopt -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs && $nonopt $(test .$module = .yes && echo -bundle $allow_undefined_flag || echo -dynamiclib) -o $lib ${lib}-master.o $deplibs$linker_flags $(test .$module != .yes && echo -install_name $rpath/$soname $verstring)' # We need to add '_' to the symbols in $export_symbols first #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' - hardcode_direct=yes + hardcode_direct=no hardcode_shlibpath_var=no whole_archive_flag_spec='-all_load $convenience' ;; diff -ruN php-4.3.3.orig/ext/gd/gdcache.c php-4.3.3/ext/gd/gdcache.c --- php-4.3.3.orig/ext/gd/gdcache.c Mon Mar 17 19:14:22 2003 +++ php-4.3.3/ext/gd/gdcache.c Thu Aug 28 21:33:23 2003 @@ -52,8 +52,21 @@ /* implementation */ /*********************************************************/ - /* create a new cache */ +#ifdef __APPLE__ +extern gdCache_head_t * +gdCacheCreate( + int size, + gdCacheTestFn_t gdCacheTest, + gdCacheFetchFn_t gdCacheFetch, + gdCacheReleaseFn_t gdCacheRelease ); + +extern void +gdCacheDelete( gdCache_head_t *head ); + +extern void * +gdCacheGet( gdCache_head_t *head, void *keydata ); +#else gdCache_head_t * gdCacheCreate( int size, @@ -130,7 +143,7 @@ elem->userdata = userdata; return userdata; } - +#endif /*********************************************************/ diff -ruN php-4.3.3.orig/ext/pcre/php_pcre.c php-4.3.3/ext/pcre/php_pcre.c --- php-4.3.3.orig/ext/pcre/php_pcre.c Sat Jun 28 18:08:29 2003 +++ php-4.3.3/ext/pcre/php_pcre.c Thu Sep 4 19:46:47 2003 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 The PHP Group | + | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pcre.c,v 1.132.2.8 2003/06/29 00:08:29 andrei Exp $ */ +/* $Id: php_pcre.c,v 1.132.2.1 2002/11/21 23:51:57 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -56,7 +56,6 @@ static void php_pcre_free(void *ptr) { - if (ptr) pefree(ptr, 1); } @@ -64,7 +63,6 @@ static void php_free_pcre_cache(void *data) { pcre_cache_entry *pce = (pcre_cache_entry *) data; - if (!pce) return; pefree(pce->re, 1); #if HAVE_SETLOCALE if ((void*)pce->tables) pefree((void*)pce->tables, 1); @@ -318,7 +316,7 @@ /* }}} */ /* {{{ add_offset_pair */ -static inline void add_offset_pair(zval *result, char *str, int len, int offset, char *name) +static inline void add_offset_pair(zval *result, char *str, int len, int offset) { zval *match_pair; @@ -330,10 +328,6 @@ add_next_index_stringl(match_pair, str, len, 1); add_next_index_long(match_pair, offset); - if (name) { - zval_add_ref(&match_pair); - zend_hash_update(Z_ARRVAL_P(result), name, strlen(name)+1, &match_pair, sizeof(zval *), NULL); - } zend_hash_next_index_insert(Z_ARRVAL_P(result), &match_pair, sizeof(zval *), NULL); } /* }}} */ @@ -342,15 +336,11 @@ */ static void php_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) { - /* parameters */ - char *regex; /* Regular expression */ - char *subject; /* String to match against */ - int regex_len; - int subject_len; - zval *subpats = NULL; /* Array for subpatterns */ - int flags; /* Match control flags */ - - zval *result_set, /* Holds a set of subpatterns after + zval **regex, /* Regular expression */ + **subject, /* String to match against */ + **subpats = NULL, /* Array for subpatterns */ + **flags, /* Match control flags */ + *result_set, /* Holds a set of subpatterns after a global match */ **match_sets = NULL; /* An array of sets of matches for each subpattern after a global match */ @@ -362,56 +352,63 @@ int *offsets; /* Array of subpattern offsets */ int num_subpats; /* Number of captured subpatterns */ int size_offsets; /* Size of the offsets array */ - int start_offset = 0; /* Where the new search starts */ + int start_offset; /* Where the new search starts */ int matched; /* Has anything matched */ - int subpats_order = 0; /* Order of subpattern matches */ + int i; + int subpats_order = 0; /* Order of subpattern matches */ int offset_capture = 0;/* Capture match offsets: yes/no */ int g_notempty = 0; /* If the match should not be empty */ - const char **stringlist; /* Holds list of subpatterns */ + const char **stringlist; /* Used to hold list of subpatterns */ char *match; /* The current match */ - char **subpat_names = NULL;/* Array for named subpatterns */ - int i; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zll", ®ex, ®ex_len, - &subject, &subject_len, &subpats, &flags, &start_offset) == FAILURE) { - RETURN_FALSE; - } - if (global) - subpats_order = PREG_PATTERN_ORDER; - - if (ZEND_NUM_ARGS() > 3) { - offset_capture = flags & PREG_OFFSET_CAPTURE; - /* - * subpats_order is pre-set to pattern mode so we change it only if - * necessary. - */ - if (flags & 0xff) { - subpats_order = flags & 0xff; - } - if ((global && (subpats_order < PREG_PATTERN_ORDER || subpats_order > PREG_SET_ORDER)) || - (!global && subpats_order != 0)) { - zend_error(E_WARNING, "Wrong value for parameter 4 in call to %s()", get_active_function_name(TSRMLS_C)); - return; - } + /* Get function parameters and do error-checking. */ + switch(ZEND_NUM_ARGS()) { + case 2: + if (global || zend_get_parameters_ex(2, ®ex, &subject) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + + case 3: + if (zend_get_parameters_ex(3, ®ex, &subject, &subpats) == FAILURE) { + WRONG_PARAM_COUNT; + } + if (global) + subpats_order = PREG_PATTERN_ORDER; + break; + + case 4: + if (zend_get_parameters_ex(4, ®ex, &subject, &subpats, &flags) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long_ex(flags); + offset_capture = Z_LVAL_PP(flags) & PREG_OFFSET_CAPTURE; + subpats_order = Z_LVAL_PP(flags) & 0xff; + if ((global && (subpats_order < PREG_PATTERN_ORDER || subpats_order > PREG_SET_ORDER)) || + (!global && subpats_order != 0)) { + zend_error(E_WARNING, "Wrong value for parameter 4 in call to %s()", get_active_function_name(TSRMLS_C)); + return; + } + break; + + default: + WRONG_PARAM_COUNT; } - /* Overwrite the passed-in value for subpatterns with an empty array. */ - if (subpats != NULL) { - zval_dtor(subpats); - array_init(subpats); - } + /* Make sure we're dealing with strings. */ + convert_to_string_ex(regex); + convert_to_string_ex(subject); - /* Negative offset counts from the end of the string. */ - if (start_offset < 0) { - start_offset = subject_len + start_offset; - if (start_offset < 0) { - start_offset = 0; - } + /* Make sure to clean up the passed array and initialize it. */ + if (subpats != NULL) { + zval_dtor(*subpats); + array_init(*subpats); } /* Compile regex or get it from cache. */ - if ((re = pcre_get_compiled_regex(regex, &extra, &preg_options)) == NULL) { + if ((re = pcre_get_compiled_regex(Z_STRVAL_PP(regex), &extra, &preg_options)) == NULL) { RETURN_FALSE; } @@ -419,36 +416,11 @@ pcre_fullinfo(re, extra, PCRE_INFO_CAPTURECOUNT, &num_subpats); num_subpats++; size_offsets = num_subpats * 3; - offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0); + offsets = (int *)emalloc(size_offsets * sizeof(int)); - /* - * Build a mapping from subpattern numbers to their names. We will always - * allocate the table, even though they may be no named subpatterns. This - * avoids somewhat more complicated logic in the inner loops. - */ - subpat_names = (char **)safe_emalloc(num_subpats, sizeof(char *), 0); - memset(subpat_names, 0, sizeof(char *) * num_subpats); - { - int name_cnt, name_size, ni = 0; - char *name_table; - unsigned short name_idx; - - pcre_fullinfo(re, extra, PCRE_INFO_NAMECOUNT, &name_cnt); - if (name_cnt > 0) { - pcre_fullinfo(re, extra, PCRE_INFO_NAMETABLE, &name_table); - pcre_fullinfo(re, extra, PCRE_INFO_NAMEENTRYSIZE, &name_size); - - while (ni++ < name_cnt) { - name_idx = 0xff * name_table[0] + name_table[1]; - subpat_names[name_idx] = name_table + 2; - name_table += name_size; - } - } - } - - /* Allocate match sets array and initialize the values. */ + /* Allocate match sets array and initialize the values */ if (global && subpats_order == PREG_PATTERN_ORDER) { - match_sets = (zval **)safe_emalloc(num_subpats, sizeof(zval *), 0); + match_sets = (zval **)emalloc(num_subpats * sizeof(zval *)); for (i=0; i= 0) { matched++; - match = subject + offsets[0]; + match = Z_STRVAL_PP(subject) + offsets[0]; /* If subpatterns array has been passed, fill it in with values. */ if (subpats != NULL) { /* Try to get the list of substrings and display a warning if failed. */ - if (pcre_get_substring_list(subject, offsets, count, &stringlist) < 0) { - efree(subpat_names); + if (pcre_get_substring_list(Z_STRVAL_PP(subject), + offsets, count, &stringlist) < 0) { efree(offsets); efree(re); zend_error(E_WARNING, "Get subpatterns list failed"); @@ -492,7 +467,7 @@ for (i = 0; i < count; i++) { if (offset_capture) { add_offset_pair(match_sets[i], (char *)stringlist[i], - offsets[(i<<1)+1] - offsets[i<<1], offsets[i<<1], NULL); + offsets[(i<<1)+1] - offsets[i<<1], offsets[i<<1]); } else { add_next_index_stringl(match_sets[i], (char *)stringlist[i], offsets[(i<<1)+1] - offsets[i<<1], 1); @@ -518,32 +493,24 @@ for (i = 0; i < count; i++) { if (offset_capture) { add_offset_pair(result_set, (char *)stringlist[i], - offsets[(i<<1)+1] - offsets[i<<1], offsets[i<<1], subpat_names[i]); + offsets[(i<<1)+1] - offsets[i<<1], offsets[i<<1]); } else { - if (subpat_names[i]) { - add_assoc_stringl(result_set, subpat_names[i], (char *)stringlist[i], - offsets[(i<<1)+1] - offsets[i<<1], 1); - } add_next_index_stringl(result_set, (char *)stringlist[i], offsets[(i<<1)+1] - offsets[i<<1], 1); } } /* And add it to the output array */ - zend_hash_next_index_insert(Z_ARRVAL_P(subpats), &result_set, sizeof(zval *), NULL); + zend_hash_next_index_insert(Z_ARRVAL_PP(subpats), &result_set, + sizeof(zval *), NULL); } } else { /* single pattern matching */ /* For each subpattern, insert it into the subpatterns array. */ for (i = 0; i < count; i++) { if (offset_capture) { - add_offset_pair(subpats, (char *)stringlist[i], - offsets[(i<<1)+1] - offsets[i<<1], - offsets[i<<1], subpat_names[i]); + add_offset_pair(*subpats, (char *)stringlist[i], + offsets[(i<<1)+1] - offsets[i<<1], offsets[i<<1]); } else { - if (subpat_names[i]) { - add_assoc_stringl(subpats, subpat_names[i], (char *)stringlist[i], - offsets[(i<<1)+1] - offsets[i<<1], 1); - } - add_next_index_stringl(subpats, (char *)stringlist[i], + add_next_index_stringl(*subpats, (char *)stringlist[i], offsets[(i<<1)+1] - offsets[i<<1], 1); } } @@ -557,7 +524,7 @@ this is not necessarily the end. We need to advance the start offset, and continue. Fudge the offset values to achieve this, unless we're already at the end of the string. */ - if (g_notempty != 0 && start_offset < subject_len) { + if (g_notempty != 0 && start_offset < Z_STRLEN_PP(subject)) { offsets[0] = start_offset; offsets[1] = start_offset + 1; } else @@ -576,24 +543,19 @@ /* Add the match sets to the output array and clean up */ if (global && subpats_order == PREG_PATTERN_ORDER) { - for (i = 0; i < num_subpats; i++) { - if (subpat_names[i]) { - zend_hash_update(Z_ARRVAL_P(subpats), subpat_names[i], - strlen(subpat_names[i])+1, &match_sets[i], sizeof(zval *), NULL); - } - zend_hash_next_index_insert(Z_ARRVAL_P(subpats), &match_sets[i], sizeof(zval *), NULL); + for (i=0; i alloc_len) { alloc_len = new_len + 1; /* now we know exactly how long it is */ - new_buf = safe_emalloc(alloc_len, sizeof(char), 0); + new_buf = emalloc(alloc_len * sizeof(char)); memcpy(new_buf, result, *result_len); efree(result); result = new_buf; @@ -1082,10 +1044,6 @@ zend_get_parameters_ex(ZEND_NUM_ARGS(), ®ex, &replace, &subject, &limit) == FAILURE) { WRONG_PARAM_COUNT; } - if (!is_callable_replace && Z_TYPE_PP(replace) == IS_ARRAY && Z_TYPE_PP(regex) != IS_ARRAY) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter mismatch, pattern is a string while replacement in an array."); - RETURN_FALSE; - } SEPARATE_ZVAL(replace); if (Z_TYPE_PP(replace) != IS_ARRAY) @@ -1121,7 +1079,6 @@ /* For each subject entry, convert it to string, then perform replacement and add the result to the return_value array. */ while (zend_hash_get_current_data(Z_ARRVAL_PP(subject), (void **)&subject_entry) == SUCCESS) { - SEPARATE_ZVAL(subject_entry); if ((result = php_replace_in_subject(*regex, *replace, subject_entry, &result_len, limit_val, is_callable_replace TSRMLS_CC)) != NULL) { /* Add to return array */ switch(zend_hash_get_current_key(Z_ARRVAL_PP(subject), &string_key, &num_key, 0)) @@ -1223,7 +1180,7 @@ /* Calculate the size of the offsets array, and allocate memory for it. */ size_offsets = (pcre_info(re, NULL, NULL) + 1) * 3; - offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0); + offsets = (int *)emalloc(size_offsets * sizeof(int)); /* Start at the beginning of the string */ start_offset = 0; @@ -1251,7 +1208,7 @@ if (offset_capture) { /* Add (match, offset) pair to the return value */ - add_offset_pair(return_value, last_match, &Z_STRVAL_PP(subject)[offsets[0]]-last_match, next_offset, NULL); + add_offset_pair(return_value, last_match, &Z_STRVAL_PP(subject)[offsets[0]]-last_match, next_offset); } else { /* Add the piece to the return value */ add_next_index_stringl(return_value, last_match, @@ -1273,7 +1230,7 @@ /* If we have matched a delimiter */ if (!no_empty || match_len > 0) { if (offset_capture) { - add_offset_pair(return_value, &Z_STRVAL_PP(subject)[offsets[i<<1]], match_len, offsets[i<<1], NULL); + add_offset_pair(return_value, &Z_STRVAL_PP(subject)[offsets[i<<1]], match_len, offsets[i<<1]); } else { add_next_index_stringl(return_value, &Z_STRVAL_PP(subject)[offsets[i<<1]], @@ -1309,7 +1266,7 @@ { if (offset_capture) { /* Add the last (match, offset) pair to the return value */ - add_offset_pair(return_value, &Z_STRVAL_PP(subject)[start_offset], Z_STRLEN_PP(subject) - start_offset, start_offset, NULL); + add_offset_pair(return_value, &Z_STRVAL_PP(subject)[start_offset], Z_STRLEN_PP(subject) - start_offset, start_offset); } else { /* Add the last piece to the return value */ add_next_index_stringl(return_value, last_match, Z_STRVAL_PP(subject) + Z_STRLEN_PP(subject) - last_match, 1); @@ -1363,7 +1320,7 @@ /* Allocate enough memory so that even if each character is quoted, we won't run out of room */ - out_str = safe_emalloc(2, Z_STRLEN_PP(in_str_arg), 1); + out_str = emalloc(2 * Z_STRLEN_PP(in_str_arg) + 1); /* Go through the string and quote necessary characters */ for(p = in_str, q = out_str; p != in_str_end; p++) { @@ -1454,7 +1411,7 @@ /* Calculate the size of the offsets array, and allocate memory for it. */ size_offsets = (pcre_info(re, NULL, NULL) + 1) * 3; - offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0); + offsets = (int *)emalloc(size_offsets * sizeof(int)); /* Initialize return array */ array_init(return_value); diff -ruN php-4.3.3.orig/ext/pcre/php_pcre.h php-4.3.3/ext/pcre/php_pcre.h --- php-4.3.3.orig/ext/pcre/php_pcre.h Tue Dec 31 09:35:08 2002 +++ php-4.3.3/ext/pcre/php_pcre.h Thu Sep 4 19:46:47 2003 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 The PHP Group | + | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pcre.h,v 1.33.4.1 2002/12/31 16:35:08 sebastian Exp $ */ +/* $Id: php_pcre.h,v 1.33 2002/05/13 17:28:36 andrei Exp $ */ #ifndef PHP_PCRE_H #define PHP_PCRE_H