sniper          Sun Apr 15 22:54:27 2007 UTC

  Modified files:              
    /php-src/sapi/cgi   getopt.c php_getopt.h 
  Log:
  MFB: sync getopt from CLI
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/getopt.c?r1=1.11&r2=1.12&diff_format=u
Index: php-src/sapi/cgi/getopt.c
diff -u php-src/sapi/cgi/getopt.c:1.11 php-src/sapi/cgi/getopt.c:1.12
--- php-src/sapi/cgi/getopt.c:1.11      Mon Jan  1 09:29:36 2007
+++ php-src/sapi/cgi/getopt.c   Sun Apr 15 22:54:26 2007
@@ -16,6 +16,8 @@
    +----------------------------------------------------------------------+
 */
 
+/* $Id: getopt.c,v 1.12 2007/04/15 22:54:26 sniper Exp $ */
+
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
@@ -77,29 +79,34 @@
        }
        if ((argv[*optind][0] == '-') && (argv[*optind][1] == '-')) {
                /* '--' indicates end of args if not followed by a known long 
option name */
+               if (argv[*optind][2] == '\0') {
+                       (*optind)++;
+                       return(EOF);
+               }
+
                while (1) {
                        opts_idx++;
                        if (opts[opts_idx].opt_char == '-') {
                                (*optind)++;
-                               return(EOF);
+                               return(php_opt_error(argc, argv, *optind-1, 
optchr, OPTERRARG, show_err));
                        } else if (opts[opts_idx].opt_name && 
!strcmp(&argv[*optind][2], opts[opts_idx].opt_name)) {
                                break;
                        }
                }
                optchr = 0;
-               dash = 1;
-               arg_start = 2 + strlen(opts[opts_idx].opt_name);
-       }
-       if (!dash) {
-               dash = 1;
-               optchr = 1;
-       }
-
-       /* Check if the guy tries to do a -: kind of flag */
-       if (argv[*optind][optchr] == ':') {
                dash = 0;
-               (*optind)++;
-               return (php_opt_error(argc, argv, *optind-1, optchr, 
OPTERRCOLON, show_err));
+               arg_start = 2 + strlen(opts[opts_idx].opt_name);
+       } else {
+               if (!dash) {
+                       dash = 1;
+                       optchr = 1;
+               }
+               /* Check if the guy tries to do a -: kind of flag */
+               if (argv[*optind][optchr] == ':') {
+                       dash = 0;
+                       (*optind)++;
+                       return (php_opt_error(argc, argv, *optind-1, optchr, 
OPTERRCOLON, show_err));
+               }
        }
        if (opts_idx < 0) {
                while (1) {
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/php_getopt.h?r1=1.9&r2=1.10&diff_format=u
Index: php-src/sapi/cgi/php_getopt.h
diff -u php-src/sapi/cgi/php_getopt.h:1.9 php-src/sapi/cgi/php_getopt.h:1.10
--- php-src/sapi/cgi/php_getopt.h:1.9   Mon Jan  1 09:29:36 2007
+++ php-src/sapi/cgi/php_getopt.h       Sun Apr 15 22:54:26 2007
@@ -16,8 +16,17 @@
    +----------------------------------------------------------------------+
 */
 
+/* $Id: php_getopt.h,v 1.10 2007/04/15 22:54:26 sniper Exp $ */
+
 #include "php.h"
 
+#ifdef NETWARE
+/*
+As NetWare LibC has optind and optarg macros defined in unistd.h our local 
variables were getting mistakenly preprocessed so undeffing optind and optarg
+*/
+#undef optarg
+#undef optind
+#endif
 /* Define structure for one recognized option (both single char and long name).
  * If short_open is '-' this is the last option.
  */

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

Reply via email to