summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2017-11-12 23:00:10 +0800
committerWill Estes <westes575@gmail.com>2017-12-08 09:56:18 -0500
commitc984ab0fd0ad534a725019a7bf4f49a3571d87d1 (patch)
tree70ae11a862af1bc70926cabfab1565044702e921
parentaa775c871137c570ded2bbd6ebbe7ca4ee39efe7 (diff)
scanner: scanopt_err() now returns void
-rw-r--r--src/scanopt.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/scanopt.c b/src/scanopt.c
index 76d15af..04fbdc3 100644
--- a/src/scanopt.c
+++ b/src/scanopt.c
@@ -68,7 +68,7 @@ static int PRINTLEN(struct _scanopt_t *, int);
static int RVAL(struct _scanopt_t *, int);
static int FLAGS(struct _scanopt_t *, int);
static const char *DESC(struct _scanopt_t *, int);
-static int scanopt_err(struct _scanopt_t *, int, int);
+static void scanopt_err(struct _scanopt_t *, int, int);
static int matchlongopt(char *, char **, int *, char **, int *);
static int find_opt(struct _scanopt_t *, int, char *, int, int *, int *opt_offset);
@@ -457,7 +457,7 @@ int scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage)
#endif /* no scanopt_usage */
-static int scanopt_err (struct _scanopt_t *s, int is_short, int err)
+static void scanopt_err(struct _scanopt_t *s, int is_short, int err)
{
const char *optname = "";
char optchar[2];
@@ -502,7 +502,6 @@ static int scanopt_err (struct _scanopt_t *s, int is_short, int err)
break;
}
}
- return err;
}
@@ -689,7 +688,8 @@ int scanopt (scanopt_t *svoid, char **arg, int *optindex)
if (!find_opt
(s, 0, pstart, namelen, &errcode, &opt_offset)) {
- return scanopt_err (s, 1, errcode);
+ scanopt_err(s, 1, errcode);
+ return errcode;
}
optarg = pstart + 1;
@@ -717,9 +717,9 @@ int scanopt (scanopt_t *svoid, char **arg, int *optindex)
/* case: no args allowed */
if (auxp->flags & ARG_NONE) {
if (optarg && !is_short) {
- scanopt_err (s, is_short, errcode = SCANOPT_ERR_ARG_NOT_ALLOWED);
+ scanopt_err(s, is_short, SCANOPT_ERR_ARG_NOT_ALLOWED);
INC_INDEX (s, 1);
- return errcode;
+ return SCANOPT_ERR_ARG_NOT_ALLOWED;
}
else if (!optarg)
INC_INDEX (s, 1);
@@ -730,8 +730,10 @@ int scanopt (scanopt_t *svoid, char **arg, int *optindex)
/* case: required */
if (auxp->flags & ARG_REQ) {
- if (!optarg && !has_next)
- return scanopt_err (s, is_short, SCANOPT_ERR_ARG_NOT_FOUND);
+ if (!optarg && !has_next) {
+ scanopt_err(s, is_short, SCANOPT_ERR_ARG_NOT_FOUND);
+ return SCANOPT_ERR_ARG_NOT_FOUND;
+ }
if (!optarg) {
/* Let the next argv element become the argument. */