Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8618 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26978 invoked by uid 1010); 19 Mar 2004 19:16:47 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 26954 invoked from network); 19 Mar 2004 19:16:46 -0000 Received: from unknown (HELO gcrc.osu.edu) (140.254.51.70) by pb1.pair.com with SMTP; 19 Mar 2004 19:16:46 -0000 Received: (qmail 15771 invoked by uid 1000); 19 Mar 2004 19:15:21 -0000 Date: Fri, 19 Mar 2004 14:15:21 -0500 To: internals@lists.php.net Message-ID: <20040319191521.GA15731@spoonguard.org> References: <20040319182439.GA15076@spoonguard.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline In-Reply-To: <20040319182439.GA15076@spoonguard.org> User-Agent: Mutt/1.4.1i Subject: Re: [PATCH] PHP5 RC1: Breakage in ext/sybase From: dave@spoonguard.org (David Brown) --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="php_sybase-string-termination.diff" 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; --1yeeQ81UyVL57Vl7--