cvs: php4 /sapi/cgi getopt.c
| From: | James Moore | Date: | Thu, 17 May 2001 21:32:05 +0000 |
| Subject: | cvs: php4 /sapi/cgi getopt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5809@lists.php.net to get a copy of this message | ||
jmoore Thu May 17 14:32:05 2001 EDT
Modified files:
/php4/sapi/cgi getopt.c
Log:
@ - Fixed getopt so it accepts arguments in the form -<option><value> not
@ just -<option> <value> (jmoore)
Index: php4/sapi/cgi/getopt.c
diff -u php4/sapi/cgi/getopt.c:1.2 php4/sapi/cgi/getopt.c:1.3
--- php4/sapi/cgi/getopt.c:1.2 Thu Feb 10 08:44:58 2000
+++ php4/sapi/cgi/getopt.c Thu May 17 14:32:05 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,25 @@
}
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
+ {
+ int offset = 2;
+ int len = 0;
+ while(argv[ap_php_optind][offset]) {
+ buff[len++] = argv[ap_php_optind][offset++];
+ }
+ ap_php_optarg = buff;
+ ap_php_optind++;
+ }
return(*cp);
}
else