Re: [PATCH] PHP5 RC1: Breakage in ext/sybase
| From: | David Brown | Date: | Fri, 19 Mar 2004 19:15:21 +0000 |
| Subject: | Re: [PATCH] PHP5 RC1: Breakage in ext/sybase | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8618@lists.php.net to get a copy of this message | ||
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
dave@spoonguard.org
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 thies@thieso.net */ - 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;
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 thies@thieso.net */ - 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;