summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/lex/ccl.c15
-rw-r--r--usr.bin/lex/dfa.c39
-rw-r--r--usr.bin/lex/filter.c5
-rw-r--r--usr.bin/lex/flexdef.h4
-rw-r--r--usr.bin/lex/gen.c44
-rw-r--r--usr.bin/lex/main.c28
-rw-r--r--usr.bin/lex/misc.c148
-rw-r--r--usr.bin/lex/nfa.c52
-rw-r--r--usr.bin/lex/parse.y33
-rw-r--r--usr.bin/lex/scan.l10
-rw-r--r--usr.bin/lex/scanopt.c76
-rw-r--r--usr.bin/lex/sym.c45
-rw-r--r--usr.bin/lex/tblcmp.c41
-rw-r--r--usr.bin/lex/yylex.c4
14 files changed, 175 insertions, 369 deletions
diff --git a/usr.bin/lex/ccl.c b/usr.bin/lex/ccl.c
index 1c9e42e0f79..d773ffbfc87 100644
--- a/usr.bin/lex/ccl.c
+++ b/usr.bin/lex/ccl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccl.c,v 1.9 2022/12/26 19:16:01 jmc Exp $ */
+/* $OpenBSD: ccl.c,v 1.10 2024/11/09 18:03:44 op Exp $ */
/* ccl - routines for character classes */
@@ -55,9 +55,7 @@ ccl_contains(const int cclp, const int ch)
/* ccladd - add a single character to a ccl */
void
-ccladd(cclp, ch)
- int cclp;
- int ch;
+ccladd(int cclp, int ch)
{
int ind, len, newpos, i;
@@ -190,7 +188,7 @@ ccl_set_union(int a, int b)
/* cclinit - return an empty ccl */
int
-cclinit()
+cclinit(void)
{
if (++lastccl >= current_maxccls) {
current_maxccls += MAX_CCLS_INCREMENT;
@@ -231,8 +229,7 @@ cclinit()
/* cclnegate - negate the given ccl */
void
-cclnegate(cclp)
- int cclp;
+cclnegate(int cclp)
{
cclng[cclp] = 1;
ccl_has_nl[cclp] = !ccl_has_nl[cclp];
@@ -247,9 +244,7 @@ cclnegate(cclp)
*/
void
-list_character_set(file, cset)
- FILE *file;
- int cset[];
+list_character_set(FILE *file, int cset[])
{
int i;
diff --git a/usr.bin/lex/dfa.c b/usr.bin/lex/dfa.c
index b986787fa1b..9c1c9e515aa 100644
--- a/usr.bin/lex/dfa.c
+++ b/usr.bin/lex/dfa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dfa.c,v 1.8 2015/11/19 23:20:34 tedu Exp $ */
+/* $OpenBSD: dfa.c,v 1.9 2024/11/09 18:03:44 op Exp $ */
/* dfa - DFA construction routines */
@@ -51,9 +51,7 @@ int symfollowset PROTO ((int[], int, int, int[]));
* indexed by equivalence class.
*/
-void check_for_backing_up (ds, state)
- int ds;
- int state[];
+void check_for_backing_up (int ds, int state[])
{
if ((reject && !dfaacc[ds].dfaacc_set) || (!reject && !dfaacc[ds].dfaacc_state)) { /* state is non-accepting */
++num_backing_up;
@@ -98,10 +96,8 @@ void check_for_backing_up (ds, state)
* accset[1 .. nacc] is the list of accepting numbers for the DFA state.
*/
-void check_trailing_context (nfa_states, num_states, accset, nacc)
- int *nfa_states, num_states;
- int *accset;
- int nacc;
+void check_trailing_context (int *nfa_states, int num_states,
+ int *accset, int nacc)
{
int i, j;
@@ -139,9 +135,7 @@ void check_trailing_context (nfa_states, num_states, accset, nacc)
* and writes a report to the given file.
*/
-void dump_associated_rules (file, ds)
- FILE *file;
- int ds;
+void dump_associated_rules (FILE *file, int ds)
{
int i, j;
int num_associated_rules = 0;
@@ -189,9 +183,7 @@ void dump_associated_rules (file, ds)
* is done to the given file.
*/
-void dump_transitions (file, state)
- FILE *file;
- int state[];
+void dump_transitions (FILE *file, int state[])
{
int i, ec;
int out_char_set[CSIZE];
@@ -237,8 +229,8 @@ void dump_transitions (file, state)
* hashval is the hash value for the dfa corresponding to the state set.
*/
-int *epsclosure (t, ns_addr, accset, nacc_addr, hv_addr)
- int *t, *ns_addr, accset[], *nacc_addr, *hv_addr;
+int *epsclosure (int *t, int *ns_addr, int accset[], int *nacc_addr,
+ int *hv_addr)
{
int stkpos, ns, tsp;
int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum;
@@ -353,7 +345,7 @@ ADD_STATE(state); \
/* increase_max_dfas - increase the maximum number of DFAs */
-void increase_max_dfas ()
+void increase_max_dfas (void)
{
current_max_dfas += MAX_DFAS_INCREMENT;
@@ -380,7 +372,7 @@ void increase_max_dfas ()
* dfa starts out in state #1.
*/
-void ntod ()
+void ntod (void)
{
int *accset, ds, nacc, newds;
int sym, hashval, numstates, dsize;
@@ -822,8 +814,8 @@ void ntod ()
* On return, the dfa state number is in newds.
*/
-int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
- int sns[], numstates, accset[], nacc, hashval, *newds_addr;
+int snstods (int sns[], int numstates, int accset[], int nacc, int hashval,
+ int *newds_addr)
{
int didsort = 0;
int i, j;
@@ -944,8 +936,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
* int transsym, int nset[current_max_dfa_size] );
*/
-int symfollowset (ds, dsize, transsym, nset)
- int ds[], dsize, transsym, nset[];
+int symfollowset (int ds[], int dsize, int transsym, int nset[])
{
int ns, tsp, sym, i, j, lenccl, ch, numstates, ccllist;
@@ -1022,9 +1013,7 @@ int symfollowset (ds, dsize, transsym, nset)
* int symlist[numecs], int duplist[numecs] );
*/
-void sympartition (ds, numstates, symlist, duplist)
- int ds[], numstates;
- int symlist[], duplist[];
+void sympartition (int ds[], int numstates, int symlist[], int duplist[])
{
int tch, i, j, k, ns, dupfwd[CSIZE + 1], lenccl, cclp, ich;
diff --git a/usr.bin/lex/filter.c b/usr.bin/lex/filter.c
index 22b3fccba07..b1ad8fa0e77 100644
--- a/usr.bin/lex/filter.c
+++ b/usr.bin/lex/filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: filter.c,v 1.9 2017/08/30 02:54:07 lteo Exp $ */
+/* $OpenBSD: filter.c,v 1.10 2024/11/09 18:03:44 op Exp $ */
/* filter - postprocessing of flex output through filters */
@@ -361,11 +361,10 @@ filter_fix_linedirs(struct filter * chain)
if (buf[0] == '#'
&& regexec(&regex_linedir, buf, 3, m, 0) == 0) {
- int num;
char *fname;
/* extract the line number and filename */
- num = regmatch_strtol(&m[1], buf, NULL, 0);
+ regmatch_strtol(&m[1], buf, NULL, 0);
fname = regmatch_dup(&m[2], buf);
if (strcmp(fname,
diff --git a/usr.bin/lex/flexdef.h b/usr.bin/lex/flexdef.h
index 8cf92079b2f..d1a64c7d84c 100644
--- a/usr.bin/lex/flexdef.h
+++ b/usr.bin/lex/flexdef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: flexdef.h,v 1.16 2022/12/26 19:16:01 jmc Exp $ */
+/* $OpenBSD: flexdef.h,v 1.17 2024/11/09 18:03:44 op Exp $ */
/* flexdef - definitions file for flex */
@@ -997,7 +997,7 @@ extern int yyparse PROTO ((void)); /* the YACC parser */
extern int flexscan PROTO ((void));
/* Open the given file (if NULL, stdin) for scanning. */
-extern void set_input_file PROTO ((char *));
+extern void set_input_file PROTO ((const char *));
/* Wrapup a file in the lexical analyzer. */
extern int yywrap PROTO ((void));
diff --git a/usr.bin/lex/gen.c b/usr.bin/lex/gen.c
index 0a3f29fa308..4adc1618907 100644
--- a/usr.bin/lex/gen.c
+++ b/usr.bin/lex/gen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gen.c,v 1.15 2015/11/19 23:28:03 tedu Exp $ */
+/* $OpenBSD: gen.c,v 1.16 2024/11/09 18:03:44 op Exp $ */
/* gen - actual generation (writing) of flex scanners */
@@ -85,7 +85,7 @@ get_state_decl(void)
/* Indent to the current level. */
void
-do_indent()
+do_indent(void)
{
int i = indent_level * 8;
@@ -129,7 +129,7 @@ mkeoltbl(void)
/* Generate the table for possible eol matches. */
static void
-geneoltbl()
+geneoltbl(void)
{
int i;
@@ -154,7 +154,7 @@ geneoltbl()
/* Generate the code to keep backing-up information. */
void
-gen_backing_up()
+gen_backing_up(void)
{
if (reject || num_backing_up == 0)
return;
@@ -176,7 +176,7 @@ gen_backing_up()
/* Generate the code to perform the backing up. */
void
-gen_bu_action()
+gen_bu_action(void)
{
if (reject || num_backing_up == 0)
return;
@@ -342,7 +342,7 @@ mkssltbl(void)
/* genctbl - generates full speed compressed transition table */
void
-genctbl()
+genctbl(void)
{
int i;
int end_of_buffer_action = num_rules + 1;
@@ -445,7 +445,7 @@ genctbl()
/* mkecstbl - Make equivalence-class tables. */
-struct yytbl_data *
+static struct yytbl_data *
mkecstbl(void)
{
int i;
@@ -476,7 +476,7 @@ mkecstbl(void)
/* Generate equivalence-class tables. */
void
-genecs()
+genecs(void)
{
int i, j;
int numrows;
@@ -512,7 +512,7 @@ genecs()
/* Generate the code to find the action number. */
void
-gen_find_action()
+gen_find_action(void)
{
if (fullspd)
indent_puts("yy_act = yy_current_state[-1].yy_nxt;");
@@ -690,7 +690,7 @@ mkftbl(void)
/* genftbl - generate full transition table */
void
-genftbl()
+genftbl(void)
{
int i;
int end_of_buffer_action = num_rules + 1;
@@ -724,9 +724,8 @@ genftbl()
/* Generate the code to find the next compressed-table state. */
-void
-gen_next_compressed_state(char_map)
- char *char_map;
+void
+gen_next_compressed_state(char *char_map)
{
indent_put2s("YY_CHAR yy_c = %s;", char_map);
@@ -771,7 +770,7 @@ gen_next_compressed_state(char_map)
/* Generate the code to find the next match. */
void
-gen_next_match()
+gen_next_match(void)
{
/*
* NOTE - changes in here should be reflected in gen_next_state() and
@@ -873,8 +872,7 @@ gen_next_match()
/* Generate the code to find the next state. */
void
-gen_next_state(worry_about_NULs)
- int worry_about_NULs;
+gen_next_state(int worry_about_NULs)
{ /* NOTE - changes in here should be reflected
* in gen_next_match() */
char char_map[256];
@@ -940,7 +938,7 @@ gen_next_state(worry_about_NULs)
/* Generate the code to make a NUL transition. */
void
-gen_NUL_trans()
+gen_NUL_trans(void)
{ /* NOTE - changes in here should be reflected
* in gen_next_match() */
/*
@@ -1025,7 +1023,7 @@ gen_NUL_trans()
/* Generate the code to find the start state. */
void
-gen_start_state()
+gen_start_state(void)
{
if (fullspd) {
if (bol_needed) {
@@ -1056,7 +1054,7 @@ gen_start_state()
/* gentabs - generate data statements for the transition tables */
void
-gentabs()
+gentabs(void)
{
int i, j, k, *accset, nacc, *acc_array, total_states;
int end_of_buffer_action = num_rules + 1;
@@ -1475,8 +1473,7 @@ gentabs()
*/
void
-indent_put2s(fmt, arg)
- const char *fmt, *arg;
+indent_put2s(const char *fmt, const char *arg)
{
do_indent();
out_str(fmt, arg);
@@ -1489,8 +1486,7 @@ indent_put2s(fmt, arg)
*/
void
-indent_puts(str)
- const char *str;
+indent_puts(const char *str)
{
do_indent();
outn(str);
@@ -1501,7 +1497,7 @@ indent_puts(str)
*/
void
-make_tables()
+make_tables(void)
{
int i;
int did_eof_rule = false;
diff --git a/usr.bin/lex/main.c b/usr.bin/lex/main.c
index 6930c84a946..0fac0a01b66 100644
--- a/usr.bin/lex/main.c
+++ b/usr.bin/lex/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.29 2022/12/26 19:16:01 jmc Exp $ */
+/* $OpenBSD: main.c,v 1.30 2024/11/09 18:03:44 op Exp $ */
/* flex - tool to generate fast lexical analyzers */
@@ -137,9 +137,7 @@ int flex_main PROTO((int argc, char *argv[]));
int main PROTO((int argc, char *argv[]));
int
-flex_main(argc, argv)
- int argc;
- char *argv[];
+flex_main(int argc, char *argv[])
{
int i, exit_status, child_status;
@@ -202,9 +200,7 @@ flex_main(argc, argv)
/* Wrapper around flex_main, so flex_main can be built as a library. */
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
#if ENABLE_NLS
#if HAVE_LOCALE_H
@@ -226,7 +222,7 @@ main(argc, argv)
/* check_options - check user-specified options */
void
-check_options()
+check_options(void)
{
int i;
@@ -473,9 +469,7 @@ check_options()
*/
void
-flexend(exit_status)
- int exit_status;
-
+flexend(int exit_status)
{
static int called_before = -1; /* prevent infinite recursion. */
int tblsiz;
@@ -904,9 +898,7 @@ flexend(exit_status)
/* flexinit - initialize flex */
void
-flexinit(argc, argv)
- int argc;
- char **argv;
+flexinit(int argc, char *argv[])
{
int i, sawcmpflag, rv, optind;
char *arg;
@@ -1427,7 +1419,7 @@ flexinit(argc, argv)
/* readin - read in the rules section of the input file(s) */
void
-readin()
+readin(void)
{
static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;";
static char yy_nostdinit[] =
@@ -1653,7 +1645,7 @@ readin()
/* set_up_initial_allocations - allocate memory for internal tables */
void
-set_up_initial_allocations()
+set_up_initial_allocations(void)
{
maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS);
current_mns = INITIAL_MNS;
@@ -1714,9 +1706,7 @@ set_up_initial_allocations()
/* extracts basename from path, optionally stripping the extension "\.*"
* (same concept as /bin/sh `basename`, but different handling of extension). */
static char *
-basename2(path, strip_ext)
- char *path;
- int strip_ext; /* boolean */
+basename2(char *path, int strip_ext)
{
char *b, *e = 0;
diff --git a/usr.bin/lex/misc.c b/usr.bin/lex/misc.c
index 4562beca3e5..1b6c7441c9e 100644
--- a/usr.bin/lex/misc.c
+++ b/usr.bin/lex/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.20 2022/12/26 19:16:01 jmc Exp $ */
+/* $OpenBSD: misc.c,v 1.21 2024/11/09 18:03:44 op Exp $ */
/* misc - miscellaneous flex routines */
@@ -95,9 +95,7 @@ sko_pop(bool * dc)
/* Append "#define defname value\n" to the running buffer. */
void
-action_define(defname, value)
- const char *defname;
- int value;
+action_define(const char *defname, int value)
{
char buf[MAXLINE];
char *cpy;
@@ -117,31 +115,9 @@ action_define(defname, value)
}
-/** Append "m4_define([[defname]],[[value]])m4_dnl\n" to the running buffer.
- * @param defname The macro name.
- * @param value The macro value, can be NULL, which is the same as the empty string.
- */
-void
-action_m4_define(const char *defname, const char *value)
-{
- char buf[MAXLINE];
-
- flexfatal("DO NOT USE THIS FUNCTION!");
-
- if ((int) strlen(defname) > MAXLINE / 2) {
- format_pinpoint_message(_
- ("name \"%s\" ridiculously long"),
- defname);
- return;
- }
- snprintf(buf, sizeof(buf), "m4_define([[%s]],[[%s]])m4_dnl\n", defname, value ? value : "");
- add_action(buf);
-}
-
/* Append "new_text" to the running buffer. */
void
-add_action(new_text)
- const char *new_text;
+add_action(const char *new_text)
{
int len = strlen(new_text);
@@ -172,9 +148,7 @@ add_action(new_text)
/* allocate_array - allocate memory for an integer array of the given size */
void *
-allocate_array(size, element_size)
- int size;
- size_t element_size;
+allocate_array(int size, size_t element_size)
{
void *mem;
size_t num_bytes = element_size * size;
@@ -191,8 +165,7 @@ allocate_array(size, element_size)
/* all_lower - true if a string is all lower-case */
int
-all_lower(str)
- char *str;
+all_lower(char *str)
{
while (*str) {
if (!isascii((u_char) * str) || !islower((u_char) * str))
@@ -207,8 +180,7 @@ all_lower(str)
/* all_upper - true if a string is all upper-case */
int
-all_upper(str)
- char *str;
+all_upper(char *str)
{
while (*str) {
if (!isascii((u_char) * str) || !isupper((u_char) * str))
@@ -235,8 +207,7 @@ intcmp(const void *a, const void *b)
*/
void
-check_char(c)
- int c;
+check_char(int c)
{
if (c >= CSIZE)
lerrsf(_("bad character '%s' detected in check_char()"),
@@ -253,8 +224,7 @@ check_char(c)
/* clower - replace upper-case letter to lower-case */
u_char
-clower(c)
- int c;
+clower(int c)
{
return (u_char) ((isascii(c) && isupper(c)) ? tolower(c) : c);
}
@@ -263,8 +233,7 @@ clower(c)
/* copy_string - returns a dynamically allocated copy of a string */
char *
-copy_string(str)
- const char *str;
+copy_string(const char *str)
{
const char *c1;
char *c2;
@@ -292,8 +261,7 @@ copy_string(str)
*/
u_char *
-copy_unsigned_string(str)
- u_char *str;
+copy_unsigned_string(unsigned char *str)
{
u_char *c;
u_char *copy;
@@ -326,7 +294,7 @@ cclcmp(const void *a, const void *b)
/* dataend - finish up a block of data declarations */
void
-dataend()
+dataend(void)
{
/* short circuit any output */
if (gentables) {
@@ -345,7 +313,7 @@ dataend()
/* dataflush - flush generated data statements */
void
-dataflush()
+dataflush(void)
{
/* short circuit any output */
if (!gentables)
@@ -369,8 +337,7 @@ dataflush()
/* flexerror - report an error message and terminate */
void
-flexerror(msg)
- const char *msg;
+flexerror(const char *msg)
{
fprintf(stderr, "%s: %s\n", program_name, msg);
flexend(1);
@@ -380,8 +347,7 @@ flexerror(msg)
/* flexfatal - report a fatal error message and terminate */
void
-flexfatal(msg)
- const char *msg;
+flexfatal(const char *msg)
{
fprintf(stderr, _("%s: fatal internal error, %s\n"),
program_name, msg);
@@ -392,8 +358,7 @@ flexfatal(msg)
/* htoi - convert a hexadecimal digit string to an integer value */
int
-htoi(str)
- u_char str[];
+htoi(unsigned char str[])
{
unsigned int result;
@@ -406,9 +371,7 @@ htoi(str)
/* lerrif - report an error message formatted with one integer argument */
void
-lerrif(msg, arg)
- const char *msg;
- int arg;
+lerrif(const char *msg, int arg)
{
char errmsg[MAXLINE];
@@ -420,8 +383,7 @@ lerrif(msg, arg)
/* lerrsf - report an error message formatted with one string argument */
void
-lerrsf(msg, arg)
- const char *msg, arg[];
+lerrsf(const char *msg, const char arg[])
{
char errmsg[MAXLINE];
@@ -434,8 +396,7 @@ lerrsf(msg, arg)
/* lerrsf_fatal - as lerrsf, but call flexfatal */
void
-lerrsf_fatal(msg, arg)
- const char *msg, arg[];
+lerrsf_fatal(const char *msg, const char arg[])
{
char errmsg[MAXLINE];
@@ -448,9 +409,7 @@ lerrsf_fatal(msg, arg)
/* line_directive_out - spit out a "#line" statement */
void
-line_directive_out(output_file, do_infile)
- FILE *output_file;
- int do_infile;
+line_directive_out(FILE *output_file, int do_infile)
{
char directive[MAXLINE], filename[MAXLINE];
char *s1, *s2, *s3;
@@ -499,7 +458,7 @@ line_directive_out(output_file, do_infile)
* and the prolog begins
*/
void
-mark_defs1()
+mark_defs1(void)
{
defs1_offset = 0;
action_array[action_index++] = '\0';
@@ -512,7 +471,7 @@ mark_defs1()
* representing the end of the action prolog
*/
void
-mark_prolog()
+mark_prolog(void)
{
action_array[action_index++] = '\0';
action_offset = action_index;
@@ -525,8 +484,7 @@ mark_prolog()
* Generates a data statement initializing the current 2-D array to "value".
*/
void
-mk2data(value)
- int value;
+mk2data(int value)
{
/* short circuit any output */
if (!gentables)
@@ -555,8 +513,7 @@ mk2data(value)
* "value".
*/
void
-mkdata(value)
- int value;
+mkdata(int value)
{
/* short circuit any output */
if (!gentables)
@@ -581,8 +538,7 @@ mkdata(value)
/* myctoi - return the integer represented by a string of digits */
int
-myctoi(array)
- const char *array;
+myctoi(const char *array)
{
int val = 0;
@@ -595,8 +551,7 @@ myctoi(array)
/* myesc - return character corresponding to escape sequence */
u_char
-myesc(array)
- u_char array[];
+myesc(unsigned char array[])
{
u_char c, esc_char;
@@ -686,8 +641,7 @@ myesc(array)
/* otoi - convert an octal digit string to an integer value */
int
-otoi(str)
- u_char str[];
+otoi(unsigned char str[])
{
unsigned int result;
@@ -701,68 +655,55 @@ otoi(str)
*/
void
-out(str)
- const char *str;
+out(const char *str)
{
fputs(str, stdout);
}
void
-out_dec(fmt, n)
- const char *fmt;
- int n;
+out_dec(const char *fmt, int n)
{
fprintf(stdout, fmt, n);
}
void
-out_dec2(fmt, n1, n2)
- const char *fmt;
- int n1, n2;
+out_dec2(const char *fmt, int n1, int n2)
{
fprintf(stdout, fmt, n1, n2);
}
void
-out_hex(fmt, x)
- const char *fmt;
- unsigned int x;
+out_hex(const char *fmt, unsigned int x)
{
fprintf(stdout, fmt, x);
}
void
-out_str(fmt, str)
- const char *fmt, str[];
+out_str(const char *fmt, const char str[])
{
fprintf(stdout, fmt, str);
}
void
-out_str3(fmt, s1, s2, s3)
- const char *fmt, s1[], s2[], s3[];
+out_str3(const char *fmt, const char s1[], const char s2[], const char s3[])
{
fprintf(stdout, fmt, s1, s2, s3);
}
void
-out_str_dec(fmt, str, n)
- const char *fmt, str[];
- int n;
+out_str_dec(const char *fmt, const char str[], int n)
{
fprintf(stdout, fmt, str, n);
}
void
-outc(c)
- int c;
+outc(int c)
{
fputc(c, stdout);
}
void
-outn(str)
- const char *str;
+outn(const char *str)
{
fputs(str, stdout);
fputc('\n', stdout);
@@ -787,8 +728,7 @@ out_m4_define(const char *def, const char *val)
*/
char *
-readable_form(c)
- int c;
+readable_form(int c)
{
static char rform[10];
@@ -831,10 +771,7 @@ readable_form(c)
/* reallocate_array - increase the size of a dynamic array */
void *
-reallocate_array(array, size, element_size)
- void *array;
- int size;
- size_t element_size;
+reallocate_array(void *array, int size, size_t element_size)
{
void *new_array;
size_t num_bytes = element_size * size;
@@ -854,7 +791,7 @@ reallocate_array(array, size, element_size)
* "%%" or EOF is found.
*/
void
-skelout()
+skelout(void)
{
char buf_storage[MAXLINE];
char *buf = buf_storage;
@@ -969,8 +906,7 @@ skelout()
*/
void
-transition_struct_out(element_v, element_n)
- int element_v, element_n;
+transition_struct_out(int element_v, int element_n)
{
/* short circuit any output */
@@ -996,8 +932,7 @@ transition_struct_out(element_v, element_n)
* broken versions of bison.
*/
void *
-yy_flex_xmalloc(size)
- int size;
+yy_flex_xmalloc(int size)
{
void *result = malloc((size_t) size);
@@ -1013,8 +948,7 @@ yy_flex_xmalloc(size)
* str can be any null-terminated string, or NULL.
* returns str. */
char *
-chomp(str)
- char *str;
+chomp(char *str)
{
char *p = str;
diff --git a/usr.bin/lex/nfa.c b/usr.bin/lex/nfa.c
index 272febfc69e..07c1999418e 100644
--- a/usr.bin/lex/nfa.c
+++ b/usr.bin/lex/nfa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfa.c,v 1.11 2015/11/19 22:52:40 tedu Exp $ */
+/* $OpenBSD: nfa.c,v 1.12 2024/11/09 18:03:44 op Exp $ */
/* nfa - NFA construction routines */
@@ -48,8 +48,7 @@ void mkxtion PROTO((int, int));
*/
void
-add_accept(mach, accepting_number)
- int mach, accepting_number;
+add_accept(int mach, int accepting_number)
{
/*
* Hang the accepting number off an epsilon state. if it is
@@ -82,8 +81,7 @@ add_accept(mach, accepting_number)
*/
int
-copysingl(singl, num)
- int singl, num;
+copysingl(int singl, int num)
{
int copy, i;
@@ -99,9 +97,7 @@ copysingl(singl, num)
/* dumpnfa - debugging routine to write out an nfa */
void
-dumpnfa(state1)
- int state1;
-
+dumpnfa(int state1)
{
int sym, tsp1, tsp2, anum, ns;
@@ -156,8 +152,7 @@ dumpnfa(state1)
*/
int
-dupmachine(mach)
- int mach;
+dupmachine(int mach)
{
int i, init, state_offset;
int state = 0;
@@ -204,9 +199,8 @@ dupmachine(mach)
*/
void
-finish_rule(mach, variable_trail_rule, headcnt, trailcnt,
- pcont_act)
- int mach, variable_trail_rule, headcnt, trailcnt, pcont_act;
+finish_rule(int mach, int variable_trail_rule, int headcnt, int trailcnt,
+ int pcont_act)
{
char action_text[MAXLINE];
@@ -319,8 +313,7 @@ finish_rule(mach, variable_trail_rule, headcnt, trailcnt,
*/
int
-link_machines(first, last)
- int first, last;
+link_machines(int first, int last)
{
if (first == NIL)
return last;
@@ -347,8 +340,7 @@ link_machines(first, last)
*/
void
-mark_beginning_as_normal(mach)
- int mach;
+mark_beginning_as_normal(int mach)
{
switch (state_type[mach]) {
case STATE_NORMAL:
@@ -390,8 +382,7 @@ mark_beginning_as_normal(mach)
*/
int
-mkbranch(first, second)
- int first, second;
+mkbranch(int first, int second)
{
int eps;
@@ -419,8 +410,7 @@ mkbranch(first, second)
*/
int
-mkclos(state)
- int state;
+mkclos(int state)
{
return mkopt(mkposcl(state));
}
@@ -441,8 +431,7 @@ mkclos(state)
*/
int
-mkopt(mach)
- int mach;
+mkopt(int mach)
{
int eps;
@@ -479,8 +468,7 @@ mkopt(mach)
*/
int
-mkor(first, second)
- int first, second;
+mkor(int first, int second)
{
int eps, orend;
@@ -534,8 +522,7 @@ mkor(first, second)
*/
int
-mkposcl(state)
- int state;
+mkposcl(int state)
{
int eps;
@@ -563,8 +550,7 @@ mkposcl(state)
*/
int
-mkrep(mach, lb, ub)
- int mach, lb, ub;
+mkrep(int mach, int lb, int ub)
{
int base_mach, tail, copy, i;
@@ -609,8 +595,7 @@ mkrep(mach, lb, ub)
*/
int
-mkstate(sym)
- int sym;
+mkstate(int sym)
{
if (++lastnfa >= current_mns) {
if ((current_mns += MNS_INCREMENT) >= maximum_mns)
@@ -686,8 +671,7 @@ mkstate(sym)
*/
void
-mkxtion(statefrom, stateto)
- int statefrom, stateto;
+mkxtion(int statefrom, int stateto)
{
if (trans1[statefrom] == NO_TRANSITION)
trans1[statefrom] = stateto;
@@ -705,7 +689,7 @@ mkxtion(statefrom, stateto)
/* new_rule - initialize for a new rule */
void
-new_rule()
+new_rule(void)
{
if (++num_rules >= current_max_rules) {
++num_reallocs;
diff --git a/usr.bin/lex/parse.y b/usr.bin/lex/parse.y
index 26a9809a661..dce6be8c934 100644
--- a/usr.bin/lex/parse.y
+++ b/usr.bin/lex/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.10 2017/04/12 14:53:27 millert Exp $ */
+/* $OpenBSD: parse.y,v 1.11 2024/11/09 18:03:44 op Exp $ */
/* parse.y - parser for flex input */
@@ -950,7 +950,7 @@ string : string CHAR
* conditions
*/
-void build_eof_action()
+void build_eof_action(void)
{
int i;
char action_text[MAXLINE];
@@ -989,8 +989,7 @@ void build_eof_action()
/* format_synerr - write out formatted syntax error */
-void format_synerr( msg, arg )
-const char *msg, arg[];
+void format_synerr(const char *msg, const char arg[])
{
char errmsg[MAXLINE];
@@ -1001,8 +1000,7 @@ const char *msg, arg[];
/* synerr - report a syntax error */
-void synerr( str )
-const char *str;
+void synerr(const char *str)
{
syntaxerror = true;
pinpoint_message( str );
@@ -1011,8 +1009,7 @@ const char *str;
/* format_warn - write out formatted warning */
-void format_warn( msg, arg )
-const char *msg, arg[];
+void format_warn(const char *msg, const char arg[])
{
char warn_msg[MAXLINE];
@@ -1023,8 +1020,7 @@ const char *msg, arg[];
/* warn - report a warning, unless -w was given */
-void warn( str )
-const char *str;
+void warn(const char *str)
{
line_warning( str, linenum );
}
@@ -1033,8 +1029,7 @@ const char *str;
* pinpointing its location
*/
-void format_pinpoint_message( msg, arg )
-const char *msg, arg[];
+void format_pinpoint_message(const char *msg, const char arg[])
{
char errmsg[MAXLINE];
@@ -1045,8 +1040,7 @@ const char *msg, arg[];
/* pinpoint_message - write out a message, pinpointing its location */
-void pinpoint_message( str )
-const char *str;
+void pinpoint_message(const char *str)
{
line_pinpoint( str, linenum );
}
@@ -1054,9 +1048,7 @@ const char *str;
/* line_warning - report a warning at a given line, unless -w was given */
-void line_warning( str, line )
-const char *str;
-int line;
+void line_warning(const char *str, int line)
{
char warning[MAXLINE];
@@ -1070,9 +1062,7 @@ int line;
/* line_pinpoint - write out a message, pinpointing it at the given line */
-void line_pinpoint( str, line )
-const char *str;
-int line;
+void line_pinpoint(const char *str, int line)
{
fprintf( stderr, "%s:%d: %s\n", infilename, line, str );
}
@@ -1082,7 +1072,6 @@ int line;
* currently, messages are ignore
*/
-void yyerror( msg )
-const char *msg;
+void yyerror(const char *msg)
{
}
diff --git a/usr.bin/lex/scan.l b/usr.bin/lex/scan.l
index 09561eddbf1..a2c8013af96 100644
--- a/usr.bin/lex/scan.l
+++ b/usr.bin/lex/scan.l
@@ -1,4 +1,4 @@
-/* $OpenBSD: scan.l,v 1.13 2019/09/22 00:47:12 miko Exp $ */
+/* $OpenBSD: scan.l,v 1.14 2024/11/09 18:03:44 op Exp $ */
/* scan.l - scanner for flex input -*-C-*- */
@@ -61,7 +61,7 @@ extern const char *escaped_qstart, *escaped_qend;
#define MARK_END_OF_PROLOG mark_prolog();
#define YY_DECL \
- int flexscan()
+ int flexscan(void)
#define RETURNCHAR \
yylval = (unsigned char) yytext[0]; \
@@ -977,8 +977,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
%%
-
-int yywrap()
+int yywrap(void)
{
if ( --num_input_files > 0 )
{
@@ -993,8 +992,7 @@ int yywrap()
/* set_input_file - open the given file (if NULL, stdin) for scanning */
-void set_input_file( file )
-char *file;
+void set_input_file(const char *file)
{
if ( file && strcmp( file, "-" ) )
{
diff --git a/usr.bin/lex/scanopt.c b/usr.bin/lex/scanopt.c
index f4de1fd29b0..d00ded0833c 100644
--- a/usr.bin/lex/scanopt.c
+++ b/usr.bin/lex/scanopt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scanopt.c,v 1.6 2017/05/31 07:20:26 tedu Exp $ */
+/* $OpenBSD: scanopt.c,v 1.7 2024/11/09 18:03:44 op Exp $ */
/* flex - tool to generate fast lexical analyzers */
@@ -44,9 +44,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 ((u_char)*a++) == tolower ((u_char)*b++)) ;
return b - a;
@@ -89,38 +87,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 : "";
}
@@ -128,7 +116,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 */
@@ -161,11 +149,8 @@ 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;
@@ -257,10 +242,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;
@@ -531,18 +513,11 @@ int scanopt_usage (scanner, fp, usage)
#endif /* no scanopt_usage */
-static int scanopt_err (s, opt_offset, is_short, err)
- struct _scanopt_t *s;
- int opt_offset;
- int is_short;
- int err;
+static int scanopt_err (struct _scanopt_t *s, int opt_offset,
+ int is_short, int err)
{
const char *optname = "";
char optchar[2];
- const optspec_t *opt = NULL;
-
- if (opt_offset >= 0)
- opt = s->options + opt_offset;
if (!s->no_err_msg) {
@@ -594,12 +569,8 @@ static int scanopt_err (s, opt_offset, 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;
@@ -641,13 +612,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;
@@ -706,10 +672,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;
@@ -857,8 +820,7 @@ int scanopt (svoid, arg, optindex)
}
-void scanopt_destroy (svoid)
- scanopt_t *svoid;
+void scanopt_destroy (scanopt_t *svoid)
{
struct _scanopt_t *s;
diff --git a/usr.bin/lex/sym.c b/usr.bin/lex/sym.c
index a201432d903..7df87492ae5 100644
--- a/usr.bin/lex/sym.c
+++ b/usr.bin/lex/sym.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sym.c,v 1.9 2015/11/19 23:34:56 mmcc Exp $ */
+/* $OpenBSD: sym.c,v 1.10 2024/11/09 18:03:44 op Exp $ */
/* sym - symbol table routines */
@@ -74,12 +74,8 @@ static int hashfunct PROTO ((const char *, int));
* -1 is returned if the symbol already exists, and the change not made.
*/
-static int addsym (sym, str_def, int_def, table, table_size)
- char sym[];
- char *str_def;
- int int_def;
- hash_table table;
- int table_size;
+static int addsym (char sym[], char *str_def, int int_def, hash_table table,
+ int table_size)
{
int hash_val = hashfunct (sym, table_size);
struct hash_entry *sym_entry = table[hash_val];
@@ -121,9 +117,7 @@ static int addsym (sym, str_def, int_def, table, table_size)
/* cclinstal - save the text of a character class */
-void cclinstal (ccltxt, cclnum)
- u_char ccltxt[];
- int cclnum;
+void cclinstal (unsigned char ccltxt[], int cclnum)
{
/* We don't bother checking the return status because we are not
* called unless the symbol is new.
@@ -139,8 +133,7 @@ void cclinstal (ccltxt, cclnum)
* Returns 0 if there's no CCL associated with the text.
*/
-int ccllookup (ccltxt)
- u_char ccltxt[];
+int ccllookup (unsigned char ccltxt[])
{
return findsym ((char *) ccltxt, ccltab, CCL_HASH_SIZE)->int_val;
}
@@ -148,10 +141,8 @@ int ccllookup (ccltxt)
/* findsym - find symbol in symbol table */
-static struct hash_entry *findsym (sym, table, table_size)
- const char *sym;
- hash_table table;
- int table_size;
+static struct hash_entry *findsym (const char *sym, hash_table table,
+ int table_size)
{
static struct hash_entry empty_entry = {
(struct hash_entry *) 0, (struct hash_entry *) 0,
@@ -172,9 +163,7 @@ static struct hash_entry *findsym (sym, table, table_size)
/* hashfunct - compute the hash value for "str" and hash size "hash_size" */
-static int hashfunct (str, hash_size)
- const char *str;
- int hash_size;
+static int hashfunct (const char *str, int hash_size)
{
int hashval;
int locstr;
@@ -193,11 +182,8 @@ static int hashfunct (str, hash_size)
/* ndinstal - install a name definition */
-void ndinstal (name, definition)
- const char *name;
- u_char definition[];
+void ndinstal (const char *name, unsigned char definition[])
{
-
if (addsym (copy_string (name),
(char *) copy_unsigned_string (definition), 0,
ndtbl, NAME_TABLE_HASH_SIZE))
@@ -210,8 +196,7 @@ void ndinstal (name, definition)
* Returns a nil pointer if the name definition does not exist.
*/
-u_char *ndlookup (nd)
- const char *nd;
+u_char *ndlookup (const char *nd)
{
return (u_char *) findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val;
}
@@ -219,7 +204,7 @@ u_char *ndlookup (nd)
/* scextend - increase the maximum number of start conditions */
-void scextend ()
+void scextend (void)
{
current_max_scs += MAX_SCS_INCREMENT;
@@ -239,11 +224,8 @@ void scextend ()
* The start condition is "exclusive" if xcluflg is true.
*/
-void scinstal (str, xcluflg)
- const char *str;
- int xcluflg;
+void scinstal (const char *str, int xcluflg)
{
-
if (++lastsc >= current_max_scs)
scextend ();
@@ -267,8 +249,7 @@ str);
* Returns 0 if no such start condition.
*/
-int sclookup (str)
- const char *str;
+int sclookup (const char *str)
{
return findsym (str, sctbl, START_COND_HASH_SIZE)->int_val;
}
diff --git a/usr.bin/lex/tblcmp.c b/usr.bin/lex/tblcmp.c
index 0792ee8d746..ca1447c5e1b 100644
--- a/usr.bin/lex/tblcmp.c
+++ b/usr.bin/lex/tblcmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tblcmp.c,v 1.11 2022/12/26 19:16:01 jmc Exp $ */
+/* $OpenBSD: tblcmp.c,v 1.12 2024/11/09 18:03:44 op Exp $ */
/* tblcmp - table compression routines */
@@ -81,8 +81,7 @@ int tbldiff PROTO((int[], int, int[]));
*/
void
-bldtbl(state, statenum, totaltrans, comstate, comfreq)
- int state[], statenum, totaltrans, comstate, comfreq;
+bldtbl(int state[], int statenum, int totaltrans, int comstate, int comfreq)
{
int extptr, extrct[2][CSIZE + 1];
int mindiff, minprot, i, d;
@@ -231,7 +230,7 @@ bldtbl(state, statenum, totaltrans, comstate, comfreq)
*/
void
-cmptmps()
+cmptmps(void)
{
int tmpstorage[CSIZE + 1];
int *tmp = tmpstorage, i, j;
@@ -299,7 +298,7 @@ cmptmps()
/* expand_nxt_chk - expand the next check arrays */
void
-expand_nxt_chk()
+expand_nxt_chk(void)
{
int old_max = current_max_xpairs;
@@ -334,8 +333,7 @@ expand_nxt_chk()
*/
int
-find_table_space(state, numtrans)
- int *state, numtrans;
+find_table_space(int *state, int numtrans)
{
/*
* Firstfree is the position of the first possible occurrence of two
@@ -435,7 +433,7 @@ find_table_space(state, numtrans)
* all "chk" entries to be zero.
*/
void
-inittbl()
+inittbl(void)
{
int i;
@@ -467,7 +465,7 @@ inittbl()
/* mkdeftbl - make the default, "jam" table entries */
void
-mkdeftbl()
+mkdeftbl(void)
{
int i;
@@ -518,9 +516,7 @@ mkdeftbl()
*/
void
-mkentry(state, numchars, statenum, deflink, totaltrans)
- int *state;
- int numchars, statenum, deflink, totaltrans;
+mkentry(int *state, int numchars, int statenum, int deflink, int totaltrans)
{
int minec, maxec, i, baseaddr;
int tblbase, tbllast;
@@ -636,8 +632,7 @@ mkentry(state, numchars, statenum, deflink, totaltrans)
*/
void
-mk1tbl(state, sym, onenxt, onedef)
- int state, sym, onenxt, onedef;
+mk1tbl(int state, int sym, int onenxt, int onedef)
{
if (firstfree < sym)
firstfree = sym;
@@ -663,8 +658,7 @@ mk1tbl(state, sym, onenxt, onedef)
/* mkprot - create new proto entry */
void
-mkprot(state, statenum, comstate)
- int state[], statenum, comstate;
+mkprot(int state[], int statenum, int comstate)
{
int i, slot, tblbase;
@@ -701,8 +695,7 @@ mkprot(state, statenum, comstate)
*/
void
-mktemplate(state, statenum, comstate)
- int state[], statenum, comstate;
+mktemplate(int state[], int statenum, int comstate)
{
int i, numdiff, tmpbase, tmp[CSIZE + 1];
u_char transset[CSIZE + 1];
@@ -755,8 +748,7 @@ mktemplate(state, statenum, comstate)
/* mv2front - move proto queue element to front of queue */
void
-mv2front(qelm)
- int qelm;
+mv2front(int qelm)
{
if (firstprot != qelm) {
if (qelm == lastprot)
@@ -783,8 +775,7 @@ mv2front(qelm)
*/
void
-place_state(state, statenum, transnum)
- int *state, statenum, transnum;
+place_state(int *state, int statenum, int transnum)
{
int i;
int *state_ptr;
@@ -828,8 +819,7 @@ place_state(state, statenum, transnum)
*/
void
-stack1(statenum, sym, nextstate, deflink)
- int statenum, sym, nextstate, deflink;
+stack1(int statenum, int sym, int nextstate, int deflink)
{
if (onesp >= ONE_STACK_SIZE - 1)
mk1tbl(statenum, sym, nextstate, deflink);
@@ -859,8 +849,7 @@ stack1(statenum, sym, nextstate, deflink)
*/
int
-tbldiff(state, pr, ext)
- int state[], pr, ext[];
+tbldiff(int state[], int pr, int ext[])
{
int i, *sp = state, *ep = ext, *protp;
int numdiff = 0;
diff --git a/usr.bin/lex/yylex.c b/usr.bin/lex/yylex.c
index e50dea258de..efdc699eb13 100644
--- a/usr.bin/lex/yylex.c
+++ b/usr.bin/lex/yylex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yylex.c,v 1.6 2015/11/19 19:43:40 tedu Exp $ */
+/* $OpenBSD: yylex.c,v 1.7 2024/11/09 18:03:44 op Exp $ */
/* yylex - scanner front-end for flex */
@@ -40,7 +40,7 @@
/* yylex - scan for a regular expression token */
-int yylex ()
+int yylex (void)
{
int toktype;
static int beglin = false;