[PHP-CVS] cvs: php4 /main output.c

2002-10-01 Thread Yasuo Ohgaki

yohgaki Tue Oct  1 06:01:56 2002 EDT

  Modified files:  
/php4/main  output.c 
  Log:
  Fixed bug #17825. Double zval_ptr_dtor().
  
  
Index: php4/main/output.c
diff -u php4/main/output.c:1.124 php4/main/output.c:1.125
--- php4/main/output.c:1.124Mon Sep 30 22:43:33 2002
+++ php4/main/output.c  Tue Oct  1 06:01:56 2002
 -18,7 +18,7 
+--+
 */
 
-/* $Id: output.c,v 1.124 2002/10/01 02:43:33 yohgaki Exp $ */
+/* $Id: output.c,v 1.125 2002/10/01 10:01:56 yohgaki Exp $ */
 
 #include php.h
 #include ext/standard/head.h
 -231,7 +231,6 
FREE_ZVAL(orig_buffer);
}
zval_ptr_dtor(z_status);
-   zval_ptr_dtor(OG(active_ob_buffer).output_handler);
}
 
if (!final_buffer) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 / NEWS

2002-10-01 Thread Yasuo Ohgaki

yohgaki Tue Oct  1 06:04:05 2002 EDT

  Modified files:  
/php4   NEWS 
  Log:
  Bug fix
  
  
Index: php4/NEWS
diff -u php4/NEWS:1.1163 php4/NEWS:1.1164
--- php4/NEWS:1.1163Mon Sep 30 22:54:30 2002
+++ php4/NEWS   Tue Oct  1 06:04:04 2002
 -4,6 +4,7 
 - ATTENTION!! make install will *always* install the CLI SAPI binary in 
   {PREFIX}/bin/php. If you enable the CGI binary to be built, it will be
   installed as {PREFIX}/bin/php-cgi.
+- Fixed bug #17825 (ob_start() chunk size option didn't work well). (Yasuo)
 - Fixed output buffering implicit flush. (Yasuo) 
 - Added getopt() for parsing command line options and arguments. (Jon)
 - Added pg_fetch_assoc(), pg_fetch_all(), pg_metadata(), pg_convert(), 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/mbstring php_unicode.c

2002-10-01 Thread Zeev Suraski

zeevTue Oct  1 06:16:40 2002 EDT

  Modified files:  
/php4/ext/mbstring  php_unicode.c 
  Log:
  Fix warnings
  
  
Index: php4/ext/mbstring/php_unicode.c
diff -u php4/ext/mbstring/php_unicode.c:1.1 php4/ext/mbstring/php_unicode.c:1.2
--- php4/ext/mbstring/php_unicode.c:1.1 Wed Sep 25 20:53:47 2002
+++ php4/ext/mbstring/php_unicode.c Tue Oct  1 06:16:40 2002
 -236,7 +236,7 
char *unicode, *newstr;
size_t unicode_len;
unsigned long *unicode_ptr;
-   int i;
+   size_t i;
 
unicode = php_mb_convert_encoding(srcstr, srclen, NATIVE_UNICODE_ENCODING, 
src_encoding, unicode_len TSRMLS_CC);
if (unicode == NULL)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4(PHP_4_2_0) /main output.c

2002-10-01 Thread Yasuo Ohgaki

yohgaki Tue Oct  1 06:19:04 2002 EDT

  Modified files:  (Branch: PHP_4_2_0)
/php4/main  output.c 
  Log:
  MFH
  
  
Index: php4/main/output.c
diff -u php4/main/output.c:1.88.2.2 php4/main/output.c:1.88.2.3
--- php4/main/output.c:1.88.2.2 Fri Aug 23 04:36:28 2002
+++ php4/main/output.c  Tue Oct  1 06:19:04 2002
 -17,7 +17,7 
+--+
 */
 
-/* $Id: output.c,v 1.88.2.2 2002/08/23 08:36:28 zeev Exp $ */
+/* $Id: output.c,v 1.88.2.3 2002/10/01 10:19:04 yohgaki Exp $ */
 
 #include php.h
 #include ext/standard/head.h
 -189,7 +189,6 
orig_buffer-refcount-=2;
}
zval_ptr_dtor(z_status);
-   zval_ptr_dtor(OG(active_ob_buffer).output_handler);
}
 
if (!final_buffer) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/session php_session.h session.c

2002-10-01 Thread Sascha Schumann

sas Tue Oct  1 07:59:46 2002 EDT

  Modified files:  
