summaryrefslogtreecommitdiff
path: root/src/scanopt.c
diff options
context:
space:
mode:
authorStefan Reinauer <stefan.reinauer@coreboot.org>2015-05-14 11:16:04 -0700
committerWill Estes <westes575@gmail.com>2015-11-19 19:26:07 -0500
commit0f7b9136ed566f4a79b2d6ca33299babcce3049e (patch)
tree4d7e50ccc92c0917ec491c23aadaf93b5b0c5047 /src/scanopt.c
parent09eae589d3954a1e1206aa01108ee75ef57776da (diff)
Switch function definitions from mixed K&R to consistent ANSI C.
flex was using K&R function definitions for some functions and ANSI C style in others, sometimes even in the same file. Change the code to consistently use ANSI C. Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/scanopt.c')
-rw-r--r--src/scanopt.c66
1 files changed, 15 insertions, 51 deletions
diff --git a/src/scanopt.c b/src/scanopt.c
index 10c372a..4b55ed6 100644
--- a/src/scanopt.c
+++ b/src/scanopt.c
@@ -42,9 +42,7 @@
#else
static int STRCASECMP PROTO ((const char *, const char *));
-static int STRCASECMP (a, b)
- const char *a;
- const char *b;
+static int STRCASECMP (const char *a, const char *b)
{
while (tolower ((unsigned char)*a++) == tolower ((unsigned char)*b++)) ;
return b - a;
@@ -87,38 +85,28 @@ static int matchlongopt PROTO ((char *, char **, int *, char **, int *));
static int find_opt
PROTO ((struct _scanopt_t *, int, char *, int, int *, int *opt_offset));
-static const char *NAME (s, i)
- struct _scanopt_t *s;
- int i;
+static const char *NAME (struct _scanopt_t *s, int i)
{
return s->options[i].opt_fmt +
((s->aux[i].flags & IS_LONG) ? 2 : 1);
}
-static int PRINTLEN (s, i)
- struct _scanopt_t *s;
- int i;
+static int PRINTLEN (struct _scanopt_t *s, int i)
{
return s->aux[i].printlen;
}
-static int RVAL (s, i)
- struct _scanopt_t *s;
- int i;
+static int RVAL (struct _scanopt_t *s, int i)
{
return s->options[i].r_val;
}
-static int FLAGS (s, i)
- struct _scanopt_t *s;
- int i;
+static int FLAGS (struct _scanopt_t *s, int i)
{
return s->aux[i].flags;
}
-static const char *DESC (s, i)
- struct _scanopt_t *s;
- int i;
+static const char *DESC (struct _scanopt_t *s, int i)
{
return s->options[i].desc ? s->options[i].desc : "";
}
@@ -126,7 +114,7 @@ static const char *DESC (s, i)
#ifndef NO_SCANOPT_USAGE
static int get_cols PROTO ((void));
-static int get_cols ()
+static int get_cols (void)
{
char *env;
int cols = 80; /* default */
@@ -159,11 +147,7 @@ static int get_cols ()
(s)->subscript= 0; \
}while(0)
-scanopt_t *scanopt_init (options, argc, argv, flags)
- const optspec_t *options;
- int argc;
- char **argv;
- int flags;
+scanopt_t *scanopt_init (const optspec_t *options, int argc, char **argv, int flags)
{
int i;
struct _scanopt_t *s;
@@ -255,10 +239,7 @@ typedef struct usg_elem usg_elem;
[indent][option, alias1, alias2...][indent][description line1
description line2...]
*/
-int scanopt_usage (scanner, fp, usage)
- scanopt_t *scanner;
- FILE *fp;
- const char *usage;
+int scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage)
{
struct _scanopt_t *s;
int i, columns, indent = 2;
@@ -529,10 +510,7 @@ int scanopt_usage (scanner, fp, usage)
#endif /* no scanopt_usage */
-static int scanopt_err (s, is_short, err)
- struct _scanopt_t *s;
- int is_short;
- int err;
+static int scanopt_err (struct _scanopt_t *s, int is_short, int err)
{
const char *optname = "";
char optchar[2];
@@ -587,12 +565,7 @@ static int scanopt_err (s, is_short, err)
* optname will point to str + 2
*
*/
-static int matchlongopt (str, optname, optlen, arg, arglen)
- char *str;
- char **optname;
- int *optlen;
- char **arg;
- int *arglen;
+static int matchlongopt (char *str, char **optname, int *optlen, char **arg, int *arglen)
{
char *p;
@@ -634,13 +607,8 @@ static int matchlongopt (str, optname, optlen, arg, arglen)
* Short options must be exact.
* Return boolean true if found and no error.
* Error stored in err_code or zero if no error. */
-static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
- struct _scanopt_t *s;
- int lookup_long;
- char *optstart;
- int len;
- int *err_code;
- int *opt_offset;
+static int find_opt (struct _scanopt_t *s, int lookup_long, char *optstart, int
+ len, int *err_code, int *opt_offset)
{
int nmatch = 0, lastr_val = 0, i;
@@ -699,10 +667,7 @@ static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
}
-int scanopt (svoid, arg, optindex)
- scanopt_t *svoid;
- char **arg;
- int *optindex;
+int scanopt (scanopt_t *svoid, char **arg, int *optindex)
{
char *optname = NULL, *optarg = NULL, *pstart;
int namelen = 0, arglen = 0;
@@ -848,8 +813,7 @@ int scanopt (svoid, arg, optindex)
}
-int scanopt_destroy (svoid)
- scanopt_t *svoid;
+int scanopt_destroy (scanopt_t *svoid)
{
struct _scanopt_t *s;