diff options
Diffstat (limited to 'libc/unistd/getopt.c')
-rw-r--r-- | libc/unistd/getopt.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/libc/unistd/getopt.c b/libc/unistd/getopt.c index 2cf5dbb73..d9c458595 100644 --- a/libc/unistd/getopt.c +++ b/libc/unistd/getopt.c @@ -34,6 +34,13 @@ #include <libintl.h> #endif +libc_hidden_proto(strchr) +libc_hidden_proto(strcmp) +libc_hidden_proto(strlen) +libc_hidden_proto(strncmp) +libc_hidden_proto(getenv) +libc_hidden_proto(fprintf) + #ifdef __UCLIBC_MJN3_ONLY__ #warning TODO: Enable gettext awareness. #endif /* __UCLIBC_MJN3_ONLY__ */ @@ -149,7 +156,7 @@ static enum } ordering; # include <string.h> -# define my_index __strchr +# define my_index strchr /* Handle permutation of arguments. */ @@ -247,7 +254,7 @@ static const char *_getopt_initialize (attribute_unused int argc, attribute_unus ordering = REQUIRE_ORDER; ++optstring; } - else if (__getenv ("POSIXLY_CORRECT") != NULL) + else if (getenv ("POSIXLY_CORRECT") != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; @@ -371,7 +378,7 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ - if (optind != argc && !__strcmp (argv[optind], "--")) + if (optind != argc && !strcmp (argv[optind], "--")) { optind++; @@ -447,10 +454,10 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!__strncmp (p->name, nextchar, nameend - nextchar)) + if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) - == (unsigned int) __strlen (p->name)) + == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -479,7 +486,7 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); } - nextchar += __strlen (nextchar); + nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; @@ -517,7 +524,7 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * } - nextchar += __strlen (nextchar); + nextchar += strlen (nextchar); optopt = pfound->val; return '?'; @@ -535,12 +542,12 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); } - nextchar += __strlen (nextchar); + nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } - nextchar += __strlen (nextchar); + nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) @@ -651,9 +658,9 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!__strncmp (p->name, nextchar, nameend - nextchar)) + if (!strncmp (p->name, nextchar, nameend - nextchar)) { - if ((unsigned int) (nameend - nextchar) == __strlen (p->name)) + if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -678,7 +685,7 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); } - nextchar += __strlen (nextchar); + nextchar += strlen (nextchar); optind++; return '?'; } @@ -700,7 +707,7 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * argv[0], pfound->name); } - nextchar += __strlen (nextchar); + nextchar += strlen (nextchar); return '?'; } } @@ -716,11 +723,11 @@ int attribute_hidden _getopt_internal (int argc, char *const *argv, const char * _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); } - nextchar += __strlen (nextchar); + nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } - nextchar += __strlen (nextchar); + nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) |