[ofw] [PATCH] getopt.c - support parsing rewind

Smith, Stan stan.smith at intel.com
Fri May 21 09:08:01 PDT 2010


Support getopt()/get_opt_long() parsing rewind (ala optind = 0) as used in opensm.

signed-off-by: stan smith <stan.mith at intel.com>

--- a/etc/user/getopt.c Fri May 21 09:04:30 2010
+++ b/etc/user/getopt.c Fri May 21 09:00:20 2010
@@ -45,6 +45,11 @@

        optarg = NULL;

+       if (optind == 0) {
+               optind = opterr = 1;
+               optopt = '?';
+       }
+
        if (optind >= argc) {
                return EOF;
        }
@@ -102,6 +107,12 @@
        char arg[256];
        char *str;
        int i;
+
+       if (optind == 0) {
+               optarg = NULL;
+               optind = opterr = 1;
+               optopt = '?';
+       }

        if (optind == argc) {
                return EOF;



More information about the ofw mailing list