Compare commits

...
199 Commits
Author SHA1 Message Date
SVN Migration e0411a0187 This commit was manufactured by cvs2svn to create tag 'php_4_4_0'. 2005-07-11 07:45:15 +00:00
Derick Rethans 7902154f46 - Go with 4.4.0. 2005-07-11 07:45:14 +00:00
Derick Rethans 44bf966ae7 - MFH: Fixed memory corruption in pg_copy_from() in case the as_null parameter
was passed. (Derick)
2005-07-05 12:50:03 +00:00
Edin Kadribasic caf18b2bfa BFN: now in the correct place :) 2005-07-02 23:07:50 +00:00
Edin Kadribasic a55d32948b BFN 2005-07-02 23:05:37 +00:00
Edin Kadribasic f5d89321e8 MFH 2005-07-02 22:53:11 +00:00
Derick Rethans 201569c7f9 - Back to -dev 2005-07-01 10:05:42 +00:00
Derick Rethans 7e1fa145ee - GO with RC2. 2005-07-01 09:54:01 +00:00
Pierre Joye d5a7368d72 - really remove xmp-rpc 1.2.2 2005-07-01 09:48:53 +00:00
Pierre Joye 97073a0517 - remove xml_rpc 1.2.2 (step #2)
- add 1.3.1 archive (step #3)
2005-07-01 09:42:15 +00:00
Pierre Joye e6dd1bee42 - update xmp_rpc to 1.3.1 (step #1/3) 2005-07-01 09:41:04 +00:00
Derick Rethans 2be36d43e8 - Added missing .cvsignore. 2005-07-01 09:35:18 +00:00
Derick Rethans cacba2613e - Backport config.m4 from HEAD so that pg_config can be used. 2005-07-01 09:10:14 +00:00
Stefan Esser b10466c3ee MFH: Also check FTP password 2005-06-27 08:27:23 +00:00
Holger Zimmermann 313ace007d Replaced PCHAR by CHAR * (not defined in pi3web_sapi header) 2005-06-26 09:17:40 +00:00
Dmitry Stogov 8301424d57 Fixed bug #28377 (debug_backtrace is intermittently passing args) 2005-06-23 12:21:01 +00:00
foobar 7d96c874b9 MFH 2005-06-21 13:07:40 +00:00
Dmitry Stogov fc4dabbbf6 Fixed bug #31213 (Sideeffects caused by fix of bug #29493) 2005-06-21 12:11:19 +00:00
Antony Dovgal 10a123f2f8 MFH: reorder and prevent memleak: bailout after free() 2005-06-20 19:59:43 +00:00
foobar 490617c780 fix VPATH testing (partial MFH) 2005-06-18 22:54:07 +00:00
foobar 97e89bfb82 BFN 2005-06-18 18:58:55 +00:00
foobar 317c7ae225 MFH 2005-06-18 18:55:12 +00:00
foobar a29aa6577d MFH 2005-06-17 16:23:04 +00:00
Dmitry Stogov a07fe81c38 Fixed bug #31402 (unserialize creates a field containing a reference when it should not) 2005-06-17 13:52:58 +00:00
foobar 1b9a2471bd MFH 2005-06-15 17:13:52 +00:00
Edin Kadribasic fd6a541974 MSVC++ 6.0 doesn't support long long type 2005-06-13 19:32:15 +00:00
Derick Rethans a0207767c4 - Back to dev 2005-06-13 14:34:26 +00:00
Derick Rethans ba7a46ba54 - Go with 4.4.0RC1. 2005-06-13 14:23:34 +00:00
foobar d233c60165 touch 2005-06-13 14:14:39 +00:00
Derick Rethans 093bc03fd5 - MFH: Fixed bug with unserialize() with "exotic" letters in class names 2005-06-13 14:13:11 +00:00
Antony Dovgal 450348fd7a MFH:
destroy session after destroying error handle
SQLT_CHR is allowed too
2005-06-13 09:37:57 +00:00
foobar 13f4cdcca7 MFH 2005-06-12 01:15:43 +00:00
foobar f4058a30fa Revert. re2c 0.9.7 obviously does not work properly (or our .re files are buggy) 2005-06-11 23:55:39 +00:00
foobar d3b74b0ec5 regenerated with re2c 0.9.7 2005-06-11 20:21:50 +00:00
foobar ddf0954eec MFH 2005-06-10 12:35:00 +00:00
Ilia Alshanetsky 544beecc55 MFH: Fixed compiler warning. 2005-06-09 16:13:34 +00:00
Dmitry Stogov 780b300fcf Fixed bug #25922 (In error handler, modifying 5th arg (errcontext) may result in seg fault) 2005-06-09 10:14:38 +00:00
Dmitry Stogov a82e35c290 Fixed memory allocation bugs in array_reduce() with initial value (#22463 & #24980) 2005-06-08 19:55:01 +00:00
foobar eb43932fb1 MFH 2005-06-08 10:34:41 +00:00
foobar 63626d1c68 MFH 2005-06-07 21:57:13 +00:00
foobar 3dc32f41a9 MFH 2005-06-07 21:40:36 +00:00
foobar 4d83ad6282 MFH 2005-06-07 17:23:12 +00:00
Derick Rethans 1a3b493d9a - MFH: Added the --disable-zend-memory-manager switch to disable the Zend
memory manager.
#- I discussed this with Dmitry today - we found it useful.
2005-06-07 13:37:33 +00:00
Derick Rethans 858745ddf9 - Fixed bug #32685, #29423 (Segfault when using assignment by reference within
function).
2005-06-07 09:57:44 +00:00
Ilia Alshanetsky a17e5fe163 MFH: Better storage size for output length. 2005-06-06 16:31:08 +00:00
Ilia Alshanetsky 44518f05f8 MFH: Fixed strval to not print notices on strval(array()). 2005-06-06 12:50:57 +00:00
Derick Rethans d1602669bc - MFH: Fixed bug #33242 (Mangled error message when stream fails). 2005-06-06 12:42:51 +00:00
Derick Rethans 76d392d3a9 - We've man pages just fine 2005-06-06 11:24:16 +00:00
Derick Rethans 94a2ab1990 - Update NEWS with the bz fix 2005-06-06 11:07:55 +00:00
Uwe Schindler ada89376b4 MFH: Fix bug #33166 for other branches and new bug #33255, no man pages for 4.4 2005-06-06 11:06:22 +00:00
Derick Rethans c479074f98 - Merge back changes which where in 4.3 but somehow didn't make it into the new
branch.
2005-06-06 10:59:47 +00:00
Edin Kadribasic e5788c2eb7 Sync with recent config.m4 changes 2005-06-06 09:38:53 +00:00
Derick Rethans 4f64bc6cfe - Commit the reference problem bug fix. 2005-06-06 09:30:09 +00:00
Derick Rethans 94801d1206 - Rename version. 2005-06-06 09:23:58 +00:00
SVN Migration 0cf43df604 This commit was manufactured by cvs2svn to create branch 'PHP_4_4'. 2005-06-02 21:32:50 +00:00
foobar a4ecfdb08c MFH: - Fixed bug #28605 (Need to use -[m]ieee option for Alpha CPUs) 2005-06-02 21:32:49 +00:00
Antony Dovgal 1a733ccbdd MFH: fix bug #33222 (segfault when CURL handle is closed in a callback). 2005-06-02 21:05:06 +00:00
Antony Dovgal 473e88e574 MFH: fix bug #33214 (odbc_next_result does not signal SQL errors with 2-statement SQL batches).
Path by rich at kastle dot com.
2005-06-02 15:42:58 +00:00
Derick Rethans 5955cb64bb - That should have been removed, not commented out. 2005-06-02 08:50:52 +00:00
Derick Rethans 0d3b976c03 - MFH: Fixed memory corruption in stristr(). 2005-06-02 08:31:38 +00:00
Ilia Alshanetsky a02c9cf4f1 MFH: Fixed bug #33210 (relax jpeg recursive loop protection). 2005-06-01 22:29:20 +00:00
foobar ca66964530 MFH: - Fixed bug #33200 (preg_replace(): magic_quotes_sybase=On makes 'e' modifier misbehave) 2005-05-31 12:56:00 +00:00
foobar b73fec0d9f MFH 2005-05-31 12:22:27 +00:00
Andrei Zmievski 1233878300 Upgrade PCRE library to 5.0. 2005-05-27 18:12:43 +00:00
Andrei Zmievski 7cb6bc0d50 MFH 2005-05-26 21:49:04 +00:00
Ilia Alshanetsky b57e6a484a MFH: Added scheme validation for parse_url(). 2005-05-26 03:56:45 +00:00
Andrei Zmievski 0943b7909a MFH (pcre cache flush) 2005-05-24 21:12:16 +00:00
Antony Dovgal 6305213066 MFH: make it compile on Win32 2005-05-24 10:14:16 +00:00
Ilia Alshanetsky 04d0a78649 MFH: Fixed bug #32810 (temporary files not using plain file wrapper). 2005-05-23 21:51:00 +00:00
Antony Dovgal 64ddf44bd5 revert by Wez's request 2005-05-23 15:37:29 +00:00
Antony Dovgal 1650db955c MFH: fix bug #32810 (fread after tmpfile() reads only 8192 bytes) 2005-05-23 11:52:44 +00:00
Antony Dovgal 4e03cdce32 MFH: fix test 2005-05-23 11:39:05 +00:00
foobar 8a6bb7e993 MFH: Upgrade bundled shtool to 2.0.1 2005-05-23 09:46:32 +00:00
foobar 0031c498a3 MFH: - Fixed bug #33017 ("make distclean" gives an error with VPATH build). 2005-05-23 09:43:59 +00:00
Ilia Alshanetsky add1f2f783 MFH: Fixed bug #29338 (unencoded spaces get ignored after certain tags). 2005-05-22 16:45:41 +00:00
Antony Dovgal cd98638298 MFH: fix compile warning 2005-05-22 12:59:29 +00:00
Rasmus Lerdorf dd5c63bc18 Fixed bug #33072 - Add a safemode/open_basedir check for runtime save_path
change
2005-05-21 19:46:34 +00:00
Grant Croker 50292aaff9 - Fixed bug #30593 (--with-ingres option generates broken Makefile). 2005-05-20 15:57:13 +00:00
Derick Rethans 456eba04a2 Update NEWS 2005-05-20 11:15:33 +00:00
Derick Rethans 379c4af44a - Fixed bug #33013: "next month" was done wrong. 2005-05-20 11:13:14 +00:00
Antony Dovgal e5f04e5d2f MFH: fix bug #32944 (Disabling session.use_cookies doesn't prevent reading session cookies) 2005-05-20 10:28:35 +00:00
foobar 30d0600769 reorder 2005-05-20 06:36:56 +00:00
Rasmus Lerdorf f0a7020898 NEWS file update for Jani 2005-05-19 16:16:44 +00:00
Rasmus Lerdorf bb9223391e Fix for bug #33057 - Don't send extraneous entity-headers on a 304 as per
RFC 2616 section 10.3.5
2005-05-19 16:14:46 +00:00
Ilia Alshanetsky f4a39b5314 Fixed bug #32802 (broken MFH) 2005-05-17 18:42:35 +00:00
Antony Dovgal 75a3ee0284 MFH: gdImageGifCtx() is always available in bundled lib 2005-05-17 12:23:09 +00:00
Antony Dovgal 4c5d775dd1 MFH: fix bug #32742 (segmentation fault when the stream with a wrapper is not closed) 2005-05-16 08:55:31 +00:00
Antony Dovgal 804d8f2183 MFH: fix bug #29975 (memory leaks when set_error_handler() is used inside error handler) 2005-05-13 23:11:17 +00:00
Rasmus Lerdorf e48af012eb I am reverting this patch:
http://cvs.php.net/diff.php/php-src/main/php_variables.c?r1=1.45.2.9&r2=1.45.2.10&ty=u

It consistently causes this segfault:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 2837)]
0x405313ff in zend_hash_find (ht=0x8266682, arKey=0x8266660 "fud_session_1109269364_referer_id", nKeyLength=34, pData=0x0)
    at /home/rasmus/php43/Zend/zend_hash.c:897
897                                     *pData = p->pData;
(gdb) bt
#0  0x405313ff in zend_hash_find (ht=0x8266682, arKey=0x8266660 "fud_session_1109269364_referer_id", nKeyLength=34, pData=0x0)
    at /home/rasmus/php43/Zend/zend_hash.c:897
#1  0x4050c39c in php_register_variable_ex (var=0x8266660 "fud_session_1109269364_referer_id", val=0xbffff730, track_vars_array=0x823e908)
    at /home/rasmus/php43/main/php_variables.c:201
#2  0x4050c031 in php_register_variable_safe (var=0x823e908 "?m\031\b", strval=0x0, str_len=0, track_vars_array=0x823e908)
    at /home/rasmus/php43/main/php_variables.c:56
#3  0x4050c6fb in php_default_treat_data (arg=2, str=0x0, destArray=0x823e908) at /home/rasmus/php43/main/php_variables.c:318
#4  0x40502af2 in php_hash_environment () at /home/rasmus/php43/main/main.c:1442
#5  0x4050187f in php_request_startup () at /home/rasmus/php43/main/main.c:936
#6  0x4053e746 in apache_php_module_main (r=0x818c894, display_source_mode=0) at /home/rasmus/php43/sapi/apache/sapi_apache.c:33
#7  0x4053f1e9 in send_php (r=0x818c894, display_source_mode=0, filename=0x0) at /home/rasmus/php43/sapi/apache/mod_php4.c:621
#8  0x4053f36d in send_parsed_php (r=0x823e908) at /home/rasmus/php43/sapi/apache/mod_php4.c:636
2005-05-13 05:27:14 +00:00
Antony Dovgal a570698425 MFH: fix #33019 (socket errors cause memory leaks in php_strerror())
patch by jwozniak23 at poczta dot onet dot pl
2005-05-12 16:27:22 +00:00
Antony Dovgal 4ca2a45a0c use & and check for the right value of result_type
btw, nobody noticed that result_type wasn't ever working in 4.3, because it was absent in parse_params()..
also, I prefer "Tony" just for uniformity =)
2005-05-10 23:15:06 +00:00
foobar 0d12de2d75 Tony or Antony? :) 2005-05-10 21:47:11 +00:00
Antony Dovgal 180e1501bb MFH: fix #32904 (pg_get_notify() ignores result_type parameter) 2005-05-10 20:14:11 +00:00
foobar d6597ad37d - Fixed bugs #32800, #32830 (ext/odbc: Problems with 64bit systems) 2005-05-10 13:21:36 +00:00
foobar 295719fa32 Revert the memleak fix due to net-snmp oddity (see also bug #32613) 2005-05-10 11:21:19 +00:00
Georg Richter 6e516e2214 fix for bug #32116 (mysql compressed connection doesn't work under win) 2005-05-09 17:45:50 +00:00
foobar e213ff37c3 MFH: - getlogin() / getgroups() are not necessarily available everywhere 2005-05-09 12:16:19 +00:00
foobar ae85316906 Remove dos crap 2005-05-09 07:08:42 +00:00
foobar 79cbb4b143 MFH: - Fixed putenv() under win32 (see bug #32957) 2005-05-08 19:50:39 +00:00
Rasmus Lerdorf fcfd9f78ab Oops, wrong place. It was in the logo stuff instead. 2005-05-08 17:20:57 +00:00
Rasmus Lerdorf 0b7fbabd80 Let's not XSS ourself at least 2005-05-08 17:09:24 +00:00
foobar 49b5d46a76 MFH: - Fixed bug #32932 (Oracle LDAP: ldap_get_entries invalid pointer)
# also partial sync with HEAD (just some ws/cs changes)
2005-05-08 16:06:25 +00:00
Wez Furlong 01ee1225dc Fix #32974 2005-05-07 14:55:39 +00:00
Rasmus Lerdorf c227ea05c4 Fix what I assume was a typo 2005-05-07 09:25:31 +00:00
Ilia Alshanetsky 6b582b2c85 MFH: Check ftp user name for control characters. 2005-05-06 18:43:31 +00:00
Antony Dovgal 91f96ef1d7 MFH: fix off-by-one in _php_image_output()
and prevent such errors in php_do_open_temporary_file()
2005-05-06 16:51:54 +00:00
Ilia Alshanetsky 394662b4a2 MFH: Fixed bug #32936 (http redirects URLs are not checked for control chars). 2005-05-06 02:19:04 +00:00
Ilia Alshanetsky 65af72474e Bug fixing news. 2005-05-03 01:30:19 +00:00
Pierre Joye 0512d70c33 - MFH (#32893, imagettf crashes)
uses long for zval
2005-05-02 09:39:26 +00:00
Pierre Joye 2253f7dbf7 - #32891, init old y positions to non possible values. -1 being used if the
center start a (x,0)
2005-05-01 05:45:55 +00:00
foobar c006bbb006 MFH: - Fix problems with phpized ext/imap 2005-04-30 09:31:09 +00:00
foobar a4f461f9df MFH: - Added man pages for "phpize" and "php-config" scripts. (Jakub Vrana) 2005-04-30 04:28:24 +00:00
foobar 681c35bc17 MFH 2005-04-30 04:12:24 +00:00
foobar 58ba05c901 MFH: Moved phpextdist to dev/ 2005-04-30 03:02:10 +00:00
foobar 5b6edac5bc MFH 2005-04-28 14:24:47 +00:00
Antony Dovgal 49470fdc74 MFH: handle unsupported datatypes and prevent segfault 2005-04-28 14:13:08 +00:00
foobar 3f573827c2 MFH 2005-04-28 13:14:46 +00:00
Rob Richards 2f69536e0e BFN 2005-04-28 12:20:13 +00:00
Rob Richards fbf441a447 MFH: Fix bug #32245 (xml_parser_free() in function assigned to the xml parser
gives a segfault)
2005-04-28 12:19:38 +00:00
foobar 58a6e8f921 MFH 2005-04-27 23:27:53 +00:00
Andrey Hristov c9a701c4d1 change names 2005-04-27 21:22:18 +00:00
Ilia Alshanetsky e000385d10 MFH: Fixed bug #32813 (parse_url() does not handle scheme-only urls properly). 2005-04-25 23:49:27 +00:00
foobar 4be5f46e50 MFH: Revert. Nokia didn't pay me enough. :) 2005-04-25 21:22:48 +00:00
Stanislav Malyshev 218f2b42e0 rm unneeded 2005-04-25 12:04:35 +00:00
Stanislav Malyshev 3158315a54 fix for #32773 2005-04-25 12:03:53 +00:00
Stanislav Malyshev cc83a160ee Fix #32773 and made right fix for GMP FPEs 2005-04-25 12:03:27 +00:00
Stanislav Malyshev ba9ef20412 add test 2005-04-25 11:18:44 +00:00
Dmitry Stogov 1296a72aff Test case fnd news entriey for bug #29944 2005-04-25 10:51:39 +00:00
Stanislav Malyshev 3c7723a674 Remove broken fix - second operand of GMP operation certainly can be 0 in general case 2005-04-25 10:21:58 +00:00
Dmitry Stogov e3c797aed4 Fixed call to estrndup() with invalid length 2005-04-25 06:14:50 +00:00
Ilia Alshanetsky 44a7348d22 MFH: Fixed bug #32802 (General cookie overrides more specific cookie). 2005-04-24 18:10:30 +00:00
foobar a67ec786cc typo 2005-04-23 23:57:40 +00:00
foobar fbd807a7b8 MFH: fix memleak 2005-04-23 21:15:39 +00:00
foobar 95c6aa35c7 MFH: - Fixed bug #32111 (Cookies can also be separated by colon) 2005-04-23 20:34:15 +00:00
Joe Orton 362db6cec6 MFH: Fixed bug #32797 (invalid C code in xmlrpc extension). 2005-04-22 11:57:53 +00:00
Antony Dovgal ba4e292b20 add missing entries in .cvsignore 2005-04-22 09:22:23 +00:00
Antony Dovgal 7c33078b31 fix C++ comments 2005-04-22 09:21:49 +00:00
Andrey Hristov 5393ff76f4 MFH
introduce INT_MAX and INT_SIZE
#would be wonderful if the doc team takes care of that
#defined since 4.3.12, missing in 5.0.0-5.0.4, available in 5.0.5+
2005-04-22 07:27:45 +00:00
Masaki Fujimoto 588fc6e846 - MFH: Fix mbfl_encoding_detector_feed() and mbfl_mbfl_identify_encoding() behaviour 2005-04-22 05:03:38 +00:00
foobar 1c32084d9d MFH 2005-04-21 23:02:23 +00:00
foobar 078f3abb05 MFH: - Fixed bug #32647 (Using register_shutdown_function() with invalid callback can crash PHP) 2005-04-21 14:47:13 +00:00
foobar 8fe6e70d72 Fix test 2005-04-21 14:38:27 +00:00
foobar 6567ab4932 MFH: Added test for bug #32647 2005-04-21 14:18:51 +00:00
Brian France a9c0b4eaa6 MFH: Added support for .cc files in extensions. 2005-04-20 20:51:45 +00:00
foobar cd387e3f9a MFH 2005-04-19 22:06:50 +00:00
foobar 8fd7c98196 MFH: - Remove relic 2005-04-17 13:37:29 +00:00
foobar 52105b88b4 - Fixed bug #32730 (ext/crack.c fails to compile with cracklib-2.8.3) 2005-04-17 13:27:18 +00:00
foobar 0bf8ea8b03 MFH: - Fixed bug #31887 (ISAPI: Custom 5xx error does not return correct HTTP response message) 2005-04-17 03:39:39 +00:00
foobar 35b7a1e3f7 retype 2005-04-16 12:25:36 +00:00
foobar 89347c7c20 typofix 2005-04-16 12:15:48 +00:00
Uwe Schindler bd36484d85 MFH: use streams api for md5_file() and sha1_file() 2005-04-16 09:49:53 +00:00
foobar 73bc800428 MFH 2005-04-15 22:25:29 +00:00
foobar 6b38c14911 MFH 2005-04-15 22:20:43 +00:00
foobar 626d78118d MFH: - Use correct type (bug #32720) 2005-04-15 22:08:43 +00:00
Uwe Schindler a9c24d9728 correct copy/paste problem 2005-04-15 09:44:45 +00:00
Uwe Schindler 9cfdc3a4da correct copy/paste problem 2005-04-15 09:24:45 +00:00
Uwe Schindler 080e6fd89f MFH: fix various solaris problems by replacing stdio with posix io where possible 2005-04-15 09:15:03 +00:00
foobar 7f1754653c - Regenerated with re2c 0.9.6 (fixes severe bugs) 2005-04-14 22:41:39 +00:00
foobar 7f84c5e32b MFH: - Add support for latest Birdstep 2005-04-14 21:17:49 +00:00
foobar 7e4495a66f BFN 2005-04-14 15:48:38 +00:00
foobar 2e63e4f923 MFH: Fixes & cleanup + some minor new features 2005-04-14 15:41:50 +00:00
Ilia Alshanetsky 2745fef293 Fixed bug #31583 (php_std_date() uses short day names in non-y2k_compliance
mode).

Patch by: mike at php dot net
2005-04-14 13:30:27 +00:00
Antony Dovgal febe0e0caf MFH: disable pg_cmdtuples() too, if there is no pg_affected_rows() 2005-04-13 22:12:06 +00:00
Derick Rethans c1e9d3433d - Fixed bug #32699 (pg_affected_rows() was defined when it was not available). 2005-04-13 21:27:35 +00:00
Antony Dovgal e58545fde9 MFH: add testcase for bug #30833 2005-04-13 08:24:12 +00:00
Moriyoshi Koizumi 40d6477fe5 - MFH: commit the pending patch (bug #32311). 2005-04-13 08:08:28 +00:00
Frank M. Kromann e681512beb MFH: Fix for #32682. Error on module shutdown when called from activescript 2005-04-12 17:46:45 +00:00
foobar b3acf2c5c4 MFH: - Fixed bug #32587 (Apache2: errors sent to error_log do not include timestamps)
# Also nuked the deprecated APLOG_NOERRNO's
2005-04-08 20:35:02 +00:00
foobar 2ed05398fc regenerated with re2c 0.9.4 2005-04-08 20:18:21 +00:00
foobar a5fa2525c8 typo 2005-04-08 20:17:41 +00:00
foobar 4ee1f9830d Missing $Id$ tag 2005-04-08 20:16:41 +00:00
Ilia Alshanetsky 3aaec591c2 MFH: Missing part of the patch for bug #32589 2005-04-08 15:04:52 +00:00
foobar 5ccc67cc8a MFH: for the s*printf* stuff 2005-04-08 13:37:53 +00:00
foobar 2b865616f1 MFH and Fixes bug #32482 (ap_php_snprintf broken) 2005-04-08 05:44:53 +00:00
Jon Parise 03aa84f955 MFH 1.36: Spell "overridden" correctly. 2005-04-07 23:33:50 +00:00
foobar 83b353de2c BFN 2005-04-07 22:24:21 +00:00
foobar 0a9d87e630 - Fixed bug #32591 (ext/mysql: Unsatisfied symbol: ntohs with HP-UX) 2005-04-07 22:23:01 +00:00
foobar 4942272466 MFH 2005-04-07 22:04:26 +00:00
foobar 001a39d7fb MFH 2005-04-07 20:49:01 +00:00
Uwe Schindler 85a028b891 Bug #32614 - prevent from crahsing with segfault on solaris if fdopen() fails - this fixes NOT the stdio-problem on solaris! 2005-04-07 07:28:08 +00:00
foobar 9a6cf59744 MFH 2005-04-06 22:16:11 +00:00
Antony Dovgal 6dce4e78ab MFH: remove proto 2005-04-05 20:32:01 +00:00
Ilia Alshanetsky 6f871656df MFH: Fixed bug #32589 (Possible crash inside imap_mail_compose, with charsets). 2005-04-05 14:49:10 +00:00
Sara Golemon a4d454fdcf MFH rev 1.72 (of main/streams/streams.c) 2005-04-04 20:26:49 +00:00
foobar 782736f277 update 2005-04-04 18:53:47 +00:00
Antony Dovgal 7350e8b884 fix #32567 (ext/gmp fails to compile with thread safety enabled) 2005-04-04 16:30:42 +00:00
Uwe Schindler 34486b7aae Bug #32491 (File upload error - unable to create a temporary file) - Changing file upload from stdio to posix 2005-04-04 14:59:58 +00:00
Ilia Alshanetsky fbdc2a9d10 MFH: Fixed bug #32530 (chunk_split() does not append endstr if chunklen is
longer then the original string).
2005-04-03 18:09:55 +00:00
Antony Dovgal a384315b3a MFH: fix typo 2005-04-03 13:06:58 +00:00
Antony Dovgal 68e170bec8 MFH: fix output_reset_rewrite_vars() returning false 2005-04-03 12:20:51 +00:00
foobar 34a310de8c - Sync with HEAD:
. php_error -> php_error_docref (fixes test)
  . pval -> zval
  . use modern parameter parsing
# No new functionality was added!
2005-04-03 11:39:43 +00:00
foobar 430b4a6531 MFH 2005-04-03 11:18:05 +00:00
Greg Beaver d7d721c96c allow local install, remove -n switch 2005-04-02 23:52:12 +00:00
foobar 50a7757f0c MFH 2005-04-02 23:19:53 +00:00
foobar e528918061 MFH 2005-04-02 23:04:41 +00:00
foobar 40ebf7dbc1 - Fixed bug #32538 (ext/swf/swf.c does not compile with gcc-3.4.x or newer) 2005-04-02 06:03:14 +00:00
foobar 70a222560d MFH: Added SORT_LOCALE_STRING for array sorting 2005-03-31 08:18:40 +00:00
foobar 71e6b9e504 MFH: c++ fix 2005-03-31 07:40:30 +00:00
Ilia Alshanetsky 8b06c5cda1 back to dev. 2005-03-30 22:10:25 +00:00
154 changed files with 23284 additions and 3656 deletions

No files matched your search

+1 -1
View File
@@ -71,7 +71,7 @@ clean:
distclean: clean
rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php4.spec sapi/apache/libphp4.module buildmk.stamp
egrep define'.*include/php' configure|sed 's/.*>//'|xargs rm -f
egrep define'.*include/php' $(top_srcdir)/configure|sed 's/.*>//'|xargs rm -f
find . -name Makefile | xargs rm -f
.PHONY: all clean install distclean test
+85
View File
@@ -1,5 +1,90 @@
PHP 4 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
11 Jul 2005, Version 4.4.0
- Added man pages for "phpize" and "php-config" scripts. (Jakub Vrana)
- Added support for .cc files in extensions. (Brian)
- Added the sorting flag SORT_LOCALE_STRING to the sort() functions which makes
them sort based on the current locale. (Derick)
- Changed sha1_file() and md5_file() functions to use streams instead of
low level IO. (Uwe)
- Fixed memory corruptions when using references in a wrong way. (Marcus,
Dmitry, Derick)
- Fixed memory corruption in pg_copy_from() in case the as_null parameter was
passed. (Derick)
- Fixed memory corruption in stristr(). (Derick)
- Fixed bug #32685, #29423 (Segfault when using assignment by reference within
function). (Dmitry, Derick)
- Fixed bug #33242 (Mangled error message when stream fails). (Derick)
- Fixed bug #33222 (segfault when CURL handle is closed in a callback). (Tony)
- Fixed bug #33214 (odbc_next_result does not signal SQL errors with
2-statement SQL batches). (rich at kastle dot com, Tony)
- Fixed bug #33210 (relax jpeg recursive loop protection). (Ilia)
- Fixed bug #33200 (preg_replace(): magic_quotes_sybase=On makes 'e' modifier
misbehave). (Jani)
- Fixed bug #33150 (shtool: insecure temporary file creation). (Jani)
- Fixed bug #33072 (Add a safemode/open_basedir check for runtime save_path
change) (Rasmus)
- Fixed bug #33070 (Improved performance of bzdecompress() by several orders
of magnitude). (Ilia)
- Fixed bug #33057 (Don't send extraneous entity-headers on a 304 as per
RFC 2616 section 10.3.5) (Rasmus, Choitel)
- Fixed bug #33019 (socket errors cause memory leaks in php_strerror()).
(jwozniak23 at poczta dot onet dot pl, Tony).
- Fixed bug #33017 ("make distclean" gives an error with VPATH build). (Jani)
- Fixed bug #33013 ("next month" was handled wrong while parsing dates).
(Derick)
- Fixed bug #32974 (pcntl calls malloc() from a signal handler). (Wez)
- Fixed bug #32944 (Disabling session.use_cookies doesn't prevent reading
session cookies). (Jani, Tony)
- Fixed bug #32936 (http redirects URLs are not checked for control chars). (Ilia)
- Fixed bug #32932 (Oracle LDAP: ldap_get_entries invalid pointer). (Jani)
- Fixed bug #32904 (pg_get_notify() ignores result_type parameter). (Tony)
- Fixed bug #32813 (parse_url() does not handle scheme-only urls properly). (Ilia)
- Fixed bug #32810 (temporary files not using plain file wrapper). (Ilia)
- Fixed bug #32802 (General cookie overrides more specific cookie). (Ilia)
- Fixed bugs #32800, #32830 (ext/odbc: Problems with 64bit systems). (Jani)
- Fixed bug #32773 (GMP functions break when second parameter is 0). (Stas)
- Fixed bug #32742 (segmentation fault when the stream with a wrapper
is not closed). (Tony, Dmitry)
- Fixed bug #32730 (ext/crack.c fails to compile with cracklib-2.8.3). (Jani)
- Fixed bug #32670 (foreach() does not issue warning on unset array arg). (Ilia)
- Fixed bug #32699 (pg_affected_rows() was defined when it was not available).
(Derick)
- Fixed bug #32682 (ext/mssql: Error on module shutdown when called from
activescript). (Frank)
- Fixed bug #32647 (Using register_shutdown_function() with invalid callback
can crash PHP). (Jani)
- Fixed bug #32591 (ext/mysql: Unsatisfied symbol: ntohs with HP-UX). (Jani)
- Fixed bug #32589 (Possible crash inside imap_mail_compose, with charsets).
(Ilia)
- Fixed bug #32587 (Apache2: errors sent to error_log do not include
timestamps). (Jani)
- Fixed bug #32567 (ext/gmp fails to compile in threadsafe mode). (Tony)
- Fixed bug #32538 (ext/swf/swf.c does not compile with gcc-3.4.x or newer).
(adam dot greenfield at gmail dot com)
- Fixed bug #32530 (chunk_split() does not append endstr if chunklen is
longer then the original string). (Ilia)
- Fixed bug #32491 (File upload error - unable to create a temporary file).
(Uwe Schindler)
- Fixed bug #32311 (mb_encode_mimeheader() does not properly escape characters).
(Moriyoshi)
- Fixed bug #32245 (xml_parser_free() in a function assigned to the xml parser
gives a segfault). (Rob)
- Fixed bug #32116 (mysql compressed connection doesn't work under windows)
(Georg)
- Fixed bug #31887 (ISAPI: Custom 5xx error does not return correct HTTP
response message). (Jani)
- Fixed bug #31583 (php_std_date() uses short day names in non-y2k_compliance mode).
(mike at php dot net)
- Fixed bug #31213 (Sideeffects caused by fix of bug #29493). (Dmitry)
- Fixed bug #30052 (Crash on shutdown after odbc_pconnect()). (Edin)
- Fixed bug #29975 (memory leaks when set_error_handler() is used inside error
handler). (Tony)
- Fixed bug #29944 (Function defined in switch, crashes). (Dmitry)
- Fixed bug #29338 (unencoded spaces get ignored after certain tags). (Ilia)
- Fixed bug #28605 (Need to use -[m]ieee option for Alpha CPUs). (Jani)
- Fixed bug #28377 (debug_backtrace is intermittently passing args). (Dmitry)
31 Mar 2005, Version 4.3.11
- Added Oracle Instant Client support. (cjbj at hotmail dot com, Tony)
- Added checks for negative values to gmp_sqrt(), gmp_powm(), gmp_sqrtrem()
+5 -1
View File
@@ -143,7 +143,7 @@ dnl append to the array which has been dynamically chosen at m4 time
dnl choose the right compiler/flags/etc. for the source-file
case $ac_src in
*.c[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
*.cpp[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;;
*.cpp|*.cc[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;;
esac
dnl create a rule for the object/source combo
@@ -1684,6 +1684,10 @@ AC_DEFUN([PHP_SETUP_OPENSSL],[
unset OPENSSL_INCDIR
unset OPENSSL_LIBDIR
dnl Empty variable means 'no'
test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
dnl Fallbacks for different configure options
if test "$PHP_OPENSSL" != "no"; then
PHP_OPENSSL_DIR=$PHP_OPENSSL
+6 -3
View File
@@ -14,7 +14,7 @@
# | Author: Sascha Schumann <sascha@schumann.cx> |
# +----------------------------------------------------------------------+
#
# $Id$
# $Id$
#
include generated_lists
@@ -32,6 +32,9 @@ acconfig_h_SOURCES = acconfig.h.in $(config_h_files)
targets = $(TOUCH_FILES) configure $(config_h_in)
PHP_AUTOCONF ?= 'autoconf'
PHP_AUTOHEADER ?= 'autoheader'
SUPPRESS_WARNINGS ?= 2>&1 | (egrep -v '(AC_TRY_RUN called without default to allow cross compiling|AC_PROG_CXXCPP was called before AC_PROG_CXX|defined in acinclude.m4 but never used|AC_PROG_LEX invoked multiple times|AC_DECL_YYTEXT is expanded from...|the top level)'||true)
all: $(targets)
@@ -45,7 +48,7 @@ $(config_h_in): configure acconfig.h
# correctly otherwise (timestamps are not updated)
@echo rebuilding $@
@rm -f $@
autoheader $(SUPPRESS_WARNINGS)
$(PHP_AUTOHEADER) $(SUPPRESS_WARNINGS)
$(TOUCH_FILES):
touch $(TOUCH_FILES)
@@ -56,5 +59,5 @@ aclocal.m4: configure.in acinclude.m4
configure: aclocal.m4 configure.in $(config_m4_files)
@echo rebuilding $@
autoconf $(SUPPRESS_WARNINGS)
$(PHP_AUTOCONF) $(SUPPRESS_WARNINGS)
+10 -3
View File
@@ -16,15 +16,20 @@
# | Sascha Schumann <sascha@schumann.cx> |
# +----------------------------------------------------------------------+
#
# $Id: buildcheck.sh,v 1.21.2.11 2005-01-20 01:43:18 sniper Exp $
# $Id: buildcheck.sh,v 1.21.2.13 2005-04-07 23:33:50 jon Exp $
#
echo "buildconf: checking installation..."
stamp=$1
# Allow the autoconf executable to be overridden by $PHP_AUTOCONF.
if test -z "$PHP_AUTOCONF"; then
PHP_AUTOCONF='autoconf'
fi
# autoconf 2.13 or newer
ac_version=`autoconf --version 2>/dev/null|head -n 1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
ac_version=`$PHP_AUTOCONF --version 2>/dev/null|head -n 1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
if test -z "$ac_version"; then
echo "buildconf: autoconf not found."
echo " You need autoconf version 2.13 or newer installed"
@@ -42,7 +47,9 @@ echo "buildconf: autoconf version $ac_version (ok)"
fi
if test "$1" = "2" && test "$2" -ge "50"; then
echo "buildconf: running cvsclean."
echo "buildconf: Your version of autoconf likely contains buggy cache code."
echo " Running cvsclean for you."
echo " To avoid this, install autoconf-2.13 and automake-1.5."
./cvsclean
stamp=
fi
+228 -151
View File
@@ -1,12 +1,12 @@
#!/bin/sh
##
## GNU shtool -- The GNU Portable Shell Tool
## Copyright (c) 1994-2002 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 1994-2005 Ralf S. Engelschall <rse@engelschall.com>
##
## See http://www.gnu.org/software/shtool/ for more information.
## See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
##
## Version: 1.6.2 (02-Nov-2002)
## Version: 2.0.2 (15-Jun-2005)
## Contents: 4/19 available modules
##
@@ -54,7 +54,7 @@
## rotate Logfile rotation
## tarball Roll distribution tarballs
## subst Apply sed(1) substitution operations
## guessos Simple operating system guesser
## platform Platform Identification Utility
## arx Extended archive command
## slo Separate linker options by library class
## scpp Sharing C Pre-Processor
@@ -66,9 +66,9 @@ if [ $# -eq 0 ]; then
echo "$0:Hint: run \`$0 -h' for usage" 1>&2
exit 1
fi
if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
echo "This is GNU shtool, version 1.6.2 (02-Nov-2002)"
echo "Copyright (c) 1994-2002 Ralf S. Engelschall <rse@engelschall.com>"
if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then
echo "This is GNU shtool, version 2.0.2 (15-Jun-2005)"
echo "Copyright (c) 1994-2005 Ralf S. Engelschall <rse@engelschall.com>"
echo "Report bugs to <bug-shtool@gnu.org>"
echo ''
echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
@@ -80,7 +80,7 @@ if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
echo ' -r, --recreate recreate this shtool script via shtoolize'
echo ''
echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
echo ' echo [-n|--newline] [-e|--expand] [<str> ...]'
echo ' echo [-n|--newline] [-e|--expand] [<string> ...]'
echo ' install [-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy]'
echo ' [-C|--compare-copy] [-s|--strip] [-m|--mode <mode>]'
echo ' [-o|--owner <owner>] [-g|--group <group>] [-e|--exec'
@@ -106,17 +106,21 @@ if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
echo ' rotate [-v|--verbose] [-t|--trace] [-f|--force] [-n|--num-files'
echo ' <count>] [-s|--size <size>] [-c|--copy] [-r|--remove]'
echo ' [-a|--archive-dir <dir>] [-z|--compress [<tool>:]<level>]'
echo ' [-b|--background] [-d|--delay] [-p|--pad <len>] [-o|--owner'
echo ' <owner>] [-g|--group <group>] [-m|--mode <mode>] [-M|--migrate'
echo ' [-b|--background] [-d|--delay] [-p|--pad <len>] [-m|--mode'
echo ' <mode>] [-o|--owner <owner>] [-g|--group <group>] [-M|--migrate'
echo ' <cmd>] [-P|--prolog <cmd>] [-E|--epilog <cmd>] <file> [...]'
echo ' tarball [-t|--trace] [-v|--verbose] [-o|--output <tarball>]'
echo ' [-c|--compress <prog>] [-d|--directory <dir>] [-u|--user'
echo ' <user>] [-g|--group <group>] [-e|--exclude <pattern>]'
echo ' <path> [<path> ...]'
echo ' subst [-v|--verbose] [-t|--trace] [-n|--nop] [-s|--stealth]'
echo ' [-i|--interactive] [-b|--backup <ext>] [-e|--exec <cmd>]'
echo ' [-f|--file <cmd-file>] [<file>] [...]'
echo ' guessos '
echo ' subst [-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning]'
echo ' [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup'
echo ' <ext>] [-e|--exec <cmd>] [-f|--file <cmd-file>] [<file>]'
echo ' [...]'
echo ' platform [-F|--format <format>] [-S|--sep <string>] [-C|--conc'
echo ' <string>] [-L|--lower] [-U|--upper] [-v|--verbose]'
echo ' [-c|--concise] [-n|--no-newline] [-t|--type <type>]'
echo ' [-V|--version] [-h|--help]'
echo ' arx [-t|--trace] [-C|--command <cmd>] <op> <archive> [<file>'
echo ' ...]'
echo ' slo [-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib>'
@@ -131,15 +135,15 @@ if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
echo ''
exit 0
fi
if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then
echo "GNU shtool 1.6.2 (02-Nov-2002)"
if [ ".$1" = ".-v" ] || [ ".$1" = ".--version" ]; then
echo "GNU shtool 2.0.2 (15-Jun-2005)"
exit 0
fi
if [ ".$1" = ".-r" -o ".$1" = ."--recreate" ]; then
if [ ".$1" = ".-r" ] || [ ".$1" = ".--recreate" ]; then
shtoolize -oshtool echo install mkdir path
exit 0
fi
if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then
if [ ".$1" = ".-d" ] || [ ".$1" = ".--debug" ]; then
shift
set -x
fi
@@ -166,7 +170,7 @@ gen_tmpfile=no
case $tool in
echo )
str_tool="echo"
str_usage="[-n|--newline] [-e|--expand] [<str> ...]"
str_usage="[-n|--newline] [-e|--expand] [<string> ...]"
arg_spec="0+"
opt_spec="n.e."
opt_alias="n:newline,e:expand"
@@ -261,7 +265,7 @@ eval `echo h.$opt_spec |\
# parse option alias string
eval `echo h:help,$opt_alias |\
tr 'x-' 'x_' | sed -e 's/\([a-zA-Z0-9]\):\([^,]*\),*/opt_ALIAS_\2=\1;/g'`
sed -e 's/-/_/g' -e 's/\([a-zA-Z0-9]\):\([^,]*\),*/opt_ALIAS_\2=\1;/g'`
# interate over argument line
opt_PREV=''
@@ -286,12 +290,12 @@ while [ $# -gt 0 ]; do
--[a-zA-Z0-9]*=*)
eval `echo "x$1" |\
sed -e 's/^x--\([a-zA-Z0-9-]*\)=\(.*\)$/opt_OPT="\1";opt_ARG="\2"/'`
opt_STR=`echo $opt_OPT | tr 'x-' 'x_'`
opt_STR=`echo $opt_OPT | sed -e 's/-/_/g'`
eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
;;
--[a-zA-Z0-9]*)
opt_OPT=`echo "x$1" | cut -c4-`
opt_STR=`echo $opt_OPT | tr 'x-' 'x_'`
opt_STR=`echo $opt_OPT | sed -e 's/-/_/g'`
eval "opt_OPT=\${opt_ALIAS_${opt_STR}-${opt_OPT}}"
opt_ARG=''
;;
@@ -315,8 +319,8 @@ while [ $# -gt 0 ]; do
# determine whether option needs an argument
eval "opt_MODE=\$opt_MODE_${opt_OPT}"
if [ ".$opt_ARG" = . -a ".$opt_ARG_OK" != .yes ]; then
if [ ".$opt_MODE" = ".:" -o ".$opt_MODE" = ".+" ]; then
if [ ".$opt_ARG" = . ] && [ ".$opt_ARG_OK" != .yes ]; then
if [ ".$opt_MODE" = ".:" ] || [ ".$opt_MODE" = ".+" ]; then
opt_PREV="$opt_OPT"
continue
fi
@@ -375,6 +379,7 @@ esac
# establish a temporary file on request
if [ ".$gen_tmpfile" = .yes ]; then
# create (explicitly) secure temporary directory
if [ ".$TMPDIR" != . ]; then
tmpdir="$TMPDIR"
elif [ ".$TEMPDIR" != . ]; then
@@ -382,12 +387,40 @@ if [ ".$gen_tmpfile" = .yes ]; then
else
tmpdir="/tmp"
fi
tmpfile="$tmpdir/.shtool.$$"
rm -f $tmpfile >/dev/null 2>&1
touch $tmpfile
chmod 600 $tmpfile
tmpdir="$tmpdir/.shtool.$$"
( umask 077
rm -rf "$tmpdir" >/dev/null 2>&1 || true
mkdir "$tmpdir" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$msgprefix:Error: failed to create temporary directory \`$tmpdir'" 1>&2
exit 1
fi
)
# create (implicitly) secure temporary file
tmpfile="$tmpdir/shtool.tmp"
touch "$tmpfile"
fi
# utility function: map string to lower case
util_lower () {
echo "$1" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
}
# utility function: map string to upper case
util_upper () {
echo "$1" | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
}
# cleanup procedure
shtool_exit () {
rc="$1"
if [ ".$gen_tmpfile" = .yes ]; then
rm -rf "$tmpdir" >/dev/null 2>&1 || true
fi
exit $rc
}
##
## DISPATCH INTO SCRIPT BODY
##
@@ -397,12 +430,11 @@ case $tool in
echo )
##
## echo -- Print string with optional construct expansion
## Copyright (c) 1998-2002 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for WML as buildinfo
## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
text="$*"
# check for broken escape sequence expansion
seo=''
bytes=`echo '\1' | wc -c | awk '{ printf("%s", $1); }'`
@@ -412,18 +444,18 @@ echo )
seo='-E'
fi
fi
# check for existing -n option (to suppress newline)
minusn=''
bytes=`echo -n 123 2>/dev/null | wc -c | awk '{ printf("%s", $1); }'`
if [ ".$bytes" = .3 ]; then
minusn='-n'
fi
# determine terminal bold sequence
term_bold=''
term_norm=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[Bb]'`" != . ]; then
if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[Bb]'`" != . ]; then
case $TERM in
# for the most important terminal types we directly know the sequences
xterm|xterm*|vt220|vt220*)
@@ -459,96 +491,139 @@ echo )
break
fi
done
if [ ".$term_bold" != . -a ".$term_norm" != . ]; then
if [ ".$term_bold" != . ] && [ ".$term_norm" != . ]; then
break;
fi
done
;;
esac
if [ ".$term_bold" = . -o ".$term_norm" = . ]; then
if [ ".$term_bold" = . ] || [ ".$term_norm" = . ]; then
echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2
term_bold=''
term_norm=''
fi
fi
# determine user name
username=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uUgG]'`" != . ]; then
username="$LOGNAME"
if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[uUgG]'`" != . ]; then
username="`(id -un) 2>/dev/null`"
if [ ".$username" = . ]; then
username="$USER"
if [ ".$username" = . ]; then
username="`(whoami) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$username" = . ]; then
username="`(who am i) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$username" = . ]; then
username='unknown'
fi
fi
fi
fi
fi
# determine user id
userid=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%U'`" != . ]; then
userid="`(id -u) 2>/dev/null`"
if [ ".$userid" = . ]; then
str="`(id) 2>/dev/null`"
if [ ".`echo $str | grep '^uid[ ]*=[ ]*[0-9]*('`" != . ]; then
userid=`echo $str | sed -e 's/^uid[ ]*=[ ]*//' -e 's/(.*//'`
username=`echo $str | sed -e 's/^uid[ ]*=[ ]*[0-9]*(//' -e 's/).*$//'`
fi
if [ ".$userid" = . ]; then
userid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$userid" = . ]; then
userid=`(ypcat passwd) 2>/dev/null |
egrep "^${username}:" | \
sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$userid" = . ]; then
userid='?'
if [ ".$username" = . ]; then
username="$LOGNAME"
if [ ".$username" = . ]; then
username="$USER"
if [ ".$username" = . ]; then
username="`(whoami) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$username" = . ]; then
username="`(who am i) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$username" = . ]; then
username='unknown'
fi
fi
fi
fi
fi
fi
fi
# determine user id
userid=''
if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%U'`" != . ]; then
userid="`(id -u) 2>/dev/null`"
if [ ".$userid" = . ]; then
userid="`(id -u ${username}) 2>/dev/null`"
if [ ".$userid" = . ]; then
str="`(id) 2>/dev/null`"
if [ ".`echo $str | grep '^uid[ ]*=[ ]*[0-9]*('`" != . ]; then
userid=`echo $str | sed -e 's/^uid[ ]*=[ ]*//' -e 's/(.*$//'`
fi
if [ ".$userid" = . ]; then
userid=`(getent passwd ${username}) 2>/dev/null | \
sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$userid" = . ]; then
userid=`grep "^${username}:" /etc/passwd 2>/dev/null | \
sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$userid" = . ]; then
userid=`(ypcat passwd) 2>/dev/null |
grep "^${username}:" | \
sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$userid" = . ]; then
userid='?'
fi
fi
fi
fi
fi
fi
fi
# determine (primary) group id
groupid=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[gG]'`" != . ]; then
groupid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[gG]'`" != . ]; then
groupid="`(id -g ${username}) 2>/dev/null`"
if [ ".$groupid" = . ]; then
groupid=`(ypcat passwd) 2>/dev/null | egrep "^${username}:" | \
sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
str="`(id) 2>/dev/null`"
if [ ".`echo $str | grep 'gid[ ]*=[ ]*[0-9]*('`" != . ]; then
groupid=`echo $str | sed -e 's/^.*gid[ ]*=[ ]*//' -e 's/(.*$//'`
fi
if [ ".$groupid" = . ]; then
groupid='?'
groupid=`(getent passwd ${username}) 2>/dev/null | \
sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$groupid" = . ]; then
groupid=`grep "^${username}:" /etc/passwd 2>/dev/null | \
sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$groupid" = . ]; then
groupid=`(ypcat passwd) 2>/dev/null | grep "^${username}:" | \
sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
if [ ".$groupid" = . ]; then
groupid='?'
fi
fi
fi
fi
fi
fi
# determine (primary) group name
groupname=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%g'`" != . ]; then
groupname=`egrep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \
sed -e 's/:.*$//'`
if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%g'`" != . ]; then
groupname="`(id -gn ${username}) 2>/dev/null`"
if [ ".$groupname" = . ]; then
groupname=`(ypcat group) 2>/dev/null | \
egrep "^[^:]*:[^:]*:${groupid}:" | \
sed -e 's/:.*$//'`
str="`(id) 2>/dev/null`"
if [ ".`echo $str | grep 'gid[ ]*=[ ]*[0-9]*('`" != . ]; then
groupname=`echo $str | sed -e 's/^.*gid[ ]*=[ ]*[0-9]*(//' -e 's/).*$//'`
fi
if [ ".$groupname" = . ]; then
groupname='?'
groupname=`(getent group) 2>/dev/null | \
grep "^[^:]*:[^:]*:${groupid}:" | \
sed -e 's/:.*$//'`
if [ ".$groupname" = . ]; then
groupname=`grep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \
sed -e 's/:.*$//'`
if [ ".$groupname" = . ]; then
groupname=`(ypcat group) 2>/dev/null | \
grep "^[^:]*:[^:]*:${groupid}:" | \
sed -e 's/:.*$//'`
if [ ".$groupname" = . ]; then
groupname='?'
fi
fi
fi
fi
fi
fi
# determine host and domain name
hostname=''
domainname=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%h'`" != . ]; then
if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%h'`" != . ]; then
hostname="`(uname -n) 2>/dev/null |\
awk '{ printf("%s", $1); }'`"
if [ ".$hostname" = . ]; then
@@ -565,16 +640,16 @@ echo )
;;
esac
fi
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%d'`" != . ]; then
if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%d'`" != . ]; then
if [ ".$domainname" = . ]; then
if [ -f /etc/resolv.conf ]; then
domainname="`egrep '^[ ]*domain' /etc/resolv.conf | sed -e 'q' |\
domainname="`grep '^[ ]*domain' /etc/resolv.conf | sed -e 'q' |\
sed -e 's/.*domain//' \
-e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
-e 's/^\.//' -e 's/^/./' |\
awk '{ printf("%s", $1); }'`"
if [ ".$domainname" = . ]; then
domainname="`egrep '^[ ]*search' /etc/resolv.conf | sed -e 'q' |\
domainname="`grep '^[ ]*search' /etc/resolv.conf | sed -e 'q' |\
sed -e 's/.*search//' \
-e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
-e 's/ .*//' -e 's/ .*//' \
@@ -584,13 +659,13 @@ echo )
fi
fi
fi
# determine current time
time_day=''
time_month=''
time_year=''
time_monthname=''
if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[DMYm]'`" != . ]; then
if [ ".$opt_e" = .yes ] && [ ".`echo $text | grep '%[DMYm]'`" != . ]; then
time_day=`date '+%d'`
time_month=`date '+%m'`
time_year=`date '+%Y' 2>/dev/null`
@@ -616,7 +691,7 @@ echo )
12) time_monthname='Dec' ;;
esac
fi
# expand special ``%x'' constructs
if [ ".$opt_e" = .yes ]; then
text=`echo $seo "$text" |\
@@ -633,7 +708,7 @@ echo )
-e "s/%Y/${time_year}/g" \
-e "s/%m/${time_monthname}/g" 2>/dev/null`
fi
# create output
if [ .$opt_n = .no ]; then
echo $seo "$text"
@@ -646,15 +721,16 @@ echo )
echo dummy | awk '{ printf("%s", TEXT); }' TEXT="$text"
fi
fi
shtool_exit 0
;;
install )
##
## install -- Install a program, script or datafile
## Copyright (c) 1997-2002 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for shtool
## Copyright (c) 1997-2005 Ralf S. Engelschall <rse@engelschall.com>
##
# special case: "shtool install -d <dir> [...]" internally
# maps to "shtool mkdir -f -p -m 755 <dir> [...]"
if [ "$opt_d" = yes ]; then
@@ -672,11 +748,11 @@ install )
cmd="$cmd -t"
fi
for dir in "$@"; do
eval "$cmd $dir" || exit $?
eval "$cmd $dir" || shtool_exit $?
done
exit 0
shtool_exit 0
fi
# determine source(s) and destination
argc=$#
srcs=""
@@ -685,30 +761,30 @@ install )
shift
done
dstpath="$1"
# type check for destination
dstisdir=0
if [ -d $dstpath ]; then
dstpath=`echo "$dstpath" | sed -e 's:/$::'`
dstisdir=1
fi
# consistency check for destination
if [ $argc -gt 2 -a $dstisdir = 0 ]; then
if [ $argc -gt 2 ] && [ $dstisdir = 0 ]; then
echo "$msgprefix:Error: multiple sources require destination to be directory" 1>&2
exit 1
shtool_exit 1
fi
# iterate over all source(s)
for src in $srcs; do
dst=$dstpath
# if destination is a directory, append the input filename
if [ $dstisdir = 1 ]; then
dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
dst="$dst/$dstfile"
fi
# check for correct arguments
if [ ".$src" = ".$dst" ]; then
echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2
@@ -718,17 +794,17 @@ install )
echo "$msgprefix:Warning: source \`$src' is a directory - skipped" 1>&2
continue
fi
# make a temp file name in the destination directory
dsttmp=`echo $dst |\
sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \
-e "s;\$;/#INST@$$#;"`
# verbosity
if [ ".$opt_v" = .yes ]; then
echo "$src -> $dst" 1>&2
fi
# copy or move the file name to the temp name
# (because we might be not allowed to change the source)
if [ ".$opt_C" = .yes ]; then
@@ -738,14 +814,14 @@ install )
if [ ".$opt_t" = .yes ]; then
echo "cp $src $dsttmp" 1>&2
fi
cp $src $dsttmp || exit $?
cp $src $dsttmp || shtool_exit $?
else
if [ ".$opt_t" = .yes ]; then
echo "mv $src $dsttmp" 1>&2
fi
mv $src $dsttmp || exit $?
mv $src $dsttmp || shtool_exit $?
fi
# adjust the target file
if [ ".$opt_e" != . ]; then
sed='sed'
@@ -755,34 +831,35 @@ install )
sed="$sed -e '$e'"
done
cp $dsttmp $dsttmp.old
eval "$sed <$dsttmp.old >$dsttmp" || exit $?
chmod u+w $dsttmp
eval "$sed <$dsttmp.old >$dsttmp" || shtool_exit $?
rm -f $dsttmp.old
fi
if [ ".$opt_s" = .yes ]; then
if [ ".$opt_t" = .yes ]; then
echo "strip $dsttmp" 1>&2
fi
strip $dsttmp || exit $?
strip $dsttmp || shtool_exit $?
fi
if [ ".$opt_o" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chown $opt_o $dsttmp" 1>&2
fi
chown $opt_o $dsttmp || exit $?
chown $opt_o $dsttmp || shtool_exit $?
fi
if [ ".$opt_g" != . ]; then
if [ ".$opt_t" = .yes ]; then
echo "chgrp $opt_g $dsttmp" 1>&2
fi
chgrp $opt_g $dsttmp || exit $?
chgrp $opt_g $dsttmp || shtool_exit $?
fi
if [ ".$opt_m" != ".-" ]; then
if [ ".$opt_t" = .yes ]; then
echo "chmod $opt_m $dsttmp" 1>&2
fi
chmod $opt_m $dsttmp || exit $?
chmod $opt_m $dsttmp || shtool_exit $?
fi
# determine whether to do a quick install
# (has to be done _after_ the strip was already done)
quick=no
@@ -793,7 +870,7 @@ install )
fi
fi
fi
# finally, install the file to the real destination
if [ $quick = yes ]; then
if [ ".$opt_t" = .yes ]; then
@@ -807,21 +884,21 @@ install )
rm -f $dst && mv $dsttmp $dst
fi
done
shtool_exit 0
;;
mkdir )
##
## mkdir -- Make one or more directories
## Copyright (c) 1996-2002 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for public domain by Noah Friedman <friedman@prep.ai.mit.edu>
## Cleaned up and enhanced for shtool
## Copyright (c) 1996-2005 Ralf S. Engelschall <rse@engelschall.com>
##
errstatus=0
for p in ${1+"$@"}; do
# if the directory already exists...
if [ -d "$p" ]; then
if [ ".$opt_f" = .no -a ".$opt_p" = .no ]; then
if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
echo "$msgprefix:Error: directory already exists: $p" 1>&2
errstatus=1
break
@@ -895,32 +972,32 @@ mkdir )
done
fi
done
exit $errstatus
shtool_exit $errstatus
;;
path )
##
## path -- Deal with program paths
## Copyright (c) 1998-2002 Ralf S. Engelschall <rse@engelschall.com>
## Originally written for Apache
## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
##
namelist="$*"
# check whether the test command supports the -x option
if [ -x /bin/sh ] 2>/dev/null; then
minusx="-x"
else
minusx="-r"
fi
# split path string
paths="`echo $opt_p |\
sed -e 's/^:/.:/' \
-e 's/::/:.:/g' \
-e 's/:$/:./' \
-e 's/:/ /g'`"
# SPECIAL REQUEST
# translate forward to reverse path
if [ ".$opt_r" = .yes ]; then
@@ -933,25 +1010,25 @@ path )
done
fi
echo $rp | sed -e 's:/$::'
exit 0
shtool_exit 0
fi
# SPECIAL REQUEST
# strip out directory or base name
if [ ".$opt_d" = .yes ]; then
echo "$namelist" |\
sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'
exit 0
shtool_exit 0
fi
if [ ".$opt_b" = .yes ]; then
echo "$namelist" |\
sed -e 's;.*/\([^/]*\)$;\1;'
exit 0
shtool_exit 0
fi
# MAGIC SITUATION
# Perl Interpreter (perl)
if [ ".$opt_m" = .yes -a ".$namelist" = .perl ]; then
if [ ".$opt_m" = .yes ] && [ ".$namelist" = .perl ]; then
rm -f $tmpfile >/dev/null 2>&1
touch $tmpfile
found=0
@@ -960,7 +1037,7 @@ path )
dir=`echo $dir | sed -e 's;/*$;;'`
nc=99
for name in perl perl5 miniperl; do
if [ $minusx "$dir/$name" -a ! -d "$dir/$name" ]; then
if [ $minusx "$dir/$name" ] && [ ! -d "$dir/$name" ]; then
perl="$dir/$name"
pv=`$perl -e 'printf("%.3f", $]);'`
echo "$pv:$pc:$nc:$perl" >>$tmpfile
@@ -974,15 +1051,15 @@ path )
perl="`cat $tmpfile | sort -r -u | sed -e 'q' | cut -d: -f4`"
rm -f $tmpfile >/dev/null 2>&1
echo "$perl"
exit 0
shtool_exit 0
fi
rm -f $tmpfile >/dev/null 2>&1
exit 1
shtool_exit 1
fi
# MAGIC SITUATION
# C pre-processor (cpp)
if [ ".$opt_m" = .yes -a ".$namelist" = .cpp ]; then
if [ ".$opt_m" = .yes ] && [ ".$namelist" = .cpp ]; then
echo >$tmpfile.c "#include <assert.h>"
echo >>$tmpfile.c "Syntax Error"
# 1. try the standard cc -E approach
@@ -998,7 +1075,7 @@ path )
# 3. try a standalone cpp command in path and lib dirs
for path in $paths /lib /usr/lib /usr/local/lib; do
path=`echo $path | sed -e 's;/*$;;'`
if [ $minusx "$path/cpp" -a ! -d "$path/cpp" ]; then
if [ $minusx "$path/cpp" ] && [ ! -d "$path/cpp" ]; then
cpp="$path/cpp"
break
fi
@@ -1017,30 +1094,30 @@ path )
rm -f $tmpfile.c $tmpfile.out >/dev/null 2>&1
if [ ".$cpp" != . ]; then
echo "$cpp"
exit 0
shtool_exit 0
fi
exit 1
shtool_exit 1
fi
# STANDARD SITUATION
# iterate over names
for name in $namelist; do
# iterate over paths
for path in $paths; do
path=`echo $path | sed -e 's;/*$;;'`
if [ $minusx "$path/$name" -a ! -d "$path/$name" ]; then
if [ $minusx "$path/$name" ] && [ ! -d "$path/$name" ]; then
if [ ".$opt_s" != .yes ]; then
echo "$path/$name"
fi
exit 0
shtool_exit 0
fi
done
done
exit 1
shtool_exit 1
;;
esac
exit 0
shtool_exit 0
##EOF##
+22 -3
View File
@@ -39,8 +39,8 @@ PHP_CANONICAL_HOST
AC_CONFIG_HEADER(main/php_config.h)
MAJOR_VERSION=4
MINOR_VERSION=3
RELEASE_VERSION=11
MINOR_VERSION=4
RELEASE_VERSION=0
EXTRA_VERSION=""
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
@@ -180,6 +180,17 @@ PHP_C_BIGENDIAN
dnl Platform-specific compile settings.
dnl -------------------------------------------------------------------------
dnl See bug #28605
case $host_cpu in
alpha*)
if test "$GCC" = "yes"; then
CFLAGS="$CFLAGS -mieee"
else
CFLAGS="$CFLAGS -ieee"
fi
;;
esac
case $host_alias in
*solaris*)
CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
@@ -425,6 +436,12 @@ PHP_TM_GMTOFF
PHP_STRUCT_FLOCK
PHP_SOCKLEN_T
AC_CHECK_SIZEOF(intmax_t, 0)
AC_CHECK_SIZEOF(size_t, 8)
AC_CHECK_SIZEOF(ssize_t, 8)
AC_CHECK_SIZEOF(ptrdiff_t, 8)
AC_CHECK_SIZEOF(long long, 8)
AC_CHECK_SIZEOF(long long int, 8)
AC_CHECK_SIZEOF(long, 8)
AC_CHECK_SIZEOF(int, 4)
@@ -1269,9 +1286,11 @@ AC_DEFINE([HAVE_BUILD_DEFS_H], 1, [ ])
$php_shtool mkdir -p pear/scripts
$php_shtool mkdir -p scripts
$php_shtool mkdir -p scripts/man1
ALL_OUTPUT_FILES="php4.spec main/build-defs.h \
scripts/phpize scripts/php-config \
scripts/phpize scripts/man1/phpize.1 \
scripts/php-config scripts/man1/php-config.1 \
$PHP_OUTPUT_FILES"
AC_OUTPUT($ALL_OUTPUT_FILES, [], [
+39 -45
View File
@@ -40,9 +40,6 @@
#define PHP_BZ_ERRSTR 1
#define PHP_BZ_ERRBOTH 2
/* Blocksize of the decompression buffer */
#define PHP_BZ_DECOMPRESS_SIZE 4096
function_entry bz2_functions[] = {
PHP_FE(bzopen, NULL)
PHP_FE(bzread, NULL)
@@ -434,56 +431,53 @@ PHP_FUNCTION(bzcompress)
Decompresses BZip2 compressed data */
PHP_FUNCTION(bzdecompress)
{
zval **source, /* Source data to decompress */
**zsmall; /* (Optional) user specified small */
char *dest; /* Destination buffer, initially allocated */
int error, /* Error container */
iter = 1, /* Iteration count for the compression loop */
size, /* Current size to realloc the dest buffer to */
dest_len = PHP_BZ_DECOMPRESS_SIZE, /* Size of the destination length */
small = 0, /* The actual small */
argc = ZEND_NUM_ARGS(); /* Argument count */
if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &source, &zsmall) == FAILURE) {
WRONG_PARAM_COUNT;
char *source, *dest;
int source_len, error;
long small = 0;
#if defined(PHP_WIN32) && _MSC_VER < 1300
unsigned __int64 size = 0;
#else
unsigned long long size = 0;
#endif
bz_stream bzs;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &small)) {
RETURN_FALSE;
}
convert_to_string_ex(source);
/* optional small argument handling */
if (argc > 1) {
convert_to_long_ex(zsmall);
small = Z_LVAL_PP(zsmall);
bzs.bzalloc = NULL;
bzs.bzfree = NULL;
if (BZ2_bzDecompressInit(&bzs, 0, small) != BZ_OK) {
RETURN_FALSE;
}
/* Depending on the size of the source buffer, either allocate
the length of the source buffer or the a default decompression
size */
dest = emalloc(PHP_BZ_DECOMPRESS_SIZE > Z_STRLEN_PP(source) ? PHP_BZ_DECOMPRESS_SIZE : Z_STRLEN_PP(source));
bzs.next_in = source;
bzs.avail_in = source_len;
/* (de)Compression Loop */
do {
/* Handle the (re)allocation of the buffer */
size = dest_len * iter;
if (iter > 1) {
dest = erealloc(dest, size);
}
++iter;
/* Perform the decompression */
error = BZ2_bzBuffToBuffDecompress(dest, &size, Z_STRVAL_PP(source), Z_STRLEN_PP(source), small, 0);
} while (error == BZ_OUTBUFF_FULL);
/* in most cases bz2 offers at least 2:1 compression, so we use that as our base */
bzs.avail_out = source_len * 2;
bzs.next_out = dest = emalloc(bzs.avail_out + 1);
if (error != BZ_OK) {
efree(dest);
RETURN_LONG(error);
} else {
/* we might have allocated a little to much, so erealloc the buffer
down to size, before returning it */
while ((error = BZ2_bzDecompress(&bzs)) == BZ_OK && bzs.avail_in > 0) {
/* compression is better then 2:1, need to allocate more memory */
bzs.avail_out = source_len;
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
dest = erealloc(dest, size + bzs.avail_out + 1);
bzs.next_out = dest + size;
}
if (error == BZ_STREAM_END || error == BZ_OK) {
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
dest = erealloc(dest, size + 1);
dest[size] = 0;
RETURN_STRINGL(dest, size, 0);
dest[size] = '\0';
RETVAL_STRINGL(dest, size, 0);
} else { /* real error */
efree(dest);
RETVAL_LONG(error);
}
BZ2_bzDecompressEnd(&bzs);
}
/* }}} */
+303 -301
View File
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
| Authors: Shane Caraveo <shane@caraveo.com> |
| Colin Viebrock <colin@easydns.com> |
| Hartmut Holzgraefe <hartmut@six.de> |
| Hartmut Holzgraefe <hholzgra@php.net> |
| Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
@@ -34,7 +34,7 @@
#include "sdncal.h"
#include <stdio.h>
function_entry calendar_functions[] = {
PHP_FE(jdtogregorian, NULL)
PHP_FE(gregoriantojd, NULL)
@@ -48,10 +48,10 @@ function_entry calendar_functions[] = {
PHP_FE(jdmonthname, NULL)
PHP_FE(easter_date, NULL)
PHP_FE(easter_days, NULL)
PHP_FE(unixtojd, NULL)
PHP_FE(jdtounix, NULL)
PHP_FE(cal_to_jd, NULL)
PHP_FE(cal_from_jd, NULL)
PHP_FE(unixtojd, NULL)
PHP_FE(jdtounix, NULL)
PHP_FE(cal_to_jd, NULL)
PHP_FE(cal_from_jd, NULL)
PHP_FE(cal_days_in_month, NULL)
PHP_FE(cal_info, NULL)
{NULL, NULL, NULL}
@@ -60,8 +60,8 @@ function_entry calendar_functions[] = {
zend_module_entry calendar_module_entry = {
STANDARD_MODULE_HEADER,
"calendar",
calendar_functions,
"calendar",
calendar_functions,
PHP_MINIT(calendar),
NULL,
NULL,
@@ -83,60 +83,76 @@ enum cal_name_type_t {
CAL_FRENCH,
CAL_NUM_CALS
};
typedef long int (*cal_to_jd_func_t)(int month, int day, int year);
typedef void (*cal_from_jd_func_t)(long int jd, int* year, int* month, int* day);
typedef char* (*cal_as_string_func_t)(int year, int month, int day);
typedef long int (*cal_to_jd_func_t) (int month, int day, int year);
typedef void (*cal_from_jd_func_t) (long int jd, int *year, int *month, int *day);
typedef char *(*cal_as_string_func_t) (int year, int month, int day);
struct cal_entry_t {
char *name;
char *symbol;
cal_to_jd_func_t to_jd;
cal_from_jd_func_t from_jd;
int num_months;
int max_days_in_month;
char **month_name_short;
char **month_name_long;
char *name;
char *symbol;
cal_to_jd_func_t to_jd;
cal_from_jd_func_t from_jd;
int num_months;
int max_days_in_month;
char **month_name_short;
char **month_name_long;
};
static struct cal_entry_t cal_conversion_table[CAL_NUM_CALS] = {
{ "Gregorian", "CAL_GREGORIAN", GregorianToSdn, SdnToGregorian, 12, 31, MonthNameShort, MonthNameLong },
{ "Julian", "CAL_JULIAN", JulianToSdn, SdnToJulian, 12, 31, MonthNameShort, MonthNameLong },
{ "Jewish", "CAL_JEWISH", JewishToSdn, SdnToJewish, 13, 30, JewishMonthName, JewishMonthName },
{ "French", "CAL_FRENCH", FrenchToSdn, SdnToFrench, 13, 30, FrenchMonthName, FrenchMonthName }
{"Gregorian", "CAL_GREGORIAN", GregorianToSdn, SdnToGregorian, 12, 31,
MonthNameShort, MonthNameLong},
{"Julian", "CAL_JULIAN", JulianToSdn, SdnToJulian, 12, 31,
MonthNameShort, MonthNameLong},
{"Jewish", "CAL_JEWISH", JewishToSdn, SdnToJewish, 13, 30,
JewishMonthName, JewishMonthName},
{"French", "CAL_FRENCH", FrenchToSdn, SdnToFrench, 13, 30,
FrenchMonthName, FrenchMonthName}
};
/* For jddayofweek */
enum { CAL_DOW_DAYNO, CAL_DOW_SHORT, CAL_DOW_LONG };
enum { CAL_DOW_DAYNO, CAL_DOW_SHORT, CAL_DOW_LONG };
/* For jdmonthname */
enum { CAL_MONTH_GREGORIAN_SHORT, CAL_MONTH_GREGORIAN_LONG,
enum { CAL_MONTH_GREGORIAN_SHORT, CAL_MONTH_GREGORIAN_LONG,
CAL_MONTH_JULIAN_SHORT, CAL_MONTH_JULIAN_LONG, CAL_MONTH_JEWISH,
CAL_MONTH_FRENCH };
CAL_MONTH_FRENCH
};
/* for heb_number_to_chars */
static char alef_bet[25] = "0àáâãäåæçèéëìîðñòôö÷øùú";
#define CAL_JEWISH_ADD_ALAFIM_GERESH 0x2
#define CAL_JEWISH_ADD_ALAFIM 0x4
#define CAL_JEWISH_ADD_GERESHAYIM 0x8
PHP_MINIT_FUNCTION(calendar)
{
REGISTER_LONG_CONSTANT("CAL_GREGORIAN", CAL_GREGORIAN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_JULIAN", CAL_JULIAN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_JEWISH", CAL_JEWISH, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_FRENCH", CAL_FRENCH, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_NUM_CALS", CAL_NUM_CALS, CONST_CS|CONST_PERSISTENT);
/* constants for jddayofweek */
REGISTER_LONG_CONSTANT("CAL_DOW_DAYNO", CAL_DOW_DAYNO, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_DOW_SHORT", CAL_DOW_SHORT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_DOW_LONG", CAL_DOW_LONG, CONST_CS|CONST_PERSISTENT);
/* constants for jdmonthname */
REGISTER_LONG_CONSTANT("CAL_MONTH_GREGORIAN_SHORT", CAL_MONTH_GREGORIAN_SHORT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_GREGORIAN_LONG", CAL_MONTH_GREGORIAN_LONG, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_JULIAN_SHORT", CAL_MONTH_JULIAN_SHORT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_JULIAN_LONG", CAL_MONTH_JULIAN_LONG, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_JEWISH", CAL_MONTH_JEWISH, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_FRENCH", CAL_MONTH_FRENCH, CONST_CS|CONST_PERSISTENT);
/* constants for easter calculation */
REGISTER_LONG_CONSTANT("CAL_EASTER_DEFAULT", CAL_EASTER_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_EASTER_ROMAN", CAL_EASTER_ROMAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_EASTER_ALWAYS_GREGORIAN", CAL_EASTER_ALWAYS_GREGORIAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_EASTER_ALWAYS_JULIAN", CAL_EASTER_ALWAYS_JULIAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_GREGORIAN", CAL_GREGORIAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_JULIAN", CAL_JULIAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_JEWISH", CAL_JEWISH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_FRENCH", CAL_FRENCH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_NUM_CALS", CAL_NUM_CALS, CONST_CS | CONST_PERSISTENT);
/* constants for jddayofweek */
REGISTER_LONG_CONSTANT("CAL_DOW_DAYNO", CAL_DOW_DAYNO, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_DOW_SHORT", CAL_DOW_SHORT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_DOW_LONG", CAL_DOW_LONG, CONST_CS | CONST_PERSISTENT);
/* constants for jdmonthname */
REGISTER_LONG_CONSTANT("CAL_MONTH_GREGORIAN_SHORT", CAL_MONTH_GREGORIAN_SHORT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_GREGORIAN_LONG", CAL_MONTH_GREGORIAN_LONG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_JULIAN_SHORT", CAL_MONTH_JULIAN_SHORT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_JULIAN_LONG", CAL_MONTH_JULIAN_LONG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_JEWISH", CAL_MONTH_JEWISH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_MONTH_FRENCH", CAL_MONTH_FRENCH, CONST_CS | CONST_PERSISTENT);
/* constants for easter calculation */
REGISTER_LONG_CONSTANT("CAL_EASTER_DEFAULT", CAL_EASTER_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_EASTER_ROMAN", CAL_EASTER_ROMAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_EASTER_ALWAYS_GREGORIAN", CAL_EASTER_ALWAYS_GREGORIAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_EASTER_ALWAYS_JULIAN", CAL_EASTER_ALWAYS_JULIAN, CONST_CS | CONST_PERSISTENT);
/* constants for Jewish date formatting */
REGISTER_LONG_CONSTANT("CAL_JEWISH_ADD_ALAFIM_GERESH", CAL_JEWISH_ADD_ALAFIM_GERESH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_JEWISH_ADD_ALAFIM", CAL_JEWISH_ADD_ALAFIM, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CAL_JEWISH_ADD_GERESHAYIM", CAL_JEWISH_ADD_GERESHAYIM, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
@@ -147,42 +163,65 @@ PHP_MINFO_FUNCTION(calendar)
php_info_print_table_end();
}
/* {{{ proto array cal_info(int calendar)
Returns information about a particular calendar */
PHP_FUNCTION(cal_info)
static void _php_cal_info(int cal, zval **ret)
{
zval ** cal;
zval * months, *smonths;
zval *months, *smonths;
int i;
struct cal_entry_t * calendar;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &cal) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(cal);
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
zend_error(E_WARNING, "%s(): invalid calendar ID %ld", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
RETURN_FALSE;
}
struct cal_entry_t *calendar;
calendar = &cal_conversion_table[Z_LVAL_PP(cal)];
array_init(return_value);
calendar = &cal_conversion_table[cal];
array_init(*ret);
MAKE_STD_ZVAL(months);
MAKE_STD_ZVAL(smonths);
array_init(months);
array_init(smonths);
for (i=1; i<= calendar->num_months; i++) {
for (i = 1; i <= calendar->num_months; i++) {
add_index_string(months, i, calendar->month_name_long[i], 1);
add_index_string(smonths, i, calendar->month_name_short[i], 1);
}
add_assoc_zval(return_value, "months", months);
add_assoc_zval(return_value, "abbrevmonths", smonths);
add_assoc_long(return_value, "maxdaysinmonth", calendar->max_days_in_month);
add_assoc_string(return_value, "calname", calendar->name, 1);
add_assoc_string(return_value, "calsymbol", calendar->symbol, 1);
add_assoc_zval(*ret, "months", months);
add_assoc_zval(*ret, "abbrevmonths", smonths);
add_assoc_long(*ret, "maxdaysinmonth", calendar->max_days_in_month);
add_assoc_string(*ret, "calname", calendar->name, 1);
add_assoc_string(*ret, "calsymbol", calendar->symbol, 1);
}
/* {{{ proto array cal_info(int calendar)
Returns information about a particular calendar */
PHP_FUNCTION(cal_info)
{
long cal = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &cal) == FAILURE) {
RETURN_FALSE;
}
if (cal == -1) {
int i;
zval *val;
array_init(return_value);
for (i = 0; i < CAL_NUM_CALS; i++) {
MAKE_STD_ZVAL(val);
_php_cal_info(i, &val);
add_index_zval(return_value, i, val);
}
return;
}
if (cal != -1 && (cal < 0 || cal >= CAL_NUM_CALS)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld.", cal);
RETURN_FALSE;
}
_php_cal_info(cal, &return_value);
}
/* }}} */
@@ -190,34 +229,35 @@ PHP_FUNCTION(cal_info)
Returns the number of days in a month for a given year and calendar */
PHP_FUNCTION(cal_days_in_month)
{
zval ** cal, **month, **year;
struct cal_entry_t * calendar;
long cal, month, year;
struct cal_entry_t *calendar;
long sdn_start, sdn_next;
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &cal, &month, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(cal);
convert_to_long_ex(month);
convert_to_long_ex(year);
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
zend_error(E_WARNING, "%s(): invalid calendar ID %ld", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &cal, &month, &year) == FAILURE) {
RETURN_FALSE;
}
calendar = &cal_conversion_table[Z_LVAL_PP(cal)];
sdn_start = calendar->to_jd(Z_LVAL_PP(year), Z_LVAL_PP(month), 1);
sdn_next = calendar->to_jd(Z_LVAL_PP(year), 1 + Z_LVAL_PP(month), 1);
if (sdn_next == 0) {
/* if invalid, try first month of the next year... */
sdn_next = calendar->to_jd(Z_LVAL_PP(year) + 1, 1, 1);
if (cal < 0 || cal >= CAL_NUM_CALS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld.", cal);
RETURN_FALSE;
}
calendar = &cal_conversion_table[cal];
sdn_start = calendar->to_jd(year, month, 1);
if (sdn_start == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid date.");
RETURN_FALSE;
}
sdn_next = calendar->to_jd(year, 1 + month, 1);
if (sdn_next == 0) {
/* if invalid, try first month of the next year... */
sdn_next = calendar->to_jd(year + 1, 1, 1);
}
RETURN_LONG(sdn_next - sdn_start);
}
/* }}} */
@@ -226,26 +266,18 @@ PHP_FUNCTION(cal_days_in_month)
Converts from a supported calendar to Julian Day Count */
PHP_FUNCTION(cal_to_jd)
{
zval ** cal, **month, **day, **year;
long jdate;
long cal, month, day, year;
if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &cal, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(cal);
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
zend_error(E_WARNING, "%s(): invalid calendar ID %ld", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &cal, &month, &day, &year) != SUCCESS) {
RETURN_FALSE;
}
jdate = cal_conversion_table[Z_LVAL_PP(cal)].to_jd(
Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));
RETURN_LONG(jdate);
if (cal < 0 || cal >= CAL_NUM_CALS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld.", cal);
RETURN_FALSE;
}
RETURN_LONG(cal_conversion_table[cal].to_jd(year, month, day));
}
/* }}} */
@@ -253,42 +285,38 @@ PHP_FUNCTION(cal_to_jd)
Converts from Julian Day Count to a supported calendar and return extended information */
PHP_FUNCTION(cal_from_jd)
{
zval ** jd, ** cal;
long jd, cal;
int month, day, year, dow;
char date[16];
struct cal_entry_t * calendar;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &jd, &cal) != SUCCESS) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(jd);
convert_to_long_ex(cal);
struct cal_entry_t *calendar;
if (Z_LVAL_PP(cal) < 0 || Z_LVAL_PP(cal) >= CAL_NUM_CALS) {
zend_error(E_WARNING, "%s(): invalid calendar ID %ld", get_active_function_name(TSRMLS_C), Z_LVAL_PP(cal));
if (zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC, "ll", &jd, &cal) == FAILURE) {
RETURN_FALSE;
}
calendar = &cal_conversion_table[Z_LVAL_PP(cal)];
if (cal < 0 || cal >= CAL_NUM_CALS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid calendar ID %ld", cal);
RETURN_FALSE;
}
calendar = &cal_conversion_table[cal];
array_init(return_value);
calendar->from_jd(
Z_LVAL_PP(jd),
&year, &month, &day);
calendar->from_jd(jd, &year, &month, &day);
sprintf(date, "%i/%i/%i", month, day, year);
add_assoc_string(return_value, "date", date, 1);
add_assoc_long(return_value, "month", month);
add_assoc_long(return_value, "day", day);
add_assoc_long(return_value, "year", year);
/* day of week */
dow = DayOfWeek(Z_LVAL_PP(jd));
/* day of week */
dow = DayOfWeek(jd);
add_assoc_long(return_value, "dow", dow);
add_assoc_string(return_value, "abbrevdayname", DayNameShort[dow], 1);
add_assoc_string(return_value, "dayname", DayNameLong[dow], 1);
/* month name */
/* month name */
add_assoc_string(return_value, "abbrevmonth", calendar->month_name_short[month], 1);
add_assoc_string(return_value, "monthname", calendar->month_name_long[month], 1);
}
@@ -298,16 +326,15 @@ PHP_FUNCTION(cal_from_jd)
Converts a julian day count to a gregorian calendar date */
PHP_FUNCTION(jdtogregorian)
{
pval **julday;
long julday;
int year, month, day;
char date[10];
char date[16];
if (zend_get_parameters_ex(1, &julday) != SUCCESS) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(julday);
SdnToGregorian(Z_LVAL_PP(julday), &year, &month, &day);
SdnToGregorian(julday, &year, &month, &day);
sprintf(date, "%i/%i/%i", month, day, year);
RETURN_STRING(date, 1);
@@ -318,37 +345,29 @@ PHP_FUNCTION(jdtogregorian)
Converts a gregorian calendar date to julian day count */
PHP_FUNCTION(gregoriantojd)
{
pval **year, **month, **day;
int jdate;
long year, month, day;
if (zend_get_parameters_ex(3, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
jdate = GregorianToSdn(Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));
RETURN_LONG(jdate);
RETURN_LONG(GregorianToSdn(year, month, day));
}
/* }}} */
/* {{{ proto string jdtojulian(int juliandaycount)
Convert a julian day count to a julian calendar date */
PHP_FUNCTION(jdtojulian)
PHP_FUNCTION(jdtojulian)
{
pval **julday;
long julday;
int year, month, day;
char date[10];
char date[16];
if (zend_get_parameters_ex(1, &julday) != SUCCESS) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(julday);
SdnToJulian(Z_LVAL_PP(julday), &year, &month, &day);
SdnToJulian(julday, &year, &month, &day);
sprintf(date, "%i/%i/%i", month, day, year);
RETURN_STRING(date, 1);
@@ -359,137 +378,146 @@ PHP_FUNCTION(jdtojulian)
Converts a julian calendar date to julian day count */
PHP_FUNCTION(juliantojd)
{
pval **year, **month, **day;
int jdate;
long year, month, day;
if (zend_get_parameters_ex(3, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
jdate = JulianToSdn(Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));
RETURN_LONG(jdate);
RETURN_LONG(JulianToSdn(year, month, day));
}
/* }}} */
/*
caution: the hebrew format product non unique result.
for example both: year '5' and year '5000' product 'ä'.
use the numeric one for calculations.
/* {{{ heb_number_to_chars*/
/*
caution: the Hebrew format produces non unique result.
for example both: year '5' and year '5000' produce 'ä'.
use the numeric one for calculations.
*/
static char* heb_number_to_chars(int n, char **ret)
static char *heb_number_to_chars(int n, int fl, char **ret)
{
char *p, *old;
char *p, old[18], *endofalafim;
p = emalloc(10);
old = p;
/*
prevents the option breaking the jewish beliefs, and some other
critical resources ;)
*/
p = endofalafim = old;
/*
prevents the option breaking the jewish beliefs, and some other
critical resources ;)
*/
if (n > 9999 || n < 1) {
efree(old);
*ret = NULL;
return NULL;
}
/* alafim case */
/* alafim (thousands) case */
if (n / 1000) {
*p = alef_bet[n / 1000];
p++;
if (CAL_JEWISH_ADD_ALAFIM_GERESH & fl) {
*p = '\'';
p++;
}
if (CAL_JEWISH_ADD_ALAFIM & fl) {
strcpy(p, " àìôéí ");
p += 7;
}
endofalafim = p;
n = n % 1000;
}
/* taf-taf case */
/* tav-tav (tav=400) case */
while (n >= 400) {
*p = alef_bet[22];
p++;
n-=400;
n -= 400;
}
/* meot case */
if (n >= 100) {
*p = alef_bet[18+n/100];
/* meot (hundreads) case */
if (n >= 100) {
*p = alef_bet[18 + n / 100];
p++;
n = n % 100;
}
/* tet-vav tet-zain case */
/* tet-vav & tet-zain case (special case for 15 and 16) */
if (n == 15 || n == 16) {
*p = alef_bet[9];
p++;
*p = alef_bet[n-9];
*p = alef_bet[n - 9];
p++;
} else {
/* asarot case */
if (n >= 10) {
*p = alef_bet[9+n/10];
/* asarot (tens) case */
if (n >= 10) {
*p = alef_bet[9 + n / 10];
p++;
n = n % 10;
}
/* yeihot case */
/* yehidot (ones) case */
if (n > 0) {
*p = alef_bet[n];
p++;
}
}
if (CAL_JEWISH_ADD_GERESHAYIM & fl) {
switch (p - endofalafim) {
case 0:
break;
case 1:
*p = '\'';
p++;
break;
default:
*(p) = *(p - 1);
*(p - 1) = '"';
p++;
}
}
*p = '\0';
*ret = estrndup(old, (p - old) + 1);
p = *ret;
efree(old);
return p;
}
/* }}} */
/* {{{ proto string jdtojewish(int juliandaycount)
/* {{{ proto string jdtojewish(int juliandaycount [, bool hebrew [, int fl]])
Converts a julian day count to a jewish calendar date */
PHP_FUNCTION(jdtojewish)
PHP_FUNCTION(jdtojewish)
{
long julday, fl;
long julday, fl = 0;
zend_bool heb = 0;
int year, month, day;
char date[10], hebdate[25];
char date[16], hebdate[25];
char *dayp, *yearp;
if (ZEND_NUM_ARGS() == 1) {
if (zend_parse_parameters(1 TSRMLS_CC,"l", &julday) != SUCCESS) {
RETURN_FALSE;
}
fl=0;
} else if (ZEND_NUM_ARGS() == 2) {
if (zend_parse_parameters(2 TSRMLS_CC,"ll", &julday, &fl) != SUCCESS) {
RETURN_FALSE;
}
} else {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|bl", &julday, &heb, &fl) == FAILURE) {
RETURN_FALSE;
}
SdnToJewish(julday, &year, &month, &day);
if(!fl) {
if (!heb) {
sprintf(date, "%i/%i/%i", month, day, year);
RETURN_STRING(date, 1);
} else {
if (year <= 0 || year > 9999) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of range year.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Year out of range (0-9999).");
RETURN_FALSE;
}
sprintf(hebdate, "%s %s %s", heb_number_to_chars(day, &dayp), JewishMonthHebName[month], heb_number_to_chars(year, &yearp));
sprintf(hebdate, "%s %s %s", heb_number_to_chars(day, fl, &dayp), JewishMonthHebName[month], heb_number_to_chars(year, fl, &yearp));
if (dayp) {
efree(dayp);
}
if (yearp) {
efree(yearp);
efree(yearp);
}
RETURN_STRING(hebdate, 1);
}
}
/* }}} */
@@ -498,20 +526,13 @@ PHP_FUNCTION(jdtojewish)
Converts a jewish calendar date to a julian day count */
PHP_FUNCTION(jewishtojd)
{
pval **year, **month, **day;
int jdate;
long year, month, day;
if (zend_get_parameters_ex(3, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
jdate = JewishToSdn(Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));
RETURN_LONG(jdate);
RETURN_LONG(JewishToSdn(year, month, day));
}
/* }}} */
@@ -519,17 +540,15 @@ PHP_FUNCTION(jewishtojd)
Converts a julian day count to a french republic calendar date */
PHP_FUNCTION(jdtofrench)
{
pval **julday;
long julday;
int year, month, day;
char date[10];
char date[16];
if (zend_get_parameters_ex(1, &julday) != SUCCESS) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &julday) == FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(julday);
SdnToFrench(Z_LVAL_PP(julday), &year, &month, &day);
SdnToFrench(julday, &year, &month, &day);
sprintf(date, "%i/%i/%i", month, day, year);
RETURN_STRING(date, 1);
@@ -540,20 +559,13 @@ PHP_FUNCTION(jdtofrench)
Converts a french republic calendar date to julian day count */
PHP_FUNCTION(frenchtojd)
{
pval **year, **month, **day;
int jdate;
long year, month, day;
if (zend_get_parameters_ex(3, &month, &day, &year) != SUCCESS) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &month, &day, &year) == FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(month);
convert_to_long_ex(day);
convert_to_long_ex(year);
jdate = FrenchToSdn(Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));
RETURN_LONG(jdate);
RETURN_LONG(FrenchToSdn(year, month, day));
}
/* }}} */
@@ -561,37 +573,30 @@ PHP_FUNCTION(frenchtojd)
Returns name or number of day of week from julian day count */
PHP_FUNCTION(jddayofweek)
{
pval *julday, *mode;
long julday, mode = CAL_DOW_DAYNO;
int day;
char *daynamel, *daynames;
int myargc=ZEND_NUM_ARGS(), mymode=0;
if ((myargc < 1) || (myargc > 2) || (zend_get_parameters(ht, myargc, &julday, &mode) != SUCCESS)) {
WRONG_PARAM_COUNT;
}
convert_to_long(julday);
if(myargc==2) {
convert_to_long(mode);
mymode = Z_LVAL_P(mode);
}
day = DayOfWeek(Z_LVAL_P(julday));
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &julday, &mode) == FAILURE) {
RETURN_FALSE;
}
day = DayOfWeek(julday);
daynamel = DayNameLong[day];
daynames = DayNameShort[day];
switch (mymode) {
case CAL_DOW_SHORT:
RETURN_STRING(daynamel, 1);
break;
case CAL_DOW_LONG:
RETURN_STRING(daynames, 1);
break;
case CAL_DOW_DAYNO:
default:
RETURN_LONG(day);
break;
}
switch (mode) {
case CAL_DOW_SHORT:
RETURN_STRING(daynamel, 1);
break;
case CAL_DOW_LONG:
RETURN_STRING(daynames, 1);
break;
case CAL_DOW_DAYNO:
default:
RETURN_LONG(day);
break;
}
}
/* }}} */
@@ -599,43 +604,40 @@ PHP_FUNCTION(jddayofweek)
Returns name of month for julian day count */
PHP_FUNCTION(jdmonthname)
{
pval **julday, **mode;
long julday, mode;
char *monthname = NULL;
int month, day, year;
if (zend_get_parameters_ex(2, &julday, &mode) != SUCCESS) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &julday, &mode) == FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(julday);
convert_to_long_ex(mode);
switch(Z_LVAL_PP(mode)) {
case CAL_MONTH_GREGORIAN_LONG: /* gregorian or julian month */
SdnToGregorian(Z_LVAL_PP(julday), &year, &month, &day);
monthname = MonthNameLong[month];
break;
case CAL_MONTH_JULIAN_SHORT: /* gregorian or julian month */
SdnToJulian(Z_LVAL_PP(julday), &year, &month, &day);
monthname = MonthNameShort[month];
break;
case CAL_MONTH_JULIAN_LONG: /* gregorian or julian month */
SdnToJulian(Z_LVAL_PP(julday), &year, &month, &day);
monthname = MonthNameLong[month];
break;
case CAL_MONTH_JEWISH: /* jewish month */
SdnToJewish(Z_LVAL_PP(julday), &year, &month, &day);
monthname = JewishMonthName[month];
break;
case CAL_MONTH_FRENCH: /* french month */
SdnToFrench(Z_LVAL_PP(julday), &year, &month, &day);
monthname = FrenchMonthName[month];
break;
default: /* default gregorian */
case CAL_MONTH_GREGORIAN_SHORT: /* gregorian or julian month */
SdnToGregorian(Z_LVAL_PP(julday), &year, &month, &day);
monthname = MonthNameShort[month];
break;
switch (mode) {
case CAL_MONTH_GREGORIAN_LONG: /* gregorian or julian month */
SdnToGregorian(julday, &year, &month, &day);
monthname = MonthNameLong[month];
break;
case CAL_MONTH_JULIAN_SHORT: /* gregorian or julian month */
SdnToJulian(julday, &year, &month, &day);
monthname = MonthNameShort[month];
break;
case CAL_MONTH_JULIAN_LONG: /* gregorian or julian month */
SdnToJulian(julday, &year, &month, &day);
monthname = MonthNameLong[month];
break;
case CAL_MONTH_JEWISH: /* jewish month */
SdnToJewish(julday, &year, &month, &day);
monthname = JewishMonthName[month];
break;
case CAL_MONTH_FRENCH: /* french month */
SdnToFrench(julday, &year, &month, &day);
monthname = FrenchMonthName[month];
break;
default: /* default gregorian */
case CAL_MONTH_GREGORIAN_SHORT: /* gregorian or julian month */
SdnToGregorian(julday, &year, &month, &day);
monthname = MonthNameShort[month];
break;
}
RETURN_STRING(monthname, 1);
+4
View File
@@ -29,6 +29,10 @@
#include <packer.h>
#ifndef STRINGSIZE
#define STRINGSIZE 1024
#endif
extern char * FascistLook(PWDICT *pwp, char *instring);
extern int PWClose(PWDICT *pwp);
+16 -2
View File
@@ -436,10 +436,12 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
zend_list_addref(ch->id);
ZVAL_STRINGL(argv[1], data, length, 1);
ch->in_callback = 1;
error = call_user_function(EG(function_table),
NULL,
t->func,
retval, 2, argv TSRMLS_CC);
ch->in_callback = 0;
if (error == FAILURE) {
php_error(E_WARNING, "%s(): Couldn't call the CURLOPT_WRITEFUNCTION",
get_active_function_name(TSRMLS_C));
@@ -495,10 +497,12 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
zend_list_addref(t->fd);
ZVAL_LONG(argv[2], (int) size * nmemb);
ch->in_callback = 1;
error = call_user_function(EG(function_table),
NULL,
t->func,
retval, 3, argv TSRMLS_CC);
ch->in_callback = 0;
if (error == FAILURE) {
php_error(E_WARNING, "%s(): Cannot call the CURLOPT_READFUNCTION",
get_active_function_name(TSRMLS_C));
@@ -553,10 +557,12 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
zend_list_addref(ch->id);
ZVAL_STRINGL(argv[1], data, length, 1);
ch->in_callback = 1;
error = call_user_function(EG(function_table),
NULL,
t->func,
retval, 2, argv TSRMLS_CC);
ch->in_callback = 0;
if (error == FAILURE) {
php_error(E_WARNING, "%s(): Couldn't call the CURLOPT_HEADERFUNCTION",
get_active_function_name(TSRMLS_C));
@@ -606,10 +612,12 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
ZVAL_STRING(argv[1], prompt, 1);
ZVAL_LONG(argv[2], buflen);
ch->in_callback = 1;
error = call_user_function(EG(function_table),
NULL,
func,
retval, 2, argv TSRMLS_CC);
ch->in_callback = 0;
if (error == FAILURE) {
php_error(E_WARNING, "%s(): Couldn't call the CURLOPT_PASSWDFUNCTION", get_active_function_name(TSRMLS_C));
} else if (Z_TYPE_P(retval) == IS_STRING) {
@@ -680,7 +688,9 @@ static void alloc_curl_handle(php_curl **ch)
(*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
(*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read));
memset(&(*ch)->err, 0, sizeof((*ch)->err));
(*ch)->in_callback = 0;
zend_llist_init(&(*ch)->to_free.str, sizeof(char *),
(void(*)(void *)) curl_free_string, 0);
zend_llist_init(&(*ch)->to_free.slist, sizeof(struct curl_slist),
@@ -1337,7 +1347,11 @@ PHP_FUNCTION(curl_close)
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if (ch->in_callback) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close CURL handle from a callback");
return;
}
zend_list_delete(Z_LVAL_PP(zid));
}
/* }}} */
+1
View File
@@ -93,6 +93,7 @@ typedef struct {
struct _php_curl_free to_free;
long id;
unsigned int uses;
zend_bool in_callback;
} php_curl;
/* streams support */
+102 -112
View File
@@ -118,33 +118,33 @@ static PHP_MSHUTDOWN_FUNCTION(dbase)
Opens a dBase-format database file */
PHP_FUNCTION(dbase_open)
{
pval *dbf_name, *options;
zval **dbf_name, **options;
dbhead_t *dbh;
int handle;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbf_name, &options)==FAILURE) {
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &dbf_name, &options) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(dbf_name);
convert_to_long(options);
convert_to_string_ex(dbf_name);
convert_to_long_ex(options);
if (Z_LVAL_P(options) == 1) {
php_error(E_WARNING, "Cannot open %s in write-only mode", Z_STRVAL_P(dbf_name));
RETURN_FALSE;
}
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_P(dbf_name), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_P(dbf_name) TSRMLS_CC)) {
if (Z_LVAL_PP(options) == 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot open %s in write-only mode", Z_STRVAL_PP(dbf_name));
RETURN_FALSE;
}
dbh = dbf_open(Z_STRVAL_P(dbf_name), Z_LVAL_P(options) TSRMLS_CC);
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(dbf_name), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_PP(dbf_name) TSRMLS_CC)) {
RETURN_FALSE;
}
dbh = dbf_open(Z_STRVAL_PP(dbf_name), Z_LVAL_PP(options) TSRMLS_CC);
if (dbh == NULL) {
php_error(E_WARNING, "unable to open database %s", Z_STRVAL_P(dbf_name));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to open database %s", Z_STRVAL_PP(dbf_name));
RETURN_FALSE;
}
@@ -157,22 +157,22 @@ PHP_FUNCTION(dbase_open)
Closes an open dBase-format database file */
PHP_FUNCTION(dbase_close)
{
pval *dbh_id;
zval **dbh_id;
dbhead_t *dbh;
int dbh_type;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) {
if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &dbh_id) == FAILURE)) {
WRONG_PARAM_COUNT;
}
convert_to_long(dbh_id);
dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type);
convert_to_long_ex(dbh_id);
dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
RETURN_FALSE;
}
zend_list_delete(Z_LVAL_P(dbh_id));
zend_list_delete(Z_LVAL_PP(dbh_id));
RETURN_TRUE;
}
/* }}} */
@@ -181,18 +181,18 @@ PHP_FUNCTION(dbase_close)
Returns the number of records in the database */
PHP_FUNCTION(dbase_numrecords)
{
pval *dbh_id;
zval **dbh_id;
dbhead_t *dbh;
int dbh_type;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) {
if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &dbh_id) == FAILURE)) {
WRONG_PARAM_COUNT;
}
convert_to_long(dbh_id);
dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type);
convert_to_long_ex(dbh_id);
dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
RETURN_FALSE;
}
@@ -204,18 +204,18 @@ PHP_FUNCTION(dbase_numrecords)
Returns the number of fields (columns) in the database */
PHP_FUNCTION(dbase_numfields)
{
pval *dbh_id;
zval **dbh_id;
dbhead_t *dbh;
int dbh_type;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) {
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &dbh_id) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(dbh_id);
dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type);
convert_to_long_ex(dbh_id);
dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
RETURN_FALSE;
}
@@ -227,18 +227,18 @@ PHP_FUNCTION(dbase_numfields)
Packs the database (deletes records marked for deletion) */
PHP_FUNCTION(dbase_pack)
{
pval *dbh_id;
zval **dbh_id;
dbhead_t *dbh;
int dbh_type;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) {
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &dbh_id) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(dbh_id);
dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type);
convert_to_long_ex(dbh_id);
dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
RETURN_FALSE;
}
@@ -252,7 +252,7 @@ PHP_FUNCTION(dbase_pack)
Adds a record to the database */
PHP_FUNCTION(dbase_add_record)
{
pval *dbh_id, *fields, **field;
zval **dbh_id, **fields, **field;
dbhead_t *dbh;
int dbh_type;
@@ -262,40 +262,36 @@ PHP_FUNCTION(dbase_add_record)
int i;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &fields)==FAILURE) {
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &dbh_id, &fields) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(dbh_id);
if (Z_TYPE_P(fields) != IS_ARRAY) {
php_error(E_WARNING, "Expected array as second parameter");
convert_to_long_ex(dbh_id);
if (Z_TYPE_PP(fields) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter");
RETURN_FALSE;
}
dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type);
dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
RETURN_FALSE;
}
num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields));
num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields));
if (num_fields != dbh->db_nfields) {
php_error(E_WARNING, "Wrong number of fields specified");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong number of fields specified");
RETURN_FALSE;
}
cp = t_cp = (char *)emalloc(dbh->db_rlen + 1);
if (!cp) {
php_error(E_WARNING, "unable to allocate memory");
RETURN_FALSE;
}
*t_cp++ = VALID_RECORD;
dbf = dbh->db_fields;
for (i = 0, cur_f = dbf; cur_f < &dbf[num_fields]; i++, cur_f++) {
zval tmp;
if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) {
php_error(E_WARNING, "unexpected error");
if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unexpected error");
efree(cp);
RETURN_FALSE;
}
@@ -310,7 +306,7 @@ PHP_FUNCTION(dbase_add_record)
dbh->db_records++;
if (put_dbf_record(dbh, dbh->db_records, cp) < 0) {
php_error(E_WARNING, "unable to put record at %ld", dbh->db_records);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to put record at %ld", dbh->db_records);
efree(cp);
RETURN_FALSE;
}
@@ -326,7 +322,7 @@ PHP_FUNCTION(dbase_add_record)
Replaces a record to the database */
PHP_FUNCTION(dbase_replace_record)
{
pval *dbh_id, *fields, **field, *recnum;
zval **dbh_id, **fields, **field, **recnum;
dbhead_t *dbh;
int dbh_type;
@@ -336,40 +332,36 @@ PHP_FUNCTION(dbase_replace_record)
int i;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 3 || getParameters(ht, 3, &dbh_id, &fields, &recnum)==FAILURE) {
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &dbh_id, &fields, &recnum) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(dbh_id);
convert_to_long(recnum);
if (Z_TYPE_P(fields) != IS_ARRAY) {
php_error(E_WARNING, "Expected array as second parameter");
convert_to_long_ex(dbh_id);
convert_to_long_ex(recnum);
if (Z_TYPE_PP(fields) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter");
RETURN_FALSE;
}
dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type);
dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
RETURN_FALSE;
}
num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields));
num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields));
if (num_fields != dbh->db_nfields) {
php_error(E_WARNING, "Wrong number of fields specified");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong number of fields specified");
RETURN_FALSE;
}
cp = t_cp = (char *)emalloc(dbh->db_rlen + 1);
if (!cp) {
php_error(E_WARNING, "unable to allocate memory");
RETURN_FALSE;
}
*t_cp++ = VALID_RECORD;
dbf = dbh->db_fields;
for (i = 0, cur_f = dbf; cur_f < &dbf[num_fields]; i++, cur_f++) {
if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) {
php_error(E_WARNING, "unexpected error");
if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unexpected error");
efree(cp);
RETURN_FALSE;
}
@@ -378,8 +370,8 @@ PHP_FUNCTION(dbase_replace_record)
t_cp += cur_f->db_flen;
}
if (put_dbf_record(dbh, Z_LVAL_P(recnum), cp) < 0) {
php_error(E_WARNING, "unable to put record at %ld", dbh->db_records);
if (put_dbf_record(dbh, Z_LVAL_PP(recnum), cp) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to put record at %ld", dbh->db_records);
efree(cp);
RETURN_FALSE;
}
@@ -395,28 +387,28 @@ PHP_FUNCTION(dbase_replace_record)
Marks a record to be deleted */
PHP_FUNCTION(dbase_delete_record)
{
pval *dbh_id, *record;
zval **dbh_id, **record;
dbhead_t *dbh;
int dbh_type;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &record)==FAILURE) {
if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &dbh_id, &record) == FAILURE)) {
WRONG_PARAM_COUNT;
}
convert_to_long(dbh_id);
convert_to_long(record);
convert_to_long_ex(dbh_id);
convert_to_long_ex(record);
dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type);
dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
RETURN_FALSE;
}
if (del_dbf_record(dbh, Z_LVAL_P(record)) < 0) {
if (Z_LVAL_P(record) > dbh->db_records) {
php_error(E_WARNING, "record %d out of bounds", Z_LVAL_P(record));
if (del_dbf_record(dbh, Z_LVAL_PP(record)) < 0) {
if (Z_LVAL_PP(record) > dbh->db_records) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "record %ld out of bounds", Z_LVAL_PP(record));
} else {
php_error(E_WARNING, "unable to delete record %d", Z_LVAL_P(record));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to delete record %ld", Z_LVAL_PP(record));
}
RETURN_FALSE;
}
@@ -430,7 +422,7 @@ PHP_FUNCTION(dbase_delete_record)
*/
static void php_dbase_get_record(INTERNAL_FUNCTION_PARAMETERS, int assoc)
{
pval *dbh_id, *record;
zval **dbh_id, **record;
dbhead_t *dbh;
int dbh_type;
dbfield_t *dbf, *cur_f;
@@ -440,28 +432,26 @@ static void php_dbase_get_record(INTERNAL_FUNCTION_PARAMETERS, int assoc)
int errno_save;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &record)==FAILURE) {
if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &dbh_id, &record) == FAILURE)) {
WRONG_PARAM_COUNT;
}
convert_to_long(dbh_id);
convert_to_long(record);
convert_to_long_ex(dbh_id);
convert_to_long_ex(record);
dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type);
dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
RETURN_FALSE;
}
if ((data = get_dbf_record(dbh, Z_LVAL_P(record))) == NULL) {
php_error(E_WARNING, "Tried to read bad record %d", Z_LVAL_P(record));
if ((data = get_dbf_record(dbh, Z_LVAL_PP(record))) == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to read bad record %ld", Z_LVAL_PP(record));
RETURN_FALSE;
}
dbf = dbh->db_fields;
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
array_init(return_value);
fnp = NULL;
for (cur_f = dbf; cur_f < &dbf[dbh->db_nfields]; cur_f++) {
@@ -582,7 +572,7 @@ PHP_FUNCTION(dbase_get_record_with_names)
Creates a new dBase-format database file */
PHP_FUNCTION(dbase_create)
{
pval *filename, *fields, **field, **value;
zval **filename, **fields, **field, **value;
int fd;
dbhead_t *dbh;
@@ -591,37 +581,37 @@ PHP_FUNCTION(dbase_create)
int i, rlen, handle;
DBase_TLS_VARS;
if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &filename, &fields)==FAILURE) {
if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &filename, &fields) == FAILURE)) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
convert_to_string_ex(filename);
if (Z_TYPE_P(fields) != IS_ARRAY) {
php_error(E_WARNING, "Expected array as second parameter");
if (Z_TYPE_PP(fields) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter");
RETURN_FALSE;
}
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_P(filename), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(filename), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_P(filename) TSRMLS_CC)) {
if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) {
RETURN_FALSE;
}
if ((fd = VCWD_OPEN_MODE(Z_STRVAL_P(filename), O_BINARY|O_RDWR|O_CREAT, 0644)) < 0) {
php_error(E_WARNING, "Unable to create database (%d): %s", errno, strerror(errno));
if ((fd = VCWD_OPEN_MODE(Z_STRVAL_PP(filename), O_BINARY|O_RDWR|O_CREAT, 0644)) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create database (%d): %s", errno, strerror(errno));
RETURN_FALSE;
}
num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields));
num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields));
/* have to use regular malloc() because this gets free()d by
code in the dbase library */
dbh = (dbhead_t *)malloc(sizeof(dbhead_t));
dbf = (dbfield_t *)malloc(sizeof(dbfield_t) * num_fields);
if (!dbh || !dbf) {
php_error(E_WARNING, "Unable to allocate memory for header info");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate memory for header info");
RETURN_FALSE;
}
@@ -651,27 +641,27 @@ PHP_FUNCTION(dbase_create)
for (i = 0, cur_f = dbf; i < num_fields; i++, cur_f++) {
/* look up the first field */
if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) {
php_error(E_WARNING, "unable to find field %d", i);
if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to find field %d", i);
free_dbf_head(dbh);
RETURN_FALSE;
}
if (Z_TYPE_PP (field) != IS_ARRAY) {
php_error(E_WARNING, "second parameter must be array of arrays");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "second parameter must be array of arrays");
free_dbf_head(dbh);
RETURN_FALSE;
}
/* field name */
if (zend_hash_index_find(Z_ARRVAL_PP(field), 0, (void **)&value) == FAILURE) {
php_error(E_WARNING, "expected field name as first element of list in field %d", i);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field name as first element of list in field %d", i);
free_dbf_head(dbh);
RETURN_FALSE;
}
convert_to_string_ex(value);
if (Z_STRLEN_PP(value) > 10 || Z_STRLEN_PP(value) == 0) {
php_error(E_WARNING, "invalid field name '%s' (must be non-empty and less than or equal to 10 characters)", Z_STRVAL_PP(value));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid field name '%s' (must be non-empty and less than or equal to 10 characters)", Z_STRVAL_PP(value));
free_dbf_head(dbh);
RETURN_FALSE;
}
@@ -679,7 +669,7 @@ PHP_FUNCTION(dbase_create)
/* field type */
if (zend_hash_index_find(Z_ARRVAL_PP (field), 1, (void **)&value) == FAILURE) {
php_error(E_WARNING, "expected field type as second element of list in field %d", i);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field type as second element of list in field %d", i);
RETURN_FALSE;
}
convert_to_string_ex(value);
@@ -704,7 +694,7 @@ PHP_FUNCTION(dbase_create)
case 'C':
/* field length */
if (zend_hash_index_find(Z_ARRVAL_PP (field), 2, (void **)&value) == FAILURE) {
php_error(E_WARNING, "expected field length as third element of list in field %d", i);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field length as third element of list in field %d", i);
free_dbf_head(dbh);
RETURN_FALSE;
}
@@ -713,7 +703,7 @@ PHP_FUNCTION(dbase_create)
if (cur_f->db_type == 'N') {
if (zend_hash_index_find(Z_ARRVAL_PP (field), 3, (void **)&value) == FAILURE) {
php_error(E_WARNING, "expected field precision as fourth element of list in field %d", i);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field precision as fourth element of list in field %d", i);
free_dbf_head(dbh);
RETURN_FALSE;
}
@@ -722,7 +712,7 @@ PHP_FUNCTION(dbase_create)
}
break;
default:
php_error(E_WARNING, "unknown field type '%c'", cur_f->db_type);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown field type '%c'", cur_f->db_type);
}
cur_f->db_foffset = rlen;
rlen += cur_f->db_flen;
+10 -9
View File
@@ -136,7 +136,8 @@ void pack_dbf(dbhead_t *dbh)
/* Try to truncate the file to the right size. */
if (ftruncate(dbh->db_fd, out_off) != 0) {
php_error(E_WARNING, "dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there.");
TSRMLS_FETCH();
php_error_docref(NULL TSRMLS_CC, E_WARNING, "dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there.");
}
if (rec_cnt == 0)
@@ -167,16 +168,16 @@ void put_field_val(char *rp, dbfield_t *fldp, char *cp)
*/
void out_rec(dbhead_t *dbh, dbfield_t *dbf, char *cp)
{
dbfield_t *cur_f;
int nfields = dbh->db_nfields;
char *fnp = (char *)malloc(dbh->db_rlen);
dbfield_t *cur_f;
int nfields = dbh->db_nfields;
char *fnp = (char *)malloc(dbh->db_rlen);
printf("%c", *cp);
for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) {
printf(" ");
printf("%c", *cp);
for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) {
printf(" ");
printf(cur_f->db_format, get_field_val(cp, cur_f, fnp));
}
printf("\n");
}
printf("\n");
free(fnp);
}
+29 -12
View File
@@ -33,6 +33,8 @@ typedef struct {
int cflags;
} reg_cache;
static int reg_magic = 0;
/* {{{ _php_regcomp
*/
static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
@@ -42,19 +44,34 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
reg_cache *rc = NULL;
TSRMLS_FETCH();
if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == FAILURE ||
rc->cflags != cflags) {
r = regcomp(preg, pattern, cflags);
if(!r) {
reg_cache rcp;
rcp.cflags = cflags;
memcpy(&rcp.preg, preg, sizeof(*preg));
zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
(void *) &rcp, sizeof(rcp), NULL);
if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
&& rc->cflags == cflags) {
/*
* We use a saved magic number to see whether cache is corrupted, and if it
* is, we flush it and compile the pattern from scratch.
*/
if (rc->preg.re_magic != reg_magic) {
zend_hash_clean(&REG(ht_rc));
} else {
memcpy(preg, &rc->preg, sizeof(*preg));
return r;
}
} else {
memcpy(preg, &rc->preg, sizeof(*preg));
}
r = regcomp(preg, pattern, cflags);
if(!r) {
reg_cache rcp;
rcp.cflags = cflags;
memcpy(&rcp.preg, preg, sizeof(*preg));
/*
* Since we don't have access to the actual MAGIC1 definition in the private
* header file, we save the magic value immediately after compilation. Hopefully,
* it's good.
*/
if (!reg_magic) reg_magic = preg->re_magic;
zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
(void *) &rcp, sizeof(rcp), NULL);
}
return r;
+1
View File
@@ -311,6 +311,7 @@ dnl These are always available with bundled library
AC_DEFINE(HAVE_GD_IMAGEELLIPSE, 1, [ ])
AC_DEFINE(HAVE_GD_FONTCACHESHUTDOWN,1, [ ])
AC_DEFINE(HAVE_GD_DYNAMIC_CTX_EX, 1, [ ])
AC_DEFINE(HAVE_GD_GIF_CTX, 1, [ ])
dnl Make sure the libgd/ is first in the include path
GDLIB_CFLAGS="-DHAVE_LIBPNG"
+3 -2
View File
@@ -1699,7 +1699,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
char buf[4096];
char *path;
tmp = php_open_temporary_file("", "", &path TSRMLS_CC);
tmp = php_open_temporary_file(NULL, NULL, &path TSRMLS_CC);
if (tmp == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open temporary file");
RETURN_FALSE;
@@ -3017,7 +3017,8 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
{
zval *IM, *EXT = NULL;
gdImagePtr im=NULL;
int col = -1, x = -1, y = -1, str_len, fontname_len, i, brect[8];
long col = -1, x = -1, y = -1;
int str_len, fontname_len, i, brect[8];
double ptsize, angle;
unsigned char *str = NULL, *fontname = NULL;
char *error = NULL;
+2 -2
View File
@@ -1737,8 +1737,8 @@ void gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
rx = r << 1;
ry = 0;
x = a;
old_y2=-1;
old_y1=-1;
old_y2=-2;
old_y1=-2;
while (x > 0){
if (r > 0) {
my1++;my2--;
+1 -1
View File
@@ -1,5 +1,5 @@
--TEST--
gdimagefill() function (Bug #19366 (fixed in bundled libgd))
Bug #19366 (gdimagefill() function crashes (fixed in bundled libgd))
--SKIPIF--
<?php
if (!extension_loaded('gd')) die("skip gd extension not available\n");
+1 -1
View File
@@ -1,5 +1,5 @@
--TEST--
gdimagefill() function (Bug #19366 (fixed in bundled libgd))
Bug #27582 (ImageFillToBorder() on alphablending image looses alpha on fill color)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die("skip gd extension not available\n");
+46 -24
View File
@@ -205,7 +205,7 @@ ZEND_MODULE_INFO_D(gmp)
if(Z_TYPE_PP(zval) == IS_RESOURCE) { \
ZEND_FETCH_RESOURCE(gmpnumber, mpz_t *, zval, -1, GMP_RESOURCE_NAME, le_gmp);\
} else {\
if(convert_to_gmp(&gmpnumber, zval, 0) == FAILURE) {\
if(convert_to_gmp(&gmpnumber, zval, 0 TSRMLS_CC) == FAILURE) {\
RETURN_FALSE;\
}\
ZEND_REGISTER_RESOURCE(NULL, gmpnumber, le_gmp);\
@@ -217,7 +217,7 @@ if(Z_TYPE_PP(zval) == IS_RESOURCE) { \
/* {{{ convert_to_gmp
* Convert zval to be gmp number */
static int convert_to_gmp(mpz_t * *gmpnumber, zval **val, int base)
static int convert_to_gmp(mpz_t * *gmpnumber, zval **val, int base TSRMLS_DC)
{
int ret = 0;
int skip_lead = 0;
@@ -280,8 +280,8 @@ typedef void (*gmp_binary_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);
typedef unsigned long (*gmp_binary_ui_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long);
/* }}} */
#define gmp_zval_binary_ui_op(r, a, b, o, u) gmp_zval_binary_ui_op_ex(r, a, b, o, u, 0 TSRMLS_CC)
#define gmp_zval_binary_ui_op2(r, a, b, o, u) gmp_zval_binary_ui_op2_ex(r, a, b, o, u, 0 TSRMLS_CC)
#define gmp_zval_binary_ui_op(r, a, b, o, u) gmp_zval_binary_ui_op_ex(r, a, b, o, u, 0, 0 TSRMLS_CC)
#define gmp_zval_binary_ui_op2(r, a, b, o, u) gmp_zval_binary_ui_op2_ex(r, a, b, o, u, 0, 0 TSRMLS_CC)
#define gmp_binary_ui_op(op, uop) _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, uop)
#define gmp_binary_op(op) _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, NULL)
@@ -296,7 +296,7 @@ typedef unsigned long (*gmp_binary_ui_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, unsig
Execute GMP binary operation.
May return GMP resource or long if operation allows this
*/
static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zval **b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int allow_ui_return TSRMLS_DC)
static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zval **b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int allow_ui_return, int check_b_zero TSRMLS_DC)
{
mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result;
unsigned long long_result=0;
@@ -309,10 +309,20 @@ static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zv
FETCH_GMP_ZVAL(gmpnum_b, b_arg);
}
if (!Z_LVAL_PP(b_arg)) {
RETURN_FALSE;
}
if(check_b_zero) {
int b_is_zero = 0;
if(use_ui) {
b_is_zero = (Z_LVAL_PP(b_arg) == 0);
} else {
b_is_zero = !mpz_cmp_ui(*gmpnum_b, 0);
}
if(b_is_zero) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Zero operand not allowed");
RETURN_FALSE;
}
}
INIT_GMP_NUM(gmpnum_result);
if(use_ui && gmp_ui_op) {
if(allow_ui_return) {
@@ -337,7 +347,7 @@ static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zv
Execute GMP binary operation which returns 2 values.
May return GMP resources or longs if operation allows this.
*/
static inline void gmp_zval_binary_ui_op2_ex(zval *return_value, zval **a_arg, zval **b_arg, gmp_binary_op2_t gmp_op, gmp_binary_ui_op2_t gmp_ui_op, int allow_ui_return TSRMLS_DC)
static inline void gmp_zval_binary_ui_op2_ex(zval *return_value, zval **a_arg, zval **b_arg, gmp_binary_op2_t gmp_op, gmp_binary_ui_op2_t gmp_ui_op, int allow_ui_return, int check_b_zero TSRMLS_DC)
{
mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result1, *gmpnum_result2;
zval r;
@@ -352,10 +362,20 @@ static inline void gmp_zval_binary_ui_op2_ex(zval *return_value, zval **a_arg, z
FETCH_GMP_ZVAL(gmpnum_b, b_arg);
}
if (!Z_LVAL_PP(b_arg)) {
RETURN_FALSE;
}
if(check_b_zero) {
int b_is_zero = 0;
if(use_ui) {
b_is_zero = (Z_LVAL_PP(b_arg) == 0);
} else {
b_is_zero = !mpz_cmp_ui(*gmpnum_b, 0);
}
if(b_is_zero) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Zero operand not allowed");
RETURN_FALSE;
}
}
INIT_GMP_NUM(gmpnum_result1);
INIT_GMP_NUM(gmpnum_result2);
@@ -509,7 +529,7 @@ ZEND_FUNCTION(gmp_init)
}
}
if(convert_to_gmp(&gmpnumber, number_arg, base) == FAILURE) {
if(convert_to_gmp(&gmpnumber, number_arg, base TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
}
@@ -642,13 +662,13 @@ ZEND_FUNCTION(gmp_div_qr)
switch(round) {
case GMP_ROUND_ZERO:
gmp_zval_binary_ui_op2(return_value, a_arg, b_arg, mpz_tdiv_qr, (gmp_binary_ui_op2_t)mpz_tdiv_qr_ui);
gmp_zval_binary_ui_op2_ex(return_value, a_arg, b_arg, mpz_tdiv_qr, (gmp_binary_ui_op2_t)mpz_tdiv_qr_ui, 0, 1 TSRMLS_CC);
break;
case GMP_ROUND_PLUSINF:
gmp_zval_binary_ui_op2(return_value, a_arg, b_arg, mpz_cdiv_qr, (gmp_binary_ui_op2_t)mpz_cdiv_qr_ui);
gmp_zval_binary_ui_op2_ex(return_value, a_arg, b_arg, mpz_cdiv_qr, (gmp_binary_ui_op2_t)mpz_cdiv_qr_ui, 0, 1 TSRMLS_CC);
break;
case GMP_ROUND_MINUSINF:
gmp_zval_binary_ui_op2(return_value, a_arg, b_arg, mpz_fdiv_qr, (gmp_binary_ui_op2_t)mpz_fdiv_qr_ui);
gmp_zval_binary_ui_op2_ex(return_value, a_arg, b_arg, mpz_fdiv_qr, (gmp_binary_ui_op2_t)mpz_fdiv_qr_ui, 0, 1 TSRMLS_CC);
break;
}
@@ -677,15 +697,17 @@ ZEND_FUNCTION(gmp_div_r)
break;
}
switch(round) {
case GMP_ROUND_ZERO:
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_r, (gmp_binary_ui_op_t)mpz_tdiv_r_ui, 1 TSRMLS_CC);
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_r, (gmp_binary_ui_op_t)mpz_tdiv_r_ui, 1, 1 TSRMLS_CC);
break;
case GMP_ROUND_PLUSINF:
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_r, (gmp_binary_ui_op_t)mpz_cdiv_r_ui, 1 TSRMLS_CC);
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_r, (gmp_binary_ui_op_t)mpz_cdiv_r_ui, 1, 1 TSRMLS_CC);
break;
case GMP_ROUND_MINUSINF:
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_r, (gmp_binary_ui_op_t)mpz_fdiv_r_ui, 1 TSRMLS_CC);
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_r, (gmp_binary_ui_op_t)mpz_fdiv_r_ui, 1, 1 TSRMLS_CC);
break;
}
}
@@ -715,13 +737,13 @@ ZEND_FUNCTION(gmp_div_q)
switch(round) {
case GMP_ROUND_ZERO:
gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_tdiv_q, (gmp_binary_ui_op_t)mpz_tdiv_q_ui);
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_q, (gmp_binary_ui_op_t)mpz_tdiv_q_ui, 0, 1 TSRMLS_CC);
break;
case GMP_ROUND_PLUSINF:
gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_cdiv_q, (gmp_binary_ui_op_t)mpz_cdiv_q_ui);
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_q, (gmp_binary_ui_op_t)mpz_cdiv_q_ui, 0, 1 TSRMLS_CC);
break;
case GMP_ROUND_MINUSINF:
gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_fdiv_q, (gmp_binary_ui_op_t)mpz_fdiv_q_ui);
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_q, (gmp_binary_ui_op_t)mpz_fdiv_q_ui, 0, 1 TSRMLS_CC);
break;
}
@@ -738,7 +760,7 @@ ZEND_FUNCTION(gmp_mod)
WRONG_PARAM_COUNT;
}
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_mod, (gmp_binary_ui_op_t)mpz_mod_ui, 1 TSRMLS_CC);
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_mod, (gmp_binary_ui_op_t)mpz_mod_ui, 1, 1 TSRMLS_CC);
}
/* }}} */
@@ -984,7 +1006,7 @@ ZEND_FUNCTION(gmp_gcd)
WRONG_PARAM_COUNT;
}
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_gcd, (gmp_binary_ui_op_t)mpz_gcd_ui, 1 TSRMLS_CC);
gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_gcd, (gmp_binary_ui_op_t)mpz_gcd_ui, 1, 0 TSRMLS_CC);
}
/* }}} */
+22
View File
@@ -0,0 +1,22 @@
--TEST--
Bug #32773 binary GMP functions returns unexpected value, when second parameter is int(0)
--SKIPIF--
<?php if (!extension_loaded("gmp")) print "skip"; ?>
--FILE--
<?php
echo '10 + 0 = ', gmp_strval(gmp_add(10, 0)), "\n";
echo '10 + "0" = ', gmp_strval(gmp_add(10, '0')), "\n";
echo gmp_strval(gmp_div(10, 0))."\n";
echo gmp_strval(gmp_div_qr(10, 0))."\n";
?>
--EXPECTF--
10 + 0 = 10
10 + "0" = 10
Warning: gmp_div(): Zero operand not allowed in %s on line %d
0
Warning: gmp_div_qr(): Zero operand not allowed in %s on line %d
0
+2 -1
View File
@@ -3015,7 +3015,8 @@ PHP_FUNCTION(imap_mail_compose)
if (zend_hash_find(Z_ARRVAL_PP(data), "charset", sizeof("charset"), (void **) &pvalue)== SUCCESS) {
convert_to_string_ex(pvalue);
tmp_param = mail_newbody_parameter();
tmp_param->value = cpystr(Z_STRVAL_PP(pvalue));
tmp_param->value = (char *) fs_get(Z_STRLEN_PP(pvalue) + 1);
memcpy(tmp_param->value, Z_STRVAL_PP(pvalue), Z_STRLEN_PP(pvalue) + 1);
tmp_param->attribute = "CHARSET";
tmp_param->next = bod->parameter;
bod->parameter = tmp_param;
-59
View File
@@ -1,59 +0,0 @@
--TEST--
Bug #31142 test #1 (imap_mail_compose() generates incorrect output)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
?>
--FILE--
<?php
$envelope["from"]= "joe@example.com";
$envelope["to"] = "foo@example.com";
$envelope["cc"] = "bar@example.com";
$part1["type"] = TYPEMULTIPART;
$part1["subtype"] = "mixed";
$part2["type"] = TYPEAPPLICATION;
$part2["encoding"] = ENCBINARY;
$part2["subtype"] = "octet-stream";
$part2["description"] = "some file";
$part2["contents.data"] = "ABC";
$part3["type"] = TYPETEXT;
$part3["subtype"] = "plain";
$part3["description"] = "description3";
$part3["contents.data"] = "contents.data3\n\n\n\t";
$body[1] = $part1;
$body[2] = $part2;
$body[3] = $part3;
echo imap_mail_compose($envelope, $body);
?>
--EXPECTF--
From: joe@example.com
To: foo@example.com
cc: bar@example.com
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
--%s
Content-Type: APPLICATION/octet-stream
Content-Transfer-Encoding: BASE64
Content-Description: some file
QUJD
--%s
Content-Type: TEXT/plain; CHARSET=US-ASCII
Content-Description: description3
contents.data3
--%s--
-30
View File
@@ -1,30 +0,0 @@
--TEST--
Bug #31142 test #2 (imap_mail_compose() generates incorrect output)
--SKIPIF--
<?php
if (!extension_loaded("imap")) {
die("skip imap extension not available");
}
?>
--FILE--
<?php
$envelope["from"]= 'host@domain.com';
$envelope["return_path"]= 'host@domain.com';
$part1["type"]=TYPETEXT;
$part1["subtype"]="plain";
$part1["encoding"]=ENCQUOTEDPRINTABLE ;
$part1["charset"]='iso-8859-2';
$part1["contents.data"]=imap_8bit('asn řkl');
$body = array($part1);
echo imap_mail_compose($envelope, $body);
?>
--EXPECT--
From: host@domain.com
MIME-Version: 1.0
Content-Type: TEXT/plain; CHARSET=iso-8859-2
Content-Transfer-Encoding: QUOTED-PRINTABLE
asn =C5=99kl
+4 -2
View File
@@ -29,7 +29,9 @@ if test "$PHP_INGRES" != "no"; then
AC_MSG_ERROR(Cannot find libiiapi.a under $II_DIR/lib)
fi
PHP_ADD_LIBRARY_WITH_PATH(iiapi, $II_LIB_DIR, II_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(ingres, $II_LIB_DIR, II_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(iiapi.1, $II_LIB_DIR, II_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(q.1, $II_LIB_DIR, II_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(frame.1, $II_LIB_DIR, II_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(compat.1, $II_LIB_DIR, II_SHARED_LIBADD)
PHP_ADD_INCLUDE($II_INC_DIR)
fi
+14 -4
View File
@@ -99,7 +99,9 @@ if test "$PHP_LDAP" != "no"; then
elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME; then
PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
AC_DEFINE(HAVE_ORALDAP,1,[ ])
if test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
AC_DEFINE(HAVE_ORALDAP_10,1,[ ])
fi
else
AC_MSG_ERROR(Cannot find ldap libraries in $LDAP_LIBDIR.)
fi
@@ -112,8 +114,6 @@ if test "$PHP_LDAP" != "no"; then
_SAVE_CPPFLAGS=$CPPFLAGS
_SAVE_LDFLAGS=$LDFLAGS
CPPFLAGS="$CPPFLAGS -I$LDAP_INCDIR"
LDFLAGS="$LDFLAGS $LDAP_SHARED_LIBADD"
AC_CACHE_CHECK([for 3 arg ldap_set_rebind_proc], ac_cv_3arg_setrebindproc,
[AC_TRY_COMPILE([#include <ldap.h>], [ldap_set_rebind_proc(0,0,0)],
ac_cv_3arg_setrebindproc=yes, ac_cv_3arg_setrebindproc=no)])
@@ -124,6 +124,16 @@ if test "$PHP_LDAP" != "no"; then
dnl Solaris 2.8 claims to be 2004 API, but doesn't have
dnl ldap_parse_reference() nor ldap_start_tls_s()
AC_CHECK_FUNCS([ldap_parse_reference ldap_start_tls_s])
AC_CHECK_FUNCS([ldap_parse_result ldap_parse_reference ldap_start_tls_s])
LDFLAGS=$_SAVE_LDFLAGS
dnl
dnl Sanity check
dnl
_SAVE_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $LDAP_SHARED_LIBADD"
AC_CHECK_FUNC(ldap_bind_s, [], [
AC_MSG_ERROR([LDAP build check failed. Please check config.log for more information.])
])
LDFLAGS=$_SAVE_LDFLAGS
fi
+35 -26
View File
@@ -121,16 +121,18 @@ function_entry ldap_functions[] = {
PHP_FE(ldap_compare, NULL)
PHP_FE(ldap_sort, NULL)
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
PHP_FE(ldap_rename, NULL)
PHP_FE(ldap_get_option, third_argument_force_ref)
PHP_FE(ldap_set_option, NULL)
PHP_FE(ldap_parse_result, arg3to6of6_force_ref)
PHP_FE(ldap_first_reference, NULL)
PHP_FE(ldap_next_reference, NULL)
#ifdef HAVE_LDAP_PARSE_REFERENCE
PHP_FE(ldap_parse_reference, third_argument_force_ref)
#endif
PHP_FE(ldap_rename, NULL)
#ifdef HAVE_LDAP_PARSE_RESULT
PHP_FE(ldap_parse_result, arg3to6of6_force_ref)
#endif
#ifdef HAVE_LDAP_START_TLS_S
PHP_FE(ldap_start_tls, NULL)
#endif
@@ -223,7 +225,7 @@ PHP_MINIT_FUNCTION(ldap)
REGISTER_LONG_CONSTANT("LDAP_DEREF_FINDING", LDAP_DEREF_FINDING, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_DEREF_ALWAYS", LDAP_DEREF_ALWAYS, CONST_PERSISTENT | CONST_CS);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
/* LDAP options */
REGISTER_LONG_CONSTANT("LDAP_OPT_DEREF", LDAP_OPT_DEREF, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_OPT_SIZELIMIT", LDAP_OPT_SIZELIMIT, CONST_PERSISTENT | CONST_CS);
@@ -234,7 +236,9 @@ PHP_MINIT_FUNCTION(ldap)
#ifdef LDAP_OPT_RESTART
REGISTER_LONG_CONSTANT("LDAP_OPT_RESTART", LDAP_OPT_RESTART, CONST_PERSISTENT | CONST_CS);
#endif
#ifdef LDAP_OPT_HOST_NAME
REGISTER_LONG_CONSTANT("LDAP_OPT_HOST_NAME", LDAP_OPT_HOST_NAME, CONST_PERSISTENT | CONST_CS);
#endif
REGISTER_LONG_CONSTANT("LDAP_OPT_ERROR_STRING", LDAP_OPT_ERROR_STRING, CONST_PERSISTENT | CONST_CS);
#ifdef LDAP_OPT_MATCHED_DN
REGISTER_LONG_CONSTANT("LDAP_OPT_MATCHED_DN", LDAP_OPT_MATCHED_DN, CONST_PERSISTENT | CONST_CS);
@@ -414,7 +418,7 @@ PHP_FUNCTION(ldap_connect)
static int _get_lderrno(LDAP *ldap)
{
#if !HAVE_NSLDAP
#if LDAP_API_VERSION > 2000
#if LDAP_API_VERSION > 2000 || HAVE_ORALDAP_10
int lderr;
/* New versions of OpenLDAP do it this way */
@@ -478,7 +482,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
{
/* sizelimit */
if (sizelimit > -1) {
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
ldap_set_option(ldap, LDAP_OPT_SIZELIMIT, &sizelimit);
#else
ldap->ld_sizelimit = sizelimit;
@@ -487,7 +491,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
/* timelimit */
if (timelimit > -1) {
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
ldap_set_option(ldap, LDAP_OPT_TIMELIMIT, &timelimit);
#else
ldap->ld_timelimit = timelimit;
@@ -496,7 +500,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
/* deref */
if (deref > -1) {
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
#else
ldap->ld_deref = deref;
@@ -915,12 +919,12 @@ PHP_FUNCTION(ldap_get_entries)
add_index_string(tmp1, num_attrib, attribute, 1);
num_attrib++;
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
#endif
attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
}
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
if (ber != NULL)
ber_free(ber, 0);
#endif
@@ -928,7 +932,7 @@ PHP_FUNCTION(ldap_get_entries)
add_assoc_long(tmp1, "count", num_attrib);
dn = ldap_get_dn(ldap, ldap_result_entry);
add_assoc_string(tmp1, "dn", dn, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(dn);
#else
free(dn);
@@ -968,7 +972,7 @@ PHP_FUNCTION(ldap_first_attribute)
ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry);
RETVAL_STRING(attribute, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
#endif
}
@@ -999,7 +1003,7 @@ PHP_FUNCTION(ldap_next_attribute)
ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry);
RETVAL_STRING(attribute, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
#endif
}
@@ -1046,12 +1050,12 @@ PHP_FUNCTION(ldap_get_attributes)
add_index_string(return_value, num_attrib, attribute, 1);
num_attrib++;
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
#endif
attribute = ldap_next_attribute(ld->link, resultentry->data, ber);
}
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
if (ber != NULL) {
ber_free(ber, 0);
}
@@ -1159,7 +1163,7 @@ PHP_FUNCTION(ldap_get_dn)
text = ldap_get_dn(ld->link, resultentry->data);
if (text != NULL) {
RETVAL_STRING(text, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(text);
#else
free(text);
@@ -1222,7 +1226,7 @@ PHP_FUNCTION(ldap_dn2ufn)
if (ufn !=NULL) {
RETVAL_STRING(ufn, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(ufn);
#endif
} else {
@@ -1542,8 +1546,7 @@ PHP_FUNCTION(ldap_sort)
}
/* }}} */
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
/* {{{ proto bool ldap_get_option(resource link, int option, mixed retval)
Get the current value of various session-wide parameters */
PHP_FUNCTION(ldap_get_option)
@@ -1581,8 +1584,10 @@ PHP_FUNCTION(ldap_get_option)
ZVAL_LONG(*retval, val);
} break;
/* options with string value */
case LDAP_OPT_HOST_NAME:
case LDAP_OPT_ERROR_STRING:
#ifdef LDAP_OPT_HOST_NAME
case LDAP_OPT_HOST_NAME:
#endif
#ifdef LDAP_OPT_MATCHED_DN
case LDAP_OPT_MATCHED_DN:
#endif
@@ -1636,7 +1641,7 @@ PHP_FUNCTION(ldap_set_option)
opt = Z_LVAL_PP(option);
switch (opt) {
/* options with int value */
/* options with int value */
case LDAP_OPT_DEREF:
case LDAP_OPT_SIZELIMIT:
case LDAP_OPT_TIMELIMIT:
@@ -1653,9 +1658,11 @@ PHP_FUNCTION(ldap_set_option)
RETURN_FALSE;
}
} break;
/* options with string value */
case LDAP_OPT_HOST_NAME:
/* options with string value */
case LDAP_OPT_ERROR_STRING:
#ifdef LDAP_OPT_HOST_NAME
case LDAP_OPT_HOST_NAME:
#endif
#ifdef LDAP_OPT_MATCHED_DN
case LDAP_OPT_MATCHED_DN:
#endif
@@ -1751,6 +1758,7 @@ PHP_FUNCTION(ldap_set_option)
}
/* }}} */
#ifdef HAVE_LDAP_PARSE_RESULT
/* {{{ proto bool ldap_parse_result(resource link, resource result, int errcode, string matcheddn, string errmsg, array referrals)
Extract information from result */
PHP_FUNCTION(ldap_parse_result)
@@ -1816,6 +1824,7 @@ PHP_FUNCTION(ldap_parse_result)
RETURN_TRUE;
}
/* }}} */
#endif
/* {{{ proto resource ldap_first_reference(resource link, resource result)
Return first reference */
@@ -1928,7 +1937,7 @@ PHP_FUNCTION(ldap_rename)
convert_to_string_ex(newparent);
convert_to_boolean_ex(deleteoldrdn);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
rc = ldap_rename_s(ld->link, Z_STRVAL_PP(dn), Z_STRVAL_PP(newrdn), Z_STRVAL_PP(newparent), Z_BVAL_PP(deleteoldrdn), NULL, NULL);
#else
if (Z_STRLEN_PP(newparent) != 0) {
@@ -1972,10 +1981,10 @@ PHP_FUNCTION(ldap_start_tls)
}
/* }}} */
#endif
#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP */
#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 */
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
/* {{{ proto _ldap_rebind_proc()
/* {{{ _ldap_rebind_proc()
*/
int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgid, void *params)
{
+7 -15
View File
@@ -34,59 +34,51 @@ extern zend_module_entry ldap_module_entry;
/* LDAP functions */
PHP_MINIT_FUNCTION(ldap);
PHP_MSHUTDOWN_FUNCTION(ldap);
PHP_MINFO_FUNCTION(ldap);
PHP_FUNCTION(ldap_connect);
PHP_FUNCTION(ldap_bind);
PHP_FUNCTION(ldap_unbind);
PHP_FUNCTION(ldap_read);
PHP_FUNCTION(ldap_list);
PHP_FUNCTION(ldap_search);
PHP_FUNCTION(ldap_free_result);
PHP_FUNCTION(ldap_count_entries);
PHP_FUNCTION(ldap_first_entry);
PHP_FUNCTION(ldap_next_entry);
PHP_FUNCTION(ldap_get_entries);
PHP_FUNCTION(ldap_first_attribute);
PHP_FUNCTION(ldap_next_attribute);
PHP_FUNCTION(ldap_get_attributes);
PHP_FUNCTION(ldap_get_values);
PHP_FUNCTION(ldap_get_values_len);
PHP_FUNCTION(ber_free);
PHP_FUNCTION(ldap_get_dn);
PHP_FUNCTION(ldap_explode_dn);
PHP_FUNCTION(ldap_dn2ufn);
PHP_FUNCTION(ldap_add);
PHP_FUNCTION(ldap_delete);
PHP_FUNCTION(ldap_mod_add);
PHP_FUNCTION(ldap_mod_replace);
PHP_FUNCTION(ldap_mod_del);
PHP_FUNCTION(ldap_errno);
PHP_FUNCTION(ldap_err2str);
PHP_FUNCTION(ldap_error);
PHP_FUNCTION(ldap_compare);
PHP_FUNCTION(ldap_sort);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
PHP_FUNCTION(ldap_get_option);
PHP_FUNCTION(ldap_set_option);
PHP_FUNCTION(ldap_parse_result);
PHP_FUNCTION(ldap_first_reference);
PHP_FUNCTION(ldap_next_reference);
PHP_FUNCTION(ldap_parse_reference);
PHP_FUNCTION(ldap_rename);
#ifdef HAVE_LDAP_PARSE_RESULT
PHP_FUNCTION(ldap_parse_result);
#endif
#ifdef HAVE_LDAP_PARSE_REFERENCE
PHP_FUNCTION(ldap_parse_reference);
#endif
#endif
#if LDAP_API_VERSION > 2000
+32 -11
View File
@@ -405,16 +405,16 @@ mbfl_encoding_detector_feed(mbfl_encoding_detector *identd, mbfl_string *string)
num = identd->filter_list_size;
n = string->len;
p = string->val;
bad = 0;
while (n > 0) {
i = 0;
bad = 0;
while (i < num) {
for (i = 0; i < num; i++) {
filter = identd->filter_list[i];
(*filter->filter_function)(*p, filter);
if (filter->flag) {
bad++;
if (!filter->flag) {
(*filter->filter_function)(*p, filter);
if (filter->flag) {
bad++;
}
}
i++;
}
if ((num - 1) <= bad) {
res = 1;
@@ -555,9 +555,11 @@ mbfl_identify_encoding(mbfl_string *string, enum mbfl_no_encoding *elist, int el
while (n > 0) {
for (i = 0; i < num; i++) {
filter = &flist[i];
(*filter->filter_function)(*p, filter);
if (filter->flag) {
bad++;
if (!filter->flag) {
(*filter->filter_function)(*p, filter);
if (filter->flag) {
bad++;
}
}
}
if ((num - 1) <= bad && !strict) {
@@ -1960,6 +1962,25 @@ mime_header_encoder_block_collector(int c, void *data)
static int
mime_header_encoder_collector(int c, void *data)
{
static int qp_table[256] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00 */
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
0, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 1, 0, 1, /* 0x10 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 0x50 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 0x70 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xA0 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xB0 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xC0 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xD0 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xE0 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 /* 0xF0 */
};
int n;
struct mime_header_encoder_data *pe = (struct mime_header_encoder_data *)data;
@@ -1969,7 +1990,7 @@ mime_header_encoder_collector(int c, void *data)
break;
default: /* ASCII */
if (c >= 0x21 && c < 0x7f) { /* ASCII exclude SPACE and CTLs */
if (!qp_table[(c & 0xff)]) { /* ordinary characters */
mbfl_memory_device_output(c, &pe->tmpdev);
pe->status1 = 1;
} else if (pe->status1 == 0 && c == 0x20) { /* repeat SPACE */
+4
View File
@@ -317,7 +317,11 @@ PHP_MINIT_FUNCTION(mssql)
PHP_MSHUTDOWN_FUNCTION(mssql)
{
UNREGISTER_INI_ENTRIES();
#ifndef HAVE_FREETDS
dbwinexit();
#else
dbexit();
#endif
return SUCCESS;
}
+1 -1
View File
@@ -239,7 +239,7 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_ALLOCA
#define HAVE_STRPBRK
#define HAVE_STRSTR
/* #define HAVE_COMPRESS -- not with PHP, please */
#define HAVE_COMPRESS
#ifdef NOT_USED
#define HAVE_SNPRINTF /* Gave link error */
+3
View File
@@ -51,6 +51,9 @@
# endif
# include <netdb.h>
# include <netinet/in.h>
# if HAVE_ARPA_INET_H
# include <arpa/inet.h>
# endif
#endif
#include <mysql.h>
+12 -6
View File
@@ -836,18 +836,18 @@ _oci_conn_list_dtor(oci_connection *connection TSRMLS_DC)
(ub4) OCI_HTYPE_SVCCTX));
}
if (connection->session && connection->session->exclusive) {
/* exclusive connection created via OCINLogon() close their
associated session when destructed */
zend_list_delete(connection->session->num);
}
if (connection->pError) {
CALL_OCI(OCIHandleFree(
(dvoid *) connection->pError,
(ub4) OCI_HTYPE_ERROR));
}
if (connection->session && connection->session->exclusive) {
/* exclusive connection created via OCINLogon() close their
associated session when destructed */
zend_list_delete(connection->session->num);
}
oci_debug("END _oci_conn_list_dtor: id=%d",connection->id);
efree(connection);
@@ -2975,6 +2975,12 @@ break;
}
value_sz = sizeof(void*);
break;
case SQLT_CHR:
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown or unsupported datatype given: %u", ocitype);
RETURN_FALSE;
break;
}
if ((ocitype == SQLT_CHR) && (value_sz == -1)) {
+30 -3
View File
@@ -223,7 +223,7 @@ AC_MSG_CHECKING(for Empress support)
AC_ARG_WITH(empress,
[ --with-empress[=DIR] Include Empress support. DIR is the Empress base
install directory, defaults to \$EMPRESSPATH.
From PHP4, this option only supports Empress Version
From PHP 4, this option only supports Empress Version
8.60 and above],
[
PHP_WITH_SHARED
@@ -255,7 +255,7 @@ AC_ARG_WITH(empress-bcs,
[ --with-empress-bcs[=DIR]
Include Empress Local Access support. DIR is the
Empress base install directory, defaults to
\$EMPRESSPATH. From PHP4, this option only supports
\$EMPRESSPATH. From PHP 4, this option only supports
Empress Version 8.60 and above.],
[
PHP_WITH_SHARED
@@ -313,10 +313,35 @@ AC_ARG_WITH(birdstep,
ODBC_INCDIR=$withval/include
ODBC_LIBDIR=$withval/lib
fi
case $host_alias in
*aix*[)]
AC_DEFINE(AIX,1,[ ]);;
*hpux*[)]
AC_DEFINE(HPUX,1,[ ]);;
*linux*[)]
AC_DEFINE(LINUX,1,[ ]);;
*qnx*[)]
AC_DEFINE(NEUTRINO,1,[ ]);;
i?86-*-solaris*[)]
AC_DEFINE(ISOLARIS,1,[ ]);;
sparc-*-solaris*[)]
AC_DEFINE(SOLARIS,1,[ ]);;
*unixware*[)]
AC_DEFINE(UNIXWARE,1,[ ]);;
esac
ODBC_INCLUDE=-I$ODBC_INCDIR
ODBC_TYPE=birdstep
ODBC_LFLAGS=-L$ODBC_LIBDIR
ODBC_LIBS="-lCadm -lCdict -lCenc -lCrdm -lCrpc -lCrdbc -lCrm -lCuapi -lutil"
if test -e "$ODBC_LIBDIR/libCrdbc32.$SHLIB_SUFFIX_NAME"; then
ODBC_LIBS="-lCrdbc32 -lCadm32 -lCncp32 -lCrm32 -lCsql32 -lCdict32 -lCrdm32 -lCrpc32 -lutil"
elif test -e "$ODBC_LIBDIR/libCrdbc.$SHLIB_SUFFIX_NAME"; then
ODBC_LIBS="-lCrdbc -lCadm -lCncp -lCrm -lCsql -lCdict -lCrdm -lCrpc -lutil"
fi
AC_DEFINE(HAVE_BIRDSTEP,1,[ ])
AC_MSG_RESULT(yes)
@@ -514,7 +539,9 @@ if test -n "$ODBC_TYPE"; then
if test "$ODBC_TYPE" != "dbmaker"; then
ext_shared=$shared
PHP_EVAL_LIBLINE([$ODBC_LFLAGS $ODBC_LIBS], ODBC_SHARED_LIBADD)
AC_DEFINE(HAVE_SQLDATASOURCES,1,[ ])
if test "$ODBC_TYPE" != "birdstep"; then
AC_DEFINE(HAVE_SQLDATASOURCES,1,[ ])
fi
fi
AC_DEFINE(HAVE_UODBC,1,[ ])
+5 -3
View File
@@ -245,7 +245,7 @@ static void _close_odbc_pconn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
odbc_result *res;
odbc_connection *conn = (odbc_connection *)rsrc->ptr;
nument = zend_hash_next_free_element(&EG(regular_list));
nument = zend_hash_next_free_element(&EG(persistent_list));
for(i = 1; i < nument; i++) {
ptr = zend_list_find(i, &type);
if (ptr && (type == le_result)) {
@@ -2436,8 +2436,10 @@ PHP_FUNCTION(odbc_next_result)
result->values = NULL;
}
RETURN_TRUE;
}
else {
} else if (rc == SQL_NO_DATA_FOUND) {
RETURN_FALSE;
} else {
odbc_sql_error(result->conn_ptr, result->stmt, "SQLMoreResults");
RETURN_FALSE;
}
}
+1 -1
View File
@@ -33,7 +33,7 @@
extern zend_module_entry odbc_module_entry;
#define odbc_module_ptr &odbc_module_entry
#if defined(HAVE_DBMAKER) || defined(PHP_WIN32) || defined(HAVE_IBMDB2) || defined(HAVE_UNIXODBC)
#if defined(HAVE_DBMAKER) || defined(PHP_WIN32) || defined(HAVE_IBMDB2) || defined(HAVE_UNIXODBC) || defined(HAVE_BIRDSTEP)
# define PHP_ODBC_HAVE_FETCH_HASH 1
#endif
+1 -1
View File
@@ -216,7 +216,7 @@ typedef struct odbc_connection {
typedef struct odbc_result_value {
char name[32];
char *value;
long int vallen;
SDWORD vallen;
SDWORD coltype;
} odbc_result_value;
+4 -4
View File
@@ -2510,7 +2510,7 @@ PHP_FUNCTION(openssl_private_encrypt)
cryptedlen = EVP_PKEY_size(pkey);
cryptedbuf = emalloc(cryptedlen + 1);
switch (Z_TYPE_P(pkey)) {
switch (pkey->type) {
case EVP_PKEY_RSA:
case EVP_PKEY_RSA2:
successful = (RSA_private_encrypt(data_len,
@@ -2566,7 +2566,7 @@ PHP_FUNCTION(openssl_private_decrypt)
cryptedlen = EVP_PKEY_size(pkey);
crypttemp = emalloc(cryptedlen + 1);
switch (Z_TYPE_P(pkey)) {
switch (pkey->type) {
case EVP_PKEY_RSA:
case EVP_PKEY_RSA2:
cryptedlen = RSA_private_decrypt(data_len,
@@ -2629,7 +2629,7 @@ PHP_FUNCTION(openssl_public_encrypt)
cryptedlen = EVP_PKEY_size(pkey);
cryptedbuf = emalloc(cryptedlen + 1);
switch (Z_TYPE_P(pkey)) {
switch (pkey->type) {
case EVP_PKEY_RSA:
case EVP_PKEY_RSA2:
successful = (RSA_public_encrypt(data_len,
@@ -2686,7 +2686,7 @@ PHP_FUNCTION(openssl_public_decrypt)
cryptedlen = EVP_PKEY_size(pkey);
crypttemp = emalloc(cryptedlen + 1);
switch (Z_TYPE_P(pkey)) {
switch (pkey->type) {
case EVP_PKEY_RSA:
case EVP_PKEY_RSA2:
cryptedlen = RSA_public_decrypt(data_len,
+64 -36
View File
@@ -139,17 +139,13 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
static void php_pcntl_init_globals(zend_pcntl_globals *pcntl_globals)
{
/* Just in case ... */
memset(&pcntl_globals->php_signal_queue,0,sizeof(pcntl_globals->php_signal_queue));
zend_llist_init(&pcntl_globals->php_signal_queue, sizeof (long), NULL, 1);
pcntl_globals->signal_queue_ready = 0;
pcntl_globals->processing_signal_queue = 0;
memset(pcntl_globals, 0, sizeof(*pcntl_globals));
}
PHP_RINIT_FUNCTION(pcntl)
{
zend_hash_init(&PCNTL_G(php_signal_table), 16, NULL, ZVAL_PTR_DTOR, 1);
zend_hash_init(&PCNTL_G(php_signal_table), 16, NULL, ZVAL_PTR_DTOR, 0);
PCNTL_G(head) = PCNTL_G(tail) = PCNTL_G(spares) = NULL;
return SUCCESS;
}
@@ -164,13 +160,26 @@ PHP_MINIT_FUNCTION(pcntl)
PHP_MSHUTDOWN_FUNCTION(pcntl)
{
zend_llist_destroy(&PCNTL_G(php_signal_queue));
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(pcntl)
{
struct php_pcntl_pending_signal *sig;
/* FIXME: if a signal is delivered after this point, things will go pear shaped;
* need to remove signal handlers */
zend_hash_destroy(&PCNTL_G(php_signal_table));
while (PCNTL_G(head)) {
sig = PCNTL_G(head);
PCNTL_G(head) = sig->next;
efree(sig);
}
while (PCNTL_G(spares)) {
sig = PCNTL_G(spares);
PCNTL_G(spares) = sig->next;
efree(sig);
}
return SUCCESS;
}
@@ -467,6 +476,19 @@ PHP_FUNCTION(pcntl_signal)
return;
}
if (!PCNTL_G(spares)) {
/* since calling malloc() from within a signal handler is not portable,
* pre-allocate a few records for recording signals */
int i;
for (i = 0; i < 32; i++) {
struct php_pcntl_pending_signal *psig;
psig = emalloc(sizeof(*psig));
psig->next = PCNTL_G(spares);
PCNTL_G(spares) = psig;
}
}
/* Special long value case for SIG_DFL and SIG_IGN */
if (Z_TYPE_P(handle)==IS_LONG) {
if (Z_LVAL_P(handle)!= (long) SIG_DFL && Z_LVAL_P(handle) != (long) SIG_IGN) {
@@ -501,57 +523,63 @@ PHP_FUNCTION(pcntl_signal)
/* Our custom signal handler that calls the appropriate php_function */
static void pcntl_signal_handler(int signo)
{
long signal_num = signo;
struct php_pcntl_pending_signal *psig;
TSRMLS_FETCH();
IF_DEBUG(DEBUG_OUT("Caught signo %d\n", signo));
if (! PCNTL_G(processing_signal_queue)) {
zend_llist_add_element(&PCNTL_G(php_signal_queue), &signal_num);
PCNTL_G(signal_queue_ready) = 1;
IF_DEBUG(DEBUG_OUT("Added queue entry\n"));
psig = PCNTL_G(spares);
if (!psig) {
/* oops, too many signals for us to track, so we'll forget about this one */
return;
}
return;
PCNTL_G(spares) = psig->next;
psig->signo = signo;
psig->next = NULL;
/* the head check is important, as the tick handler cannot atomically clear both
* the head and tail */
if (PCNTL_G(head) && PCNTL_G(tail)) {
PCNTL_G(tail)->next = psig;
} else {
PCNTL_G(head) = psig;
}
PCNTL_G(tail) = psig;
}
void pcntl_tick_handler()
{
zend_llist_element *element;
zval *param, **handle, *retval;
struct php_pcntl_pending_signal *queue, *next;
TSRMLS_FETCH();
/* Bail if the queue is empty or if we are already playing the queue*/
if (! PCNTL_G(signal_queue_ready) || PCNTL_G(processing_signal_queue))
if (! PCNTL_G(head) || PCNTL_G(processing_signal_queue))
return;
/* Mark our queue empty */
PCNTL_G(signal_queue_ready) = 0;
/* If for some reason our signal queue is empty then return */
if (zend_llist_count(&PCNTL_G(php_signal_queue)) <= 0) {
return;
}
/* Prevent reentrant handler calls */
PCNTL_G(processing_signal_queue) = 1;
queue = PCNTL_G(head);
PCNTL_G(head) = NULL; /* simple stores are atomic */
/* Allocate */
MAKE_STD_ZVAL(param);
MAKE_STD_ZVAL(retval);
/* Traverse through our signal queue and call the appropriate php functions */
for (element = (&PCNTL_G(php_signal_queue))->head; element; element = element->next) {
long *signal_num = (long *)&element->data;
if (zend_hash_index_find(&PCNTL_G(php_signal_table), *signal_num, (void **) &handle)==FAILURE) {
continue;
while (queue) {
if (zend_hash_index_find(&PCNTL_G(php_signal_table), queue->signo, (void **) &handle)==SUCCESS) {
ZVAL_LONG(param, queue->signo);
/* Call php signal handler - Note that we do not report errors, and we ignore the return value */
/* FIXME: this is probably broken when multiple signals are handled in this while loop (retval) */
call_user_function(EG(function_table), NULL, *handle, retval, 1, &param TSRMLS_CC);
}
ZVAL_LONG(param, *signal_num);
/* Call php signal handler - Note that we do not report errors, and we ignore the eturn value */
call_user_function(EG(function_table), NULL, *handle, retval, 1, &param TSRMLS_CC);
next = queue->next;
queue->next = PCNTL_G(spares);
PCNTL_G(spares) = queue;
queue = next;
}
/* Clear */
zend_llist_clean(&PCNTL_G(php_signal_queue));
/* Re-enable queue */
PCNTL_G(processing_signal_queue) = 0;
+7 -2
View File
@@ -51,12 +51,17 @@ PHP_FUNCTION(pcntl_wstopsig);
PHP_FUNCTION(pcntl_signal);
PHP_FUNCTION(pcntl_exec);
struct php_pcntl_pending_signal {
struct php_pcntl_pending_signal *next;
long signo;
};
ZEND_BEGIN_MODULE_GLOBALS(pcntl)
HashTable php_signal_table;
zend_llist php_signal_queue;
int signal_queue_ready;
int processing_signal_queue;
struct php_pcntl_pending_signal *head, *tail, *spares;
ZEND_END_MODULE_GLOBALS(pcntl)
#ifdef ZTS
#define PCNTL_G(v) TSRMG(pcntl_globals_id, zend_pcntl_globals *, v)
#else
+4 -3
View File
@@ -4,11 +4,11 @@
declare(ticks=1);
function alarm_handle($signal){
if ($signal==SIGALRM) print "Caught SIGALRM!!!\n";
if ($signal==SIGALRM) print "Child: Caught SIGALRM!!!\n";
}
function usr1_handle($signal){
if ($signal==SIGUSR1) print "Caught SIGUSR1!!!\n";
if ($signal==SIGUSR1) print "Child: Caught SIGUSR1!!!\n";
}
print "This test will demonstrate a fork followed by ipc via signals.\n";
@@ -23,6 +23,7 @@ if ($pid==0) {
sleep(100);
print "Child: Resetting Alarm handler to Ignore....\n";
pcntl_signal(SIGALRM, SIG_IGN);
print "Child: sleeping for 10 seconds....\n";
sleep(10);
print "Done\n";
} else {
@@ -33,7 +34,7 @@ if ($pid==0) {
sleep(1);
print "Parent: Senging SIGUSR1 to Child\n";
posix_kill($pid,SIGUSR1);
sleep(1);
sleep(2);
print "Parent: Sending SIGALRM to Child\n";
pcntl_waitpid($pid, &$status, $options);
}
+2 -2
View File
@@ -13,7 +13,7 @@ PHP_ARG_WITH(pcre-regex,for PCRE support,
if test "$PHP_PCRE_REGEX" != "no"; then
if test "$PHP_PCRE_REGEX" = "yes"; then
PHP_NEW_EXTENSION(pcre, pcrelib/maketables.c pcrelib/get.c pcrelib/study.c pcrelib/pcre.c php_pcre.c, $ext_shared,,-DSUPPORT_UTF8 -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -I@ext_srcdir@/pcrelib)
PHP_NEW_EXTENSION(pcre, pcrelib/maketables.c pcrelib/get.c pcrelib/study.c pcrelib/pcre.c php_pcre.c, $ext_shared,,-DSUPPORT_UTF8 -DSUPPORT_UCP -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -DMATCH_LIMIT=10000000 -I@ext_srcdir@/pcrelib)
PHP_ADD_BUILD_DIR($ext_builddir/pcrelib)
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
else
@@ -50,7 +50,7 @@ if test "$PHP_PCRE_REGEX" != "no"; then
AC_DEFINE(HAVE_PCRE, 1, [ ])
PHP_ADD_INCLUDE($PCRE_INCDIR)
PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared,,-DSUPPORT_UTF8 -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10)
PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared,,-DSUPPORT_UTF8 -DSUPPORT_UCP -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -DMATCH_LIMIT=10000000)
fi
PHP_SUBST(PCRE_SHARED_LIBADD)
fi
+1 -1
View File
@@ -3,4 +3,4 @@ Written by: Philip Hazel <ph10@cam.ac.uk>
University of Cambridge Computing Service,
Cambridge, England. Phone: +44 1223 334714.
Copyright (c) 1997-2003 University of Cambridge
Copyright (c) 1997-2004 University of Cambridge
+27 -36
View File
@@ -4,51 +4,42 @@ PCRE LICENCE
PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Release 5 of PCRE is distributed under the terms of the "BSD" licence, as
specified below. The documentation for PCRE, supplied in the "doc"
directory, is distributed under the same terms as the software itself.
Written by: Philip Hazel <ph10@cam.ac.uk>
University of Cambridge Computing Service,
Cambridge, England. Phone: +44 1223 334714.
Copyright (c) 1997-2003 University of Cambridge
Copyright (c) 1997-2004 University of Cambridge
All rights reserved.
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. In practice, this means that if you use
PCRE in software that you distribute to others, commercially or
otherwise, you must put a sentence like this
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Regular expression support is provided by the PCRE library package,
which is open source software, written by Philip Hazel, and copyright
by the University of Cambridge, England.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
somewhere reasonably visible in your documentation and in any relevant
files or online help data or similar. A reference to the ftp site for
the source, that is, to
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
should also be given in the documentation. However, this condition is not
intended to apply to whole chains of software. If package A includes PCRE,
it must acknowledge it, but if package B is software that includes package
A, the condition is not imposed on package B (unless it uses PCRE
independently).
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), or Lesser General Purpose Licence (LGPL),
then the terms of that licence shall supersede any condition above with
which it is incompatible.
The documentation for PCRE, supplied in the "doc" directory, is distributed
under the same terms as the software itself.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
End
+136
View File
@@ -1,6 +1,142 @@
ChangeLog for PCRE
------------------
Version 5.0 13-Sep-04
---------------------
1. Internal change: literal characters are no longer packed up into items
containing multiple characters in a single byte-string. Each character
is now matched using a separate opcode. However, there may be more than one
byte in the character in UTF-8 mode.
2. The pcre_callout_block structure has two new fields: pattern_position and
next_item_length. These contain the offset in the pattern to the next match
item, and its length, respectively.
3. The PCRE_AUTO_CALLOUT option for pcre_compile() requests the automatic
insertion of callouts before each pattern item. Added the /C option to
pcretest to make use of this.
4. On the advice of a Windows user, the lines
#if defined(_WIN32) || defined(WIN32)
_setmode( _fileno( stdout ), 0x8000 );
#endif /* defined(_WIN32) || defined(WIN32) */
have been added to the source of pcretest. This apparently does useful
magic in relation to line terminators.
5. Changed "r" and "w" in the calls to fopen() in pcretest to "rb" and "wb"
for the benefit of those environments where the "b" makes a difference.
6. The icc compiler has the same options as gcc, but "configure" doesn't seem
to know about it. I have put a hack into configure.in that adds in code
to set GCC=yes if CC=icc. This seems to end up at a point in the
generated configure script that is early enough to affect the setting of
compiler options, which is what is needed, but I have no means of testing
whether it really works. (The user who reported this had patched the
generated configure script, which of course I cannot do.)
LATER: After change 22 below (new libtool files), the configure script
seems to know about icc (and also ecc). Therefore, I have commented out
this hack in configure.in.
7. Added support for pkg-config (2 patches were sent in).
8. Negated POSIX character classes that used a combination of internal tables
were completely broken. These were [[:^alpha:]], [[:^alnum:]], and
[[:^ascii]]. Typically, they would match almost any characters. The other
POSIX classes were not broken in this way.
9. Matching the pattern "\b.*?" against "ab cd", starting at offset 1, failed
to find the match, as PCRE was deluded into thinking that the match had to
start at the start point or following a newline. The same bug applied to
patterns with negative forward assertions or any backward assertions
preceding ".*" at the start, unless the pattern required a fixed first
character. This was a failing pattern: "(?!.bcd).*". The bug is now fixed.
10. In UTF-8 mode, when moving forwards in the subject after a failed match
starting at the last subject character, bytes beyond the end of the subject
string were read.
11. Renamed the variable "class" as "classbits" to make life easier for C++
users. (Previously there was a macro definition, but it apparently wasn't
enough.)
12. Added the new field "tables" to the extra data so that tables can be passed
in at exec time, or the internal tables can be re-selected. This allows
a compiled regex to be saved and re-used at a later time by a different
program that might have everything at different addresses.
13. Modified the pcre-config script so that, when run on Solaris, it shows a
-R library as well as a -L library.
14. The debugging options of pcretest (-d on the command line or D on a
pattern) showed incorrect output for anything following an extended class
that contained multibyte characters and which was followed by a quantifier.
15. Added optional support for general category Unicode character properties
via the \p, \P, and \X escapes. Unicode property support implies UTF-8
support. It adds about 90K to the size of the library. The meanings of the
inbuilt class escapes such as \d and \s have NOT been changed.
16. Updated pcredemo.c to include calls to free() to release the memory for the
compiled pattern.
17. The generated file chartables.c was being created in the source directory
instead of in the building directory. This caused the build to fail if the
source directory was different from the building directory, and was
read-only.
18. Added some sample Win commands from Mark Tetrode into the NON-UNIX-USE
file. No doubt somebody will tell me if they don't make sense... Also added
Dan Mooney's comments about building on OpenVMS.
19. Added support for partial matching via the PCRE_PARTIAL option for
pcre_exec() and the \P data escape in pcretest.
20. Extended pcretest with 3 new pattern features:
(i) A pattern option of the form ">rest-of-line" causes pcretest to
write the compiled pattern to the file whose name is "rest-of-line".
This is a straight binary dump of the data, with the saved pointer to
the character tables forced to be NULL. The study data, if any, is
written too. After writing, pcretest reads a new pattern.
(ii) If, instead of a pattern, "<rest-of-line" is given, pcretest reads a
compiled pattern from the given file. There must not be any
occurrences of "<" in the file name (pretty unlikely); if there are,
pcretest will instead treat the initial "<" as a pattern delimiter.
After reading in the pattern, pcretest goes on to read data lines as
usual.
(iii) The F pattern option causes pcretest to flip the bytes in the 32-bit
and 16-bit fields in a compiled pattern, to simulate a pattern that
was compiled on a host of opposite endianness.
21. The pcre-exec() function can now cope with patterns that were compiled on
hosts of opposite endianness, with this restriction:
As for any compiled expression that is saved and used later, the tables
pointer field cannot be preserved; the extra_data field in the arguments
to pcre_exec() should be used to pass in a tables address if a value
other than the default internal tables were used at compile time.
22. Calling pcre_exec() with a negative value of the "ovecsize" parameter is
now diagnosed as an error. Previously, most of the time, a negative number
would have been treated as zero, but if in addition "ovector" was passed as
NULL, a crash could occur.
23. Updated the files ltmain.sh, config.sub, config.guess, and aclocal.m4 with
new versions from the libtool 1.5 distribution (the last one is a copy of
a file called libtool.m4). This seems to have fixed the need to patch
"configure" to support Darwin 1.3 (which I used to do). However, I still
had to patch ltmain.sh to ensure that ${SED} is set (it isn't on my
workstation).
24. Changed the PCRE licence to be the more standard "BSD" licence.
Version 4.5 01-Dec-03
---------------------
+27 -36
View File
@@ -4,51 +4,42 @@ PCRE LICENCE
PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Release 5 of PCRE is distributed under the terms of the "BSD" licence, as
specified below. The documentation for PCRE, supplied in the "doc"
directory, is distributed under the same terms as the software itself.
Written by: Philip Hazel <ph10@cam.ac.uk>
University of Cambridge Computing Service,
Cambridge, England. Phone: +44 1223 334714.
Copyright (c) 1997-2003 University of Cambridge
Copyright (c) 1997-2004 University of Cambridge
All rights reserved.
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. In practice, this means that if you use
PCRE in software that you distribute to others, commercially or
otherwise, you must put a sentence like this
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Regular expression support is provided by the PCRE library package,
which is open source software, written by Philip Hazel, and copyright
by the University of Cambridge, England.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
somewhere reasonably visible in your documentation and in any relevant
files or online help data or similar. A reference to the ftp site for
the source, that is, to
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
should also be given in the documentation. However, this condition is not
intended to apply to whole chains of software. If package A includes PCRE,
it must acknowledge it, but if package B is software that includes package
A, the condition is not imposed on package B (unless it uses PCRE
independently).
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), or Lesser General Purpose Licence (LGPL),
then the terms of that licence shall supersede any condition above with
which it is incompatible.
The documentation for PCRE, supplied in the "doc" directory, is distributed
under the same terms as the software itself.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
End
+47
View File
@@ -1,6 +1,53 @@
News about PCRE releases
------------------------
Release 5.0 13-Sep-04
---------------------
The licence under which PCRE is released has been changed to the more
conventional "BSD" licence.
In the code, some bugs have been fixed, and there are also some major changes
in this release (which is why I've increased the number to 5.0). Some changes
are internal rearrangements, and some provide a number of new facilities. The
new features are:
1. There's an "automatic callout" feature that inserts callouts before every
item in the regex, and there's a new callout field that gives the position
in the pattern - useful for debugging and tracing.
2. The extra_data structure can now be used to pass in a set of character
tables at exec time. This is useful if compiled regex are saved and re-used
at a later time when the tables may not be at the same address. If the
default internal tables are used, the pointer saved with the compiled
pattern is now set to NULL, which means that you don't need to do anything
special unless you are using custom tables.
3. It is possible, with some restrictions on the content of the regex, to
request "partial" matching. A special return code is given if all of the
subject string matched part of the regex. This could be useful for testing
an input field as it is being typed.
4. There is now some optional support for Unicode character properties, which
means that the patterns items such as \p{Lu} and \X can now be used. Only
the general category properties are supported. If PCRE is compiled with this
support, an additional 90K data structure is include, which increases the
size of the library dramatically.
5. There is support for saving compiled patterns and re-using them later.
6. There is support for running regular expressions that were compiled on a
different host with the opposite endianness.
7. The pcretest program has been extended to accommodate the new features.
The main internal rearrangement is that sequences of literal characters are no
longer handled as strings. Instead, each character is handled on its own. This
makes some UTF-8 handling easier, and makes the support of partial matching
possible. Compiled patterns containing long literal strings will be larger as a
result of this change; I hope that performance will not be much affected.
Release 4.5 01-Dec-03
---------------------
+132 -10
View File
@@ -1,19 +1,25 @@
Compiling PCRE on non-Unix systems
----------------------------------
See below for comments on Cygwin or MinGW usage. I (Philip Hazel) have no
knowledge of Windows sytems and how their libraries work. The items in the
PCRE Makefile that relate to anything other than Unix-like systems have been
contributed by PCRE users. There are some other comments and files in the
Contrib directory on the ftp site that you may find useful.
See below for comments on Cygwin or MinGW and OpenVMS usage. I (Philip Hazel)
have no knowledge of Windows or VMS sytems and how their libraries work. The
items in the PCRE Makefile that relate to anything other than Unix-like systems
have been contributed by PCRE users. There are some other comments and files in
the Contrib directory on the ftp site that you may find useful. See
The following are generic comments about building PCRE:
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib
If you want to compile PCRE for a non-Unix system (or perhaps, more strictly,
for a system that does not support "configure" and make files), note that PCRE
consists entirely of code written in Standard C, and so should compile
successfully on any machine with a Standard C compiler and library, using
normal compiling commands to do the following:
for a system that does not support "configure" and "make" files), note that
PCRE consists entirely of code written in Standard C, and so should compile
successfully on any system that has a Standard C compiler and library.
GENERIC INSTRUCTIONS
The following are generic comments about building PCRE. The interspersed
indented commands are suggestions from Mark Tetrode as to which commands you
might use on a Windows system to build a static library.
(1) Copy or rename the file config.in as config.h, and change the macros that
define HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0.
@@ -23,32 +29,85 @@ particular, if you want to force a specific value for newline, you can define
the NEWLINE macro. The default is to use '\n', thereby using whatever value
your compiler gives to '\n'.
rem Mark Tetrode's commands
copy config.in config.h
rem Use write, because notepad cannot handle UNIX files. Change values.
write config.h
(2) Copy or rename the file pcre.in as pcre.h, and change the macro definitions
for PCRE_MAJOR, PCRE_MINOR, and PCRE_DATE near its start to the values set in
configure.in.
rem Mark Tetrode's commands
copy pcre.in pcre.h
rem Read values from configure.in
write configure.in
rem Change values
write pcre.h
(3) Compile dftables.c as a stand-alone program, and then run it with
the single argument "chartables.c". This generates a set of standard
character tables and writes them to that file.
rem Mark Tetrode's commands
rem Compile & run
cl -DSUPPORT_UTF8 dftables.c
dftables.exe > chartables.c
(4) Compile maketables.c, get.c, study.c and pcre.c and link them all
together into an object library in whichever form your system keeps such
libraries. This is the pcre library (chartables.c is included by means of an
#include directive). If your system has static and shared libraries, you may
have to do this once for each type.
rem Mark Tetrode's commands, for a static library
rem Compile & lib
cl -DSUPPORT_UTF8 -DPOSIX_MALLOC_THRESHOLD=10 /c maketables.c get.c study.c pcre.c
lib /OUT:pcre.lib maketables.obj get.obj study.obj pcre.obj
(5) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix
library.
rem Mark Tetrode's commands, for a static library
rem Compile & lib
cl -DSUPPORT_UTF8 -DPOSIX_MALLOC_THRESHOLD=10 /c pcreposix.c
lib /OUT:pcreposix.lib pcreposix.obj
(6) Compile the test program pcretest.c. This needs the functions in the
pcre and pcreposix libraries when linking.
rem Mark Tetrode's commands
rem compile & link
cl pcretest.c pcre.lib pcreposix.lib
(7) Run pcretest on the testinput files in the testdata directory, and check
that the output matches the corresponding testoutput files. You must use the
-i option when checking testinput2. Note that the supplied files are in Unix
format, with just LF characters as line terminators. You may need to edit them
to change this if your system uses a different convention.
rem Mark Tetrode's commands
rem Make a change, i.e. space, backspace, and save again - do this for all
rem to change UNIX to Win, \n to \n\r
write testoutput1
write testoutput2
write testoutput3
write testoutput4
write testoutput5
pcretest testdata\testinput1 testdata\myoutput1
windiff testdata\testoutput1 testdata\myoutput1
pcretest -i testdata\testinput2 testdata\myoutput2
windiff testdata\testoutput2 testdata\myoutput2
pcretest testdata\testinput3 testdata\myoutput3
windiff testdata\testoutput3 testdata\myoutput3
pcretest testdata\testinput4 testdata\myoutput4
windiff testdata\testoutput4 testdata\myoutput4
pcretest testdata\testinput5 testdata\myoutput5
windiff testdata\testoutput5 testdata\myoutput5
FURTHER REMARKS
If you have a system without "configure" but where you can use a Makefile, edit
Makefile.in to create Makefile, substituting suitable values for the variables
at the head of the file.
@@ -119,4 +178,67 @@ void (*pcre_free)(void *) = free;
#endif
=========================
BUILDING PCRE ON OPENVMS
Dan Mooney sent the following comments about building PCRE on OpenVMS:
"It was quite easy to compile and link the library. I don't have a formal
make file but the attached file [reproduced below] contains the OpenVMS DCL
commands I used to build the library. I had to add #define
POSIX_MALLOC_THRESHOLD 10 to pcre.h since it was not defined anywhere.
The library was built on:
O/S: HP OpenVMS v7.3-1
Compiler: Compaq C v6.5-001-48BCD
Linker: vA13-01
The test results did not match 100% due to the issues you mention in your
documentation regarding isprint(), iscntrl(), isgraph() and ispunct(). I
modified some of the character tables temporarily and was able to get the
results to match. Tests using the fr locale did not match since I don't have
that locale loaded. The study size was always reported to be 3 less than the
value in the standard test output files."
=========================
$! This DCL procedure builds PCRE on OpenVMS
$!
$! I followed the instructions in the non-unix-use file in the distribution.
$!
$ COMPILE == "CC/LIST/NOMEMBER_ALIGNMENT/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES
$ COMPILE DFTABLES.C
$ LINK/EXE=DFTABLES.EXE DFTABLES.OBJ
$ RUN DFTABLES.EXE/OUTPUT=CHARTABLES.C
$ COMPILE MAKETABLES.C
$ COMPILE GET.C
$ COMPILE STUDY.C
$! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
$! did not seem to be defined anywhere.
$! I edited pcre.h and added #DEFINE SUPPORT_UTF8 to enable UTF8 support.
$ COMPILE PCRE.C
$ LIB/CREATE PCRE MAKETABLES.OBJ, GET.OBJ, STUDY.OBJ, PCRE.OBJ
$! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
$! did not seem to be defined anywhere.
$ COMPILE PCREPOSIX.C
$ LIB/CREATE PCREPOSIX PCREPOSIX.OBJ
$ COMPILE PCRETEST.C
$ LINK/EXE=PCRETEST.EXE PCRETEST.OBJ, PCRE/LIB, PCREPOSIX/LIB
$! C programs that want access to command line arguments must be
$! defined as a symbol
$ PCRETEST :== "$ SYS$ROADSUSERS:[DMOONEY.REGEXP]PCRETEST.EXE"
$! Arguments must be enclosed in quotes.
$ PCRETEST "-C"
$! Test results:
$!
$! The test results did not match 100%. The functions isprint(), iscntrl(),
$! isgraph() and ispunct() on OpenVMS must not produce the same results
$! as the system that built the test output files provided with the
$! distribution.
$!
$! The study size did not match and was always 3 less on OpenVMS.
$!
$! Locale could not be set to fr
$!
=========================
****
+82 -20
View File
@@ -22,6 +22,28 @@ ensure that they link with PCRE's libpcreposix library. Otherwise they may pick
up the "real" POSIX functions of the same name.
Documentation for PCRE
----------------------
If you install PCRE in the normal way, you will end up with an installed set of
man pages whose names all start with "pcre". The one that is called "pcre"
lists all the others. In addition to these man pages, the PCRE documentation is
supplied in two other forms; however, as there is no standard place to install
them, they are left in the doc directory of the unpacked source distribution.
These forms are:
1. Files called doc/pcre.txt, doc/pcregrep.txt, and doc/pcretest.txt. The
first of these is a concatenation of the text forms of all the section 3
man pages except those that summarize individual functions. The other two
are the text forms of the section 1 man pages for the pcregrep and
pcretest commands. Text forms are provided for ease of scanning with text
editors or similar tools.
2. A subdirectory called doc/html contains all the documentation in HTML
form, hyperlinked in various ways, and rooted in a file called
doc/index.html.
Contributions by users of PCRE
------------------------------
@@ -46,7 +68,7 @@ INSTALL.
Most commonly, people build PCRE within its own distribution directory, and in
this case, on many systems, just running "./configure" is sufficient, but the
usual methods of changing standard defaults are available. For example,
usual methods of changing standard defaults are available. For example:
CFLAGS='-O2 -Wall' ./configure --prefix=/opt/local
@@ -69,6 +91,13 @@ library. You can read more about them in the pcrebuild man page.
for handling UTF-8 is not included in the library. (Even when included, it
still has to be enabled by an option at run time.)
. If, in addition to support for UTF-8 character strings, you want to include
support for the \P, \p, and \X sequences that recognize Unicode character
properties, you must add --enable-unicode-properties to the "configure"
command. This adds about 90K to the size of the library (in the form of a
property table); only the basic two-letter properties such as Lu are
supported.
. You can build PCRE to recognized CR or NL as the newline character, instead
of whatever your compiler uses for "\n", by adding --newline-is-cr or
--newline-is-nl to the "configure" command, respectively. Only do this if you
@@ -111,12 +140,14 @@ library. You can read more about them in the pcrebuild man page.
on the "configure" command. PCRE runs more slowly in this mode, but it may be
necessary in environments with limited stack sizes.
The "configure" script builds five files:
The "configure" script builds seven files:
. libtool is a script that builds shared and/or static libraries
. pcre.h is build by copying pcre.in and making substitutions
. Makefile is built by copying Makefile.in and making substitutions.
. config.h is built by copying config.in and making substitutions.
. pcre-config is built by copying pcre-config.in and making substitutions.
. libpcre.pc is data for the pkg-config command, built from libpcre.pc.in
. libtool is a script that builds shared and/or static libraries
. RunTest is a script for running tests
Once "configure" has run, you can run "make". It builds two libraries called
@@ -125,20 +156,33 @@ command. You can use "make install" to copy these, the public header files
pcre.h and pcreposix.h, and the man pages to appropriate live directories on
your system, in the normal way.
Retrieving configuration information on Unix-like systems
---------------------------------------------------------
Running "make install" also installs the command pcre-config, which can be used
to recall information about the PCRE configuration and installation. For
example,
example:
pcre-config --version
prints the version number, and
pcre-config --libs
pcre-config --libs
outputs information about where the library is installed. This command can be
included in makefiles for programs that use PCRE, saving the programmer from
having to remember too many details.
The pkg-config command is another system for saving and retrieving information
about installed libraries. Instead of separate commands for each library, a
single command is used. For example:
pkg-config --cflags pcre
The data is held in *.pc files that are installed in a directory called
pkgconfig.
Shared libraries on Unix-like systems
-------------------------------------
@@ -158,7 +202,7 @@ installed themselves. However, the versions left in the source directory still
use the uninstalled libraries.
To build PCRE using static libraries only you must use --disable-shared when
configuring it. For example
configuring it. For example:
./configure --prefix=/usr/gnu --disable-shared
@@ -202,9 +246,9 @@ configuring process. (This can also be run by "make runtest", "make check", or
The script runs the pcretest test program (which is documented in its own man
page) on each of the testinput files (in the testdata directory) in turn,
and compares the output with the contents of the corresponding testoutput file.
A file called testtry is used to hold the output from pcretest. To run pcretest
on just one of the test files, give its number as an argument to RunTest, for
example:
A file called testtry is used to hold the main output from pcretest
(testsavedregex is also used as a working file). To run pcretest on just one of
the test files, give its number as an argument to RunTest, for example:
RunTest 2
@@ -247,19 +291,23 @@ running "configure". This file can be also fed directly to the perltest script,
provided you are running Perl 5.8 or higher. (For Perl 5.6, a small patch,
commented in the script, can be be used.)
The fifth and final file tests error handling with UTF-8 encoding, and internal
UTF-8 features of PCRE that are not relevant to Perl.
The fifth test checks error handling with UTF-8 encoding, and internal UTF-8
features of PCRE that are not relevant to Perl.
The sixth and final test checks the support for Unicode character properties.
It it not run automatically unless PCRE is built with Unicode property support.
To to this you must set --enable-unicode-properties when running "configure".
Character tables
----------------
PCRE uses four tables for manipulating and identifying characters. The final
argument of the pcre_compile() function is a pointer to a block of memory
containing the concatenated tables. A call to pcre_maketables() can be used to
generate a set of tables in the current locale. If the final argument for
pcre_compile() is passed as NULL, a set of default tables that is built into
the binary is used.
PCRE uses four tables for manipulating and identifying characters whose values
are less than 256. The final argument of the pcre_compile() function is a
pointer to a block of memory containing the concatenated tables. A call to
pcre_maketables() can be used to generate a set of tables in the current
locale. If the final argument for pcre_compile() is passed as NULL, a set of
default tables that is built into the binary is used.
The source file called chartables.c contains the default set of tables. This is
not supplied in the distribution, but is built by the program dftables
@@ -299,12 +347,20 @@ The distribution should contain the following files:
headers:
dftables.c auxiliary program for building chartables.c
get.c )
maketables.c )
study.c ) source of
pcre.c ) the functions
study.c ) source of the functions
pcre.c ) in the library
pcreposix.c )
printint.c )
ucp.c )
ucp.h ) source for the code that is used for
ucpinternal.h ) Unicode property handling
ucptable.c )
ucptypetable.c )
pcre.in "source" for the header for the external API; pcre.h
is built from this by "configure"
pcreposix.h header for the external POSIX wrapper API
@@ -335,7 +391,9 @@ The distribution should contain the following files:
doc/pcretest.txt plain text documentation of test program
doc/perltest.txt plain text documentation of Perl test program
install-sh a shell script for installing files
libpcre.pc.in "source" for libpcre.pc for pkg-config
ltmain.sh file used to build a libtool script
mkinstalldirs script for making install directories
pcretest.c comprehensive test program
pcredemo.c simple demonstration of coding calls to PCRE
perltest Perl test program
@@ -346,15 +404,19 @@ The distribution should contain the following files:
testdata/testinput3 test data for locale-specific tests
testdata/testinput4 test data for UTF-8 tests compatible with Perl
testdata/testinput5 test data for other UTF-8 tests
testdata/testinput6 test data for Unicode property support tests
testdata/testoutput1 test results corresponding to testinput1
testdata/testoutput2 test results corresponding to testinput2
testdata/testoutput3 test results corresponding to testinput3
testdata/testoutput4 test results corresponding to testinput4
testdata/testoutput5 test results corresponding to testinput5
testdata/testoutput6 test results corresponding to testinput6
(C) Auxiliary files for Win32 DLL
dll.mk
libpcre.def
libpcreposix.def
pcre.def
(D) Auxiliary file for VPASCAL
@@ -362,4 +424,4 @@ The distribution should contain the following files:
makevp.bat
Philip Hazel <ph10@cam.ac.uk>
December 2003
September 2004
+21 -15
View File
@@ -11,26 +11,32 @@ Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), then the terms of that licence shall
supersede any condition above with which it is incompatible.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
See the file Tech.Notes for some information on the internals.
*/
+67 -33
View File
@@ -1,6 +1,9 @@
Technical Notes about PCRE
--------------------------
Historical note 1
-----------------
Many years ago I implemented some regular expression functions to an algorithm
suggested by Martin Richards. These were not Unix-like in form, and were quite
restricted in what they could do by comparison with Perl. The interesting part
@@ -9,12 +12,15 @@ form of an expression was known in advance. The code to apply an expression did
not operate by backtracking, as the original Henry Spencer code and current
Perl code does, but instead checked all possibilities simultaneously by keeping
a list of current states and checking all of them as it advanced through the
subject string. (In the terminology of Jeffrey Friedl's book, it was a "DFA
algorithm".) When the pattern was all used up, all remaining states were
subject string. In the terminology of Jeffrey Friedl's book, it was a "DFA
algorithm". When the pattern was all used up, all remaining states were
possible matches, and the one matching the longest subset of the subject string
was chosen. This did not necessarily maximize the individual wild portions of
the pattern, as is expected in Unix and Perl-style regular expressions.
Historical note 2
-----------------
By contrast, the code originally written by Henry Spencer and subsequently
heavily modified for Perl actually compiles the expression twice: once in a
dummy mode in order to find out how much store will be needed, and then for
@@ -23,6 +29,9 @@ optionally, minimizing in Perl) the amount of the subject that matches
individual wild portions of the pattern. This is an "NFA algorithm" in Friedl's
terminology.
OK, here's the real stuff
-------------------------
For the set of functions that forms PCRE (which are unrelated to those
mentioned above), I tried at first to invent an algorithm that used an amount
of store bounded by a multiple of the number of characters in the pattern, to
@@ -38,8 +47,16 @@ got quite big anyway to handle all the Perl stuff.
The compiled form of a pattern is a vector of bytes, containing items of
variable length. The first byte in an item is an opcode, and the length of the
item is either implicit in the opcode or contained in the data bytes which
follow it. A list of all the opcodes follows:
item is either implicit in the opcode or contained in the data bytes that
follow it.
In many cases below "two-byte" data values are specified. This is in fact just
a default. PCRE can be compiled to use 3-byte or 4-byte values (impairing the
performance). This is necessary only when patterns whose compiled length is
greater than 64K are going to be processed. In this description, we assume the
"normal" compilation options.
A list of all the opcodes follows:
Opcodes with no following data
------------------------------
@@ -48,7 +65,7 @@ These items are all just one byte long
OP_END end of pattern
OP_ANY match any character
OP_ANYBYTE match any single byte, even in UTF-8 mode
OP_ANYBYTE match any single byte, even in UTF-8 mode
OP_SOD match start of data: \A
OP_SOM, start of match (subject + offset): \G
OP_CIRC ^ (start of data, or after \n in multiline)
@@ -63,13 +80,14 @@ These items are all just one byte long
OP_EODN match end of data or \n at end: \Z
OP_EOD match end of data: \z
OP_DOLL $ (end of data, or before \n in multiline)
OP_EXTUNI match an extended Unicode character
Repeating single characters
---------------------------
The common repeats (*, +, ?) when applied to a single character appear as
two-byte items using the following opcodes:
The common repeats (*, +, ?) when applied to a single character use the
following opcodes:
OP_STAR
OP_MINSTAR
@@ -78,6 +96,7 @@ two-byte items using the following opcodes:
OP_QUERY
OP_MINQUERY
In ASCII mode, these are two-byte items; in UTF-8 mode, the length is variable.
Those with "MIN" in their name are the minimizing versions. Each is followed by
the character that is to be repeated. Other repeats make use of
@@ -109,39 +128,52 @@ byte. The opcodes are:
OP_TYPEEXACT
Matching a character string
Match by Unicode property
-------------------------
OP_PROP and OP_NOTPROP are used for positive and negative matches of a
character by testing its Unicode property (the \p and \P escape sequences).
Each is followed by a single byte that encodes the desired property value.
Repeats of these items use the OP_TYPESTAR etc. set of opcodes, followed by two
bytes: OP_PROP or OP_NOTPROP and then the desired property value.
Matching literal characters
---------------------------
The OP_CHARS opcode is followed by a one-byte count and then that number of
characters. If there are more than 255 characters in sequence, successive
instances of OP_CHARS are used.
The OP_CHAR opcode is followed by a single character that is to be matched
casefully. For caseless matching, OP_CHARNC is used. In UTF-8 mode, the
character may be more than one byte long. (Earlier versions of PCRE used
multi-character strings, but this was changed to allow some new features to be
added.)
Character classes
-----------------
If there is only one character, OP_CHARS is used for a positive class,
and OP_NOT for a negative one (that is, for something like [^a]). However, in
UTF-8 mode, this applies only to characters with values < 128, because OP_NOT
is confined to single bytes.
If there is only one character, OP_CHAR or OP_CHARNC is used for a positive
class, and OP_NOT for a negative one (that is, for something like [^a]).
However, in UTF-8 mode, the use of OP_NOT applies only to characters with
values < 128, because OP_NOT is confined to single bytes.
Another set of repeating opcodes (OP_NOTSTAR etc.) are used for a repeated,
negated, single-character class. The normal ones (OP_STAR etc.) are used for a
repeated positive single-character class.
When there's more than one character in a class and all the characters are less
than 256, OP_CLASS is used for a positive class, and OP_NCLASS for a negative
than 256, OP_CLASS is used for a positive class, and OP_NCLASS for a negative
one. In either case, the opcode is followed by a 32-byte bit map containing a 1
bit for every character that is acceptable. The bits are counted from the least
significant end of each byte.
The reason for having both OP_CLASS and OP_NCLASS is so that, in UTF-8 mode,
subject characters with values greater than 256 can be handled correctly. For
The reason for having both OP_CLASS and OP_NCLASS is so that, in UTF-8 mode,
subject characters with values greater than 256 can be handled correctly. For
OP_CLASS they don't match, whereas for OP_NCLASS they do.
For classes containing characters with values > 255, OP_XCLASS is used. It
optionally uses a bit map (if any characters lie within it), followed by a list
of pairs and single characters. There is a flag character than indicates
of pairs and single characters. There is a flag character than indicates
whether it's a positive or a negative class.
@@ -192,14 +224,14 @@ the bracket itself. (They could have all been done like this, but I was making
minimal changes.)
A bracket opcode is followed by two bytes which give the offset to the next
alternative OP_ALT or, if there aren't any branches, to the matching KET
alternative OP_ALT or, if there aren't any branches, to the matching OP_KET
opcode. Each OP_ALT is followed by two bytes giving the offset to the next one,
or to the KET opcode.
or to the OP_KET opcode.
OP_KET is used for subpatterns that do not repeat indefinitely, while
OP_KETRMIN and OP_KETRMAX are used for indefinite repetitions, minimally or
maximally respectively. All three are followed by two bytes giving (as a
positive number) the offset back to the matching BRA opcode.
positive number) the offset back to the matching OP_BRA opcode.
If a subpattern is quantified such that it is permitted to match zero times, it
is preceded by one of OP_BRAZERO or OP_BRAMINZERO. These are single-byte
@@ -207,15 +239,14 @@ opcodes which tell the matcher that skipping this subpattern entirely is a
valid branch.
A subpattern with an indefinite maximum repetition is replicated in the
compiled data its minimum number of times (or once with a BRAZERO if the
minimum is zero), with the final copy terminating with a KETRMIN or KETRMAX as
appropriate.
compiled data its minimum number of times (or once with OP_BRAZERO if the
minimum is zero), with the final copy terminating with OP_KETRMIN or OP_KETRMAX
as appropriate.
A subpattern with a bounded maximum repetition is replicated in a nested
fashion up to the maximum number of times, with BRAZERO or BRAMINZERO before
each replication after the minimum, so that, for example, (abc){2,5} is
compiled as (abc)(abc)((abc)((abc)(abc)?)?)?. The 99 and 200 bracket limits do
not apply to these internally generated brackets.
fashion up to the maximum number of times, with OP_BRAZERO or OP_BRAMINZERO
before each replication after the minimum, so that, for example, (abc){2,5} is
compiled as (abc)(abc)((abc)((abc)(abc)?)?)?.
Assertions
@@ -260,8 +291,11 @@ from the start of the whole pattern.
Callout
-------
OP_CALLOUT is followed by one byte of data that holds a callout number in the
range 0 to 255.
OP_CALLOUT is followed by one byte of data that holds a callout number in the
range 0 to 254 for manual callouts, or 255 for an automatic callout. In both
cases there follows a two-byte value giving the offset in the pattern to the
start of the following item, and another two-byte item giving the length of the
next item.
Changing options
@@ -278,4 +312,4 @@ at compile time, and so does not cause anything to be put into the compiled
data.
Philip Hazel
August 2003
September 2004
File diff suppressed because it is too large. Load diff
+22 -14
View File
@@ -12,29 +12,37 @@ Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), then the terms of that licence shall
supersede any condition above with which it is incompatible.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains some convenience functions for extracting substrings
from the subject string after a regex match has succeeded. The original idea
for these functions came from Scott Wimer <scottw@cgibuilder.com>. */
for these functions came from Scott Wimer. */
/* Include the internals header, which itself includes Standard C headers plus
+221 -158
View File
@@ -5,30 +5,38 @@
/* This is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language. See
the file Tech.Notes for some information on the internals.
the file doc/Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2003 University of Cambridge
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), then the terms of that licence shall
supersede any condition above with which it is incompatible.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
@@ -45,6 +53,18 @@ modules, but which are not relevant to the outside. */
# include <php_config.h>
#endif
/* Standard C headers plus the external interface definition. The only time
setjmp and stdarg are used is when NO_RECURSE is set. */
#include <ctype.h>
#include <limits.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef PCRE_SPY
#define PCRE_DEFINITION /* Win32 __declspec(export) trigger for .dll */
#endif
@@ -57,24 +77,45 @@ On Unix systems, "configure" can be used to override this default. */
#define NEWLINE '\n'
#endif
/* The value of MATCH_LIMIT determines the default number of times the match()
function can be called during a single execution of pcre_exec(). (There is a
runtime method of setting a different limit.) The limit exists in order to
catch runaway regular expressions that take for ever to determine that they do
not match. The default is set very large so that it does not accidentally catch
legitimate cases. On Unix systems, "configure" can be used to override this
default default. */
#ifndef MATCH_LIMIT
#define MATCH_LIMIT 10000000
#endif
/* If you are compiling for a system that needs some magic to be inserted
* before the definition of an exported function, define this macro to contain
* the relevant magic. It apears at the start of every exported function. */
#define EXPORT
/* We need to have types that specify unsigned 16-bit and 32-bit integers. We
cannot determine these outside the compilation (e.g. by running a program as
part of "configure") because PCRE is often cross-compiled for use on other
systems. Instead we make use of the maximum sizes that are available at
preprocessor time in standard C environments. */
#if USHRT_MAX == 65535
typedef unsigned short pcre_uint16;
#elif UINT_MAX == 65535
typedef unsigned int pcre_uint16;
#else
#error Cannot determine a type for 16-bit unsigned integers
#endif
#if UINT_MAX == 4294967295
typedef unsigned int pcre_uint32;
#elif ULONG_MAX == 4294967295
typedef unsigned long int pcre_uint32;
#else
#error Cannot determine a type for 32-bit unsigned integers
#endif
/* All character handling must be done as unsigned characters. Otherwise there
are problems with top-bit-set characters and functions such as isspace().
However, we leave the interface to the outside world as char *, because that
should make things easier for callers. We define a short type for unsigned char
to save lots of typing. I tried "uchar", but it causes problems on Digital
Unix, where it is defined in sys/types, so use "uschar" instead. */
typedef unsigned char uschar;
/* Include the public PCRE header */
#include "pcre.h"
/* When compiling for use with the Virtual Pascal compiler, these functions
@@ -95,18 +136,6 @@ neither (there some non-Unix environments where this is the case). This assumes
that all calls to memmove are moving strings upwards in store, which is the
case in PCRE. */
/* Standard C headers plus the external interface definition. The only time
setjmp and stdarg are used is when NO_RECURSE is set. */
#include <ctype.h>
#include <limits.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if ! HAVE_MEMMOVE
#undef memmove /* some systems may have a macro */
#if HAVE_BCOPY
@@ -126,13 +155,14 @@ for (i = 0; i < n; ++i) *(--dest) = *(--src);
#endif /* not VPCOMPAT */
/* PCRE keeps offsets in its compiled code as 2-byte quantities by default.
These are used, for example, to link from the start of a subpattern to its
alternatives and its end. The use of 2 bytes per offset limits the size of the
compiled regex to around 64K, which is big enough for almost everybody.
However, I received a request for an even bigger limit. For this reason, and
also to make the code easier to maintain, the storing and loading of offsets
from the byte string is now handled by the macros that are defined here.
/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored
in big-endian order) by default. These are used, for example, to link from the
start of a subpattern to its alternatives and its end. The use of 2 bytes per
offset limits the size of the compiled regex to around 64K, which is big enough
for almost everybody. However, I received a request for an even bigger limit.
For this reason, and also to make the code easier to maintain, the storing and
loading of offsets from the byte string is now handled by the macros that are
defined here.
The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
the config.h file, but can be overridden by using -D on the command line. This
@@ -208,6 +238,7 @@ Standard C system should have one. */
#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
#endif
/* These are the public options that can change during matching. */
#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
@@ -216,12 +247,13 @@ Standard C system should have one. */
but skip the top bit so we can use ints for convenience without getting tangled
with negative values. The public options defined in pcre.h start at the least
significant end. Make sure they don't overlap, though now that we have expanded
to four bytes there is plenty of space. */
to four bytes, there is plenty of space. */
#define PCRE_FIRSTSET 0x40000000 /* first_byte is set */
#define PCRE_REQCHSET 0x20000000 /* req_byte is set */
#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
#define PCRE_ICHANGED 0x08000000 /* i option changes within regex */
#define PCRE_NOPARTIAL 0x04000000 /* can't use partial with this regex */
/* Options for the "extra" block produced by pcre_study(). */
@@ -233,10 +265,11 @@ time, run time or study time, respectively. */
#define PUBLIC_OPTIONS \
(PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK)
PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT)
#define PUBLIC_EXEC_OPTIONS \
(PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK)
(PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
PCRE_PARTIAL)
#define PUBLIC_STUDY_OPTIONS 0 /* None defined */
@@ -296,12 +329,13 @@ definitions below, up to ESC_z. There's a dummy for OP_ANY because it
corresponds to "." rather than an escape sequence. The final one must be
ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two
tests in the code for an escape greater than ESC_b and less than ESC_Z to
detect the types that may be repeated. These are the types that consume a
character. If any new escapes are put in between that don't consume a
detect the types that may be repeated. These are the types that consume
characters. If any new escapes are put in between that don't consume a
character, that code will have to change. */
enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,
ESC_w, ESC_dum1, ESC_C, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_REF };
ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_X, ESC_Z, ESC_z, ESC_E,
ESC_Q, ESC_REF };
/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
contain UTF-8 characters with values greater than 255. */
@@ -312,6 +346,8 @@ contain UTF-8 characters with values greater than 255. */
#define XCL_END 0 /* Marks end of individual items */
#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
#define XCL_RANGE 2 /* A range (two multibyte chars) follows */
#define XCL_PROP 3 /* Unicode property (one property code) follows */
#define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */
/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
@@ -337,100 +373,112 @@ enum {
OP_WORDCHAR, /* 10 \w */
OP_ANY, /* 11 Match any character */
OP_ANYBYTE, /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */
OP_EODN, /* 13 End of data or \n at end of data: \Z. */
OP_EOD, /* 14 End of data: \z */
OP_NOTPROP, /* 13 \P (not Unicode property) */
OP_PROP, /* 14 \p (Unicode property) */
OP_EXTUNI, /* 15 \X (extended Unicode sequence */
OP_EODN, /* 16 End of data or \n at end of data: \Z. */
OP_EOD, /* 17 End of data: \z */
OP_OPT, /* 15 Set runtime options */
OP_CIRC, /* 16 Start of line - varies with multiline switch */
OP_DOLL, /* 17 End of line - varies with multiline switch */
OP_CHARS, /* 18 Match string of characters */
OP_NOT, /* 19 Match anything but the following char */
OP_OPT, /* 18 Set runtime options */
OP_CIRC, /* 19 Start of line - varies with multiline switch */
OP_DOLL, /* 20 End of line - varies with multiline switch */
OP_CHAR, /* 21 Match one character, casefully */
OP_CHARNC, /* 22 Match one character, caselessly */
OP_NOT, /* 23 Match anything but the following char */
OP_STAR, /* 20 The maximizing and minimizing versions of */
OP_MINSTAR, /* 21 all these opcodes must come in pairs, with */
OP_PLUS, /* 22 the minimizing one second. */
OP_MINPLUS, /* 23 This first set applies to single characters */
OP_QUERY, /* 24 */
OP_MINQUERY, /* 25 */
OP_UPTO, /* 26 From 0 to n matches */
OP_MINUPTO, /* 27 */
OP_EXACT, /* 28 Exactly n matches */
OP_STAR, /* 24 The maximizing and minimizing versions of */
OP_MINSTAR, /* 25 all these opcodes must come in pairs, with */
OP_PLUS, /* 26 the minimizing one second. */
OP_MINPLUS, /* 27 This first set applies to single characters */
OP_QUERY, /* 28 */
OP_MINQUERY, /* 29 */
OP_UPTO, /* 30 From 0 to n matches */
OP_MINUPTO, /* 31 */
OP_EXACT, /* 32 Exactly n matches */
OP_NOTSTAR, /* 29 The maximizing and minimizing versions of */
OP_NOTMINSTAR, /* 30 all these opcodes must come in pairs, with */
OP_NOTPLUS, /* 31 the minimizing one second. */
OP_NOTMINPLUS, /* 32 This set applies to "not" single characters */
OP_NOTQUERY, /* 33 */
OP_NOTMINQUERY, /* 34 */
OP_NOTUPTO, /* 35 From 0 to n matches */
OP_NOTMINUPTO, /* 36 */
OP_NOTEXACT, /* 37 Exactly n matches */
OP_NOTSTAR, /* 33 The maximizing and minimizing versions of */
OP_NOTMINSTAR, /* 34 all these opcodes must come in pairs, with */
OP_NOTPLUS, /* 35 the minimizing one second. */
OP_NOTMINPLUS, /* 36 This set applies to "not" single characters */
OP_NOTQUERY, /* 37 */
OP_NOTMINQUERY, /* 38 */
OP_NOTUPTO, /* 39 From 0 to n matches */
OP_NOTMINUPTO, /* 40 */
OP_NOTEXACT, /* 41 Exactly n matches */
OP_TYPESTAR, /* 38 The maximizing and minimizing versions of */
OP_TYPEMINSTAR, /* 39 all these opcodes must come in pairs, with */
OP_TYPEPLUS, /* 40 the minimizing one second. These codes must */
OP_TYPEMINPLUS, /* 41 be in exactly the same order as those above. */
OP_TYPEQUERY, /* 42 This set applies to character types such as \d */
OP_TYPEMINQUERY, /* 43 */
OP_TYPEUPTO, /* 44 From 0 to n matches */
OP_TYPEMINUPTO, /* 45 */
OP_TYPEEXACT, /* 46 Exactly n matches */
OP_TYPESTAR, /* 42 The maximizing and minimizing versions of */
OP_TYPEMINSTAR, /* 43 all these opcodes must come in pairs, with */
OP_TYPEPLUS, /* 44 the minimizing one second. These codes must */
OP_TYPEMINPLUS, /* 45 be in exactly the same order as those above. */
OP_TYPEQUERY, /* 46 This set applies to character types such as \d */
OP_TYPEMINQUERY, /* 47 */
OP_TYPEUPTO, /* 48 From 0 to n matches */
OP_TYPEMINUPTO, /* 49 */
OP_TYPEEXACT, /* 50 Exactly n matches */
OP_CRSTAR, /* 47 The maximizing and minimizing versions of */
OP_CRMINSTAR, /* 48 all these opcodes must come in pairs, with */
OP_CRPLUS, /* 49 the minimizing one second. These codes must */
OP_CRMINPLUS, /* 50 be in exactly the same order as those above. */
OP_CRQUERY, /* 51 These are for character classes and back refs */
OP_CRMINQUERY, /* 52 */
OP_CRRANGE, /* 53 These are different to the three seta above. */
OP_CRMINRANGE, /* 54 */
OP_CRSTAR, /* 51 The maximizing and minimizing versions of */
OP_CRMINSTAR, /* 52 all these opcodes must come in pairs, with */
OP_CRPLUS, /* 53 the minimizing one second. These codes must */
OP_CRMINPLUS, /* 54 be in exactly the same order as those above. */
OP_CRQUERY, /* 55 These are for character classes and back refs */
OP_CRMINQUERY, /* 56 */
OP_CRRANGE, /* 57 These are different to the three sets above. */
OP_CRMINRANGE, /* 58 */
OP_CLASS, /* 55 Match a character class, chars < 256 only */
OP_NCLASS, /* 56 Same, but the bitmap was created from a negative
OP_CLASS, /* 59 Match a character class, chars < 256 only */
OP_NCLASS, /* 60 Same, but the bitmap was created from a negative
class - the difference is relevant only when a UTF-8
character > 255 is encountered. */
OP_XCLASS, /* 57 Extended class for handling UTF-8 chars within the
OP_XCLASS, /* 61 Extended class for handling UTF-8 chars within the
class. This does both positive and negative. */
OP_REF, /* 58 Match a back reference */
OP_RECURSE, /* 59 Match a numbered subpattern (possibly recursive) */
OP_CALLOUT, /* 60 Call out to external function if provided */
OP_REF, /* 62 Match a back reference */
OP_RECURSE, /* 63 Match a numbered subpattern (possibly recursive) */
OP_CALLOUT, /* 64 Call out to external function if provided */
OP_ALT, /* 61 Start of alternation */
OP_KET, /* 62 End of group that doesn't have an unbounded repeat */
OP_KETRMAX, /* 63 These two must remain together and in this */
OP_KETRMIN, /* 64 order. They are for groups the repeat for ever. */
OP_ALT, /* 65 Start of alternation */
OP_KET, /* 66 End of group that doesn't have an unbounded repeat */
OP_KETRMAX, /* 67 These two must remain together and in this */
OP_KETRMIN, /* 68 order. They are for groups the repeat for ever. */
/* The assertions must come before ONCE and COND */
OP_ASSERT, /* 65 Positive lookahead */
OP_ASSERT_NOT, /* 66 Negative lookahead */
OP_ASSERTBACK, /* 67 Positive lookbehind */
OP_ASSERTBACK_NOT, /* 68 Negative lookbehind */
OP_REVERSE, /* 69 Move pointer back - used in lookbehind assertions */
OP_ASSERT, /* 69 Positive lookahead */
OP_ASSERT_NOT, /* 70 Negative lookahead */
OP_ASSERTBACK, /* 71 Positive lookbehind */
OP_ASSERTBACK_NOT, /* 72 Negative lookbehind */
OP_REVERSE, /* 73 Move pointer back - used in lookbehind assertions */
/* ONCE and COND must come after the assertions, with ONCE first, as there's
a test for >= ONCE for a subpattern that isn't an assertion. */
OP_ONCE, /* 70 Once matched, don't back up into the subpattern */
OP_COND, /* 71 Conditional group */
OP_CREF, /* 72 Used to hold an extraction string number (cond ref) */
OP_ONCE, /* 74 Once matched, don't back up into the subpattern */
OP_COND, /* 75 Conditional group */
OP_CREF, /* 76 Used to hold an extraction string number (cond ref) */
OP_BRAZERO, /* 73 These two must remain together and in this */
OP_BRAMINZERO, /* 74 order. */
OP_BRAZERO, /* 77 These two must remain together and in this */
OP_BRAMINZERO, /* 78 order. */
OP_BRANUMBER, /* 75 Used for extracting brackets whose number is greater
OP_BRANUMBER, /* 79 Used for extracting brackets whose number is greater
than can fit into an opcode. */
OP_BRA /* 76 This and greater values are used for brackets that
extract substrings up to a basic limit. After that,
use is made of OP_BRANUMBER. */
OP_BRA /* 80 This and greater values are used for brackets that
extract substrings up to EXTRACT_BASIC_MAX. After
that, use is made of OP_BRANUMBER. */
};
/* WARNING: There is an implicit assumption in study.c that all opcodes are
less than 128 in value. This makes handling UTF-8 character sequences easier.
*/
/* WARNING WARNING WARNING: There is an implicit assumption in pcre.c and
study.c that all opcodes are less than 128 in value. This makes handling UTF-8
character sequences easier. */
/* The highest extraction number before we have to start using additional
bytes. (Originally PCRE didn't have support for extraction counts highter than
this number.) The value is limited by the number of opcodes left after OP_BRA,
i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional
opcodes. */
#define EXTRACT_BASIC_MAX 100
/* This macro defines textual names for all the opcodes. There are used only
@@ -439,8 +487,10 @@ macro is referenced only in printint.c. */
#define OP_NAME_LIST \
"End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d", \
"\\S", "\\s", "\\W", "\\w", "Any", "Anybyte", "\\Z", "\\z", \
"Opt", "^", "$", "chars", "not", \
"\\S", "\\s", "\\W", "\\w", "Any", "Anybyte", \
"notprop", "prop", "extuni", \
"\\Z", "\\z", \
"Opt", "^", "$", "char", "charnc", "not", \
"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
@@ -463,8 +513,11 @@ in UTF-8 mode. The code that uses this table must know about such things. */
#define OP_LENGTHS \
1, /* End */ \
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \
1, 1, 1, 1, 2, 1, 1, /* Any, Anybyte, \Z, \z, Opt, ^, $ */ \
2, /* Chars - the minimum length */ \
1, 1, /* Any, Anybyte */ \
2, 2, 1, /* NOTPROP, PROP, EXTUNI */ \
1, 1, 2, 1, 1, /* \Z, \z, Opt, ^, $ */ \
2, /* Char - the minimum length */ \
2, /* Charnc - the minimum length */ \
2, /* not */ \
/* Positive single-char repeats ** These are */ \
2, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** minima in */ \
@@ -483,7 +536,7 @@ in UTF-8 mode. The code that uses this table must know about such things. */
0, /* XCLASS - variable length */ \
3, /* REF */ \
1+LINK_SIZE, /* RECURSE */ \
2, /* CALLOUT */ \
2+2*LINK_SIZE, /* CALLOUT */ \
1+LINK_SIZE, /* Alt */ \
1+LINK_SIZE, /* Ket */ \
1+LINK_SIZE, /* KetRmax */ \
@@ -501,14 +554,6 @@ in UTF-8 mode. The code that uses this table must know about such things. */
1+LINK_SIZE /* BRA */ \
/* The highest extraction number before we have to start using additional
bytes. (Originally PCRE didn't have support for extraction counts highter than
this number.) The value is limited by the number of opcodes left after OP_BRA,
i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional
opcodes. */
#define EXTRACT_BASIC_MAX 150
/* A magic value for OP_CREF to indicate the "in recursion" condition. */
#define CREF_RECURSE 0xffff
@@ -554,7 +599,7 @@ just to accommodate the POSIX wrapper. */
#define ERR34 "character value in \\x{...} sequence is too large"
#define ERR35 "invalid condition (?(0)"
#define ERR36 "\\C not allowed in lookbehind assertion"
#define ERR37 "PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X"
#define ERR37 "PCRE does not support \\L, \\l, \\N, \\U, or \\u"
#define ERR38 "number after (?C is > 255"
#define ERR39 "closing ) for (?C expected"
#define ERR40 "recursive call could loop indefinitely"
@@ -562,37 +607,51 @@ just to accommodate the POSIX wrapper. */
#define ERR42 "syntax error after (?P"
#define ERR43 "two named groups have the same name"
#define ERR44 "invalid UTF-8 string"
/* All character handling must be done as unsigned characters. Otherwise there
are problems with top-bit-set characters and functions such as isspace().
However, we leave the interface to the outside world as char *, because that
should make things easier for callers. We define a short type for unsigned char
to save lots of typing. I tried "uchar", but it causes problems on Digital
Unix, where it is defined in sys/types, so use "uschar" instead. */
typedef unsigned char uschar;
#define ERR45 "support for \\P, \\p, and \\X has not been compiled"
#define ERR46 "malformed \\P or \\p sequence"
#define ERR47 "unknown property name after \\P or \\p"
/* The real format of the start of the pcre block; the index of names and the
code vector run on as long as necessary after the end. */
code vector run on as long as necessary after the end. We store an explicit
offset to the name table so that if a regex is compiled on one host, saved, and
then run on another where the size of pointers is different, all might still
be well. For the case of compiled-on-4 and run-on-8, we include an extra
pointer that is always NULL. For future-proofing, we also include a few dummy
fields - even though you can never get this planning right!
NOTE NOTE NOTE:
Because people can now save and re-use compiled patterns, any additions to this
structure should be made at the end, and something earlier (e.g. a new
flag in the options or one of the dummy fields) should indicate that the new
fields are present. Currently PCRE always sets the dummy fields to zero.
NOTE NOTE NOTE:
*/
typedef struct real_pcre {
unsigned long int magic_number;
size_t size; /* Total that was malloced */
const unsigned char *tables; /* Pointer to tables */
unsigned long int options;
unsigned short int top_bracket;
unsigned short int top_backref;
unsigned short int first_byte;
unsigned short int req_byte;
unsigned short int name_entry_size; /* Size of any name items; 0 => none */
unsigned short int name_count; /* Number of name items */
pcre_uint32 magic_number;
pcre_uint32 size; /* Total that was malloced */
pcre_uint32 options;
pcre_uint32 dummy1; /* For future use, maybe */
pcre_uint16 top_bracket;
pcre_uint16 top_backref;
pcre_uint16 first_byte;
pcre_uint16 req_byte;
pcre_uint16 name_table_offset; /* Offset to name table that follows */
pcre_uint16 name_entry_size; /* Size of any name items */
pcre_uint16 name_count; /* Number of name items */
pcre_uint16 dummy2; /* For future use, maybe */
const unsigned char *tables; /* Pointer to tables or NULL for std */
const unsigned char *nullpad; /* NULL padding */
} real_pcre;
/* The format of the block used to store data from pcre_study(). */
/* The format of the block used to store data from pcre_study(). The same
remark (see NOTE above) about extending this structure applies. */
typedef struct pcre_study_data {
size_t size; /* Total that was malloced */
uschar options;
pcre_uint32 size; /* Total that was malloced */
pcre_uint32 options;
uschar start_bits[32];
} pcre_study_data;
@@ -605,12 +664,14 @@ typedef struct compile_data {
const uschar *cbits; /* Points to character type table */
const uschar *ctypes; /* Points to table of type maps */
const uschar *start_code; /* The start of the compiled code */
const uschar *start_pattern; /* The start of the pattern */
uschar *name_table; /* The name/number table */
int names_found; /* Number of entries so far */
int name_entry_size; /* Size of each entry */
int top_backref; /* Maximum back reference */
unsigned int backref_map; /* Bitmap of low back refs */
int req_varyopt; /* "After variable item" flag for reqbyte */
BOOL nopartial; /* Set TRUE if partial won't work */
} compile_data;
/* Structure for maintaining a chain of pointers to the currently incomplete
@@ -660,6 +721,8 @@ typedef struct match_data {
BOOL utf8; /* UTF8 flag */
BOOL endonly; /* Dollar not before final \n */
BOOL notempty; /* Empty string match not wanted */
BOOL partial; /* PARTIAL flag */
BOOL hitend; /* Hit the end of the subject at some point */
const uschar *start_code; /* For use when recursing */
const uschar *start_subject; /* Start of the subject string */
const uschar *end_subject; /* End of the subject string */
+19
View File
@@ -0,0 +1,19 @@
LIBRARY libpcre
EXPORTS
pcre_malloc
pcre_free
pcre_config
pcre_callout
pcre_compile
pcre_copy_substring
pcre_exec
pcre_get_substring
pcre_get_stringnumber
pcre_get_substring_list
pcre_free_substring
pcre_free_substring_list
pcre_info
pcre_fullinfo
pcre_maketables
pcre_study
pcre_version
+24
View File
@@ -0,0 +1,24 @@
LIBRARY libpcreposix
EXPORTS
pcre_malloc
pcre_free
pcre_config
pcre_callout
pcre_compile
pcre_copy_substring
pcre_exec
pcre_get_substring
pcre_get_stringnumber
pcre_get_substring_list
pcre_free_substring
pcre_free_substring_list
pcre_info
pcre_fullinfo
pcre_maketables
pcre_study
pcre_version
regcomp
regexec
regerror
regfree
+21 -15
View File
@@ -11,26 +11,32 @@ Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), then the terms of that licence shall
supersede any condition above with which it is incompatible.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
See the file Tech.Notes for some information on the internals.
*/
+1607 -716
View File
File diff suppressed because it is too large. Load diff
+52 -6
View File
@@ -2,7 +2,39 @@
* Perl-Compatible Regular Expressions *
*************************************************/
/* Copyright (c) 1997-2003 University of Cambridge */
/* In its original form, this is the .in file that is transformed by
"configure" into pcre.h.
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifndef _PCRE_H
#define _PCRE_H
@@ -12,9 +44,9 @@ make changes to pcre.in. */
#include "php_compat.h"
#define PCRE_MAJOR 4
#define PCRE_MINOR 5
#define PCRE_DATE 01-December-2003
#define PCRE_MAJOR 5
#define PCRE_MINOR 0
#define PCRE_DATE 13-Sep-2004
/* Win32 uses DLL by default */
@@ -60,6 +92,8 @@ extern "C" {
#define PCRE_UTF8 0x0800
#define PCRE_NO_AUTO_CAPTURE 0x1000
#define PCRE_NO_UTF8_CHECK 0x2000
#define PCRE_AUTO_CALLOUT 0x4000
#define PCRE_PARTIAL 0x8000
/* Exec-time and get/set-time error codes */
@@ -74,6 +108,10 @@ extern "C" {
#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
#define PCRE_ERROR_BADUTF8 (-10)
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
#define PCRE_ERROR_PARTIAL (-12)
#define PCRE_ERROR_BADPARTIAL (-13)
#define PCRE_ERROR_INTERNAL (-14)
#define PCRE_ERROR_BADCOUNT (-15)
/* Request types for pcre_fullinfo() */
@@ -89,6 +127,7 @@ extern "C" {
#define PCRE_INFO_NAMECOUNT 8
#define PCRE_INFO_NAMETABLE 9
#define PCRE_INFO_STUDYSIZE 10
#define PCRE_INFO_DEFAULT_TABLES 11
/* Request types for pcre_config() */
@@ -98,12 +137,14 @@ extern "C" {
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
#define PCRE_CONFIG_MATCH_LIMIT 4
#define PCRE_CONFIG_STACKRECURSE 5
#define PCRE_CONFIG_UNICODE_PROPERTIES 6
/* Bit flags for the pcre_extra structure */
#define PCRE_EXTRA_STUDY_DATA 0x0001
#define PCRE_EXTRA_MATCH_LIMIT 0x0002
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
#define PCRE_EXTRA_TABLES 0x0008
/* Types */
@@ -111,13 +152,15 @@ struct real_pcre; /* declaration; the definition is private */
typedef struct real_pcre pcre;
/* The structure for passing additional data to pcre_exec(). This is defined in
such as way as to be extensible. */
such as way as to be extensible. Always add new fields at the end, in order to
remain compatible. */
typedef struct pcre_extra {
unsigned long int flags; /* Bits for which fields are set */
void *study_data; /* Opaque data from pcre_study() */
unsigned long int match_limit; /* Maximum number of calls to match() */
void *callout_data; /* Data passed back in callouts */
const unsigned char *tables; /* Pointer to character tables */
} pcre_extra;
/* The structure for passing out data via the pcre_callout_function. We use a
@@ -133,10 +176,13 @@ typedef struct pcre_callout_block {
const char *subject; /* The subject being matched */
int subject_length; /* The length of the subject */
int start_match; /* Offset to start of this match attempt */
int current_position; /* Where we currently are */
int current_position; /* Where we currently are in the subject */
int capture_top; /* Max current capture */
int capture_last; /* Most recently closed capture */
void *callout_data; /* Data passed in with the call */
/* ------------------- Added for Version 1 -------------------------- */
int pattern_position; /* Offset to next item in the pattern */
int next_item_length; /* Length of next item in the pattern */
/* ------------------------------------------------------------------ */
} pcre_callout_block;
+324
View File
@@ -0,0 +1,324 @@
/*************************************************
* PCRE DEMONSTRATION PROGRAM *
*************************************************/
/* This is a demonstration program to illustrate the most straightforward ways
of calling the PCRE regular expression library from a C program. See the
pcresample documentation for a short discussion.
Compile thuswise:
gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib \
-R/usr/local/lib -lpcre
Replace "/usr/local/include" and "/usr/local/lib" with wherever the include and
library files for PCRE are installed on your system. Only some operating
systems (e.g. Solaris) use the -R option.
*/
#include <stdio.h>
#include <string.h>
#include <pcre.h>
#define OVECCOUNT 30 /* should be a multiple of 3 */
int main(int argc, char **argv)
{
pcre *re;
const char *error;
char *pattern;
char *subject;
unsigned char *name_table;
int erroffset;
int find_all;
int namecount;
int name_entry_size;
int ovector[OVECCOUNT];
int subject_length;
int rc, i;
/**************************************************************************
* First, sort out the command line. There is only one possible option at *
* the moment, "-g" to request repeated matching to find all occurrences, *
* like Perl's /g option. We set the variable find_all to a non-zero value *
* if the -g option is present. Apart from that, there must be exactly two *
* arguments. *
**************************************************************************/
find_all = 0;
for (i = 1; i < argc; i++)
{
if (strcmp(argv[i], "-g") == 0) find_all = 1;
else break;
}
/* After the options, we require exactly two arguments, which are the pattern,
and the subject string. */
if (argc - i != 2)
{
printf("Two arguments required: a regex and a subject string\n");
return 1;
}
pattern = argv[i];
subject = argv[i+1];
subject_length = (int)strlen(subject);
/*************************************************************************
* Now we are going to compile the regular expression pattern, and handle *
* and errors that are detected. *
*************************************************************************/
re = pcre_compile(
pattern, /* the pattern */
0, /* default options */
&error, /* for error message */
&erroffset, /* for error offset */
NULL); /* use default character tables */
/* Compilation failed: print the error message and exit */
if (re == NULL)
{
printf("PCRE compilation failed at offset %d: %s\n", erroffset, error);
return 1;
}
/*************************************************************************
* If the compilation succeeded, we call PCRE again, in order to do a *
* pattern match against the subject string. This does just ONE match. If *
* further matching is needed, it will be done below. *
*************************************************************************/
rc = pcre_exec(
re, /* the compiled pattern */
NULL, /* no extra data - we didn't study the pattern */
subject, /* the subject string */
subject_length, /* the length of the subject */
0, /* start at offset 0 in the subject */
0, /* default options */
ovector, /* output vector for substring information */
OVECCOUNT); /* number of elements in the output vector */
/* Matching failed: handle error cases */
if (rc < 0)
{
switch(rc)
{
case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
/*
Handle other special cases if you like
*/
default: printf("Matching error %d\n", rc); break;
}
free(re); /* Release memory used for the compiled pattern */
return 1;
}
/* Match succeded */
printf("\nMatch succeeded at offset %d\n", ovector[0]);
/*************************************************************************
* We have found the first match within the subject string. If the output *
* vector wasn't big enough, set its size to the maximum. Then output any *
* substrings that were captured. *
*************************************************************************/
/* The output vector wasn't big enough */
if (rc == 0)
{
rc = OVECCOUNT/3;
printf("ovector only has room for %d captured substrings\n", rc - 1);
}
/* Show substrings stored in the output vector by number. Obviously, in a real
application you might want to do things other than print them. */
for (i = 0; i < rc; i++)
{
char *substring_start = subject + ovector[2*i];
int substring_length = ovector[2*i+1] - ovector[2*i];
printf("%2d: %.*s\n", i, substring_length, substring_start);
}
/**************************************************************************
* That concludes the basic part of this demonstration program. We have *
* compiled a pattern, and performed a single match. The code that follows *
* first shows how to access named substrings, and then how to code for *
* repeated matches on the same subject. *
**************************************************************************/
/* See if there are any named substrings, and if so, show them by name. First
we have to extract the count of named parentheses from the pattern. */
(void)pcre_fullinfo(
re, /* the compiled pattern */
NULL, /* no extra data - we didn't study the pattern */
PCRE_INFO_NAMECOUNT, /* number of named substrings */
&namecount); /* where to put the answer */
if (namecount <= 0) printf("No named substrings\n"); else
{
unsigned char *tabptr;
printf("Named substrings\n");
/* Before we can access the substrings, we must extract the table for
translating names to numbers, and the size of each entry in the table. */
(void)pcre_fullinfo(
re, /* the compiled pattern */
NULL, /* no extra data - we didn't study the pattern */
PCRE_INFO_NAMETABLE, /* address of the table */
&name_table); /* where to put the answer */
(void)pcre_fullinfo(
re, /* the compiled pattern */
NULL, /* no extra data - we didn't study the pattern */
PCRE_INFO_NAMEENTRYSIZE, /* size of each entry in the table */
&name_entry_size); /* where to put the answer */
/* Now we can scan the table and, for each entry, print the number, the name,
and the substring itself. */
tabptr = name_table;
for (i = 0; i < namecount; i++)
{
int n = (tabptr[0] << 8) | tabptr[1];
printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
ovector[2*n+1] - ovector[2*n], subject + ovector[2*n]);
tabptr += name_entry_size;
}
}
/*************************************************************************
* If the "-g" option was given on the command line, we want to continue *
* to search for additional matches in the subject string, in a similar *
* way to the /g option in Perl. This turns out to be trickier than you *
* might think because of the possibility of matching an empty string. *
* What happens is as follows: *
* *
* If the previous match was NOT for an empty string, we can just start *
* the next match at the end of the previous one. *
* *
* If the previous match WAS for an empty string, we can't do that, as it *
* would lead to an infinite loop. Instead, a special call of pcre_exec() *
* is made with the PCRE_NOTEMPTY and PCRE_ANCHORED flags set. The first *
* of these tells PCRE that an empty string is not a valid match; other *
* possibilities must be tried. The second flag restricts PCRE to one *
* match attempt at the initial string position. If this match succeeds, *
* an alternative to the empty string match has been found, and we can *
* proceed round the loop. *
*************************************************************************/
if (!find_all)
{
free(re); /* Release the memory used for the compiled pattern */
return 0; /* Finish unless -g was given */
}
/* Loop for second and subsequent matches */
for (;;)
{
int options = 0; /* Normally no options */
int start_offset = ovector[1]; /* Start at end of previous match */
/* If the previous match was for an empty string, we are finished if we are
at the end of the subject. Otherwise, arrange to run another match at the
same point to see if a non-empty match can be found. */
if (ovector[0] == ovector[1])
{
if (ovector[0] == subject_length) break;
options = PCRE_NOTEMPTY | PCRE_ANCHORED;
}
/* Run the next matching operation */
rc = pcre_exec(
re, /* the compiled pattern */
NULL, /* no extra data - we didn't study the pattern */
subject, /* the subject string */
subject_length, /* the length of the subject */
start_offset, /* starting offset in the subject */
options, /* options */
ovector, /* output vector for substring information */
OVECCOUNT); /* number of elements in the output vector */
/* This time, a result of NOMATCH isn't an error. If the value in "options"
is zero, it just means we have found all possible matches, so the loop ends.
Otherwise, it means we have failed to find a non-empty-string match at a
point where there was a previous empty-string match. In this case, we do what
Perl does: advance the matching position by one, and continue. We do this by
setting the "end of previous match" offset, because that is picked up at the
top of the loop as the point at which to start again. */
if (rc == PCRE_ERROR_NOMATCH)
{
if (options == 0) break;
ovector[1] = start_offset + 1;
continue; /* Go round the loop again */
}
/* Other matching errors are not recoverable. */
if (rc < 0)
{
printf("Matching error %d\n", rc);
free(re); /* Release memory used for the compiled pattern */
return 1;
}
/* Match succeded */
printf("\nMatch succeeded again at offset %d\n", ovector[0]);
/* The match succeeded, but the output vector wasn't big enough. */
if (rc == 0)
{
rc = OVECCOUNT/3;
printf("ovector only has room for %d captured substrings\n", rc - 1);
}
/* As before, show substrings stored in the output vector by number, and then
also any named substrings. */
for (i = 0; i < rc; i++)
{
char *substring_start = subject + ovector[2*i];
int substring_length = ovector[2*i+1] - ovector[2*i];
printf("%2d: %.*s\n", i, substring_length, substring_start);
}
if (namecount <= 0) printf("No named substrings\n"); else
{
unsigned char *tabptr = name_table;
printf("Named substrings\n");
for (i = 0; i < namecount; i++)
{
int n = (tabptr[0] << 8) | tabptr[1];
printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
ovector[2*n+1] - ovector[2*n], subject + ovector[2*n]);
tabptr += name_entry_size;
}
}
} /* End of loop to find second and subsequent matches */
printf("\n");
free(re); /* Release memory used for the compiled pattern */
return 0;
}
/* End of pcredemo.c */
+32 -1
View File
@@ -4,7 +4,38 @@
/* This is a grep program that uses the PCRE regular expression library to do
its pattern matching. On a Unix or Win32 system it can recurse into
directories. */
directories.
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#include <ctype.h>
#include <stdio.h>
+27 -16
View File
@@ -15,23 +15,31 @@ Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), then the terms of that licence shall
supersede any condition above with which it is incompatible.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
@@ -48,7 +56,7 @@ static const char *const estring[] = {
ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20,
ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR29, ERR29, ERR30,
ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39, ERR40,
ERR41, ERR42, ERR43, ERR44 };
ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47 };
static const int eint[] = {
REG_EESCAPE, /* "\\ at end of pattern" */
@@ -87,14 +95,17 @@ static const int eint[] = {
REG_BADPAT, /* "character value in \x{...} sequence is too large" */
REG_BADPAT, /* "invalid condition (?(0)" */
REG_BADPAT, /* "\\C not allowed in lookbehind assertion" */
REG_EESCAPE, /* "PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X" */
REG_EESCAPE, /* "PCRE does not support \\L, \\l, \\N, \\U, or \\u" */
REG_BADPAT, /* "number after (?C is > 255" */
REG_BADPAT, /* "closing ) for (?C expected" */
REG_BADPAT, /* "recursive call could loop indefinitely" */
REG_BADPAT, /* "unrecognized character after (?P" */
REG_BADPAT, /* "syntax error after (?P" */
REG_BADPAT, /* "two named groups have the same name" */
REG_BADPAT /* "invalid UTF-8 string" */
REG_BADPAT, /* "invalid UTF-8 string" */
REG_BADPAT, /* "support for \\P, \\p, and \\X has not been compiled" */
REG_BADPAT, /* "malformed \\P or \\p sequence" */
REG_BADPAT /* "unknown property name after \\P or \\p" */
};
/* Table of texts corresponding to POSIX error codes */
+32 -3
View File
@@ -2,14 +2,43 @@
* Perl-Compatible Regular Expressions *
*************************************************/
/* Copyright (c) 1997-2003 University of Cambridge */
#ifndef _PCREPOSIX_H
#define _PCREPOSIX_H
/* This is the header for the POSIX wrapper interface to the PCRE Perl-
Compatible Regular Expression library. It defines the things POSIX says should
be there. I hope. */
be there. I hope.
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* Have to include stdlib.h in order to ensure that size_t is defined. */
+380 -77
View File
@@ -4,7 +4,37 @@
/* This program was hacked up as a tester for PCRE. I really should have
written it more tidily in the first place. Will I ever learn? It has grown and
been extended and consequently is now rather untidy in places. */
been extended and consequently is now rather untidy in places.
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#include <ctype.h>
#include <stdio.h>
@@ -12,6 +42,7 @@ been extended and consequently is now rather untidy in places. */
#include <stdlib.h>
#include <time.h>
#include <locale.h>
#include <errno.h>
/* We need the internal info for displaying the results of pcre_study(). Also
for getting the opcodes for showing compiled code. */
@@ -35,9 +66,10 @@ Makefile. */
#endif
#endif
#define LOOPREPEAT 50000
#define LOOPREPEAT 500000
#define BUFFER_SIZE 30000
#define PBUFFER_SIZE BUFFER_SIZE
#define DBUFFER_SIZE BUFFER_SIZE
@@ -52,6 +84,8 @@ static int show_malloc;
static int use_utf8;
static size_t gotten_store;
static uschar *pbuffer = NULL;
static const int utf8_table1[] = {
0x0000007f, 0x000007ff, 0x0000ffff, 0x001fffff, 0x03ffffff, 0x7fffffff};
@@ -71,10 +105,13 @@ static const int utf8_table3[] = {
/* The code for doing this is held in a separate file that is also included in
pcre.c when it is compiled with the debug switch. It defines a function called
print_internals(), which uses a table of opcode lengths defined by the macro
OP_LENGTHS, whose name must be OP_lengths. */
OP_LENGTHS, whose name must be OP_lengths. It also uses a table that translates
Unicode property names to numbers; this is kept in a separate file. */
static uschar OP_lengths[] = { OP_LENGTHS };
#include "ucp.h"
#include "ucptypetable.c"
#include "printint.c"
@@ -269,7 +306,7 @@ data is not zero. */
static int callout(pcre_callout_block *cb)
{
FILE *f = (first_callout | callout_extra)? outfile : NULL;
int i, pre_start, post_start;
int i, pre_start, post_start, subject_length;
if (callout_extra)
{
@@ -300,16 +337,26 @@ pre_start = pchars((unsigned char *)cb->subject, cb->start_match, f);
post_start = pchars((unsigned char *)(cb->subject + cb->start_match),
cb->current_position - cb->start_match, f);
subject_length = pchars((unsigned char *)cb->subject, cb->subject_length, NULL);
(void)pchars((unsigned char *)(cb->subject + cb->current_position),
cb->subject_length - cb->current_position, f);
if (f != NULL) fprintf(f, "\n");
/* Always print appropriate indicators, with callout number if not already
shown */
shown. For automatic callouts, show the pattern offset. */
if (callout_extra) fprintf(outfile, " ");
else fprintf(outfile, "%3d ", cb->callout_number);
if (cb->callout_number == 255)
{
fprintf(outfile, "%+3d ", cb->pattern_position);
if (cb->pattern_position > 99) fprintf(outfile, "\n ");
}
else
{
if (callout_extra) fprintf(outfile, " ");
else fprintf(outfile, "%3d ", cb->callout_number);
}
for (i = 0; i < pre_start; i++) fprintf(outfile, " ");
fprintf(outfile, "^");
@@ -320,6 +367,12 @@ if (post_start > 0)
fprintf(outfile, "^");
}
for (i = 0; i < subject_length - pre_start - post_start + 4; i++)
fprintf(outfile, " ");
fprintf(outfile, "%.*s", (cb->next_item_length == 0)? 1 : cb->next_item_length,
pbuffer + cb->pattern_position);
fprintf(outfile, "\n");
first_callout = 0;
@@ -395,6 +448,23 @@ if ((rc = pcre_fullinfo(re, study, option, ptr)) < 0)
/*************************************************
* Byte flipping function *
*************************************************/
static long int
byteflip(long int value, int n)
{
if (n == 2) return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);
return ((value & 0x000000ff) << 24) |
((value & 0x0000ff00) << 8) |
((value & 0x00ff0000) >> 8) |
((value & 0xff000000) >> 24);
}
/*************************************************
* Main Program *
*************************************************/
@@ -429,8 +499,15 @@ when I am debugging. */
buffer = (unsigned char *)malloc(BUFFER_SIZE);
dbuffer = (unsigned char *)malloc(DBUFFER_SIZE);
pbuffer = (unsigned char *)malloc(PBUFFER_SIZE);
/* Static so that new_malloc can use it. */
/* The outfile variable is static so that new_malloc can use it. The _setmode()
stuff is some magic that I don't understand, but which apparently does good
things in Windows. It's related to line terminations. */
#if defined(_WIN32) || defined(WIN32)
_setmode( _fileno( stdout ), 0x8000 );
#endif /* defined(_WIN32) || defined(WIN32) */
outfile = stdout;
@@ -462,6 +539,8 @@ while (argc > 1 && argv[op][0] == '-')
printf("Compiled with\n");
(void)pcre_config(PCRE_CONFIG_UTF8, &rc);
printf(" %sUTF-8 support\n", rc? "" : "No ");
(void)pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &rc);
printf(" %sUnicode properties support\n", rc? "" : "No ");
(void)pcre_config(PCRE_CONFIG_NEWLINE, &rc);
printf(" Newline character is %s\n", (rc == '\r')? "CR" : "LF");
(void)pcre_config(PCRE_CONFIG_LINK_SIZE, &rc);
@@ -481,11 +560,12 @@ while (argc > 1 && argv[op][0] == '-')
printf(" -C show PCRE compile-time options and exit\n");
printf(" -d debug: show compiled code; implies -i\n"
" -i show information about compiled pattern\n"
" -m output memory used information\n"
" -o <n> set size of offsets vector to <n>\n");
#if !defined NOPOSIX
printf(" -p use POSIX interface\n");
#endif
printf(" -s output store information\n"
printf(" -s output store (memory) used information\n"
" -t time compilation and execution\n");
return 1;
}
@@ -508,7 +588,7 @@ if (offsets == NULL)
if (argc > 1)
{
infile = fopen(argv[op], "r");
infile = fopen(argv[op], "rb");
if (infile == NULL)
{
printf("** Failed to open %s\n", argv[op]);
@@ -518,7 +598,7 @@ if (argc > 1)
if (argc > 2)
{
outfile = fopen(argv[op+1], "w");
outfile = fopen(argv[op+1], "wb");
if (outfile == NULL)
{
printf("** Failed to open %s\n", argv[op+1]);
@@ -551,13 +631,17 @@ while (!done)
const char *error;
unsigned char *p, *pp, *ppp;
unsigned char *to_file = NULL;
const unsigned char *tables = NULL;
unsigned long int true_size, true_study_size = 0;
size_t size, regex_gotten_store;
int do_study = 0;
int do_debug = debug;
int do_G = 0;
int do_g = 0;
int do_showinfo = showinfo;
int do_showrest = 0;
int do_flip = 0;
int erroroffset, len, delimiter;
use_utf8 = 0;
@@ -571,8 +655,93 @@ while (!done)
while (isspace(*p)) p++;
if (*p == 0) continue;
/* Get the delimiter and seek the end of the pattern; if is isn't
complete, read more. */
/* See if the pattern is to be loaded pre-compiled from a file. */
if (*p == '<' && strchr((char *)(p+1), '<') == NULL)
{
unsigned long int magic;
uschar sbuf[8];
FILE *f;
p++;
pp = p + (int)strlen((char *)p);
while (isspace(pp[-1])) pp--;
*pp = 0;
f = fopen((char *)p, "rb");
if (f == NULL)
{
fprintf(outfile, "Failed to open %s: %s\n", p, strerror(errno));
continue;
}
if (fread(sbuf, 1, 8, f) != 8) goto FAIL_READ;
true_size =
(sbuf[0] << 24) | (sbuf[1] << 16) | (sbuf[2] << 8) | sbuf[3];
true_study_size =
(sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];
re = (real_pcre *)new_malloc(true_size);
regex_gotten_store = gotten_store;
if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;
magic = ((real_pcre *)re)->magic_number;
if (magic != MAGIC_NUMBER)
{
if (byteflip(magic, sizeof(magic)) == MAGIC_NUMBER)
{
do_flip = 1;
}
else
{
fprintf(outfile, "Data in %s is not a compiled PCRE regex\n", p);
fclose(f);
continue;
}
}
fprintf(outfile, "Compiled regex%s loaded from %s\n",
do_flip? " (byte-inverted)" : "", p);
/* Need to know if UTF-8 for printing data strings */
new_info(re, NULL, PCRE_INFO_OPTIONS, &options);
use_utf8 = (options & PCRE_UTF8) != 0;
/* Now see if there is any following study data */
if (true_study_size != 0)
{
pcre_study_data *psd;
extra = (pcre_extra *)new_malloc(sizeof(pcre_extra) + true_study_size);
extra->flags = PCRE_EXTRA_STUDY_DATA;
psd = (pcre_study_data *)(((char *)extra) + sizeof(pcre_extra));
extra->study_data = psd;
if (fread(psd, 1, true_study_size, f) != true_study_size)
{
FAIL_READ:
fprintf(outfile, "Failed to read data from %s\n", p);
if (extra != NULL) new_free(extra);
if (re != NULL) new_free(re);
fclose(f);
continue;
}
fprintf(outfile, "Study data loaded from %s\n", p);
do_study = 1; /* To get the data output if requested */
}
else fprintf(outfile, "No study data\n");
fclose(f);
goto SHOW_INFO;
}
/* In-line pattern (the usual case). Get the delimiter and seek the end of
the pattern; if is isn't complete, read more. */
delimiter = *p++;
@@ -617,9 +786,11 @@ while (!done)
if (pp[1] == '\\') *pp++ = '\\';
/* Terminate the pattern at the delimiter */
/* Terminate the pattern at the delimiter, and save a copy of the pattern
for callouts. */
*pp++ = 0;
strcpy((char *)pbuffer, (char *)p);
/* Look for options after final delimiter */
@@ -639,8 +810,10 @@ while (!done)
case '+': do_showrest = 1; break;
case 'A': options |= PCRE_ANCHORED; break;
case 'C': options |= PCRE_AUTO_CALLOUT; break;
case 'D': do_debug = do_showinfo = 1; break;
case 'E': options |= PCRE_DOLLAR_ENDONLY; break;
case 'F': do_flip = 1; break;
case 'G': do_G = 1; break;
case 'I': do_showinfo = 1; break;
case 'M': log_store = 1; break;
@@ -669,7 +842,15 @@ while (!done)
pp = ppp;
break;
case '>':
to_file = pp;
while (*pp != 0) pp++;
while (isspace(pp[-1])) pp--;
*pp = 0;
break;
case '\n': case ' ': break;
default:
fprintf(outfile, "** Unknown option '%c'\n", pp[-1]);
goto SKIP_DATA;
@@ -685,6 +866,7 @@ while (!done)
{
int rc;
int cflags = 0;
if ((options & PCRE_CASELESS) != 0) cflags |= REG_ICASE;
if ((options & PCRE_MULTILINE) != 0) cflags |= REG_NEWLINE;
rc = regcomp(&preg, (char *)p, cflags);
@@ -759,14 +941,77 @@ while (!done)
sizeof(real_pcre) -
((real_pcre *)re)->name_count * ((real_pcre *)re)->name_entry_size));
/* Extract the size for possible writing before possibly flipping it,
and remember the store that was got. */
true_size = ((real_pcre *)re)->size;
regex_gotten_store = gotten_store;
/* If /S was present, study the regexp to generate additional info to
help with the matching. */
if (do_study)
{
if (timeit)
{
register int i;
clock_t time_taken;
clock_t start_time = clock();
for (i = 0; i < LOOPREPEAT; i++)
extra = pcre_study(re, study_options, &error);
time_taken = clock() - start_time;
if (extra != NULL) free(extra);
fprintf(outfile, " Study time %.3f milliseconds\n",
(((double)time_taken * 1000.0) / (double)LOOPREPEAT) /
(double)CLOCKS_PER_SEC);
}
extra = pcre_study(re, study_options, &error);
if (error != NULL)
fprintf(outfile, "Failed to study: %s\n", error);
else if (extra != NULL)
true_study_size = ((pcre_study_data *)(extra->study_data))->size;
}
/* If the 'F' option was present, we flip the bytes of all the integer
fields in the regex data block and the study block. This is to make it
possible to test PCRE's handling of byte-flipped patterns, e.g. those
compiled on a different architecture. */
if (do_flip)
{
real_pcre *rre = (real_pcre *)re;
rre->magic_number = byteflip(rre->magic_number, sizeof(rre->magic_number));
rre->size = byteflip(rre->size, sizeof(rre->size));
rre->options = byteflip(rre->options, sizeof(rre->options));
rre->top_bracket = byteflip(rre->top_bracket, sizeof(rre->top_bracket));
rre->top_backref = byteflip(rre->top_backref, sizeof(rre->top_backref));
rre->first_byte = byteflip(rre->first_byte, sizeof(rre->first_byte));
rre->req_byte = byteflip(rre->req_byte, sizeof(rre->req_byte));
rre->name_table_offset = byteflip(rre->name_table_offset,
sizeof(rre->name_table_offset));
rre->name_entry_size = byteflip(rre->name_entry_size,
sizeof(rre->name_entry_size));
rre->name_count = byteflip(rre->name_count, sizeof(rre->name_count));
if (extra != NULL)
{
pcre_study_data *rsd = (pcre_study_data *)(extra->study_data);
rsd->size = byteflip(rsd->size, sizeof(rsd->size));
rsd->options = byteflip(rsd->options, sizeof(rsd->options));
}
}
/* Extract information from the compiled data if required */
SHOW_INFO:
if (do_showinfo)
{
unsigned long int get_options;
unsigned long int get_options, all_options;
int old_first_char, old_options, old_count;
int count, backrefmax, first_char, need_char;
int nameentrysize, namecount;
const uschar *nametable;
size_t size;
if (do_debug)
{
@@ -802,9 +1047,9 @@ while (!done)
get_options, old_options);
}
if (size != gotten_store) fprintf(outfile,
if (size != regex_gotten_store) fprintf(outfile,
"Size disagreement: pcre_fullinfo=%d call to malloc for %d\n",
size, gotten_store);
size, regex_gotten_store);
fprintf(outfile, "Capturing subpattern count = %d\n", count);
if (backrefmax > 0)
@@ -822,6 +1067,18 @@ while (!done)
}
}
/* The NOPARTIAL bit is a private bit in the options, so we have
to fish it out via out back door */
all_options = ((real_pcre *)re)->options;
if (do_flip)
{
all_options = byteflip(all_options, sizeof(all_options));
}
if ((all_options & PCRE_NOPARTIAL) != 0)
fprintf(outfile, "Partial matching not supported\n");
if (get_options == 0) fprintf(outfile, "No options\n");
else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s\n",
((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",
@@ -871,77 +1128,103 @@ while (!done)
else
fprintf(outfile, "Need char = %d%s\n", ch, caseless);
}
}
/* If /S was present, study the regexp to generate additional info to
help with the matching. */
if (do_study)
{
if (timeit)
{
register int i;
clock_t time_taken;
clock_t start_time = clock();
for (i = 0; i < LOOPREPEAT; i++)
extra = pcre_study(re, study_options, &error);
time_taken = clock() - start_time;
if (extra != NULL) free(extra);
fprintf(outfile, " Study time %.3f milliseconds\n",
(((double)time_taken * 1000.0) / (double)LOOPREPEAT) /
(double)CLOCKS_PER_SEC);
}
extra = pcre_study(re, study_options, &error);
if (error != NULL)
fprintf(outfile, "Failed to study: %s\n", error);
else if (extra == NULL)
fprintf(outfile, "Study returned NULL\n");
/* Don't output study size; at present it is in any case a fixed
value, but it varies, depending on the computer architecture, and
so messes up the test suite. */
so messes up the test suite. (And with the /F option, it might be
flipped.) */
else if (do_showinfo)
if (do_study)
{
size_t size;
uschar *start_bits = NULL;
new_info(re, extra, PCRE_INFO_STUDYSIZE, &size);
new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits);
/* fprintf(outfile, "Study size = %d\n", size); */
if (start_bits == NULL)
fprintf(outfile, "No starting character set\n");
if (extra == NULL)
fprintf(outfile, "Study returned NULL\n");
else
{
int i;
int c = 24;
fprintf(outfile, "Starting character set: ");
for (i = 0; i < 256; i++)
uschar *start_bits = NULL;
new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits);
if (start_bits == NULL)
fprintf(outfile, "No starting byte set\n");
else
{
if ((start_bits[i/8] & (1<<(i%8))) != 0)
int i;
int c = 24;
fprintf(outfile, "Starting byte set: ");
for (i = 0; i < 256; i++)
{
if (c > 75)
if ((start_bits[i/8] & (1<<(i&7))) != 0)
{
fprintf(outfile, "\n ");
c = 2;
}
if (isprint(i) && i != ' ')
{
fprintf(outfile, "%c ", i);
c += 2;
}
else
{
fprintf(outfile, "\\x%02x ", i);
c += 5;
if (c > 75)
{
fprintf(outfile, "\n ");
c = 2;
}
if (isprint(i) && i != ' ')
{
fprintf(outfile, "%c ", i);
c += 2;
}
else
{
fprintf(outfile, "\\x%02x ", i);
c += 5;
}
}
}
fprintf(outfile, "\n");
}
fprintf(outfile, "\n");
}
}
}
}
/* If the '>' option was present, we write out the regex to a file, and
that is all. The first 8 bytes of the file are the regex length and then
the study length, in big-endian order. */
if (to_file != NULL)
{
FILE *f = fopen((char *)to_file, "wb");
if (f == NULL)
{
fprintf(outfile, "Unable to open %s: %s\n", to_file, strerror(errno));
}
else
{
uschar sbuf[8];
sbuf[0] = (true_size >> 24) & 255;
sbuf[1] = (true_size >> 16) & 255;
sbuf[2] = (true_size >> 8) & 255;
sbuf[3] = (true_size) & 255;
sbuf[4] = (true_study_size >> 24) & 255;
sbuf[5] = (true_study_size >> 16) & 255;
sbuf[6] = (true_study_size >> 8) & 255;
sbuf[7] = (true_study_size) & 255;
if (fwrite(sbuf, 1, 8, f) < 8 ||
fwrite(re, 1, true_size, f) < true_size)
{
fprintf(outfile, "Write error on %s: %s\n", to_file, strerror(errno));
}
else
{
fprintf(outfile, "Compiled regex written to %s\n", to_file);
if (extra != NULL)
{
if (fwrite(extra->study_data, 1, true_study_size, f) <
true_study_size)
{
fprintf(outfile, "Write error on %s: %s\n", to_file,
strerror(errno));
}
else fprintf(outfile, "Study data written to %s\n", to_file);
}
}
fclose(f);
}
continue; /* With next regex */
}
} /* End of non-POSIX compile */
/* Read data lines and test them */
@@ -1045,10 +1328,14 @@ while (!done)
}
break;
case 0: /* Allows for an empty line */
case 0: /* \ followed by EOF allows for an empty line */
p--;
continue;
case '>':
while(isdigit(*p)) start_offset = start_offset * 10 + *p++ - '0';
continue;
case 'A': /* Option setting */
options |= PCRE_ANCHORED;
continue;
@@ -1159,6 +1446,10 @@ while (!done)
if (n == 0) use_offsets = NULL; /* Ensures it can't write to it */
continue;
case 'P':
options |= PCRE_PARTIAL;
continue;
case 'S':
show_malloc = 1;
continue;
@@ -1269,7 +1560,8 @@ while (!done)
min = mid;
mid = (mid == max - 1)? max : (max > 0)? (min + max)/2 : mid*2;
}
else if (count >= 0 || count == PCRE_ERROR_NOMATCH)
else if (count >= 0 || count == PCRE_ERROR_NOMATCH ||
count == PCRE_ERROR_PARTIAL)
{
if (mid == min + 1)
{
@@ -1305,8 +1597,11 @@ while (!done)
/* The normal case is just to do the match once, with the default
value of match_limit. */
else count = pcre_exec(re, extra, (char *)bptr, len,
start_offset, options | g_notempty, use_offsets, use_size_offsets);
else
{
count = pcre_exec(re, extra, (char *)bptr, len,
start_offset, options | g_notempty, use_offsets, use_size_offsets);
}
if (count == 0)
{
@@ -1393,6 +1688,14 @@ while (!done)
}
}
/* There was a partial match */
else if (count == PCRE_ERROR_PARTIAL)
{
fprintf(outfile, "Partial match\n");
break; /* Out of the /g loop */
}
/* Failed to match. If this is a /g or /G loop and we previously set
g_notempty after a null match, this is not necessarily the end.
We want to advance the start offset, and continue. In the case of UTF-8
+37 -25
View File
@@ -12,23 +12,31 @@ Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2003 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), then the terms of that licence shall
supersede any condition above with which it is incompatible.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
@@ -57,7 +65,7 @@ Returns: nothing
*/
static void
set_bit(uschar *start_bits, int c, BOOL caseless, compile_data *cd)
set_bit(uschar *start_bits, unsigned int c, BOOL caseless, compile_data *cd)
{
start_bits[c/8] |= (1 << (c&7));
if (caseless && (cd->ctypes[c] & ctype_letter) != 0)
@@ -123,7 +131,7 @@ do
/* Skip over callout */
case OP_CALLOUT:
tcode += 2;
tcode += 2 + 2*LINK_SIZE;
break;
/* Skip over extended extraction bracket number */
@@ -186,11 +194,10 @@ do
/* At least one single char sets the bit and stops */
case OP_EXACT: /* Fall through */
tcode++;
case OP_CHARS: /* Fall through */
tcode++;
tcode += 2;
case OP_CHAR:
case OP_CHARNC:
case OP_PLUS:
case OP_MINPLUS:
set_bit(start_bits, tcode[1], caseless, cd);
@@ -403,8 +410,9 @@ pcre_study(const pcre *external_re, int options, const char **errorptr)
uschar start_bits[32];
pcre_extra *extra;
pcre_study_data *study;
const uschar *tables;
const real_pcre *re = (const real_pcre *)external_re;
uschar *code = (uschar *)re + sizeof(real_pcre) +
uschar *code = (uschar *)re + re->name_table_offset +
(re->name_count * re->name_entry_size);
compile_data compile_block;
@@ -429,12 +437,16 @@ at present. */
if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)
return NULL;
/* Set the character tables in the block which is passed around */
/* Set the character tables in the block that is passed around */
compile_block.lcc = re->tables + lcc_offset;
compile_block.fcc = re->tables + fcc_offset;
compile_block.cbits = re->tables + cbits_offset;
compile_block.ctypes = re->tables + ctypes_offset;
tables = re->tables;
if (tables == NULL)
(void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES, &tables);
compile_block.lcc = tables + lcc_offset;
compile_block.fcc = tables + fcc_offset;
compile_block.cbits = tables + cbits_offset;
compile_block.ctypes = tables + ctypes_offset;
/* See if we can find a fixed set of initial characters for the pattern. */
+151
View File
@@ -0,0 +1,151 @@
/*************************************************
* libucp - Unicode Property Table handler *
*************************************************/
/* This function provides a fast way of obtaining the basic Unicode properties
of a character, using a compact binary tree that occupies less than 100K bytes.
Copyright (c) 2004 University of Cambridge
-------------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
*/
#include "ucp.h" /* Exported interface */
#include "ucpinternal.h" /* Internal table details */
#include "ucptable.c" /* The table itself */
/*************************************************
* Search table and return data *
*************************************************/
/* Two values are returned: the category is ucp_C, ucp_L, etc. The detailed
character type is ucp_Lu, ucp_Nd, etc.
Arguments:
c the character value
type_ptr the detailed character type is returned here
case_ptr for letters, the opposite case is returned here, if there
is one, else zero
Returns: the character type category or -1 if not found
*/
static int
ucp_findchar(const int c, int *type_ptr, int *case_ptr)
{
cnode *node = ucp_table;
register int cc = c;
int case_offset;
for (;;)
{
register int d = node->f1 | ((node->f0 & f0_chhmask) << 16);
if (cc == d) break;
if (cc < d)
{
if ((node->f0 & f0_leftexists) == 0) return -1;
node ++;
}
else
{
register int roffset = (node->f2 & f2_rightmask) >> f2_rightshift;
if (roffset == 0) return -1;
node += 1 << (roffset - 1);
}
}
switch ((*type_ptr = ((node->f0 & f0_typemask) >> f0_typeshift)))
{
case ucp_Cc:
case ucp_Cf:
case ucp_Cn:
case ucp_Co:
case ucp_Cs:
return ucp_C;
break;
case ucp_Ll:
case ucp_Lu:
case_offset = node->f2 & f2_casemask;
if ((case_offset & 0x0100) != 0) case_offset |= 0xfffff000;
*case_ptr = (case_offset == 0)? 0 : cc + case_offset;
return ucp_L;
case ucp_Lm:
case ucp_Lo:
case ucp_Lt:
*case_ptr = 0;
return ucp_L;
break;
case ucp_Mc:
case ucp_Me:
case ucp_Mn:
return ucp_M;
break;
case ucp_Nd:
case ucp_Nl:
case ucp_No:
return ucp_N;
break;
case ucp_Pc:
case ucp_Pd:
case ucp_Pe:
case ucp_Pf:
case ucp_Pi:
case ucp_Ps:
case ucp_Po:
return ucp_P;
break;
case ucp_Sc:
case ucp_Sk:
case ucp_Sm:
case ucp_So:
return ucp_S;
break;
case ucp_Zl:
case ucp_Zp:
case ucp_Zs:
return ucp_Z;
break;
default: /* "Should never happen" */
return -1;
break;
}
}
/* End of ucp.c */
+58
View File
@@ -0,0 +1,58 @@
/*************************************************
* libucp - Unicode Property Table handler *
*************************************************/
/* These are the character categories that are returned by ucp_findchar */
enum {
ucp_C, /* Other */
ucp_L, /* Letter */
ucp_M, /* Mark */
ucp_N, /* Number */
ucp_P, /* Punctuation */
ucp_S, /* Symbol */
ucp_Z /* Separator */
};
/* These are the detailed character types that are returned by ucp_findchar */
enum {
ucp_Cc, /* Control */
ucp_Cf, /* Format */
ucp_Cn, /* Unassigned */
ucp_Co, /* Private use */
ucp_Cs, /* Surrogate */
ucp_Ll, /* Lower case letter */
ucp_Lm, /* Modifier letter */
ucp_Lo, /* Other letter */
ucp_Lt, /* Title case letter */
ucp_Lu, /* Upper case letter */
ucp_Mc, /* Spacing mark */
ucp_Me, /* Enclosing mark */
ucp_Mn, /* Non-spacing mark */
ucp_Nd, /* Decimal number */
ucp_Nl, /* Letter number */
ucp_No, /* Other number */
ucp_Pc, /* Connector punctuation */
ucp_Pd, /* Dash punctuation */
ucp_Pe, /* Close punctuation */
ucp_Pf, /* Final punctuation */
ucp_Pi, /* Initial punctuation */
ucp_Po, /* Other punctuation */
ucp_Ps, /* Open punctuation */
ucp_Sc, /* Currency symbol */
ucp_Sk, /* Modifier symbol */
ucp_Sm, /* Mathematical symbol */
ucp_So, /* Other symbol */
ucp_Zl, /* Line separator */
ucp_Zp, /* Paragraph separator */
ucp_Zs /* Space separator */
};
/* For use in PCRE we make this function static so that there is no conflict if
PCRE is linked with an application that makes use of an external version -
assuming an external version is ever released... */
static int ucp_findchar(const int, int *, int *);
/* End of ucp.h */
+91
View File
@@ -0,0 +1,91 @@
/*************************************************
* libucp - Unicode Property Table handler *
*************************************************/
/* Internal header file defining the layout of compact nodes in the tree. */
typedef struct cnode {
unsigned short int f0;
unsigned short int f1;
unsigned short int f2;
} cnode;
/* Things for the f0 field */
#define f0_leftexists 0x8000 /* Left child exists */
#define f0_typemask 0x3f00 /* Type bits */
#define f0_typeshift 8 /* Type shift */
#define f0_chhmask 0x00ff /* Character high bits */
/* Things for the f2 field */
#define f2_rightmask 0xf000 /* Mask for right offset bits */
#define f2_rightshift 12 /* Shift for right offset */
#define f2_casemask 0x0fff /* Mask for case offset */
/* The tree consists of a vector of structures of type cnode, with the root
node as the first element. The three short ints (16-bits) are used as follows:
(f0) (1) The 0x8000 bit of f0 is set if a left child exists. The child's node
is the next node in the vector.
(2) The 0x4000 bits of f0 is spare.
(3) The 0x3f00 bits of f0 contain the character type; this is a number
defined by the enumeration in ucp.h (e.g. ucp_Lu).
(4) The bottom 8 bits of f0 contain the most significant byte of the
character's 24-bit codepoint.
(f1) (1) The f1 field contains the two least significant bytes of the
codepoint.
(f2) (1) The 0xf000 bits of f2 contain zero if there is no right child of this
node. Otherwise, they contain one plus the exponent of the power of
two of the offset to the right node (e.g. a value of 3 means 8). The
units of the offset are node items.
(2) The 0x0fff bits of f2 contain the signed offset from this character to
its alternate cased value. They are zero if there is no such
character.
-----------------------------------------------------------------------------
||.|.| type (6) | ms char (8) || ls char (16) ||....| case offset (12) ||
-----------------------------------------------------------------------------
| | |
| |-> spare |
| exponent of right
|-> left child exists child offset
The upper/lower casing information is set only for characters that come in
pairs. There are (at present) four non-one-to-one mappings in the Unicode data.
These are ignored. They are:
1FBE Greek Prosgegrammeni (lower, with upper -> capital iota)
2126 Ohm
212A Kelvin
212B Angstrom
Certainly for the last three, having an alternate case would seem to be a
mistake. I don't know any Greek, so cannot comment on the first one.
When searching the tree, proceed as follows:
(1) Start at the first node.
(2) Extract the character value from f1 and the bottom 8 bits of f0;
(3) Compare with the character being sought. If equal, we are done.
(4) If the test character is smaller, inspect the f0_leftexists flag. If it is
not set, the character is not in the tree. If it is set, move to the next
node, and go to (2).
(5) If the test character is bigger, extract the f2_rightmask bits from f2, and
shift them right by f2_rightshift. If the result is zero, the character is
not in the tree. Otherwise, calculate the number of nodes to skip by
shifting the value 1 left by this number minus one. Go to (2).
*/
/* End of internal.h */
File diff suppressed because it is too large. Load diff
+93
View File
@@ -0,0 +1,93 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/*
This is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language. See
the file Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains a table for translating Unicode property names into
code values for the ucp_findchar function. It is in a separate module so that
it can be included both in the main pcre library, and into pcretest (for
printing out internals). */
typedef struct {
const char *name;
int value;
} ucp_type_table;
static ucp_type_table utt[] = {
{ "C", 128 + ucp_C },
{ "Cc", ucp_Cc },
{ "Cf", ucp_Cf },
{ "Cn", ucp_Cn },
{ "Co", ucp_Co },
{ "Cs", ucp_Cs },
{ "L", 128 + ucp_L },
{ "Ll", ucp_Ll },
{ "Lm", ucp_Lm },
{ "Lo", ucp_Lo },
{ "Lt", ucp_Lt },
{ "Lu", ucp_Lu },
{ "M", 128 + ucp_M },
{ "Mc", ucp_Mc },
{ "Me", ucp_Me },
{ "Mn", ucp_Mn },
{ "N", 128 + ucp_N },
{ "Nd", ucp_Nd },
{ "Nl", ucp_Nl },
{ "No", ucp_No },
{ "P", 128 + ucp_P },
{ "Pc", ucp_Pc },
{ "Pd", ucp_Pd },
{ "Pe", ucp_Pe },
{ "Pf", ucp_Pf },
{ "Pi", ucp_Pi },
{ "Po", ucp_Po },
{ "Ps", ucp_Ps },
{ "S", 128 + ucp_S },
{ "Sc", ucp_Sc },
{ "Sk", ucp_Sk },
{ "Sm", ucp_Sm },
{ "So", ucp_So },
{ "Z", 128 + ucp_Z },
{ "Zl", ucp_Zl },
{ "Zp", ucp_Zp },
{ "Zs", ucp_Zs }
};
/* End of ucptypetable.c */
+15 -7
View File
@@ -152,13 +152,21 @@ PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *preg_
back the compiled pattern, otherwise go on and compile it. */
regex_len = strlen(regex);
if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {
/*
* We use a quick pcre_info() check to see whether cache is corrupted, and if it
* is, we flush it and compile the pattern from scratch.
*/
if (pcre_info(pce->re, NULL, NULL) == PCRE_ERROR_BADMAGIC) {
zend_hash_clean(&PCRE_G(pcre_cache));
} else {
#if HAVE_SETLOCALE
if (!strcmp(pce->locale, locale)) {
if (!strcmp(pce->locale, locale)) {
#endif
*extra = pce->extra;
*preg_options = pce->preg_options;
return pce->re;
*extra = pce->extra;
*preg_options = pce->preg_options;
return pce->re;
#if HAVE_SETLOCALE
}
}
#endif
}
@@ -742,9 +750,9 @@ static int preg_do_eval(char *eval_str, int eval_str_len, char *subject,
in instead of the backref */
match = subject + offsets[backref<<1];
match_len = offsets[(backref<<1)+1] - offsets[backref<<1];
if (match_len)
esc_match = php_addslashes(match, match_len, &esc_match_len, 0 TSRMLS_CC);
else {
if (match_len) {
esc_match = php_addslashes_ex(match, match_len, &esc_match_len, 0, 1 TSRMLS_CC);
} else {
esc_match = match;
esc_match_len = 0;
}
+12
View File
@@ -0,0 +1,12 @@
--TEST--
Bug #33200 (magic_quotes_sybase = On makes 'e' modifier misbehave)
--INI--
magic_quotes_sybase=1
--FILE--
<?php
$str = 'some \'$sample\' text';
$str = preg_replace("/(some.*text)/e", "strtoupper('\\1')", $str);
echo $str;
?>
--EXPECT--
SOME '$SAMPLE' TEXT
+58 -24
View File
@@ -2,37 +2,56 @@ dnl
dnl $Id$
dnl
AC_DEFUN([PHP_PGSQL_CHECK_FUNCTIONS],[
])
PHP_ARG_WITH(pgsql,for PostgreSQL support,
[ --with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL
base install directory, defaults to /usr/local/pgsql.])
base install directory or the path to pg_config])
if test "$PHP_PGSQL" != "no"; then
PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
if test "$PHP_PGSQL" = "yes"; then
PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
else
PGSQL_SEARCH_PATHS=$PHP_PGSQL
fi
for i in $PGSQL_SEARCH_PATHS; do
for j in include include/pgsql include/postgres include/postgresql ""; do
if test -r "$i/$j/libpq-fe.h"; then
PGSQL_INC_BASE=$i
PGSQL_INCLUDE=$i/$j
if test -r "$i/$j/pg_config.h"; then
AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
fi
fi
done
for j in lib lib/pgsql lib/postgres lib/postgresql ""; do
if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
PGSQL_LIBDIR=$i/$j
fi
done
AC_MSG_CHECKING(for pg_config)
for i in $PHP_PGSQL $PHP_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
if test -x $i/pg_config; then
PG_CONFIG="$i/pg_config"
break;
fi
done
if test -n "$PG_CONFIG"; then
AC_MSG_RESULT([$PG_CONFIG])
PGSQL_INCLUDE=`$PG_CONFIG --includedir`
PGSQL_LIBDIR=`$PG_CONFIG --libdir`
AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
else
AC_MSG_RESULT(not found)
if test "$PHP_PGSQL" = "yes"; then
PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
else
PGSQL_SEARCH_PATHS=$PHP_PGSQL
fi
for i in $PGSQL_SEARCH_PATHS; do
for j in include include/pgsql include/postgres include/postgresql ""; do
if test -r "$i/$j/libpq-fe.h"; then
PGSQL_INC_BASE=$i
PGSQL_INCLUDE=$i/$j
if test -r "$i/$j/pg_config.h"; then
AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
fi
fi
done
for j in $PHP_LIBDIR $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
PGSQL_LIBDIR=$i/$j
fi
done
done
fi
if test -z "$PGSQL_INCLUDE"; then
AC_MSG_ERROR(Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path)
fi
@@ -50,11 +69,26 @@ if test "$PHP_PGSQL" != "no"; then
old_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -L$PGSQL_LIBDIR"
AC_CHECK_LIB(pq, PQescapeString,AC_DEFINE(HAVE_PQESCAPE,1,[PostgreSQL 7.2.0 or later]))
AC_CHECK_LIB(pq, PQunescapeBytea,AC_DEFINE(HAVE_PQUNESCAPEBYTEA,1,[PostgreSQL 7.3.0 or later]))
AC_CHECK_LIB(pq, PQsetnonblocking,AC_DEFINE(HAVE_PQSETNONBLOCKING,1,[PostgreSQL 7.0.x or later]))
AC_CHECK_LIB(pq, PQcmdTuples,AC_DEFINE(HAVE_PQCMDTUPLES,1,[Broken libpq under windows]))
AC_CHECK_LIB(pq, PQoidValue,AC_DEFINE(HAVE_PQOIDVALUE,1,[Older PostgreSQL]))
AC_CHECK_LIB(pq, PQclientEncoding,AC_DEFINE(HAVE_PQCLIENTENCODING,1,[PostgreSQL 7.0.x or later]))
AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibye]))
AC_CHECK_LIB(pq, PQparameterStatus,AC_DEFINE(HAVE_PQPARAMETERSTATUS,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQprotocolVersion,AC_DEFINE(HAVE_PQPROTOCOLVERSION,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQtransactionStatus,AC_DEFINE(HAVE_PGTRANSACTIONSTATUS,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQexecParams,AC_DEFINE(HAVE_PQEXECPARAMS,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQprepare,AC_DEFINE(HAVE_PQPREPARE,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQexecPrepared,AC_DEFINE(HAVE_PQEXECPREPARED,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQresultErrorField,AC_DEFINE(HAVE_PQRESULTERRORFIELD,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQsendQueryParams,AC_DEFINE(HAVE_PQSENDQUERYPARAMS,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQsendPrepare,AC_DEFINE(HAVE_PQSENDPREPARE,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQsendQueryPrepared,AC_DEFINE(HAVE_PQSENDQUERYPREPARED,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQputCopyData,AC_DEFINE(HAVE_PQPUTCOPYDATA,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQputCopyEnd,AC_DEFINE(HAVE_PQPUTCOPYEND,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQgetCopyData,AC_DEFINE(HAVE_PQGETCOPYDATA,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQsetErrorVerbosity,AC_DEFINE(HAVE_PQSETERRORVERBOSITY,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
+19 -4
View File
@@ -100,7 +100,9 @@ function_entry pgsql_functions[] = {
PHP_FE(pg_fetch_array, NULL)
PHP_FE(pg_fetch_object, NULL)
PHP_FE(pg_fetch_all, NULL)
#if HAVE_PQCMDTUPLES
PHP_FE(pg_affected_rows,NULL)
#endif
PHP_FE(pg_get_result, NULL)
PHP_FE(pg_result_seek, NULL)
PHP_FE(pg_result_status,NULL)
@@ -161,7 +163,9 @@ function_entry pgsql_functions[] = {
/* aliases for downwards compatibility */
PHP_FALIAS(pg_exec, pg_query, NULL)
PHP_FALIAS(pg_getlastoid, pg_last_oid, NULL)
#if HAVE_PQCMDTUPLES
PHP_FALIAS(pg_cmdtuples, pg_affected_rows, NULL)
#endif
PHP_FALIAS(pg_errormessage, pg_last_error, NULL)
PHP_FALIAS(pg_numrows, pg_num_rows, NULL)
PHP_FALIAS(pg_numfields, pg_num_fields, NULL)
@@ -1077,6 +1081,7 @@ PHP_FUNCTION(pg_num_fields)
}
/* }}} */
#if HAVE_PQCMDTUPLES
/* {{{ proto int pg_affected_rows(resource result)
Returns the number of affected tuples */
PHP_FUNCTION(pg_affected_rows)
@@ -1084,6 +1089,7 @@ PHP_FUNCTION(pg_affected_rows)
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_CMD_TUPLES);
}
/* }}} */
#endif
/* {{{ proto string pg_last_notice(resource connection)
Returns the last notice set by the backend */
@@ -2601,6 +2607,7 @@ PHP_FUNCTION(pg_copy_from)
zval **tmp;
char *table_name, *pg_delim = NULL, *pg_null_as = NULL;
int table_name_len, pg_delim_len, pg_null_as_len;
int pg_null_as_free = 0;
char *query;
char *query_template = "COPY \"\" FROM STDIN DELIMITERS ':' WITH NULL AS ''";
HashPosition pos;
@@ -2620,6 +2627,7 @@ PHP_FUNCTION(pg_copy_from)
}
if (!pg_null_as) {
pg_null_as = safe_estrdup("\\\\N");
pg_null_as_free = 1;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
@@ -2632,7 +2640,9 @@ PHP_FUNCTION(pg_copy_from)
}
pgsql_result = PQexec(pgsql, query);
efree(pg_null_as);
if (pg_null_as_free) {
efree(pg_null_as);
}
efree(query);
if (pgsql_result) {
@@ -3119,12 +3129,17 @@ PHP_FUNCTION(pg_get_notify)
PGnotify *pgsql_notify;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l",
&pgsql_link) == FAILURE) {
&pgsql_link, &result_type) == FAILURE) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (!(result_type & PGSQL_BOTH)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid result type");
RETURN_FALSE;
}
PQconsumeInput(pgsql);
pgsql_notify = PQnotifies(pgsql);
if (!pgsql_notify) {
@@ -3132,11 +3147,11 @@ PHP_FUNCTION(pg_get_notify)
RETURN_FALSE;
}
array_init(return_value);
if (result_type & (PGSQL_NUM|PGSQL_BOTH)) {
if (result_type & PGSQL_NUM) {
add_index_string(return_value, 0, pgsql_notify->relname, 1);
add_index_long(return_value, 1, pgsql_notify->be_pid);
}
if (result_type & (PGSQL_ASSOC|PGSQL_BOTH)) {
if (result_type & PGSQL_ASSOC) {
add_assoc_string(return_value, "message", pgsql_notify->relname, 1);
add_assoc_long(return_value, "pid", pgsql_notify->be_pid);
}
+2
View File
@@ -83,7 +83,9 @@ PHP_FUNCTION(pg_fetch_object);
PHP_FUNCTION(pg_fetch_result);
PHP_FUNCTION(pg_fetch_row);
PHP_FUNCTION(pg_fetch_all);
#if HAVE_PQCMDTUPLES
PHP_FUNCTION(pg_affected_rows);
#endif
PHP_FUNCTION(pg_get_result);
PHP_FUNCTION(pg_result_seek);
PHP_FUNCTION(pg_result_status);
+1 -1
View File
@@ -9,5 +9,5 @@ if test "$PHP_POSIX" = "yes"; then
AC_DEFINE(HAVE_POSIX, 1, [whether to include POSIX-like functions])
PHP_NEW_EXTENSION(posix, posix.c, $ext_shared)
AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo getrlimit)
AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo getrlimit getlogin getgroups)
fi
+4
View File
@@ -54,8 +54,12 @@ PHP_FUNCTION(posix_seteuid);
#ifdef HAVE_SETEGID
PHP_FUNCTION(posix_setegid);
#endif
#ifdef HAVE_GETGROUPS
PHP_FUNCTION(posix_getgroups);
#endif
#ifdef HAVE_GETLOGIN
PHP_FUNCTION(posix_getlogin);
#endif
/* POSIX.1, 4.3 */
PHP_FUNCTION(posix_getpgrp);
+8
View File
@@ -69,8 +69,12 @@ function_entry posix_functions[] = {
#ifdef HAVE_SETEGID
PHP_FE(posix_setegid, NULL)
#endif
#ifdef HAVE_GETGROUPS
PHP_FE(posix_getgroups, NULL)
#endif
#ifdef HAVE_GETLOGIN
PHP_FE(posix_getlogin, NULL)
#endif
/* POSIX.1, 4.3 */
PHP_FE(posix_getpgrp, NULL)
@@ -363,6 +367,7 @@ PHP_FUNCTION(posix_setegid)
/* {{{ proto array posix_getgroups(void)
Get supplementary group id's (POSIX.1, 4.2.3) */
#ifdef HAVE_GETGROUPS
PHP_FUNCTION(posix_getgroups)
{
gid_t gidlist[NGROUPS_MAX];
@@ -389,10 +394,12 @@ PHP_FUNCTION(posix_getgroups)
add_next_index_long(return_value, gidlist[i]);
}
}
#endif
/* }}} */
/* {{{ proto string posix_getlogin(void)
Get user name (POSIX.1, 4.2.4) */
#ifdef HAVE_GETLOGIN
PHP_FUNCTION(posix_getlogin)
{
char *p;
@@ -408,6 +415,7 @@ PHP_FUNCTION(posix_getlogin)
RETURN_STRING(p, 1);
}
#endif
/* }}} */
/* {{{ proto int posix_getpgrp(void)
+17 -3
View File
@@ -117,6 +117,20 @@ static PHP_INI_MH(OnUpdateSerializer)
return SUCCESS;
}
static PHP_INI_MH(OnUpdateSaveDir) {
/* Only do the safemode/open_basedir check at runtime */
if(stage == PHP_INI_STAGE_RUNTIME) {
if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_ALLOW_ONLY_DIR))) {
return FAILURE;
}
if (php_check_open_basedir(new_value TSRMLS_CC)) {
return FAILURE;
}
}
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
return SUCCESS;
}
/* {{{ PHP_INI
*/
@@ -124,9 +138,9 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("session.bug_compat_42", "1", PHP_INI_ALL, OnUpdateBool, bug_compat, php_ps_globals, ps_globals)
STD_PHP_INI_BOOLEAN("session.bug_compat_warn", "1", PHP_INI_ALL, OnUpdateBool, bug_compat_warn, php_ps_globals, ps_globals)
#ifdef PHP_WIN32
STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateString, save_path, php_ps_globals, ps_globals)
STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateSaveDir,save_path, php_ps_globals, ps_globals)
#else
STD_PHP_INI_ENTRY("session.save_path", "/tmp", PHP_INI_ALL, OnUpdateString, save_path, php_ps_globals, ps_globals)
STD_PHP_INI_ENTRY("session.save_path", "/tmp", PHP_INI_ALL, OnUpdateSaveDir,save_path, php_ps_globals, ps_globals)
#endif
STD_PHP_INI_ENTRY("session.name", "PHPSESSID", PHP_INI_ALL, OnUpdateString, session_name, php_ps_globals, ps_globals)
PHP_INI_ENTRY("session.save_handler", "files", PHP_INI_ALL, OnUpdateSaveHandler)
@@ -1015,7 +1029,7 @@ PHPAPI void php_session_start(TSRMLS_D)
*/
if (!PS(id)) {
if (zend_hash_find(&EG(symbol_table), "_COOKIE",
if (PS(use_cookies) && zend_hash_find(&EG(symbol_table), "_COOKIE",
sizeof("_COOKIE"), (void **) &data) == SUCCESS &&
Z_TYPE_PP(data) == IS_ARRAY &&
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name),
-1
View File
@@ -39,7 +39,6 @@ extern zend_module_entry snmp_module_entry;
#endif
PHP_MINIT_FUNCTION(snmp);
PHP_MSHUTDOWN_FUNCTION(snmp);
PHP_MINFO_FUNCTION(snmp);
PHP_FUNCTION(snmpget);
+4 -13
View File
@@ -156,7 +156,7 @@ zend_module_entry snmp_module_entry = {
"snmp",
snmp_functions,
PHP_MINIT(snmp),
PHP_MSHUTDOWN(snmp),
NULL,
NULL,
NULL,
PHP_MINFO(snmp),
@@ -208,16 +208,6 @@ PHP_MINIT_FUNCTION(snmp)
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(snmp)
{
snmp_shutdown("snmpapp");
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(snmp)
@@ -347,9 +337,9 @@ static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS,
struct snmp_pdu *pdu=NULL, *response;
struct variable_list *vars;
oid name[MAX_NAME_LEN];
int name_length;
size_t name_length;
oid root[MAX_NAME_LEN];
int rootlen = 0;
size_t rootlen = 0;
int gotroot = 0;
int status, count;
char buf[2048];
@@ -442,6 +432,7 @@ retry:
if (st == 1) {
*return_value = *snmpval;
zval_copy_ctor(return_value);
zval_ptr_dtor(&snmpval);
snmp_close(ss);
return;
} else if (st == 2) {
+9
View File
@@ -354,6 +354,10 @@ static char *php_strerror(int error TSRMLS_DC)
buf = hstrerror(error);
#else
{
if (SOCKETS_G(strerror_buf)) {
efree(SOCKETS_G(strerror_buf));
}
spprintf(&(SOCKETS_G(strerror_buf)), 0, "Host lookup error %d", error);
buf = SOCKETS_G(strerror_buf);
}
@@ -368,6 +372,11 @@ static char *php_strerror(int error TSRMLS_DC)
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &tmp, 0, NULL)) {
if (SOCKETS_G(strerror_buf)) {
efree(SOCKETS_G(strerror_buf));
}
SOCKETS_G(strerror_buf) = estrdup(tmp);
LocalFree(tmp);
+23 -6
View File
@@ -66,6 +66,7 @@ php_array_globals array_globals;
#define SORT_REGULAR 0
#define SORT_NUMERIC 1
#define SORT_STRING 2
#define SORT_LOCALE_STRING 5
#define SORT_DESC 3
#define SORT_ASC 4
@@ -103,6 +104,8 @@ PHP_MINIT_FUNCTION(array)
REGISTER_LONG_CONSTANT("SORT_REGULAR", SORT_REGULAR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SORT_NUMERIC", SORT_NUMERIC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SORT_STRING", SORT_STRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SORT_LOCALE_STRING", SORT_LOCALE_STRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CASE_LOWER", CASE_LOWER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CASE_UPPER", CASE_UPPER, CONST_CS | CONST_PERSISTENT);
@@ -132,6 +135,12 @@ static void set_compare_func(int sort_type TSRMLS_DC)
ARRAYG(compare_func) = string_compare_function;
break;
#if HAVE_STRCOLL
case SORT_LOCALE_STRING:
ARRAYG(compare_func) = string_locale_compare_function;
break;
#endif
case SORT_REGULAR:
default:
ARRAYG(compare_func) = compare_function;
@@ -631,7 +640,7 @@ static int array_user_key_compare(const void *a, const void *b TSRMLS_DC)
s = *((Bucket **) b);
if (f->nKeyLength) {
Z_STRVAL(key1) = estrndup(f->arKey, f->nKeyLength);
Z_STRVAL(key1) = estrndup(f->arKey, f->nKeyLength-1);
Z_STRLEN(key1) = f->nKeyLength-1;
Z_TYPE(key1) = IS_STRING;
} else {
@@ -639,7 +648,7 @@ static int array_user_key_compare(const void *a, const void *b TSRMLS_DC)
Z_TYPE(key1) = IS_LONG;
}
if (s->nKeyLength) {
Z_STRVAL(key2) = estrndup(s->arKey, s->nKeyLength);
Z_STRVAL(key2) = estrndup(s->arKey, s->nKeyLength-1);
Z_STRLEN(key2) = s->nKeyLength-1;
Z_TYPE(key2) = IS_STRING;
} else {
@@ -1298,7 +1307,11 @@ PHP_FUNCTION(extract)
*orig_var = *entry;
} else {
(*entry)->is_ref = 1;
if ((*var_array)->refcount > 1) {
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
} else {
(*entry)->is_ref = 1;
}
zval_add_ref(entry);
zend_hash_update(EG(active_symbol_table), final_name.c, final_name.len+1, (void **) entry, sizeof(zval *), NULL);
}
@@ -2483,7 +2496,7 @@ PHP_FUNCTION(array_change_key_case)
zend_hash_index_update(Z_ARRVAL_P(return_value), num_key, entry, sizeof(entry), NULL);
break;
case HASH_KEY_IS_STRING:
new_key=estrndup(string_key,str_key_len);
new_key=estrndup(string_key,str_key_len - 1);
if (change_to_upper)
php_strtoupper(new_key, str_key_len - 1);
else
@@ -3229,8 +3242,11 @@ PHP_FUNCTION(array_reduce)
efree(callback_name);
if (ZEND_NUM_ARGS() > 2) {
convert_to_long_ex(initial);
result = *initial;
ALLOC_ZVAL(result);
*result = **initial;
zval_copy_ctor(result);
convert_to_long(result);
INIT_PZVAL(result);
} else {
MAKE_STD_ZVAL(result);
ZVAL_NULL(result);
@@ -3246,6 +3262,7 @@ PHP_FUNCTION(array_reduce)
if (result) {
*return_value = *result;
zval_copy_ctor(return_value);
zval_ptr_dtor(&result);
}
return;
}
+51 -27
View File
@@ -944,6 +944,13 @@ zend_module_entry basic_functions_module = {
static void php_putenv_destructor(putenv_entry *pe)
{
if (pe->previous_value) {
#if _MSC_VER
/* VS.Net has a bug in putenv() when setting a variable that
* is already set; if the SetEnvironmentVariable() API call
* fails, the Crt will double free() a string.
* We try to avoid this by setting our own value first */
SetEnvironmentVariable(pe->key, "bugbug");
#endif
putenv(pe->previous_value);
} else {
# if HAVE_UNSETENV
@@ -1232,11 +1239,10 @@ PHP_RSHUTDOWN_FUNCTION(basic)
}
STR_FREE(BG(locale_string));
if (FG(stream_wrappers)) {
zend_hash_destroy(FG(stream_wrappers));
efree(FG(stream_wrappers));
FG(stream_wrappers) = NULL;
}
/*
FG(stream_wrappers) are destroyed
during php_request_shutdown()
*/
PHP_RSHUTDOWN(fsock) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(filestat) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
@@ -1430,6 +1436,14 @@ PHP_FUNCTION(putenv)
}
}
#if _MSC_VER
/* VS.Net has a bug in putenv() when setting a variable that
* is already set; if the SetEnvironmentVariable() API call
* fails, the Crt will double free() a string.
* We try to avoid this by setting our own value first */
SetEnvironmentVariable(pe.key, "bugbug");
#endif
if (putenv(pe.putenv_string) == 0) { /* success */
zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len+1, (void **) &pe, sizeof(putenv_entry), NULL);
#ifdef HAVE_TZSET
@@ -2089,17 +2103,21 @@ void user_tick_function_dtor(user_tick_function_entry *tick_function_entry)
static int user_shutdown_function_call(php_shutdown_function_entry *shutdown_function_entry TSRMLS_DC)
{
zval retval;
char *function_name = NULL;
if (call_user_function( EG(function_table), NULL,
shutdown_function_entry->arguments[0],
&retval,
shutdown_function_entry->arg_count - 1,
shutdown_function_entry->arguments + 1
TSRMLS_CC ) == SUCCESS ) {
if (!zend_is_callable(shutdown_function_entry->arguments[0], 0, &function_name)) {
php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", function_name);
} else if (call_user_function(EG(function_table), NULL,
shutdown_function_entry->arguments[0],
&retval,
shutdown_function_entry->arg_count - 1,
shutdown_function_entry->arguments + 1
TSRMLS_CC ) == SUCCESS)
{
zval_dtor(&retval);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s() - function does not exist", Z_STRVAL_P(shutdown_function_entry->arguments[0]));
}
if (function_name) {
efree(function_name);
}
return 0;
}
@@ -2192,6 +2210,7 @@ void php_free_shutdown_functions(TSRMLS_D)
PHP_FUNCTION(register_shutdown_function)
{
php_shutdown_function_entry shutdown_function_entry;
char *function_name = NULL;
int i;
shutdown_function_entry.arg_count = ZEND_NUM_ARGS();
@@ -2200,26 +2219,31 @@ PHP_FUNCTION(register_shutdown_function)
WRONG_PARAM_COUNT;
}
shutdown_function_entry.arguments = (pval **) safe_emalloc(sizeof(pval *), shutdown_function_entry.arg_count, 0);
shutdown_function_entry.arguments = (zval **) safe_emalloc(sizeof(zval *), shutdown_function_entry.arg_count, 0);
if (zend_get_parameters_array(ht, shutdown_function_entry.arg_count, shutdown_function_entry.arguments) == FAILURE) {
RETURN_FALSE;
}
/* Prevent entering of anything but arrays/strings */
if (Z_TYPE_P(shutdown_function_entry.arguments[0]) != IS_ARRAY) {
convert_to_string(shutdown_function_entry.arguments[0]);
}
if (!BG(user_shutdown_function_names)) {
ALLOC_HASHTABLE(BG(user_shutdown_function_names));
zend_hash_init(BG(user_shutdown_function_names), 0, NULL, (void (*)(void *)) user_shutdown_function_dtor, 0);
}
/* Prevent entering of anything but valid callback (syntax check only!) */
if (!zend_is_callable(shutdown_function_entry.arguments[0], 1, &function_name)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid shutdown callback '%s' passed", function_name);
efree(shutdown_function_entry.arguments);
RETVAL_FALSE;
} else {
if (!BG(user_shutdown_function_names)) {
ALLOC_HASHTABLE(BG(user_shutdown_function_names));
zend_hash_init(BG(user_shutdown_function_names), 0, NULL, (void (*)(void *)) user_shutdown_function_dtor, 0);
}
for (i = 0; i < shutdown_function_entry.arg_count; i++) {
shutdown_function_entry.arguments[i]->refcount++;
for (i = 0; i < shutdown_function_entry.arg_count; i++) {
shutdown_function_entry.arguments[i]->refcount++;
}
zend_hash_next_index_insert(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL);
}
if (function_name) {
efree(function_name);
}
zend_hash_next_index_insert(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL);
}
/* }}} */
+2 -2
View File
@@ -50,9 +50,9 @@ CREDIT_LINE("mhash", "Sascha Schumann");
CREDIT_LINE("mime_magic", "Hartmut Holzgraefe");
CREDIT_LINE("MING", "Dave Hayden, Frank M. Kromann");
CREDIT_LINE("mnoGoSearch", "Sergey Kartashoff, Alex Barkov, Ramil Kalimullin");
CREDIT_LINE("MS SQL", "Frank M. Kromann");
CREDIT_LINE("msession", "Mark L. Woodward");
CREDIT_LINE("mSQL", "Zeev Suraski");
CREDIT_LINE("MS SQL", "Frank M. Kromann");
CREDIT_LINE("Multibyte String Functions", "Tsukada Takuya, Rui Hirokawa");
CREDIT_LINE("MySQL", "Zeev Suraski, Zak Greant, Georg Richter");
CREDIT_LINE("ncurses", "Ilia Alshanetsky, Wez Furlong, Hartmut Holzgraefe, Georg Richter");
@@ -86,8 +86,8 @@ CREDIT_LINE("Verisign Payflow Pro", "John Donagher, David Croft");
CREDIT_LINE("W32API", "James Moore");
CREDIT_LINE("WDDX", "Andrei Zmievski");
CREDIT_LINE("Win32 COM", "Alan Brown, Wez Furlong, Harald Radi, Zeev Suraski");
CREDIT_LINE("xmlrpc", "Dan Libby");
CREDIT_LINE("XML", "Stig Bakken, Thies C. Arntzen");
CREDIT_LINE("xmlrpc", "Dan Libby");
CREDIT_LINE("YAZ", "Adam Dickmeiss");
CREDIT_LINE("Yellow Pages", "Stephanie Wehner, Fredrik Ohrn");
CREDIT_LINE("Zip", "Sterling Hughes");
+1 -1
View File
@@ -781,7 +781,7 @@ char *php_std_date(time_t t TSRMLS_DC)
tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
} else {
snprintf(str, 80, "%s, %02d-%s-%02d %02d:%02d:%02d GMT",
day_short_names[tm1->tm_wday],
day_full_names[tm1->tm_wday],
tm1->tm_mday,
mon_short_names[tm1->tm_mon],
((tm1->tm_year) % 100),
-4
View File
@@ -390,12 +390,8 @@ PHP_FUNCTION(glob)
* doesn't. This ensure that if no match is found, an empty array
* is always returned so it can be used without worrying in e.g.
* foreach() */
#ifndef __linux__
RETURN_FALSE;
#else
array_init(return_value);
return;
#endif
}
#endif
RETURN_FALSE;
+21 -3
View File
@@ -142,7 +142,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
unsigned short portno;
char *scratch;
int result;
int i, use_ssl;
int i, use_ssl, tmp_len;
#ifdef HAVE_OPENSSL_EXT
int use_ssl_on_data=0;
php_stream *reuseid=NULL;
@@ -243,10 +243,25 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
#endif
#define PHP_FTP_CNTRL_CHK(val, val_len, err_msg) { \
unsigned char *s = val, *e = s + val_len; \
while (s < e) { \
if (iscntrl(*s)) { \
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, err_msg, val); \
goto errexit; \
} \
s++; \
} \
}
/* send the user name */
php_stream_write_string(stream, "USER ");
if (resource->user != NULL) {
php_raw_url_decode(resource->user, strlen(resource->user));
unsigned char *s, *e;
tmp_len = php_raw_url_decode(resource->user, strlen(resource->user));
PHP_FTP_CNTRL_CHK(resource->user, tmp_len, "Invalid login %s")
php_stream_write_string(stream, resource->user);
} else {
php_stream_write_string(stream, "anonymous");
@@ -262,7 +277,10 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
php_stream_write_string(stream, "PASS ");
if (resource->pass != NULL) {
php_raw_url_decode(resource->pass, strlen(resource->pass));
tmp_len = php_raw_url_decode(resource->pass, strlen(resource->pass));
PHP_FTP_CNTRL_CHK(resource->pass, tmp_len, "Invalid password %s")
php_stream_write_string(stream, resource->pass);
} else {
/* if the user has configured who they are,
+33 -1
View File
@@ -107,6 +107,8 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
size_t chunk_size = 0, file_size = 0;
int eol_detect, have_header = 0;
tmp_line[0] = '\0';
if (redirect_max < 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Circular redirect, aborting.");
return NULL;
@@ -494,6 +496,34 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
} else {
strlcpy(new_path, location, sizeof(new_path));
}
php_url_free(resource);
/* check for invalid redirection URLs */
if ((resource = php_url_parse(new_path)) == NULL) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect url! %s", new_path);
goto out;
}
#define CHECK_FOR_CNTRL_CHARS(val) { \
if (val) { \
unsigned char *s, *e; \
int l; \
l = php_url_decode(val, strlen(val)); \
s = val; e = s + l; \
while (s < e) { \
if (iscntrl(*s)) { \
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect url! %s", new_path); \
goto out; \
} \
s++; \
} \
} \
} \
/* check for control characters in login, password & path */
CHECK_FOR_CNTRL_CHARS(resource->user)
CHECK_FOR_CNTRL_CHARS(resource->pass)
CHECK_FOR_CNTRL_CHARS(resource->path)
stream = php_stream_url_wrap_http_ex(NULL, new_path, mode, options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC);
if (stream && stream->wrapperdata) {
entryp = &entry;
@@ -518,7 +548,9 @@ out:
efree(http_header_line);
if (scratch)
efree(scratch);
php_url_free(resource);
if (resource) {
php_url_free(resource);
}
if (stream) {
if (header_init) {
+1 -1
View File
@@ -401,7 +401,7 @@ static unsigned int php_next_marker(php_stream * stream, int last_marker, int co
last_marker = M_PSEUDO; /* stop skipping non 0xff for M_COM */
}
}
if (++a > 10)
if (++a > 25)
{
/* who knows the maxim amount of 0xff? though 7 */
/* but found other implementations */
+15 -3
View File
@@ -408,7 +408,9 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
if (expose_php && !sapi_module.phpinfo_as_text) {
PUTS("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
if (SG(request_info).request_uri) {
PUTS(SG(request_info).request_uri);
char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
PUTS(elem_esc);
efree(elem_esc);
}
if ((ta->tm_mon==3) && (ta->tm_mday==1)) {
PUTS("?="PHP_EGG_LOGO_GUID"\" alt=\"Nadia!\" /></a>");
@@ -463,6 +465,12 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
php_info_print_table_row(2, "Debug Build", "no" );
#endif
#if USE_ZEND_ALLOC
php_info_print_table_row(2, "Zend Memory Manager", "enabled" );
#else
php_info_print_table_row(2, "Zend Memory Manager", "disabled" );
#endif
#ifdef ZTS
php_info_print_table_row(2, "Thread Safety", "enabled" );
#else
@@ -510,7 +518,9 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
if (expose_php && !sapi_module.phpinfo_as_text) {
PUTS("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
if (SG(request_info).request_uri) {
PUTS(SG(request_info).request_uri);
char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
PUTS(elem_esc);
efree(elem_esc);
}
PUTS("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
}
@@ -525,7 +535,9 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
php_info_print_hr();
PUTS("<h1><a href=\"");
if (SG(request_info).request_uri) {
PUTS(SG(request_info).request_uri);
char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
PUTS(elem_esc);
efree(elem_esc);
}
PUTS("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
PUTS("PHP Credits");
+7 -18
View File
@@ -23,9 +23,7 @@
* md5_file() added by Alessandro Astarita <aleast@capri.it>
*/
#include <stdio.h>
#include "php.h"
#include "md5.h"
PHPAPI void make_digest(char *md5str, unsigned char *digest)
@@ -73,7 +71,7 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
unsigned char digest[16];
PHP_MD5_CTX context;
int n;
FILE *fp;
php_stream *stream;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -81,34 +79,25 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
convert_to_string_ex(arg);
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(arg), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_PP(arg) TSRMLS_CC)) {
RETURN_FALSE;
}
if ((fp = VCWD_FOPEN(Z_STRVAL_PP(arg), "rb")) == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open file");
stream = php_stream_open_wrapper(Z_STRVAL_PP(arg), "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL);
if (!stream) {
RETURN_FALSE;
}
PHP_MD5Init(&context);
while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) {
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
PHP_MD5Update(&context, buf, n);
}
PHP_MD5Final(digest, &context);
if (ferror(fp)) {
fclose(fp);
php_stream_close(stream);
if (n<0) {
RETURN_FALSE;
}
fclose(fp);
make_digest(md5str, digest);
RETVAL_STRING(md5str, 1);
+1 -1
View File
@@ -546,7 +546,7 @@ static TABLE const OtherTable[] = {
{ "now", tDAY_UNIT, 0 },
{ "last", tUNUMBER, -1 },
{ "this", tUNUMBER, 0 },
{ "next", tUNUMBER, 2 },
{ "next", tUNUMBER, 1 },
{ "first", tUNUMBER, 1 },
/* { "second", tUNUMBER, 2 }, */
{ "third", tUNUMBER, 3 },
+1
View File
@@ -116,6 +116,7 @@ PHPAPI char *php_strtoupper(char *s, size_t len);
PHPAPI char *php_strtolower(char *s, size_t len);
PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trlen);
PHPAPI char *php_addslashes(char *str, int length, int *new_length, int freeit TSRMLS_DC);
PHPAPI char *php_addslashes_ex(char *str, int length, int *new_length, int freeit, int ignore_sybase TSRMLS_DC);
PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int freeit, char *what, int wlength TSRMLS_DC);
PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC);
PHPAPI void php_stripcslashes(char *str, int *len);
+29 -12
View File
@@ -33,6 +33,8 @@ typedef struct {
int cflags;
} reg_cache;
static int reg_magic = 0;
/* {{{ _php_regcomp
*/
static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
@@ -42,19 +44,34 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
reg_cache *rc = NULL;
TSRMLS_FETCH();
if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == FAILURE ||
rc->cflags != cflags) {
r = regcomp(preg, pattern, cflags);
if(!r) {
reg_cache rcp;
rcp.cflags = cflags;
memcpy(&rcp.preg, preg, sizeof(*preg));
zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
(void *) &rcp, sizeof(rcp), NULL);
if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
&& rc->cflags == cflags) {
/*
* We use a saved magic number to see whether cache is corrupted, and if it
* is, we flush it and compile the pattern from scratch.
*/
if (rc->preg.re_magic != reg_magic) {
zend_hash_clean(&REG(ht_rc));
} else {
memcpy(preg, &rc->preg, sizeof(*preg));
return r;
}
} else {
memcpy(preg, &rc->preg, sizeof(*preg));
}
r = regcomp(preg, pattern, cflags);
if(!r) {
reg_cache rcp;
rcp.cflags = cflags;
memcpy(&rcp.preg, preg, sizeof(*preg));
/*
* Since we don't have access to the actual MAGIC1 definition in the private
* header file, we save the magic value immediately after compilation. Hopefully,
* it's good.
*/
if (!reg_magic) reg_magic = preg->re_magic;
zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
(void *) &rcp, sizeof(rcp), NULL);
}
return r;
+7 -17
View File
@@ -18,7 +18,6 @@
/* $Id$ */
#include <stdio.h>
#include "php.h"
/* This code is heavily based on the PHP md5 implementation */
@@ -71,7 +70,7 @@ PHP_FUNCTION(sha1_file)
unsigned char digest[20];
PHP_SHA1_CTX context;
int n;
FILE *fp;
php_stream *stream;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -79,34 +78,25 @@ PHP_FUNCTION(sha1_file)
convert_to_string_ex(arg);
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(arg), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_PP(arg) TSRMLS_CC)) {
RETURN_FALSE;
}
if ((fp = VCWD_FOPEN(Z_STRVAL_PP(arg), "rb")) == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open file");
stream = php_stream_open_wrapper(Z_STRVAL_PP(arg), "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL);
if (!stream) {
RETURN_FALSE;
}
PHP_SHA1Init(&context);
while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) {
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
PHP_SHA1Update(&context, buf, n);
}
PHP_SHA1Final(digest, &context);
if (ferror(fp)) {
fclose(fp);
php_stream_close(stream);
if (n<0) {
RETURN_FALSE;
}
fclose(fp);
make_sha1_digest(sha1str, digest);
RETVAL_STRING(sha1str, 1);
+19 -9
View File
@@ -1317,8 +1317,6 @@ PHP_FUNCTION(stristr)
if (!Z_STRLEN_PP(needle)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
efree(haystack_orig);
zval_ptr_dtor(haystack);
zval_ptr_dtor(needle);
RETURN_FALSE;
}
@@ -1339,8 +1337,6 @@ PHP_FUNCTION(stristr)
RETVAL_FALSE;
}
zval_ptr_dtor(haystack);
zval_ptr_dtor(needle);
efree(haystack_orig);
}
/* }}} */
@@ -1576,7 +1572,13 @@ PHP_FUNCTION(chunk_split)
}
if (chunklen > Z_STRLEN_PP(p_str)) {
RETURN_STRINGL(Z_STRVAL_PP(p_str), Z_STRLEN_PP(p_str), 1);
/* to maintain BC, we must return original string + ending */
result_len = endlen + Z_STRLEN_PP(p_str);
result = emalloc(result_len + 1);
memcpy(result, Z_STRVAL_PP(p_str), Z_STRLEN_PP(p_str));
memcpy(result + Z_STRLEN_PP(p_str), end, endlen);
result[result_len] = '\0';
RETURN_STRINGL(result, result_len, 0);
}
if (!Z_STRLEN_PP(p_str)) {
@@ -2407,18 +2409,26 @@ PHPAPI char *php_addcslashes(char *str, int length, int *new_length, int should_
}
/* }}} */
/* true static */
const unsigned char php_esc_list[256] = {2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
/* {{{ php_addslashes
*/
PHPAPI char *php_addslashes(char *str, int length, int *new_length, int should_free TSRMLS_DC)
{
return php_addslashes_ex(str, length, new_length, should_free, 0 TSRMLS_CC);
}
/* }}} */
/* true static */
const unsigned char php_esc_list[256] = {2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
/* {{{ php_addslashes_ex
*/
PHPAPI char *php_addslashes_ex(char *str, int length, int *new_length, int should_free, int ignore_sybase TSRMLS_DC)
{
char *e = str + (length ? length : (length = strlen(str)));
char *p = str;
char *new_str, *ps;
int local_new_length = length;
int type = PG(magic_quotes_sybase) ? 1 : 0;
int type = (!ignore_sybase && PG(magic_quotes_sybase)) ? 1 : 0;
if (!new_length) {
new_length = &local_new_length;
+35
View File
@@ -0,0 +1,35 @@
--TEST--
bug #30833 (array_count_values() modifying input array)
--FILE--
<?php
$foo = array('abc', '0000');
var_dump($foo);
$count = array_count_values( $foo );
var_dump($count);
var_dump($foo);
echo "Done\n";
?>
--EXPECT--
array(2) {
[0]=>
string(3) "abc"
[1]=>
string(4) "0000"
}
array(2) {
["abc"]=>
int(1)
["0000"]=>
int(1)
}
array(2) {
[0]=>
string(3) "abc"
[1]=>
string(4) "0000"
}
Done
+2
View File
@@ -28,6 +28,8 @@ function test($use_extract) {
test(false);
test(true);
?>
--EXPECT--
int(1)
int(1)
Loaded 100 of 154 files, more files were not shown because too many files have changed in this diff. Show more