/php4/ext/session   php_session.h session.c 
  Log:
  The session extension ensures now that get_session_var can rely
  on the state of $_SESSION/$HTTP_SESSION_VARS. It does not look up
  symbols in the global symbol table anymore.
  
  This was achieved by actually planting references between every 
  $_SESSION[x] and $x, not only when restoring a session, but also
  when registering a session variable (in a register_globals=1 context).
  
  Upon registering a new variable, this memory leak continues to show
  up, regardless of register_globals.
  
  ext/session/session.c(272) :  Freeing 0x0818F01C (12 bytes), script=test
  
  Obviously, the newly allocated empty zval is not properly freed.  If anyone
  has any idea on how to fix that, please step forward.
  
  
Index: php4/ext/session/php_session.h
diff -u php4/ext/session/php_session.h:1.81 php4/ext/session/php_session.h:1.82
--- php4/ext/session/php_session.h:1.81 Thu Aug 15 17:44:44 2002
+++ php4/ext/session/php_session.h  Tue Oct  1 07:59:45 2002
 -174,6 +174,7 
 
 PHPAPI void session_adapt_url(const char *, size_t, char **, size_t * TSRMLS_DC);
 
+void php_add_session_var(char *name, size_t namelen TSRMLS_DC);
 void php_set_session_var(char *name, size_t namelen, zval *state_val, 
php_unserialize_data_t *var_hash TSRMLS_DC);
 int php_get_session_var(char *name, size_t namelen, zval ***state_var TSRMLS_DC);
 
 -186,22 +187,19 
 PHPAPI void php_session_set_id(char *id TSRMLS_DC);
 PHPAPI void php_session_start(TSRMLS_D);
 
-#define PS_ADD_VARL(name,namelen) 
 \
+#define PS_ADD_VARL(name,namelen) do {
+ \
zend_hash_add_empty_element(PS(vars), name, namelen + 1); 
 \
-   if (PS(http_session_vars)) {   
 \
-   zval *empty_var;   
 \
-  
 \
-   ALLOC_INIT_ZVAL(empty_var);
 \
-   zend_hash_add(Z_ARRVAL_P(PS(http_session_vars)), name, namelen+1, 
empty_var, sizeof(zval *), NULL);\
-   }
+   php_add_session_var(name, namelen TSRMLS_CC);  
+ \
+} while (0)
 
 #define PS_ADD_VAR(name) PS_ADD_VARL(name, strlen(name))
 
-#define PS_DEL_VARL(name,namelen) 
 \
+#define PS_DEL_VARL(name,namelen) do {
+ \
zend_hash_del(PS(vars), name, namelen+1); 
 \
if (PS(http_session_vars)) {   
 \
zend_hash_del(Z_ARRVAL_P(PS(http_session_vars)), name, namelen+1); 
 \
-   }
+   }  
+ \
+} while (0)
 
 
 #define PS_ENCODE_VARS
 \
