Browse code

shared/getopt.[ch]: fix type conflict on Solaris (introduced in r5060)

git-svn: trunk@5064

Tomasz Kojm authored on 2009/05/06 17:39:50
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed May  6 10:37:51 CEST 2009 (tk)
2
+----------------------------------
3
+ * shared/getopt.[ch]: fix type conflict on Solaris (introduced in r5060)
4
+
1 5
 Wed May  6 10:55:25 EEST 2009 (edwin)
2 6
 -------------------------------------
3 7
  * unit_tests/efence_tests.sh: set EF_ALIGNMENT=8 for non-x86
... ...
@@ -33,6 +33,7 @@ int optind=1, opterr=1, optopt=0;
33 33
 char *optarg=0;
34 34
 
35 35
 /* reset argument parser to start-up values */
36
+/*
36 37
 int getopt_reset(void)
37 38
 {
38 39
     optind = 1;
... ...
@@ -41,12 +42,13 @@ int getopt_reset(void)
41 41
     optarg = 0;
42 42
     return 0;
43 43
 }
44
+*/
44 45
 
45 46
 /* this is the plain old UNIX getopt, with GNU-style extensions. */
46 47
 /* if you're porting some piece of UNIX software, this is all you need. */
47 48
 /* this supports GNU-style permution and optional arguments */
48 49
 
49
-int getopt(int argc, char *argvc[], const char *opts)
50
+int my_getopt(int argc, char *argvc[], const char *opts)
50 51
 {
51 52
   char **argv = (char**)argvc;
52 53
   static int charind=0;
... ...
@@ -120,7 +122,7 @@ int getopt(int argc, char *argvc[], const char *opts)
120 120
       for(i=j=optind; i<argc; i++) if((argv[i][0] == '-') &&
121 121
                                         (argv[i][1] != '\0')) {
122 122
         optind=i;
123
-        opt=getopt(argc, argv, opts);
123
+        opt=my_getopt(argc, argv, opts);
124 124
         while(i > j) {
125 125
           tmp=argv[--i];
126 126
           for(k=i; k+1<optind; k++) argv[k]=argv[k+1];
... ...
@@ -132,7 +134,7 @@ int getopt(int argc, char *argvc[], const char *opts)
132 132
     }
133 133
   } else {
134 134
     charind++;
135
-    opt = getopt(argc, argv, opts);
135
+    opt = my_getopt(argc, argv, opts);
136 136
   }
137 137
   if (optind > argc) optind = argc;
138 138
   return opt;
... ...
@@ -143,7 +145,7 @@ int getopt(int argc, char *argvc[], const char *opts)
143 143
  * expecting GNU libc getopt call it.
144 144
  */
145 145
 
146
-int _getopt_internal(int argc, char * argv[], const char *shortopts,
146
+static int _getopt_internal(int argc, char * argv[], const char *shortopts,
147 147
                      const struct option *longopts, int *longind,
148 148
                      int long_only)
149 149
 {
... ...
@@ -192,7 +194,7 @@ int _getopt_internal(int argc, char * argv[], const char *shortopts,
192 192
       break;
193 193
     }
194 194
   } else if((!long_only) && (argv[optind][1] != '-'))
195
-    opt = getopt(argc, argv, shortopts);
195
+    opt = my_getopt(argc, argv, shortopts);
196 196
   else {
197 197
     int charind, offset;
198 198
     int found = 0, ind, hits = 0;
... ...
@@ -206,7 +208,7 @@ int _getopt_internal(int argc, char * argv[], const char *shortopts,
206 206
             ((c == 'W') && (shortopts[ind] == ';'))) &&
207 207
            (shortopts[++ind] == ':'))
208 208
           ind ++;
209
-        if(optopt == c) return getopt(argc, argv, shortopts);
209
+        if(optopt == c) return my_getopt(argc, argv, shortopts);
210 210
       }
211 211
     }
212 212
     offset = 2 - (argv[optind][1] != '-');
... ...
@@ -251,7 +253,7 @@ int _getopt_internal(int argc, char * argv[], const char *shortopts,
251 251
       }
252 252
       optind++;
253 253
     } else if(!hits) {
254
-      if(offset == 1) opt = getopt(argc, argv, shortopts);
254
+      if(offset == 1) opt = my_getopt(argc, argv, shortopts);
255 255
       else {
256 256
         opt = '?';
257 257
         if(opterr) fprintf(stderr,
... ...
@@ -269,13 +271,13 @@ int _getopt_internal(int argc, char * argv[], const char *shortopts,
269 269
   return opt;
270 270
 }
271 271
 
272
-int getopt_long(int argc, char * argv[], const char *shortopts,
272
+int my_getopt_long(int argc, char * argv[], const char *shortopts,
273 273
                 const struct option *longopts, int *longind)
274 274
 {
275 275
   return _getopt_internal(argc, argv, shortopts, longopts, longind, 0);
276 276
 }
277 277
 
278
-int getopt_long_only(int argc, char * argv[], const char *shortopts,
278
+int my_getopt_long_only(int argc, char * argv[], const char *shortopts,
279 279
                 const struct option *longopts, int *longind)
280 280
 {
281 281
   return _getopt_internal(argc, argv, shortopts, longopts, longind, 1);
... ...
@@ -30,11 +30,8 @@
30 30
 extern "C" {
31 31
 #endif
32 32
 
33
-/* reset argument parser to start-up values */
34
-extern int getopt_reset(void);
35
-
36 33
 /* UNIX-style short-argument parser */
37
-extern int getopt(int argc, char *argv[], const char *opts);
34
+extern int my_getopt(int argc, char *argv[], const char *opts);
38 35
 
39 36
 extern int optind, opterr, optopt;
40 37
 extern char *optarg;
... ...
@@ -55,16 +52,12 @@ struct option {
55 55
 #define optional_argument 2
56 56
 
57 57
 /* GNU-style long-argument parsers */
58
-extern int getopt_long(int argc, char * argv[], const char *shortopts,
58
+extern int my_getopt_long(int argc, char * argv[], const char *shortopts,
59 59
                        const struct option *longopts, int *longind);
60 60
 
61
-extern int getopt_long_only(int argc, char * argv[], const char *shortopts,
61
+extern int my_getopt_long_only(int argc, char * argv[], const char *shortopts,
62 62
                             const struct option *longopts, int *longind);
63 63
 
64
-extern int _getopt_internal(int argc, char * argv[], const char *shortopts,
65
-                            const struct option *longopts, int *longind,
66
-                            int long_only);
67
-
68 64
 #ifdef __cplusplus
69 65
 }
70 66
 #endif
... ...
@@ -766,7 +766,7 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
766 766
 
767 767
 	} else {
768 768
 	    opt_index = 0;
769
-	    ret = getopt_long(argc, argv, shortopts, longopts, &opt_index);
769
+	    ret = my_getopt_long(argc, argv, shortopts, longopts, &opt_index);
770 770
 	    if(ret == -1)
771 771
 		break;
772 772