Re: cvs: php-src / NEWS /ext/xsl xsltprocessor.c

From: Date: Mon, 22 Dec 2003 16:47:56 +0000
Subject: Re: cvs: php-src / NEWS /ext/xsl xsltprocessor.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-25375@lists.php.net to get a copy of this message
In cases like this I think it's sexier to use do {} while(0). I also use goto but usually only in places where the former isn't suitable. In your case, I think it is. It would look something like the following: int fd; php_stream *stream = php_stream_open_wrapper_ex(uri, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, NULL); do {
        if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)&fd, 1) == FAILURE) {
                break;
        }
        ret = xsltSaveResultToFd(fd, newdocp, sheetp);
        xmlFreeDoc(newdocp);
} while (0);
        php_stream_close(stream);
Anyway, it's up to you. I guess it's a matter of taste. Andi At 04:32 PM 12/22/2003 +0000, Ilia Alshanetsky wrote:
iliaa           Mon Dec 22 11:32:30 2003 EDT
Modified files:
    /php-src    NEWS
    /php-src/ext/xsl    xsltprocessor.c
Log: Fixed bug #26690 (make xsltProcessor->transformToUri use streams wrappers). Index: php-src/NEWS diff -u php-src/NEWS:1.1551 php-src/NEWS:1.1552 --- php-src/NEWS:1.1551 Mon Dec 22 11:27:14 2003
+++ php-src/NEWS        Mon Dec 22 11:32:28 2003
@@ -1,6 +1,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2004, PHP 5 RC 1 +- Fixed bug #26690 (make xsltProcessor->transformToUri use streams wrappers). + (Ilia) - Fixed bug #26675 (Segfault on ArrayAccess use). (Marcus) 21 Dec 2003, PHP 5 Beta 3 Index: php-src/ext/xsl/xsltprocessor.c diff -u php-src/ext/xsl/xsltprocessor.c:1.17 php-src/ext/xsl/xsltprocessor.c:1.18
--- php-src/ext/xsl/xsltprocessor.c:1.17        Sat Nov 29 11:37:37 2003
+++ php-src/ext/xsl/xsltprocessor.c     Mon Dec 22 11:32:29 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
*/ -/* $Id: xsltprocessor.c,v 1.17 2003/11/29 16:37:37 chregu Exp $ */ +/* $Id: xsltprocessor.c,v 1.18 2003/12/22 16:32:29 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -297,8 +297,17 @@
        ret = -1;
        if (newdocp) {
-               ret = xsltSaveResultToFilename(uri, newdocp, sheetp, 0);
+               int fd;
+               php_stream *stream = php_stream_open_wrapper_ex(uri, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, NULL);
+
+               if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)&fd, 1) == FAILURE) {
+                       goto done;
+               }
+
+               ret = xsltSaveResultToFd(fd, newdocp, sheetp);
+done:
                xmlFreeDoc(newdocp);
+               php_stream_close(stream);
        }
        RETVAL_LONG(ret);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.cvs (#25375) next »