logo       

cvs: ZendEngine2(PHP_5_3) / zend_API.c: msg#00061

Subject: cvs: ZendEngine2(PHP_5_3) / zend_API.c
tony2001                Tue Oct 30 10:17:41 2007 UTC

  Modified files:              (Branch: PHP_5_3)
    /ZendEngine2        zend_API.c 
  Log:
  backport zero args checks from HEAD
  (fixes error message when passing parameters to a function accepting none)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.34.2.7&r2=1.296.2.27.2.34.2.8&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.27.2.34.2.7 
ZendEngine2/zend_API.c:1.296.2.27.2.34.2.8
--- ZendEngine2/zend_API.c:1.296.2.27.2.34.2.7  Mon Oct 29 17:09:57 2007
+++ ZendEngine2/zend_API.c      Tue Oct 30 10:17:41 2007
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.c,v 1.296.2.27.2.34.2.7 2007/10/29 17:09:57 pollita Exp $ */
+/* $Id: zend_API.c,v 1.296.2.27.2.34.2.8 2007/10/30 10:17:41 tony2001 Exp $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -788,11 +788,26 @@
        return SUCCESS;
 }
 
+#define RETURN_IF_ZERO_ARGS(num_args, type_spec, quiet)  { \
+       int __num_args = (num_args); \
+       if (0 == (type_spec)[0] && 0 != __num_args && !(quiet)) { \
+               char *__space; \
+               char * __class_name = get_active_class_name(&__space 
TSRMLS_CC); \
+               zend_error(E_WARNING, "%s%s%s() expects exactly 0 parameters, 
%d given", \
+                                       __class_name, __space, \
+                                       get_active_function_name(TSRMLS_C), 
__num_args); \
+               return FAILURE; \
+       }\
+}
+
+
 ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char 
*type_spec, ...)
 {
        va_list va;
        int retval;
 
+       RETURN_IF_ZERO_ARGS(num_args, type_spec, flags & 
ZEND_PARSE_PARAMS_QUIET);
+
        va_start(va, type_spec);
        retval = zend_parse_va_args(num_args, type_spec, &va, flags TSRMLS_CC);
        va_end(va);
@@ -805,6 +820,8 @@
        va_list va;
        int retval;
 
+       RETURN_IF_ZERO_ARGS(num_args, type_spec, 0);
+
        va_start(va, type_spec);
        retval = zend_parse_va_args(num_args, type_spec, &va, 0 TSRMLS_CC);
        va_end(va);
@@ -821,11 +838,15 @@
        zend_class_entry *ce;
 
        if (!this_ptr) {
+               RETURN_IF_ZERO_ARGS(num_args, p, 0);
+
                va_start(va, type_spec);
                retval = zend_parse_va_args(num_args, type_spec, &va, 0 
TSRMLS_CC);
                va_end(va);
        } else {
                p++;
+               RETURN_IF_ZERO_ARGS(num_args, p, 0);
+
                va_start(va, type_spec);
 
                object = va_arg(va, zval **);
@@ -853,11 +874,15 @@
        int quiet = flags & ZEND_PARSE_PARAMS_QUIET;
 
        if (!this_ptr) {
+               RETURN_IF_ZERO_ARGS(num_args, p, quiet);
+
                va_start(va, type_spec);
                retval = zend_parse_va_args(num_args, type_spec, &va, 0 
TSRMLS_CC);
                va_end(va);
        } else {
                p++;
+               RETURN_IF_ZERO_ARGS(num_args-1, p, quiet);
+
                va_start(va, type_spec);
 
                object = va_arg(va, zval **);

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe