summaryrefslogtreecommitdiff
path: root/app/wlib/mswlib/getopt.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2024-07-03 10:19:30 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2024-07-03 10:19:30 +0200
commita14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (patch)
treee469179df67a0e0db49161a43cbf8076a189f6f4 /app/wlib/mswlib/getopt.c
parent5d2c2b27a6323e2666378b986129b2a7c2c39e5c (diff)
New upstream version 5.3.0GAupstream/5.3.0GAupstream
Diffstat (limited to 'app/wlib/mswlib/getopt.c')
-rw-r--r--app/wlib/mswlib/getopt.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/app/wlib/mswlib/getopt.c b/app/wlib/mswlib/getopt.c
index 888f5f8..48ffca9 100644
--- a/app/wlib/mswlib/getopt.c
+++ b/app/wlib/mswlib/getopt.c
@@ -20,7 +20,7 @@
You should have received a copy of the GNU General Public License
along with ASPEX; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
----------------------------------------------------------------------*/
@@ -39,49 +39,50 @@ int optind = 1, opterr, optopt;
int getopt(int argc, char *argv[], const char *optstring)
{
- static int pos = 0;
- char *str;
-
- if (pos == 0) {
- if ((optind >= argc) || (*argv[optind] != OPTCHAR))
- return EOF;
- pos = 1;
- if (argv[optind][pos] == '\0')
- return EOF;
- }
-
- str = strchr(optstring, argv[optind][pos]);
- if (str == NULL) {
- optopt = argv[optind][pos];
- if (opterr)
- fprintf(stderr, "%s: illegal option -- %c\n", argv[0],
- optopt);
- return '?';
- }
-
- if (str[1] == ':') {
- if (argv[optind][pos+1] != '\0') {
- optarg = &argv[optind][pos+1];
- return *str;
+ static int pos = 0;
+ char *str;
+
+ if (pos == 0) {
+ if ((optind >= argc) || (*argv[optind] != OPTCHAR)) {
+ return EOF;
+ }
+ pos = 1;
+ if (argv[optind][pos] == '\0') {
+ return EOF;
+ }
}
- optind++;
- if (optind >= argc) {
- optopt = *str;
- if (opterr)
- fprintf(stderr, "%s: option requires an argument -- %c\n",
- argv[0], optopt);
- return '?';
+
+ str = strchr(optstring, argv[optind][pos]);
+ if (str == NULL) {
+ optopt = argv[optind][pos];
+ if (opterr)
+ fprintf(stderr, "%s: illegal option -- %c\n", argv[0],
+ optopt);
+ return '?';
}
- optarg = argv[optind];
- optind++; pos = 0;
- return *str;
- }
- else {
- pos++;
- if (argv[optind][pos] == '\0') {
- optind++;
- pos = 0;
+
+ if (str[1] == ':') {
+ if (argv[optind][pos+1] != '\0') {
+ optarg = &argv[optind][pos+1];
+ return *str;
+ }
+ optind++;
+ if (optind >= argc) {
+ optopt = *str;
+ if (opterr)
+ fprintf(stderr, "%s: option requires an argument -- %c\n",
+ argv[0], optopt);
+ return '?';
+ }
+ optarg = argv[optind];
+ optind++; pos = 0;
+ return *str;
+ } else {
+ pos++;
+ if (argv[optind][pos] == '\0') {
+ optind++;
+ pos = 0;
+ }
+ return *str;
}
- return *str;
- }
}