cvs: php4(PHP_4_0_6) /sapi/cgi getopt.c
| From: | James Moore | Date: | Thu, 17 May 2001 23:21:07 +0000 |
| Subject: | cvs: php4(PHP_4_0_6) /sapi/cgi getopt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5811@lists.php.net to get a copy of this message | ||
jmoore Thu May 17 16:21:07 2001 EDT
Modified files: (Branch: PHP_4_0_6)
/php4/sapi/cgi getopt.c
Log:
MFH
# Cleaned this up. WIll commit back to head in a second.
Index: php4/sapi/cgi/getopt.c
diff -u php4/sapi/cgi/getopt.c:1.2 php4/sapi/cgi/getopt.c:1.2.6.1
--- php4/sapi/cgi/getopt.c:1.2 Thu Feb 10 08:44:58 2000
+++ php4/sapi/cgi/getopt.c Thu May 17 16:21:07 2001
@@ -10,6 +10,7 @@
#define OPTERRARG (3)
+char buff[81]; /* too hold option value when needed */
char *ap_php_optarg;
int ap_php_optind = 1;
static int ap_php_opterr = 1;
@@ -98,11 +99,20 @@
}
if (cp[1] == ':')
{
+ /* Check for cases where the value of the argument
+ is in the form -<arg> <val> or in the form -<arg><val> */
dash = 0;
- ap_php_optind++;
- if (ap_php_optind == argc)
- return(ap_php_optiserr(argc, argv, ap_php_optind-1, optstr, optchr, OPTERRARG));
- ap_php_optarg = argv[ap_php_optind++];
+ if(!argv[ap_php_optind][2]) {
+ ap_php_optind++;
+ if (ap_php_optind == argc)
+ return(ap_php_optiserr(argc, argv, ap_php_optind-1, optstr, optchr, OPTERRARG));
+ ap_php_optarg = argv[ap_php_optind++];
+ }
+ else
+ {
+ ap_php_optarg = &argv[ap_php_optind][2];
+ ap_php_optind++;
+ }
return(*cp);
}
else