3 Commits
0.2.1 ... 0.2.3

Author SHA1 Message Date
michael
50ecf39bfd - Allow proceeding with configuration, even if expect.h was not found
- Fix bug #5950 (fopen("expect://") leaves zombies)


git-svn-id: https://svn.php.net/repository/pecl/expect/trunk@242353 c90b9560-bf6c-de11-be94-00142212c4b1
2007-09-09 15:43:36 +00:00
michael
41baa86ee3 New package with bugfix.
git-svn-id: https://svn.php.net/repository/pecl/expect/trunk@215802 c90b9560-bf6c-de11-be94-00142212c4b1
2006-07-05 14:53:16 +00:00
michael
c206870203 Fix segfault on scenario with EXP_TIMEOUT.
git-svn-id: https://svn.php.net/repository/pecl/expect/trunk@215801 c90b9560-bf6c-de11-be94-00142212c4b1
2006-07-05 14:51:56 +00:00
4 changed files with 31 additions and 19 deletions

View File

@@ -13,10 +13,6 @@ if test "$PHP_EXPECT" != "no"; then
fi
done
if test -z "$LIBEXPECT_DIR"; then
AC_MSG_ERROR(expect extension requires libexpect version >= 5.43.0)
fi
PHP_ADD_LIBRARY_WITH_PATH(expect, $LIBEXPECT_DIR/lib, EXPECT_SHARED_LIBADD)
PHP_ADD_INCLUDE($LIBEXPECT_DIR/include)

View File

@@ -255,10 +255,10 @@ PHP_FUNCTION(expect_expectl)
key = exp_expectv (fd, ecases);
int exp_match_len = exp_match_end - exp_match + 1;
int exp_match_len = exp_match_end - exp_match;
if (z_match && exp_match && exp_match_len > 0) {
char *tmp = (char *)emalloc (sizeof(char) * exp_match_len);
strlcpy (tmp, exp_match, exp_match_len);
char *tmp = (char *)emalloc (sizeof(char) * (exp_match_len + 1));
strlcpy (tmp, exp_match, exp_match_len + 1);
zval_dtor (z_match);
array_init(z_match);
add_index_string(z_match, 0, tmp, 1);
@@ -271,9 +271,9 @@ PHP_FUNCTION(expect_expectl)
and add matching substring to matches array */
for (i = 1; i <= 9; i++) {
if (matchedcase.re->startp[i] != NULL) {
int sub_match_len = matchedcase.re->endp[i] - matchedcase.re->startp[i] + 1;
char *sub_match = (char *)emalloc (sizeof(char) * sub_match_len);
strlcpy (sub_match, matchedcase.re->startp[i], sub_match_len);
int sub_match_len = matchedcase.re->endp[i] - matchedcase.re->startp[i];
char *sub_match = (char *)emalloc (sizeof(char) * (sub_match_len + 1));
strlcpy (sub_match, matchedcase.re->startp[i], sub_match_len + 1);
add_next_index_string(z_match, sub_match, 1);
efree (sub_match);
}

View File

@@ -21,26 +21,43 @@
#include "php.h"
#include "php_expect.h"
#include "php_streams.h"
#include <sys/wait.h>
php_stream *php_expect_stream_opener (php_stream_wrapper *wrapper, char *command, char *mode, int options,
php_stream *php_expect_stream_open (php_stream_wrapper *wrapper, char *command, char *mode, int options,
char **opened_command, php_stream_context *context STREAMS_DC TSRMLS_DC)
{
FILE *fp;
if (strncasecmp("expect://", command, sizeof("expect://")-1) == 0) {
command += sizeof("expect://")-1;
}
if ((fp = exp_popen(command)) != NULL) {
return php_stream_fopen_from_pipe (fp, "");
php_stream* stream = php_stream_fopen_from_pipe (fp, mode);
zval *z_pid;
MAKE_STD_ZVAL (z_pid);
ZVAL_LONG (z_pid, exp_pid);
stream->wrapperdata = z_pid;
return stream;
}
return NULL;
}
static int php_expect_stream_close (php_stream_wrapper *wrapper, php_stream *stream TSRMLS_DC)
{
zval* z_pid = stream->wrapperdata;
int s = 0;
waitpid (Z_LVAL_P(z_pid), &s, 0);
zval_ptr_dtor (&z_pid);
stream->wrapperdata = NULL;
return s;
}
/* }}} */
static php_stream_wrapper_ops php_expect_wrapper_ops = {
php_expect_stream_opener,
NULL, /* close */
php_expect_stream_open,
php_expect_stream_close, /* close */
NULL, /* stat */
NULL, /* stat_url */
NULL, /* opendir */

View File

@@ -14,11 +14,10 @@
</maintainers>
<release>
<version>0.2.1</version>
<date>2006-07-04</date>
<version>0.2.2</version>
<date>2006-07-05</date>
<state>beta</state>
<notes>1) Support returning match substrings in array.
2) Fix missing null-termination in returned match string.
<notes>Fix segfault on scenario with EXP_TIMEOUT.
</notes>
</release>