Hi:

On Fri, Mar 19, 2004 at 01:24:39PM -0500, David Brown wrote:
| +     /* Get rid of extra nulls */
| +     while (res_length > 0 && res_buf[res_length] == '\0')
| +             res_length--;
| +
|       Z_STRVAL_P(result) = res_buf;
| +     Z_STRLEN_P(result) = res_length+1;
|       Z_TYPE_P(result) = IS_STRING;

Replying to myself. Though this is technically correct (since the case
of res_length == 0 is filtered out before this code runs), it's really
unclear. Sorry about that. I've attached an updated patch - this one
does the right-trimming in the same way as it's done elsewhere in
php_sybase_get_column_content.

Thanks,

- Dave
  [EMAIL PROTECTED]

diff -ur php-5.0.0RC1-dist/ext/sybase/php_sybase_db.c 
php-5.0.0RC1/ext/sybase/php_sybase_db.c
--- php-5.0.0RC1-dist/ext/sybase/php_sybase_db.c        2004-03-19 14:06:06.000000000 
-0500
+++ php-5.0.0RC1/ext/sybase/php_sybase_db.c     2004-03-19 14:10:48.000000000 -0500
@@ -731,19 +731,13 @@
                                }
 
                                res_buf = (char *) emalloc(res_length+1);
-                               memset(res_buf,' ',res_length+1);  /* XXX i'm sure 
there's a better way
-                                                                                      
                   but i don't have sybase here to test
-                                                                                      
                   991105 [EMAIL PROTECTED]  */
-                               
dbconvert(NULL,coltype(offset),dbdata(sybase_ptr->link,offset), 
src_length,SYBCHAR,res_buf,res_length);
-#if ilia_0             
-                               /* get rid of trailing spaces */
-                               p = res_buf + res_length;
-                               while (p >= res_buf && (*p == ' ' || *p == '\0')) {
-                                       p--;
-                               }
-                               *(++p) = 0; /* put a trailing NULL */
-                               res_length = p - res_buf;
-#endif         
+                               memset(res_buf,0,res_length+1);
+                               
dbconvert(NULL,coltype(offset),dbdata(sybase_ptr->link,offset),src_length,SYBCHAR,res_buf,res_length);
+
+                               /* Get rid of extra nulls */
+                               while (res_length > 0 && res_buf[res_length-1] == '\0')
+                                       res_length--;
+
                                Z_STRLEN_P(result) = res_length;
                                Z_STRVAL_P(result) = res_buf;
                                Z_TYPE_P(result) = IS_STRING;

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to