Index: php4/ext/session/session.c
diff -u php4/ext/session/session.c:1.322 php4/ext/session/session.c:1.323
--- php4/ext/session/session.c:1.322Sun Sep 29 15:28:12 2002
+++ php4/ext/session/session.c  Tue Oct  1 07:59:45 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: session.c,v 1.322 2002/09/29 19:28:12 sniper Exp $ */
+/* $Id: session.c,v 1.323 2002/10/01 11:59:45 sas Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
 -238,6 +238,43 
 
 #define MAX_STR 512
 
+void php_add_session_var(char *name, size_t namelen TSRMLS_DC)
+{
+   zval **sym_track = NULL;
+   
+   zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name, namelen + 1, 
+   (void *) sym_track);
+
+   /*
+* Set up a proper reference between $_SESSION[x] and $x.
+*/
+
+   if (PG(register_globals)) {
+   zval **sym_global = NULL;
+   
+   zend_hash_find(EG(symbol_table), name, namelen + 1, 
+   (void *) sym_global);
+   
+   if (sym_global == NULL  sym_track == NULL) {
+   zval *empty_var;
+
+   ALLOC_INIT_ZVAL(empty_var);
+   zend_set_hash_symbol(empty_var, name, namelen, 1, 

[PHP-CVS] cvs: php4 /ext/session mod_files.c

2002-10-01 Thread Sascha Schumann

sas Tue Oct  1 15:19:11 2002 EDT

  Modified files:  
/php4/ext/session   mod_files.c 
  Log:
  Disable pread/pwrite for now until we can clarify why it should be
  impossible to write a check for a broken OS feature.
  
  
Index: php4/ext/session/mod_files.c
diff -u php4/ext/session/mod_files.c:1.81 php4/ext/session/mod_files.c:1.82
--- php4/ext/session/mod_files.c:1.81   Mon Sep 30 06:18:57 2002
+++ php4/ext/session/mod_files.cTue Oct  1 15:19:10 2002
 -16,7 +16,7 
+--+
  */
 
-/* $Id: mod_files.c,v 1.81 2002/09/30 10:18:57 wez Exp $ */
+/* $Id: mod_files.c,v 1.82 2002/10/01 19:19:10 sas Exp $ */
 
 #include php.h
 
 -271,7 +271,7 
data-st_size = *vallen = sbuf.st_size;
*val = emalloc(sbuf.st_size);
 
-#ifdef HAVE_PREAD
+#if defined(HAVE_WORKING_PREAD_TEST)  defined(HAVE_PREAD)
n = pread(data-fd, *val, sbuf.st_size, 0);
 #else
lseek(data-fd, 0, SEEK_SET);
 -307,7 +307,7 
if (vallen  (int)data-st_size)
ftruncate(data-fd, 0);
 
-#ifdef HAVE_PWRITE
+#if defined(HAVE_WORKING_PWRITE_TEST)  defined(HAVE_PWRITE)
n = pwrite(data-fd, val, vallen, 0);
 #else
lseek(data-fd, 0, SEEK_SET);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard filestat.c

2002-10-01 Thread Stefan Esser

sesser  Tue Oct  1 17:53:25 2002 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  repairing the chaos
  
  utime(filename, NULL) is not only valid but a MUST on linux if you are
  not the owner...
  
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.110 php4/ext/standard/filestat.c:1.111
--- php4/ext/standard/filestat.c:1.110  Mon Sep 23 10:59:24 2002
+++ php4/ext/standard/filestat.cTue Oct  1 17:53:25 2002
 -16,7 +16,7 
+--+
  */
 
-/* $Id: filestat.c,v 1.110 2002/09/23 14:59:24 sas Exp $ */
+/* $Id: filestat.c,v 1.111 2002/10/01 21:53:25 sesser Exp $ */
 
 #include php.h
 #include safe_mode.h
 -484,16 +484,20 
struct utimbuf *newtime = NULL;
int ac = ZEND_NUM_ARGS();
 
-   newtime = newtimebuf;
 
if (ac == 1  zend_get_parameters_ex(1, filename) != FAILURE) {
+#ifndef HAVE_UTIME_NULL
+   newtime = newtimebuf;
newtime-modtime = newtime-actime = time(NULL);
+#endif
} else if (ac == 2  zend_get_parameters_ex(2, filename, filetime) != 
FAILURE) {
convert_to_long_ex(filetime);
+   newtime = newtimebuf;
newtime-modtime = newtime-actime = Z_LVAL_PP(filetime);
} else if (ac == 3  zend_get_parameters_ex(3, filename, filetime, 
fileatime) != FAILURE) {
convert_to_long_ex(fileatime);
convert_to_long_ex(filetime);
+   newtime = newtimebuf;
newtime-actime = Z_LVAL_PP(fileatime);
newtime-modtime = Z_LVAL_PP(filetime);
} else {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 / run-tests.php

2002-10-01 Thread Marcus Börger

I was working on this one too and thought about listing
all skipped directories. I also thought about a special
skip file that allows to skip all tests in a directory by one
file. This came to my mind when seeing many extensions
having an include file that is used for the skip section.

Will we remove all the skip sections that are no longer
needed now? A problem could be when manually adding
extensions to the tests which are not compiled into the
binary.

marcus

At 03:52 02.10.2002, Jani Taskinen wrote:
sniper  Tue Oct  1 21:52:25 2002 EDT

   Modified files:
 /php4   run-tests.php
   Log:
   - Run ext/* tests only for those modules that are actually compiled
 into the php binary. (faster)
   - Skip search of .phpt files if they are passed as parameters


Index: php4/run-tests.php
diff -u php4/run-tests.php:1.55 php4/run-tests.php:1.56
--- php4/run-tests.php:1.55 Wed Sep 11 15:42:59 2002
+++ php4/run-tests.php  Tue Oct  1 21:52:25 2002
 -44,7 +44,7 
  error_reporting(E_ALL);

  if (ini_get('safe_mode')) {
-echo SAFE_MODE_WARNING
+echo  SAFE_MODE_WARNING

  +---+
  |   ! WARNING ! |
 -62,25 +62,25 
  // Require the explicit specification.
  // Otherwise we could end up testing the wrong file!

-if(isset($_ENV['TEST_PHP_EXECUTABLE'])) {
+if (isset($_ENV['TEST_PHP_EXECUTABLE'])) {
 $php = $_ENV['TEST_PHP_EXECUTABLE'];
  } else {
 error(environment variable TEST_PHP_EXECUTABLE must be set to 
 specify PHP executable!);
  }

-if(isset($_ENV['TEST_PHP_LOG_FORMAT'])) {
+if (isset($_ENV['TEST_PHP_LOG_FORMAT'])) {
 $log_format = strtoupper($_ENV['TEST_PHP_LOG_FORMAT']);
  } else {
 $log_format = 'LEOD';
  }

-if(!@is_executable($php)) {
+if (!@is_executable($php)) {
 error(invalid PHP executable specified by TEST_PHP_EXECUTABLE  = 
  . $php);
  }

  // Check whether a detailed log is wanted.

-if(isset($_ENV['TEST_PHP_DETAILED'])) {
+if (isset($_ENV['TEST_PHP_DETAILED'])) {
 define('DETAILED', $_ENV['TEST_PHP_DETAILED']);
  } else {
 define('DETAILED', 0);
 -103,7 +103,7 
  // Make sure we are using the proper php.ini.

  $php_ini = realpath(php.ini-dist);
-if(realpath(get_cfg_var('cfg_file_path')) != $php_ini) {
+if (realpath(get_cfg_var('cfg_file_path')) != $php_ini) {
 error(php.ini-dist was not used!);
  }
  $php .=  -c $php_ini;
 -115,65 +115,67 
  $test_results = array();

  // If parameters given assume they represent selected tests to run.
-if (isset($argc)  $argc1) {
+if (isset($argc)  $argc  1) {
 for ($i=1; $i$argc; $i++) {
 $testfile = realpath($argv[$i]);
 $test_to_run[$testfile] = 1;
 }
+
+   // Run selected tests.
+   if (count($test_to_run)) {
+   echo Running selected tests.\n;
+   foreach($test_to_run AS $name=$runnable) {
+   echo test: $name runnable: $runnable\n;
+   if ($runnable) {
+   $test_results[$name] = run_test($php,$name);
+   }
+   }
+   exit(0);
+   }
  }

  // Compile a list of all test files (*.phpt).
-$test_files = array();
-$module_of_test = array();
-find_files(getcwd());
-
-function find_files($dir) {
-   global $test_files, $module_of_test;
-
-   /* FIXME: this messes up if you unpack PHP in /ext/pear :) */
-   if (ereg('/ext/([^/]+)/',$dir/,$r)) {
-   $module = $r[1];
-   } else if (ereg('/pear/',$dir/)) {
-   $module = 'pear';
-   } else {
-   $module = '';
-   }
+$test_files = array();
+$exts_to_test = get_loaded_extensions();
+sort($exts_to_test);
+$extra_dirs = array('pear', 'tests');
+$cwd=getcwd();
+
+// First get list of test files in ext/
+foreach ($exts_to_test as $dir) {
+   find_files({$cwd}/ext/{$dir});
+}
+
+// Then the rest
+foreach ($extra_dirs as $dir) {
+   find_files({$cwd}/{$dir});
+}
+
+function find_files($dir)
+{
+   global $test_files;

 $o = opendir($dir) or error(cannot open directory: $dir);
-   while (($name = readdir($o))!==false) {
+   while (($name = readdir($o)) !== false) {
 if (is_dir({$dir}/{$name})  !in_array($name, 
 array('.', '..', 'CVS'))) {
 find_files({$dir}/{$name});
 }

 // Cleanup any left-over tmp files from last run.
-   if (substr($name, -4)=='.tmp') {
+   if (substr($name, -4) == '.tmp') {
 unlink($dir/$name);
 continue;
 }

 // Otherwise we're only interested in *.phpt files.
-   if (substr($name, -5)=='.phpt') {
+   if (substr($name, -5) == '.phpt') {
 $testfile = realpath({$dir}/{$name});
 $test_files[] = 

[PHP-CVS] cvs: php4 / NEWS /ext/pgsql pgsql.c php_pgsql.h

2002-10-01 Thread Yasuo Ohgaki

yohgaki Tue Oct  1 22:41:21 2002 EDT

  Modified files:  
/php4   NEWS 
/php4/ext/pgsql pgsql.c php_pgsql.h 
  Log:
  Added pg_ping()
  
  
Index: php4/NEWS
diff -u php4/NEWS:1.1165 php4/NEWS:1.1166
--- php4/NEWS:1.1165Tue Oct  1 22:11:26 2002
+++ php4/NEWS   Tue Oct  1 22:41:19 2002
 -7,7 +7,7 
 - Fixed bug #17825 (ob_start() chunk size option didn't work well). (Yasuo)
 - Fixed output buffering implicit flush. (Yasuo) 
 - Added getopt() for parsing command line options and arguments. (Jon)
-- Added pg_fetch_assoc(), pg_fetch_all(), pg_meta_data(), pg_convert(), 
+- Added pg_fetch_assoc(), pg_fetch_all(), pg_ping(), pg_meta_data(), pg_convert(), 
   pg_insert(), pg_select(), pg_update() and pg_delete(). (Yasuo)
 - Fixed bug #17281 (Sanity checks for encoding sessions). (Ilia)
 - Fixed bug #16995 and #19392 (Prevent crash if $HTTP_SESSION_VARS != ARRAY).
Index: php4/ext/pgsql/pgsql.c
diff -u php4/ext/pgsql/pgsql.c:1.225 php4/ext/pgsql/pgsql.c:1.226
--- php4/ext/pgsql/pgsql.c:1.225Tue Oct  1 22:11:26 2002
+++ php4/ext/pgsql/pgsql.c  Tue Oct  1 22:41:21 2002
 -19,7 +19,7 
+--+
  */
  
-/* $Id: pgsql.c,v 1.225 2002/10/02 02:11:26 yohgaki Exp $ */
+/* $Id: pgsql.c,v 1.226 2002/10/02 02:41:21 yohgaki Exp $ */
 
 #include stdlib.h
 
 -88,6 +88,7 
PHP_FE(pg_port, NULL)
PHP_FE(pg_tty,  NULL)
PHP_FE(pg_options,  NULL)
+   PHP_FE(pg_ping, NULL)
/* query functions */
PHP_FE(pg_query,NULL)
PHP_FE(pg_send_query,   NULL)
 -146,7 +147,7 
PHP_FE(pg_set_client_encoding,  NULL)
 #endif
/* misc function */
-   PHP_FE(pg_meta_data, NULL)
+   PHP_FE(pg_meta_data,NULL)
PHP_FE(pg_convert,  NULL)
PHP_FE(pg_insert,   NULL)
PHP_FE(pg_update,   NULL)
 -837,6 +838,37 
 PHP_FUNCTION(pg_host)
 {
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_HOST);
+}
+/* }}} */
+
+/* {{{ proto bool pg_ping([resource connection])
+   Ping database. If connection is bad, try to reconnect. */
+PHP_FUNCTION(pg_ping)
+{
+   zval *pgsql_link = NULL;
+   int id = -1;
+   PGconn *pgsql;
+
+   if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() 
+TSRMLS_CC, r,
+pgsql_link) == 
+FAILURE) {
+   RETURN_FALSE;
+   }
+
+   ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL link, 
+le_link, le_plink);
+
+   /* ping connection */
+   PQexec(pgsql, SELECT 1;);
+
+   /* check status. */
+   if (PQstatus(pgsql) == CONNECTION_OK)
+   RETURN_TRUE;
+
+   /* reset connection if it's broken */
+   PQreset(pgsql);
+   if (PQstatus(pgsql) == CONNECTION_OK) {
+   RETURN_TRUE;
+   }
+   RETURN_FALSE;
 }
 /* }}} */
 
Index: php4/ext/pgsql/php_pgsql.h
diff -u php4/ext/pgsql/php_pgsql.h:1.49 php4/ext/pgsql/php_pgsql.h:1.50
--- php4/ext/pgsql/php_pgsql.h:1.49 Tue Oct  1 22:11:27 2002
+++ php4/ext/pgsql/php_pgsql.h  Tue Oct  1 22:41:21 2002
 -17,7 +17,7 
+--+
  */
  
-/* $Id: php_pgsql.h,v 1.49 2002/10/02 02:11:27 yohgaki Exp $ */
+/* $Id: php_pgsql.h,v 1.50 2002/10/02 02:41:21 yohgaki Exp $ */
 
 #ifndef PHP_PGSQL_H
 #define PHP_PGSQL_H
 -71,6 +71,7 
 PHP_FUNCTION(pg_port);
 PHP_FUNCTION(pg_tty);
 PHP_FUNCTION(pg_options);
+PHP_FUNCTION(pg_ping);
 /* query functions */
 PHP_FUNCTION(pg_query);
 PHP_FUNCTION(pg_send_query);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 / NEWS

2002-10-01 Thread Yasuo Ohgaki

yohgaki Tue Oct  1 23:17:30 2002 EDT

  Modified files:  
/php4   NEWS 
  Log:
  pg_data_seek()
  
  
Index: php4/NEWS
diff -u php4/NEWS:1.1166 php4/NEWS:1.1167
--- php4/NEWS:1.1166Tue Oct  1 22:41:19 2002
+++ php4/NEWS   Tue Oct  1 23:17:30 2002
 -8,7 +8,7 
 - Fixed output buffering implicit flush. (Yasuo) 
 - Added getopt() for parsing command line options and arguments. (Jon)
 - Added pg_fetch_assoc(), pg_fetch_all(), pg_ping(), pg_meta_data(), pg_convert(), 
-  pg_insert(), pg_select(), pg_update() and pg_delete(). (Yasuo)
+  pg_insert(), pg_select(), pg_update(), pg_delete() and pg_data_seek(). (Yasuo)
 - Fixed bug #17281 (Sanity checks for encoding sessions). (Ilia)
 - Fixed bug #16995 and #19392 (Prevent crash if $HTTP_SESSION_VARS != ARRAY).
   (Ilia)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/pgsql mysql_users.php

2002-10-01 Thread Yasuo Ohgaki

yohgaki Tue Oct  1 23:32:28 2002 EDT

  Added files: 
/php4/ext/pgsql mysql_users.php 
  Log:
  Add some example functions for mysql users.
  
  

Index: php4/ext/pgsql/mysql_users.php
+++ php4/ext/pgsql/mysql_users.php
?php
/*
 * File: mysql_users.php
 * Author: Yasuo Ohgaki [EMAIL PROTECTED]
 * 
 * This file contains example user defined functions that does
 * similar to MySQL functions. They can be implemented as module
 * functions, but there won't be many users need them.
 *
 * Requires: PostgreSQL 7.2.x
 */

/*
 * mysql_list_dbs()
 * 
 * This function should be needed, since PostgreSQL connection 
 * binds database.
 */
function pg_list_dbs($db) 
{
assert(is_resource($db));
$query = '
SELECT
 d.datname as Name,
 u.usename as Owner,
 pg_encoding_to_char(d.encoding) as Encoding
FROM 
 pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid
ORDER BY 1;
';
return pg_query($db, $query);
}


/*
 * mysql_list_tables()
 */
function pg_list_tables($db) 
{
assert(is_resource($db));
$query = 
SELECT
 c.relname as \Name\,
 CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 
'S' THEN 'sequence' WHEN 's' THEN 'special' END as \Type\,
  u.usename as \Owner\
FROM
 pg_class c LEFT JOIN pg_user u ON c.relowner = u.usesysid
WHERE
 c.relkind IN ('r','v','S','')
 AND c.relname !~ '^pg_'
ORDER BY 1;
;
return pg_query($db, $query);
}

/*
 * mysql_list_fields()
 *
 * See also pg_meta_data(). It returns field defintion as array.
 */
function pg_list_fields($db, $table) 
{
assert(is_resource($db));
$query = 
SELECT
 a.attname,
 format_type(a.atttypid, a.atttypmod),
 a.attnotnull,
 a.atthasdef,
 a.attnum
FROM
 pg_class c,
 pg_attribute a
WHERE
 c.relname = '.$table.'
 AND a.attnum  0 AND a.attrelid = c.oid
ORDER BY a.attnum;
;
return pg_query($db, $query);
}

?



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 / NEWS /ext/pgsql pgsql.c

2002-10-01 Thread Yasuo Ohgaki

yohgaki Wed Oct  2 00:03:22 2002 EDT

  Modified files:  
/php4   NEWS 
/php4/ext/pgsql pgsql.c 
  Log:
  Added pg_unescape_bytea(). Fixed pg_data_seek().
  php_pgsql_unescape_bytea(PQunescapeBytea) is shamelessly stolen from PostgreSQL 7.3 
:)
  
  
Index: php4/NEWS
diff -u php4/NEWS:1.1167 php4/NEWS:1.1168
--- php4/NEWS:1.1167Tue Oct  1 23:17:30 2002
+++ php4/NEWS   Wed Oct  2 00:03:20 2002
 -8,7 +8,8 
 - Fixed output buffering implicit flush. (Yasuo) 
 - Added getopt() for parsing command line options and arguments. (Jon)
 - Added pg_fetch_assoc(), pg_fetch_all(), pg_ping(), pg_meta_data(), pg_convert(), 
-  pg_insert(), pg_select(), pg_update(), pg_delete() and pg_data_seek(). (Yasuo)
+  pg_insert(), pg_select(), pg_update(), pg_delete(), pg_data_seek() and
+  pg_unescape_bytea(). (Yasuo)
 - Fixed bug #17281 (Sanity checks for encoding sessions). (Ilia)
 - Fixed bug #16995 and #19392 (Prevent crash if $HTTP_SESSION_VARS != ARRAY).
   (Ilia)
Index: php4/ext/pgsql/pgsql.c
diff -u php4/ext/pgsql/pgsql.c:1.227 php4/ext/pgsql/pgsql.c:1.228
--- php4/ext/pgsql/pgsql.c:1.227Tue Oct  1 23:16:34 2002
+++ php4/ext/pgsql/pgsql.c  Wed Oct  2 00:03:21 2002
 -19,7 +19,7 
+--+
  */
  
-/* $Id: pgsql.c,v 1.227 2002/10/02 03:16:34 yohgaki Exp $ */
+/* $Id: pgsql.c,v 1.228 2002/10/02 04:03:21 yohgaki Exp $ */
 
 #include stdlib.h
 
 -1423,7 +1423,6 
 {
zval *result;
int row;
-   PGresult *pgsql_result;
pgsql_result_handle *pg_result;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|l,
 -1438,7 +1437,7 
 /* if (ZEND_NUM_ARGS() == 1) */
 /* RETURN_LONG(pg_result-row); */
 
-   if (row  0 || row = PQntuples(pg_result))
+   if (row  0 || row = PQntuples(pg_result-result))
RETURN_FALSE;

/* seek to offset */
 -2613,6 +2612,133 
 
to = (char *)PQescapeBytea((unsigned char*)from, from_len, to_len);
RETVAL_STRINGL(to, to_len-1, 1); /* to_len includes addtional '\0' */
+   free(to);
+}
+/* }}} */
+
+/* PQunescapeBytea() from PostgreSQL 7.3 to provide bytea unescape feature to 7.2 
+users.
+   Renamed to php_pgsql_unescape_bytea() */
+/*
+ * PQunescapeBytea - converts the null terminated string representation
+ * of a bytea, strtext, into binary, filling a buffer. It returns a
+ * pointer to the buffer which is NULL on error, and the size of the
+ * buffer in retbuflen. The pointer may subsequently be used as an
+ * argument to the function free(3). It is the reverse of PQescapeBytea.
+ *
+ * The following transformations are reversed:
+ * '\0' == ASCII  0 == \000
+ * '\'' == ASCII 39 == \'
+ * '\\' == ASCII 92 == \\
+ *
+ * States:
+ * 0   normal  0-1-2-3-4
+ * 1   \  1-5
+ * 2   \0 1-6
+ * 3   \00
+ * 4   \000
+ * 5   \'
+ * 6   \\
+ */
+static unsigned char * php_pgsql_unescape_bytea(unsigned char *strtext, size_t 
+*retbuflen)
+{
+   size_t  buflen;
+   unsigned char *buffer,
+  *sp,
+  *bp;
+   unsigned int state = 0;
+
+   if (strtext == NULL)
+   return NULL;
+   buflen = strlen(strtext);   /* will shrink, also we discover if
+* strtext */
+   buffer = (unsigned char *) malloc(buflen);  /* isn't NULL terminated */
+   if (buffer == NULL)
+   return NULL;
+   for (bp = buffer, sp = strtext; *sp != '\0'; bp++, sp++)
+   {
+   switch (state)
+   {
+   case 0:
+   if (*sp == '\\')
+   state = 1;
+   *bp = *sp;
+   break;
+   case 1:
+   if (*sp == '\'')/* state=5 */
+   {   /* replace \' with 39 
+*/
+   bp--;
+   *bp = '\'';
+   buflen--;
+   state = 0;
+   }
+   else if (*sp == '\\')   /* state=6 */
+   {   /* replace \\ with 92 
+*/
+   bp--;
+   *bp = '\\';
+   buflen--;
+   state = 0;
+   }
+   

[PHP-CVS] cvs: php4 /tests/func 006.phpt

2002-10-01 Thread Yasuo Ohgaki

yohgaki Wed Oct  2 01:29:06 2002 EDT

  Modified files:  
/php4/tests/func006.phpt 
  Log:
  Improve test to show output bufferring bypass bug clearly.
  
  
  
Index: php4/tests/func/006.phpt
diff -u php4/tests/func/006.phpt:1.2 php4/tests/func/006.phpt:1.3
--- php4/tests/func/006.phpt:1.2Thu Aug  1 08:02:22 2002
+++ php4/tests/func/006.phptWed Oct  2 01:29:06 2002
 -14,8 +14,10 
   ob_end_clean();
 $a = ob_get_contents();
 ob_end_clean();
-echo $b;
-echo $a;
+
+var_dump( $b ); // 2B
+var_dump( $a ); // 1A
 ?
 --EXPECT--
-2B1A
+string(2) 2B
+string(2) 1A



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 / acinclude.m4 /ext/session config.m4 mod_files.c

2002-10-01 Thread Sascha Schumann

sas Wed Oct  2 02:05:16 2002 EDT

  Modified files:  
/php4   acinclude.m4 
/php4/ext/session   config.m4 mod_files.c 
  Log:
  The pread/pwrite macros check for a bug in the Linux glibc now. 
  The bug causes the kernel not to return -1/EAGAIN. The new test case
  has been borrowed from the Linux Test Project.
  
  This also fixes a bug which apparently caused HAVE_PREAD/WRITE to be
  defined even if the more complex checks failed (ac_cv_func_NAME=no
  was set albeit with no difference).
  
  
Index: php4/acinclude.m4
diff -u php4/acinclude.m4:1.207 php4/acinclude.m4:1.208
--- php4/acinclude.m4:1.207 Sun Sep 29 20:03:09 2002
+++ php4/acinclude.m4   Wed Oct  2 02:05:15 2002
 -1,4 +1,4 
-dnl $Id: acinclude.m4,v 1.207 2002/09/30 00:03:09 sas Exp $
+dnl $Id: acinclude.m4,v 1.208 2002/10/02 06:05:15 sas Exp $
 dnl
 dnl This file contains local autoconf functions.
 
 -381,7 +381,16 
 #include fcntl.h
 #include unistd.h
 $1
-main() { return !(pwrite(open(conftest_in, O_WRONLY|O_CREAT, 0600), hi, 2, 0) 
== 2); }
+main() {
+int fd = open(conftest_in, O_WRONLY|O_CREAT, 0600);
+
+if (fd  0) exit(1);
+if (pwrite(fd, text, 4, 0) != 4) exit(1);
+/* Linux glibc breakage until 2.2.5 */
+if (pwrite(fd, text, 4, -1) != -1) exit(1);
+exit(0);
+}
+
   ],[
 ac_cv_pwrite=yes
   ],[
 -399,7 +408,15 
 #include fcntl.h
 #include unistd.h
 $1
-main() { char buf[3]; return !(pread(open(conftest_in, O_RDONLY), buf, 2, 0) == 
2); }
+main() {
+char buf[3]; 
+int fd = open(conftest_in, O_RDONLY);
+if (fd  0) exit(1);
+if (pread(fd, buf, 2, 0) != 2) exit(1);
+/* Linux glibc breakage until 2.2.5 */
+if (pread(fd, buf, 2, -1) != -1) exit(1);
+exit(0);
+}
   ],[
 ac_cv_pread=yes
   ],[
 -421,10 +438,12 
 fi
   ])
 
-  case $ac_cv_pwrite in
-  no) ac_cv_func_pwrite=no;;
-  64) AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]);;
-  esac
+  if test $ac_cv_pwrite != no; then
+AC_DEFINE(HAVE_PWRITE, 1, [ ])
+if test $ac_cv_pwrite = 64; then
+  AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
+fi
+  fi  
 ])
 
 AC_DEFUN(PHP_PREAD_TEST,[
 -438,10 +457,12 
 fi
   ])
 
