summaryrefslogtreecommitdiff
path: root/src/misc/getopt.c
AgeCommit message (Collapse)AuthorLines
2014-12-10fix getopt handling of initial '+' in optstringRich Felker-1/+1
in the case where an initial '+' was passed in optstring (a getopt_long feature to suppress argv permutation), getopt would fail to see a possible subsequent ':', resulting in incorrect handling of missing arguments.
2014-12-04fix getopt handling of ':' modifier for multibyte option charactersRich Felker-4/+9
the previous hard-coded offsets of +1 and +2 contained a hidden assumption that the option character matched was single-byte, despite this implementation of getopt attempting to support multibyte option characters. this patch reworks the matching logic to leave the final index pointing just past the matched character so that fixed offsets can be used to check for ':'.
2014-12-02add support for non-option arguments extension to getoptGianluca Anzolin-1/+16
this is a GNU extension, activated by including '-' as the first character of the options string, whereby non-option arguments are processed as if they were arguments to an option character '\1' rather than ending option processing.
2014-11-15getopt: fix optional argument processingFelix Fietkau-2/+2
Processing an option character with optional argument fails if the option is last on the command line. This happens because the if (optind >= argc) check runs first before testing for optional argument.
2014-06-11support optional-argument extension to getopt via double-colonRich Felker-2/+5
this extension is not incompatible with the standard behavior of the function, not expensive, and avoids requiring a replacement getopt with full GNU extensions for a few important apps including busybox's sed with the -i option.
2013-04-05Add ABI compatability aliases.Isaac Dunham-0/+2
GNU used several extensions that were incompatible with C99 and POSIX, so they used alternate names for the standard functions. The result is that we need these to run standards-conformant programs that were linked with glibc.
2012-09-30add getopt reset supportRich Felker-2/+11
based on proposed patches by Daniel Cegiełka, with minor changes: - use a weak symbol for optreset so it doesn't clash with namespace - also reset optpos (position in multi-option arg like -lR) - also make getopt_long support reset
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+63