1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 10:43:30 +02:00

@ - Fixed getopt so it accepts arguments in the form -<option><value> not

@   just -<option> <value> (jmoore)
This commit is contained in:
James Moore
2001-05-17 21:32:05 +00:00
parent 73f04651fa
commit 873d59a8ea
+19 -4
View File
@@ -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 @@ int ap_php_getopt(int argc, char* const *argv, const char *optstr)
}
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