From 3a9322c32a757a1227bba67f5058503ae7b9f458 Mon Sep 17 00:00:00 2001 From: SVN Migration Date: Sun, 6 Apr 2003 17:53:18 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. --- .gdbinit | 257 +++++++++++++++++++++++++++++++++ ext/mysqli/config.m4 | 45 ++++++ ext/mysqli/tests/028.phpt | 19 +++ ext/mysqli/tests/042.phpt | 61 ++++++++ ext/mysqli/tests/047.phpt | 73 ++++++++++ pear/scripts/pear.sh | 28 ++++ pear/scripts/pearcmd.php | 295 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 778 insertions(+) create mode 100644 .gdbinit create mode 100644 ext/mysqli/config.m4 create mode 100644 ext/mysqli/tests/028.phpt create mode 100644 ext/mysqli/tests/042.phpt create mode 100644 ext/mysqli/tests/047.phpt create mode 100644 pear/scripts/pear.sh create mode 100644 pear/scripts/pearcmd.php diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 0000000000..065396bc5c --- /dev/null +++ b/.gdbinit @@ -0,0 +1,257 @@ +define dump_bt + set $t = $arg0 + while $t + printf "[0x%08x] ", $t + if $t->function_state.function->common.function_name + printf "%s() ", $t->function_state.function->common.function_name + else + printf "??? " + end + if $t->op_array != 0 + printf "%s:%d ", $t->op_array->filename, $t->opline->lineno + end + set $t = $t->prev_execute_data + printf "\n" + end +end + +document dump_bt + dumps the current execution stack. usage: dump_bt executor_globals.current_execute_data +end + +define printzv + set $ind = 0 + ____printzv $arg0 0 +end + +document printzv + prints content of zval +end + +define ____printzv + set $zvalue = $arg0 + + if $zvalue->type == 0 + set $typename = "NULL" + end + if $zvalue->type == 1 + set $typename = "long" + end + if $zvalue->type == 2 + set $typename = "double" + end + if $zvalue->type == 3 + set $typename = "string" + end + if $zvalue->type == 4 + set $typename = "array" + end + if $zvalue->type == 5 + set $typename = "object" + end + if $zvalue->type == 6 + set $typename = "bool" + end + if $zvalue->type == 7 + set $typename = "resource" + end + if $zvalue->type == 8 + set $typename = "constant" + end + if $zvalue->type == 9 + set $typename = "const_array" + end + + printf "[0x%08x] ", $zvalue + + if $zvalue == executor_globals.uninitialized_zval_ptr + printf "*uninitialized* " + end + printf "(refcount=%d) %s: ", $zvalue->refcount, $typename + if $zvalue->type == 1 + printf "%ld", $zvalue->value.lval + end + if $zvalue->type == 2 + printf "%lf", $zvalue->value.dval + end + if $zvalue->type == 3 + printf "\"%s\"(%d)", $zvalue->value.str.val, $zvalue->value.str.len + end + if $zvalue->type == 4 + if ! $arg1 + printf "{\n" + set $ind = $ind + 1 + ____print_ht $zvalue->value.ht + set $ind = $ind - 1 + set $i = $ind + while $i > 0 + printf " " + set $i = $i - 1 + end + printf "}" + end + end + if $zvalue->type == 5 + if ! $arg1 + printf "(prop examination disabled due to a gdb bug)" +# set $ht = $zvalue->value.obj.handlers->get_properties($zvalue) +# printf "{\n" +# set $ind = $ind + 1 +# ____print_ht $ht +# set $ind = $ind - 1 +# set $i = $ind +# while $i > 0 +# printf " " +# set $i = $i - 1 +# end +# printf "}" + end + end + if $zvalue->type == 6 + if $zvalue->lval + printf "true" + else + printf "false" + end + end + if $zvalue->type == 7 + printf "#%d", $zvalue->value.lval + end + printf "\n" +end + +define ____print_ht + set $ht = $arg0 + set $p = $ht->pListHead + + while $p != 0 + set $zval = *(struct _zval_struct **)$p->pData + + set $i = $ind + while $i > 0 + printf " " + set $i = $i - 1 + end + + if $p->nKeyLength > 0 + printf "\"%s\" => ", $p->arKey + else + printf "%d => ", $p->h + end + + ____printzv $zval 1 + set $p = $p->pListNext + end +end + +define print_ht + set $ind = 1 + printf "[0x%08x] {\n", $arg0 + ____print_ht $arg0 + printf "}\n" +end + +document print_ht + dumps elements of HashTable made of zval +end + +define printzn + set $ind = 0 + set $znode = $arg0 + if $znode->op_type == 1 + set $optype = "IS_CONST" + end + if $znode->op_type == 2 + set $optype = "IS_TMP_VAR" + end + if $znode->op_type == 4 + set $optype = "IS_VAR" + end + if $znode->op_type == 8 + set $optype = "IS_UNUSED" + end + + printf "[0x%08x] %s", $znode, $optype + + if $znode->op_type == 1 + printf ": " + ____printzv &$znode->u.constant + end + if $znode->op_type == 2 + printf ": " + set $tvar = (union _temp_variable *)((char *)executor_globals.current_execute_data->Ts + $znode->u.var) + ____printzv ((union _temp_variable *)$tvar)->tmp_var + end + if $znode->op_type == 4 + printf ": " + set $tvar = (union _temp_variable *)((char *)executor_globals.current_execute_data->Ts + $znode->u.var) + ____printzv *$tvar->var.ptr_ptr + end + if $znode->op_type == 8 + printf "\n" + end +end + +document printzn + print type and content of znode. usage: printzn &opline->op1 +end + +define printzops + printf "op1 => " + printzn &execute_data->opline.op1 + printf "op2 => " + printzn &execute_data->opline.op2 + printf "result => " + printzn &execute_data->opline.result +end + +document printzops + dump operands of the current opline +end + +define zmemcheck + set $p = alloc_globals.head + set $stat = "?" + if $arg0 != 0 + set $not_found = 1 + else + set $not_found = 0 + end + printf " block file:line (orig) status\n" + printf "-------------------------------------------------------------------------------\n" + while $p + set $aptr = $p + sizeof(struct _zend_mem_header) + sizeof(align_test) + if $arg0 == 0 || (void *)$aptr == (void *)$arg0 + if $p->magic == 0x7312f8dc + set $stat = "OK" + end + if $p->magic == 0x99954317 + set $stat = "FREED" + end + if $p->magic == 0xfb8277dc + set $stat = "CACHED" + end + + printf " 0x%08x %-52s:%5d %-06s\n", $aptr, $p->filename, $p->lineno, $stat + if $p->orig_filename + printf " <= %-52s:%5d\n", $p->orig_filename, $p->orig_lineno + end + if $arg0 != 0 + set $p = 0 + set $not_found = 0 + else + set $p = $p->pNext + end + else + set $p = $p->pNext + end + end + if $not_found + printf "no such block that begins at 0x%08x.\n", $aptr + end +end + +document zmemcheck + show status of a memory block. usage: zmemcheck [ptr]. if ptr = 0 all blocks will be listed. +end + diff --git a/ext/mysqli/config.m4 b/ext/mysqli/config.m4 new file mode 100644 index 0000000000..2c32818e50 --- /dev/null +++ b/ext/mysqli/config.m4 @@ -0,0 +1,45 @@ +dnl +dnl $Id$ +dnl config.m4 for extension mysqli + +PHP_ARG_WITH(mysqli, for MySQLi support, +[ --with-mysqli[=FILE] Include MySQLi support. FILE is the optional + pathname to mysql_config.]) + +if test "$PHP_MYSQLI" != "no"; then + + if test "$PHP_MYSQL" = "yes"; then + AC_MSG_ERROR([--with-mysql (using bundled libs) can not be used together with --with-mysqli.]) + fi + + if test "$PHP_MYSQLI" = "yes"; then + MYSQL_CONFIG=`$php_shtool path mysql_config` + else + MYSQL_CONFIG=$PHP_MYSQLI + fi + + if test -x "$MYSQL_CONFIG" && $MYSQL_CONFIG --libs > /dev/null 2>&1; then + MYSQLI_INCLINE=`$MYSQL_CONFIG --cflags | sed -e "s/'//g"` + MYSQLI_LIBLINE=`$MYSQL_CONFIG --libs | sed -e "s/'//g"` + else + AC_MSG_RESULT([mysql_config not found]) + AC_MSG_ERROR([Please reinstall the mysql distribution]) + fi + + dnl + dnl Check the library + dnl + PHP_CHECK_LIBRARY(mysqlclient, mysql_bind_param, + [ + PHP_EVAL_INCLINE($MYSQLI_INCLINE) + PHP_EVAL_LIBLINE($MYSQLI_LIBLINE, MYSQLI_SHARED_LIBADD) + AC_DEFINE(HAVE_MYSQLILIB,1,[ ]) + ],[ + AC_MSG_ERROR([wrong mysql library version or lib not found. Check config.log for more information.]) + ],[ + $MYSQLI_LIBLINE + ]) + + PHP_SUBST(MYSQLI_SHARED_LIBADD) + PHP_NEW_EXTENSION(mysqli, mysqli.c mysqli_api.c mysqli_nonapi.c mysqli_fe.c mysqli_profiler.c mysqli_profiler_com.c, $ext_shared) +fi diff --git a/ext/mysqli/tests/028.phpt b/ext/mysqli/tests/028.phpt new file mode 100644 index 0000000000..d9e848f2ba --- /dev/null +++ b/ext/mysqli/tests/028.phpt @@ -0,0 +1,19 @@ +--TEST-- +function test: mysqli_character_set_name +--FILE-- + +--EXPECT-- +string(6) "latin1" diff --git a/ext/mysqli/tests/042.phpt b/ext/mysqli/tests/042.phpt new file mode 100644 index 0000000000..58580c631a --- /dev/null +++ b/ext/mysqli/tests/042.phpt @@ -0,0 +1,61 @@ +--TEST-- +mysqli_fetch_object +--FILE-- + +--EXPECTF-- +object(stdClass)#%d (7) { + ["c1"]=> + string(1) "0" + ["c2"]=> + string(5) "35999" + ["c3"]=> + NULL + ["c4"]=> + string(4) "-500" + ["c5"]=> + string(6) "-32768" + ["c6"]=> + string(1) "0" + ["c7"]=> + string(1) "0" +} diff --git a/ext/mysqli/tests/047.phpt b/ext/mysqli/tests/047.phpt new file mode 100644 index 0000000000..0a11e0cf02 --- /dev/null +++ b/ext/mysqli/tests/047.phpt @@ -0,0 +1,73 @@ +--TEST-- +mysqli_prepare_result +--FILE-- + +--EXPECTF-- +array(2) { + [0]=> + object(stdClass)#%d (9) { + ["name"]=> + string(3) "foo" + ["orgname"]=> + string(3) "foo" + ["table"]=> + string(13) "test_affected" + ["orgtable"]=> + string(13) "test_affected" + ["def"]=> + string(0) "" + ["max_length"]=> + int(0) + ["flags"]=> + int(32768) + ["type"]=> + int(3) + ["decimals"]=> + int(0) + } + [1]=> + object(stdClass)#%d (9) { + ["name"]=> + string(3) "bar" + ["orgname"]=> + string(3) "bar" + ["table"]=> + string(13) "test_affected" + ["orgtable"]=> + string(13) "test_affected" + ["def"]=> + string(0) "" + ["max_length"]=> + int(0) + ["flags"]=> + int(0) + ["type"]=> + int(253) + ["decimals"]=> + int(0) + } +} diff --git a/pear/scripts/pear.sh b/pear/scripts/pear.sh new file mode 100644 index 0000000000..dad0838338 --- /dev/null +++ b/pear/scripts/pear.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# first find which PHP binary to use +if test "x$PHP_PEAR_PHP_BIN" != "x"; then + PHP="$PHP_PEAR_PHP_BIN" +else + if test "@php_bin@" = '@'php_bin'@'; then + PHP=php + else + PHP="@php_bin@" + fi +fi + +# then look for the right pear include dir +if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then + INCDIR=$PHP_PEAR_INSTALL_DIR + INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR" +else + if test "@php_dir@" = '@'php_dir'@'; then + INCDIR=`dirname $0` + INCARG="" + else + INCDIR="@php_dir@" + INCARG="-d include_path=@php_dir@" + fi +fi + +exec $PHP -C -q $INCARG -d output_buffering=1 $INCDIR/pearcmd.php $@ diff --git a/pear/scripts/pearcmd.php b/pear/scripts/pearcmd.php new file mode 100644 index 0000000000..b3ce371106 --- /dev/null +++ b/pear/scripts/pearcmd.php @@ -0,0 +1,295 @@ + | +// | Tomas V.V.Cox | +// | | +// +----------------------------------------------------------------------+ +// +// $Id$ + +ob_end_clean(); +/** + * @nodep Gtk + */ +if ('@include_path@' != '@'.'include_path'.'@') { + ini_set('include_path', '@include_path@'); +} +ini_set('allow_url_fopen', true); +set_time_limit(0); +ob_implicit_flush(true); +ini_set('track_errors', true); +ini_set('html_errors', false); +ini_set('magic_quotes_runtime', false); +error_reporting(E_ALL & ~E_NOTICE); +set_error_handler('error_handler'); + +$pear_package_version = "@pear_version@"; + +require_once 'PEAR.php'; +require_once 'PEAR/Config.php'; +require_once 'PEAR/Command.php'; +require_once 'Console/Getopt.php'; + +PEAR_Command::setFrontendType('CLI'); +$all_commands = PEAR_Command::getCommands(); + +$argv = Console_Getopt::readPHPArgv(); +$progname = basename($argv[0]); +$options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:vV"); +if (PEAR::isError($options)) { + usage($options); +} + +$opts = $options[0]; + +$fetype = 'CLI'; +if ($progname == 'gpear' || $progname == 'pear-gtk') { + $fetype = 'Gtk'; +} else { + foreach ($opts as $opt) { + if ($opt[0] == 'G') { + $fetype = 'Gtk'; + } + } +} +PEAR_Command::setFrontendType($fetype); +$ui = &PEAR_Command::getFrontendObject(); +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")); + +$pear_user_config = ''; +$pear_system_config = ''; +$store_user_config = false; +$store_system_config = false; +$verbose = 1; + +foreach ($opts as $opt) { + switch ($opt[0]) { + case 'c': + $pear_user_config = $opt[1]; + break; + case 'C': + $pear_system_config = $opt[1]; + break; + } +} + +$config = &PEAR_Config::singleton($pear_user_config, $pear_system_config); +$verbose = $config->get("verbose"); +$cmdopts = array(); + +foreach ($opts as $opt) { + $param = !empty($opt[1]) ? $opt[1] : true; + switch ($opt[0]) { + case 'd': + list($key, $value) = explode('=', $param); + $config->set($key, $value, 'user'); + break; + case 'D': + list($key, $value) = explode('=', $param); + $config->set($key, $value, 'system'); + break; + case 's': + $store_user_config = true; + break; + case 'S': + $store_system_config = true; + break; + case 'u': + $config->remove($param, 'user'); + break; + case 'v': + $config->set('verbose', $config->get('verbose') + 1); + break; + case 'q': + $config->set('verbose', $config->get('verbose') - 1); + break; + case 'V': + usage(null, 'version'); + default: + // all non pear params goes to the command + $cmdopts[$opt[0]] = $param; + break; + } +} + +if ($store_system_config) { + $config->store('system'); +} + +if ($store_user_config) { + $config->store('user'); +} + +$command = (isset($options[1][0])) ? $options[1][0] : null; + +if (empty($command) && ($store_user_config || $store_system_config)) { + exit; +} + +if ($fetype == 'Gtk') { + Gtk::main(); +} else do { + if ($command == 'help') { + usage(null, @$options[1][1]); + } + + PEAR::pushErrorHandling(PEAR_ERROR_RETURN); + $cmd = PEAR_Command::factory($command, $config); + PEAR::popErrorHandling(); + if (PEAR::isError($cmd)) { + usage(null, @$options[1][1]); + } + + $short_args = $long_args = null; + PEAR_Command::getGetoptArgs($command, $short_args, $long_args); + if (PEAR::isError($tmp = Console_Getopt::getopt($options[1], $short_args, $long_args))) { + break; + } + list($tmpopt, $params) = $tmp; + $opts = array(); + foreach ($tmpopt as $foo => $tmp2) { + list($opt, $value) = $tmp2; + if ($value === null) { + $value = true; // options without args + } + if (strlen($opt) == 1) { + $cmdoptions = $cmd->getOptions($command); + foreach ($cmdoptions as $o => $d) { + if (@$d['shortopt'] == $opt) { + $opts[$o] = $value; + } + } + } else { + if (substr($opt, 0, 2) == '--') { + $opts[substr($opt, 2)] = $value; + } + } + } + $ok = $cmd->run($command, $opts, $params); + if ($ok === false) { + PEAR::raiseError("unknown command `$command'"); + } +} while (false); + +// {{{ usage() + +function usage($error = null, $helpsubject = null) +{ + global $progname, $all_commands; + $stderr = fopen('php://stderr', 'w'); + if (PEAR::isError($error)) { + fputs($stderr, $error->getMessage() . "\n"); + } elseif ($error !== null) { + fputs($stderr, "$error\n"); + } + if ($helpsubject != null) { + $put = cmdHelp($helpsubject); + } else { + $put = + "Usage: $progname [options] command [command-options] \n". + "Type \"$progname help options\" to list all options.\n". + "Type \"$progname help \" to get the help for the specified command.\n". + "Commands:\n"; + $maxlen = max(array_map("strlen", $all_commands)); + $formatstr = "%-{$maxlen}s %s\n"; + ksort($all_commands); + foreach ($all_commands as $cmd => $class) { + $put .= sprintf($formatstr, $cmd, PEAR_Command::getDescription($cmd)); + } + } + fputs($stderr, "$put\n"); + fclose($stderr); + exit; +} + +function cmdHelp($command) +{ + global $progname, $all_commands, $config; + if ($command == "options") { + return + "Options:\n". + " -v increase verbosity level (default 1)\n". + " -q be quiet, decrease verbosity level\n". + " -c file find user configuration in `file'\n". + " -C file find system configuration in `file'\n". + " -d foo=bar set user config variable `foo' to `bar'\n". + " -D foo=bar set system config variable `foo' to `bar'\n". + " -G start in graphical (Gtk) mode\n". + " -s store user configuration\n". + " -S store system configuration\n". + " -u foo unset `foo' in the user configuration\n". + " -h, -? display help/usage (this message)\n". + " -V version information\n"; + } elseif ($command == "shortcuts") { + $sc = PEAR_Command::getShortcuts(); + $ret = "Shortcuts:\n"; + foreach ($sc as $s => $c) { + $ret .= sprintf(" %-8s %s\n", $s, $c); + } + return $ret; + + } elseif ($command == "version") { + return "PEAR Version: ".$GLOBALS['pear_package_version']."\nPHP Version: ".phpversion()."\nZend Engine Version: ".zend_version(); + + } elseif ($help = PEAR_Command::getHelp($command)) { + if (is_string($help)) { + return "$progname $command [options] $help\n"; + } + if ($help[1] === null) { + return "$progname $command $help[0]"; + } else { + return "$progname $command [options] $help[0]\n$help[1]"; + } + } + return "No such command"; +} + +// }}} + +function error_handler($errno, $errmsg, $file, $line, $vars) { + if (error_reporting() == 0) { + return; // @silenced error + } + $errortype = array ( + 1 => "Error", + 2 => "Warning", + 4 => "Parsing Error", + 8 => "Notice", + 16 => "Core Error", + 32 => "Core Warning", + 64 => "Compile Error", + 128 => "Compile Warning", + 256 => "User Error", + 512 => "User Warning", + 1024=> "User Notice" + ); + $prefix = $errortype[$errno]; + $file = basename($file); + print "\n$prefix: $errmsg in $file on line $line\n"; +} + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: nil + * mode: php + * End: + */ +// vim600:syn=php + +?> -- 2.40.0