diff options
author | Lenar Lõhmus <flex@php.net> | 2002-11-01 14:44:06 +0000 |
---|---|---|
committer | Lenar Lõhmus <flex@php.net> | 2002-11-01 14:44:06 +0000 |
commit | d2275d91950531560cdb8925317293e2e7a46385 (patch) | |
tree | bc0b0a293aa60911e484741271b7b34aa01279f0 /ext/xslt | |
parent | f7bd4ce0ba8ff5b3361639ed20dd3c16ccd4fe55 (diff) | |
download | php-git-d2275d91950531560cdb8925317293e2e7a46385.tar.gz |
Fix scheme_getall() function so that data returned by user is always
converted to string except when script returns FALSE or NULL. In this case
signal sablotron that we are not able to handle requested scheme.
Diffstat (limited to 'ext/xslt')
-rw-r--r-- | ext/xslt/sablot.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ext/xslt/sablot.c b/ext/xslt/sablot.c index 8c2961ba13..08d83e0086 100644 --- a/ext/xslt/sablot.c +++ b/ext/xslt/sablot.c @@ -853,6 +853,7 @@ static int scheme_getall(void *user_data, SablotHandle proc, const char *scheme, { zval *argv[3]; /* Arguments to the scheme getall function */ zval *retval; /* Return value from the scheme getall function */ + int result; php_xslt *handle = (php_xslt *) user_data; /* A PHP-XSLT processor */ TSRMLS_FETCH(); @@ -883,16 +884,24 @@ static int scheme_getall(void *user_data, SablotHandle proc, const char *scheme, /* return failure */ return 1; } - - /* Save the return value in the buffer (copying it) */ - *buffer = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); - *byte_count = Z_STRLEN_P(retval); + + if ((Z_TYPE_P(retval) == IS_BOOL && Z_LVAL_P(retval) == 0) || (Z_TYPE_P(retval) == IS_NULL)) { + result = 1; + } else { + /* Convert the return value to string if needed */ + if (Z_TYPE_P(retval) != IS_STRING) + convert_to_string_ex(&retval); + + /* Save the return value in the buffer (copying it) */ + *buffer = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); + *byte_count = Z_STRLEN_P(retval); + result = 0; + } /* Free return value */ zval_ptr_dtor(&retval); - /* return success */ - return 0; + return result; } /* }}} */ |