summaryrefslogtreecommitdiff
path: root/codec/compat
diff options
context:
space:
mode:
authorSebastien Lugan <slugan@users.noreply.github.com>2004-04-29 13:10:05 +0000
committerSebastien Lugan <slugan@users.noreply.github.com>2004-04-29 13:10:05 +0000
commitec9bd9f6a455a83da8c2c77f5b2628b416cca18f (patch)
treee9f3cb176093b68fc7faf35f09b595f5b1f6680d /codec/compat
parent4f83e82a74e7456881eadd68f5b863ea502ea8bc (diff)
Reformatage : indent -kr $(find . -name '*.c') $(find . -name '*.h')
Diffstat (limited to 'codec/compat')
-rw-r--r--codec/compat/getopt.c111
-rw-r--r--codec/compat/getopt.h2
2 files changed, 57 insertions, 56 deletions
diff --git a/codec/compat/getopt.c b/codec/compat/getopt.c
index baf35a40..f2854ff3 100644
--- a/codec/compat/getopt.c
+++ b/codec/compat/getopt.c
@@ -35,17 +35,17 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
-#endif /* LIBC_SCCS and not lint */
+#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-int opterr = 1, /* if error message should be printed */
- optind = 1, /* index into parent argv vector */
- optopt, /* character checked for validity */
- optreset; /* reset getopt */
-char *optarg; /* argument associated with option */
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
@@ -61,56 +61,57 @@ char *const *nargv;
const char *ostr;
{
# define __progname nargv[0]
- static char *place = EMSG; /* option letter processing */
- char *oli; /* option letter list index */
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
- if (optreset || !*place) { /* update scanning pointer */
- optreset = 0;
- if (optind >= nargc || *(place = nargv[optind]) != '-') {
- place = EMSG;
- return (-1);
- }
- if (place[1] && *++place == '-') { /* found "--" */
- ++optind;
- place = EMSG;
- return (-1);
- }
- } /* option letter okay? */
- if ((optopt = (int) *place++) == (int) ':' ||
- !(oli = strchr(ostr, optopt))) {
- /*
- * if the user didn't specify '-' as an option,
- * assume it means -1.
- */
- if (optopt == (int) '-')
- return (-1);
- if (!*place)
- ++optind;
- if (opterr && *ostr != ':')
- (void) fprintf(stderr,
- "%s: illegal option -- %c\n", __progname, optopt);
- return (BADCH);
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ place = EMSG;
+ return (-1);
}
- if (*++oli != ':') { /* don't need argument */
- optarg = NULL;
- if (!*place)
- ++optind;
- } else { /* need an argument */
- if (*place) /* no white space */
- optarg = place;
- else if (nargc <= ++optind) { /* no arg */
- place = EMSG;
- if (*ostr == ':')
- return (BADARG);
- if (opterr)
- (void) fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- __progname, optopt);
- return (BADCH);
- } else /* white space */
- optarg = nargv[optind];
- place = EMSG;
- ++optind;
+ if (place[1] && *++place == '-') { /* found "--" */
+ ++optind;
+ place = EMSG;
+ return (-1);
}
- return (optopt); /* dump back option letter */
+ } /* option letter okay? */
+ if ((optopt = (int) *place++) == (int) ':' ||
+ !(oli = strchr(ostr, optopt))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means -1.
+ */
+ if (optopt == (int) '-')
+ return (-1);
+ if (!*place)
+ ++optind;
+ if (opterr && *ostr != ':')
+ (void) fprintf(stderr,
+ "%s: illegal option -- %c\n", __progname,
+ optopt);
+ return (BADCH);
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ } else { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ if (*ostr == ':')
+ return (BADARG);
+ if (opterr)
+ (void) fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ __progname, optopt);
+ return (BADCH);
+ } else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* dump back option letter */
}
diff --git a/codec/compat/getopt.h b/codec/compat/getopt.h
index f2cf1fad..ab9c1a7b 100644
--- a/codec/compat/getopt.h
+++ b/codec/compat/getopt.h
@@ -11,4 +11,4 @@ extern char *optarg;
extern int getopt(int nargc, char *const *nargv, const char *ostr);
-#endif /* _GETOPT_H_ */
+#endif /* _GETOPT_H_ */