mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-5.6' of git.php.net:php-src into PHP-5.6
Conflicts: ext/mysqli/tests/mysqli_begin_transaction.phpt
This commit is contained in:
commit
090c3e87c0
140 changed files with 4204 additions and 2027 deletions
69
NEWS
69
NEWS
|
@ -1,14 +1,25 @@
|
|||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 2014, PHP 5.6.0 Beta 1
|
||||
?? ??? 2014, PHP 5.6.0 Beta 2
|
||||
|
||||
10 Apr 2014, PHP 5.6.0 Beta 1
|
||||
|
||||
- Core:
|
||||
. Allow zero length comparison in substr_compare() (Tjerk)
|
||||
. Fixed bug #60602 (proc_open() changes environment array) (Tjerk)
|
||||
. Fixed bug #61019 (Out of memory on command stream_get_contents). (Mike)
|
||||
. Fixed bug #64330 (stream_socket_server() creates wrong Abstract Namespace
|
||||
UNIX sockets). (Mike)
|
||||
. Fixed bug #66182 (exit in stream filter produces segfault). (Mike)
|
||||
. Fixed bug #66736 (fpassthru broken). (Mike)
|
||||
. Fixed bug #66822 (Cannot use T_POW in const expression) (Tjerk)
|
||||
. Fixed bug #67043 (substr_compare broke by previous change) (Tjerk)
|
||||
|
||||
- SPL:
|
||||
. Added feature #65545 (SplFileObject::fread()) (Tjerk)
|
||||
. Fixed bug #66834 (empty() does not work on classes that extend ArrayObject) (Tjerk)
|
||||
. Fixed bug #66702 (RegexIterator::INVERT_MATCH does not invert). (Joshua
|
||||
Thijssen)
|
||||
|
||||
- cURL:
|
||||
. Fixed bug #66109 (Can't reset CURLOPT_CUSTOMREQUEST to default behaviour)
|
||||
|
@ -20,20 +31,47 @@ PHP NEWS
|
|||
. Added DateTimeImmutable::createFromMutable to create a DateTimeImmutable
|
||||
object from an existing DateTime (mutable) object (Derick)
|
||||
|
||||
- Embed:
|
||||
. Fixed bug #65715 (php5embed.lib isn't provided anymore). (Anatol).
|
||||
|
||||
- Fileinfo:
|
||||
. Fixed bug #66820 (out-of-bounds memory access in fileinfo)
|
||||
(CVE-2014-2270). (Remi)
|
||||
. Fixed bug #66946i (fileinfo: extensive backtracking in awk rule regular
|
||||
expression). (CVE-2013-7345) (Remi)
|
||||
. Fixed bug #66987 (Memory corruption in fileinfo ext / bigendian).
|
||||
(Remi)
|
||||
|
||||
|
||||
- GD:
|
||||
. Fixed bug #66815 (imagecrop(): insufficient fix for NULL defer
|
||||
CVE-2013-7327). (Tomas Hoger, Remi).
|
||||
. Fixed #66869 (Invalid 2nd argument crashes imageaffinematrixget) (Pierre)
|
||||
. Fixed bug #66887 (imagescale - poor quality of scaled image). (Remi)
|
||||
. Fixed bug #66890 (imagescale segfault). (Remi)
|
||||
. Fixed bug #66893 (imagescale ignore method argument). (Remi)
|
||||
|
||||
- GMP:
|
||||
. Fixed bug #66872 (invalid argument crashes gmp_testbit) (Pierre)
|
||||
|
||||
- Hash:
|
||||
. Fixed bug #66698 (Missing FNV1a32 and FNV1a64 hash functions).
|
||||
(Michael M Slusarz).
|
||||
. Implemented timing attack safe string comparison function
|
||||
(RFC: https://wiki.php.net/rfc/timing_attack). (Rouven Weßling)
|
||||
. hash_pbkdf2() now works correctly if the $length argument is not specified.
|
||||
(Nikita)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #66873 (A reproductible crash in UConverter when given invalid
|
||||
encoding) (Stas)
|
||||
|
||||
- Mail:
|
||||
. Fixed bug #66535 (Don't add newline after X-PHP-Originating-Script) (Tjerk)
|
||||
|
||||
- Mbstring:
|
||||
. Upgraded to oniguruma 5.9.5 (Anatol)
|
||||
|
||||
- Mcrypt:
|
||||
. No longer allow invalid key sizes, invalid IV sizes or missing required IV
|
||||
in mcrypt_encrypt, mcrypt_decrypt and the deprecated mode functions.
|
||||
|
@ -55,6 +93,13 @@ PHP NEWS
|
|||
peer verification fails. (Daniel Lowrey)
|
||||
. Encrypted TLS servers now support the server name indication TLS extension
|
||||
via the new "SNI_server_certs" SSL context option. (Daniel Lowrey)
|
||||
. Fixed bug #66833 (Default disgest algo is still MD5, switch to SHA1). (Remi)
|
||||
|
||||
- PCRE:
|
||||
. Added support for (*MARK) backtracking verbs. (Nikita)
|
||||
|
||||
- PDO_firebird:
|
||||
. Fixed Bug #66071 (memory corruption in error handling) (Popa)
|
||||
|
||||
- PDO_pgsql:
|
||||
. Cleaned up code by increasing the requirements to libpq versions providing
|
||||
|
@ -67,9 +112,31 @@ PHP NEWS
|
|||
without preparing them, while still passing parameters separately from
|
||||
the command text using PQexecParams. (Matteo)
|
||||
|
||||
- Pgsql:
|
||||
. Read-only access to the socket stream underlying database connections is
|
||||
exposed via a new pg_socket() function to allow read/write polling when
|
||||
establishing asynchronous connections and executing queries in non-blocking
|
||||
applications. (Daniel Lowrey)
|
||||
. Asynchronous connections are now possible using the PGSQL_CONNECT_ASYNC
|
||||
flag in conjunction with a new pg_connect_poll() function and connection
|
||||
polling status constants. (Daniel Lowrey)
|
||||
. New pg_flush() and pg_consume_input() functions added to manually complete
|
||||
non-blocking reads/writes to underlying connection sockets. (Daniel Lowrey)
|
||||
|
||||
- Session
|
||||
. Remove session_gc() and session_serializer_name() wich were introduced in the first 5.6.0 alpha.
|
||||
|
||||
- SimpleXML:
|
||||
. Fixed bug #66084 (simplexml_load_string() mangles empty node name)
|
||||
(Anatol)
|
||||
|
||||
- SQLite:
|
||||
. Updated the bundled libsqlite to the version 3.8.3.1 (Anatol)
|
||||
|
||||
- XSL:
|
||||
. Fixed bug #53965 (<xsl:include> cannot find files with relative paths
|
||||
when loaded with "file://"). (Anatol)
|
||||
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
27 Feb 2014, PHP 5.6.0 Alpha 3
|
||||
|
||||
|
|
141
UPGRADING
141
UPGRADING
|
@ -71,6 +71,9 @@ PHP 5.6 UPGRADE NOTES
|
|||
- Added use function and use const.
|
||||
(https://wiki.php.net/rfc/use_function)
|
||||
|
||||
- Added a function for timing attack safe string comparison
|
||||
(https://wiki.php.net/rfc/timing_attack)
|
||||
|
||||
- Added gost-crypto (CryptoPro S-box) hash algorithm.
|
||||
|
||||
- Stream wrappers verify peer certificates and host names by default in
|
||||
|
@ -127,6 +130,12 @@ PHP 5.6 UPGRADE NOTES
|
|||
- Stream crypto method specification now accepts flags instead of values
|
||||
allowing support for multiple discrete protocols in a given stream.
|
||||
|
||||
- PostgreSQL database connections may now be established asynchronously using
|
||||
new constants and polling functions in ext/pgsql.
|
||||
|
||||
- Non-blocking read/write query behavior now optionally available in database
|
||||
operations using the ext/pgsql extension.
|
||||
|
||||
========================================
|
||||
2. Changes in SAPI modules
|
||||
========================================
|
||||
|
@ -145,16 +154,27 @@ PHP 5.6 UPGRADE NOTES
|
|||
Instance calls from an incompatible context are now deprecated and issue
|
||||
E_DEPRECATED instead of E_STRICT. See https://wiki.php.net/rfc/incompat_ctx
|
||||
|
||||
- The "CN_match" SSL context option is deprecated in favor of the new
|
||||
"peer_name" option. Name verification now checks certificate SAN names as
|
||||
well as the CN field and "CN_match" is deprecated to avoid confusion. Its
|
||||
use triggers E_DEPRECATED but continues to work as before. If both values
|
||||
are specified "CN_match" takes precedence. Otherwise, the two options are
|
||||
interchangeable.
|
||||
- The "CN_match" and "SNI_server_name" SSL context options are deprecated in
|
||||
favor of the new "peer_name" option. Name verification now checks certificate
|
||||
SAN names as well as the CN field and the specific name fields are deprecated
|
||||
to avoid confusion. Their use triggers E_DEPRECATED but continues to work as
|
||||
before. If specified, the specific values take precedence over the general
|
||||
"peer_name" value.
|
||||
|
||||
- Deprecated PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, an
|
||||
undocument constant effectively equivalent to PDO::ATTR_EMULATE_PREPARES.
|
||||
|
||||
- Deprecated INIs: Following INIs are deprecated in favour of new
|
||||
internal_encoding/input_encoding/output_encoding. Refer to "Changes to
|
||||
encodings in PHP 5.6" in "11. Other Changes" section for more details.
|
||||
|
||||
iconv.input_encoding
|
||||
iconv.output_encoding
|
||||
iconv.internal_encoding
|
||||
mbstring.http_input
|
||||
mbstring.http_output
|
||||
mbstring.internal_encoding
|
||||
|
||||
========================================
|
||||
4. Changed Functions
|
||||
========================================
|
||||
|
@ -163,6 +183,18 @@ PHP 5.6 UPGRADE NOTES
|
|||
CURLOPT_SAFE_UPLOAD is now turned on by default and uploads with @file
|
||||
do not work unless it is explicitly set to false.
|
||||
|
||||
curl_setopt() now supports the following nullable settings (>= 5.5.11):
|
||||
. CURLOPT_CUSTOMREQUEST
|
||||
. CURLOPT_FTPPORT
|
||||
. CURLOPT_RANGE
|
||||
. CURLOPT_FTP_ACCOUNT
|
||||
. CURLOPT_RTSP_SESSION_ID
|
||||
. CURLOPT_KRBLEVEL
|
||||
. CURLOPT_KRB4LEVEL
|
||||
|
||||
- Strings:
|
||||
substr_compare() now allows $length to be zero.
|
||||
|
||||
- Crypt:
|
||||
crypt() will now raise an E_NOTICE error if the salt parameter is omitted.
|
||||
See: https://wiki.php.net/rfc/crypt_function_salt
|
||||
|
@ -177,6 +209,12 @@ PHP 5.6 UPGRADE NOTES
|
|||
|
||||
- Pgsql:
|
||||
pg_insert()/pg_select()/pg_update()/pg_delete() are no longer EXPERIMENTAL.
|
||||
The following functions no longer block until query write completion if the
|
||||
socket stream underlying a database connection is set to non-blocking mode:
|
||||
. pg_send_execute()
|
||||
. pg_send_prepare()
|
||||
. pg_send_query()
|
||||
. pg_send_query_params()
|
||||
|
||||
========================================
|
||||
5. New Functions
|
||||
|
@ -185,6 +223,9 @@ PHP 5.6 UPGRADE NOTES
|
|||
- GMP:
|
||||
Added gmp_root($a, $nth) and gmp_rootrem($a, $nth) for calculating nth roots.
|
||||
|
||||
- Hash
|
||||
Added hash_equals($known_string, $user_string)
|
||||
|
||||
- OpenSSL:
|
||||
Added string openssl_x509_fingerprint($x509, $type, $binary).
|
||||
Added string openssl_spki_new($private_key, $challenge, $algorithm)
|
||||
|
@ -198,6 +239,12 @@ PHP 5.6 UPGRADE NOTES
|
|||
Added ldap_modify_batch($link_identifier, $dn, $modifications) described in
|
||||
https://wiki.php.net/rfc/ldap_modify_batch.
|
||||
|
||||
- Pgsql:
|
||||
Added pg_socket($connection) to allow async connections and non-blocking IO
|
||||
Added pg_connect_poll($connection) for establishing async connections
|
||||
Added pg_consume_input($connection) for non-blocking query result consumption
|
||||
Added pg_flush($connection) for non-blocking query write completion
|
||||
|
||||
- PDO_pgsql
|
||||
Added PDO::pgsqlGetNotify($result_type = PDO::FETCH_USE_DEFAULT, $ms_timeout = 0)
|
||||
Added PDO::pgsqlGetPid()
|
||||
|
@ -205,6 +252,9 @@ PHP 5.6 UPGRADE NOTES
|
|||
- Zip:
|
||||
Added ZipArchive::setPassword($password)
|
||||
|
||||
- SPL
|
||||
Added SplFileObject::fread($length) to complement fwrite() method (>= 5.5.11)
|
||||
|
||||
========================================
|
||||
6. New Classes and Interfaces
|
||||
========================================
|
||||
|
@ -246,6 +296,15 @@ PHP 5.6 UPGRADE NOTES
|
|||
- The oci_internal_debug() function is now a no-op.
|
||||
- The phpinfo() output format for OCI8 has changed.
|
||||
|
||||
- OpenSSL:
|
||||
- The "SNI_enabled" SSL stream context option is now set to TRUE by default
|
||||
if supported by the underlying openssl library.
|
||||
|
||||
- PCRE:
|
||||
- The information collected by the (*MARK) backtracking control verb is now
|
||||
collected into the "MARK" index of the $matches array for preg_match(),
|
||||
preg_match_all() and preg_replace_callback().
|
||||
|
||||
- Pgsql:
|
||||
- pg_insert()/pg_select()/pg_update()/pg_delete()/pg_meta_data()/pg_convert()
|
||||
are no longer EXPERIMENTAL
|
||||
|
@ -256,6 +315,12 @@ PHP 5.6 UPGRADE NOTES
|
|||
- pg_select() returns PostgreSQL query resource when query is executed.
|
||||
- Added extended flag parameter for pg_meta_data(). pg_meta_data() always
|
||||
returns "is enum" attribute.
|
||||
- The new pg_socket() function returns a socket stream with no behavior other
|
||||
than to allow IO-readiness polling on a DB connection socket. Calling
|
||||
stream_set_blocking() on its result enables non-blocking behavior.
|
||||
- Passing the new PGSQL_CONNECT_ASYNC flag to pg_connect() allows applications
|
||||
to poll for IO readiness via pg_connect_poll() and establish connections
|
||||
asynchronously.
|
||||
|
||||
- PDO_pgsql:
|
||||
- Added PDO::PGSQL_ATTR_DISABLE_PREPARES constant to execute the queries
|
||||
|
@ -274,6 +339,18 @@ PHP 5.6 UPGRADE NOTES
|
|||
|
||||
- Pgsql:
|
||||
PGSQL_DML_ESCAPE int(4096)
|
||||
PGSQL_CONNECT_ASYNC
|
||||
PGSQL_CONNECTION_STARTED
|
||||
PGSQL_CONNECTION_MADE
|
||||
PGSQL_CONNECTION_AWAITING_RESPONSE
|
||||
PGSQL_CONNECTION_AUTH_OK
|
||||
PGSQL_CONNECTION_SSL_STARTUP
|
||||
PGSQL_CONNECTION_SETENV
|
||||
PGSQL_POLLING_FAILED
|
||||
PGSQL_POLLING_READING
|
||||
PGSQL_POLLING_WRITING
|
||||
PGSQL_POLLING_OK
|
||||
PGSQL_POLLING_ACTIVE
|
||||
|
||||
- OpenSSL:
|
||||
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT int(9)
|
||||
|
@ -295,6 +372,18 @@ PHP 5.6 UPGRADE NOTES
|
|||
enabled and to recognize the value -1 for never populating the global
|
||||
$HTTP_RAW_POST_DATA variable, which will be default in future PHP versions.
|
||||
|
||||
default_charset is set to UTF-8. It was empty previously. default_charset
|
||||
is used where it is applicable. Iconv/Mbstring/htmlentities/htmlspecialchars/
|
||||
html_entity_decode use default_charset as default encoding.
|
||||
|
||||
internal_encoding/input_encoding/output_encoding is added for encoding
|
||||
handling modules. Refer to "Changes to encodings in PHP 5.6" in "11. Other Changes"
|
||||
section for more details.
|
||||
|
||||
- cURL:
|
||||
If the new openssl.cafile ini directive is specified ext/curl will give the
|
||||
openssl path precedence over its own curl.cainfo directive.
|
||||
|
||||
- OpenSSL:
|
||||
openssl.cafile and openssl.capath ini directives have been added to allow
|
||||
global CA default specification as necessary.
|
||||
|
@ -318,3 +407,43 @@ PHP 5.6 UPGRADE NOTES
|
|||
- Zip:
|
||||
New --with-libzip option allow to use system libzip. Version > 0.11 required,
|
||||
Version >= 0.11.2 recommended for all features.
|
||||
|
||||
- Changes to encodings in PHP 5.6
|
||||
The default value of default_charset is now UTF-8 when it is not
|
||||
explicitly set in php.ini
|
||||
|
||||
The following php.ini parameters were added:
|
||||
internal_encoding
|
||||
input_encoding
|
||||
output_encoding
|
||||
|
||||
The values of the following php.ini parameters have become empty in
|
||||
PHP 5.6 (previously they were all ISO-8859-1)
|
||||
|
||||
iconv.input_encoding
|
||||
iconv.output_encoding
|
||||
iconv.internal_encoding
|
||||
|
||||
Changes were made to character set handling in:
|
||||
- the iconv and mbstring extensions,
|
||||
- and htmlentities(), htmlspecialchars(), html_entity_decode() functions
|
||||
|
||||
The precedence for these is now:
|
||||
|
||||
default_charset < internal/input/output_encoding < (mbstring.* || iconv.*) < function parameter
|
||||
|
||||
For example, the easiest way to use the UTF-8 encoding is to set
|
||||
default_charset=UTF-8 and leave the following php.ini parameters
|
||||
|
||||
empty:
|
||||
|
||||
iconv.input_encoding
|
||||
iconv.output_encoding
|
||||
iconv.internal_encoding
|
||||
mbstring.http_input
|
||||
mbstring.http_output
|
||||
mbstring.internal_encoding
|
||||
internal_encoding
|
||||
input_encoding
|
||||
output_encoding
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ UPGRADE NOTES - PHP X.Y
|
|||
c. POST data handling
|
||||
d. Arginfo changes
|
||||
e. tsrm_virtual_cwd.h moved to zend_virtual_cwd.h
|
||||
f. empty strings are interned
|
||||
|
||||
2. Build system changes
|
||||
a. Unix build system changes
|
||||
|
@ -115,6 +116,13 @@ UPGRADE NOTES - PHP X.Y
|
|||
|
||||
Memory allocation is now managed by emalloc/efree instead of malloc/free.
|
||||
|
||||
f. empty strings are interned
|
||||
|
||||
String created using STR_EMPTY_ALLOC() are now interned.
|
||||
convert_to_string use STR_EMPTY_ALLOC() for zval when IS_NULL.
|
||||
STR_FREE() shoud be prefered as efree on such strings can raise memory corruption.
|
||||
|
||||
|
||||
========================
|
||||
2. Build system changes
|
||||
========================
|
||||
|
|
|
@ -363,7 +363,7 @@ ZEND_METHOD(error_exception, getSeverity)
|
|||
|
||||
#define TRACE_ARG_APPEND(vallen) \
|
||||
*str = (char*)erealloc(*str, *len + 1 + vallen); \
|
||||
memcpy((*str) + *len - l_added + 1 + vallen, (*str) + *len - l_added + 1, l_added);
|
||||
memmove((*str) + *len - l_added + 1 + vallen, (*str) + *len - l_added + 1, l_added);
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
|
413
Zend/zend_hash.c
413
Zend/zend_hash.c
|
@ -29,18 +29,24 @@
|
|||
(element)->pNext->pLast = (element); \
|
||||
}
|
||||
|
||||
#define CONNECT_TO_GLOBAL_DLLIST(element, ht) \
|
||||
(element)->pListLast = (ht)->pListTail; \
|
||||
(ht)->pListTail = (element); \
|
||||
(element)->pListNext = NULL; \
|
||||
if ((element)->pListLast != NULL) { \
|
||||
(element)->pListLast->pListNext = (element); \
|
||||
} \
|
||||
if (!(ht)->pListHead) { \
|
||||
#define CONNECT_TO_GLOBAL_DLLIST_EX(element, ht, last, next)\
|
||||
(element)->pListLast = (last); \
|
||||
(element)->pListNext = (next); \
|
||||
if ((last) != NULL) { \
|
||||
(last)->pListNext = (element); \
|
||||
} else { \
|
||||
(ht)->pListHead = (element); \
|
||||
} \
|
||||
if ((ht)->pInternalPointer == NULL) { \
|
||||
(ht)->pInternalPointer = (element); \
|
||||
if ((next) != NULL) { \
|
||||
(next)->pListLast = (element); \
|
||||
} else { \
|
||||
(ht)->pListTail = (element); \
|
||||
} \
|
||||
|
||||
#define CONNECT_TO_GLOBAL_DLLIST(element, ht) \
|
||||
CONNECT_TO_GLOBAL_DLLIST_EX(element, ht, (ht)->pListTail, (Bucket *) NULL); \
|
||||
if ((ht)->pInternalPointer == NULL) { \
|
||||
(ht)->pInternalPointer = (element); \
|
||||
}
|
||||
|
||||
#if ZEND_DEBUG
|
||||
|
@ -122,13 +128,13 @@ ZEND_API ulong zend_hash_func(const char *arKey, uint nKeyLength)
|
|||
memcpy((p)->pData, pData, nDataSize); \
|
||||
}
|
||||
|
||||
#define INIT_DATA(ht, p, pData, nDataSize); \
|
||||
#define INIT_DATA(ht, p, _pData, nDataSize); \
|
||||
if (nDataSize == sizeof(void*)) { \
|
||||
memcpy(&(p)->pDataPtr, pData, sizeof(void *)); \
|
||||
memcpy(&(p)->pDataPtr, (_pData), sizeof(void *)); \
|
||||
(p)->pData = &(p)->pDataPtr; \
|
||||
} else { \
|
||||
(p)->pData = (void *) pemalloc_rel(nDataSize, (ht)->persistent);\
|
||||
memcpy((p)->pData, pData, nDataSize); \
|
||||
memcpy((p)->pData, (_pData), nDataSize); \
|
||||
(p)->pDataPtr=NULL; \
|
||||
}
|
||||
|
||||
|
@ -141,6 +147,51 @@ ZEND_API ulong zend_hash_func(const char *arKey, uint nKeyLength)
|
|||
|
||||
static const Bucket *uninitialized_bucket = NULL;
|
||||
|
||||
static zend_always_inline void i_zend_hash_bucket_delete(HashTable *ht, Bucket *p)
|
||||
{
|
||||
#ifdef ZEND_SIGNALS
|
||||
TSRMLS_FETCH();
|
||||
#endif
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
if (p->pLast) {
|
||||
p->pLast->pNext = p->pNext;
|
||||
} else {
|
||||
ht->arBuckets[p->h & ht->nTableMask] = p->pNext;
|
||||
}
|
||||
if (p->pNext) {
|
||||
p->pNext->pLast = p->pLast;
|
||||
}
|
||||
if (p->pListLast != NULL) {
|
||||
p->pListLast->pListNext = p->pListNext;
|
||||
} else {
|
||||
/* Deleting the head of the list */
|
||||
ht->pListHead = p->pListNext;
|
||||
}
|
||||
if (p->pListNext != NULL) {
|
||||
p->pListNext->pListLast = p->pListLast;
|
||||
} else {
|
||||
/* Deleting the tail of the list */
|
||||
ht->pListTail = p->pListLast;
|
||||
}
|
||||
if (ht->pInternalPointer == p) {
|
||||
ht->pInternalPointer = p->pListNext;
|
||||
}
|
||||
ht->nNumOfElements--;
|
||||
if (ht->pDestructor) {
|
||||
ht->pDestructor(p->pData);
|
||||
}
|
||||
if (p->pData != &p->pDataPtr) {
|
||||
pefree(p->pData, ht->persistent);
|
||||
}
|
||||
pefree(p, ht->persistent);
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
}
|
||||
|
||||
static void zend_hash_bucket_delete(HashTable *ht, Bucket *p) {
|
||||
i_zend_hash_bucket_delete(ht, p);
|
||||
}
|
||||
|
||||
ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
|
||||
{
|
||||
uint i = 3;
|
||||
|
@ -358,9 +409,6 @@ ZEND_API int _zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void
|
|||
}
|
||||
UPDATE_DATA(ht, p, pData, nDataSize);
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
if ((long)h >= (long)ht->nNextFreeElement) {
|
||||
ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX;
|
||||
}
|
||||
if (pDest) {
|
||||
*pDest = p->pData;
|
||||
}
|
||||
|
@ -424,23 +472,42 @@ ZEND_API int zend_hash_rehash(HashTable *ht)
|
|||
}
|
||||
|
||||
memset(ht->arBuckets, 0, ht->nTableSize * sizeof(Bucket *));
|
||||
p = ht->pListHead;
|
||||
while (p != NULL) {
|
||||
for (p = ht->pListHead; p != NULL; p = p->pListNext) {
|
||||
nIndex = p->h & ht->nTableMask;
|
||||
CONNECT_TO_BUCKET_DLLIST(p, ht->arBuckets[nIndex]);
|
||||
ht->arBuckets[nIndex] = p;
|
||||
p = p->pListNext;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
ZEND_API void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys) {
|
||||
Bucket *p;
|
||||
uint nIndex;
|
||||
ulong offset = 0;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
if (UNEXPECTED(ht->nNumOfElements == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(ht->arBuckets, 0, ht->nTableSize * sizeof(Bucket *));
|
||||
for (p = ht->pListHead; p != NULL; p = p->pListNext) {
|
||||
if (!only_integer_keys || p->nKeyLength == 0) {
|
||||
p->h = offset++;
|
||||
p->nKeyLength = 0;
|
||||
}
|
||||
|
||||
nIndex = p->h & ht->nTableMask;
|
||||
CONNECT_TO_BUCKET_DLLIST(p, ht->arBuckets[nIndex]);
|
||||
ht->arBuckets[nIndex] = p;
|
||||
}
|
||||
ht->nNextFreeElement = offset;
|
||||
}
|
||||
|
||||
ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, uint nKeyLength, ulong h, int flag)
|
||||
{
|
||||
uint nIndex;
|
||||
Bucket *p;
|
||||
#ifdef ZEND_SIGNALS
|
||||
TSRMLS_FETCH();
|
||||
#endif
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
|
||||
|
@ -455,38 +522,7 @@ ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, uint n
|
|||
&& (p->nKeyLength == nKeyLength)
|
||||
&& ((p->nKeyLength == 0) /* Numeric index (short circuits the memcmp() check) */
|
||||
|| !memcmp(p->arKey, arKey, nKeyLength))) { /* String index */
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
if (p == ht->arBuckets[nIndex]) {
|
||||
ht->arBuckets[nIndex] = p->pNext;
|
||||
} else {
|
||||
p->pLast->pNext = p->pNext;
|
||||
}
|
||||
if (p->pNext) {
|
||||
p->pNext->pLast = p->pLast;
|
||||
}
|
||||
if (p->pListLast != NULL) {
|
||||
p->pListLast->pListNext = p->pListNext;
|
||||
} else {
|
||||
/* Deleting the head of the list */
|
||||
ht->pListHead = p->pListNext;
|
||||
}
|
||||
if (p->pListNext != NULL) {
|
||||
p->pListNext->pListLast = p->pListLast;
|
||||
} else {
|
||||
ht->pListTail = p->pListLast;
|
||||
}
|
||||
if (ht->pInternalPointer == p) {
|
||||
ht->pInternalPointer = p->pListNext;
|
||||
}
|
||||
ht->nNumOfElements--;
|
||||
if (ht->pDestructor) {
|
||||
ht->pDestructor(p->pData);
|
||||
}
|
||||
if (p->pData != &p->pDataPtr) {
|
||||
pefree(p->pData, ht->persistent);
|
||||
}
|
||||
pefree(p, ht->persistent);
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
i_zend_hash_bucket_delete(ht, p);
|
||||
return SUCCESS;
|
||||
}
|
||||
p = p->pNext;
|
||||
|
@ -553,73 +589,14 @@ ZEND_API void zend_hash_clean(HashTable *ht)
|
|||
}
|
||||
}
|
||||
|
||||
/* This function is used by the various apply() functions.
|
||||
* It deletes the passed bucket, and returns the address of the
|
||||
* next bucket. The hash *may* be altered during that time, the
|
||||
* returned value will still be valid.
|
||||
*/
|
||||
static Bucket *zend_hash_apply_deleter(HashTable *ht, Bucket *p)
|
||||
{
|
||||
Bucket *retval;
|
||||
#ifdef ZEND_SIGNALS
|
||||
TSRMLS_FETCH();
|
||||
#endif
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
if (p->pLast) {
|
||||
p->pLast->pNext = p->pNext;
|
||||
} else {
|
||||
uint nIndex;
|
||||
|
||||
nIndex = p->h & ht->nTableMask;
|
||||
ht->arBuckets[nIndex] = p->pNext;
|
||||
}
|
||||
if (p->pNext) {
|
||||
p->pNext->pLast = p->pLast;
|
||||
} else {
|
||||
/* Nothing to do as this list doesn't have a tail */
|
||||
}
|
||||
|
||||
if (p->pListLast != NULL) {
|
||||
p->pListLast->pListNext = p->pListNext;
|
||||
} else {
|
||||
/* Deleting the head of the list */
|
||||
ht->pListHead = p->pListNext;
|
||||
}
|
||||
if (p->pListNext != NULL) {
|
||||
p->pListNext->pListLast = p->pListLast;
|
||||
} else {
|
||||
ht->pListTail = p->pListLast;
|
||||
}
|
||||
if (ht->pInternalPointer == p) {
|
||||
ht->pInternalPointer = p->pListNext;
|
||||
}
|
||||
ht->nNumOfElements--;
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
|
||||
if (ht->pDestructor) {
|
||||
ht->pDestructor(p->pData);
|
||||
}
|
||||
if (p->pData != &p->pDataPtr) {
|
||||
pefree(p->pData, ht->persistent);
|
||||
}
|
||||
retval = p->pListNext;
|
||||
pefree(p, ht->persistent);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_hash_graceful_destroy(HashTable *ht)
|
||||
{
|
||||
Bucket *p;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
|
||||
p = ht->pListHead;
|
||||
while (p != NULL) {
|
||||
p = zend_hash_apply_deleter(ht, p);
|
||||
while (ht->pListHead != NULL) {
|
||||
zend_hash_bucket_delete(ht, ht->pListHead);
|
||||
}
|
||||
|
||||
if (ht->nTableMask) {
|
||||
pefree(ht->arBuckets, ht->persistent);
|
||||
}
|
||||
|
@ -629,14 +606,10 @@ ZEND_API void zend_hash_graceful_destroy(HashTable *ht)
|
|||
|
||||
ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht)
|
||||
{
|
||||
Bucket *p;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
|
||||
p = ht->pListTail;
|
||||
while (p != NULL) {
|
||||
zend_hash_apply_deleter(ht, p);
|
||||
p = ht->pListTail;
|
||||
while (ht->pListTail != NULL) {
|
||||
zend_hash_bucket_delete(ht, ht->pListTail);
|
||||
}
|
||||
|
||||
if (ht->nTableMask) {
|
||||
|
@ -665,12 +638,13 @@ ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC)
|
|||
p = ht->pListHead;
|
||||
while (p != NULL) {
|
||||
int result = apply_func(p->pData TSRMLS_CC);
|
||||
|
||||
|
||||
Bucket *p_next = p->pListNext;
|
||||
if (result & ZEND_HASH_APPLY_REMOVE) {
|
||||
p = zend_hash_apply_deleter(ht, p);
|
||||
} else {
|
||||
p = p->pListNext;
|
||||
zend_hash_bucket_delete(ht, p);
|
||||
}
|
||||
p = p_next;
|
||||
|
||||
if (result & ZEND_HASH_APPLY_STOP) {
|
||||
break;
|
||||
}
|
||||
|
@ -690,11 +664,12 @@ ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t appl
|
|||
while (p != NULL) {
|
||||
int result = apply_func(p->pData, argument TSRMLS_CC);
|
||||
|
||||
Bucket *p_next = p->pListNext;
|
||||
if (result & ZEND_HASH_APPLY_REMOVE) {
|
||||
p = zend_hash_apply_deleter(ht, p);
|
||||
} else {
|
||||
p = p->pListNext;
|
||||
zend_hash_bucket_delete(ht, p);
|
||||
}
|
||||
p = p_next;
|
||||
|
||||
if (result & ZEND_HASH_APPLY_STOP) {
|
||||
break;
|
||||
}
|
||||
|
@ -716,17 +691,20 @@ ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func
|
|||
p = ht->pListHead;
|
||||
while (p != NULL) {
|
||||
int result;
|
||||
Bucket *p_next;
|
||||
|
||||
va_start(args, num_args);
|
||||
hash_key.arKey = p->arKey;
|
||||
hash_key.nKeyLength = p->nKeyLength;
|
||||
hash_key.h = p->h;
|
||||
result = apply_func(p->pData TSRMLS_CC, num_args, args, &hash_key);
|
||||
|
||||
p_next = p->pListNext;
|
||||
if (result & ZEND_HASH_APPLY_REMOVE) {
|
||||
p = zend_hash_apply_deleter(ht, p);
|
||||
} else {
|
||||
p = p->pListNext;
|
||||
zend_hash_bucket_delete(ht, p);
|
||||
}
|
||||
p = p_next;
|
||||
|
||||
if (result & ZEND_HASH_APPLY_STOP) {
|
||||
va_end(args);
|
||||
break;
|
||||
|
@ -740,7 +718,7 @@ ZEND_API void zend_hash_apply_with_arguments(HashTable *ht TSRMLS_DC, apply_func
|
|||
|
||||
ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC)
|
||||
{
|
||||
Bucket *p, *q;
|
||||
Bucket *p;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
|
||||
|
@ -749,11 +727,12 @@ ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSR
|
|||
while (p != NULL) {
|
||||
int result = apply_func(p->pData TSRMLS_CC);
|
||||
|
||||
q = p;
|
||||
p = p->pListLast;
|
||||
Bucket *p_last = p->pListLast;
|
||||
if (result & ZEND_HASH_APPLY_REMOVE) {
|
||||
zend_hash_apply_deleter(ht, q);
|
||||
zend_hash_bucket_delete(ht, p);
|
||||
}
|
||||
p = p_last;
|
||||
|
||||
if (result & ZEND_HASH_APPLY_STOP) {
|
||||
break;
|
||||
}
|
||||
|
@ -1223,8 +1202,6 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const
|
|||
return FAILURE;
|
||||
}
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
|
||||
if (q) {
|
||||
if (mode != HASH_UPDATE_KEY_ANYWAY) {
|
||||
Bucket *r = p->pListLast;
|
||||
|
@ -1239,73 +1216,17 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const
|
|||
}
|
||||
if (mode & found) {
|
||||
/* delete current bucket */
|
||||
if (p == ht->arBuckets[p->h & ht->nTableMask]) {
|
||||
ht->arBuckets[p->h & ht->nTableMask] = p->pNext;
|
||||
} else {
|
||||
p->pLast->pNext = p->pNext;
|
||||
}
|
||||
if (p->pNext) {
|
||||
p->pNext->pLast = p->pLast;
|
||||
}
|
||||
if (p->pListLast != NULL) {
|
||||
p->pListLast->pListNext = p->pListNext;
|
||||
} else {
|
||||
/* Deleting the head of the list */
|
||||
ht->pListHead = p->pListNext;
|
||||
}
|
||||
if (p->pListNext != NULL) {
|
||||
p->pListNext->pListLast = p->pListLast;
|
||||
} else {
|
||||
ht->pListTail = p->pListLast;
|
||||
}
|
||||
if (ht->pInternalPointer == p) {
|
||||
ht->pInternalPointer = p->pListNext;
|
||||
}
|
||||
ht->nNumOfElements--;
|
||||
if (ht->pDestructor) {
|
||||
ht->pDestructor(p->pData);
|
||||
}
|
||||
if (p->pData != &p->pDataPtr) {
|
||||
pefree(p->pData, ht->persistent);
|
||||
}
|
||||
pefree(p, ht->persistent);
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
zend_hash_bucket_delete(ht, p);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* delete another bucket with the same key */
|
||||
if (q == ht->arBuckets[q->h & ht->nTableMask]) {
|
||||
ht->arBuckets[q->h & ht->nTableMask] = q->pNext;
|
||||
} else {
|
||||
q->pLast->pNext = q->pNext;
|
||||
}
|
||||
if (q->pNext) {
|
||||
q->pNext->pLast = q->pLast;
|
||||
}
|
||||
if (q->pListLast != NULL) {
|
||||
q->pListLast->pListNext = q->pListNext;
|
||||
} else {
|
||||
/* Deleting the head of the list */
|
||||
ht->pListHead = q->pListNext;
|
||||
}
|
||||
if (q->pListNext != NULL) {
|
||||
q->pListNext->pListLast = q->pListLast;
|
||||
} else {
|
||||
ht->pListTail = q->pListLast;
|
||||
}
|
||||
if (ht->pInternalPointer == q) {
|
||||
ht->pInternalPointer = q->pListNext;
|
||||
}
|
||||
ht->nNumOfElements--;
|
||||
if (ht->pDestructor) {
|
||||
ht->pDestructor(q->pData);
|
||||
}
|
||||
if (q->pData != &q->pDataPtr) {
|
||||
pefree(q->pData, ht->persistent);
|
||||
}
|
||||
pefree(q, ht->persistent);
|
||||
zend_hash_bucket_delete(ht, q);
|
||||
}
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
|
||||
if (p->pNext) {
|
||||
p->pNext->pLast = p->pLast;
|
||||
}
|
||||
|
@ -1332,21 +1253,12 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const
|
|||
q->pData = p->pData;
|
||||
}
|
||||
q->pDataPtr = p->pDataPtr;
|
||||
q->pListNext = p->pListNext;
|
||||
q->pListLast = p->pListLast;
|
||||
if (q->pListNext) {
|
||||
p->pListNext->pListLast = q;
|
||||
} else {
|
||||
ht->pListTail = q;
|
||||
}
|
||||
if (q->pListLast) {
|
||||
p->pListLast->pListNext = q;
|
||||
} else {
|
||||
ht->pListHead = q;
|
||||
}
|
||||
|
||||
CONNECT_TO_GLOBAL_DLLIST_EX(q, ht, p->pListLast, p->pListNext);
|
||||
if (ht->pInternalPointer == p) {
|
||||
ht->pInternalPointer = q;
|
||||
}
|
||||
|
||||
if (pos) {
|
||||
*pos = q;
|
||||
}
|
||||
|
@ -1377,6 +1289,75 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const
|
|||
}
|
||||
}
|
||||
|
||||
/* Performs an in-place splice operation on a hashtable:
|
||||
* The elements between offset and offset+length are removed and the elements in list[list_count]
|
||||
* are inserted in their place. The removed elements can be optionally collected into a hashtable.
|
||||
* This operation reindexes the hashtable, i.e. integer keys will be zero-based and sequential,
|
||||
* while string keys stay intact. The same applies to the elements inserted into the removed HT. */
|
||||
ZEND_API void _zend_hash_splice(HashTable *ht, uint nDataSize, copy_ctor_func_t pCopyConstructor, uint offset, uint length, void **list, uint list_count, HashTable *removed ZEND_FILE_LINE_DC) /* {{{ */
|
||||
{
|
||||
int pos;
|
||||
Bucket *p;
|
||||
|
||||
IS_CONSISTENT(ht);
|
||||
CHECK_INIT(ht);
|
||||
|
||||
/* Skip all elements until offset */
|
||||
for (pos = 0, p = ht->pListHead; pos < offset && p; pos++, p = p->pListNext);
|
||||
|
||||
while (pos < offset + length && p) {
|
||||
/* Copy removed element into HT, if it was specified */
|
||||
if (removed != NULL) {
|
||||
void *new_entry;
|
||||
|
||||
if (p->nKeyLength == 0) {
|
||||
zend_hash_next_index_insert(removed, p->pData, sizeof(zval *), &new_entry);
|
||||
} else {
|
||||
zend_hash_quick_update(removed, p->arKey, p->nKeyLength, p->h, p->pData, sizeof(zval *), &new_entry);
|
||||
}
|
||||
|
||||
if (pCopyConstructor) {
|
||||
pCopyConstructor(new_entry);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove element */
|
||||
{
|
||||
Bucket *p_next = p->pListNext;
|
||||
zend_hash_bucket_delete(ht, p);
|
||||
p = p_next;
|
||||
}
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (list != NULL) {
|
||||
int i;
|
||||
for (i = 0; i < list_count; i++) {
|
||||
/* Add new element only to the global linked list, not the bucket list.
|
||||
* Also use key 0 for everything, as we'll reindex the hashtable anyways. */
|
||||
Bucket *q = pemalloc_rel(sizeof(Bucket), ht->persistent);
|
||||
q->arKey = NULL;
|
||||
q->nKeyLength = 0;
|
||||
q->h = 0;
|
||||
INIT_DATA(ht, q, list[i], nDataSize);
|
||||
|
||||
CONNECT_TO_GLOBAL_DLLIST_EX(q, ht, p ? p->pListLast : ht->pListTail, p);
|
||||
|
||||
ht->nNumOfElements++;
|
||||
|
||||
if (pCopyConstructor) {
|
||||
pCopyConstructor(q->pData);
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_HASH_IF_FULL_DO_RESIZE(ht);
|
||||
}
|
||||
|
||||
zend_hash_reindex(ht, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
|
||||
compare_func_t compar, int renumber TSRMLS_DC)
|
||||
{
|
||||
|
@ -1423,15 +1404,7 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func,
|
|||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
|
||||
if (renumber) {
|
||||
p = ht->pListHead;
|
||||
i=0;
|
||||
while (p != NULL) {
|
||||
p->nKeyLength = 0;
|
||||
p->h = i++;
|
||||
p = p->pListNext;
|
||||
}
|
||||
ht->nNextFreeElement = i;
|
||||
zend_hash_rehash(ht);
|
||||
zend_hash_reindex(ht, 0);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
|
@ -227,6 +227,11 @@ ZEND_API int zend_hash_minmax(const HashTable *ht, compare_func_t compar, int fl
|
|||
ZEND_API int zend_hash_num_elements(const HashTable *ht);
|
||||
|
||||
ZEND_API int zend_hash_rehash(HashTable *ht);
|
||||
ZEND_API void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys);
|
||||
|
||||
ZEND_API void _zend_hash_splice(HashTable *ht, uint nDataSize, copy_ctor_func_t pCopyConstructor, uint offset, uint length, void **list, uint list_count, HashTable *removed ZEND_FILE_LINE_DC);
|
||||
#define zend_hash_splice(ht, nDataSize, pCopyConstructor, offset, length, list, list_count, removed) \
|
||||
_zend_hash_splice(ht, nDataSize, pCopyConstructor, offset, length, list, list_count, removed ZEND_FILE_LINE_CC)
|
||||
|
||||
/*
|
||||
* DJBX33A (Daniel J. Bernstein, Times 33 with Addition)
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "ext/standard/file.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
#include "main/php_network.h"
|
||||
|
||||
/* for fileno() */
|
||||
#include <stdio.h>
|
||||
|
@ -245,7 +246,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
|||
stream = php_stream_open_wrapper(path, mode, options | STREAM_WILL_CAST, opened_path);
|
||||
|
||||
if (stream) {
|
||||
int fd;
|
||||
php_socket_t fd;
|
||||
if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **) &fd, REPORT_ERRORS)) {
|
||||
bz_file = BZ2_bzdopen(fd, mode);
|
||||
}
|
||||
|
@ -394,7 +395,7 @@ static PHP_FUNCTION(bzopen)
|
|||
NULL);
|
||||
} else if (Z_TYPE_PP(file) == IS_RESOURCE) {
|
||||
/* If it is a resource, than its a stream resource */
|
||||
int fd;
|
||||
php_socket_t fd;
|
||||
int stream_mode_len;
|
||||
|
||||
php_stream_from_zval(stream, file);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1509,6 +1509,12 @@ char *_dom_get_valid_file_path(char *source, char *resolved_path, int resolved_p
|
|||
|
||||
if (uri->scheme != NULL) {
|
||||
/* absolute file uris - libxml only supports localhost or empty host */
|
||||
#ifdef PHP_WIN32
|
||||
if (strncasecmp(source, "file://",7) == 0 && ':' == source[8]) {
|
||||
isFileUri = 1;
|
||||
source += 7;
|
||||
} else
|
||||
#endif
|
||||
if (strncasecmp(source, "file:///",8) == 0) {
|
||||
isFileUri = 1;
|
||||
#ifdef PHP_WIN32
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
--- libmagic.orig/apprentice.c Tue Nov 19 22:01:12 2013
|
||||
+++ libmagic/apprentice.c Fri Feb 21 00:21:27 2014
|
||||
+++ libmagic/apprentice.c Mon Mar 31 17:15:53 2014
|
||||
@@ -29,6 +29,8 @@
|
||||
* apprentice - make one pass through /etc/magic, learning its secrets.
|
||||
*/
|
||||
|
@ -180,7 +180,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
return NULL;
|
||||
}
|
||||
|
||||
@@ -505,22 +498,24 @@
|
||||
@@ -505,22 +498,26 @@
|
||||
{
|
||||
if (map == NULL)
|
||||
return;
|
||||
|
@ -194,12 +194,14 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
- free(map->p);
|
||||
- free(map);
|
||||
+ if (map->p != php_magic_database) {
|
||||
+ int j;
|
||||
+ for (j = 0; j < MAGIC_SETS; j++) {
|
||||
+ if (map->magic[j])
|
||||
+ efree(map->magic[j]);
|
||||
+ }
|
||||
+ if (map->p != NULL) {
|
||||
+ if (map->p == NULL) {
|
||||
+ int j;
|
||||
+ for (j = 0; j < MAGIC_SETS; j++) {
|
||||
+ if (map->magic[j]) {
|
||||
+ efree(map->magic[j]);
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ efree(map->p);
|
||||
+ }
|
||||
+ }
|
||||
|
@ -215,7 +217,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
return NULL;
|
||||
}
|
||||
mlist->next = mlist->prev = mlist;
|
||||
@@ -539,10 +534,10 @@
|
||||
@@ -539,10 +536,10 @@
|
||||
struct mlist *next = ml->next;
|
||||
if (ml->map)
|
||||
apprentice_unmap(ml->map);
|
||||
|
@ -228,7 +230,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
}
|
||||
|
||||
/* const char *fn: list of magic files and directories */
|
||||
@@ -555,12 +550,28 @@
|
||||
@@ -555,12 +552,28 @@
|
||||
|
||||
file_reset(ms);
|
||||
|
||||
|
@ -258,7 +260,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
file_oomem(ms, strlen(fn));
|
||||
return -1;
|
||||
}
|
||||
@@ -575,7 +586,7 @@
|
||||
@@ -575,7 +588,7 @@
|
||||
mlist_free(ms->mlist[i]);
|
||||
while (i != 0);
|
||||
}
|
||||
|
@ -267,7 +269,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -592,7 +603,7 @@
|
||||
@@ -592,7 +605,7 @@
|
||||
fn = p;
|
||||
}
|
||||
|
||||
|
@ -276,7 +278,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
|
||||
if (errs == -1) {
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
@@ -918,7 +929,7 @@
|
||||
@@ -918,7 +931,7 @@
|
||||
|
||||
mset[i].max += ALLOC_INCR;
|
||||
if ((mp = CAST(struct magic_entry *,
|
||||
|
@ -285,7 +287,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
NULL) {
|
||||
file_oomem(ms, sizeof(*mp) * mset[i].max);
|
||||
return -1;
|
||||
@@ -939,13 +950,20 @@
|
||||
@@ -939,13 +952,20 @@
|
||||
load_1(struct magic_set *ms, int action, const char *fn, int *errs,
|
||||
struct magic_entry_set *mset)
|
||||
{
|
||||
|
@ -310,7 +312,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
if (errno != ENOENT)
|
||||
file_error(ms, errno, "cannot read magic file `%s'",
|
||||
fn);
|
||||
@@ -955,8 +973,7 @@
|
||||
@@ -955,8 +975,7 @@
|
||||
|
||||
memset(&me, 0, sizeof(me));
|
||||
/* read and parse this file */
|
||||
|
@ -320,7 +322,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
if (len == 0) /* null line, garbage, etc */
|
||||
continue;
|
||||
if (line[len - 1] == '\n') {
|
||||
@@ -1014,8 +1031,7 @@
|
||||
@@ -1014,8 +1033,7 @@
|
||||
}
|
||||
if (me.mp)
|
||||
(void)addentry(ms, &me, mset);
|
||||
|
@ -330,7 +332,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
}
|
||||
|
||||
/*
|
||||
@@ -1094,7 +1110,7 @@
|
||||
@@ -1094,7 +1112,7 @@
|
||||
mentrycount += me[i].cont_count;
|
||||
|
||||
slen = sizeof(**ma) * mentrycount;
|
||||
|
@ -339,7 +341,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
file_oomem(ms, slen);
|
||||
return -1;
|
||||
}
|
||||
@@ -1116,8 +1132,8 @@
|
||||
@@ -1116,8 +1134,8 @@
|
||||
if (me == NULL)
|
||||
return;
|
||||
for (i = 0; i < nme; i++)
|
||||
|
@ -350,7 +352,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
}
|
||||
|
||||
private struct magic_map *
|
||||
@@ -1126,18 +1142,20 @@
|
||||
@@ -1126,18 +1144,20 @@
|
||||
int errs = 0;
|
||||
uint32_t i, j;
|
||||
size_t files = 0, maxfiles = 0;
|
||||
|
@ -375,7 +377,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
{
|
||||
file_oomem(ms, sizeof(*map));
|
||||
return NULL;
|
||||
@@ -1148,22 +1166,26 @@
|
||||
@@ -1148,22 +1168,26 @@
|
||||
(void)fprintf(stderr, "%s\n", usg_hdr);
|
||||
|
||||
/* load directory or file */
|
||||
|
@ -409,7 +411,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
continue;
|
||||
}
|
||||
if (files >= maxfiles) {
|
||||
@@ -1171,23 +1193,23 @@
|
||||
@@ -1171,23 +1195,23 @@
|
||||
maxfiles = (maxfiles + 1) * 2;
|
||||
mlen = maxfiles * sizeof(*filearr);
|
||||
if ((filearr = CAST(char **,
|
||||
|
@ -440,7 +442,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
} else
|
||||
load_1(ms, action, fn, &errs, mset);
|
||||
if (errs)
|
||||
@@ -1226,9 +1248,9 @@
|
||||
@@ -1226,9 +1250,9 @@
|
||||
if (errs) {
|
||||
for (j = 0; j < MAGIC_SETS; j++) {
|
||||
if (map->magic[j])
|
||||
|
@ -452,7 +454,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
return NULL;
|
||||
}
|
||||
return map;
|
||||
@@ -1516,7 +1538,7 @@
|
||||
@@ -1516,7 +1540,7 @@
|
||||
if (me->cont_count == me->max_count) {
|
||||
struct magic *nm;
|
||||
size_t cnt = me->max_count + ALLOC_CHUNK;
|
||||
|
@ -461,7 +463,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
sizeof(*nm) * cnt))) == NULL) {
|
||||
file_oomem(ms, sizeof(*nm) * cnt);
|
||||
return -1;
|
||||
@@ -1531,7 +1553,7 @@
|
||||
@@ -1531,7 +1555,7 @@
|
||||
static const size_t len = sizeof(*m) * ALLOC_CHUNK;
|
||||
if (me->mp != NULL)
|
||||
return 1;
|
||||
|
@ -470,7 +472,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
file_oomem(ms, len);
|
||||
return -1;
|
||||
}
|
||||
@@ -1704,7 +1726,7 @@
|
||||
@@ -1704,7 +1728,7 @@
|
||||
m->type = get_standard_integer_type(l, &l);
|
||||
else if (*l == 's' && !isalpha((unsigned char)l[1])) {
|
||||
m->type = FILE_STRING;
|
||||
|
@ -479,7 +481,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -1717,6 +1739,10 @@
|
||||
@@ -1717,6 +1741,10 @@
|
||||
if (m->type == FILE_INVALID) {
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(ms, "type `%s' invalid", l);
|
||||
|
@ -490,7 +492,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
return -1;
|
||||
}
|
||||
|
||||
@@ -1725,7 +1751,7 @@
|
||||
@@ -1725,7 +1753,7 @@
|
||||
|
||||
m->mask_op = 0;
|
||||
if (*l == '~') {
|
||||
|
@ -499,7 +501,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
m->mask_op |= FILE_OPINVERSE;
|
||||
else if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(ms, "'~' invalid for string types");
|
||||
@@ -1734,7 +1760,7 @@
|
||||
@@ -1734,7 +1762,7 @@
|
||||
m->str_range = 0;
|
||||
m->str_flags = m->type == FILE_PSTRING ? PSTRING_1_LE : 0;
|
||||
if ((op = get_op(*l)) != -1) {
|
||||
|
@ -508,7 +510,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
uint64_t val;
|
||||
++l;
|
||||
m->mask_op |= op;
|
||||
@@ -1925,11 +1951,6 @@
|
||||
@@ -1925,11 +1953,6 @@
|
||||
if (check_format(ms, m) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
@ -520,7 +522,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
m->mimetype[0] = '\0'; /* initialise MIME type to none */
|
||||
return 0;
|
||||
}
|
||||
@@ -2575,59 +2596,76 @@
|
||||
@@ -2575,59 +2598,76 @@
|
||||
private struct magic_map *
|
||||
apprentice_map(struct magic_set *ms, const char *fn)
|
||||
{
|
||||
|
@ -618,7 +620,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
if (*ptr != MAGICNO) {
|
||||
if (swap4(*ptr) != MAGICNO) {
|
||||
file_error(ms, 0, "bad magic in `%s'", dbname);
|
||||
@@ -2641,17 +2679,29 @@
|
||||
@@ -2641,17 +2681,29 @@
|
||||
else
|
||||
version = ptr[1];
|
||||
if (version != VERSIONNO) {
|
||||
|
@ -656,7 +658,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
}
|
||||
map->magic[0] = CAST(struct magic *, map->p) + 1;
|
||||
nentries = 0;
|
||||
@@ -2664,22 +2714,29 @@
|
||||
@@ -2664,22 +2716,29 @@
|
||||
map->magic[i + 1] = map->magic[i] + map->nmagic[i];
|
||||
nentries += map->nmagic[i];
|
||||
}
|
||||
|
@ -691,7 +693,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2700,14 +2757,19 @@
|
||||
@@ -2700,14 +2759,19 @@
|
||||
char *dbname;
|
||||
int rv = -1;
|
||||
uint32_t i;
|
||||
|
@ -714,7 +716,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
file_error(ms, errno, "cannot open `%s'", dbname);
|
||||
goto out;
|
||||
}
|
||||
@@ -2717,31 +2779,33 @@
|
||||
@@ -2717,31 +2781,33 @@
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -754,7 +756,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
return rv;
|
||||
}
|
||||
|
||||
@@ -2754,6 +2818,7 @@
|
||||
@@ -2754,6 +2820,7 @@
|
||||
{
|
||||
const char *p, *q;
|
||||
char *buf;
|
||||
|
@ -762,7 +764,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
|
||||
if (strip) {
|
||||
if ((p = strrchr(fn, '/')) != NULL)
|
||||
@@ -2775,16 +2840,18 @@
|
||||
@@ -2775,16 +2842,18 @@
|
||||
q++;
|
||||
/* Compatibility with old code that looked in .mime */
|
||||
if (ms->flags & MAGIC_MIME) {
|
||||
|
@ -787,7 +789,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
|||
|
||||
/* Compatibility with old code that looked in .mime */
|
||||
if (strstr(p, ".mime") != NULL)
|
||||
@@ -2874,7 +2941,7 @@
|
||||
@@ -2874,7 +2943,7 @@
|
||||
m->offset = swap4((uint32_t)m->offset);
|
||||
m->in_offset = swap4((uint32_t)m->in_offset);
|
||||
m->lineno = swap4((uint32_t)m->lineno);
|
||||
|
@ -1649,8 +1651,8 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
|
|||
}
|
||||
diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
||||
--- libmagic.orig/funcs.c Thu Feb 13 00:20:53 2014
|
||||
+++ libmagic/funcs.c Fri Feb 28 14:01:53 2014
|
||||
@@ -41,79 +41,76 @@
|
||||
+++ libmagic/funcs.c Wed Mar 19 13:28:34 2014
|
||||
@@ -41,79 +41,79 @@
|
||||
#if defined(HAVE_WCTYPE_H)
|
||||
#include <wctype.h>
|
||||
#endif
|
||||
|
@ -1674,16 +1676,18 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
-{
|
||||
- int len;
|
||||
- char *buf, *newstr;
|
||||
+#ifndef PREG_OFFSET_CAPTURE
|
||||
+# define PREG_OFFSET_CAPTURE (1<<8)
|
||||
+#endif
|
||||
+#include "php.h"
|
||||
+#include "main/php_network.h"
|
||||
|
||||
- if (ms->event_flags & EVENT_HAD_ERR)
|
||||
- return 0;
|
||||
- len = vasprintf(&buf, fmt, ap);
|
||||
- if (len < 0)
|
||||
- goto out;
|
||||
-
|
||||
+#ifndef PREG_OFFSET_CAPTURE
|
||||
+# define PREG_OFFSET_CAPTURE (1<<8)
|
||||
+#endif
|
||||
|
||||
- if (ms->o.buf != NULL) {
|
||||
- len = asprintf(&newstr, "%s%s", ms->o.buf, buf);
|
||||
- free(buf);
|
||||
|
@ -1767,7 +1771,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
ms->event_flags |= EVENT_HAD_ERR;
|
||||
ms->error = error;
|
||||
}
|
||||
@@ -160,10 +157,9 @@
|
||||
@@ -160,10 +160,9 @@
|
||||
file_error(ms, errno, "error reading");
|
||||
}
|
||||
|
||||
|
@ -1780,7 +1784,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
{
|
||||
int m = 0, rv = 0, looks_text = 0;
|
||||
int mime = ms->flags & MAGIC_MIME;
|
||||
@@ -203,10 +199,10 @@
|
||||
@@ -203,10 +202,10 @@
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1794,7 +1798,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void)fprintf(stderr, "zmagic %d\n", m);
|
||||
goto done_encoding;
|
||||
@@ -221,12 +217,17 @@
|
||||
@@ -221,12 +220,17 @@
|
||||
}
|
||||
|
||||
/* Check if we have a CDF file */
|
||||
|
@ -1804,7 +1808,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
- (void)fprintf(stderr, "cdf %d\n", m);
|
||||
- goto done;
|
||||
+ if ((ms->flags & MAGIC_NO_CHECK_CDF) == 0) {
|
||||
+ int fd;
|
||||
+ php_socket_t fd;
|
||||
+ TSRMLS_FETCH();
|
||||
+ if (stream && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&fd, 0)) {
|
||||
+ if ((m = file_trycdf(ms, fd, ubuf, nb)) != 0) {
|
||||
|
@ -1817,7 +1821,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
|
||||
/* try soft magic tests */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)
|
||||
@@ -300,7 +301,6 @@
|
||||
@@ -300,7 +304,6 @@
|
||||
|
||||
return m;
|
||||
}
|
||||
|
@ -1825,7 +1829,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
|
||||
protected int
|
||||
file_reset(struct magic_set *ms)
|
||||
@@ -310,11 +310,11 @@
|
||||
@@ -310,11 +313,11 @@
|
||||
return -1;
|
||||
}
|
||||
if (ms->o.buf) {
|
||||
|
@ -1839,7 +1843,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
ms->o.pbuf = NULL;
|
||||
}
|
||||
ms->event_flags &= ~EVENT_HAD_ERR;
|
||||
@@ -333,7 +333,7 @@
|
||||
@@ -333,7 +336,7 @@
|
||||
protected const char *
|
||||
file_getbuffer(struct magic_set *ms)
|
||||
{
|
||||
|
@ -1848,7 +1852,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
size_t psize, len;
|
||||
|
||||
if (ms->event_flags & EVENT_HAD_ERR)
|
||||
@@ -348,15 +348,13 @@
|
||||
@@ -348,15 +351,13 @@
|
||||
/* * 4 is for octal representation, + 1 is for NUL */
|
||||
len = strlen(ms->o.buf);
|
||||
if (len > (SIZE_MAX - 1) / 4) {
|
||||
|
@ -1865,7 +1869,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
|
||||
#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
|
||||
{
|
||||
@@ -416,8 +414,8 @@
|
||||
@@ -416,8 +417,8 @@
|
||||
if (level >= ms->c.len) {
|
||||
len = (ms->c.len += 20) * sizeof(*ms->c.li);
|
||||
ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?
|
||||
|
@ -1876,7 +1880,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
|||
if (ms->c.li == NULL) {
|
||||
file_oomem(ms, len);
|
||||
return -1;
|
||||
@@ -437,32 +435,50 @@
|
||||
@@ -437,32 +438,50 @@
|
||||
return ms->o.buf == NULL ? 0 : strlen(ms->o.buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -499,12 +499,14 @@ apprentice_unmap(struct magic_map *map)
|
|||
if (map == NULL)
|
||||
return;
|
||||
if (map->p != php_magic_database) {
|
||||
int j;
|
||||
for (j = 0; j < MAGIC_SETS; j++) {
|
||||
if (map->magic[j])
|
||||
efree(map->magic[j]);
|
||||
}
|
||||
if (map->p != NULL) {
|
||||
if (map->p == NULL) {
|
||||
int j;
|
||||
for (j = 0; j < MAGIC_SETS; j++) {
|
||||
if (map->magic[j]) {
|
||||
efree(map->magic[j]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
efree(map->p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.67 2014/02/12 23:20:53 christos Exp $")
|
|||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "main/php_network.h"
|
||||
|
||||
#ifndef PREG_OFFSET_CAPTURE
|
||||
# define PREG_OFFSET_CAPTURE (1<<8)
|
||||
#endif
|
||||
|
@ -218,7 +221,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
|
|||
|
||||
/* Check if we have a CDF file */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_CDF) == 0) {
|
||||
int fd;
|
||||
php_socket_t fd;
|
||||
TSRMLS_FETCH();
|
||||
if (stream && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&fd, 0)) {
|
||||
if ((m = file_trycdf(ms, fd, ubuf, nb)) != 0) {
|
||||
|
|
4
ext/fileinfo/magicdata.patch
Normal file
4
ext/fileinfo/magicdata.patch
Normal file
|
@ -0,0 +1,4 @@
|
|||
Patches applied to file sources tree before generating magic.mgc
|
||||
and before running create_data_file.php to create data_file.c.
|
||||
|
||||
|
|
@ -728,6 +728,46 @@ PHP_FUNCTION(hash_pbkdf2)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool hash_equals(string known_string, string user_string)
|
||||
Compares two strings using the same time whether they're equal or not.
|
||||
A difference in length will leak */
|
||||
PHP_FUNCTION(hash_equals)
|
||||
{
|
||||
zval *known_zval, *user_zval;
|
||||
char *known_str, *user_str;
|
||||
int result = 0, j;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &known_zval, &user_zval) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* We only allow comparing string to prevent unexpected results. */
|
||||
if (Z_TYPE_P(known_zval) != IS_STRING) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected known_string to be a string, %s given", zend_zval_type_name(known_zval));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (Z_TYPE_P(user_zval) != IS_STRING) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected user_string to be a string, %s given", zend_zval_type_name(user_zval));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (Z_STRLEN_P(known_zval) != Z_STRLEN_P(user_zval)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
known_str = Z_STRVAL_P(known_zval);
|
||||
user_str = Z_STRVAL_P(user_zval);
|
||||
|
||||
/* This is security sensitive code. Do not optimize this for speed. */
|
||||
for (j = 0; j < Z_STRLEN_P(known_zval); j++) {
|
||||
result |= known_str[j] ^ user_str[j];
|
||||
}
|
||||
|
||||
RETURN_BOOL(0 == result);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Module Housekeeping */
|
||||
|
||||
static void php_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
|
||||
|
@ -1152,6 +1192,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_pbkdf2, 0, 0, 4)
|
|||
ZEND_ARG_INFO(0, raw_output)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_hash_equals, 0)
|
||||
ZEND_ARG_INFO(0, known_string)
|
||||
ZEND_ARG_INFO(0, user_string)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
/* BC Land */
|
||||
#ifdef PHP_MHASH_BC
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_mhash_get_block_size, 0)
|
||||
|
@ -1199,6 +1244,7 @@ const zend_function_entry hash_functions[] = {
|
|||
|
||||
PHP_FE(hash_algos, arginfo_hash_algos)
|
||||
PHP_FE(hash_pbkdf2, arginfo_hash_pbkdf2)
|
||||
PHP_FE(hash_equals, arginfo_hash_equals)
|
||||
|
||||
/* BC Land */
|
||||
#ifdef PHP_HASH_MD5_NOT_IN_CORE
|
||||
|
|
|
@ -136,6 +136,7 @@ PHP_FUNCTION(hash_update_file);
|
|||
PHP_FUNCTION(hash_final);
|
||||
PHP_FUNCTION(hash_algos);
|
||||
PHP_FUNCTION(hash_pbkdf2);
|
||||
PHP_FUNCTION(hash_equals);
|
||||
|
||||
PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len);
|
||||
PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops);
|
||||
|
|
43
ext/hash/tests/hash_equals.phpt
Normal file
43
ext/hash/tests/hash_equals.phpt
Normal file
|
@ -0,0 +1,43 @@
|
|||
--TEST--
|
||||
hash_equals() function
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(hash_equals("same", "same"));
|
||||
var_dump(hash_equals("not1same", "not2same"));
|
||||
var_dump(hash_equals("short", "longer"));
|
||||
var_dump(hash_equals("longer", "short"));
|
||||
var_dump(hash_equals("", "notempty"));
|
||||
var_dump(hash_equals("notempty", ""));
|
||||
var_dump(hash_equals("", ""));
|
||||
var_dump(hash_equals(123, "NaN"));
|
||||
var_dump(hash_equals("NaN", 123));
|
||||
var_dump(hash_equals(123, 123));
|
||||
var_dump(hash_equals(null, ""));
|
||||
var_dump(hash_equals(null, 123));
|
||||
var_dump(hash_equals(null, null));
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
|
||||
Warning: hash_equals(): Expected known_string to be a string, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: hash_equals(): Expected user_string to be a string, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: hash_equals(): Expected known_string to be a string, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
|
||||
bool(false)
|
|
@ -226,11 +226,10 @@ static PHP_INI_MH(OnUpdateInputEncoding)
|
|||
if (new_value_length >= ICONV_CSNMAXLEN) {
|
||||
return FAILURE;
|
||||
}
|
||||
if (new_value_length) {
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
} else {
|
||||
OnUpdateString(entry, PG(input_encoding), strlen(PG(input_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
|
||||
php_error_docref("ref.iconv" TSRMLS_CC, E_DEPRECATED, "Use of iconv.input_encoding is deprecated");
|
||||
}
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -240,11 +239,10 @@ static PHP_INI_MH(OnUpdateOutputEncoding)
|
|||
if(new_value_length >= ICONV_CSNMAXLEN) {
|
||||
return FAILURE;
|
||||
}
|
||||
if (new_value_length) {
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
} else {
|
||||
OnUpdateString(entry, PG(output_encoding), strlen(PG(output_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
|
||||
php_error_docref("ref.iconv" TSRMLS_CC, E_DEPRECATED, "Use of iconv.output_encoding is deprecated");
|
||||
}
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -254,11 +252,10 @@ static PHP_INI_MH(OnUpdateInternalEncoding)
|
|||
if(new_value_length >= ICONV_CSNMAXLEN) {
|
||||
return FAILURE;
|
||||
}
|
||||
if (new_value_length) {
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
} else {
|
||||
OnUpdateString(entry, PG(internal_encoding), strlen(PG(internal_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
|
||||
php_error_docref("ref.iconv" TSRMLS_CC, E_DEPRECATED, "Use of iconv.internal_encoding is deprecated");
|
||||
}
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -347,6 +344,40 @@ PHP_MINFO_FUNCTION(miconv)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static char *get_internal_encoding(TSRMLS_D) {
|
||||
if (ICONVG(internal_encoding) && ICONVG(internal_encoding)[0]) {
|
||||
return ICONVG(internal_encoding);
|
||||
} else if (PG(internal_encoding) && PG(internal_encoding)[0]) {
|
||||
return PG(internal_encoding);
|
||||
} else if (SG(default_charset)) {
|
||||
return SG(default_charset);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static char *get_input_encoding(TSRMLS_D) {
|
||||
if (ICONVG(input_encoding) && ICONVG(input_encoding)[0]) {
|
||||
return ICONVG(input_encoding);
|
||||
} else if (PG(input_encoding) && PG(input_encoding)[0]) {
|
||||
return PG(input_encoding);
|
||||
} else if (SG(default_charset)) {
|
||||
return SG(default_charset);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static char *get_output_encoding(TSRMLS_D) {
|
||||
if (ICONVG(output_encoding) && ICONVG(output_encoding)[0]) {
|
||||
return ICONVG(output_encoding);
|
||||
} else if (PG(output_encoding) && PG(output_encoding)[0]) {
|
||||
return PG(output_encoding);
|
||||
} else if (SG(default_charset)) {
|
||||
return SG(default_charset);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
static int php_iconv_output_conflict(const char *handler_name, size_t handler_name_len TSRMLS_DC)
|
||||
{
|
||||
if (php_output_get_level(TSRMLS_C)) {
|
||||
|
@ -388,12 +419,12 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
|
|||
|
||||
if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
|
||||
int len;
|
||||
char *p = strstr(ICONVG(output_encoding), "//");
|
||||
char *p = strstr(get_output_encoding(TSRMLS_C), "//");
|
||||
|
||||
if (p) {
|
||||
len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, (int)(p - ICONVG(output_encoding)), ICONVG(output_encoding));
|
||||
len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, (int)(p - get_output_encoding(TSRMLS_C)), get_output_encoding(TSRMLS_C));
|
||||
} else {
|
||||
len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, ICONVG(output_encoding));
|
||||
len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, get_output_encoding(TSRMLS_C));
|
||||
}
|
||||
if (content_type && SUCCESS == sapi_add_header(content_type, len, 0)) {
|
||||
SG(sapi_headers).send_default_content_type = 0;
|
||||
|
@ -404,7 +435,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
|
|||
|
||||
if (output_context->in.used) {
|
||||
output_context->out.free = 1;
|
||||
_php_iconv_show_error(php_iconv_string(output_context->in.data, output_context->in.used, &output_context->out.data, &output_context->out.used, ICONVG(output_encoding), ICONVG(internal_encoding)), ICONVG(output_encoding), ICONVG(internal_encoding) TSRMLS_CC);
|
||||
_php_iconv_show_error(php_iconv_string(output_context->in.data, output_context->in.used, &output_context->out.data, &output_context->out.used, get_output_encoding(TSRMLS_C), get_internal_encoding(TSRMLS_C)), get_output_encoding(TSRMLS_C), get_internal_encoding(TSRMLS_C) TSRMLS_CC);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
@ -1991,7 +2022,7 @@ static void _php_iconv_show_error(php_iconv_err_t err, const char *out_charset,
|
|||
Returns the character count of str */
|
||||
PHP_FUNCTION(iconv_strlen)
|
||||
{
|
||||
char *charset = ICONVG(internal_encoding);
|
||||
char *charset = get_internal_encoding(TSRMLS_C);
|
||||
int charset_len = 0;
|
||||
char *str;
|
||||
int str_len;
|
||||
|
@ -2024,7 +2055,7 @@ PHP_FUNCTION(iconv_strlen)
|
|||
Returns specified part of a string */
|
||||
PHP_FUNCTION(iconv_substr)
|
||||
{
|
||||
char *charset = ICONVG(internal_encoding);
|
||||
char *charset = get_internal_encoding(TSRMLS_C);
|
||||
int charset_len = 0;
|
||||
char *str;
|
||||
int str_len;
|
||||
|
@ -2064,7 +2095,7 @@ PHP_FUNCTION(iconv_substr)
|
|||
Finds position of first occurrence of needle within part of haystack beginning with offset */
|
||||
PHP_FUNCTION(iconv_strpos)
|
||||
{
|
||||
char *charset = ICONVG(internal_encoding);
|
||||
char *charset = get_internal_encoding(TSRMLS_C);
|
||||
int charset_len = 0;
|
||||
char *haystk;
|
||||
int haystk_len;
|
||||
|
@ -2112,7 +2143,7 @@ PHP_FUNCTION(iconv_strpos)
|
|||
Finds position of last occurrence of needle within part of haystack beginning with offset */
|
||||
PHP_FUNCTION(iconv_strrpos)
|
||||
{
|
||||
char *charset = ICONVG(internal_encoding);
|
||||
char *charset = get_internal_encoding(TSRMLS_C);
|
||||
int charset_len = 0;
|
||||
char *haystk;
|
||||
int haystk_len;
|
||||
|
@ -2163,7 +2194,7 @@ PHP_FUNCTION(iconv_mime_encode)
|
|||
smart_str retval = {0};
|
||||
php_iconv_err_t err;
|
||||
|
||||
const char *in_charset = ICONVG(internal_encoding);
|
||||
const char *in_charset = get_internal_encoding(TSRMLS_C);
|
||||
const char *out_charset = in_charset;
|
||||
long line_len = 76;
|
||||
const char *lfchars = "\r\n";
|
||||
|
@ -2276,7 +2307,7 @@ PHP_FUNCTION(iconv_mime_decode)
|
|||
{
|
||||
char *encoded_str;
|
||||
int encoded_str_len;
|
||||
char *charset = ICONVG(internal_encoding);
|
||||
char *charset = get_internal_encoding(TSRMLS_C);
|
||||
int charset_len = 0;
|
||||
long mode = 0;
|
||||
|
||||
|
@ -2317,7 +2348,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)
|
|||
{
|
||||
const char *encoded_str;
|
||||
int encoded_str_len;
|
||||
char *charset = ICONVG(internal_encoding);
|
||||
char *charset = get_internal_encoding(TSRMLS_C);
|
||||
int charset_len = 0;
|
||||
long mode = 0;
|
||||
|
||||
|
@ -2485,15 +2516,15 @@ PHP_FUNCTION(iconv_get_encoding)
|
|||
|
||||
if (!strcasecmp("all", type)) {
|
||||
array_init(return_value);
|
||||
add_assoc_string(return_value, "input_encoding", ICONVG(input_encoding), 1);
|
||||
add_assoc_string(return_value, "output_encoding", ICONVG(output_encoding), 1);
|
||||
add_assoc_string(return_value, "internal_encoding", ICONVG(internal_encoding), 1);
|
||||
add_assoc_string(return_value, "input_encoding", get_input_encoding(TSRMLS_C), 1);
|
||||
add_assoc_string(return_value, "output_encoding", get_output_encoding(TSRMLS_C), 1);
|
||||
add_assoc_string(return_value, "internal_encoding", get_internal_encoding(TSRMLS_C), 1);
|
||||
} else if (!strcasecmp("input_encoding", type)) {
|
||||
RETVAL_STRING(ICONVG(input_encoding), 1);
|
||||
RETVAL_STRING(get_input_encoding(TSRMLS_C), 1);
|
||||
} else if (!strcasecmp("output_encoding", type)) {
|
||||
RETVAL_STRING(ICONVG(output_encoding), 1);
|
||||
RETVAL_STRING(get_output_encoding(TSRMLS_C), 1);
|
||||
} else if (!strcasecmp("internal_encoding", type)) {
|
||||
RETVAL_STRING(ICONVG(internal_encoding), 1);
|
||||
RETVAL_STRING(get_internal_encoding(TSRMLS_C), 1);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
|
77
ext/iconv/tests/iconv_default_charset.phpt
Normal file
77
ext/iconv/tests/iconv_default_charset.phpt
Normal file
|
@ -0,0 +1,77 @@
|
|||
--TEST--
|
||||
Test default_charset handling
|
||||
--SKIPIF--
|
||||
<?php
|
||||
extension_loaded('iconv') or die('skip');
|
||||
function_exists('iconv_get_encoding') or die("skip iconv_get_encoding() is not available in this build");
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
default_charset=UTF-8
|
||||
internal_encoding=
|
||||
input_encoding=
|
||||
output_encoding=
|
||||
iconv.internal_encoding=
|
||||
iconv.input_encoding=
|
||||
iconv.output_encoding=
|
||||
--FILE--
|
||||
<?php
|
||||
echo "*** Testing default_charset handling ***\n";
|
||||
|
||||
echo "--- Get php.ini values ---\n";
|
||||
var_dump(ini_get('default_charset'),
|
||||
ini_get('internal_encoding'),
|
||||
ini_get('input_encoding'),
|
||||
ini_get('output_encoding'),
|
||||
ini_get('iconv.internal_encoding'),
|
||||
ini_get('iconv.input_encoding'),
|
||||
ini_get('iconv.output_encoding'));
|
||||
|
||||
echo "\n--- Altering encodings ---\n";
|
||||
var_dump(ini_set('default_charset', 'ISO-8859-1'));
|
||||
|
||||
echo "\n--- results of alterations ---\n";
|
||||
var_dump(ini_get('default_charset'),
|
||||
ini_get('internal_encoding'),
|
||||
ini_get('input_encoding'),
|
||||
ini_get('output_encoding'),
|
||||
ini_get('iconv.internal_encoding'),
|
||||
ini_get('iconv.input_encoding'),
|
||||
ini_get('iconv.output_encoding'));
|
||||
|
||||
/*
|
||||
echo "\n--- Altering encodings ---\n";
|
||||
var_dump(ini_set('default_charset', 'ISO-8859-1'),
|
||||
ini_set('internal_encoding'),
|
||||
ini_set('input_encoding'),
|
||||
ini_set('output_encoding'),
|
||||
ini_set('iconv.internal_encoding'),
|
||||
ini_set('iconv.input_encoding'),
|
||||
ini_set('iconv.output_encoding'));
|
||||
*/
|
||||
|
||||
echo "Done";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing default_charset handling ***
|
||||
--- Get php.ini values ---
|
||||
string(5) "UTF-8"
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
--- Altering encodings ---
|
||||
string(5) "UTF-8"
|
||||
|
||||
--- results of alterations ---
|
||||
string(10) "ISO-8859-1"
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
Done
|
|
@ -6,6 +6,7 @@ extension_loaded('iconv') or die('skip');
|
|||
function_exists('iconv_get_encoding') or die("skip iconv_get_encoding() is not available in this build");
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
iconv.input_encoding=ISO-8859-1
|
||||
iconv.internal_encoding=ISO-8859-1
|
||||
iconv.output_encoding=ISO-8859-1
|
||||
|
|
|
@ -5,6 +5,8 @@ Oystein Rose <orose@redpill-linpro.com>
|
|||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("iconv")) { echo 'skip extension not available'; } ?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ Encoding INI test
|
|||
--SKIPIF--
|
||||
<?php extension_loaded('iconv') or die('skip mbstring not available'); ?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
default_charset=ISO-8859-1
|
||||
internal_encoding=
|
||||
input_encoding=
|
||||
|
|
|
@ -5,6 +5,8 @@ Test iconv_set_encoding() function : error functionality
|
|||
extension_loaded('iconv') or die('skip');
|
||||
function_exists('iconv_set_encoding') or die("skip iconv_set_encoding() is not available in this build");
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool iconv_set_encoding(string type, string charset)
|
||||
|
|
|
@ -5,6 +5,8 @@ Test iconv_strpos() function : basic functionality
|
|||
extension_loaded('iconv') or die('skip');
|
||||
function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build");
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]])
|
||||
|
|
|
@ -5,6 +5,8 @@ Test iconv_strpos() function : usage variations - Pass different integers as $of
|
|||
extension_loaded('iconv') or die('skip');
|
||||
function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build");
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]])
|
||||
|
|
|
@ -5,6 +5,8 @@ Test iconv_strrpos() function : basic functionality
|
|||
extension_loaded('iconv') or die('skip');
|
||||
function_exists('iconv_strrpos') or die("skip iconv_strrpos() is not available in this build");
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset])
|
||||
|
|
|
@ -57,6 +57,8 @@ static inline void php_converter_throw_failure(php_converter_object *objval, UEr
|
|||
|
||||
/* {{{ php_converter_default_callback */
|
||||
static void php_converter_default_callback(zval *return_value, zval *zobj, long reason, zval *error TSRMLS_DC) {
|
||||
zval_dtor(error);
|
||||
ZVAL_LONG(error, U_ZERO_ERROR);
|
||||
/* Basic functionality so children can call parent::toUCallback() */
|
||||
switch (reason) {
|
||||
case UCNV_UNASSIGNED:
|
||||
|
@ -66,7 +68,16 @@ static void php_converter_default_callback(zval *return_value, zval *zobj, long
|
|||
php_converter_object *objval = (php_converter_object*)CONV_GET(zobj);
|
||||
char chars[127];
|
||||
int8_t chars_len = sizeof(chars);
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
UErrorCode uerror = U_ZERO_ERROR;
|
||||
if(!objval->src) {
|
||||
php_converter_throw_failure(objval, U_INVALID_STATE_ERROR TSRMLS_CC, "Source Converter has not been initialized yet");
|
||||
chars[0] = 0x1A;
|
||||
chars[1] = 0;
|
||||
chars_len = 1;
|
||||
ZVAL_LONG(error, U_INVALID_STATE_ERROR);
|
||||
RETVAL_STRINGL(chars, chars_len, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Yes, this is fairly wasteful at first glance,
|
||||
* but considering that the alternative is to store
|
||||
|
@ -75,18 +86,17 @@ static void php_converter_default_callback(zval *return_value, zval *zobj, long
|
|||
* I'd rather take the CPU hit here, than waste time
|
||||
* storing a value I'm unlikely to use.
|
||||
*/
|
||||
ucnv_getSubstChars(objval->src, chars, &chars_len, &error);
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(objval, "ucnv_getSubstChars", error);
|
||||
ucnv_getSubstChars(objval->src, chars, &chars_len, &uerror);
|
||||
if (U_FAILURE(uerror)) {
|
||||
THROW_UFAILURE(objval, "ucnv_getSubstChars", uerror);
|
||||
chars[0] = 0x1A;
|
||||
chars[1] = 0;
|
||||
chars_len = 1;
|
||||
ZVAL_LONG(error, uerror);
|
||||
}
|
||||
RETVAL_STRINGL(chars, chars_len, 1);
|
||||
}
|
||||
}
|
||||
zval_dtor(error);
|
||||
ZVAL_LONG(error, U_ZERO_ERROR);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -359,40 +359,40 @@ Formatted DateTime is : 20091231 03:02 PM
|
|||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'America/Los_Angeles',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : Saturday, December 30, 2000 5:04:05 PM GMT-10:00
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'America/Los_Angeles',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : December 30, 2000 5:04:05 PM GMT-10:00
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'America/Los_Angeles',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : Dec 30, 2000 5:04:05 PM
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'America/Los_Angeles',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : 12/30/00 5:04 PM
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'America/Los_Angeles',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : 20001230 05:04 PM
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
datefmt_format_code()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 && ICU < 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
423
ext/intl/tests/dateformat_format_variant3.phpt
Normal file
423
ext/intl/tests/dateformat_format_variant3.phpt
Normal file
|
@ -0,0 +1,423 @@
|
|||
--TEST--
|
||||
datefmt_format_code()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
//ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
/*
|
||||
* Test for the datefmt_format function
|
||||
*/
|
||||
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$timezone = 'GMT-10:00';
|
||||
|
||||
$locale_arr = array (
|
||||
'en_US'
|
||||
);
|
||||
|
||||
$datetype_arr = array (
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::LONG,
|
||||
IntlDateFormatter::MEDIUM,
|
||||
IntlDateFormatter::SHORT,
|
||||
IntlDateFormatter::NONE
|
||||
);
|
||||
|
||||
$res_str = '';
|
||||
|
||||
|
||||
$time_arr = array (
|
||||
0,
|
||||
-1200000,
|
||||
1200000,
|
||||
2200000000.0,
|
||||
-2200000000.0,
|
||||
90099999,
|
||||
3600,
|
||||
-3600
|
||||
);
|
||||
|
||||
$localtime_arr1 = array (
|
||||
'tm_sec' => 24 ,
|
||||
'tm_min' => 3,
|
||||
'tm_hour' => 19,
|
||||
'tm_mday' => 3,
|
||||
'tm_mon' => 3,
|
||||
'tm_year' => 105,
|
||||
);
|
||||
$localtime_arr2 = array (
|
||||
'tm_sec' => 21,
|
||||
'tm_min' => 5,
|
||||
'tm_hour' => 7,
|
||||
'tm_mday' => 13,
|
||||
'tm_mon' => 4,
|
||||
'tm_year' => 205,
|
||||
);
|
||||
$localtime_arr3 = array (
|
||||
'tm_sec' => 11,
|
||||
'tm_min' => 13,
|
||||
'tm_hour' => 0,
|
||||
'tm_mday' => 17,
|
||||
'tm_mon' => 11,
|
||||
'tm_year' => -5
|
||||
);
|
||||
|
||||
$localtime_arr = array (
|
||||
$localtime_arr1,
|
||||
$localtime_arr2,
|
||||
$localtime_arr3
|
||||
);
|
||||
|
||||
$d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC"));
|
||||
$d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC"));
|
||||
$d2->setTimezone(new DateTimeZone("PDT"));
|
||||
$dates = array(
|
||||
$d1,
|
||||
$d2,
|
||||
new StdClass(),
|
||||
);
|
||||
|
||||
//Test format with input as a timestamp : integer
|
||||
foreach( $time_arr as $timestamp_entry){
|
||||
$res_str .= "\n------------\n";
|
||||
$res_str .= "\nInput timestamp is : $timestamp_entry";
|
||||
$res_str .= "\n------------\n";
|
||||
foreach( $locale_arr as $locale_entry ){
|
||||
foreach( $datetype_arr as $datetype_entry )
|
||||
{
|
||||
$res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry ";
|
||||
$fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN);
|
||||
$formatted = ut_datefmt_format( $fmt , $timestamp_entry);
|
||||
$res_str .= "\nFormatted timestamp is : $formatted";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Test format with input as a localtime :array
|
||||
foreach( $localtime_arr as $localtime_entry){
|
||||
$res_str .= "\n------------\n";
|
||||
$res_str .= "\nInput localtime is : ";
|
||||
foreach( $localtime_entry as $key => $value){
|
||||
$res_str .= "$key : '$value' , ";
|
||||
}
|
||||
|
||||
$res_str .= "\n------------\n";
|
||||
foreach( $locale_arr as $locale_entry ){
|
||||
foreach( $datetype_arr as $datetype_entry )
|
||||
{
|
||||
$res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry ";
|
||||
$fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN );
|
||||
$formatted1 = ut_datefmt_format( $fmt , $localtime_entry);
|
||||
if( intl_get_error_code() == U_ZERO_ERROR){
|
||||
$res_str .= "\nFormatted localtime_array is : $formatted1";
|
||||
}else{
|
||||
$res_str .= "\nError while formatting as: '".intl_get_error_message()."'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($dates as $date_entry) {
|
||||
foreach( $locale_arr as $locale_entry ){
|
||||
foreach( $datetype_arr as $datetype_entry ) {
|
||||
$res_str .= "\n------------";
|
||||
$res_str .= "\nDate is: ".var_export($date_entry, true);
|
||||
$res_str .= "\n------------";
|
||||
|
||||
$fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN );
|
||||
$formatted1 = ut_datefmt_format( $fmt , $date_entry);
|
||||
if( intl_get_error_code() == U_ZERO_ERROR){
|
||||
$res_str .= "\nFormatted DateTime is : $formatted1";
|
||||
}else{
|
||||
$res_str .= "\nError while formatting as: '".intl_get_error_message()."'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
------------
|
||||
|
||||
Input timestamp is : 0
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Wednesday, December 31, 1969 at 2:00:00 PM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : December 31, 1969 at 2:00:00 PM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Dec 31, 1969, 2:00:00 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted timestamp is : 12/31/69, 2:00 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted timestamp is : 19691231 02:00 PM
|
||||
------------
|
||||
|
||||
Input timestamp is : -1200000
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Wednesday, December 17, 1969 at 4:40:00 PM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : December 17, 1969 at 4:40:00 PM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Dec 17, 1969, 4:40:00 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted timestamp is : 12/17/69, 4:40 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted timestamp is : 19691217 04:40 PM
|
||||
------------
|
||||
|
||||
Input timestamp is : 1200000
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Wednesday, January 14, 1970 at 11:20:00 AM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : January 14, 1970 at 11:20:00 AM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Jan 14, 1970, 11:20:00 AM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted timestamp is : 1/14/70, 11:20 AM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted timestamp is : 19700114 11:20 AM
|
||||
------------
|
||||
|
||||
Input timestamp is : 2200000000
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Sunday, September 18, 2039 at 1:06:40 PM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : September 18, 2039 at 1:06:40 PM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Sep 18, 2039, 1:06:40 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted timestamp is : 9/18/39, 1:06 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted timestamp is : 20390918 01:06 PM
|
||||
------------
|
||||
|
||||
Input timestamp is : -2200000000
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Saturday, April 14, 1900 at 2:53:20 PM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : April 14, 1900 at 2:53:20 PM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Apr 14, 1900, 2:53:20 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted timestamp is : 4/14/00, 2:53 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted timestamp is : 19000414 02:53 PM
|
||||
------------
|
||||
|
||||
Input timestamp is : 90099999
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Wednesday, November 8, 1972 at 9:46:39 AM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : November 8, 1972 at 9:46:39 AM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Nov 8, 1972, 9:46:39 AM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted timestamp is : 11/8/72, 9:46 AM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted timestamp is : 19721108 09:46 AM
|
||||
------------
|
||||
|
||||
Input timestamp is : 3600
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Wednesday, December 31, 1969 at 3:00:00 PM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : December 31, 1969 at 3:00:00 PM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Dec 31, 1969, 3:00:00 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted timestamp is : 12/31/69, 3:00 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted timestamp is : 19691231 03:00 PM
|
||||
------------
|
||||
|
||||
Input timestamp is : -3600
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Wednesday, December 31, 1969 at 1:00:00 PM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : December 31, 1969 at 1:00:00 PM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Dec 31, 1969, 1:00:00 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted timestamp is : 12/31/69, 1:00 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted timestamp is : 19691231 01:00 PM
|
||||
------------
|
||||
|
||||
Input localtime is : tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_mday : '3' , tm_mon : '3' , tm_year : '105' ,
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted localtime_array is : Sunday, April 3, 2005 at 7:03:24 PM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted localtime_array is : April 3, 2005 at 7:03:24 PM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted localtime_array is : Apr 3, 2005, 7:03:24 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted localtime_array is : 4/3/05, 7:03 PM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted localtime_array is : 20050403 07:03 PM
|
||||
------------
|
||||
|
||||
Input localtime is : tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_mday : '13' , tm_mon : '4' , tm_year : '205' ,
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted localtime_array is : Wednesday, May 13, 2105 at 7:05:21 AM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted localtime_array is : May 13, 2105 at 7:05:21 AM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted localtime_array is : May 13, 2105, 7:05:21 AM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted localtime_array is : 5/13/05, 7:05 AM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted localtime_array is : 21050513 07:05 AM
|
||||
------------
|
||||
|
||||
Input localtime is : tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_mday : '17' , tm_mon : '11' , tm_year : '-5' ,
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted localtime_array is : Tuesday, December 17, 1895 at 12:13:11 AM GMT-10:00
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted localtime_array is : December 17, 1895 at 12:13:11 AM GMT-10
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted localtime_array is : Dec 17, 1895, 12:13:11 AM
|
||||
IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3
|
||||
Formatted localtime_array is : 12/17/95, 12:13 AM
|
||||
IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1
|
||||
Formatted localtime_array is : 18951217 12:13 AM
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2010-01-01 01:02:03',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'UTC',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : Thursday, December 31, 2009 at 3:02:03 PM GMT-10:00
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2010-01-01 01:02:03',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'UTC',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : December 31, 2009 at 3:02:03 PM GMT-10
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2010-01-01 01:02:03',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'UTC',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : Dec 31, 2009, 3:02:03 PM
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2010-01-01 01:02:03',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'UTC',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : 12/31/09, 3:02 PM
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2010-01-01 01:02:03',
|
||||
'timezone_type' => 3,
|
||||
'timezone' => 'UTC',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : 20091231 03:02 PM
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : Saturday, December 30, 2000 at 5:04:05 PM GMT-10:00
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : December 30, 2000 at 5:04:05 PM GMT-10
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : Dec 30, 2000, 5:04:05 PM
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : 12/30/00, 5:04 PM
|
||||
------------
|
||||
Date is: DateTime::__set_state(array(
|
||||
'date' => '2000-12-30 19:04:05',
|
||||
'timezone_type' => 2,
|
||||
'timezone' => 'PDT',
|
||||
))
|
||||
------------
|
||||
Formatted DateTime is : 20001230 05:04 PM
|
||||
------------
|
||||
Date is: stdClass::__set_state(array(
|
||||
))
|
||||
------------
|
||||
Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR'
|
||||
------------
|
||||
Date is: stdClass::__set_state(array(
|
||||
))
|
||||
------------
|
||||
Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR'
|
||||
------------
|
||||
Date is: stdClass::__set_state(array(
|
||||
))
|
||||
------------
|
||||
Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR'
|
||||
------------
|
||||
Date is: stdClass::__set_state(array(
|
||||
))
|
||||
------------
|
||||
Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR'
|
||||
------------
|
||||
Date is: stdClass::__set_state(array(
|
||||
))
|
||||
------------
|
||||
Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR'
|
|
@ -26,7 +26,7 @@ do_test(IntlTimeZone::createTimeZone('GMT+0405'), true);
|
|||
--EXPECTF--
|
||||
string(3) "CET"
|
||||
int(3600000)
|
||||
string(13) "Europe/Berlin"
|
||||
string(%d) "%rEurope\/Berlin|CET%r"
|
||||
int(3600)
|
||||
string(16) "Europe/Amsterdam"
|
||||
int(3600000)
|
||||
|
|
11
ext/intl/tests/uconverter_bug66873.phpt
Normal file
11
ext/intl/tests/uconverter_bug66873.phpt
Normal file
|
@ -0,0 +1,11 @@
|
|||
--TEST--
|
||||
Bug #66873 - crash in UConverter with invalid encoding
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$o = new UConverter(1, 1);
|
||||
$o->toUCallback(1, 1, 1, $b);
|
||||
var_dump($o->getErrorCode());
|
||||
--EXPECT--
|
||||
int(27)
|
|
@ -601,6 +601,34 @@ static sapi_post_entry php_post_entries[] = {
|
|||
ZEND_GET_MODULE(mbstring)
|
||||
#endif
|
||||
|
||||
static char *get_internal_encoding(TSRMLS_D) {
|
||||
if (PG(internal_encoding) && PG(internal_encoding)[0]) {
|
||||
return PG(internal_encoding);
|
||||
} else if (SG(default_charset)) {
|
||||
return SG(default_charset);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static char *get_input_encoding(TSRMLS_D) {
|
||||
if (PG(input_encoding) && PG(input_encoding)[0]) {
|
||||
return PG(input_encoding);
|
||||
} else if (SG(default_charset)) {
|
||||
return SG(default_charset);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static char *get_output_encoding(TSRMLS_D) {
|
||||
if (PG(output_encoding) && PG(output_encoding)[0]) {
|
||||
return PG(output_encoding);
|
||||
} else if (SG(default_charset)) {
|
||||
return SG(default_charset);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/* {{{ allocators */
|
||||
static void *_php_mb_allocators_malloc(unsigned int sz)
|
||||
{
|
||||
|
@ -1236,9 +1264,9 @@ static PHP_INI_MH(OnUpdate_mbstring_http_input)
|
|||
if (MBSTRG(http_input_list)) {
|
||||
pefree(MBSTRG(http_input_list), 1);
|
||||
}
|
||||
if (SUCCESS == php_mb_parse_encoding_list(PG(input_encoding), strlen(PG(input_encoding))+1, &list, &size, 1 TSRMLS_CC)) {
|
||||
if (SUCCESS == php_mb_parse_encoding_list(get_input_encoding(TSRMLS_C), strlen(get_input_encoding(TSRMLS_C))+1, &list, &size, 1 TSRMLS_CC)) {
|
||||
MBSTRG(http_input_list) = list;
|
||||
MBSTRG(http_input_list_size) = 0;
|
||||
MBSTRG(http_input_list_size) = size;
|
||||
return SUCCESS;
|
||||
}
|
||||
MBSTRG(http_input_list) = NULL;
|
||||
|
@ -1256,6 +1284,10 @@ static PHP_INI_MH(OnUpdate_mbstring_http_input)
|
|||
MBSTRG(http_input_list) = list;
|
||||
MBSTRG(http_input_list_size) = size;
|
||||
|
||||
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
|
||||
php_error_docref("ref.mbstring" TSRMLS_CC, E_DEPRECATED, "Use of mbstring.http_input is deprecated");
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1266,7 +1298,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output)
|
|||
const mbfl_encoding *encoding;
|
||||
|
||||
if (new_value == NULL || new_value_length == 0) {
|
||||
encoding = mbfl_name2encoding(PG(output_encoding));
|
||||
encoding = mbfl_name2encoding(get_output_encoding(TSRMLS_C));
|
||||
if (!encoding) {
|
||||
MBSTRG(http_output_encoding) = &mbfl_encoding_pass;
|
||||
MBSTRG(current_http_output_encoding) = &mbfl_encoding_pass;
|
||||
|
@ -1282,6 +1314,11 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output)
|
|||
}
|
||||
MBSTRG(http_output_encoding) = encoding;
|
||||
MBSTRG(current_http_output_encoding) = encoding;
|
||||
|
||||
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
|
||||
php_error_docref("ref.mbstring" TSRMLS_CC, E_DEPRECATED, "Use of mbstring.http_output is deprecated");
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1315,15 +1352,19 @@ int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_v
|
|||
/* {{{ static PHP_INI_MH(OnUpdate_mbstring_internal_encoding) */
|
||||
static PHP_INI_MH(OnUpdate_mbstring_internal_encoding)
|
||||
{
|
||||
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
|
||||
php_error_docref("ref.mbstring" TSRMLS_CC, E_DEPRECATED, "Use of mbstring.internal_encoding is deprecated");
|
||||
}
|
||||
|
||||
if (OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC) == FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
if (stage == PHP_INI_STAGE_STARTUP || stage == PHP_INI_STAGE_SHUTDOWN
|
||||
|| stage == PHP_INI_STAGE_RUNTIME) {
|
||||
|
||||
if (stage & (PHP_INI_STAGE_STARTUP | PHP_INI_STAGE_SHUTDOWN | PHP_INI_STAGE_RUNTIME)) {
|
||||
if (new_value_length) {
|
||||
return _php_mb_ini_mbstring_internal_encoding_set(new_value, new_value_length TSRMLS_CC);
|
||||
} else {
|
||||
return _php_mb_ini_mbstring_internal_encoding_set(PG(internal_encoding), strlen(PG(internal_encoding))+1 TSRMLS_CC);
|
||||
return _php_mb_ini_mbstring_internal_encoding_set(get_internal_encoding(TSRMLS_C), strlen(get_internal_encoding(TSRMLS_C))+1 TSRMLS_CC);
|
||||
}
|
||||
} else {
|
||||
/* the corresponding mbstring globals needs to be set according to the
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
History
|
||||
|
||||
2013/10/21: Version 5.9.5
|
||||
|
||||
2013/10/21: [impl] escape warnings for -Wall. (regparse.c)
|
||||
2013/10/21: [bug] fixes an issue on Windows x64. (thanks Anatoliy Belsky)
|
||||
The issue was discovered in PHP, see https://bugs.php.net/64769.
|
||||
2013/10/21: [impl] remove unused variable. (regcomp.c)
|
||||
|
||||
2013/04/04: Version 5.9.4
|
||||
|
||||
2013/04/04: [dev] remove Makefile.in from git repository.
|
||||
2013/04/04: [dist] add oniguruma.pc.in file. (for pkg-config)
|
||||
(thanks Giulio Paci)
|
||||
|
||||
2012/10/26: Version 5.9.3
|
||||
|
||||
2012/10/15: remove warnings "test: =: unary operator expected" in ./configure.
|
||||
(thanks t_okazaki)
|
||||
2012/10/15: fix print_tree ENCLOSE_OPTION bug. (thanks Suraj N. Kurapati)
|
||||
|
||||
2010/01/09: Version 5.9.2
|
||||
|
||||
2010/01/05: [bug] fix utf16be_code_to_mbc() and utf16le_code_to_mbc().
|
||||
|
@ -878,7 +897,7 @@ History
|
|||
2004/10/18: [impl] (thanks Imai Yasumasa)
|
||||
enclose #include <sys/types.h> by #ifndef __BORLANDC__.
|
||||
2004/10/18: [bug] (thanks Imai Yasumasa)
|
||||
memory access violation in select_opt_exact_info().
|
||||
memory acess violation in select_opt_exact_info().
|
||||
2004/09/25: [dist] fix doc/API and doc/API.ja.
|
||||
2004/09/25: [bug] fix OP_SEMI_END_BUF process in match_at() for
|
||||
the case USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
|
||||
|
@ -1812,7 +1831,7 @@ History
|
|||
2003/01/31: [impl] rename TTRANS() to TOLOWER().
|
||||
2003/01/30: [bug] .c.o --> .c.obj in win32\Makefile.
|
||||
2003/01/30: [impl] add -DNOT_RUBY to Makefile.in.
|
||||
NOT_RUBY is referred in regint.h for escape double
|
||||
NOT_RUBY is refered in regint.h for escape double
|
||||
including config.h.
|
||||
2003/01/30: [impl] when string hasn't case ambiguity, don't compile
|
||||
to ignore case opcode.
|
||||
|
|
|
@ -57,6 +57,10 @@
|
|||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
|
@ -72,21 +76,24 @@
|
|||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* The size of a `int', as computed by sizeof. */
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#undef SIZEOF_INT
|
||||
|
||||
/* The size of a `long', as computed by sizeof. */
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#undef SIZEOF_LONG
|
||||
|
||||
/* The size of a `short', as computed by sizeof. */
|
||||
/* The size of `short', as computed by sizeof. */
|
||||
#undef SIZEOF_SHORT
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
|
@ -101,8 +108,14 @@
|
|||
/* Define if combination explosion check */
|
||||
#undef USE_COMBINATION_EXPLOSION_CHECK
|
||||
|
||||
/* Define if enable CR+NL as line terminator */
|
||||
#undef USE_CRNL_AS_LINE_TERMINATOR
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<h1>Oniguruma</h1> (<a href="index_ja.html">Japanese</a>)
|
||||
|
||||
<p>
|
||||
(c) K.Kosako, updated at: 2010/01/09
|
||||
(c) K.Kosako, updated at: 2013/10/21
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<dt><b>What's new</b>
|
||||
</font>
|
||||
<ul>
|
||||
<li>2010/01/09: Version 5.9.2 released.</li>
|
||||
<li>2013/10/21: Version 5.9.5 released.</li>
|
||||
<li>2007/08/16: Version 4.7.1 released.</li>
|
||||
<li>2007/06/20: Version 2.5.9 released.</li>
|
||||
<li>2007/06/20: Maintainer of 2.x was changed.</li>
|
||||
|
@ -62,8 +62,8 @@ ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16<br>
|
|||
|
||||
<dt><b>Download:</b>
|
||||
<ul>
|
||||
<li> <a href="archive/onig-5.9.2.tar.gz">Latest release version 5.9.2</a> (2010/01/09) <a href="HISTORY_5X.txt">Change Log</a>
|
||||
<li> <a href="archive/onig-5.9.1.tar.gz">5.9.1</a> (2007/12/22)
|
||||
<li> <a href="archive/onig-5.9.5.tar.gz">Latest release version 5.9.5</a> (2013/10/21) <a href="HISTORY_5X.txt">Change Log</a>
|
||||
<li> <a href="archive/onig-5.9.4.tar.gz">5.9.4</a> (2013/04/04)
|
||||
<li> <a href="archive/onig-4.7.1.tar.gz">Latest release version 4.7.1</a> (2007/08/16) <a href="HISTORY_4X.txt">Change Log</a>
|
||||
<li> <a href="archive/onig-4.7.0.tar.gz">4.7.0</a> (2007/06/18)
|
||||
<li> <a href="archive/onigd2_5_9.tar.gz">Latest release version 2.5.9</a> (2007/06/20) <a href="HISTORY_2X.txt">Change Log</a>
|
||||
|
@ -78,7 +78,7 @@ About 2.x, please contact him.<br>
|
|||
* 2.x supports Ruby1.6/1.8.<br>
|
||||
|
||||
<br>
|
||||
<dt><b>Documents:</b> (version 5.9.2)
|
||||
<dt><b>Documents:</b> (version 5.9.5)
|
||||
<ul>
|
||||
<li> <a href="doc/RE.txt">Regular Expressions</a>
|
||||
<a href="doc/RE.ja.txt">(Japanese: EUC-JP)</a>
|
||||
|
@ -103,8 +103,11 @@ About 2.x, please contact him.<br>
|
|||
<br>
|
||||
<dt><b>Links:</b>
|
||||
<ul>
|
||||
<li> <a href="http://www.perzl.org/aix/index.php?n=Main.Oniguruma">AIX Open Source Packages</a>
|
||||
<li> <a href="https://aur.archlinux.org/packages/oniguruma/">Arch Linux Package</a>
|
||||
<li> <a href="http://homepage3.nifty.com/k-takata/mysoft/bregonig.html">bregonig.dll (Win32)</a> (Japanese page)
|
||||
<li> <a href="http://www.halbiz.com/osaru/cnregex.html">cnRegex 4D Plugin (Mac OS X)</a> (Japanese page)
|
||||
<li> <a href="http://limechat.net/cocoaoniguruma/">CocoaOniguruma</a>
|
||||
<li> <a href="http://kmaebashi.com/">crowbar</a> (Japanese page)
|
||||
<li> <a href="http://oniguruma5.darwinports.com">Darwin Ports (Mac OS X)</a>
|
||||
<li> <a href="http://homepage2.nifty.com/Km/onig.htm">Delphi interface (Win32)</a> (Japanese page)
|
||||
|
@ -121,7 +124,7 @@ About 2.x, please contact him.<br>
|
|||
<li> <a href="http://mongoose.jp/">mongoose</a> (Japanese page)
|
||||
<li> <a href="http://www.irori.org/tool/mregexp.html">mregexp</a> (Japanese page)
|
||||
<li> <a href="http://ochusha.sourceforge.jp/">Ochusha</a> (Japanese page)
|
||||
<li> <a href="http://www8.ocn.ne.jp/%7esonoisa/OgreKit/index.html">OgreKit (Mac OS X)</a> Regular Expression Framework for Cocoa (Japanese page)
|
||||
<li> <a href="http://sonoisa.github.com/ogrekit/About_%28English%29.html">OgreKit (Mac OS X)</a> Regular Expression Framework for Cocoa (Japanese page)
|
||||
<li> <a href="http://www.kanetaka.net/4dapi/wiki4d.dll/4dcgi/wiki.cgi?plugins-oniguruma">OnigRegexp</a> (Japanese page)
|
||||
<li> <a href="http://rubyforge.org/projects/oniguruma">Oniguruma for Ruby</a>
|
||||
<li> <a href="http://openspace.timedia.co.jp/~yasuyuki/wiliki/wiliki.cgi?Oniguruma-mysqld&l=jp">Oniguruma-mysqld</a>
|
||||
|
@ -140,6 +143,7 @@ About 2.x, please contact him.<br>
|
|||
<li> <a href="http://sourceforge.jp/projects/ttssh2/">TeraTerm (Win32)</a>
|
||||
<li> <a href="http://www8.ocn.ne.jp/~sonoisa/TiddlyWikiPod/">TiddlyWikiPod (Mac OS X)</a>
|
||||
<li> <a href="http://www.cyanworks.net/mac.html">TunesTEXT (Mac OS X)</a>
|
||||
<li> <a href="https://code.google.com/p/oniguruma-visualworks/">oniguruma-visualworks</a>
|
||||
<li> <a href="http://sourceforge.jp/projects/frogger/">XML parser</a>
|
||||
<li> <a href="http://www.yokkasoft.net/">YokkaSoft (Win32)</a> (Japanese page)
|
||||
<li> <a href="http://www.hi-ho.ne.jp/kuze/tool.htm">Zed (Win32)</a> (Japanese page)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<h1>鬼車</h1>
|
||||
|
||||
<p>
|
||||
(c) K.Kosako, 最終更新: 2010/01/09
|
||||
(c) K.Kosako, 最終更新: 2013/04/04
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<dt><b>更新情報</b>
|
||||
</font>
|
||||
<ul>
|
||||
<li>2010/01/09: Version 5.9.2 リリース</li>
|
||||
<li>2013/10/21: Version 5.9.5 リリース</li>
|
||||
<li>2007/08/16: Version 4.7.1 リリース</li>
|
||||
<li>2007/06/20: Version 2.5.9 リリース</li>
|
||||
<li>2007/06/20: 2.xの保守担当者を変更</li>
|
||||
|
@ -62,8 +62,8 @@ ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16<br>
|
|||
|
||||
<dt><b>ダウンロード:</b>
|
||||
<ul>
|
||||
<li> <a href="archive/onig-5.9.2.tar.gz">5.9.2 最新版</a> (2010/01/09) <a href="HISTORY_5X.txt">更新履歴</a>
|
||||
<li> <a href="archive/onig-5.9.1.tar.gz">5.9.1</a> (2007/12/22)
|
||||
<li> <a href="archive/onig-5.9.5.tar.gz">5.9.5 最新版</a> (2013/10/21) <a href="HISTORY_5X.txt">更新履歴</a>
|
||||
<li> <a href="archive/onig-5.9.4.tar.gz">5.9.4</a> (2013/04/04)
|
||||
<li> <a href="archive/onig-4.7.1.tar.gz">4.7.1 最新版</a> (2007/08/16) <a href="HISTORY_4X.txt">更新履歴</a>
|
||||
<li> <a href="archive/onig-4.7.0.tar.gz">4.7.0</a> (2007/06/18)
|
||||
<li> <a href="archive/onigd2_5_9.tar.gz">2.5.9 最新版</a> (2007/06/20) <a href="HISTORY_2X.txt">更新履歴</a>
|
||||
|
@ -78,7 +78,7 @@ ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16<br>
|
|||
* 2.xはRuby1.6/1.8組込みライブラリとして動作する。 (2006年末で保守を終了)<br>
|
||||
|
||||
<br>
|
||||
<dt><b>ドキュメント:</b> (version 5.9.2)
|
||||
<dt><b>ドキュメント:</b> (version 5.9.5)
|
||||
<ul>
|
||||
<li> <a href="doc/RE.txt">正規表現</a>
|
||||
<a href="doc/RE.ja.txt">(日本語: EUC-JP)</a>
|
||||
|
@ -103,8 +103,11 @@ ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16<br>
|
|||
<br>
|
||||
<dt><b>リンク:</b>
|
||||
<ul>
|
||||
<li> <a href="http://www.perzl.org/aix/index.php?n=Main.Oniguruma">AIX Open Source Packages</a>
|
||||
<li> <a href="https://aur.archlinux.org/packages/oniguruma/">Arch Linux Package</a>
|
||||
<li> <a href="http://homepage3.nifty.com/k-takata/mysoft/bregonig.html">bregonig.dll (Win32)</a> (日本語)
|
||||
<li> <a href="http://www.halbiz.com/osaru/cnregex.html">cnRegex 4D Plugin (Mac OS X)</a> (日本語)
|
||||
<li> <a href="http://limechat.net/cocoaoniguruma/index_ja.html">CocoaOniguruma</a> (日本語)
|
||||
<li> <a href="http://kmaebashi.com/">crowbar</a> (日本語)
|
||||
<li> <a href="http://oniguruma5.darwinports.com">Darwin Ports (Mac OS X)</a>
|
||||
<li> <a href="http://homepage2.nifty.com/Km/onig.htm">Delphi interface (Win32)</a> (日本語)
|
||||
|
@ -121,7 +124,7 @@ ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16<br>
|
|||
<li> <a href="http://mongoose.jp/">mongoose</a> (日本語)
|
||||
<li> <a href="http://www.irori.org/tool/mregexp.html">mregexp</a> (日本語)
|
||||
<li> <a href="http://ochusha.sourceforge.jp/">おちゅ〜しゃ</a> (日本語)
|
||||
<li> <a href="http://www8.ocn.ne.jp/%7esonoisa/OgreKit/index.html">OgreKit (Mac OS X)</a> Regular Expression Framework for Cocoa (日本語)
|
||||
<li> <a href="http://sonoisa.github.com/ogrekit/About.html">OgreKit (Mac OS X)</a> Regular Expression Framework for Cocoa (日本語)
|
||||
<li> <a href="http://www.kanetaka.net/4dapi/wiki4d.dll/4dcgi/wiki.cgi?plugins-oniguruma">OnigRegexp</a> (日本語)
|
||||
<li> <a href="http://rubyforge.org/projects/oniguruma">Oniguruma for Ruby</a>
|
||||
<li> <a href="http://openspace.timedia.co.jp/~yasuyuki/wiliki/wiliki.cgi?Oniguruma-mysqld&l=jp">Oniguruma-mysqld</a>
|
||||
|
@ -140,6 +143,7 @@ ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16<br>
|
|||
<li> <a href="http://sourceforge.jp/projects/ttssh2/">TeraTerm (Win32)</a>
|
||||
<li> <a href="http://www8.ocn.ne.jp/~sonoisa/TiddlyWikiPod/">TiddlyWikiPod (Mac OS X)</a>
|
||||
<li> <a href="http://www.cyanworks.net/mac.html">TunesTEXT (Mac OS X)</a>
|
||||
<li> <a href="https://code.google.com/p/oniguruma-visualworks/">oniguruma-visualworks</a>
|
||||
<li> <a href="http://sourceforge.jp/projects/frogger/">XML parser</a>
|
||||
<li> <a href="http://www.yokkasoft.net/">YokkaSoft (Win32)</a> (日本語)
|
||||
<li> <a href="http://www.hi-ho.ne.jp/kuze/tool.htm">Zed (Win32)</a> (日本語)
|
||||
|
|
|
@ -1,310 +0,0 @@
|
|||
/**********************************************************************
|
||||
|
||||
onigcmpt200.h - Oniguruma (regular expression library)
|
||||
|
||||
Copyright (C) 2004 K.Kosako (kosako@sofnec.co.jp)
|
||||
|
||||
**********************************************************************/
|
||||
#ifndef ONIGCMPT200_H
|
||||
#define ONIGCMPT200_H
|
||||
|
||||
/* constants */
|
||||
#define REG_MAX_ERROR_MESSAGE_LEN ONIG_MAX_ERROR_MESSAGE_LEN
|
||||
|
||||
#define RegCharEncoding OnigEncoding
|
||||
|
||||
#define REG_ENCODING_ASCII ONIG_ENCODING_ASCII
|
||||
#define REG_ENCODING_ISO_8859_1 ONIG_ENCODING_ISO_8859_1
|
||||
#define REG_ENCODING_ISO_8859_15 ONIG_ENCODING_ISO_8859_15
|
||||
#define REG_ENCODING_UTF8 ONIG_ENCODING_UTF8
|
||||
#define REG_ENCODING_EUC_JP ONIG_ENCODING_EUC_JP
|
||||
#define REG_ENCODING_SJIS ONIG_ENCODING_SJIS
|
||||
#define REG_ENCODING_BIG5 ONIG_ENCODING_BIG5
|
||||
#define REG_ENCODING_UNDEF ONIG_ENCODING_UNDEF
|
||||
|
||||
/* Don't use REGCODE_XXXX. (obsoleted) */
|
||||
#define REGCODE_UNDEF REG_ENCODING_UNDEF
|
||||
#define REGCODE_ASCII REG_ENCODING_ASCII
|
||||
#define REGCODE_UTF8 REG_ENCODING_UTF8
|
||||
#define REGCODE_EUCJP REG_ENCODING_EUC_JP
|
||||
#define REGCODE_SJIS REG_ENCODING_SJIS
|
||||
|
||||
/* Don't use REGCODE_XXXX. (obsoleted) */
|
||||
#define MBCTYPE_ASCII RE_MBCTYPE_ASCII
|
||||
#define MBCTYPE_EUC RE_MBCTYPE_EUC
|
||||
#define MBCTYPE_SJIS RE_MBCTYPE_SJIS
|
||||
#define MBCTYPE_UTF8 RE_MBCTYPE_UTF8
|
||||
|
||||
typedef unsigned char* RegTransTableType;
|
||||
#define RegOptionType OnigOptionType
|
||||
#define RegDistance OnigDistance
|
||||
|
||||
#define REG_OPTION_DEFAULT ONIG_OPTION_DEFAULT
|
||||
|
||||
/* options */
|
||||
#define REG_OPTION_NONE ONIG_OPTION_NONE
|
||||
#define REG_OPTION_SINGLELINE ONIG_OPTION_SINGLELINE
|
||||
#define REG_OPTION_MULTILINE ONIG_OPTION_MULTILINE
|
||||
#define REG_OPTION_IGNORECASE ONIG_OPTION_IGNORECASE
|
||||
#define REG_OPTION_EXTEND ONIG_OPTION_EXTEND
|
||||
#define REG_OPTION_FIND_LONGEST ONIG_OPTION_FIND_LONGEST
|
||||
#define REG_OPTION_FIND_NOT_EMPTY ONIG_OPTION_FIND_NOT_EMPTY
|
||||
#define REG_OPTION_NEGATE_SINGLELINE ONIG_OPTION_NEGATE_SINGLELINE
|
||||
#define REG_OPTION_DONT_CAPTURE_GROUP ONIG_OPTION_DONT_CAPTURE_GROUP
|
||||
#define REG_OPTION_CAPTURE_GROUP ONIG_OPTION_CAPTURE_GROUP
|
||||
#define REG_OPTION_NOTBOL ONIG_OPTION_NOTBOL
|
||||
#define REG_OPTION_NOTEOL ONIG_OPTION_NOTEOL
|
||||
#define REG_OPTION_POSIX_REGION ONIG_OPTION_POSIX_REGION
|
||||
|
||||
#define REG_OPTION_ON ONIG_OPTION_ON
|
||||
#define REG_OPTION_OFF ONIG_OPTION_OFF
|
||||
#define IS_REG_OPTION_ON ONIG_IS_OPTION_ON
|
||||
|
||||
/* syntax */
|
||||
#define RegSyntaxType OnigSyntaxType
|
||||
|
||||
#define RegSyntaxPosixBasic OnigSyntaxPosixBasic
|
||||
#define RegSyntaxPosixExtended OnigSyntaxPosixExtended
|
||||
#define RegSyntaxEmacs OnigSyntaxEmacs
|
||||
#define RegSyntaxGrep OnigSyntaxGrep
|
||||
#define RegSyntaxGnuRegex OnigSyntaxGnuRegex
|
||||
#define RegSyntaxJava OnigSyntaxJava
|
||||
#define RegSyntaxPerl OnigSyntaxPerl
|
||||
#define RegSyntaxRuby OnigSyntaxRuby
|
||||
|
||||
#define REG_SYNTAX_POSIX_BASIC ONIG_SYNTAX_POSIX_BASIC
|
||||
#define REG_SYNTAX_POSIX_EXTENDED ONIG_SYNTAX_POSIX_EXTENDED
|
||||
#define REG_SYNTAX_EMACS ONIG_SYNTAX_EMACS
|
||||
#define REG_SYNTAX_GREP ONIG_SYNTAX_GREP
|
||||
#define REG_SYNTAX_GNU_REGEX ONIG_SYNTAX_GNU_REGEX
|
||||
#define REG_SYNTAX_JAVA ONIG_SYNTAX_JAVA
|
||||
#define REG_SYNTAX_PERL ONIG_SYNTAX_PERL
|
||||
#define REG_SYNTAX_RUBY ONIG_SYNTAX_RUBY
|
||||
|
||||
#define REG_SYNTAX_DEFAULT ONIG_SYNTAX_DEFAULT
|
||||
#define RegDefaultSyntax OnigDefaultSyntax
|
||||
|
||||
/* syntax (operators) */
|
||||
#define REG_SYN_OP_VARIABLE_META_CHARACTERS \
|
||||
ONIG_SYN_OP_VARIABLE_META_CHARACTERS
|
||||
#define REG_SYN_OP_DOT_ANYCHAR \
|
||||
ONIG_SYN_OP_DOT_ANYCHAR
|
||||
#define REG_SYN_OP_ASTERISK_ZERO_INF \
|
||||
ONIG_SYN_OP_ASTERISK_ZERO_INF
|
||||
#define REG_SYN_OP_ESC_ASTERISK_ZERO_INF \
|
||||
ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF
|
||||
#define REG_SYN_OP_PLUS_ONE_INF \
|
||||
ONIG_SYN_OP_PLUS_ONE_INF
|
||||
#define REG_SYN_OP_ESC_PLUS_ONE_INF \
|
||||
ONIG_SYN_OP_ESC_PLUS_ONE_INF
|
||||
#define REG_SYN_OP_QMARK_ZERO_ONE \
|
||||
ONIG_SYN_OP_QMARK_ZERO_ONE
|
||||
#define REG_SYN_OP_ESC_QMARK_ZERO_ONE \
|
||||
ONIG_SYN_OP_ESC_QMARK_ZERO_ONE
|
||||
#define REG_SYN_OP_BRACE_INTERVAL \
|
||||
ONIG_SYN_OP_BRACE_INTERVAL
|
||||
#define REG_SYN_OP_ESC_BRACE_INTERVAL \
|
||||
ONIG_SYN_OP_ESC_BRACE_INTERVAL
|
||||
#define REG_SYN_OP_VBAR_ALT \
|
||||
ONIG_SYN_OP_VBAR_ALT
|
||||
#define REG_SYN_OP_ESC_VBAR_ALT \
|
||||
ONIG_SYN_OP_ESC_VBAR_ALT
|
||||
#define REG_SYN_OP_LPAREN_SUBEXP \
|
||||
ONIG_SYN_OP_LPAREN_SUBEXP
|
||||
#define REG_SYN_OP_ESC_LPAREN_SUBEXP \
|
||||
ONIG_SYN_OP_ESC_LPAREN_SUBEXP
|
||||
#define REG_SYN_OP_ESC_AZ_BUF_ANCHOR \
|
||||
ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR
|
||||
#define REG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR \
|
||||
ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR
|
||||
#define REG_SYN_OP_DECIMAL_BACKREF \
|
||||
ONIG_SYN_OP_DECIMAL_BACKREF
|
||||
#define REG_SYN_OP_BRACKET_CC \
|
||||
ONIG_SYN_OP_BRACKET_CC
|
||||
#define REG_SYN_OP_ESC_W_WORD \
|
||||
ONIG_SYN_OP_ESC_W_WORD
|
||||
#define REG_SYN_OP_ESC_LTGT_WORD_BEGIN_END \
|
||||
ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END
|
||||
#define REG_SYN_OP_ESC_B_WORD_BOUND \
|
||||
ONIG_SYN_OP_ESC_B_WORD_BOUND
|
||||
#define REG_SYN_OP_ESC_S_WHITE_SPACE \
|
||||
ONIG_SYN_OP_ESC_S_WHITE_SPACE
|
||||
#define REG_SYN_OP_ESC_D_DIGIT \
|
||||
ONIG_SYN_OP_ESC_D_DIGIT
|
||||
#define REG_SYN_OP_LINE_ANCHOR \
|
||||
ONIG_SYN_OP_LINE_ANCHOR
|
||||
#define REG_SYN_OP_POSIX_BRACKET \
|
||||
ONIG_SYN_OP_POSIX_BRACKET
|
||||
#define REG_SYN_OP_QMARK_NON_GREEDY \
|
||||
ONIG_SYN_OP_QMARK_NON_GREEDY
|
||||
#define REG_SYN_OP_ESC_CONTROL_CHARS \
|
||||
ONIG_SYN_OP_ESC_CONTROL_CHARS
|
||||
#define REG_SYN_OP_ESC_C_CONTROL \
|
||||
ONIG_SYN_OP_ESC_C_CONTROL
|
||||
#define REG_SYN_OP_ESC_OCTAL3 \
|
||||
ONIG_SYN_OP_ESC_OCTAL3
|
||||
#define REG_SYN_OP_ESC_X_HEX2 \
|
||||
ONIG_SYN_OP_ESC_X_HEX2
|
||||
#define REG_SYN_OP_ESC_X_BRACE_HEX8 \
|
||||
ONIG_SYN_OP_ESC_X_BRACE_HEX8
|
||||
|
||||
#define REG_SYN_OP2_ESC_CAPITAL_Q_QUOTE \
|
||||
ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE
|
||||
#define REG_SYN_OP2_QMARK_GROUP_EFFECT \
|
||||
ONIG_SYN_OP2_QMARK_GROUP_EFFECT
|
||||
#define REG_SYN_OP2_OPTION_PERL \
|
||||
ONIG_SYN_OP2_OPTION_PERL
|
||||
#define REG_SYN_OP2_OPTION_RUBY \
|
||||
ONIG_SYN_OP2_OPTION_RUBY
|
||||
#define REG_SYN_OP2_PLUS_POSSESSIVE_REPEAT \
|
||||
ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT
|
||||
#define REG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL \
|
||||
ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL
|
||||
#define REG_SYN_OP2_CCLASS_SET_OP \
|
||||
ONIG_SYN_OP2_CCLASS_SET_OP
|
||||
#define REG_SYN_OP2_QMARK_LT_NAMED_GROUP \
|
||||
ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP
|
||||
#define REG_SYN_OP2_ESC_K_NAMED_BACKREF \
|
||||
ONIG_SYN_OP2_ESC_K_NAMED_BACKREF
|
||||
#define REG_SYN_OP2_ESC_G_SUBEXP_CALL \
|
||||
ONIG_SYN_OP2_ESC_G_SUBEXP_CALL
|
||||
#define REG_SYN_OP2_ATMARK_CAPTURE_HISTORY \
|
||||
ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY
|
||||
#define REG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL \
|
||||
ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL
|
||||
#define REG_SYN_OP2_ESC_CAPITAL_M_BAR_META \
|
||||
ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META
|
||||
#define REG_SYN_OP2_ESC_V_VTAB \
|
||||
ONIG_SYN_OP2_ESC_V_VTAB
|
||||
#define REG_SYN_OP2_ESC_U_HEX4 \
|
||||
ONIG_SYN_OP2_ESC_U_HEX4
|
||||
#define REG_SYN_OP2_ESC_GNU_BUF_ANCHOR \
|
||||
ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR
|
||||
|
||||
#define REG_SYN_CONTEXT_INDEP_ANCHORS \
|
||||
ONIG_SYN_CONTEXT_INDEP_ANCHORS
|
||||
#define REG_SYN_CONTEXT_INDEP_REPEAT_OPS \
|
||||
ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS
|
||||
#define REG_SYN_CONTEXT_INVALID_REPEAT_OPS \
|
||||
ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS
|
||||
#define REG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP \
|
||||
ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP
|
||||
#define REG_SYN_ALLOW_INVALID_INTERVAL \
|
||||
ONIG_SYN_ALLOW_INVALID_INTERVAL
|
||||
#define REG_SYN_STRICT_CHECK_BACKREF \
|
||||
ONIG_SYN_STRICT_CHECK_BACKREF
|
||||
#define REG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND \
|
||||
ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND
|
||||
#define REG_SYN_CAPTURE_ONLY_NAMED_GROUP \
|
||||
ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP
|
||||
#define REG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME \
|
||||
ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME
|
||||
|
||||
#define REG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC \
|
||||
ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC
|
||||
#define REG_SYN_BACKSLASH_ESCAPE_IN_CC \
|
||||
ONIG_SYN_BACKSLASH_ESCAPE_IN_CC
|
||||
#define REG_SYN_ALLOW_EMPTY_RANGE_IN_CC \
|
||||
ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC
|
||||
#define REG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC \
|
||||
ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC
|
||||
#define REG_SYN_WARN_CC_OP_NOT_ESCAPED \
|
||||
ONIG_SYN_WARN_CC_OP_NOT_ESCAPED
|
||||
#define REG_SYN_WARN_REDUNDANT_NESTED_REPEAT \
|
||||
ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT
|
||||
|
||||
/* meta character specifiers (regex_set_meta_char()) */
|
||||
#define REG_META_CHAR_ESCAPE ONIG_META_CHAR_ESCAPE
|
||||
#define REG_META_CHAR_ANYCHAR ONIG_META_CHAR_ANYCHAR
|
||||
#define REG_META_CHAR_ANYTIME ONIG_META_CHAR_ANYTIME
|
||||
#define REG_META_CHAR_ZERO_OR_ONE_TIME ONIG_META_CHAR_ZERO_OR_ONE_TIME
|
||||
#define REG_META_CHAR_ONE_OR_MORE_TIME ONIG_META_CHAR_ONE_OR_MORE_TIME
|
||||
#define REG_META_CHAR_ANYCHAR_ANYTIME ONIG_META_CHAR_ANYCHAR_ANYTIME
|
||||
|
||||
#define REG_INEFFECTIVE_META_CHAR ONIG_INEFFECTIVE_META_CHAR
|
||||
|
||||
/* error codes */
|
||||
#define REG_IS_PATTERN_ERROR ONIG_IS_PATTERN_ERROR
|
||||
/* normal return */
|
||||
#define REG_NORMAL ONIG_NORMAL
|
||||
#define REG_MISMATCH ONIG_MISMATCH
|
||||
#define REG_NO_SUPPORT_CONFIG ONIG_NO_SUPPORT_CONFIG
|
||||
/* internal error */
|
||||
#define REGERR_MEMORY ONIGERR_MEMORY
|
||||
#define REGERR_MATCH_STACK_LIMIT_OVER ONIGERR_MATCH_STACK_LIMIT_OVER
|
||||
#define REGERR_TYPE_BUG ONIGERR_TYPE_BUG
|
||||
#define REGERR_PARSER_BUG ONIGERR_PARSER_BUG
|
||||
#define REGERR_STACK_BUG ONIGERR_STACK_BUG
|
||||
#define REGERR_UNDEFINED_BYTECODE ONIGERR_UNDEFINED_BYTECODE
|
||||
#define REGERR_UNEXPECTED_BYTECODE ONIGERR_UNEXPECTED_BYTECODE
|
||||
#define REGERR_DEFAULT_ENCODING_IS_NOT_SETTED \
|
||||
ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED
|
||||
#define REGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR \
|
||||
ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR
|
||||
/* general error */
|
||||
#define REGERR_INVALID_ARGUMENT ONIGERR_INVALID_ARGUMENT
|
||||
/* errors related to thread */
|
||||
#define REGERR_OVER_THREAD_PASS_LIMIT_COUNT \
|
||||
ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT
|
||||
|
||||
|
||||
/* must be smaller than BIT_STATUS_BITS_NUM (unsigned int * 8) */
|
||||
#define REG_MAX_CAPTURE_HISTORY_GROUP ONIG_MAX_CAPTURE_HISTORY_GROUP
|
||||
#define REG_IS_CAPTURE_HISTORY_GROUP ONIG_IS_CAPTURE_HISTORY_GROUP
|
||||
|
||||
#define REG_REGION_NOTPOS ONIG_REGION_NOTPOS
|
||||
|
||||
#define RegRegion OnigRegion
|
||||
#define RegErrorInfo OnigErrorInfo
|
||||
#define RegRepeatRange OnigRepeatRange
|
||||
|
||||
#define RegWarnFunc OnigWarnFunc
|
||||
#define regex_null_warn onig_null_warn
|
||||
#define REG_NULL_WARN ONIG_NULL_WARN
|
||||
|
||||
/* regex_t state */
|
||||
#define REG_STATE_NORMAL ONIG_STATE_NORMAL
|
||||
#define REG_STATE_SEARCHING ONIG_STATE_SEARCHING
|
||||
#define REG_STATE_COMPILING ONIG_STATE_COMPILING
|
||||
#define REG_STATE_MODIFY ONIG_STATE_MODIFY
|
||||
|
||||
#define REG_STATE ONIG_STATE
|
||||
|
||||
/* Oniguruma Native API */
|
||||
#define regex_init onig_init
|
||||
#define regex_error_code_to_str onig_error_code_to_str
|
||||
#define regex_set_warn_func onig_set_warn_func
|
||||
#define regex_set_verb_warn_func onig_set_verb_warn_func
|
||||
#define regex_new onig_new
|
||||
#define regex_free onig_free
|
||||
#define regex_recompile onig_recompile
|
||||
#define regex_search onig_search
|
||||
#define regex_match onig_match
|
||||
#define regex_region_new onig_region_new
|
||||
#define regex_region_free onig_region_free
|
||||
#define regex_region_copy onig_region_copy
|
||||
#define regex_region_clear onig_region_clear
|
||||
#define regex_region_resize onig_region_resize
|
||||
#define regex_name_to_group_numbers onig_name_to_group_numbers
|
||||
#define regex_name_to_backref_number onig_name_to_backref_number
|
||||
#define regex_foreach_name onig_foreach_name
|
||||
#define regex_number_of_names onig_number_of_names
|
||||
#define regex_get_encoding onig_get_encoding
|
||||
#define regex_get_options onig_get_options
|
||||
#define regex_get_syntax onig_get_syntax
|
||||
#define regex_set_default_syntax onig_set_default_syntax
|
||||
#define regex_copy_syntax onig_copy_syntax
|
||||
#define regex_set_meta_char onig_set_meta_char
|
||||
#define regex_end onig_end
|
||||
#define regex_version onig_version
|
||||
|
||||
/* encoding API */
|
||||
#define enc_get_prev_char_head onigenc_get_prev_char_head
|
||||
#define enc_get_left_adjust_char_head onigenc_get_left_adjust_char_head
|
||||
#define enc_get_right_adjust_char_head onigenc_get_right_adjust_char_head
|
||||
/* obsoleted API */
|
||||
#define regex_get_prev_char_head onigenc_get_prev_char_head
|
||||
#define regex_get_left_adjust_char_head onigenc_get_left_adjust_char_head
|
||||
#define regex_get_right_adjust_char_head onigenc_get_right_adjust_char_head
|
||||
|
||||
#endif /* ONIGCMPT200_H */
|
|
@ -36,7 +36,7 @@ extern "C" {
|
|||
#define ONIGURUMA
|
||||
#define ONIGURUMA_VERSION_MAJOR 5
|
||||
#define ONIGURUMA_VERSION_MINOR 9
|
||||
#define ONIGURUMA_VERSION_TEENY 2
|
||||
#define ONIGURUMA_VERSION_TEENY 5
|
||||
|
||||
#ifdef __cplusplus
|
||||
# ifndef HAVE_PROTOTYPES
|
||||
|
|
|
@ -2399,7 +2399,7 @@ is_not_included(Node* x, Node* y, regex_t* reg)
|
|||
{
|
||||
int i, len;
|
||||
OnigCodePoint code;
|
||||
UChar *p, c;
|
||||
UChar *p;
|
||||
int ytype;
|
||||
|
||||
retry:
|
||||
|
@ -2513,51 +2513,51 @@ is_not_included(Node* x, Node* y, regex_t* reg)
|
|||
if (NSTRING_LEN(x) == 0)
|
||||
break;
|
||||
|
||||
c = *(xs->s);
|
||||
//c = *(xs->s);
|
||||
switch (ytype) {
|
||||
case NT_CTYPE:
|
||||
switch (NCTYPE(y)->ctype) {
|
||||
case ONIGENC_CTYPE_WORD:
|
||||
if (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end))
|
||||
return NCTYPE(y)->not;
|
||||
else
|
||||
return !(NCTYPE(y)->not);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
switch (NCTYPE(y)->ctype) {
|
||||
case ONIGENC_CTYPE_WORD:
|
||||
if (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end))
|
||||
return NCTYPE(y)->not;
|
||||
else
|
||||
return !(NCTYPE(y)->not);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NT_CCLASS:
|
||||
{
|
||||
CClassNode* cc = NCCLASS(y);
|
||||
{
|
||||
CClassNode* cc = NCCLASS(y);
|
||||
|
||||
code = ONIGENC_MBC_TO_CODE(reg->enc, xs->s,
|
||||
xs->s + ONIGENC_MBC_MAXLEN(reg->enc));
|
||||
return (onig_is_code_in_cc(reg->enc, code, cc) != 0 ? 0 : 1);
|
||||
}
|
||||
break;
|
||||
code = ONIGENC_MBC_TO_CODE(reg->enc, xs->s,
|
||||
xs->s + ONIGENC_MBC_MAXLEN(reg->enc));
|
||||
return (onig_is_code_in_cc(reg->enc, code, cc) != 0 ? 0 : 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case NT_STR:
|
||||
{
|
||||
UChar *q;
|
||||
StrNode* ys = NSTR(y);
|
||||
len = NSTRING_LEN(x);
|
||||
if (len > NSTRING_LEN(y)) len = NSTRING_LEN(y);
|
||||
if (NSTRING_IS_AMBIG(x) || NSTRING_IS_AMBIG(y)) {
|
||||
{
|
||||
UChar *q;
|
||||
StrNode* ys = NSTR(y);
|
||||
len = NSTRING_LEN(x);
|
||||
if (len > NSTRING_LEN(y)) len = NSTRING_LEN(y);
|
||||
if (NSTRING_IS_AMBIG(x) || NSTRING_IS_AMBIG(y)) {
|
||||
/* tiny version */
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
for (i = 0, p = ys->s, q = xs->s; i < len; i++, p++, q++) {
|
||||
if (*p != *q) return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
for (i = 0, p = ys->s, q = xs->s; i < len; i++, p++, q++) {
|
||||
if (*p != *q) return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -3189,7 +3189,7 @@ next_setup(Node* node, Node* next_node, regex_t* reg)
|
|||
static int
|
||||
update_string_node_case_fold(regex_t* reg, Node *node)
|
||||
{
|
||||
UChar *p, *q, *end, buf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
|
||||
UChar *p, *end, buf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
|
||||
UChar *sbuf, *ebuf, *sp;
|
||||
int r, i, len, sbuf_size;
|
||||
StrNode* sn = NSTR(node);
|
||||
|
@ -3204,14 +3204,13 @@ update_string_node_case_fold(regex_t* reg, Node *node)
|
|||
p = sn->s;
|
||||
while (p < end) {
|
||||
len = ONIGENC_MBC_CASE_FOLD(reg->enc, reg->case_fold_flag, &p, end, buf);
|
||||
q = buf;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (sp >= ebuf) {
|
||||
sbuf = (UChar* )xrealloc(sbuf, sbuf_size * 2);
|
||||
CHECK_NULL_RETURN_MEMERR(sbuf);
|
||||
sp = sbuf + sbuf_size;
|
||||
sbuf_size *= 2;
|
||||
ebuf = sbuf + sbuf_size;
|
||||
sbuf = (UChar* )xrealloc(sbuf, sbuf_size * 2);
|
||||
CHECK_NULL_RETURN_MEMERR(sbuf);
|
||||
sp = sbuf + sbuf_size;
|
||||
sbuf_size *= 2;
|
||||
ebuf = sbuf + sbuf_size;
|
||||
}
|
||||
|
||||
*sp++ = buf[i];
|
||||
|
@ -3316,29 +3315,29 @@ expand_case_fold_string_alt(int item_num, OnigCaseFoldCodeItem items[],
|
|||
UChar *q = p + items[i].byte_len;
|
||||
|
||||
if (q < end) {
|
||||
r = expand_case_fold_make_rem_string(&rem, q, end, reg);
|
||||
if (r != 0) {
|
||||
onig_node_free(an);
|
||||
goto mem_err2;
|
||||
}
|
||||
r = expand_case_fold_make_rem_string(&rem, q, end, reg);
|
||||
if (r != 0) {
|
||||
onig_node_free(an);
|
||||
goto mem_err2;
|
||||
}
|
||||
|
||||
xnode = onig_node_list_add(NULL_NODE, snode);
|
||||
if (IS_NULL(xnode)) {
|
||||
onig_node_free(an);
|
||||
onig_node_free(rem);
|
||||
goto mem_err2;
|
||||
}
|
||||
if (IS_NULL(onig_node_list_add(xnode, rem))) {
|
||||
onig_node_free(an);
|
||||
onig_node_free(xnode);
|
||||
onig_node_free(rem);
|
||||
goto mem_err;
|
||||
}
|
||||
xnode = onig_node_list_add(NULL_NODE, snode);
|
||||
if (IS_NULL(xnode)) {
|
||||
onig_node_free(an);
|
||||
onig_node_free(rem);
|
||||
goto mem_err2;
|
||||
}
|
||||
if (IS_NULL(onig_node_list_add(xnode, rem))) {
|
||||
onig_node_free(an);
|
||||
onig_node_free(xnode);
|
||||
onig_node_free(rem);
|
||||
goto mem_err;
|
||||
}
|
||||
|
||||
NCAR(an) = xnode;
|
||||
NCAR(an) = xnode;
|
||||
}
|
||||
else {
|
||||
NCAR(an) = snode;
|
||||
NCAR(an) = snode;
|
||||
}
|
||||
|
||||
NCDR(var_anode) = an;
|
||||
|
@ -6216,8 +6215,7 @@ print_indent_tree(FILE* f, Node* node, int indent)
|
|||
fprintf(f, "<enclose:%x> ", (int )node);
|
||||
switch (NENCLOSE(node)->type) {
|
||||
case ENCLOSE_OPTION:
|
||||
fprintf(f, "option:%d\n", NENCLOSE(node)->option);
|
||||
print_indent_tree(f, NENCLOSE(node)->target, indent + add);
|
||||
fprintf(f, "option:%d", NENCLOSE(node)->option);
|
||||
break;
|
||||
case ENCLOSE_MEMORY:
|
||||
fprintf(f, "memory:%d", NENCLOSE(node)->regnum);
|
||||
|
|
|
@ -262,6 +262,14 @@ strdup_with_null(OnigEncoding enc, UChar* s, UChar* end)
|
|||
p += ONIGENC_MBC_ENC_LEN(enc, p); \
|
||||
} while (0)
|
||||
|
||||
#define PINC_S do { \
|
||||
p += ONIGENC_MBC_ENC_LEN(enc, p); \
|
||||
} while (0)
|
||||
#define PFETCH_S(c) do { \
|
||||
c = ONIGENC_MBC_TO_CODE(enc, p, end); \
|
||||
p += ONIGENC_MBC_ENC_LEN(enc, p); \
|
||||
} while (0)
|
||||
|
||||
#define PPEEK (p < end ? ONIGENC_MBC_TO_CODE(enc, p, end) : PEND_VALUE)
|
||||
#define PPEEK_IS(c) (PPEEK == (OnigCodePoint )c)
|
||||
|
||||
|
@ -2404,22 +2412,21 @@ fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env)
|
|||
OnigCodePoint c;
|
||||
OnigEncoding enc = env->enc;
|
||||
UChar* p = *src;
|
||||
PFETCH_READY;
|
||||
|
||||
if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;
|
||||
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
switch (c) {
|
||||
case 'M':
|
||||
if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META)) {
|
||||
if (PEND) return ONIGERR_END_PATTERN_AT_META;
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c != '-') return ONIGERR_META_CODE_SYNTAX;
|
||||
if (PEND) return ONIGERR_END_PATTERN_AT_META;
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c == MC_ESC(env->syntax)) {
|
||||
v = fetch_escaped_value(&p, end, env);
|
||||
if (v < 0) return v;
|
||||
v = fetch_escaped_value(&p, end, env);
|
||||
if (v < 0) return v;
|
||||
c = (OnigCodePoint )v;
|
||||
}
|
||||
c = ((c & 0xff) | 0x80);
|
||||
|
@ -2431,7 +2438,7 @@ fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env)
|
|||
case 'C':
|
||||
if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL)) {
|
||||
if (PEND) return ONIGERR_END_PATTERN_AT_CONTROL;
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c != '-') return ONIGERR_CONTROL_CODE_SYNTAX;
|
||||
goto control;
|
||||
}
|
||||
|
@ -2442,9 +2449,9 @@ fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env)
|
|||
if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_C_CONTROL)) {
|
||||
control:
|
||||
if (PEND) return ONIGERR_END_PATTERN_AT_CONTROL;
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c == '?') {
|
||||
c = 0177;
|
||||
c = 0177;
|
||||
}
|
||||
else {
|
||||
if (c == MC_ESC(env->syntax)) {
|
||||
|
@ -2452,7 +2459,7 @@ fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env)
|
|||
if (v < 0) return v;
|
||||
c = (OnigCodePoint )v;
|
||||
}
|
||||
c &= 0x9f;
|
||||
c &= 0x9f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2546,11 +2553,11 @@ fetch_name_with_level(OnigCodePoint start_code, UChar** src, UChar* end,
|
|||
|
||||
if (is_num != 0) {
|
||||
if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
|
||||
is_num = 1;
|
||||
is_num = 1;
|
||||
}
|
||||
else {
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
is_num = 0;
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
is_num = 0;
|
||||
}
|
||||
}
|
||||
else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
|
||||
|
@ -2617,7 +2624,6 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
|
|||
UChar *name_end;
|
||||
UChar *pnum_head;
|
||||
UChar *p = *src;
|
||||
PFETCH_READY;
|
||||
|
||||
*rback_num = 0;
|
||||
|
||||
|
@ -2632,27 +2638,27 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
|
|||
return ONIGERR_EMPTY_GROUP_NAME;
|
||||
}
|
||||
else {
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c == end_code)
|
||||
return ONIGERR_EMPTY_GROUP_NAME;
|
||||
|
||||
if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
|
||||
if (ref == 1)
|
||||
is_num = 1;
|
||||
is_num = 1;
|
||||
else {
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
is_num = 0;
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
is_num = 0;
|
||||
}
|
||||
}
|
||||
else if (c == '-') {
|
||||
if (ref == 1) {
|
||||
is_num = 2;
|
||||
sign = -1;
|
||||
pnum_head = p;
|
||||
is_num = 2;
|
||||
sign = -1;
|
||||
pnum_head = p;
|
||||
}
|
||||
else {
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
is_num = 0;
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
is_num = 0;
|
||||
}
|
||||
}
|
||||
else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
|
||||
|
@ -2663,29 +2669,28 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
|
|||
if (r == 0) {
|
||||
while (!PEND) {
|
||||
name_end = p;
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c == end_code || c == ')') {
|
||||
if (is_num == 2) r = ONIGERR_INVALID_GROUP_NAME;
|
||||
break;
|
||||
if (is_num == 2) r = ONIGERR_INVALID_GROUP_NAME;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_num != 0) {
|
||||
if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
|
||||
is_num = 1;
|
||||
}
|
||||
else {
|
||||
if (!ONIGENC_IS_CODE_WORD(enc, c))
|
||||
r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
|
||||
else
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
|
||||
is_num = 0;
|
||||
}
|
||||
if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
|
||||
is_num = 1;
|
||||
}
|
||||
else {
|
||||
if (!ONIGENC_IS_CODE_WORD(enc, c))
|
||||
r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
|
||||
else
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
is_num = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!ONIGENC_IS_CODE_WORD(enc, c)) {
|
||||
r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
|
||||
}
|
||||
if (!ONIGENC_IS_CODE_WORD(enc, c)) {
|
||||
r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2698,8 +2703,8 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
|
|||
*rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc);
|
||||
if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER;
|
||||
else if (*rback_num == 0) {
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
goto err;
|
||||
r = ONIGERR_INVALID_GROUP_NAME;
|
||||
goto err;
|
||||
}
|
||||
|
||||
*rback_num *= sign;
|
||||
|
@ -2712,9 +2717,9 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
|
|||
else {
|
||||
while (!PEND) {
|
||||
name_end = p;
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c == end_code || c == ')')
|
||||
break;
|
||||
break;
|
||||
}
|
||||
if (PEND)
|
||||
name_end = end;
|
||||
|
@ -3935,10 +3940,9 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env)
|
|||
OnigCodePoint c;
|
||||
OnigEncoding enc = env->enc;
|
||||
UChar *p = *src;
|
||||
PFETCH_READY;
|
||||
|
||||
if (PPEEK_IS('^')) {
|
||||
PINC;
|
||||
PINC_S;
|
||||
not = 1;
|
||||
}
|
||||
else
|
||||
|
@ -3951,12 +3955,12 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env)
|
|||
if (onigenc_with_ascii_strncmp(enc, p, end, pb->name, pb->len) == 0) {
|
||||
p = (UChar* )onigenc_step(enc, p, end, pb->len);
|
||||
if (onigenc_with_ascii_strncmp(enc, p, end, (UChar* )":]", 2) != 0)
|
||||
return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
|
||||
return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
|
||||
|
||||
r = add_ctype_to_cc(cc, pb->ctype, not, env);
|
||||
if (r != 0) return r;
|
||||
|
||||
PINC; PINC;
|
||||
PINC_S; PINC_S;
|
||||
*src = p;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3966,15 +3970,15 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env)
|
|||
c = 0;
|
||||
i = 0;
|
||||
while (!PEND && ((c = PPEEK) != ':') && c != ']') {
|
||||
PINC;
|
||||
PINC_S;
|
||||
if (++i > POSIX_BRACKET_CHECK_LIMIT_LENGTH) break;
|
||||
}
|
||||
if (c == ':' && ! PEND) {
|
||||
PINC;
|
||||
PINC_S;
|
||||
if (! PEND) {
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c == ']')
|
||||
return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
|
||||
return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3988,14 +3992,13 @@ fetch_char_property_to_ctype(UChar** src, UChar* end, ScanEnv* env)
|
|||
OnigCodePoint c;
|
||||
OnigEncoding enc = env->enc;
|
||||
UChar *prev, *start, *p = *src;
|
||||
PFETCH_READY;
|
||||
|
||||
r = 0;
|
||||
start = prev = p;
|
||||
|
||||
while (!PEND) {
|
||||
prev = p;
|
||||
PFETCH(c);
|
||||
PFETCH_S(c);
|
||||
if (c == '}') {
|
||||
r = ONIGENC_PROPERTY_NAME_TO_CTYPE(enc, start, prev);
|
||||
if (r < 0) break;
|
||||
|
@ -4153,7 +4156,6 @@ code_exist_check(OnigCodePoint c, UChar* from, UChar* end, int ignore_escaped,
|
|||
OnigCodePoint code;
|
||||
OnigEncoding enc = env->enc;
|
||||
UChar* p = from;
|
||||
PFETCH_READY;
|
||||
|
||||
in_esc = 0;
|
||||
while (! PEND) {
|
||||
|
@ -4161,7 +4163,7 @@ code_exist_check(OnigCodePoint c, UChar* from, UChar* end, int ignore_escaped,
|
|||
in_esc = 0;
|
||||
}
|
||||
else {
|
||||
PFETCH(code);
|
||||
PFETCH_S(code);
|
||||
if (code == c) return 1;
|
||||
if (code == MC_ESC(env->syntax)) in_esc = 1;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
Bug #48697 (mb_internal_encoding() value gets reset by parse_str() or mb_parse_str()
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set('mbstring.internal_encoding', 'ISO-8859-15');
|
||||
|
|
|
@ -3,6 +3,7 @@ Encoding INI test
|
|||
--SKIPIF--
|
||||
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
default_charset=Shift_JIS
|
||||
internal_encoding=
|
||||
input_encoding=
|
||||
|
|
|
@ -4,6 +4,7 @@ zend multibyte (7)
|
|||
--XFAIL--
|
||||
https://bugs.php.net/bug.php?id=66582
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
zend.multibyte=On
|
||||
zend.script_encoding=ISO-8859-1
|
||||
mbstring.internal_encoding=EUC-JP
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
--TEST--
|
||||
zend multibyte (8)
|
||||
--SKIPIF--
|
||||
--INI--
|
||||
zend.multibyte=On
|
||||
zend.script_encoding=ISO-8859-1
|
||||
|
|
|
@ -4,6 +4,7 @@ zend multibyte (9)
|
|||
--XFAIL--
|
||||
https://bugs.php.net/bug.php?id=66582
|
||||
--INI--
|
||||
error_reporting=E_ALL & ~E_DEPRECATED
|
||||
zend.multibyte=On
|
||||
zend.script_encoding=cp1251
|
||||
mbstring.internal_encoding=UTF-8
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
--TEST--
|
||||
zend multibyte (10)
|
||||
--SKIPIF--
|
||||
--INI--
|
||||
zend.multibyte=1
|
||||
--FILE--
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
--TEST--
|
||||
zend multibyte (11)
|
||||
--SKIPIF--
|
||||
--INI--
|
||||
zend.multibyte=1
|
||||
--FILE--
|
||||
|
|
|
@ -2173,19 +2173,12 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
|
|||
fci.symbol_table = NULL;
|
||||
fci.object_ptr = return_value;
|
||||
fci.retval_ptr_ptr = &retval_ptr;
|
||||
if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
|
||||
if (Z_TYPE_P(ctor_params) == IS_ARRAY) {
|
||||
HashTable *htl = Z_ARRVAL_P(ctor_params);
|
||||
Bucket *p;
|
||||
fci.params = NULL;
|
||||
fci.param_count = 0;
|
||||
fci.no_separation = 1;
|
||||
|
||||
fci.param_count = 0;
|
||||
fci.params = safe_emalloc(sizeof(zval*), htl->nNumOfElements, 0);
|
||||
p = htl->pListHead;
|
||||
while (p != NULL) {
|
||||
fci.params[fci.param_count++] = (zval**)p->pData;
|
||||
p = p->pListNext;
|
||||
}
|
||||
} else {
|
||||
if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
|
||||
if (zend_fcall_info_args(&fci, ctor_params TSRMLS_CC) == FAILURE) {
|
||||
/* Two problems why we throw exceptions here: PHP is typeless
|
||||
* and hence passing one argument that's not an array could be
|
||||
* by mistake and the other way round is possible, too. The
|
||||
|
@ -2195,11 +2188,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
|
|||
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Parameter ctor_params must be an array", 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
fci.param_count = 0;
|
||||
fci.params = NULL;
|
||||
}
|
||||
fci.no_separation = 1;
|
||||
|
||||
fcc.initialized = 1;
|
||||
fcc.function_handler = ce->constructor;
|
||||
|
|
|
@ -1297,19 +1297,12 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
|
|||
fci.symbol_table = NULL;
|
||||
fci.object_ptr = return_value;
|
||||
fci.retval_ptr_ptr = &retval_ptr;
|
||||
if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
|
||||
if (Z_TYPE_P(ctor_params) == IS_ARRAY) {
|
||||
HashTable *params_ht = Z_ARRVAL_P(ctor_params);
|
||||
Bucket *p;
|
||||
fci.params = NULL;
|
||||
fci.param_count = 0;
|
||||
fci.no_separation = 1;
|
||||
|
||||
fci.param_count = 0;
|
||||
fci.params = safe_emalloc(sizeof(zval*), params_ht->nNumOfElements, 0);
|
||||
p = params_ht->pListHead;
|
||||
while (p != NULL) {
|
||||
fci.params[fci.param_count++] = (zval**)p->pData;
|
||||
p = p->pListNext;
|
||||
}
|
||||
} else {
|
||||
if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
|
||||
if (zend_fcall_info_args(&fci, ctor_params TSRMLS_CC) == FAILURE) {
|
||||
/* Two problems why we throw exceptions here: PHP is typeless
|
||||
* and hence passing one argument that's not an array could be
|
||||
* by mistake and the other way round is possible, too. The
|
||||
|
@ -1319,11 +1312,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
|
|||
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Parameter ctor_params must be an array", 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
fci.param_count = 0;
|
||||
fci.params = NULL;
|
||||
}
|
||||
fci.no_separation = 1;
|
||||
|
||||
fcc.initialized = 1;
|
||||
fcc.function_handler = ce->constructor;
|
||||
|
|
|
@ -34,30 +34,31 @@
|
|||
#include "php_mysqli_structs.h"
|
||||
#include "mysqli_priv.h"
|
||||
|
||||
|
||||
#if !defined(MYSQLI_USE_MYSQLND)
|
||||
/* {{{ mysqli_tx_cor_options_to_string */
|
||||
static void mysqli_tx_cor_options_to_string(const MYSQL * const conn, smart_str * str, const unsigned int mode)
|
||||
{
|
||||
if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) {
|
||||
if (str->len) {
|
||||
smart_str_appendl(str, ", ", sizeof(", ") - 1);
|
||||
smart_str_appendl(str, " ", sizeof(" ") - 1);
|
||||
}
|
||||
smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1);
|
||||
} else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) {
|
||||
if (str->len) {
|
||||
smart_str_appendl(str, ", ", sizeof(", ") - 1);
|
||||
smart_str_appendl(str, " ", sizeof(" ") - 1);
|
||||
}
|
||||
smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1);
|
||||
}
|
||||
|
||||
if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) {
|
||||
if (str->len) {
|
||||
smart_str_appendl(str, ", ", sizeof(", ") - 1);
|
||||
smart_str_appendl(str, " ", sizeof(" ") - 1);
|
||||
}
|
||||
smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1);
|
||||
} else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) {
|
||||
if (str->len) {
|
||||
smart_str_appendl(str, ", ", sizeof(", ") - 1);
|
||||
smart_str_appendl(str, " ", sizeof(" ") - 1);
|
||||
}
|
||||
smart_str_appendl(str, "NO RELEASE", sizeof("NO RELEASE") - 1);
|
||||
}
|
||||
|
@ -66,8 +67,50 @@ static void mysqli_tx_cor_options_to_string(const MYSQL * const conn, smart_str
|
|||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ proto bool mysqli_commit_or_rollback_libmysql */
|
||||
static int mysqli_commit_or_rollback_libmysql(MYSQL * conn, zend_bool commit, const unsigned int mode, const char * const name)
|
||||
/* {{{ mysqlnd_escape_string_for_tx_name_in_comment */
|
||||
char *
|
||||
mysqli_escape_string_for_tx_name_in_comment(const char * const name TSRMLS_DC)
|
||||
{
|
||||
char * ret = NULL;
|
||||
if (name) {
|
||||
zend_bool warned = FALSE;
|
||||
const char * p_orig = name;
|
||||
char * p_copy;
|
||||
p_copy = ret = emalloc(strlen(name) + 1 + 2 + 2 + 1); /* space, open, close, NullS */
|
||||
*p_copy++ = ' ';
|
||||
*p_copy++ = '/';
|
||||
*p_copy++ = '*';
|
||||
while (1) {
|
||||
register char v = *p_orig;
|
||||
if (v == 0) {
|
||||
break;
|
||||
}
|
||||
if ((v >= '0' && v <= '9') ||
|
||||
(v >= 'a' && v <= 'z') ||
|
||||
(v >= 'A' && v <= 'Z') ||
|
||||
v == '-' ||
|
||||
v == '_' ||
|
||||
v == ' ' ||
|
||||
v == '=')
|
||||
{
|
||||
*p_copy++ = v;
|
||||
} else if (warned == FALSE) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Transaction name truncated. Must be only [0-9A-Za-z\\-_=]+");
|
||||
warned = TRUE;
|
||||
}
|
||||
++p_orig;
|
||||
}
|
||||
*p_copy++ = '*';
|
||||
*p_copy++ = '/';
|
||||
*p_copy++ = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqli_commit_or_rollback_libmysql */
|
||||
static int mysqli_commit_or_rollback_libmysql(MYSQL * conn, zend_bool commit, const unsigned int mode, const char * const name TSRMLS_DC)
|
||||
{
|
||||
int ret;
|
||||
smart_str tmp_str = {0, 0, 0};
|
||||
|
@ -75,23 +118,27 @@ static int mysqli_commit_or_rollback_libmysql(MYSQL * conn, zend_bool commit, co
|
|||
smart_str_0(&tmp_str);
|
||||
|
||||
{
|
||||
char * commented_name = NULL;
|
||||
unsigned int commented_name_len = name? spprintf(&commented_name, 0, " /*%s*/", name):0;
|
||||
char * query;
|
||||
unsigned int query_len = spprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"),
|
||||
commented_name? commented_name:"", tmp_str.c? tmp_str.c:"");
|
||||
char * name_esc = mysqli_escape_string_for_tx_name_in_comment(name TSRMLS_CC);
|
||||
size_t query_len;
|
||||
|
||||
query_len = spprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"),
|
||||
name_esc? name_esc:"", tmp_str.c? tmp_str.c:"");
|
||||
smart_str_free(&tmp_str);
|
||||
if (name_esc) {
|
||||
efree(name_esc);
|
||||
name_esc = NULL;
|
||||
}
|
||||
|
||||
ret = mysql_real_query(conn, query, query_len);
|
||||
efree(query);
|
||||
if (commented_name) {
|
||||
efree(commented_name);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
|
||||
/* {{{ proto mixed mysqli_affected_rows(object link)
|
||||
Get number of affected rows in previous MySQL operation */
|
||||
PHP_FUNCTION(mysqli_affected_rows)
|
||||
|
@ -660,7 +707,7 @@ void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_status TSRM
|
|||
|
||||
if (MyG(rollback_on_cached_plink) &&
|
||||
#if !defined(MYSQLI_USE_MYSQLND)
|
||||
mysqli_commit_or_rollback_libmysql(mysql->mysql, FALSE, TRANS_COR_NO_OPT, NULL))
|
||||
mysqli_commit_or_rollback_libmysql(mysql->mysql, FALSE, TRANS_COR_NO_OPT, NULL TSRMLS_CC))
|
||||
#else
|
||||
FAIL == mysqlnd_rollback(mysql->mysql, TRANS_COR_NO_OPT, NULL))
|
||||
#endif
|
||||
|
@ -704,7 +751,8 @@ PHP_FUNCTION(mysqli_close)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool mysqli_commit(object link)
|
||||
|
||||
/* {{{ proto bool mysqli_commit(object link[, int flags [, string name ]])
|
||||
Commit outstanding actions and close transaction */
|
||||
PHP_FUNCTION(mysqli_commit)
|
||||
{
|
||||
|
@ -720,7 +768,7 @@ PHP_FUNCTION(mysqli_commit)
|
|||
MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
|
||||
|
||||
#if !defined(MYSQLI_USE_MYSQLND)
|
||||
if (mysqli_commit_or_rollback_libmysql(mysql->mysql, TRUE, flags, name)) {
|
||||
if (mysqli_commit_or_rollback_libmysql(mysql->mysql, TRUE, flags, name TSRMLS_CC)) {
|
||||
#else
|
||||
if (FAIL == mysqlnd_commit(mysql->mysql, flags, name)) {
|
||||
#endif
|
||||
|
@ -1970,7 +2018,7 @@ PHP_FUNCTION(mysqli_rollback)
|
|||
MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
|
||||
|
||||
#if !defined(MYSQLI_USE_MYSQLND)
|
||||
if (mysqli_commit_or_rollback_libmysql(mysql->mysql, FALSE, flags, name)) {
|
||||
if (mysqli_commit_or_rollback_libmysql(mysql->mysql, FALSE, flags, name TSRMLS_CC)) {
|
||||
#else
|
||||
if (FAIL == mysqlnd_rollback(mysql->mysql, flags, name)) {
|
||||
#endif
|
||||
|
|
|
@ -1051,12 +1051,14 @@ PHP_FUNCTION(mysqli_get_charset)
|
|||
/* }}} */
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(MYSQLI_USE_MYSQLND)
|
||||
extern char * mysqli_escape_string_for_tx_name_in_comment(const char * const name TSRMLS_DC);
|
||||
|
||||
/* {{{ proto bool mysqli_begin_transaction_libmysql */
|
||||
static int mysqli_begin_transaction_libmysql(MYSQL * conn, const unsigned int mode, const char * const name)
|
||||
static int mysqli_begin_transaction_libmysql(MYSQL * conn, const unsigned int mode, const char * const name TSRMLS_DC)
|
||||
{
|
||||
int ret;
|
||||
zend_bool err = FALSE;
|
||||
smart_str tmp_str = {0, 0, 0};
|
||||
if (mode & TRANS_START_WITH_CONSISTENT_SNAPSHOT) {
|
||||
if (tmp_str.len) {
|
||||
|
@ -1064,33 +1066,37 @@ static int mysqli_begin_transaction_libmysql(MYSQL * conn, const unsigned int mo
|
|||
}
|
||||
smart_str_appendl(&tmp_str, "WITH CONSISTENT SNAPSHOT", sizeof("WITH CONSISTENT SNAPSHOT") - 1);
|
||||
}
|
||||
if (mode & TRANS_START_READ_WRITE) {
|
||||
if (tmp_str.len) {
|
||||
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
|
||||
if (mode & (TRANS_START_READ_WRITE | TRANS_START_READ_ONLY)) {
|
||||
if (mysql_get_server_version(conn) < 50605L) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required");
|
||||
err = TRUE;
|
||||
} else if (mode & TRANS_START_READ_WRITE) {
|
||||
if (tmp_str.len) {
|
||||
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
|
||||
}
|
||||
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
|
||||
} else if (mode & TRANS_START_READ_ONLY) {
|
||||
if (tmp_str.len) {
|
||||
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
|
||||
}
|
||||
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1);
|
||||
}
|
||||
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
|
||||
}
|
||||
if (mode & TRANS_START_READ_ONLY) {
|
||||
if (tmp_str.len) {
|
||||
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
|
||||
}
|
||||
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1);
|
||||
}
|
||||
smart_str_0(&tmp_str);
|
||||
|
||||
{
|
||||
char * commented_name = NULL;
|
||||
unsigned int commented_name_len = name? spprintf(&commented_name, 0, " /*%s*/", name):0;
|
||||
if (err == FALSE){
|
||||
char * name_esc = mysqli_escape_string_for_tx_name_in_comment(name TSRMLS_CC);
|
||||
char * query;
|
||||
unsigned int query_len = spprintf(&query, 0, "START TRANSACTION%s %s",
|
||||
commented_name? commented_name:"", tmp_str.c? tmp_str.c:"");
|
||||
name_esc? name_esc:"", tmp_str.c? tmp_str.c:"");
|
||||
|
||||
smart_str_free(&tmp_str);
|
||||
if (name_esc) {
|
||||
efree(name_esc);
|
||||
}
|
||||
|
||||
ret = mysql_real_query(conn, query, query_len);
|
||||
efree(query);
|
||||
if (commented_name) {
|
||||
efree(commented_name);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1125,7 +1131,7 @@ PHP_FUNCTION(mysqli_begin_transaction)
|
|||
}
|
||||
|
||||
#if !defined(MYSQLI_USE_MYSQLND)
|
||||
if (mysqli_begin_transaction_libmysql(mysql->mysql, flags, name)) {
|
||||
if (mysqli_begin_transaction_libmysql(mysql->mysql, flags, name TSRMLS_CC)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -67,61 +67,50 @@ if (!have_innodb($link))
|
|||
var_dump($res->fetch_assoc());
|
||||
|
||||
/* valid flags */
|
||||
$flags = array(
|
||||
MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT,
|
||||
MYSQLI_TRANS_START_READ_WRITE,
|
||||
MYSQLI_TRANS_START_READ_ONLY,
|
||||
MYSQLI_TRANS_COR_AND_CHAIN,
|
||||
MYSQLI_TRANS_COR_AND_NO_CHAIN,
|
||||
MYSQLI_TRANS_COR_RELEASE,
|
||||
MYSQLI_TRANS_COR_NO_RELEASE);
|
||||
$flags = array(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT);
|
||||
|
||||
if (mysqli_get_server_version($link) >= 50605) {
|
||||
$flags[] = MYSQLI_TRANS_START_READ_WRITE;
|
||||
$flags[] = MYSQLI_TRANS_START_READ_ONLY;
|
||||
}
|
||||
|
||||
/* just coverage */
|
||||
foreach ($flags as $flag) {
|
||||
if (!mysqli_begin_transaction($link, $flag, sprintf("flag %d", $flag))) {
|
||||
printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
}
|
||||
if (!mysqli_query($link, 'SELECT * FROM test') ||
|
||||
!mysqli_rollback($link)) {
|
||||
if (!mysqli_query($link, 'SELECT * FROM test') || !mysqli_rollback($link)) {
|
||||
printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
}
|
||||
}
|
||||
|
||||
/* does it really set a flag? */
|
||||
if (mysqli_get_server_version($link) >= 50600) {
|
||||
if (mysqli_get_server_version($link) >= 50605) {
|
||||
if (!mysqli_begin_transaction($link, MYSQLI_TRANS_START_READ_ONLY, sprintf("flag %d", $flag))) {
|
||||
printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
}
|
||||
if (!mysqli_query($link, "INSERT INTO test(id) VALUES (2)") ||
|
||||
!mysqli_commit($link)) {
|
||||
if (mysqli_query($link, "INSERT INTO test(id) VALUES (2)")) {
|
||||
printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
} else if (!mysqli_commit($link)) {
|
||||
printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
} else {
|
||||
$res = mysqli_query($link, "SELECT id FROM test WHERE id = 2");
|
||||
var_dump($res->fetch_assoc());
|
||||
}
|
||||
}
|
||||
|
||||
/* invalid flag */
|
||||
do {
|
||||
$invalid_flag = mt_rand(0, 10000);
|
||||
} while (isset(array_flip($flags)[$invalid_flag]));
|
||||
/* we may or may not hit an invalid combination provoking a SQL error */
|
||||
if (!mysqli_begin_transaction($link, $invalid_flag, sprintf("flag %d", $invalid_flag))) {
|
||||
printf("[018] invalid_flag = %d [%d] %s\n", $invalid_flag, mysqli_errno($link), mysqli_error($link));
|
||||
} else {
|
||||
printf("[018] invalid_flag = %d [%d] %s\n", $invalid_flag, mysqli_errno($link), mysqli_error($link));
|
||||
}
|
||||
|
||||
if (!mysqli_begin_transaction($link, -1)) {
|
||||
printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
}
|
||||
|
||||
/* does it like stupid names? */
|
||||
if (!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE, "*/trick me?\n\0"))
|
||||
printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
if (mysqli_get_server_version($link) >= 50605) {
|
||||
/* does it like stupid names? */
|
||||
if (@!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE, "*/trick me?\n\0"))
|
||||
printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
/* does it like stupid names? */
|
||||
if (!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE, "az09"))
|
||||
printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
/* does it like stupid names? */
|
||||
if (@!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE, "az09"))
|
||||
printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
}
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
|
@ -131,10 +120,16 @@ if (!have_innodb($link))
|
|||
?>
|
||||
--EXPECTF--
|
||||
NULL
|
||||
<<<<<<< HEAD
|
||||
[017] [1792] %s
|
||||
[018] invalid_flag = %d [%d]%A
|
||||
|
||||
Warning: mysqli_begin_transaction(): Invalid value for parameter flags (-1) in %s on line %d
|
||||
[019] [%d]%A
|
||||
[020] [%d]%A
|
||||
=======
|
||||
|
||||
Warning: mysqli_begin_transaction(): Invalid value for parameter flags (-1) in %s on line %d
|
||||
[019] [%d]%A
|
||||
>>>>>>> 3204ad5858a5abc50b11b8527d22c82eb07a80cc
|
||||
done!
|
|
@ -21,49 +21,78 @@ if (!have_innodb($link))
|
|||
$link = NULL;
|
||||
|
||||
$mysqli = new mysqli();
|
||||
if (!is_null($tmp = @$mysqli->commit()))
|
||||
if (!is_null($tmp = @$mysqli->commit())) {
|
||||
printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
|
||||
}
|
||||
|
||||
if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
|
||||
if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
|
||||
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
|
||||
$host, $user, $db, $port, $socket);
|
||||
}
|
||||
|
||||
if (true !== ($tmp = $mysqli->commit()))
|
||||
if (true !== ($tmp = $mysqli->commit())) {
|
||||
printf("[002] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
|
||||
}
|
||||
|
||||
if (true !== ($tmp = $mysqli->autocommit(false)))
|
||||
if (true !== ($tmp = $mysqli->autocommit(false))) {
|
||||
printf("[003] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp);
|
||||
}
|
||||
|
||||
if (!$mysqli->query('DROP TABLE IF EXISTS test'))
|
||||
if (!$mysqli->query('DROP TABLE IF EXISTS test')) {
|
||||
printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
|
||||
if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB'))
|
||||
if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) {
|
||||
printf("[005] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
|
||||
if (!$mysqli->query('INSERT INTO test(id) VALUES (1)'))
|
||||
if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) {
|
||||
printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
|
||||
$tmp = $mysqli->commit();
|
||||
if ($tmp !== true)
|
||||
if ($tmp !== true) {
|
||||
printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
|
||||
}
|
||||
|
||||
if (!$mysqli->query('ROLLBACK'))
|
||||
printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
|
||||
if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test'))
|
||||
if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) {
|
||||
printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
|
||||
$tmp = $res->fetch_assoc();
|
||||
if (1 != $tmp['num'])
|
||||
if (1 != $tmp['num']) {
|
||||
printf("[010] Expecting 1 row in table test, found %d rows\n", $tmp['num']);
|
||||
}
|
||||
$res->free();
|
||||
|
||||
if (!$mysqli->query('DROP TABLE IF EXISTS test'))
|
||||
if (!$mysqli->query('DROP TABLE IF EXISTS test')) {
|
||||
printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
|
||||
if (!$mysqli->commit(0 , "tx_name0123")) {
|
||||
printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
if (!$mysqli->commit(0 , "*/ nonsense")) {
|
||||
printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
if (!$mysqli->commit(0 , "tx_name ulf вендел")) {
|
||||
printf("[014] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
if (!$mysqli->commit(0 , "tx_name \t\n\r\b")) {
|
||||
printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
if (!$mysqli->commit(MYSQLI_TRANS_COR_AND_CHAIN | MYSQLI_TRANS_COR_NO_RELEASE , "tx_name")) {
|
||||
printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error);
|
||||
}
|
||||
|
||||
$mysqli->close();
|
||||
|
||||
if (NULL !== ($tmp = @$mysqli->commit()))
|
||||
printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
|
||||
if (NULL !== ($tmp = @$mysqli->commit())) {
|
||||
printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
|
||||
}
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
|
@ -72,4 +101,9 @@ if (!have_innodb($link))
|
|||
require_once("clean_table.inc");
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
|
||||
|
||||
Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
|
||||
|
||||
Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
|
||||
done!
|
|
@ -2670,24 +2670,24 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_cor_options_to_string)(const MYSQLND_CONN_D
|
|||
{
|
||||
if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) {
|
||||
if (str->len) {
|
||||
smart_str_appendl(str, ", ", sizeof(", ") - 1);
|
||||
smart_str_appendl(str, " ", sizeof(" ") - 1);
|
||||
}
|
||||
smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1);
|
||||
} else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) {
|
||||
if (str->len) {
|
||||
smart_str_appendl(str, ", ", sizeof(", ") - 1);
|
||||
smart_str_appendl(str, " ", sizeof(" ") - 1);
|
||||
}
|
||||
smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1);
|
||||
}
|
||||
|
||||
if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) {
|
||||
if (str->len) {
|
||||
smart_str_appendl(str, ", ", sizeof(", ") - 1);
|
||||
smart_str_appendl(str, " ", sizeof(" ") - 1);
|
||||
}
|
||||
smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1);
|
||||
} else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) {
|
||||
if (str->len) {
|
||||
smart_str_appendl(str, ", ", sizeof(", ") - 1);
|
||||
smart_str_appendl(str, " ", sizeof(" ") - 1);
|
||||
}
|
||||
smart_str_appendl(str, "NO RELEASE", sizeof("NO RELEASE") - 1);
|
||||
}
|
||||
|
@ -2696,6 +2696,49 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_cor_options_to_string)(const MYSQLND_CONN_D
|
|||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_escape_string_for_tx_name_in_comment */
|
||||
static char *
|
||||
mysqlnd_escape_string_for_tx_name_in_comment(const char * const name TSRMLS_DC)
|
||||
{
|
||||
char * ret = NULL;
|
||||
DBG_ENTER("mysqlnd_escape_string_for_tx_name_in_comment");
|
||||
if (name) {
|
||||
zend_bool warned = FALSE;
|
||||
const char * p_orig = name;
|
||||
char * p_copy;
|
||||
p_copy = ret = mnd_emalloc(strlen(name) + 1 + 2 + 2 + 1); /* space, open, close, NullS */
|
||||
*p_copy++ = ' ';
|
||||
*p_copy++ = '/';
|
||||
*p_copy++ = '*';
|
||||
while (1) {
|
||||
register char v = *p_orig;
|
||||
if (v == 0) {
|
||||
break;
|
||||
}
|
||||
if ((v >= '0' && v <= '9') ||
|
||||
(v >= 'a' && v <= 'z') ||
|
||||
(v >= 'A' && v <= 'Z') ||
|
||||
v == '-' ||
|
||||
v == '_' ||
|
||||
v == ' ' ||
|
||||
v == '=')
|
||||
{
|
||||
*p_copy++ = v;
|
||||
} else if (warned == FALSE) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Transaction name truncated. Must be only [0-9A-Za-z\\-_=]+");
|
||||
warned = TRUE;
|
||||
}
|
||||
++p_orig;
|
||||
}
|
||||
*p_copy++ = '*';
|
||||
*p_copy++ = '/';
|
||||
*p_copy++ = 0;
|
||||
}
|
||||
DBG_RETURN(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_conn_data::tx_commit_ex */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_conn_data, tx_commit_or_rollback)(MYSQLND_CONN_DATA * conn, const zend_bool commit, const unsigned int flags, const char * const name TSRMLS_DC)
|
||||
|
@ -2710,23 +2753,26 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_commit_or_rollback)(MYSQLND_CONN_DATA * con
|
|||
conn->m->tx_cor_options_to_string(conn, &tmp_str, flags TSRMLS_CC);
|
||||
smart_str_0(&tmp_str);
|
||||
|
||||
{
|
||||
char * commented_name = NULL;
|
||||
unsigned int commented_name_len = name? mnd_sprintf(&commented_name, 0, " /*%s*/", name):0;
|
||||
char * query;
|
||||
unsigned int query_len = mnd_sprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"),
|
||||
commented_name? commented_name:"", tmp_str.c? tmp_str.c:"");
|
||||
smart_str_free(&tmp_str);
|
||||
|
||||
{
|
||||
char * query;
|
||||
size_t query_len;
|
||||
char * name_esc = mysqlnd_escape_string_for_tx_name_in_comment(name TSRMLS_CC);
|
||||
|
||||
query_len = mnd_sprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"),
|
||||
name_esc? name_esc:"", tmp_str.c? tmp_str.c:"");
|
||||
smart_str_free(&tmp_str);
|
||||
if (name_esc) {
|
||||
mnd_efree(name_esc);
|
||||
name_esc = NULL;
|
||||
}
|
||||
if (!query) {
|
||||
SET_OOM_ERROR(*conn->error_info);
|
||||
break;
|
||||
}
|
||||
|
||||
ret = conn->m->query(conn, query, query_len TSRMLS_CC);
|
||||
mnd_sprintf_free(query);
|
||||
if (commented_name) {
|
||||
mnd_sprintf_free(commented_name);
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);
|
||||
|
@ -2754,36 +2800,41 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_begin)(MYSQLND_CONN_DATA * conn, const unsi
|
|||
}
|
||||
smart_str_appendl(&tmp_str, "WITH CONSISTENT SNAPSHOT", sizeof("WITH CONSISTENT SNAPSHOT") - 1);
|
||||
}
|
||||
if (mode & TRANS_START_READ_WRITE) {
|
||||
if (tmp_str.len) {
|
||||
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
|
||||
if (mode & (TRANS_START_READ_WRITE | TRANS_START_READ_ONLY)) {
|
||||
unsigned long server_version = conn->m->get_server_version(conn TSRMLS_CC);
|
||||
if (server_version < 50605L) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required");
|
||||
smart_str_free(&tmp_str);
|
||||
break;
|
||||
} else if (mode & TRANS_START_READ_WRITE) {
|
||||
if (tmp_str.len) {
|
||||
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
|
||||
}
|
||||
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
|
||||
} else if (mode & TRANS_START_READ_ONLY) {
|
||||
if (tmp_str.len) {
|
||||
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
|
||||
}
|
||||
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1);
|
||||
}
|
||||
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
|
||||
}
|
||||
if (mode & TRANS_START_READ_ONLY) {
|
||||
if (tmp_str.len) {
|
||||
smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1);
|
||||
}
|
||||
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1);
|
||||
}
|
||||
smart_str_0(&tmp_str);
|
||||
|
||||
{
|
||||
char * commented_name = NULL;
|
||||
unsigned int commented_name_len = name? mnd_sprintf(&commented_name, 0, " /*%s*/", name):0;
|
||||
char * name_esc = mysqlnd_escape_string_for_tx_name_in_comment(name TSRMLS_CC);
|
||||
char * query;
|
||||
unsigned int query_len = mnd_sprintf(&query, 0, "START TRANSACTION%s %s", commented_name? commented_name:"", tmp_str.c? tmp_str.c:"");
|
||||
unsigned int query_len = mnd_sprintf(&query, 0, "START TRANSACTION%s %s", name_esc? name_esc:"", tmp_str.c? tmp_str.c:"");
|
||||
smart_str_free(&tmp_str);
|
||||
|
||||
if (name_esc) {
|
||||
mnd_efree(name_esc);
|
||||
name_esc = NULL;
|
||||
}
|
||||
if (!query) {
|
||||
SET_OOM_ERROR(*conn->error_info);
|
||||
break;
|
||||
}
|
||||
ret = conn->m->query(conn, query, query_len TSRMLS_CC);
|
||||
mnd_sprintf_free(query);
|
||||
if (commented_name) {
|
||||
mnd_sprintf_free(commented_name);
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);
|
||||
|
|
|
@ -61,7 +61,7 @@ PHPAPI void
|
|||
mysqlnd_reverse_api_register_api(MYSQLND_REVERSE_API * apiext TSRMLS_DC)
|
||||
{
|
||||
zend_hash_add(&mysqlnd_api_ext_ht, apiext->module->name, strlen(apiext->module->name) + 1, &apiext,
|
||||
sizeof(MYSQLND_REVERSE_API), NULL);
|
||||
sizeof(MYSQLND_REVERSE_API *), NULL);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -107,17 +107,17 @@ static void
|
|||
mysqlnd_minfo_dump_api_plugins(smart_str * buffer TSRMLS_DC)
|
||||
{
|
||||
HashTable *ht = mysqlnd_reverse_api_get_api_list(TSRMLS_C);
|
||||
Bucket *p;
|
||||
HashPosition pos;
|
||||
MYSQLND_REVERSE_API **ext;
|
||||
|
||||
p = ht->pListHead;
|
||||
while(p != NULL) {
|
||||
MYSQLND_REVERSE_API * ext = *(MYSQLND_REVERSE_API **) p->pData;
|
||||
for (zend_hash_internal_pointer_reset_ex(ht, &pos);
|
||||
zend_hash_get_current_data_ex(ht, (void **) &ext, &pos);
|
||||
zend_hash_move_forward_ex(ht, &pos)
|
||||
) {
|
||||
if (buffer->len) {
|
||||
smart_str_appendc(buffer, ',');
|
||||
}
|
||||
smart_str_appends(buffer, ext->module->name);
|
||||
|
||||
p = p->pListNext;
|
||||
smart_str_appends(buffer, (*ext)->module->name);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -290,7 +290,7 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_field_name, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, statement_resource)
|
||||
ZEND_ARG_INFO(0, column_number)
|
||||
ZEND_ARG_INFO(0, column_number_or_name)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_field_size, 0, 0, 2)
|
||||
|
@ -300,22 +300,22 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_field_scale, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, statement_resource)
|
||||
ZEND_ARG_INFO(0, column_number)
|
||||
ZEND_ARG_INFO(0, column_number_or_name)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_field_precision, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, statement_resource)
|
||||
ZEND_ARG_INFO(0, column_number)
|
||||
ZEND_ARG_INFO(0, column_number_or_name)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_field_type, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, statement_resource)
|
||||
ZEND_ARG_INFO(0, column_number)
|
||||
ZEND_ARG_INFO(0, column_number_or_name)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_field_type_raw, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, statement_resource)
|
||||
ZEND_ARG_INFO(0, column_number)
|
||||
ZEND_ARG_INFO(0, column_number_or_name)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_field_is_null, 0, 0, 2)
|
||||
|
|
|
@ -1139,7 +1139,7 @@ PHP_FUNCTION(oci_commit)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string oci_field_name(resource stmt, int col)
|
||||
/* {{{ proto string oci_field_name(resource stmt, mixed col)
|
||||
Tell the name of a column */
|
||||
PHP_FUNCTION(oci_field_name)
|
||||
{
|
||||
|
@ -1152,7 +1152,7 @@ PHP_FUNCTION(oci_field_name)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int oci_field_size(resource stmt, int col)
|
||||
/* {{{ proto int oci_field_size(resource stmt, mixed col)
|
||||
Tell the maximum data size of a column */
|
||||
PHP_FUNCTION(oci_field_size)
|
||||
{
|
||||
|
@ -1169,7 +1169,7 @@ PHP_FUNCTION(oci_field_size)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int oci_field_scale(resource stmt, int col)
|
||||
/* {{{ proto int oci_field_scale(resource stmt, mixed col)
|
||||
Tell the scale of a column */
|
||||
PHP_FUNCTION(oci_field_scale)
|
||||
{
|
||||
|
@ -1182,7 +1182,7 @@ PHP_FUNCTION(oci_field_scale)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int oci_field_precision(resource stmt, int col)
|
||||
/* {{{ proto int oci_field_precision(resource stmt, mixed col)
|
||||
Tell the precision of a column */
|
||||
PHP_FUNCTION(oci_field_precision)
|
||||
{
|
||||
|
@ -1195,7 +1195,7 @@ PHP_FUNCTION(oci_field_precision)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto mixed oci_field_type(resource stmt, int col)
|
||||
/* {{{ proto mixed oci_field_type(resource stmt, mixed col)
|
||||
Tell the data type of a column */
|
||||
PHP_FUNCTION(oci_field_type)
|
||||
{
|
||||
|
@ -1275,7 +1275,7 @@ PHP_FUNCTION(oci_field_type)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int oci_field_type_raw(resource stmt, int col)
|
||||
/* {{{ proto int oci_field_type_raw(resource stmt, mixed col)
|
||||
Tell the raw oracle data type of a column */
|
||||
PHP_FUNCTION(oci_field_type_raw)
|
||||
{
|
||||
|
@ -1289,8 +1289,8 @@ PHP_FUNCTION(oci_field_type_raw)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool oci_field_is_null(resource stmt, int col)
|
||||
Tell whether a column is NULL */
|
||||
/* {{{ proto bool oci_field_is_null(resource stmt, mixed col)
|
||||
Tell whether a field in the current row is NULL */
|
||||
PHP_FUNCTION(oci_field_is_null)
|
||||
{
|
||||
php_oci_out_column *column;
|
||||
|
|
|
@ -45,12 +45,12 @@ libraries are available.
|
|||
<active>no</active>
|
||||
</lead>
|
||||
|
||||
<date>2014-03-11</date>
|
||||
<date>2014-03-19</date>
|
||||
<time>12:00:00</time>
|
||||
|
||||
<version>
|
||||
<release>2.0.8</release>
|
||||
<api>2.0.8</api>
|
||||
<release>2.0.9</release>
|
||||
<api>2.0.9</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
|
@ -58,7 +58,7 @@ libraries are available.
|
|||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP</license>
|
||||
<notes>
|
||||
Enhancement - Improve performance of multi-row OCI_RETURN_LOB queries (Bug #66875)
|
||||
Fixed oci_field_* reflection: $field can be a column name or index
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
|
@ -461,6 +461,21 @@ Enhancement - Improve performance of multi-row OCI_RETURN_LOB queries (Bug #6687
|
|||
</extsrcrelease>
|
||||
<changelog>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>2.0.8</release>
|
||||
<api>2.0.8</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP</license>
|
||||
<notes>
|
||||
Enhancement - Improve performance of multi-row OCI_RETURN_LOB queries (Bug #66875)
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>2.0.7</release>
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
*/
|
||||
#undef PHP_OCI8_VERSION
|
||||
#endif
|
||||
#define PHP_OCI8_VERSION "2.0.8"
|
||||
#define PHP_OCI8_VERSION "2.0.9"
|
||||
|
||||
extern zend_module_entry oci8_module_entry;
|
||||
#define phpext_oci8_ptr &oci8_module_entry
|
||||
|
|
|
@ -16,15 +16,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_001_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_001_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_001_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -42,11 +42,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_001_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_001_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = "";
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_002_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_002_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_002_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -42,11 +42,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_002_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_002_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05");
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_003_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_003_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_003_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_003_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_003_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17");
|
||||
|
||||
|
@ -63,7 +63,7 @@ echo "Done\n";
|
|||
?>
|
||||
--EXPECTF--
|
||||
Warning: oci_execute(): ORA-01403: %s
|
||||
ORA-06512: at "SYSTEM.ARRAYBINDPKG1", line %d
|
||||
ORA-06512: at "SYSTEM.ARRAY_BIND_003_PKG", line %d
|
||||
ORA-06512: at line %d in %sarray_bind_003.php on line %d
|
||||
array(4) {
|
||||
[0]=>
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_004_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_004_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_004_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_004_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_004_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array();
|
||||
|
||||
|
@ -63,7 +63,7 @@ echo "Done\n";
|
|||
?>
|
||||
--EXPECTF--
|
||||
Warning: oci_execute(): ORA-01403: %s
|
||||
ORA-06512: at "SYSTEM.ARRAYBINDPKG1", line %d
|
||||
ORA-06512: at "SYSTEM.ARRAY_BIND_004_PKG", line %d
|
||||
ORA-06512: at line %d in %sarray_bind_004.php on line %d
|
||||
array(0) {
|
||||
}
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_005_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_005_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_005_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_005_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_005_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array("", "", "", "", "");
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_006_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_006_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_006_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_006_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_006_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = array("one", "two", "three", "four", "five");
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_007_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_007_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_007_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -42,11 +42,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_007_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_007_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array(1,2,3,4,5);
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_008_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_008_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_008_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_008_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_008_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array(1,2,3,4,5);
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_011_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_011_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_011_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -42,11 +42,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_011_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_011_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = array();
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_014_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_014_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_014_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -42,7 +42,7 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_014_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
|
@ -51,7 +51,7 @@ for ($i = 1; $i < 6; $i++) {
|
|||
oci_execute($statement);
|
||||
}
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_014_pkg.iobind(:c1); END;");
|
||||
$array = Array();
|
||||
oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_INT);
|
||||
oci_execute($statement);
|
||||
|
|
|
@ -11,7 +11,7 @@ if (!defined('SQLT_BDOUBLE')) die('skip SQLT_BDOUBLE type not available on older
|
|||
|
||||
require dirname(__FILE__).'/connect.inc';
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_bdouble_pkg.iobind(:c1); END;");
|
||||
$array = Array(1.243,2.5658,3.4234,4.2123,5.9999);
|
||||
oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_BDOUBLE);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ if (!defined('SQLT_BFLOAT')) die('skip SQLT_BFLOAT type not available on older O
|
|||
|
||||
require dirname(__FILE__).'/connect.inc';
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_bfloat_pkg.iobind(:c1); END;");
|
||||
$array = Array(1.243,2.5658,3.4234,4.2123,5.9999);
|
||||
oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_BFLOAT);
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_DATE_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_DATE_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_DATE_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_DATE_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_date_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05");
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_DATE1_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_DATE1_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_DATE1_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_DATE1_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_date1_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05");
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_FLOAT_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF FLOAT INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_FLOAT_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_FLOAT_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_FLOAT_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_float_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array(1.243,2.5658,3.4234,4.2123,5.9999);
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_FLOAT1_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF FLOAT INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_FLOAT1_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_FLOAT1_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_FLOAT1_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_float1_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array(1.243,2.5658,3.4234,4.2123,5.9999);
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_INT_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_INT_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_INT_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_INT_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_int_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array(1,2,3,4,5);
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_INT1_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_INT1_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_INT1_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_INT1_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_int1_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array(1,2,3,4,5);
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_STR_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_STR_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_STR_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_STR_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_str_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array("one", "two", "three", "four", "five");
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE ARRAY_BIND_STR1_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_STR1_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAY_BIND_STR1_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,11 +45,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END ARRAY_BIND_STR1_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_str1_pkg.iobind(:c1); END;");
|
||||
|
||||
$array = Array("one", "two", "three", "four", "five");
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ require(dirname(__FILE__).'/skipif.inc');
|
|||
|
||||
require dirname(__FILE__).'/connect.inc';
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN array_bind_uin_pkg.iobind(:c1); END;");
|
||||
$array = Array(1.243,2.5658,3.4234,4.2123,5.9999);
|
||||
oci_bind_array_by_name($statement, ":c1", $array, 5, 5, SQLT_UIN);
|
||||
|
||||
|
|
|
@ -10,19 +10,19 @@ require(dirname(__FILE__).'/skipif.inc');
|
|||
|
||||
require dirname(__FILE__)."/connect.inc";
|
||||
|
||||
$p1 = "create or replace package ARRAYBINDPKG1 as
|
||||
$p1 = "create or replace package BUG37581_PKG as
|
||||
type str_array is table of char(2) index by binary_integer;
|
||||
procedure array_bind(in_str in str_array, out_str out string);
|
||||
end ARRAYBINDPKG1;";
|
||||
end BUG37581_PKG;";
|
||||
|
||||
$p2 = "create or replace package body ARRAYBINDPKG1 as
|
||||
$p2 = "create or replace package body BUG37581_PKG as
|
||||
procedure array_bind(in_str in str_array, out_str out string) is
|
||||
begin
|
||||
for i in 1 .. in_str.count loop
|
||||
out_str := in_str(i);
|
||||
end loop;
|
||||
end array_bind;
|
||||
end ARRAYBINDPKG1;";
|
||||
end BUG37581_PKG;";
|
||||
|
||||
$s1 = oci_parse($c, $p1);
|
||||
$s2 = oci_parse($c, $p2);
|
||||
|
@ -30,7 +30,7 @@ oci_execute($s1);
|
|||
oci_execute($s2);
|
||||
|
||||
|
||||
$stmt = oci_parse($c,'begin ARRAYBINDPKG1.array_bind(:in_arr, :out_str); end;');
|
||||
$stmt = oci_parse($c,'begin bug37581_pkg.array_bind(:in_arr, :out_str); end;');
|
||||
$strings = array('A','B','C','D','E');
|
||||
|
||||
oci_bind_array_by_name($stmt,':in_arr',$strings,5,1,SQLT_AFC);
|
||||
|
|
|
@ -11,15 +11,15 @@ require(dirname(__FILE__).'/skipif.inc');
|
|||
require dirname(__FILE__).'/connect.inc';
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BUG40078_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE nullbind(c1 OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END BUG40078_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY BUG40078_PKG AS
|
||||
PROCEDURE nullbind(c1 OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
c1(1) := 'one';
|
||||
|
@ -28,11 +28,11 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
c1(4) := 'four';
|
||||
c1(5) := 'five';
|
||||
END nullbind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END BUG40078_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.nullbind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN bug40078_pkg.nullbind(:c1); END;");
|
||||
|
||||
oci_bind_array_by_name($statement, ":c1", $array, 5, 20, SQLT_CHR);
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ $statement = oci_parse($c, $create);
|
|||
oci_execute($statement);
|
||||
|
||||
$create_pkg = "
|
||||
CREATE OR REPLACE PACKAGE ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BUG51253_PKG AS
|
||||
TYPE ARRTYPE IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE);
|
||||
END ARRAYBINDPKG1;";
|
||||
END BUG51253_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg);
|
||||
oci_execute($statement);
|
||||
|
||||
$create_pkg_body = "
|
||||
CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
||||
CREATE OR REPLACE PACKAGE BODY BUG51253_PKG AS
|
||||
CURSOR CUR IS SELECT name FROM bind_test;
|
||||
PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
|
||||
BEGIN
|
||||
|
@ -45,12 +45,12 @@ CREATE OR REPLACE PACKAGE BODY ARRAYBINDPKG1 AS
|
|||
END IF;
|
||||
END LOOP;
|
||||
END iobind;
|
||||
END ARRAYBINDPKG1;";
|
||||
END BUG51253_PKG;";
|
||||
$statement = oci_parse($c, $create_pkg_body);
|
||||
oci_execute($statement);
|
||||
|
||||
echo "Test 1\n";
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN bug51253_pkg.iobind(:c1); END;");
|
||||
$array1 = array("one", "two", "three", "four", "five");
|
||||
$array2 = $array1;
|
||||
oci_bind_array_by_name($statement, ":c1", $array2, 5, -1, SQLT_CHR);
|
||||
|
@ -61,7 +61,7 @@ var_dump($array2);
|
|||
|
||||
|
||||
echo "Test 2\n";
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN bug51253_pkg.iobind(:c1); END;");
|
||||
$array1 = array("one", "two", "three", "four", "five");
|
||||
$array2 = &$array1;
|
||||
oci_bind_array_by_name($statement, ":c1", $array2, 5, -1, SQLT_CHR);
|
||||
|
@ -72,7 +72,7 @@ var_dump($array2);
|
|||
|
||||
|
||||
echo "Test 3\n";
|
||||
$statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;");
|
||||
$statement = oci_parse($c, "BEGIN bug51253_pkg.iobind(:c1); END;");
|
||||
$array1 = array("one", "two", "three", "four", "five");
|
||||
$array2 = &$array1;
|
||||
oci_bind_array_by_name($statement, ":c1", $array1, 5, -1, SQLT_CHR);
|
||||
|
@ -82,7 +82,7 @@ var_dump($array1);
|
|||
var_dump($array2);
|
||||
|
||||
// Cleanup
|
||||
$statement = oci_parse($c, "DROP PACKAGE ARRAYBINDPKG1");
|
||||
$statement = oci_parse($c, "DROP PACKAGE BUG51253_PKG");
|
||||
@oci_execute($statement);
|
||||
$statement = oci_parse($c, "DROP TABLE BIND_TEST");
|
||||
@oci_execute($statement);
|
||||
|
|
|
@ -177,7 +177,7 @@ Function [ <internal%s> function oci_field_name ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ Function [ <internal%s> function oci_field_scale ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ Function [ <internal%s> function oci_field_precision ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ Function [ <internal%s> function oci_field_type ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ Function [ <internal%s> function oci_field_type_raw ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ Function [ <internal%s> function ocicolumnname ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ Function [ <internal%s> function ocicolumnscale ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -746,7 +746,7 @@ Function [ <internal%s> function ocicolumnprecision ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -754,7 +754,7 @@ Function [ <internal%s> function ocicolumntype ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,7 +762,7 @@ Function [ <internal%s> function ocicolumntyperaw ] {
|
|||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $statement_resource ]
|
||||
Parameter #1 [ <required> $column_number ]
|
||||
Parameter #1 [ <required> $column_number_or_name ]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
ARG_ENABLE("opcache", "whether to enable Zend OPcache support", "yes");
|
||||
|
||||
if (PHP_OPCACHE != "no") {
|
||||
var PHP_OPCACHE_PGO = false;
|
||||
|
||||
PHP_PGI = "no"; // workaround
|
||||
PHP_PGO = "no"; // workaround
|
||||
if (PHP_OPCACHE != "no") {
|
||||
|
||||
EXTENSION('opcache', "\
|
||||
ZendAccelerator.c \
|
||||
|
|
|
@ -918,7 +918,7 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
|
|||
req->digest = req->md_alg = EVP_get_digestbyname(req->digest_name);
|
||||
}
|
||||
if (req->md_alg == NULL) {
|
||||
req->md_alg = req->digest = EVP_md5();
|
||||
req->md_alg = req->digest = EVP_sha1();
|
||||
}
|
||||
|
||||
PHP_SSL_CONFIG_SYNTAX_CHECK(extensions_section);
|
||||
|
@ -5310,7 +5310,7 @@ PHP_FUNCTION(openssl_cipher_iv_length)
|
|||
|
||||
|
||||
/* {{{ proto string openssl_dh_compute_key(string pub_key, resource dh_key)
|
||||
Computes shared sicret for public value of remote DH key and local DH key */
|
||||
Computes shared secret for public value of remote DH key and local DH key */
|
||||
PHP_FUNCTION(openssl_dh_compute_key)
|
||||
{
|
||||
zval *key;
|
||||
|
|
|
@ -3,7 +3,6 @@ default_bits = 1024
|
|||
default_keyfile = privkey.pem
|
||||
distinguished_name = req_distinguished_name
|
||||
attributes = req_attributes
|
||||
default_md = sha1
|
||||
x509_extensions = v3_ca # The extensions to add to the self signed cert
|
||||
string_mask = MASK:4294967295
|
||||
|
||||
|
|
|
@ -577,6 +577,8 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
|
|||
int i, rc;
|
||||
int subpats_order; /* Order of subpattern matches */
|
||||
int offset_capture; /* Capture match offsets: yes/no */
|
||||
unsigned char *mark = NULL; /* Target for MARK name */
|
||||
zval *marks = NULL; /* Array of marks for PREG_PATTERN_ORDER */
|
||||
|
||||
/* Overwrite the passed-in value for subpatterns with an empty array. */
|
||||
if (subpats != NULL) {
|
||||
|
@ -619,6 +621,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
|
|||
}
|
||||
extra->match_limit = PCRE_G(backtrack_limit);
|
||||
extra->match_limit_recursion = PCRE_G(recursion_limit);
|
||||
#ifdef PCRE_EXTRA_MARK
|
||||
extra->mark = &mark;
|
||||
extra->flags |= PCRE_EXTRA_MARK;
|
||||
#endif
|
||||
|
||||
/* Calculate the size of the offsets array, and allocate memory for it. */
|
||||
rc = pcre_fullinfo(pce->re, extra, PCRE_INFO_CAPTURECOUNT, &num_subpats);
|
||||
|
@ -695,6 +701,14 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
|
|||
offsets[(i<<1)+1] - offsets[i<<1], 1);
|
||||
}
|
||||
}
|
||||
/* Add MARK, if available */
|
||||
if (mark) {
|
||||
if (!marks) {
|
||||
MAKE_STD_ZVAL(marks);
|
||||
array_init(marks);
|
||||
}
|
||||
add_index_string(marks, matched - 1, (char *) mark, 1);
|
||||
}
|
||||
/*
|
||||
* If the number of captured subpatterns on this run is
|
||||
* less than the total possible number, pad the result
|
||||
|
@ -725,6 +739,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
|
|||
offsets[(i<<1)+1] - offsets[i<<1], 1);
|
||||
}
|
||||
}
|
||||
/* Add MARK, if available */
|
||||
if (mark) {
|
||||
add_assoc_string(result_set, "MARK", (char *) mark, 1);
|
||||
}
|
||||
/* And add it to the output array */
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(subpats), &result_set, sizeof(zval *), NULL);
|
||||
}
|
||||
|
@ -744,6 +762,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
|
|||
offsets[(i<<1)+1] - offsets[i<<1], 1);
|
||||
}
|
||||
}
|
||||
/* Add MARK, if available */
|
||||
if (mark) {
|
||||
add_assoc_string(subpats, "MARK", (char *) mark, 1);
|
||||
}
|
||||
}
|
||||
|
||||
pcre_free((void *) stringlist);
|
||||
|
@ -784,6 +806,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
|
|||
zend_hash_next_index_insert(Z_ARRVAL_P(subpats), &match_sets[i], sizeof(zval *), NULL);
|
||||
}
|
||||
efree(match_sets);
|
||||
|
||||
if (marks) {
|
||||
add_assoc_zval(subpats, "MARK", marks);
|
||||
}
|
||||
}
|
||||
|
||||
efree(offsets);
|
||||
|
@ -855,7 +881,7 @@ static int preg_get_backref(char **str, int *backref)
|
|||
|
||||
/* {{{ preg_do_repl_func
|
||||
*/
|
||||
static int preg_do_repl_func(zval *function, char *subject, int *offsets, char **subpat_names, int count, char **result TSRMLS_DC)
|
||||
static int preg_do_repl_func(zval *function, char *subject, int *offsets, char **subpat_names, int count, unsigned char *mark, char **result TSRMLS_DC)
|
||||
{
|
||||
zval *retval_ptr; /* Function return value */
|
||||
zval **args[1]; /* Argument to pass to function */
|
||||
|
@ -871,6 +897,9 @@ static int preg_do_repl_func(zval *function, char *subject, int *offsets, char *
|
|||
}
|
||||
add_next_index_stringl(subpats, &subject[offsets[i<<1]], offsets[(i<<1)+1] - offsets[i<<1], 1);
|
||||
}
|
||||
if (mark) {
|
||||
add_assoc_string(subpats, "MARK", (char *) mark, 1);
|
||||
}
|
||||
args[0] = &subpats;
|
||||
|
||||
if (call_user_function_ex(EG(function_table), NULL, function, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) {
|
||||
|
@ -1032,6 +1061,7 @@ PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int sub
|
|||
*eval_result, /* Result of eval or custom function */
|
||||
walk_last; /* Last walked character */
|
||||
int rc;
|
||||
unsigned char *mark = NULL; /* Target for MARK name */
|
||||
|
||||
if (extra == NULL) {
|
||||
extra_data.flags = PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION;
|
||||
|
@ -1039,6 +1069,10 @@ PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int sub
|
|||
}
|
||||
extra->match_limit = PCRE_G(backtrack_limit);
|
||||
extra->match_limit_recursion = PCRE_G(recursion_limit);
|
||||
#ifdef PCRE_EXTRA_MARK
|
||||
extra->mark = &mark;
|
||||
extra->flags |= PCRE_EXTRA_MARK;
|
||||
#endif
|
||||
|
||||
eval = pce->preg_options & PREG_REPLACE_EVAL;
|
||||
if (is_callable_replace) {
|
||||
|
@ -1118,7 +1152,7 @@ PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int sub
|
|||
new_len += eval_result_len;
|
||||
} else if (is_callable_replace) {
|
||||
/* Use custom function to get replacement string and its length. */
|
||||
eval_result_len = preg_do_repl_func(replace_val, subject, offsets, subpat_names, count, &eval_result TSRMLS_CC);
|
||||
eval_result_len = preg_do_repl_func(replace_val, subject, offsets, subpat_names, count, mark, &eval_result TSRMLS_CC);
|
||||
new_len += eval_result_len;
|
||||
} else { /* do regular substitution */
|
||||
walk = replace;
|
||||
|
@ -1517,6 +1551,9 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec
|
|||
}
|
||||
extra->match_limit = PCRE_G(backtrack_limit);
|
||||
extra->match_limit_recursion = PCRE_G(recursion_limit);
|
||||
#ifdef PCRE_EXTRA_MARK
|
||||
extra->flags &= ~PCRE_EXTRA_MARK;
|
||||
#endif
|
||||
|
||||
/* Initialize return value */
|
||||
array_init(return_value);
|
||||
|
@ -1785,6 +1822,9 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
|
|||
}
|
||||
extra->match_limit = PCRE_G(backtrack_limit);
|
||||
extra->match_limit_recursion = PCRE_G(recursion_limit);
|
||||
#ifdef PCRE_EXTRA_MARK
|
||||
extra->flags &= ~PCRE_EXTRA_MARK;
|
||||
#endif
|
||||
|
||||
/* Calculate the size of the offsets array, and allocate memory for it. */
|
||||
rc = pcre_fullinfo(pce->re, extra, PCRE_INFO_CAPTURECOUNT, &size_offsets);
|
||||
|
|
202
ext/pcre/tests/marks.phpt
Normal file
202
ext/pcre/tests/marks.phpt
Normal file
|
@ -0,0 +1,202 @@
|
|||
--TEST--
|
||||
Test support for PCRE marks
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (version_compare(PCRE_VERSION, '8.1', '<')) {
|
||||
die('skip PCRE_VERSION >= 8.1 is required for MARK support');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$regex = <<<'REGEX'
|
||||
/
|
||||
_ (a) (*MARK:A_MARK) _
|
||||
| _ (b) _
|
||||
| _ (c) (*MARK:C_MARK) _
|
||||
| _ (d) _
|
||||
/x
|
||||
REGEX;
|
||||
|
||||
var_dump(preg_match($regex, '_c_', $matches));
|
||||
var_dump($matches);
|
||||
|
||||
var_dump(preg_match_all($regex, '_a__b__c__d_', $matches, PREG_PATTERN_ORDER));
|
||||
var_dump($matches);
|
||||
|
||||
var_dump(preg_match_all($regex, '_a__b__c__d_', $matches, PREG_SET_ORDER));
|
||||
var_dump($matches);
|
||||
|
||||
var_dump(preg_replace_callback($regex, function($matches) {
|
||||
var_dump($matches);
|
||||
return $matches[0];
|
||||
}, '_a__b__c__d_'));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
int(1)
|
||||
array(5) {
|
||||
[0]=>
|
||||
string(3) "_c_"
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(1) "c"
|
||||
["MARK"]=>
|
||||
string(6) "C_MARK"
|
||||
}
|
||||
int(4)
|
||||
array(6) {
|
||||
[0]=>
|
||||
array(4) {
|
||||
[0]=>
|
||||
string(3) "_a_"
|
||||
[1]=>
|
||||
string(3) "_b_"
|
||||
[2]=>
|
||||
string(3) "_c_"
|
||||
[3]=>
|
||||
string(3) "_d_"
|
||||
}
|
||||
[1]=>
|
||||
array(4) {
|
||||
[0]=>
|
||||
string(1) "a"
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(0) ""
|
||||
}
|
||||
[2]=>
|
||||
array(4) {
|
||||
[0]=>
|
||||
string(0) ""
|
||||
[1]=>
|
||||
string(1) "b"
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(0) ""
|
||||
}
|
||||
[3]=>
|
||||
array(4) {
|
||||
[0]=>
|
||||
string(0) ""
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(1) "c"
|
||||
[3]=>
|
||||
string(0) ""
|
||||
}
|
||||
[4]=>
|
||||
array(4) {
|
||||
[0]=>
|
||||
string(0) ""
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(1) "d"
|
||||
}
|
||||
["MARK"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(6) "A_MARK"
|
||||
[2]=>
|
||||
string(6) "C_MARK"
|
||||
}
|
||||
}
|
||||
int(4)
|
||||
array(4) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(3) "_a_"
|
||||
[1]=>
|
||||
string(1) "a"
|
||||
["MARK"]=>
|
||||
string(6) "A_MARK"
|
||||
}
|
||||
[1]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(3) "_b_"
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(1) "b"
|
||||
}
|
||||
[2]=>
|
||||
array(5) {
|
||||
[0]=>
|
||||
string(3) "_c_"
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(1) "c"
|
||||
["MARK"]=>
|
||||
string(6) "C_MARK"
|
||||
}
|
||||
[3]=>
|
||||
array(5) {
|
||||
[0]=>
|
||||
string(3) "_d_"
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(0) ""
|
||||
[4]=>
|
||||
string(1) "d"
|
||||
}
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(3) "_a_"
|
||||
[1]=>
|
||||
string(1) "a"
|
||||
["MARK"]=>
|
||||
string(6) "A_MARK"
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(3) "_b_"
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(1) "b"
|
||||
}
|
||||
array(5) {
|
||||
[0]=>
|
||||
string(3) "_c_"
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(1) "c"
|
||||
["MARK"]=>
|
||||
string(6) "C_MARK"
|
||||
}
|
||||
array(5) {
|
||||
[0]=>
|
||||
string(3) "_d_"
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(0) ""
|
||||
[4]=>
|
||||
string(1) "d"
|
||||
}
|
||||
string(12) "_a__b__c__d_"
|
|
@ -468,23 +468,11 @@ static void pdo_stmt_construct(pdo_stmt_t *stmt, zval *object, zend_class_entry
|
|||
fci.object_ptr = object;
|
||||
fci.symbol_table = NULL;
|
||||
fci.retval_ptr_ptr = &retval;
|
||||
if (ctor_args) {
|
||||
HashTable *ht = Z_ARRVAL_P(ctor_args);
|
||||
Bucket *p;
|
||||
|
||||
fci.param_count = 0;
|
||||
fci.params = safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0);
|
||||
p = ht->pListHead;
|
||||
while (p != NULL) {
|
||||
fci.params[fci.param_count++] = (zval**)p->pData;
|
||||
p = p->pListNext;
|
||||
}
|
||||
} else {
|
||||
fci.param_count = 0;
|
||||
fci.params = NULL;
|
||||
}
|
||||
fci.params = NULL;
|
||||
fci.no_separation = 1;
|
||||
|
||||
zend_fcall_info_args(&fci, ctor_args TSRMLS_CC);
|
||||
|
||||
fcc.initialized = 1;
|
||||
fcc.function_handler = dbstmt_ce->constructor;
|
||||
fcc.calling_scope = EG(scope);
|
||||
|
|
|
@ -757,23 +757,11 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
|
|||
fci->function_name = NULL;
|
||||
fci->symbol_table = NULL;
|
||||
fci->retval_ptr_ptr = &stmt->fetch.cls.retval_ptr;
|
||||
if (stmt->fetch.cls.ctor_args) {
|
||||
HashTable *ht = Z_ARRVAL_P(stmt->fetch.cls.ctor_args);
|
||||
Bucket *p;
|
||||
|
||||
fci->param_count = 0;
|
||||
fci->params = safe_emalloc(sizeof(zval**), ht->nNumOfElements, 0);
|
||||
p = ht->pListHead;
|
||||
while (p != NULL) {
|
||||
fci->params[fci->param_count++] = (zval**)p->pData;
|
||||
p = p->pListNext;
|
||||
}
|
||||
} else {
|
||||
fci->param_count = 0;
|
||||
fci->params = NULL;
|
||||
}
|
||||
fci->params = NULL;
|
||||
fci->no_separation = 1;
|
||||
|
||||
zend_fcall_info_args(fci, stmt->fetch.cls.ctor_args TSRMLS_CC);
|
||||
|
||||
fcc->initialized = 1;
|
||||
fcc->function_handler = ce->constructor;
|
||||
fcc->calling_scope = EG(scope);
|
||||
|
|
|
@ -607,14 +607,14 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
|
|||
static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
|
||||
ISC_STATUS *s = H->isc_status;
|
||||
const ISC_STATUS *s = H->isc_status;
|
||||
char buf[400];
|
||||
long i = 0, l, sqlcode = isc_sqlcode(s);
|
||||
|
||||
if (sqlcode) {
|
||||
add_next_index_long(info, sqlcode);
|
||||
|
||||
while ((l = isc_interprete(&buf[i],&s))) {
|
||||
while ((sizeof(buf)>(i+2))&&(l = fb_interpret(&buf[i],(sizeof(buf)-i-2),&s))) {
|
||||
i += l;
|
||||
strcpy(&buf[i++], " ");
|
||||
}
|
||||
|
@ -697,8 +697,8 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
|
|||
|
||||
if (!dbh->methods) {
|
||||
char errmsg[512];
|
||||
ISC_STATUS *s = H->isc_status;
|
||||
isc_interprete(errmsg, &s);
|
||||
const ISC_STATUS *s = H->isc_status;
|
||||
fb_interpret(errmsg, sizeof(errmsg),&s);
|
||||
zend_throw_exception_ex(php_pdo_get_exception(), H->isc_status[1] TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
|
||||
"HY000", H->isc_status[1], errmsg);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ PHP_MSHUTDOWN_FUNCTION(pdo_firebird) /* {{{ */
|
|||
PHP_MINFO_FUNCTION(pdo_firebird) /* {{{ */
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "PDO Driver for Firebird/InterBase", "enabled");
|
||||
php_info_print_table_header(2, "PDO Driver for Firebird", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -115,6 +115,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_pconnect, 0, 0, 1)
|
|||
ZEND_ARG_INFO(0, database)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_connect_poll, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, connection)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#if HAVE_PQPARAMETERSTATUS
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_parameter_status, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, connection)
|
||||
|
@ -526,6 +530,18 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_get_pid, 0, 0, 0)
|
|||
ZEND_ARG_INFO(0, connection)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_socket, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, connection)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_consume_input, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, connection)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_flush, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, connection)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_meta_data, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, db)
|
||||
ZEND_ARG_INFO(0, table)
|
||||
|
@ -574,6 +590,7 @@ const zend_function_entry pgsql_functions[] = {
|
|||
/* connection functions */
|
||||
PHP_FE(pg_connect, arginfo_pg_connect)
|
||||
PHP_FE(pg_pconnect, arginfo_pg_pconnect)
|
||||
PHP_FE(pg_connect_poll, arginfo_pg_connect_poll)
|
||||
PHP_FE(pg_close, arginfo_pg_close)
|
||||
PHP_FE(pg_connection_status, arginfo_pg_connection_status)
|
||||
PHP_FE(pg_connection_busy, arginfo_pg_connection_busy)
|
||||
|
@ -643,6 +660,9 @@ const zend_function_entry pgsql_functions[] = {
|
|||
#endif
|
||||
/* async message function */
|
||||
PHP_FE(pg_get_notify, arginfo_pg_get_notify)
|
||||
PHP_FE(pg_socket, arginfo_pg_socket)
|
||||
PHP_FE(pg_consume_input,arginfo_pg_consume_input)
|
||||
PHP_FE(pg_flush, arginfo_pg_flush)
|
||||
PHP_FE(pg_get_pid, arginfo_pg_get_pid)
|
||||
/* error message functions */
|
||||
PHP_FE(pg_result_error, arginfo_pg_result_error)
|
||||
|
@ -1095,6 +1115,7 @@ PHP_MINIT_FUNCTION(pgsql)
|
|||
#endif
|
||||
/* For connection option */
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECT_FORCE_NEW", PGSQL_CONNECT_FORCE_NEW, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECT_ASYNC", PGSQL_CONNECT_ASYNC, CONST_CS | CONST_PERSISTENT);
|
||||
/* For pg_fetch_array() */
|
||||
REGISTER_LONG_CONSTANT("PGSQL_ASSOC", PGSQL_ASSOC, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_NUM", PGSQL_NUM, CONST_CS | CONST_PERSISTENT);
|
||||
|
@ -1102,6 +1123,18 @@ PHP_MINIT_FUNCTION(pgsql)
|
|||
/* For pg_connection_status() */
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECTION_BAD", CONNECTION_BAD, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECTION_OK", CONNECTION_OK, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECTION_STARTED", CONNECTION_STARTED, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECTION_MADE", CONNECTION_MADE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECTION_AWAITING_RESPONSE", CONNECTION_AWAITING_RESPONSE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECTION_AUTH_OK", CONNECTION_AUTH_OK, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECTION_SSL_STARTUP", CONNECTION_SSL_STARTUP, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_CONNECTION_SETENV", CONNECTION_SETENV, CONST_CS | CONST_PERSISTENT);
|
||||
/* For pg_connect_poll() */
|
||||
REGISTER_LONG_CONSTANT("PGSQL_POLLING_FAILED", PGRES_POLLING_FAILED, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_POLLING_READING", PGRES_POLLING_READING, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_POLLING_WRITING", PGRES_POLLING_WRITING, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_POLLING_OK", PGRES_POLLING_OK, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PGSQL_POLLING_ACTIVE", PGRES_POLLING_ACTIVE, CONST_CS | CONST_PERSISTENT);
|
||||
#if HAVE_PGTRANSACTIONSTATUS
|
||||
/* For pg_transaction_status() */
|
||||
REGISTER_LONG_CONSTANT("PGSQL_TRANSACTION_IDLE", PQTRANS_IDLE, CONST_CS | CONST_PERSISTENT);
|
||||
|
@ -1401,17 +1434,35 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
|||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create new link. Too many open links (%ld)", PGG(num_links));
|
||||
goto err;
|
||||
}
|
||||
if (connstring) {
|
||||
pgsql = PQconnectdb(connstring);
|
||||
} else {
|
||||
pgsql = PQsetdb(host,port,options,tty,dbname);
|
||||
}
|
||||
if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
|
||||
PHP_PQ_ERROR("Unable to connect to PostgreSQL server: %s", pgsql);
|
||||
if (pgsql) {
|
||||
PQfinish(pgsql);
|
||||
|
||||
/* Non-blocking connect */
|
||||
if (connect_type & PGSQL_CONNECT_ASYNC) {
|
||||
if (connstring) {
|
||||
pgsql = PQconnectStart(connstring);
|
||||
if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
|
||||
PHP_PQ_ERROR("Unable to connect to PostgreSQL server: %s", pgsql);
|
||||
if (pgsql) {
|
||||
PQfinish(pgsql);
|
||||
}
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection string required for async connections");
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
if (connstring) {
|
||||
pgsql = PQconnectdb(connstring);
|
||||
} else {
|
||||
pgsql = PQsetdb(host,port,options,tty,dbname);
|
||||
}
|
||||
if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
|
||||
PHP_PQ_ERROR("Unable to connect to PostgreSQL server: %s", pgsql);
|
||||
if (pgsql) {
|
||||
PQfinish(pgsql);
|
||||
}
|
||||
goto err;
|
||||
}
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* add it to the list */
|
||||
|
@ -1463,6 +1514,31 @@ PHP_FUNCTION(pg_connect)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto resource pg_connect_poll(resource connection)
|
||||
Poll the status of an in-progress async PostgreSQL connection attempt*/
|
||||
PHP_FUNCTION(pg_connect_poll)
|
||||
{
|
||||
zval *pgsql_link;
|
||||
int id = -1;
|
||||
PGconn *pgsql;
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pgsql_link) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pgsql_link == NULL && id == -1) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
ret = PQconnectPoll(pgsql);
|
||||
|
||||
RETURN_LONG(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto resource pg_pconnect(string connection_string | [string host, string port [, string options [, string tty,]]] string database)
|
||||
Open a persistent PostgreSQL connection */
|
||||
PHP_FUNCTION(pg_pconnect)
|
||||
|
@ -2717,33 +2793,22 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
|
|||
fci.symbol_table = NULL;
|
||||
fci.object_ptr = return_value;
|
||||
fci.retval_ptr_ptr = &retval_ptr;
|
||||
if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
|
||||
if (Z_TYPE_P(ctor_params) == IS_ARRAY) {
|
||||
HashTable *ht = Z_ARRVAL_P(ctor_params);
|
||||
Bucket *p;
|
||||
fci.params = NULL;
|
||||
fci.param_count = 0;
|
||||
fci.no_separation = 1;
|
||||
|
||||
fci.param_count = 0;
|
||||
fci.params = safe_emalloc(sizeof(zval***), ht->nNumOfElements, 0);
|
||||
p = ht->pListHead;
|
||||
while (p != NULL) {
|
||||
fci.params[fci.param_count++] = (zval**)p->pData;
|
||||
p = p->pListNext;
|
||||
}
|
||||
} else {
|
||||
if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
|
||||
if (zend_fcall_info_args(&fci, ctor_params TSRMLS_CC) == FAILURE) {
|
||||
/* Two problems why we throw exceptions here: PHP is typeless
|
||||
* and hence passing one argument that's not an array could be
|
||||
* by mistake and the other way round is possible, too. The
|
||||
* by mistake and the other way round is possible, too. The
|
||||
* single value is an array. Also we'd have to make that one
|
||||
* argument passed by reference.
|
||||
*/
|
||||
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Parameter ctor_params must be an array", 0 TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
fci.param_count = 0;
|
||||
fci.params = NULL;
|
||||
}
|
||||
fci.no_separation = 1;
|
||||
|
||||
fcc.initialized = 1;
|
||||
fcc.function_handler = ce->constructor;
|
||||
|
@ -4724,6 +4789,16 @@ PHP_FUNCTION(pg_connection_busy)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static int _php_pgsql_link_has_results(PGconn *pgsql)
|
||||
{
|
||||
PGresult *result;
|
||||
while ((result = PQgetResult(pgsql))) {
|
||||
PQclear(result);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* {{{ proto bool pg_send_query(resource connection, string query)
|
||||
Send asynchronous query */
|
||||
PHP_FUNCTION(pg_send_query)
|
||||
|
@ -4733,48 +4808,63 @@ PHP_FUNCTION(pg_send_query)
|
|||
int len;
|
||||
int id = -1;
|
||||
PGconn *pgsql;
|
||||
PGresult *res;
|
||||
int leftover = 0;
|
||||
int is_non_blocking;
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs",
|
||||
&pgsql_link, &query, &len) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pgsql_link, &query, &len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
if (PQ_SETNONBLOCKING(pgsql, 1)) {
|
||||
is_non_blocking = PQisnonblocking(pgsql);
|
||||
|
||||
if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to nonblocking mode");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
while ((res = PQgetResult(pgsql))) {
|
||||
PQclear(res);
|
||||
leftover = 1;
|
||||
|
||||
if (_php_pgsql_link_has_results(pgsql)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE,
|
||||
"There are results on this connection. Call pg_get_result() until it returns FALSE");
|
||||
}
|
||||
if (leftover) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There are results on this connection. Call pg_get_result() until it returns FALSE");
|
||||
}
|
||||
if (!PQsendQuery(pgsql, query)) {
|
||||
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
|
||||
PQreset(pgsql);
|
||||
}
|
||||
|
||||
if (is_non_blocking) {
|
||||
if (!PQsendQuery(pgsql, query)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* Wait to finish sending buffer */
|
||||
while ((ret = PQflush(pgsql))) {
|
||||
if (ret == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not empty PostgreSQL send buffer");
|
||||
break;
|
||||
ret = PQflush(pgsql);
|
||||
} else {
|
||||
if (!PQsendQuery(pgsql, query)) {
|
||||
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
|
||||
PQreset(pgsql);
|
||||
}
|
||||
if (!PQsendQuery(pgsql, query)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait to finish sending buffer */
|
||||
while ((ret = PQflush(pgsql))) {
|
||||
if (ret == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not empty PostgreSQL send buffer");
|
||||
break;
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
if (PQ_SETNONBLOCKING(pgsql, 0)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
if (PQ_SETNONBLOCKING(pgsql, 0)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
|
||||
|
||||
if (ret == 0) {
|
||||
RETURN_TRUE;
|
||||
} else if (ret == -1) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
RETURN_LONG(0);
|
||||
}
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -4789,8 +4879,7 @@ PHP_FUNCTION(pg_send_query_params)
|
|||
char *query;
|
||||
int query_len, id = -1;
|
||||
PGconn *pgsql;
|
||||
PGresult *res;
|
||||
int leftover = 0;
|
||||
int is_non_blocking;
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa/", &pgsql_link, &query, &query_len, &pv_param_arr) == FAILURE) {
|
||||
|
@ -4803,16 +4892,16 @@ PHP_FUNCTION(pg_send_query_params)
|
|||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
if (PQ_SETNONBLOCKING(pgsql, 1)) {
|
||||
is_non_blocking = PQisnonblocking(pgsql);
|
||||
|
||||
if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to nonblocking mode");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
while ((res = PQgetResult(pgsql))) {
|
||||
PQclear(res);
|
||||
leftover = 1;
|
||||
}
|
||||
if (leftover) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There are results on this connection. Call pg_get_result() until it returns FALSE");
|
||||
|
||||
if (_php_pgsql_link_has_results(pgsql)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE,
|
||||
"There are results on this connection. Call pg_get_result() until it returns FALSE");
|
||||
}
|
||||
|
||||
zend_hash_internal_pointer_reset(Z_ARRVAL_P(pv_param_arr));
|
||||
|
@ -4848,7 +4937,12 @@ PHP_FUNCTION(pg_send_query_params)
|
|||
}
|
||||
}
|
||||
|
||||
if (!PQsendQueryParams(pgsql, query, num_params, NULL, (const char * const *)params, NULL, NULL, 0)) {
|
||||
if (PQsendQueryParams(pgsql, query, num_params, NULL, (const char * const *)params, NULL, NULL, 0)) {
|
||||
_php_pgsql_free_params(params, num_params);
|
||||
} else if (is_non_blocking) {
|
||||
_php_pgsql_free_params(params, num_params);
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
|
||||
PQreset(pgsql);
|
||||
}
|
||||
|
@ -4857,19 +4951,31 @@ PHP_FUNCTION(pg_send_query_params)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
_php_pgsql_free_params(params, num_params);
|
||||
/* Wait to finish sending buffer */
|
||||
while ((ret = PQflush(pgsql))) {
|
||||
if (ret == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not empty PostgreSQL send buffer");
|
||||
break;
|
||||
|
||||
if (is_non_blocking) {
|
||||
ret = PQflush(pgsql);
|
||||
} else {
|
||||
/* Wait to finish sending buffer */
|
||||
while ((ret = PQflush(pgsql))) {
|
||||
if (ret == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not empty PostgreSQL send buffer");
|
||||
break;
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
if (PQ_SETNONBLOCKING(pgsql, 0) != 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
if (PQ_SETNONBLOCKING(pgsql, 0)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
|
||||
|
||||
if (ret == 0) {
|
||||
RETURN_TRUE;
|
||||
} else if (ret == -1) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
RETURN_LONG(0);
|
||||
}
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
@ -4883,8 +4989,7 @@ PHP_FUNCTION(pg_send_prepare)
|
|||
char *query, *stmtname;
|
||||
int stmtname_len, query_len, id = -1;
|
||||
PGconn *pgsql;
|
||||
PGresult *res;
|
||||
int leftover = 0;
|
||||
int is_non_blocking;
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pgsql_link, &stmtname, &stmtname_len, &query, &query_len) == FAILURE) {
|
||||
|
@ -4897,37 +5002,54 @@ PHP_FUNCTION(pg_send_prepare)
|
|||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
if (PQ_SETNONBLOCKING(pgsql, 1)) {
|
||||
is_non_blocking = PQisnonblocking(pgsql);
|
||||
|
||||
if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to nonblocking mode");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
while ((res = PQgetResult(pgsql))) {
|
||||
PQclear(res);
|
||||
leftover = 1;
|
||||
}
|
||||
if (leftover) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There are results on this connection. Call pg_get_result() until it returns FALSE");
|
||||
|
||||
if (_php_pgsql_link_has_results(pgsql)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE,
|
||||
"There are results on this connection. Call pg_get_result() until it returns FALSE");
|
||||
}
|
||||
|
||||
if (!PQsendPrepare(pgsql, stmtname, query, 0, NULL)) {
|
||||
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
|
||||
PQreset(pgsql);
|
||||
}
|
||||
if (!PQsendPrepare(pgsql, stmtname, query, 0, NULL)) {
|
||||
if (is_non_blocking) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
|
||||
PQreset(pgsql);
|
||||
}
|
||||
if (!PQsendPrepare(pgsql, stmtname, query, 0, NULL)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Wait to finish sending buffer */
|
||||
while ((ret = PQflush(pgsql))) {
|
||||
if (ret == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not empty postgres send buffer");
|
||||
break;
|
||||
|
||||
if (is_non_blocking) {
|
||||
ret = PQflush(pgsql);
|
||||
} else {
|
||||
/* Wait to finish sending buffer */
|
||||
while ((ret = PQflush(pgsql))) {
|
||||
if (ret == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not empty PostgreSQL send buffer");
|
||||
break;
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
if (PQ_SETNONBLOCKING(pgsql, 0) != 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
if (PQ_SETNONBLOCKING(pgsql, 0)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
|
||||
|
||||
if (ret == 0) {
|
||||
RETURN_TRUE;
|
||||
} else if (ret == -1) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
RETURN_LONG(0);
|
||||
}
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
@ -4944,8 +5066,7 @@ PHP_FUNCTION(pg_send_execute)
|
|||
char *stmtname;
|
||||
int stmtname_len, id = -1;
|
||||
PGconn *pgsql;
|
||||
PGresult *res;
|
||||
int leftover = 0;
|
||||
int is_non_blocking;
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa", &pgsql_link, &stmtname, &stmtname_len, &pv_param_arr) == FAILURE) {
|
||||
|
@ -4958,16 +5079,16 @@ PHP_FUNCTION(pg_send_execute)
|
|||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
if (PQ_SETNONBLOCKING(pgsql, 1)) {
|
||||
is_non_blocking = PQisnonblocking(pgsql);
|
||||
|
||||
if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to nonblocking mode");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
while ((res = PQgetResult(pgsql))) {
|
||||
PQclear(res);
|
||||
leftover = 1;
|
||||
}
|
||||
if (leftover) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There are results on this connection. Call pg_get_result() until it returns FALSE");
|
||||
|
||||
if (_php_pgsql_link_has_results(pgsql)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE,
|
||||
"There are results on this connection. Call pg_get_result() until it returns FALSE");
|
||||
}
|
||||
|
||||
zend_hash_internal_pointer_reset(Z_ARRVAL_P(pv_param_arr));
|
||||
|
@ -4975,8 +5096,8 @@ PHP_FUNCTION(pg_send_execute)
|
|||
if (num_params > 0) {
|
||||
int i = 0;
|
||||
params = (char **)safe_emalloc(sizeof(char *), num_params, 0);
|
||||
|
||||
for(i = 0; i < num_params; i++) {
|
||||
|
||||
for (i = 0; i < num_params; i++) {
|
||||
if (zend_hash_get_current_data(Z_ARRVAL_P(pv_param_arr), (void **) &tmp) == FAILURE) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error getting parameter");
|
||||
_php_pgsql_free_params(params, num_params);
|
||||
|
@ -5003,7 +5124,12 @@ PHP_FUNCTION(pg_send_execute)
|
|||
}
|
||||
}
|
||||
|
||||
if (!PQsendQueryPrepared(pgsql, stmtname, num_params, (const char * const *)params, NULL, NULL, 0)) {
|
||||
if (PQsendQueryPrepared(pgsql, stmtname, num_params, (const char * const *)params, NULL, NULL, 0)) {
|
||||
_php_pgsql_free_params(params, num_params);
|
||||
} else if (is_non_blocking) {
|
||||
_php_pgsql_free_params(params, num_params);
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
|
||||
PQreset(pgsql);
|
||||
}
|
||||
|
@ -5012,19 +5138,30 @@ PHP_FUNCTION(pg_send_execute)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
_php_pgsql_free_params(params, num_params);
|
||||
/* Wait to finish sending buffer */
|
||||
while ((ret = PQflush(pgsql))) {
|
||||
if (ret == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not empty postgres send buffer");
|
||||
break;
|
||||
|
||||
if (is_non_blocking) {
|
||||
ret = PQflush(pgsql);
|
||||
} else {
|
||||
/* Wait to finish sending buffer */
|
||||
while ((ret = PQflush(pgsql))) {
|
||||
if (ret == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not empty PostgreSQL send buffer");
|
||||
break;
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
if (PQ_SETNONBLOCKING(pgsql, 0) != 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
if (PQ_SETNONBLOCKING(pgsql, 0)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
|
||||
|
||||
if (ret == 0) {
|
||||
RETURN_TRUE;
|
||||
} else if (ret == -1) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
RETURN_LONG(0);
|
||||
}
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
@ -5169,6 +5306,141 @@ PHP_FUNCTION(pg_get_pid)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static size_t php_pgsql_fd_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t php_pgsql_fd_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int php_pgsql_fd_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
{
|
||||
return EOF;
|
||||
}
|
||||
|
||||
static int php_pgsql_fd_flush(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
static int php_pgsql_fd_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
|
||||
{
|
||||
PGconn *pgsql = (PGconn *) stream->abstract;
|
||||
switch (option) {
|
||||
case PHP_STREAM_OPTION_BLOCKING:
|
||||
return PQ_SETNONBLOCKING(pgsql, value);
|
||||
default:
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
static int php_pgsql_fd_cast(php_stream *stream, int cast_as, void **ret TSRMLS_DC)
|
||||
{
|
||||
PGconn *pgsql = (PGconn *) stream->abstract;
|
||||
int fd_number;
|
||||
|
||||
switch (cast_as) {
|
||||
case PHP_STREAM_AS_FD_FOR_SELECT:
|
||||
case PHP_STREAM_AS_FD:
|
||||
case PHP_STREAM_AS_SOCKETD:
|
||||
if (ret) {
|
||||
fd_number = PQsocket(pgsql);
|
||||
if (fd_number == -1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
*(php_socket_t *)ret = fd_number;
|
||||
return SUCCESS;
|
||||
}
|
||||
default:
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* {{{ proto resource pg_socket(resource)
|
||||
Get a read-only handle to the socket underlying the pgsql connection */
|
||||
PHP_FUNCTION(pg_socket)
|
||||
{
|
||||
zval *pgsql_link;
|
||||
php_stream *stream;
|
||||
PGconn *pgsql;
|
||||
int id = -1;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pgsql_link) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
stream = php_stream_alloc(&php_stream_pgsql_fd_ops, pgsql, NULL, "r");
|
||||
|
||||
if (stream) {
|
||||
php_stream_to_zval(stream, return_value);
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool pg_consume_input(resource)
|
||||
Reads input on the connection */
|
||||
PHP_FUNCTION(pg_consume_input)
|
||||
{
|
||||
zval *pgsql_link;
|
||||
int id = -1;
|
||||
PGconn *pgsql;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pgsql_link) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
RETURN_BOOL(PQconsumeInput(pgsql));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto mixed pg_flush(resource)
|
||||
Flush outbound query data on the connection */
|
||||
PHP_FUNCTION(pg_flush)
|
||||
{
|
||||
zval *pgsql_link;
|
||||
int id = -1;
|
||||
PGconn *pgsql;
|
||||
int ret;
|
||||
int is_non_blocking;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pgsql_link) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
|
||||
|
||||
is_non_blocking = PQisnonblocking(pgsql);
|
||||
|
||||
if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 1) == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to nonblocking mode");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ret = PQflush(pgsql);
|
||||
|
||||
if (is_non_blocking == 0 && PQ_SETNONBLOCKING(pgsql, 0) == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed resetting connection to blocking mode");
|
||||
}
|
||||
|
||||
switch (ret) {
|
||||
case 0: RETURN_TRUE; break;
|
||||
case 1: RETURN_LONG(0); break;
|
||||
default: RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_pgsql_meta_data
|
||||
* TODO: Add meta_data cache for better performance
|
||||
*/
|
||||
|
|
|
@ -67,6 +67,7 @@ PHP_MINFO_FUNCTION(pgsql);
|
|||
/* connection functions */
|
||||
PHP_FUNCTION(pg_connect);
|
||||
PHP_FUNCTION(pg_pconnect);
|
||||
PHP_FUNCTION(pg_connect_poll);
|
||||
PHP_FUNCTION(pg_close);
|
||||
PHP_FUNCTION(pg_connection_reset);
|
||||
PHP_FUNCTION(pg_connection_status);
|
||||
|
@ -134,6 +135,9 @@ PHP_FUNCTION(pg_field_is_null);
|
|||
PHP_FUNCTION(pg_field_table);
|
||||
/* async message functions */
|
||||
PHP_FUNCTION(pg_get_notify);
|
||||
PHP_FUNCTION(pg_socket);
|
||||
PHP_FUNCTION(pg_consume_input);
|
||||
PHP_FUNCTION(pg_flush);
|
||||
PHP_FUNCTION(pg_get_pid);
|
||||
/* error message functions */
|
||||
PHP_FUNCTION(pg_result_error);
|
||||
|
@ -191,6 +195,7 @@ PHP_FUNCTION(pg_select);
|
|||
|
||||
/* connection options - ToDo: Add async connection option */
|
||||
#define PGSQL_CONNECT_FORCE_NEW (1<<1)
|
||||
#define PGSQL_CONNECT_ASYNC (1<<2)
|
||||
/* php_pgsql_convert options */
|
||||
#define PGSQL_CONV_IGNORE_DEFAULT (1<<1) /* Do not use DEAFULT value by removing field from returned array */
|
||||
#define PGSQL_CONV_FORCE_NULL (1<<2) /* Convert to NULL if string is null string */
|
||||
|
@ -222,6 +227,13 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ
|
|||
static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type);
|
||||
static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS,int entry_type);
|
||||
|
||||
static size_t php_pgsql_fd_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
|
||||
static size_t php_pgsql_fd_read(php_stream *stream, char *buf, size_t count TSRMLS_DC);
|
||||
static int php_pgsql_fd_close(php_stream *stream, int close_handle TSRMLS_DC);
|
||||
static int php_pgsql_fd_flush(php_stream *stream TSRMLS_DC);
|
||||
static int php_pgsql_fd_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC);
|
||||
static int php_pgsql_fd_cast(php_stream *stream, int cast_as, void **ret TSRMLS_DC);
|
||||
|
||||
typedef enum _php_pgsql_data_type {
|
||||
/* boolean */
|
||||
PG_BOOL,
|
||||
|
@ -284,6 +296,18 @@ typedef struct _php_pgsql_notice {
|
|||
size_t len;
|
||||
} php_pgsql_notice;
|
||||
|
||||
static php_stream_ops php_stream_pgsql_fd_ops = {
|
||||
php_pgsql_fd_write,
|
||||
php_pgsql_fd_read,
|
||||
php_pgsql_fd_close,
|
||||
php_pgsql_fd_flush,
|
||||
"PostgreSQL link",
|
||||
NULL, /* seek */
|
||||
php_pgsql_fd_cast, /* cast */
|
||||
NULL, /* stat */
|
||||
php_pgsql_fd_set_option
|
||||
};
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(pgsql)
|
||||
long default_link; /* default link when connection is omitted */
|
||||
long num_links,num_persistent;
|
||||
|
|
44
ext/pgsql/tests/29nb_async_connect.phpt
Executable file
44
ext/pgsql/tests/29nb_async_connect.phpt
Executable file
|
@ -0,0 +1,44 @@
|
|||
--TEST--
|
||||
PostgreSQL non-blocking async connect
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include("skipif.inc");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
include('nonblocking.inc');
|
||||
|
||||
if (!$db = pg_connect($conn_str, PGSQL_CONNECT_ASYNC)) {
|
||||
die("pg_connect() error");
|
||||
} elseif (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
|
||||
die("pg_connect() error");
|
||||
} elseif ($db_socket = pg_socket($db)) {
|
||||
stream_set_blocking($db_socket, FALSE);
|
||||
} else {
|
||||
die("pg_socket() error");
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
switch ($status = pg_connect_poll($db)) {
|
||||
case PGSQL_POLLING_READING:
|
||||
if (nb_is_readable($db_socket)) { break 2; }
|
||||
break;
|
||||
case PGSQL_POLLING_WRITING:
|
||||
if (nb_is_writable($db_socket)) { break 2; }
|
||||
break;
|
||||
case PGSQL_POLLING_FAILED:
|
||||
die("async connection failed");
|
||||
case PGSQL_POLLING_OK:
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
assert(pg_connection_status($db) === PGSQL_CONNECTION_MADE);
|
||||
echo "OK";
|
||||
|
||||
pg_close($db);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
OK
|
78
ext/pgsql/tests/30nb_async_query_params.phpt
Executable file
78
ext/pgsql/tests/30nb_async_query_params.phpt
Executable file
|
@ -0,0 +1,78 @@
|
|||
--TEST--
|
||||
PostgreSQL non-blocking async query params
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include("skipif.inc");
|
||||
if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
include('nonblocking.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] < 3) {
|
||||
echo "OK";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$db_socket = pg_socket($db);
|
||||
stream_set_blocking($db_socket, false);
|
||||
|
||||
$sent = pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100));
|
||||
if ($sent === FALSE) {
|
||||
echo "pg_send_query_params() error\n";
|
||||
} elseif ($sent === 0) {
|
||||
nb_flush($db, $db_socket);
|
||||
}
|
||||
|
||||
nb_consume($db, $db_socket);
|
||||
|
||||
if (!($result = pg_get_result($db))) {
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
if (!($rows = pg_num_rows($result))) {
|
||||
echo "pg_num_rows() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
$sent = pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"));
|
||||
|
||||
if ($sent === FALSE) {
|
||||
echo "pg_send_query_params() error\n";
|
||||
} elseif ($sent === 0) {
|
||||
nb_flush($db, $db_socket);
|
||||
}
|
||||
|
||||
pg_last_oid($result);
|
||||
pg_free_result($result);
|
||||
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
--EXPECT--
|
||||
OK
|
112
ext/pgsql/tests/31nb_async_query_prepared.phpt
Executable file
112
ext/pgsql/tests/31nb_async_query_prepared.phpt
Executable file
|
@ -0,0 +1,112 @@
|
|||
--TEST--
|
||||
PostgreSQL non-blocking async prepared queries
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include("skipif.inc");
|
||||
if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
include('nonblocking.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] < 3) {
|
||||
echo "OK";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$db_socket = pg_socket($db);
|
||||
stream_set_blocking($db_socket, false);
|
||||
|
||||
$nb_send = pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;");
|
||||
if ($nb_send === FALSE) {
|
||||
echo "pg_send_prepare() error\n";
|
||||
} elseif ($nb_send === 0) {
|
||||
nb_flush($db, $db_socket);
|
||||
}
|
||||
|
||||
nb_consume($db, $db_socket);
|
||||
|
||||
if (!($result = pg_get_result($db))) {
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
pg_free_result($result);
|
||||
|
||||
$nb_send = pg_send_execute($db, 'php_test', array(100));
|
||||
if ($nb_send === FALSE) {
|
||||
echo "pg_send_execute() error\n";
|
||||
} elseif ($nb_send === 0) {
|
||||
nb_flush($db, $db_socket);
|
||||
}
|
||||
|
||||
nb_consume($db, $db_socket);
|
||||
|
||||
if (!($result = pg_get_result($db))) {
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
|
||||
if (!($rows = pg_num_rows($result))) {
|
||||
echo "pg_num_rows() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
$nb_send = pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);");
|
||||
if ($nb_send === FALSE) {
|
||||
echo "pg_send_prepare() error\n";
|
||||
} elseif ($nb_send === 0) {
|
||||
nb_flush($db, $db_socket);
|
||||
}
|
||||
|
||||
nb_consume($db, $db_socket);
|
||||
|
||||
if (!($result = pg_get_result($db))) {
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
pg_free_result($result);
|
||||
|
||||
$nb_send = pg_send_execute($db, "php_test2", array(9999, "A'BC"));
|
||||
if ($nb_send === FALSE) {
|
||||
echo "pg_send_execute() error\n";
|
||||
} elseif ($nb_send === 0) {
|
||||
nb_flush($db, $db_socket);
|
||||
}
|
||||
|
||||
nb_consume($db, $db_socket);
|
||||
|
||||
if (!($result = pg_get_result($db))) {
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
|
||||
pg_last_oid($result);
|
||||
pg_free_result($result);
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
--EXPECT--
|
||||
OK
|
||||
|
84
ext/pgsql/tests/32nb_async_query.phpt
Normal file
84
ext/pgsql/tests/32nb_async_query.phpt
Normal file
|
@ -0,0 +1,84 @@
|
|||
--TEST--
|
||||
PostgreSQL non-blocking async queries
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include("skipif.inc");
|
||||
if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include('config.inc');
|
||||
include('nonblocking.inc');
|
||||
|
||||
$db = pg_connect($conn_str);
|
||||
|
||||
$version = pg_version($db);
|
||||
if ($version['protocol'] < 3) {
|
||||
echo "OK";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$db_socket = pg_socket($db);
|
||||
stream_set_blocking($db_socket, false);
|
||||
|
||||
$nb_send = pg_send_query($db, "SELECT * FROM ".$table_name.";");
|
||||
if ($nb_send === FALSE) {
|
||||
echo "pg_send_query() error\n";
|
||||
} elseif ($nb_send === 0) {
|
||||
nb_flush($db, $db_socket);
|
||||
}
|
||||
|
||||
nb_consume($db, $db_socket);
|
||||
|
||||
if (!($result = pg_get_result($db))) {
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
|
||||
if (!($rows = pg_num_rows($result))) {
|
||||
echo "pg_num_rows() error\n";
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_array($result, $i, PGSQL_NUM);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_object($result);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_row($result, $i);
|
||||
}
|
||||
for ($i=0; $i < $rows; $i++) {
|
||||
pg_fetch_result($result, $i, 0);
|
||||
}
|
||||
|
||||
pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
|
||||
pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
|
||||
pg_field_name($result, 0);
|
||||
pg_field_num($result, $field_name);
|
||||
pg_field_size($result, 0);
|
||||
pg_field_type($result, 0);
|
||||
pg_field_prtlen($result, 0);
|
||||
pg_field_is_null($result, 0);
|
||||
|
||||
$nb_send = pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');");
|
||||
if ($nb_send === FALSE) {
|
||||
echo "pg_send_query() error\n";
|
||||
} elseif ($nb_send === 0) {
|
||||
nb_flush($db, $db_socket);
|
||||
}
|
||||
|
||||
nb_consume($db, $db_socket);
|
||||
|
||||
if (!($result = pg_get_result($db))) {
|
||||
echo "pg_get_result() error\n";
|
||||
}
|
||||
|
||||
pg_last_oid($result);
|
||||
pg_free_result($result);
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
?>
|
||||
--EXPECT--
|
||||
OK
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue