diff options
author | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-05-14 11:16:04 -0700 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2015-11-19 19:26:07 -0500 |
commit | 0f7b9136ed566f4a79b2d6ca33299babcce3049e (patch) | |
tree | 4d7e50ccc92c0917ec491c23aadaf93b5b0c5047 /src/misc.c | |
parent | 09eae589d3954a1e1206aa01108ee75ef57776da (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/misc.c')
-rw-r--r-- | src/misc.c | 119 |
1 files changed, 39 insertions, 80 deletions
@@ -90,9 +90,7 @@ static void sko_pop(bool* dc) } /* Append "#define defname value\n" to the running buffer. */ -void action_define (defname, value) - const char *defname; - int value; +void action_define (const char *defname, int value) { char buf[MAXLINE]; char *cpy; @@ -137,8 +135,7 @@ static void action_m4_define (const char *defname, const char * value) #endif /* Append "new_text" to the running buffer. */ -void add_action (new_text) - const char *new_text; +void add_action (const char *new_text) { int len = strlen (new_text); @@ -166,9 +163,7 @@ void 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; +void *allocate_array (int size, size_t element_size) { void *mem; size_t num_bytes = element_size * size; @@ -184,8 +179,7 @@ void *allocate_array (size, element_size) /* all_lower - true if a string is all lower-case */ -int all_lower (str) - char *str; +int all_lower (char *str) { while (*str) { if (!isascii ((Char) * str) || !islower ((Char) * str)) @@ -199,8 +193,7 @@ int all_lower (str) /* all_upper - true if a string is all upper-case */ -int all_upper (str) - char *str; +int all_upper (char *str) { while (*str) { if (!isascii ((Char) * str) || !isupper ((Char) * str)) @@ -225,8 +218,7 @@ int intcmp (const void *a, const void *b) * and exits. */ -void check_char (c) - int c; +void check_char (int c) { if (c >= CSIZE) lerr (_("bad character '%s' detected in check_char()"), @@ -242,8 +234,7 @@ void check_char (c) /* clower - replace upper-case letter to lower-case */ -Char clower (c) - int c; +Char clower (int c) { return (Char) ((isascii (c) && isupper (c)) ? tolower (c) : c); } @@ -251,8 +242,7 @@ Char clower (c) /* copy_string - returns a dynamically allocated copy of a string */ -char *copy_string (str) - const char *str; +char *copy_string (const char *str) { const char *c1; char *c2; @@ -279,8 +269,7 @@ char *copy_string (str) * returns a dynamically allocated copy of a (potentially) unsigned string */ -Char *copy_unsigned_string (str) - Char *str; +Char *copy_unsigned_string (Char *str) { Char *c; Char *copy; @@ -312,7 +301,7 @@ int cclcmp (const void *a, const void *b) /* dataend - finish up a block of data declarations */ -void dataend () +void dataend (void) { /* short circuit any output */ if (gentables) { @@ -330,7 +319,7 @@ void dataend () /* dataflush - flush generated data statements */ -void dataflush () +void dataflush (void) { /* short circuit any output */ if (!gentables) @@ -353,8 +342,7 @@ void dataflush () /* flexerror - report an error message and terminate */ -void flexerror (msg) - const char *msg; +void flexerror (const char *msg) { fprintf (stderr, "%s: %s\n", program_name, msg); flexend (1); @@ -363,8 +351,7 @@ void flexerror (msg) /* flexfatal - report a fatal error message and terminate */ -void flexfatal (msg) - const char *msg; +void flexfatal (const char *msg) { fprintf (stderr, _("%s: fatal internal error, %s\n"), program_name, msg); @@ -374,8 +361,7 @@ void flexfatal (msg) /* htoi - convert a hexadecimal digit string to an integer value */ -int htoi (str) - Char str[]; +int htoi (Char str[]) { unsigned int result; @@ -387,7 +373,8 @@ int htoi (str) /* lerr - report an error message */ -void lerr (const char *msg, ...) { +void lerr (const char *msg, ...) +{ char errmsg[MAXLINE]; va_list args; @@ -414,9 +401,7 @@ void lerr_fatal (const char *msg, ...) /* line_directive_out - spit out a "#line" statement */ -void line_directive_out (output_file, do_infile) - FILE *output_file; - int do_infile; +void line_directive_out (FILE *output_file, int do_infile) { char directive[MAXLINE], filename[MAXLINE]; char *s1, *s2, *s3; @@ -464,7 +449,7 @@ void line_directive_out (output_file, do_infile) * representing where the user's section 1 definitions end * and the prolog begins */ -void mark_defs1 () +void mark_defs1 (void) { defs1_offset = 0; action_array[action_index++] = '\0'; @@ -476,7 +461,7 @@ void mark_defs1 () /* mark_prolog - mark the current position in the action array as * representing the end of the action prolog */ -void mark_prolog () +void mark_prolog (void) { action_array[action_index++] = '\0'; action_offset = action_index; @@ -488,8 +473,7 @@ void mark_prolog () * * Generates a data statement initializing the current 2-D array to "value". */ -void mk2data (value) - int value; +void mk2data (int value) { /* short circuit any output */ if (!gentables) @@ -518,8 +502,7 @@ void mk2data (value) * Generates a data statement initializing the current array element to * "value". */ -void mkdata (value) - int value; +void mkdata (int value) { /* short circuit any output */ if (!gentables) @@ -544,8 +527,7 @@ void mkdata (value) /* myctoi - return the integer represented by a string of digits */ -int myctoi (array) - const char *array; +int myctoi (const char *array) { int val = 0; @@ -557,8 +539,7 @@ int myctoi (array) /* myesc - return character corresponding to escape sequence */ -Char myesc (array) - Char array[]; +Char myesc (Char array[]) { Char c, esc_char; @@ -645,8 +626,7 @@ Char myesc (array) /* otoi - convert an octal digit string to an integer value */ -int otoi (str) - Char str[]; +int otoi (Char str[]) { unsigned int result; @@ -659,60 +639,47 @@ int otoi (str) * generated scanner, keeping track of the line count. */ -void out (str) - const char *str; +void out (const char *str) { fputs (str, stdout); } -void out_dec (fmt, n) - const char *fmt; - int n; +void out_dec (const char *fmt, int n) { fprintf (stdout, fmt, n); } -void out_dec2 (fmt, n1, n2) - const char *fmt; - int n1, n2; +void 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; +void out_hex (const char *fmt, unsigned int x) { fprintf (stdout, fmt, x); } -void out_str (fmt, str) - const char *fmt, str[]; +void 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[]; +void 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; +void out_str_dec (const char *fmt, const char str[], int n) { fprintf (stdout,fmt, str, n); } -void outc (c) - int c; +void outc (int c) { fputc (c, stdout); } -void outn (str) - const char *str; +void outn (const char *str) { fputs (str,stdout); fputc('\n',stdout); @@ -734,8 +701,7 @@ void out_m4_define (const char* def, const char* val) * The returned string is in static storage. */ -char *readable_form (c) - int c; +char *readable_form (int c) { static char rform[20]; @@ -782,10 +748,7 @@ char *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; +void *reallocate_array (void *array, int size, size_t element_size) { void *new_array; size_t num_bytes = element_size * size; @@ -804,7 +767,7 @@ void *reallocate_array (array, size, element_size) * Copies skelfile or skel array to stdout until a line beginning with * "%%" or EOF is found. */ -void skelout () +void skelout (void) { char buf_storage[MAXLINE]; char *buf = buf_storage; @@ -961,8 +924,7 @@ void transition_struct_out (element_v, element_n) /* The following is only needed when building flex's parser using certain * broken versions of bison. */ -void *yy_flex_xmalloc (size) - int size; +void *yy_flex_xmalloc (int size) { void *result = flex_alloc ((size_t) size); @@ -979,9 +941,7 @@ void *yy_flex_xmalloc (size) * Sets region_ptr[0] through region_ptr[size_in_bytes - 1] to zero. */ -void zero_out (region_ptr, size_in_bytes) - char *region_ptr; - size_t size_in_bytes; +void zero_out (char *region_ptr, size_t size_in_bytes) { char *rp, *rp_end; @@ -995,8 +955,7 @@ void zero_out (region_ptr, size_in_bytes) /* Remove all '\n' and '\r' characters, if any, from the end of str. * str can be any null-terminated string, or NULL. * returns str. */ -char *chomp (str) - char *str; +char *chomp (char *str) { char *p = str; |