-  case $ac_cv_pread in
-  no) ac_cv_func_pread=no;;
-  64) AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]);;
-  esac
+  if test $ac_cv_pread != no; then
+AC_DEFINE(HAVE_PREAD, 1, [ ])
+if test $ac_cv_pread = 64; then
+  AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
+fi
+  fi  
 ])
 
 AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
Index: php4/ext/session/config.m4
diff -u php4/ext/session/config.m4:1.22 php4/ext/session/config.m4:1.23
--- php4/ext/session/config.m4:1.22 Fri Sep  6 06:27:26 2002
+++ php4/ext/session/config.m4  Wed Oct  2 02:05:16 2002
 -1,5 +1,5 
 dnl
-dnl $Id: config.m4,v 1.22 2002/09/06 10:27:26 sas Exp $
+dnl $Id: config.m4,v 1.23 2002/10/02 06:05:16 sas Exp $
 dnl
 
 PHP_ARG_ENABLE(session, whether to enable PHP sessions,
 -9,7 +9,6 
 [  --with-mm[=DIR] Include mm support for session storage], no, no)
 
 if test $PHP_SESSION != no; then
-  AC_CHECK_FUNCS(pread pwrite)
   PHP_PWRITE_TEST
   PHP_PREAD_TEST
   PHP_NEW_EXTENSION(session, session.c mod_files.c mod_mm.c mod_user.c, $ext_shared)
