Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10453 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43692 invoked by uid 1010); 14 Jun 2004 18:48:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 43582 invoked from network); 14 Jun 2004 18:48:41 -0000 Received: from unknown (HELO rot2.de) (217.160.191.196) by pb1.pair.com with SMTP; 14 Jun 2004 18:48:41 -0000 Received: from php-tools.net (p50839CC2.dip.t-dialin.net [80.131.156.194]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by rot2.de (Postfix) with ESMTP id A6D162CE991; Mon, 14 Jun 2004 20:40:04 +0200 (CEST) Message-ID: <40CDF306.9010107@php-tools.net> Date: Mon, 14 Jun 2004 20:48:38 +0200 Organization: PHP Application Tools User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4; MultiZilla v1.5.0.3g) Gecko/20031007 X-Accept-Language: en-us, de, en MIME-Version: 1.0 To: Sara Golemon Cc: internals@lists.php.net References: <40CDD0EC.5070905@php-tools.net> <20040614171119.24785.qmail@pb1.pair.com> <40CDE75C.3010502@php-tools.net> <20040614182658.38550.qmail@pb1.pair.com> In-Reply-To: <20040614182658.38550.qmail@pb1.pair.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Need help with streams From: schst@php-tools.net (Stephan Schmidt) Hi, > /* Not binary safe, but depending on your data that may be okay */ > if (Z_STRLEN_PP(data) > 30) { > php_stream_write(stream, Z_STRVAL_PP(data), 30); > } else { > php_stream_printf(stream TSRMLS_CC, "%-30s", Z_STRVAL_PP(data)); > } Both solutions will pad the string with ' ', but I need to pad it with '\0'. > P.S. - As you might have noticed in the above code Z_STRVAL_PP(data) is the > same as Z_STRVAL_P(*data). The same is true of the Z_LVAL_P(*data) you used > in your previous question. I don't recall if using the _PP is dictated by > the coding standards, but it's certainly in line with established > convention. You'll probably find your code becomes more readable by others > who are accostomed to the PHP Core if you stick to the secondary indirection > macros. OK, I'll adjust this in the extension. Thanks, Stephan