[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/main/getopt.c trunk/main/getopt.c

2010-04-15 Thread Antony Dovgal
tony2001 Thu, 15 Apr 2010 11:50:43 +

Revision: http://svn.php.net/viewvc?view=revision&revision=298026

Log:
final fix for long opts in getopt()

Changed paths:
U   php/php-src/branches/PHP_5_3/main/getopt.c
U   php/php-src/trunk/main/getopt.c

Modified: php/php-src/branches/PHP_5_3/main/getopt.c
===
--- php/php-src/branches/PHP_5_3/main/getopt.c  2010-04-15 11:18:28 UTC (rev 
298025)
+++ php/php-src/branches/PHP_5_3/main/getopt.c  2010-04-15 11:50:43 UTC (rev 
298026)
@@ -81,7 +81,7 @@
}
if ((argv[*optind][0] == '-') && (argv[*optind][1] == '-')) {
char *pos;
-   int arg_end = strlen(argv[*optind])-2;
+   int arg_end = strlen(argv[*optind])-1;

/* '--' indicates end of args if not followed by a known long 
option name */
if (argv[*optind][2] == '\0') {
@@ -95,27 +95,23 @@
if ((pos = php_memnstr(&argv[*optind][arg_start], "=", 1, 
argv[*optind]+arg_end)) != NULL) {
arg_end = pos-&argv[*optind][arg_start];
arg_start++;
+   } else {
+   arg_end--;
}
-

while (1) {
php_optidx++;
if (opts[php_optidx].opt_char == '-') {
(*optind)++;
return(php_opt_error(argc, argv, *optind-1, 
optchr, OPTERRARG, show_err));
-   } else if (opts[php_optidx].opt_name && 
!strncmp(&argv[*optind][2], opts[php_optidx].opt_name, arg_end)) {
+   } else if (opts[php_optidx].opt_name && 
!strncmp(&argv[*optind][2], opts[php_optidx].opt_name, arg_end) && arg_end == 
strlen(opts[php_optidx].opt_name)) {
break;
}
}

-   if (arg_end == strlen(opts[php_optidx].opt_name)) {
-   optchr = 0;
-   dash = 0;
-   arg_start += strlen(opts[php_optidx].opt_name);
-   } else {
-   (*optind)++;
-   return (php_opt_error(argc, argv, *optind-1, optchr, 
OPTERRNF, show_err));
-   }
+   optchr = 0;
+   dash = 0;
+   arg_start += strlen(opts[php_optidx].opt_name);
} else {
if (!dash) {
dash = 1;

Modified: php/php-src/trunk/main/getopt.c
===
--- php/php-src/trunk/main/getopt.c 2010-04-15 11:18:28 UTC (rev 298025)
+++ php/php-src/trunk/main/getopt.c 2010-04-15 11:50:43 UTC (rev 298026)
@@ -81,7 +81,7 @@
}
if ((argv[*optind][0] == '-') && (argv[*optind][1] == '-')) {
char *pos;
-   int arg_end = strlen(argv[*optind])-2;
+   int arg_end = strlen(argv[*optind])-1;

/* '--' indicates end of args if not followed by a known long 
option name */
if (argv[*optind][2] == '\0') {
@@ -95,27 +95,23 @@
if ((pos = php_memnstr(&argv[*optind][arg_start], "=", 1, 
argv[*optind]+arg_end)) != NULL) {
arg_end = pos-&argv[*optind][arg_start];
arg_start++;
+   } else {
+   arg_end--;
}
-

while (1) {
php_optidx++;
if (opts[php_optidx].opt_char == '-') {
(*optind)++;
return(php_opt_error(argc, argv, *optind-1, 
optchr, OPTERRARG, show_err));
-   } else if (opts[php_optidx].opt_name && 
!strncmp(&argv[*optind][2], opts[php_optidx].opt_name, arg_end)) {
+   } else if (opts[php_optidx].opt_name && 
!strncmp(&argv[*optind][2], opts[php_optidx].opt_name, arg_end) && arg_end == 
strlen(opts[php_optidx].opt_name)) {
break;
}
}

-   if (arg_end == strlen(opts[php_optidx].opt_name)) {
-   optchr = 0;
-   dash = 0;
-   arg_start += strlen(opts[php_optidx].opt_name);
-   } else {
-   (*optind)++;
-   return (php_opt_error(argc, argv, *optind-1, optchr, 
OPTERRNF, show_err));
-   }
+   optchr = 0;
+   dash = 0;
+   arg_start += strlen(opts[php_optidx].opt_name);
} else {
if (!dash) {
dash = 1;

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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/main/getopt.c trunk/main/getopt.c

2010-04-14 Thread Antony Dovgal
tony2001 Wed, 14 Apr 2010 15:49:38 +

Revision: http://svn.php.net/viewvc?view=revision&revision=297995

Log:
discard first TWO symbols of a long argument

Changed paths:
U   php/php-src/branches/PHP_5_3/main/getopt.c
U   php/php-src/trunk/main/getopt.c

Modified: php/php-src/branches/PHP_5_3/main/getopt.c
===
--- php/php-src/branches/PHP_5_3/main/getopt.c  2010-04-14 15:32:56 UTC (rev 
297994)
+++ php/php-src/branches/PHP_5_3/main/getopt.c  2010-04-14 15:49:38 UTC (rev 
297995)
@@ -81,7 +81,7 @@
}
if ((argv[*optind][0] == '-') && (argv[*optind][1] == '-')) {
char *pos;
-   int arg_end = strlen(argv[*optind])-1;
+   int arg_end = strlen(argv[*optind])-2;

/* '--' indicates end of args if not followed by a known long 
option name */
if (argv[*optind][2] == '\0') {

Modified: php/php-src/trunk/main/getopt.c
===
--- php/php-src/trunk/main/getopt.c 2010-04-14 15:32:56 UTC (rev 297994)
+++ php/php-src/trunk/main/getopt.c 2010-04-14 15:49:38 UTC (rev 297995)
@@ -81,7 +81,7 @@
}
if ((argv[*optind][0] == '-') && (argv[*optind][1] == '-')) {
char *pos;
-   int arg_end = strlen(argv[*optind])-1;
+   int arg_end = strlen(argv[*optind])-2;

/* '--' indicates end of args if not followed by a known long 
option name */
if (argv[*optind][2] == '\0') {

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