Index: php4/ext/session/mod_files.c
diff -u php4/ext/session/mod_files.c:1.82 php4/ext/session/mod_files.c:1.83
--- php4/ext/session/mod_files.c:1.82   Tue Oct  1 15:19:10 2002
+++ php4/ext/session/mod_files.cWed Oct  2 02:05:16 2002
 -16,7 +16,7 
+--+
  */
 
-/* $Id: mod_files.c,v 1.82 2002/10/01 19:19:10 sas Exp $ */
+/* $Id: mod_files.c,v 1.83 2002/10/02 06:05:16 sas Exp $ */
 
 #include php.h
 
 -271,7 +271,7 
data-st_size = *vallen = sbuf.st_size;
*val = emalloc(sbuf.st_size);
 
-#if defined(HAVE_WORKING_PREAD_TEST)  defined(HAVE_PREAD)
+#if defined(HAVE_PREAD)
n = pread(data-fd, *val, sbuf.st_size, 0);
 #else
lseek(data-fd, 0, SEEK_SET);
 -307,7 +307,7 
if (vallen  (int)data-st_size)
ftruncate(data-fd, 0);
 
-#if defined(HAVE_WORKING_PWRITE_TEST)  defined(HAVE_PWRITE)
+#if defined(HAVE_PWRITE)
n = pwrite(data-fd, val, vallen, 0);
 #else
lseek(data-fd, 0, SEEK_SET);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php