com php-src: Move smart_str implementation into Zend/ : Zend/zend_smart_str.h Zend/zend_smart_str_p ublic.h ext/curl/interface.c ext/curl/php_curl.h
ext/date/php_date.c ext/dba/dba.c ext/filter/sanitizi ng_filters.c ext/gmp/gmp.c ext/iconv/iconv.c ext/ imap/php_imap.c ext/intl/intl_error.h
ext/intl/loca le/locale_methods.c ext/intl/transliterator/transliterato r.h ext/json/JSON_parser.h ext/json/json.c ext/js on/php_json.h
ext/libxml/php_libxml.h ext/mb
| From: | Nikita Popov | Date: | Sun, 21 Sep 2014 18:49:39 +0000 |
| Subject: | com php-src: Move smart_str implementation into Zend/ : Zend/zend_smart_str.h Zend/zend_smart_str_p ublic.h ext/curl/interface.c ext/curl/php_curl.h ext/date/php_date.c ext/dba/dba.c ext/filter/sanitizi ng_filters.c ext/gmp/gmp.c ext/iconv/iconv.c ext/ imap/php_imap.c ext/intl/intl_error.h ext/intl/loca le/locale_methods.c ext/intl/transliterator/transliterato r.h ext/json/JSON_parser.h ext/json/json.c ext/js on/php_json.h ext/libxml/php_libxml.h ext/mb |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81846@lists.php.net to get a copy of this message | ||
Commit: e33f3d3b7c9a69fe069484045a27d282aa98b00e
Author: Nikita Popov <nikic@php.net> Sat, 20 Sep 2014 22:42:02 +0200
Parents: e1fe5cb8c2ba47581c079d2b91e2fede29181dfe
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e33f3d3b7c9a69fe069484045a27d282aa98b00e
Log:
Move smart_str implementation into Zend/
So we can use it there as well...
For now I've retained the zend_smart_str_public.h header, though
it would probably be better to just move that one struct into
zend_types.h.
Changed paths:
A Zend/zend_smart_str.h
A Zend/zend_smart_str_public.h
M ext/curl/interface..c
M ext/curl/php_curl.h
M ext/date/php_date.c
M ext/dba/dba..c
M ext/filter/sanitizing_filters.c
M ext/gmp/gmp.c
M ext/iconv/iconv.c
M ext/imap/php_imap.c
M ext/intl/intl_error.h
M ext/intl/locale/locale_methods.c
M ext/intl/transliterator/transliterator.h
M ext/json/JSON_parser.h
M ext/json/json.c
M ext/json/php_json.h
M ext/libxml/php_libxml.h
M ext/mbstring/php_mbregex.c
M ext/mcrypt/mcrypt.c
M ext/mysqli/mysqli_api.c
M ext/mysqli/mysqli_nonapi.c
M ext/mysqlnd/mysqlnd.c
M ext/mysqlnd/mysqlnd_alloc.c
M ext/mysqlnd/mysqlnd_structs.h
M ext/mysqlnd/php_mysqlnd..c
M ext/oci8/oci8.c
M ext/openssl/xp_ssl.c
M ext/pcre/php_pcre.c
M ext/pgsql/pgsql.c
M ext/phar/phar_internal.h
M ext/readline/readline_cli.c
M ext/readline/readline_cli.h
M ext/session/session.c
M ext/soap/php_soap.h
M ext/sockets/conversions.c
M ext/spl/spl_array.c
M ext/spl/spl_dllist.c
M ext/spl/spl_iterators.c
M ext/spl/spl_observer.c
M ext/standard/array.c
M ext/standard/file.c
M ext/standard/filters.c
M ext/standard/http_fopen_wrapper.c
M ext/standard/php_http.h
D ext/standard/php_smart_str.h
D ext/standard/php_smart_str_public.h
M ext/standard/php_var.h
M ext/standard/string.c
M ext/standard/url_scanner_ex.c
M ext/standard/url_scanner_ex.h
M ext/standard/url_scanner_ex.re
M ext/standard/var.c
M ext/sysvmsg/sysvmsg.c
M ext/sysvshm/sysvshm.c
M ext/wddx/php_wddx_api.h
M ext/wddx/wddx.c
M main/php_variables.c
M main/spprintf.c
M sapi/apache2filter/php_functions.c
M sapi/apache2filter/sapi_apache2.c
M sapi/apache2handler/php_functions.c
M sapi/apache2handler/sapi_apache2.c
M sapi/cli/php_cli_server.c
M sapi/thttpd/thttpd.c
M sapi/thttpd/thttpd_patch
M sapi/tux/php_tux.c
diff --git a/Zend/zend_smart_str.h b/Zend/zend_smart_str.h new file mode 100644 index 0000000..0aff840 --- /dev/null +++ b/Zend/zend_smart_str.h @@ -0,0 +1,119 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Sascha Schumann <sascha@schumann.cx> | + +----------------------------------------------------------------------+ + */ + +#ifndef ZEND_SMART_STR_H +#define ZEND_SMART_STR_H + +#include <zend.h> +#include "zend_smart_str_public.h" + +#ifndef SMART_STR_PREALLOC +#define SMART_STR_PREALLOC 128 +#endif + +#ifndef SMART_STR_START_SIZE +#define SMART_STR_START_SIZE 78 +#endif + +#define smart_str_appends_ex(dest, src, what) \ + smart_str_appendl_ex((dest), (src), strlen(src), (what)) +#define smart_str_appends(dest, src) \ + smart_str_appendl((dest), (src), strlen(src)) +#define smart_str_appendc(dest, c) \ + smart_str_appendc_ex((dest), (c), 0) +#define smart_str_appendl(dest, src, len) \ + smart_str_appendl_ex((dest), (src), (len), 0) +#define smart_str_append(dest, src) \ + smart_str_append_ex((dest), (src), 0) +#define smart_str_sets(dest, src) \ + smart_str_setl((dest), (src), strlen(src)); +#define smart_str_append_long(dest, val) \ + smart_str_append_long_ex((dest), (val), 0) +#define smart_str_append_unsigned(dest, val) \ + smart_str_append_unsigned_ex((dest), (val), 0) + +static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, zend_bool persistent) { + size_t newlen; + if (!str->s) { + newlen = len; + str->a = newlen < SMART_STR_START_SIZE + ? SMART_STR_START_SIZE + : newlen + SMART_STR_PREALLOC; + str->s = zend_string_alloc(str->a, persistent); + str->s->len = 0; + } else { + newlen = str->s->len + len; + if (newlen >= str->a) { + str->a = newlen + SMART_STR_PREALLOC; + str->s = (zend_string *) perealloc(str->s, _STR_HEADER_SIZE + str->a + 1, persistent); + } + } + return newlen; +} + +static zend_always_inline void smart_str_free(smart_str *str) { + if (str->s) { + zend_string_release(str->s); + str->s = NULL; + } + str->a = 0; +} + +static zend_always_inline void smart_str_0(smart_str *str) { + if (str->s) { + str->s->val[str->s->len] = '\0'; + } +} + +static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, zend_bool persistent) { + size_t new_len = smart_str_alloc(dest, 1, persistent); + dest->s->val[new_len - 1] = ch; + dest->s->len = new_len; +} + +static zend_always_inline void smart_str_appendl_ex(smart_str *dest, const char *str, size_t len, zend_bool persistent) { + size_t new_len = smart_str_alloc(dest, len, persistent); + memcpy(dest->s->val + dest->s->len, str, len); + dest->s->len = new_len; +} + +static zend_always_inline void smart_str_append_ex(smart_str *dest, const smart_str *src, zend_bool persistent) { + if (src->s && src->s->len) { + smart_str_appendl_ex(dest, src->s->val, src->s->len, persistent); + } +} + +static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_long num, zend_bool persistent) { + char buf[32]; + char *result = zend_print_long_to_buf(buf + sizeof(buf) - 1, num); + smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent); +} + +static zend_always_inline void smart_str_append_unsigned_ex(smart_str *dest, zend_ulong num, zend_bool persistent) { + char buf[32]; + char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num); + smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent); +} + +static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) { + smart_str_free(dest); + smart_str_appendl(dest, src, len); +} + +#endif + diff --git a/Zend/zend_smart_str_public.h b/Zend/zend_smart_str_public.h new file mode 100644 index 0000000..23abe8e --- /dev/null +++ b/Zend/zend_smart_str_public.h @@ -0,0 +1,27 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Sascha Schumann <sascha@schumann.cx> | + +----------------------------------------------------------------------+ + */ + +#ifndef ZEND_SMART_STR_PUBLIC_H +#define ZEND_SMART_STR_PUBLIC_H + +typedef struct { + zend_string *s; + size_t a; +} smart_str; + +#endif diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 5c517d7..d7cacf5 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -82,7 +82,7 @@ #define SMART_STR_PREALLOC 4096 -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "ext/standard/file.h" #include "ext/standard/url.h" diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h index cc96a41..665682c 100644 --- a/ext/curl/php_curl.h +++ b/ext/curl/php_curl.h @@ -23,7 +23,7 @@ #define _PHP_CURL_H #include "php.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" #ifdef COMPILE_DL_CURL #undef HAVE_CURL diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 3fd4b27..360c6d3 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -999,7 +999,7 @@ PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D) /* {{{ date() and gmdate() data */ -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" static char *mon_full_names[] = { "January", "February", "March", "April", diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 5ca29ed..de4ea4c 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -519,7 +519,7 @@ PHP_MSHUTDOWN_FUNCTION(dba) } /* }}} */ -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ PHP_MINFO_FUNCTION */ diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c index 8ddd55b..083b538 100644 --- a/ext/filter/sanitizing_filters.c +++ b/ext/filter/sanitizing_filters.c @@ -20,7 +20,7 @@ #include "php_filter.h" #include "filter_private.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ STRUCTS */ typedef unsigned long filter_map[256]; diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 5a51c50..18e7965 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -25,7 +25,7 @@ #include "php_gmp.h" #include "ext/standard/info.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str_public.h" +#include "zend_smart_str_public.h" #include "zend_exceptions.h" #if HAVE_GMP diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 7ca97f9..d425f6c 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -55,7 +55,7 @@ #undef iconv #endif -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/base64.h" #include "ext/standard/quot_print.h" diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index d937681..8dc56c5 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -40,7 +40,7 @@ #include "ext/standard/php_string.h" #include "ext/standard/info.h" #include "ext/standard/file.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/pcre/php_pcre.h" #ifdef ERROR diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h index 6a809e8..7e8f0cf 100644 --- a/ext/intl/intl_error.h +++ b/ext/intl/intl_error.h @@ -21,7 +21,7 @@ #include <unicode/utypes.h> #include <unicode/parseerr.h> -#include <ext/standard/php_smart_str.h> +#include <zend_smart_str_public.h> #define INTL_ERROR_CODE(e) (e).code diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 2679983..27f917f 100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -36,7 +36,7 @@ #include <zend.h> #include <php.h> #include "main/php_ini.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" ZEND_EXTERN_MODULE_GLOBALS( intl ) diff --git a/ext/intl/transliterator/transliterator.h b/ext/intl/transliterator/transliterator.h index 3e38095..041c6df 100644 --- a/ext/intl/transliterator/transliterator.h +++ b/ext/intl/transliterator/transliterator.h @@ -21,7 +21,7 @@ #include <unicode/utypes.h> #include <unicode/utrans.h> -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" void transliterator_register_constants( INIT_FUNC_ARGS ); smart_str transliterator_parse_error_to_string( UParseError* pe ); diff --git a/ext/json/JSON_parser.h b/ext/json/JSON_parser.h index 3df999c..da47f40 100644 --- a/ext/json/JSON_parser.h +++ b/ext/json/JSON_parser.h @@ -4,8 +4,8 @@ #define JSON_PARSER_H #include "php.h" -#include "ext/standard/php_smart_str.h" #include "php_json.h" +#include "zend_smart_str.h" #define JSON_PARSER_DEFAULT_DEPTH 512 diff --git a/ext/json/json.c b/ext/json/json.c index 485d14d..16e452a 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -26,7 +26,7 @@ #include "php_ini.h" #include "ext/standard/info.h" #include "ext/standard/html.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "JSON_parser.h" #include "php_json.h" #include <zend_exceptions.h> diff --git a/ext/json/php_json.h b/ext/json/php_json.h index 05dcc43..5b2dc12 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -22,7 +22,7 @@ #define PHP_JSON_H #define PHP_JSON_VERSION "1.2.1" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" extern zend_module_entry json_module_entry; #define phpext_json_ptr &json_module_entry diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h index b06462d..9518654 100644 --- a/ext/libxml/php_libxml.h +++ b/ext/libxml/php_libxml.h @@ -34,7 +34,7 @@ extern zend_module_entry libxml_module_entry; # define PHP_LIBXML_API #endif -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" #include <libxml/tree.h> #define LIBXML_SAVE_NOEMPTYTAG 1<<2 diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 246f222..de0bc76 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -28,7 +28,7 @@ #if HAVE_MBREGEX -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "php_mbregex.h" #include "mbstring.h" diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index e572b7e..82cbe72 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -40,7 +40,7 @@ #include "php_globals.h" #include "ext/standard/info.h" #include "ext/standard/php_rand.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_mcrypt_filter.h" static int le_mcrypt; @@ -452,7 +452,7 @@ static PHP_MSHUTDOWN_FUNCTION(mcrypt) /* {{{ */ } /* }}} */ -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" PHP_MINFO_FUNCTION(mcrypt) /* {{{ */ { diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index eea6348..4eff098 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -30,7 +30,7 @@ #include "php_ini.h" #include "php_globals.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_mysqli_structs.h" #include "mysqli_priv.h" diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index e137e82..db0d0ee 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -29,7 +29,7 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_mysqli_structs.h" #include "mysqli_priv.h" diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 513df95..41f34e3 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -27,7 +27,7 @@ #include "mysqlnd_statistics.h" #include "mysqlnd_charset.h" #include "mysqlnd_debug.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* TODO : diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c index f37738d..daa758c 100644 --- a/ext/mysqlnd/mysqlnd_alloc.c +++ b/ext/mysqlnd/mysqlnd_alloc.c @@ -539,7 +539,7 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D) #define SMART_STR_START_SIZE 2048 #define SMART_STR_PREALLOC 512 -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ _mysqlnd_pestrndup */ diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 406c5a6..6be8b68 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -23,7 +23,7 @@ #ifndef MYSQLND_STRUCTS_H #define MYSQLND_STRUCTS_H -#include "ext/standard/php_smart_str_public.h" +#include "zend_smart_str_public.h" #define MYSQLND_TYPEDEFED_METHODS diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c index c38975f..a16018f 100644 --- a/ext/mysqlnd/php_mysqlnd.c +++ b/ext/mysqlnd/php_mysqlnd.c @@ -27,7 +27,7 @@ #include "mysqlnd_statistics.h" #include "mysqlnd_reverse_api.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ mysqlnd_functions[] * diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index c941c8e..dba13ce 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -33,7 +33,7 @@ #include "php.h" #include "ext/standard/info.h" #include "php_ini.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #if HAVE_OCI8 diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 28afe1d..b3213f9 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -28,7 +28,7 @@ #include "ext/standard/file.h" #include "ext/standard/url.h" #include "streams/php_streams_int.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_openssl.h" #include "php_network.h" #include <openssl/ssl.h> diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 3b49bf9..67857da 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -23,7 +23,7 @@ #include "php_globals.h" #include "php_pcre.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #if HAVE_PCRE || HAVE_BUNDLED_PCRE diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 8ea4d3c..207764b 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -35,7 +35,7 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/php_standard.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/ereg/php_regex.h" #ifdef PHP_WIN32 # include "win32/time.h" diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 77df0a7..f49143b 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -35,6 +35,7 @@ #include "zend_operators.h" #include "zend_qsort.h" #include "zend_vm.h" +#include "zend_smart_str.h" #include "main/php_streams.h" #include "main/streams/php_stream_plain_wrapper.h" #include "main/SAPI.h" @@ -49,7 +50,6 @@ #include "ext/standard/md5.h" #include "ext/standard/sha1.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" #include "ext/standard/php_versioning.h" #ifndef PHP_WIN32 #include "TSRM/tsrm_strtok_r.h" diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index 23841e4..ff0671c 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -42,7 +42,7 @@ #include "php_main.h" #include "fopen_wrappers.h" #include "ext/standard/php_standard.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #ifdef __riscos__ #include <unixlib/local.h> diff --git a/ext/readline/readline_cli.h b/ext/readline/readline_cli.h index 0531c71..6e57c83 100644 --- a/ext/readline/readline_cli.h +++ b/ext/readline/readline_cli.h @@ -20,7 +20,7 @@ /* $Id$ */ #include "php.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" ZEND_BEGIN_MODULE_GLOBALS(cli_readline) char *pager; diff --git a/ext/session/session.c b/ext/session/session.c index 18c0282..63bb00e 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -48,7 +48,7 @@ #include "ext/standard/url_scanner_ex.h" #include "ext/standard/php_rand.h" /* for RAND_MAX */ #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/url.h" #include "ext/standard/basic_functions.h" #include "ext/standard/head.h" diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h index 1cba5e7..6d36792 100644 --- a/ext/soap/php_soap.h +++ b/ext/soap/php_soap.h @@ -29,7 +29,7 @@ #if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION) #include "ext/session/php_session.h" #endif -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_ini.h" #include "SAPI.h" #include <libxml/parser.h> diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index f31208c..d808271 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -6,7 +6,7 @@ #endif #include <Zend/zend_llist.h> -#include <ext/standard/php_smart_str.h> +#include <zend_smart_str.h> #ifndef PHP_WIN32 # include <sys/types.h> diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 11293eb..211180a 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -26,7 +26,7 @@ #include "php_ini.h" #include "ext/standard/info.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "zend_interfaces.h" #include "zend_exceptions.h" diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index a02cfb6..0a6f97c 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -29,7 +29,7 @@ #include "php_spl.h" #include "ext/standard/info.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "spl_functions.h" #include "spl_engine.h" #include "spl_iterators.h" diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 75f229d..dddc8c5 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -35,7 +35,7 @@ #include "spl_directory.h" #include "spl_array.h" #include "spl_exceptions.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #ifdef accept #undef accept diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 289e921..d3ce72a 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -28,7 +28,7 @@ #include "ext/standard/info.h" #include "ext/standard/php_array.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "zend_interfaces.h" #include "zend_exceptions.h" diff --git a/ext/standard/array.c b/ext/standard/array.c index de5639f..c8e7995 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -45,7 +45,7 @@ #include "basic_functions.h" #include "php_string.h" #include "php_rand.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" #ifdef HAVE_SPL #include "ext/spl/spl_array.h" #endif diff --git a/ext/standard/file.c b/ext/standard/file.c index 66b0f0f..506105b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -35,7 +35,7 @@ #include "php_open_temporary_file.h" #include "ext/standard/basic_functions.h" #include "php_ini.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" #include <stdio.h> #include <stdlib.h> diff --git a/ext/standard/filters.c b/ext/standard/filters.c index e76ddfb..bef2399 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -27,7 +27,7 @@ #include "ext/standard/basic_functions.h" #include "ext/standard/file.h" #include "ext/standard/php_string.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ rot13 stream filter implementation */ static char rot13_from[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 83e894c..d695926 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -27,7 +27,7 @@ #include "php_network.h" #include "php_ini.h" #include "ext/standard/basic_functions.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include <stdio.h> #include <stdlib.h> diff --git a/ext/standard/php_http.h b/ext/standard/php_http.h index 0351b2a..0979348 100644 --- a/ext/standard/php_http.h +++ b/ext/standard/php_http.h @@ -22,7 +22,7 @@ #define PHP_HTTP_H #include "php.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, const char *num_prefix, int num_prefix_len, diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h deleted file mode 100644 index e32def2..0000000 --- a/ext/standard/php_smart_str.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef PHP_SMART_STR_H -#define PHP_SMART_STR_H - -#include "php_smart_str_public.h" - -#include <stdlib.h> -#include <zend.h> - -#ifndef SMART_STR_PREALLOC -#define SMART_STR_PREALLOC 128 -#endif - -#ifndef SMART_STR_START_SIZE -#define SMART_STR_START_SIZE 78 -#endif - -/* wrapper */ - -#define smart_str_appends_ex(dest, src, what) \ - smart_str_appendl_ex((dest), (src), strlen(src), (what)) -#define smart_str_appends(dest, src) \ - smart_str_appendl((dest), (src), strlen(src)) -#define smart_str_appendc(dest, c) \ - smart_str_appendc_ex((dest), (c), 0) -#define smart_str_appendl(dest, src, len) \ - smart_str_appendl_ex((dest), (src), (len), 0) -#define smart_str_append(dest, src) \ - smart_str_append_ex((dest), (src), 0) -#define smart_str_sets(dest, src) \ - smart_str_setl((dest), (src), strlen(src)); -#define smart_str_append_long(dest, val) \ - smart_str_append_long_ex((dest), (val), 0) -#define smart_str_append_unsigned(dest, val) \ - smart_str_append_unsigned_ex((dest), (val), 0) - -static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, zend_bool persistent) { - size_t newlen; - if (!str->s) { - newlen = len; - str->a = newlen < SMART_STR_START_SIZE - ? SMART_STR_START_SIZE - : newlen + SMART_STR_PREALLOC; - str->s = zend_string_alloc(str->a, persistent); - str->s->len = 0; - } else { - newlen = str->s->len + len; - if (newlen >= str->a) { - str->a = newlen + SMART_STR_PREALLOC; - str->s = (zend_string *) perealloc(str->s, _STR_HEADER_SIZE + str->a + 1, persistent); - } - } - return newlen; -} - -static zend_always_inline void smart_str_free(smart_str *str) { - if (str->s) { - zend_string_release(str->s); - str->s = NULL; - } - str->a = 0; -} - -static zend_always_inline void smart_str_0(smart_str *str) { - if (str->s) { - str->s->val[str->s->len] = '\0'; - } -} - -static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, zend_bool persistent) { - size_t new_len = smart_str_alloc(dest, 1, persistent); - dest->s->val[new_len - 1] = ch; - dest->s->len = new_len; -} - -static zend_always_inline void smart_str_appendl_ex(smart_str *dest, const char *str, size_t len, zend_bool persistent) { - size_t new_len = smart_str_alloc(dest, len, persistent); - memcpy(dest->s->val + dest->s->len, str, len); - dest->s->len = new_len; -} - -static zend_always_inline void smart_str_append_ex(smart_str *dest, const smart_str *src, zend_bool persistent) { - if (src->s && src->s->len) { - smart_str_appendl_ex(dest, src->s->val, src->s->len, persistent); - } -} - -static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_long num, zend_bool persistent) { - char buf[32]; - char *result = zend_print_long_to_buf(buf + sizeof(buf) - 1, num); - smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent); -} - -static zend_always_inline void smart_str_append_unsigned_ex(smart_str *dest, zend_ulong num, zend_bool persistent) { - char buf[32]; - char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num); - smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent); -} - -static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) { - smart_str_free(dest); - smart_str_appendl(dest, src, len); -} - -#endif diff --git a/ext/standard/php_smart_str_public.h b/ext/standard/php_smart_str_public.h deleted file mode 100644 index e33348e..0000000 --- a/ext/standard/php_smart_str_public.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef PHP_SMART_STR_PUBLIC_H -#define PHP_SMART_STR_PUBLIC_H - -#include <sys/types.h> - -typedef struct { - zend_string *s; - size_t a; -} smart_str; - -#endif diff --git a/ext/standard/php_var.h b/ext/standard/php_var.h index 5a9aae1..9097915 100644 --- a/ext/standard/php_var.h +++ b/ext/standard/php_var.h @@ -22,7 +22,7 @@ #define PHP_VAR_H #include "ext/standard/basic_functions.h" -#include "ext/standard/php_smart_str_public.h" +#include "zend_smart_str_public.h" PHP_FUNCTION(var_dump); PHP_FUNCTION(var_export); diff --git a/ext/standard/string.c b/ext/standard/string.c index 559fb8b..b49192b 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -56,7 +56,7 @@ #include "zend_execute.h" #include "php_globals.h" #include "basic_functions.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" #include <Zend/zend_exceptions.h> #ifdef ZTS #include "TSRM.h" diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index b7c9403..71658ec 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -42,7 +42,7 @@ #define url_scanner url_scanner_ex -#include "php_smart_str.h" +#include "zend_smart_str.h" static void tag_dtor(zval *zv) { diff --git a/ext/standard/url_scanner_ex.h b/ext/standard/url_scanner_ex.h index 00dd9fb..3c5b68c 100644 --- a/ext/standard/url_scanner_ex.h +++ b/ext/standard/url_scanner_ex.h @@ -31,7 +31,7 @@ PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, co PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC); PHPAPI int php_url_scanner_reset_vars(TSRMLS_D); -#include "php_smart_str_public.h" +#include "zend_smart_str_public.h" typedef struct { /* Used by the mainloop of the scanner */ diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 28a5ca3..ce7acfa 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -40,7 +40,7 @@ #define url_scanner url_scanner_ex -#include "php_smart_str.h" +#include "zend_smart_str.h" static void tag_dtor(zval *zv) { diff --git a/ext/standard/var.c b/ext/standard/var.c index 532e53a..88a8f9e 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -28,7 +28,7 @@ #include "php.h" #include "php_string.h" #include "php_var.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" #include "basic_functions.h" #include "php_incomplete_class.h" diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c index 1502178..d158366 100644 --- a/ext/sysvmsg/sysvmsg.c +++ b/ext/sysvmsg/sysvmsg.c @@ -27,7 +27,7 @@ #include "ext/standard/info.h" #include "php_sysvmsg.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* In order to detect MSG_EXCEPT use at run time; we have no way * of knowing what the bit definitions are, so we can't just define diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c index e0f9df3..c87be09 100644 --- a/ext/sysvshm/sysvshm.c +++ b/ext/sysvshm/sysvshm.c @@ -36,7 +36,7 @@ #include "php_sysvshm.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_ini.h" /* {{{ arginfo */ diff --git a/ext/wddx/php_wddx_api.h b/ext/wddx/php_wddx_api.h index 420377e..5c47109 100644 --- a/ext/wddx/php_wddx_api.h +++ b/ext/wddx/php_wddx_api.h @@ -21,7 +21,7 @@ #ifndef PHP_WDDX_API_H #define PHP_WDDX_API_H -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" #define WDDX_ARRAY_S "<array length='%d'>" #define WDDX_ARRAY_E "</array>" diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index be5913d..705babd 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -35,7 +35,7 @@ #include "ext/standard/php_incomplete_class.h" #include "ext/standard/base64.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/html.h" #include "ext/standard/php_string.h" #include "ext/date/php_date.h" diff --git a/main/php_variables.c b/main/php_variables.c index c1d6953..a0acb38 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -23,7 +23,7 @@ #include "php.h" #include "ext/standard/php_standard.h" #include "ext/standard/credits.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_variables.h" #include "php_globals.h" #include "php_content_types.h" diff --git a/main/spprintf.c b/main/spprintf.c index 12443a7..cf730dd 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -111,7 +111,7 @@ #define FLOAT_DIGITS 6 #define EXPONENT_LENGTH 10 -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/php_smart_string.h" /* {{{ macros */ diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c index 321df14..ea13738 100644 --- a/sapi/apache2filter/php_functions.c +++ b/sapi/apache2filter/php_functions.c @@ -22,7 +22,7 @@ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "SAPI.h" diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index 9d15932..3896861 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -30,7 +30,7 @@ #include "php_variables.h" #include "SAPI.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #ifndef NETWARE #include "ext/standard/php_standard.h" #else diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index 27643b8..d9ae4d9 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -21,7 +21,7 @@ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "ext/standard/head.h" #include "php_ini.h" diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 08e6caf..fe20030 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -30,7 +30,7 @@ #include <fcntl.h> -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #ifndef NETWARE #include "ext/standard/php_standard.h" #else diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index b2defe0..909e91e 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -96,7 +96,7 @@ #endif #include "ext/standard/file.h" /* for php_set_sock_blocking() :-( */ -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/html.h" #include "ext/standard/url.h" /* for php_url_decode() */ #include "ext/standard/php_string.h" /* for php_dirname() */ diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 1671a5b..7c03454 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -27,7 +27,7 @@ #include "php_ini.h" #include "zend_highlight.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include <sys/time.h> #include <sys/types.h> diff --git a/sapi/thttpd/thttpd_patch b/sapi/thttpd/thttpd_patch index c79ee44..1a9ed29 100644 --- a/sapi/thttpd/thttpd_patch +++ b/sapi/thttpd/thttpd_patch @@ -240,7 +240,7 @@ diff -ur thttpd-2.21b/libhttpd.c thttpd-2.21b-cool/libhttpd.c + +#define SMART_STR_USE_REALLOC + -+#include "ext/standard/php_smart_str.h" ++#include "zend_smart_str.h" static void -send_mime( httpd_conn* hc, int status, char* title, char* encodings, char* extraheads, char* type, int length, time_t mod ) diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c index 9bff4f1..783fe85 100644 --- a/sapi/tux/php_tux.c +++ b/sapi/tux/php_tux.c @@ -21,7 +21,7 @@ #include "php_main.h" #include "php_variables.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "tuxmodule.h"
diff --git a/Zend/zend_smart_str.h b/Zend/zend_smart_str.h new file mode 100644 index 0000000..0aff840 --- /dev/null +++ b/Zend/zend_smart_str.h @@ -0,0 +1,119 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Sascha Schumann <sascha@schumann.cx> | + +----------------------------------------------------------------------+ + */ + +#ifndef ZEND_SMART_STR_H +#define ZEND_SMART_STR_H + +#include <zend.h> +#include "zend_smart_str_public.h" + +#ifndef SMART_STR_PREALLOC +#define SMART_STR_PREALLOC 128 +#endif + +#ifndef SMART_STR_START_SIZE +#define SMART_STR_START_SIZE 78 +#endif + +#define smart_str_appends_ex(dest, src, what) \ + smart_str_appendl_ex((dest), (src), strlen(src), (what)) +#define smart_str_appends(dest, src) \ + smart_str_appendl((dest), (src), strlen(src)) +#define smart_str_appendc(dest, c) \ + smart_str_appendc_ex((dest), (c), 0) +#define smart_str_appendl(dest, src, len) \ + smart_str_appendl_ex((dest), (src), (len), 0) +#define smart_str_append(dest, src) \ + smart_str_append_ex((dest), (src), 0) +#define smart_str_sets(dest, src) \ + smart_str_setl((dest), (src), strlen(src)); +#define smart_str_append_long(dest, val) \ + smart_str_append_long_ex((dest), (val), 0) +#define smart_str_append_unsigned(dest, val) \ + smart_str_append_unsigned_ex((dest), (val), 0) + +static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, zend_bool persistent) { + size_t newlen; + if (!str->s) { + newlen = len; + str->a = newlen < SMART_STR_START_SIZE + ? SMART_STR_START_SIZE + : newlen + SMART_STR_PREALLOC; + str->s = zend_string_alloc(str->a, persistent); + str->s->len = 0; + } else { + newlen = str->s->len + len; + if (newlen >= str->a) { + str->a = newlen + SMART_STR_PREALLOC; + str->s = (zend_string *) perealloc(str->s, _STR_HEADER_SIZE + str->a + 1, persistent); + } + } + return newlen; +} + +static zend_always_inline void smart_str_free(smart_str *str) { + if (str->s) { + zend_string_release(str->s); + str->s = NULL; + } + str->a = 0; +} + +static zend_always_inline void smart_str_0(smart_str *str) { + if (str->s) { + str->s->val[str->s->len] = '\0'; + } +} + +static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, zend_bool persistent) { + size_t new_len = smart_str_alloc(dest, 1, persistent); + dest->s->val[new_len - 1] = ch; + dest->s->len = new_len; +} + +static zend_always_inline void smart_str_appendl_ex(smart_str *dest, const char *str, size_t len, zend_bool persistent) { + size_t new_len = smart_str_alloc(dest, len, persistent); + memcpy(dest->s->val + dest->s->len, str, len); + dest->s->len = new_len; +} + +static zend_always_inline void smart_str_append_ex(smart_str *dest, const smart_str *src, zend_bool persistent) { + if (src->s && src->s->len) { + smart_str_appendl_ex(dest, src->s->val, src->s->len, persistent); + } +} + +static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_long num, zend_bool persistent) { + char buf[32]; + char *result = zend_print_long_to_buf(buf + sizeof(buf) - 1, num); + smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent); +} + +static zend_always_inline void smart_str_append_unsigned_ex(smart_str *dest, zend_ulong num, zend_bool persistent) { + char buf[32]; + char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num); + smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent); +} + +static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) { + smart_str_free(dest); + smart_str_appendl(dest, src, len); +} + +#endif + diff --git a/Zend/zend_smart_str_public.h b/Zend/zend_smart_str_public.h new file mode 100644 index 0000000..23abe8e --- /dev/null +++ b/Zend/zend_smart_str_public.h @@ -0,0 +1,27 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Sascha Schumann <sascha@schumann.cx> | + +----------------------------------------------------------------------+ + */ + +#ifndef ZEND_SMART_STR_PUBLIC_H +#define ZEND_SMART_STR_PUBLIC_H + +typedef struct { + zend_string *s; + size_t a; +} smart_str; + +#endif diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 5c517d7..d7cacf5 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -82,7 +82,7 @@ #define SMART_STR_PREALLOC 4096 -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "ext/standard/file.h" #include "ext/standard/url.h" diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h index cc96a41..665682c 100644 --- a/ext/curl/php_curl.h +++ b/ext/curl/php_curl.h @@ -23,7 +23,7 @@ #define _PHP_CURL_H #include "php.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" #ifdef COMPILE_DL_CURL #undef HAVE_CURL diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 3fd4b27..360c6d3 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -999,7 +999,7 @@ PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D) /* {{{ date() and gmdate() data */ -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" static char *mon_full_names[] = { "January", "February", "March", "April", diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 5ca29ed..de4ea4c 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -519,7 +519,7 @@ PHP_MSHUTDOWN_FUNCTION(dba) } /* }}} */ -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ PHP_MINFO_FUNCTION */ diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c index 8ddd55b..083b538 100644 --- a/ext/filter/sanitizing_filters.c +++ b/ext/filter/sanitizing_filters.c @@ -20,7 +20,7 @@ #include "php_filter.h" #include "filter_private.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ STRUCTS */ typedef unsigned long filter_map[256]; diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 5a51c50..18e7965 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -25,7 +25,7 @@ #include "php_gmp.h" #include "ext/standard/info.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str_public.h" +#include "zend_smart_str_public.h" #include "zend_exceptions.h" #if HAVE_GMP diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 7ca97f9..d425f6c 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -55,7 +55,7 @@ #undef iconv #endif -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/base64.h" #include "ext/standard/quot_print.h" diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index d937681..8dc56c5 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -40,7 +40,7 @@ #include "ext/standard/php_string.h" #include "ext/standard/info.h" #include "ext/standard/file.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/pcre/php_pcre.h" #ifdef ERROR diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h index 6a809e8..7e8f0cf 100644 --- a/ext/intl/intl_error.h +++ b/ext/intl/intl_error.h @@ -21,7 +21,7 @@ #include <unicode/utypes.h> #include <unicode/parseerr.h> -#include <ext/standard/php_smart_str.h> +#include <zend_smart_str_public.h> #define INTL_ERROR_CODE(e) (e).code diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 2679983..27f917f 100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -36,7 +36,7 @@ #include <zend.h> #include <php.h> #include "main/php_ini.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" ZEND_EXTERN_MODULE_GLOBALS( intl ) diff --git a/ext/intl/transliterator/transliterator.h b/ext/intl/transliterator/transliterator.h index 3e38095..041c6df 100644 --- a/ext/intl/transliterator/transliterator.h +++ b/ext/intl/transliterator/transliterator.h @@ -21,7 +21,7 @@ #include <unicode/utypes.h> #include <unicode/utrans.h> -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" void transliterator_register_constants( INIT_FUNC_ARGS ); smart_str transliterator_parse_error_to_string( UParseError* pe ); diff --git a/ext/json/JSON_parser.h b/ext/json/JSON_parser.h index 3df999c..da47f40 100644 --- a/ext/json/JSON_parser.h +++ b/ext/json/JSON_parser.h @@ -4,8 +4,8 @@ #define JSON_PARSER_H #include "php.h" -#include "ext/standard/php_smart_str.h" #include "php_json.h" +#include "zend_smart_str.h" #define JSON_PARSER_DEFAULT_DEPTH 512 diff --git a/ext/json/json.c b/ext/json/json.c index 485d14d..16e452a 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -26,7 +26,7 @@ #include "php_ini.h" #include "ext/standard/info.h" #include "ext/standard/html.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "JSON_parser.h" #include "php_json.h" #include <zend_exceptions.h> diff --git a/ext/json/php_json.h b/ext/json/php_json.h index 05dcc43..5b2dc12 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -22,7 +22,7 @@ #define PHP_JSON_H #define PHP_JSON_VERSION "1.2.1" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" extern zend_module_entry json_module_entry; #define phpext_json_ptr &json_module_entry diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h index b06462d..9518654 100644 --- a/ext/libxml/php_libxml.h +++ b/ext/libxml/php_libxml.h @@ -34,7 +34,7 @@ extern zend_module_entry libxml_module_entry; # define PHP_LIBXML_API #endif -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" #include <libxml/tree.h> #define LIBXML_SAVE_NOEMPTYTAG 1<<2 diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 246f222..de0bc76 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -28,7 +28,7 @@ #if HAVE_MBREGEX -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "php_mbregex.h" #include "mbstring.h" diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index e572b7e..82cbe72 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -40,7 +40,7 @@ #include "php_globals.h" #include "ext/standard/info.h" #include "ext/standard/php_rand.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_mcrypt_filter.h" static int le_mcrypt; @@ -452,7 +452,7 @@ static PHP_MSHUTDOWN_FUNCTION(mcrypt) /* {{{ */ } /* }}} */ -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" PHP_MINFO_FUNCTION(mcrypt) /* {{{ */ { diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index eea6348..4eff098 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -30,7 +30,7 @@ #include "php_ini.h" #include "php_globals.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_mysqli_structs.h" #include "mysqli_priv.h" diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index e137e82..db0d0ee 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -29,7 +29,7 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_mysqli_structs.h" #include "mysqli_priv.h" diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 513df95..41f34e3 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -27,7 +27,7 @@ #include "mysqlnd_statistics.h" #include "mysqlnd_charset.h" #include "mysqlnd_debug.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* TODO : diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c index f37738d..daa758c 100644 --- a/ext/mysqlnd/mysqlnd_alloc.c +++ b/ext/mysqlnd/mysqlnd_alloc.c @@ -539,7 +539,7 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D) #define SMART_STR_START_SIZE 2048 #define SMART_STR_PREALLOC 512 -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ _mysqlnd_pestrndup */ diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 406c5a6..6be8b68 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -23,7 +23,7 @@ #ifndef MYSQLND_STRUCTS_H #define MYSQLND_STRUCTS_H -#include "ext/standard/php_smart_str_public.h" +#include "zend_smart_str_public.h" #define MYSQLND_TYPEDEFED_METHODS diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c index c38975f..a16018f 100644 --- a/ext/mysqlnd/php_mysqlnd.c +++ b/ext/mysqlnd/php_mysqlnd.c @@ -27,7 +27,7 @@ #include "mysqlnd_statistics.h" #include "mysqlnd_reverse_api.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ mysqlnd_functions[] * diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index c941c8e..dba13ce 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -33,7 +33,7 @@ #include "php.h" #include "ext/standard/info.h" #include "php_ini.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #if HAVE_OCI8 diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 28afe1d..b3213f9 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -28,7 +28,7 @@ #include "ext/standard/file.h" #include "ext/standard/url.h" #include "streams/php_streams_int.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_openssl.h" #include "php_network.h" #include <openssl/ssl.h> diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 3b49bf9..67857da 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -23,7 +23,7 @@ #include "php_globals.h" #include "php_pcre.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #if HAVE_PCRE || HAVE_BUNDLED_PCRE diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 8ea4d3c..207764b 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -35,7 +35,7 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/php_standard.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/ereg/php_regex.h" #ifdef PHP_WIN32 # include "win32/time.h" diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 77df0a7..f49143b 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -35,6 +35,7 @@ #include "zend_operators.h" #include "zend_qsort.h" #include "zend_vm.h" +#include "zend_smart_str.h" #include "main/php_streams.h" #include "main/streams/php_stream_plain_wrapper.h" #include "main/SAPI.h" @@ -49,7 +50,6 @@ #include "ext/standard/md5.h" #include "ext/standard/sha1.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" #include "ext/standard/php_versioning.h" #ifndef PHP_WIN32 #include "TSRM/tsrm_strtok_r.h" diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index 23841e4..ff0671c 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -42,7 +42,7 @@ #include "php_main.h" #include "fopen_wrappers.h" #include "ext/standard/php_standard.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #ifdef __riscos__ #include <unixlib/local.h> diff --git a/ext/readline/readline_cli.h b/ext/readline/readline_cli.h index 0531c71..6e57c83 100644 --- a/ext/readline/readline_cli.h +++ b/ext/readline/readline_cli.h @@ -20,7 +20,7 @@ /* $Id$ */ #include "php.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" ZEND_BEGIN_MODULE_GLOBALS(cli_readline) char *pager; diff --git a/ext/session/session.c b/ext/session/session.c index 18c0282..63bb00e 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -48,7 +48,7 @@ #include "ext/standard/url_scanner_ex.h" #include "ext/standard/php_rand.h" /* for RAND_MAX */ #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/url.h" #include "ext/standard/basic_functions.h" #include "ext/standard/head.h" diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h index 1cba5e7..6d36792 100644 --- a/ext/soap/php_soap.h +++ b/ext/soap/php_soap.h @@ -29,7 +29,7 @@ #if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION) #include "ext/session/php_session.h" #endif -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_ini.h" #include "SAPI.h" #include <libxml/parser.h> diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index f31208c..d808271 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -6,7 +6,7 @@ #endif #include <Zend/zend_llist.h> -#include <ext/standard/php_smart_str.h> +#include <zend_smart_str.h> #ifndef PHP_WIN32 # include <sys/types.h> diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 11293eb..211180a 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -26,7 +26,7 @@ #include "php_ini.h" #include "ext/standard/info.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "zend_interfaces.h" #include "zend_exceptions.h" diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index a02cfb6..0a6f97c 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -29,7 +29,7 @@ #include "php_spl.h" #include "ext/standard/info.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "spl_functions.h" #include "spl_engine.h" #include "spl_iterators.h" diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 75f229d..dddc8c5 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -35,7 +35,7 @@ #include "spl_directory.h" #include "spl_array.h" #include "spl_exceptions.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #ifdef accept #undef accept diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 289e921..d3ce72a 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -28,7 +28,7 @@ #include "ext/standard/info.h" #include "ext/standard/php_array.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "zend_interfaces.h" #include "zend_exceptions.h" diff --git a/ext/standard/array.c b/ext/standard/array.c index de5639f..c8e7995 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -45,7 +45,7 @@ #include "basic_functions.h" #include "php_string.h" #include "php_rand.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" #ifdef HAVE_SPL #include "ext/spl/spl_array.h" #endif diff --git a/ext/standard/file.c b/ext/standard/file.c index 66b0f0f..506105b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -35,7 +35,7 @@ #include "php_open_temporary_file.h" #include "ext/standard/basic_functions.h" #include "php_ini.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" #include <stdio.h> #include <stdlib.h> diff --git a/ext/standard/filters.c b/ext/standard/filters.c index e76ddfb..bef2399 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -27,7 +27,7 @@ #include "ext/standard/basic_functions.h" #include "ext/standard/file.h" #include "ext/standard/php_string.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* {{{ rot13 stream filter implementation */ static char rot13_from[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 83e894c..d695926 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -27,7 +27,7 @@ #include "php_network.h" #include "php_ini.h" #include "ext/standard/basic_functions.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include <stdio.h> #include <stdlib.h> diff --git a/ext/standard/php_http.h b/ext/standard/php_http.h index 0351b2a..0979348 100644 --- a/ext/standard/php_http.h +++ b/ext/standard/php_http.h @@ -22,7 +22,7 @@ #define PHP_HTTP_H #include "php.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, const char *num_prefix, int num_prefix_len, diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h deleted file mode 100644 index e32def2..0000000 --- a/ext/standard/php_smart_str.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef PHP_SMART_STR_H -#define PHP_SMART_STR_H - -#include "php_smart_str_public.h" - -#include <stdlib.h> -#include <zend.h> - -#ifndef SMART_STR_PREALLOC -#define SMART_STR_PREALLOC 128 -#endif - -#ifndef SMART_STR_START_SIZE -#define SMART_STR_START_SIZE 78 -#endif - -/* wrapper */ - -#define smart_str_appends_ex(dest, src, what) \ - smart_str_appendl_ex((dest), (src), strlen(src), (what)) -#define smart_str_appends(dest, src) \ - smart_str_appendl((dest), (src), strlen(src)) -#define smart_str_appendc(dest, c) \ - smart_str_appendc_ex((dest), (c), 0) -#define smart_str_appendl(dest, src, len) \ - smart_str_appendl_ex((dest), (src), (len), 0) -#define smart_str_append(dest, src) \ - smart_str_append_ex((dest), (src), 0) -#define smart_str_sets(dest, src) \ - smart_str_setl((dest), (src), strlen(src)); -#define smart_str_append_long(dest, val) \ - smart_str_append_long_ex((dest), (val), 0) -#define smart_str_append_unsigned(dest, val) \ - smart_str_append_unsigned_ex((dest), (val), 0) - -static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, zend_bool persistent) { - size_t newlen; - if (!str->s) { - newlen = len; - str->a = newlen < SMART_STR_START_SIZE - ? SMART_STR_START_SIZE - : newlen + SMART_STR_PREALLOC; - str->s = zend_string_alloc(str->a, persistent); - str->s->len = 0; - } else { - newlen = str->s->len + len; - if (newlen >= str->a) { - str->a = newlen + SMART_STR_PREALLOC; - str->s = (zend_string *) perealloc(str->s, _STR_HEADER_SIZE + str->a + 1, persistent); - } - } - return newlen; -} - -static zend_always_inline void smart_str_free(smart_str *str) { - if (str->s) { - zend_string_release(str->s); - str->s = NULL; - } - str->a = 0; -} - -static zend_always_inline void smart_str_0(smart_str *str) { - if (str->s) { - str->s->val[str->s->len] = '\0'; - } -} - -static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, zend_bool persistent) { - size_t new_len = smart_str_alloc(dest, 1, persistent); - dest->s->val[new_len - 1] = ch; - dest->s->len = new_len; -} - -static zend_always_inline void smart_str_appendl_ex(smart_str *dest, const char *str, size_t len, zend_bool persistent) { - size_t new_len = smart_str_alloc(dest, len, persistent); - memcpy(dest->s->val + dest->s->len, str, len); - dest->s->len = new_len; -} - -static zend_always_inline void smart_str_append_ex(smart_str *dest, const smart_str *src, zend_bool persistent) { - if (src->s && src->s->len) { - smart_str_appendl_ex(dest, src->s->val, src->s->len, persistent); - } -} - -static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_long num, zend_bool persistent) { - char buf[32]; - char *result = zend_print_long_to_buf(buf + sizeof(buf) - 1, num); - smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent); -} - -static zend_always_inline void smart_str_append_unsigned_ex(smart_str *dest, zend_ulong num, zend_bool persistent) { - char buf[32]; - char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num); - smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent); -} - -static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) { - smart_str_free(dest); - smart_str_appendl(dest, src, len); -} - -#endif diff --git a/ext/standard/php_smart_str_public.h b/ext/standard/php_smart_str_public.h deleted file mode 100644 index e33348e..0000000 --- a/ext/standard/php_smart_str_public.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifndef PHP_SMART_STR_PUBLIC_H -#define PHP_SMART_STR_PUBLIC_H - -#include <sys/types.h> - -typedef struct { - zend_string *s; - size_t a; -} smart_str; - -#endif diff --git a/ext/standard/php_var.h b/ext/standard/php_var.h index 5a9aae1..9097915 100644 --- a/ext/standard/php_var.h +++ b/ext/standard/php_var.h @@ -22,7 +22,7 @@ #define PHP_VAR_H #include "ext/standard/basic_functions.h" -#include "ext/standard/php_smart_str_public.h" +#include "zend_smart_str_public.h" PHP_FUNCTION(var_dump); PHP_FUNCTION(var_export); diff --git a/ext/standard/string.c b/ext/standard/string.c index 559fb8b..b49192b 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -56,7 +56,7 @@ #include "zend_execute.h" #include "php_globals.h" #include "basic_functions.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" #include <Zend/zend_exceptions.h> #ifdef ZTS #include "TSRM.h" diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index b7c9403..71658ec 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -42,7 +42,7 @@ #define url_scanner url_scanner_ex -#include "php_smart_str.h" +#include "zend_smart_str.h" static void tag_dtor(zval *zv) { diff --git a/ext/standard/url_scanner_ex.h b/ext/standard/url_scanner_ex.h index 00dd9fb..3c5b68c 100644 --- a/ext/standard/url_scanner_ex.h +++ b/ext/standard/url_scanner_ex.h @@ -31,7 +31,7 @@ PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, co PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC); PHPAPI int php_url_scanner_reset_vars(TSRMLS_D); -#include "php_smart_str_public.h" +#include "zend_smart_str_public.h" typedef struct { /* Used by the mainloop of the scanner */ diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 28a5ca3..ce7acfa 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -40,7 +40,7 @@ #define url_scanner url_scanner_ex -#include "php_smart_str.h" +#include "zend_smart_str.h" static void tag_dtor(zval *zv) { diff --git a/ext/standard/var.c b/ext/standard/var.c index 532e53a..88a8f9e 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -28,7 +28,7 @@ #include "php.h" #include "php_string.h" #include "php_var.h" -#include "php_smart_str.h" +#include "zend_smart_str.h" #include "basic_functions.h" #include "php_incomplete_class.h" diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c index 1502178..d158366 100644 --- a/ext/sysvmsg/sysvmsg.c +++ b/ext/sysvmsg/sysvmsg.c @@ -27,7 +27,7 @@ #include "ext/standard/info.h" #include "php_sysvmsg.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" /* In order to detect MSG_EXCEPT use at run time; we have no way * of knowing what the bit definitions are, so we can't just define diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c index e0f9df3..c87be09 100644 --- a/ext/sysvshm/sysvshm.c +++ b/ext/sysvshm/sysvshm.c @@ -36,7 +36,7 @@ #include "php_sysvshm.h" #include "ext/standard/php_var.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_ini.h" /* {{{ arginfo */ diff --git a/ext/wddx/php_wddx_api.h b/ext/wddx/php_wddx_api.h index 420377e..5c47109 100644 --- a/ext/wddx/php_wddx_api.h +++ b/ext/wddx/php_wddx_api.h @@ -21,7 +21,7 @@ #ifndef PHP_WDDX_API_H #define PHP_WDDX_API_H -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str_public.h" #define WDDX_ARRAY_S "<array length='%d'>" #define WDDX_ARRAY_E "</array>" diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index be5913d..705babd 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -35,7 +35,7 @@ #include "ext/standard/php_incomplete_class.h" #include "ext/standard/base64.h" #include "ext/standard/info.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/html.h" #include "ext/standard/php_string.h" #include "ext/date/php_date.h" diff --git a/main/php_variables.c b/main/php_variables.c index c1d6953..a0acb38 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -23,7 +23,7 @@ #include "php.h" #include "ext/standard/php_standard.h" #include "ext/standard/credits.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "php_variables.h" #include "php_globals.h" #include "php_content_types.h" diff --git a/main/spprintf.c b/main/spprintf.c index 12443a7..cf730dd 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -111,7 +111,7 @@ #define FLOAT_DIGITS 6 #define EXPONENT_LENGTH 10 -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/php_smart_string.h" /* {{{ macros */ diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c index 321df14..ea13738 100644 --- a/sapi/apache2filter/php_functions.c +++ b/sapi/apache2filter/php_functions.c @@ -22,7 +22,7 @@ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "SAPI.h" diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index 9d15932..3896861 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -30,7 +30,7 @@ #include "php_variables.h" #include "SAPI.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #ifndef NETWARE #include "ext/standard/php_standard.h" #else diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index 27643b8..d9ae4d9 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -21,7 +21,7 @@ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/info.h" #include "ext/standard/head.h" #include "php_ini.h" diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 08e6caf..fe20030 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -30,7 +30,7 @@ #include <fcntl.h> -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #ifndef NETWARE #include "ext/standard/php_standard.h" #else diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index b2defe0..909e91e 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -96,7 +96,7 @@ #endif #include "ext/standard/file.h" /* for php_set_sock_blocking() :-( */ -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "ext/standard/html.h" #include "ext/standard/url.h" /* for php_url_decode() */ #include "ext/standard/php_string.h" /* for php_dirname() */ diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 1671a5b..7c03454 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -27,7 +27,7 @@ #include "php_ini.h" #include "zend_highlight.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include <sys/time.h> #include <sys/types.h> diff --git a/sapi/thttpd/thttpd_patch b/sapi/thttpd/thttpd_patch index c79ee44..1a9ed29 100644 --- a/sapi/thttpd/thttpd_patch +++ b/sapi/thttpd/thttpd_patch @@ -240,7 +240,7 @@ diff -ur thttpd-2.21b/libhttpd.c thttpd-2.21b-cool/libhttpd.c + +#define SMART_STR_USE_REALLOC + -+#include "ext/standard/php_smart_str.h" ++#include "zend_smart_str.h" static void -send_mime( httpd_conn* hc, int status, char* title, char* encodings, char* extraheads, char* type, int length, time_t mod ) diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c index 9bff4f1..783fe85 100644 --- a/sapi/tux/php_tux.c +++ b/sapi/tux/php_tux.c @@ -21,7 +21,7 @@ #include "php_main.h" #include "php_variables.h" -#include "ext/standard/php_smart_str.h" +#include "zend_smart_str.h" #include "tuxmodule.h"