diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2012-03-16 09:19:14 +0100 |
---|---|---|
committer | Paolo Bonzini <bonzini@gnu.org> | 2012-03-16 10:14:54 +0100 |
commit | e4536dbf6150557a817628429f61232959248723 (patch) | |
tree | ef3801fdc7395bcfb122ea5bfef977a7b57e02ab | |
parent | 54da30b4fcfe45e52416bdf0779d2afa0ed8b129 (diff) | |
download | sed-e4536dbf6150557a817628429f61232959248723.tar.gz |
switch to the wonderful world of function prototypes
2012-03-16 Paolo Bonzini <bonzini@gnu.org>
* basicdefs.h (P_): Remove.
* sed/compile.c: Adjust.
* sed/execute.c: Likewise.
* sed/fmt.c: Likewise.
* sed/sed.c: Likewise.
* sed/sed.h: Likewise.
* sed/utils.c: Likewise.
* sed/utils.h: Likewise.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | basicdefs.h | 7 | ||||
-rw-r--r-- | sed/compile.c | 45 | ||||
-rw-r--r-- | sed/execute.c | 78 | ||||
-rw-r--r-- | sed/fmt.c | 28 | ||||
-rw-r--r-- | sed/sed.c | 4 | ||||
-rw-r--r-- | sed/sed.h | 35 | ||||
-rw-r--r-- | sed/utils.c | 6 | ||||
-rw-r--r-- | sed/utils.h | 52 |
9 files changed, 128 insertions, 138 deletions
@@ -1,3 +1,14 @@ +2012-03-16 Paolo Bonzini <bonzini@gnu.org> + + * basicdefs.h (P_): Remove. + * sed/compile.c: Adjust. + * sed/execute.c: Likewise. + * sed/fmt.c: Likewise. + * sed/sed.c: Likewise. + * sed/sed.h: Likewise. + * sed/utils.c: Likewise. + * sed/utils.h: Likewise. + 2011-05-27 Paolo Bonzini <bonzini@gnu.org> * sed/execute.c (append_replacement, do_subst): Further diff --git a/basicdefs.h b/basicdefs.h index 0cd47b8..0d28a97 100644 --- a/basicdefs.h +++ b/basicdefs.h @@ -31,13 +31,6 @@ /* type countT is used to keep track of line numbers, etc. */ typedef unsigned long countT; -/* Can the compiler grok function prototypes? */ -#if (defined __STDC__ && __STDC__-0) || defined __GNUC__ || defined __SUNPRO_C || __PROTOTYPES -# define P_(s) s -#else -# define P_(s) () -#endif - /* some basic definitions to avoid undue promulgating of ugliness */ #define MALLOC(n,t) ((t *)ck_malloc((n)*sizeof(t))) #define REALLOC(x,n,t) ((t *)ck_realloc((void *)(x),(n)*sizeof(t))) diff --git a/sed/compile.c b/sed/compile.c index a37d411..21b3464 100644 --- a/sed/compile.c +++ b/sed/compile.c @@ -204,7 +204,7 @@ bad_prog(why) /* Read the next character from the program. Return EOF if there isn't anything to read. Keep cur_input.line up to date, so error messages can be meaningful. */ -static int inchar P_((void)); +static int inchar (void); static int inchar() { @@ -226,7 +226,7 @@ inchar() } /* unget `ch' so the next call to inchar will return it. */ -static void savchar P_((int ch)); +static void savchar (int ch); static void savchar(ch) int ch; @@ -246,7 +246,7 @@ savchar(ch) } /* Read the next non-blank character from the program. */ -static int in_nonblank P_((void)); +static int in_nonblank (void); static int in_nonblank() { @@ -258,7 +258,7 @@ in_nonblank() } /* Read an integer value from the program. */ -static countT in_integer P_((int ch)); +static countT in_integer (int ch); static countT in_integer(ch) int ch; @@ -274,7 +274,7 @@ in_integer(ch) return num; } -static int add_then_next P_((struct buffer *b, int ch)); +static int add_then_next (struct buffer *b, int ch); static int add_then_next(b, ch) struct buffer *b; @@ -284,7 +284,7 @@ add_then_next(b, ch) return inchar(); } -static char * convert_number P_((char *, char *, const char *, int, int, int)); +static char * convert_number (char *, char *, const char *, int, int, int); static char * convert_number(result, buf, bufend, base, maxdigits, default_char) char *result; @@ -332,7 +332,7 @@ convert_number(result, buf, bufend, base, maxdigits, default_char) /* Read in a filename for a `r', `w', or `s///w' command. */ -static struct buffer *read_filename P_((void)); +static struct buffer *read_filename (void); static struct buffer * read_filename() { @@ -357,7 +357,7 @@ read_filename() return b; } -static struct output *get_openfile P_((struct output **file_ptrs, const char *mode, int fail)); +static struct output *get_openfile (struct output **file_ptrs, const char *mode, int fail); static struct output * get_openfile(file_ptrs, mode, fail) struct output **file_ptrs; @@ -405,7 +405,7 @@ get_openfile(file_ptrs, mode, fail) } -static struct sed_cmd *next_cmd_entry P_((struct vector **vectorp)); +static struct sed_cmd *next_cmd_entry (struct vector **vectorp); static struct sed_cmd * next_cmd_entry(vectorp) struct vector **vectorp; @@ -431,7 +431,7 @@ next_cmd_entry(vectorp) return cmd; } -static int snarf_char_class P_((struct buffer *b, mbstate_t *cur_stat)); +static int snarf_char_class (struct buffer *b, mbstate_t *cur_stat); static int snarf_char_class(b, cur_stat) struct buffer *b; @@ -512,7 +512,7 @@ snarf_char_class(b, cur_stat) } } -static struct buffer *match_slash P_((int slash, int regex)); +static struct buffer *match_slash (int slash, int regex); static struct buffer * match_slash(slash, regex) int slash; @@ -568,7 +568,7 @@ match_slash(slash, regex) return NULL; } -static int mark_subst_opts P_((struct subst *cmd)); +static int mark_subst_opts (struct subst *cmd); static int mark_subst_opts(cmd) struct subst *cmd; @@ -668,7 +668,7 @@ mark_subst_opts(cmd) /* read in a label for a `:', `b', or `t' command */ -static char *read_label P_((void)); +static char *read_label (void); static char * read_label() { @@ -695,7 +695,7 @@ read_label() compilation is complete, or a reference created by a `{' to be backpatched when the corresponding `}' is found. */ static struct sed_label *setup_label - P_((struct sed_label *, countT, char *, const struct error_info *)); + (struct sed_label *, countT, char *, const struct error_info *); static struct sed_label * setup_label(list, idx, name, err_info) struct sed_label *list; @@ -712,7 +712,7 @@ setup_label(list, idx, name, err_info) return ret; } -static struct sed_label *release_label P_((struct sed_label *list_head)); +static struct sed_label *release_label (struct sed_label *list_head); static struct sed_label * release_label(list_head) struct sed_label *list_head; @@ -732,13 +732,8 @@ release_label(list_head) return ret; } -static struct replacement *new_replacement P_((char *, size_t, - enum replacement_types)); static struct replacement * -new_replacement(text, length, type) - char *text; - size_t length; - enum replacement_types type; +new_replacement(char *text, size_t length, enum replacement_types type) { struct replacement *r = OB_MALLOC(&obs, 1, struct replacement); @@ -751,7 +746,7 @@ new_replacement(text, length, type) return r; } -static void setup_replacement P_((struct subst *, const char *, size_t)); +static void setup_replacement (struct subst *, const char *, size_t); static void setup_replacement(sub, text, length) struct subst *sub; @@ -856,7 +851,7 @@ setup_replacement(sub, text, length) sub->replacement = root.next; } -static void read_text P_((struct text_buf *buf, int leadin_ch)); +static void read_text (struct text_buf *buf, int leadin_ch); static void read_text(buf, leadin_ch) struct text_buf *buf; @@ -916,7 +911,7 @@ read_text(buf, leadin_ch) return non-zero and store the resulting address in `*addr'. If the input doesn't look like an address read nothing and return zero. */ -static bool compile_address P_((struct addr *addr, int ch)); +static bool compile_address (struct addr *addr, int ch); static bool compile_address(addr, ch) struct addr *addr; @@ -1014,7 +1009,7 @@ compile_address(addr, ch) /* Read a program (or a subprogram within `{' `}' pairs) in and store the compiled form in `*vector'. Return a pointer to the new vector. */ -static struct vector *compile_program P_((struct vector *)); +static struct vector *compile_program (struct vector *); static struct vector * compile_program(vector) struct vector *vector; diff --git a/sed/execute.c b/sed/execute.c index a430f62..cb84192 100644 --- a/sed/execute.c +++ b/sed/execute.c @@ -91,7 +91,7 @@ struct input { /* Function to read one line. If FP is NULL, read_fn better not be one which uses fp; in particular, read_always_fail() is recommended. */ - bool (*read_fn) P_((struct input *)); /* read one line */ + bool (*read_fn) (struct input *); /* read one line */ char *out_file_name; @@ -132,7 +132,7 @@ static struct append_queue *append_tail = NULL; /* increase a struct line's length, making some attempt at keeping realloc() calls under control by padding for future growth. */ -static void resize_line P_((struct line *, size_t)); +static void resize_line (struct line *, size_t); static void resize_line(lb, len) struct line *lb; @@ -165,7 +165,7 @@ resize_line(lb, len) } /* Append `length' bytes from `string' to the line `to'. */ -static void str_append P_((struct line *, const char *, size_t)); +static void str_append (struct line *, const char *, size_t); static void str_append(to, string, length) struct line *to; @@ -201,14 +201,9 @@ str_append(to, string, length) } } -static void str_append_modified P_((struct line *, const char *, size_t, - enum replacement_types)); static void -str_append_modified(to, string, length, type) - struct line *to; - const char *string; - size_t length; - enum replacement_types type; +str_append_modified(struct line *to, const char *string, size_t length, + enum replacement_types type) { mbstate_t from_stat; @@ -279,7 +274,7 @@ str_append_modified(to, string, length, type) /* Initialize a "struct line" buffer. Copy multibyte state from `state' if not null. */ -static void line_init P_((struct line *, struct line *, size_t initial_size)); +static void line_init (struct line *, struct line *, size_t initial_size); static void line_init(buf, state, initial_size) struct line *buf; @@ -300,7 +295,7 @@ line_init(buf, state, initial_size) /* Reset a "struct line" buffer to length zero. Copy multibyte state from `state' if not null. */ -static void line_reset P_((struct line *, struct line *)); +static void line_reset (struct line *, struct line *); static void line_reset(buf, state) struct line *buf, *state; @@ -320,7 +315,7 @@ line_reset(buf, state) /* Copy the contents of the line `from' into the line `to'. This destroys the old contents of `to'. Copy the multibyte state if `state' is true. */ -static void line_copy P_((struct line *from, struct line *to, int state)); +static void line_copy (struct line *from, struct line *to, int state); static void line_copy(from, to, state) struct line *from; @@ -354,7 +349,7 @@ line_copy(from, to, state) /* Append the contents of the line `from' to the line `to'. Copy the multibyte state if `state' is true. */ -static void line_append P_((struct line *from, struct line *to, int state)); +static void line_append (struct line *from, struct line *to, int state); static void line_append(from, to, state) struct line *from; @@ -371,7 +366,7 @@ line_append(from, to, state) /* Exchange two "struct line" buffers. Copy the multibyte state if `state' is true. */ -static void line_exchange P_((struct line *a, struct line *b, int state)); +static void line_exchange (struct line *a, struct line *b, int state); static void line_exchange(a, b, state) struct line *a; @@ -396,7 +391,7 @@ line_exchange(a, b, state) /* dummy function to simplify read_pattern_space() */ -static bool read_always_fail P_((struct input *)); +static bool read_always_fail (struct input *); static bool read_always_fail(input) struct input *input UNUSED; @@ -404,7 +399,7 @@ read_always_fail(input) return false; } -static bool read_file_line P_((struct input *)); +static bool read_file_line (struct input *); static bool read_file_line(input) struct input *input; @@ -427,7 +422,7 @@ read_file_line(input) } -static inline void output_missing_newline P_((struct output *)); +static inline void output_missing_newline (struct output *); static inline void output_missing_newline(outf) struct output *outf; @@ -439,7 +434,7 @@ output_missing_newline(outf) } } -static inline void flush_output P_((FILE *)); +static inline void flush_output (FILE *); static inline void flush_output(fp) FILE *fp; @@ -448,7 +443,7 @@ flush_output(fp) ck_fflush(fp); } -static void output_line P_((const char *, size_t, int, struct output *)); +static void output_line (const char *, size_t, int, struct output *); static void output_line(text, length, nl, outf) const char *text; @@ -470,7 +465,7 @@ output_line(text, length, nl, outf) flush_output(outf->fp); } -static struct append_queue *next_append_slot P_((void)); +static struct append_queue *next_append_slot (void); static struct append_queue * next_append_slot() { @@ -489,7 +484,7 @@ next_append_slot() return append_tail = n; } -static void release_append_queue P_((void)); +static void release_append_queue (void); static void release_append_queue() { @@ -506,7 +501,7 @@ release_append_queue() append_head = append_tail = NULL; } -static void dump_append_queue P_((void)); +static void dump_append_queue (void); static void dump_append_queue() { @@ -544,7 +539,7 @@ dump_append_queue() /* Compute the name of the backup file for in-place editing */ -static char *get_backup_file_name P_((const char *)); +static char *get_backup_file_name (const char *); static char * get_backup_file_name(name) const char *name; @@ -577,7 +572,7 @@ get_backup_file_name(name) } /* Initialize a struct input for the named file. */ -static void open_next_file P_((const char *name, struct input *)); +static void open_next_file (const char *name, struct input *); static void open_next_file(name, input) const char *name; @@ -678,7 +673,7 @@ open_next_file(name, input) /* Clean up an input stream that we are done with. */ -static void closedown P_((struct input *)); +static void closedown (struct input *); static void closedown(input) struct input *input; @@ -722,7 +717,7 @@ closedown(input) } /* Reset range commands so that they are marked as non-matching */ -static void reset_addresses P_((struct vector *)); +static void reset_addresses (struct vector *); static void reset_addresses(vec) struct vector *vec; @@ -741,7 +736,7 @@ reset_addresses(vec) /* Read in the next line of input, and store it in the pattern space. Return zero if there is nothing left to input. */ -static bool read_pattern_space P_((struct input *, struct vector *, int)); +static bool read_pattern_space (struct input *, struct vector *, int); static bool read_pattern_space(input, the_program, append) struct input *input; @@ -786,7 +781,7 @@ read_pattern_space(input, the_program, append) } -static bool last_file_with_data_p P_((struct input *)); +static bool last_file_with_data_p (struct input *); static bool last_file_with_data_p(input) struct input *input; @@ -811,7 +806,7 @@ last_file_with_data_p(input) } /* Determine if we match the `$' address. */ -static bool test_eof P_((struct input *)); +static bool test_eof (struct input *); static bool test_eof(input) struct input *input; @@ -832,7 +827,7 @@ test_eof(input) /* Return non-zero if the current line matches the address pointed to by `addr'. */ -static bool match_an_address_p P_((struct addr *, struct input *)); +static bool match_an_address_p (struct addr *, struct input *); static bool match_an_address_p(addr, input) struct addr *addr; @@ -870,7 +865,7 @@ match_an_address_p(addr, input) } /* return non-zero if current address is valid for cmd */ -static bool match_address_p P_((struct sed_cmd *, struct input *)); +static bool match_address_p (struct sed_cmd *, struct input *); static bool match_address_p(cmd, input) struct sed_cmd *cmd; @@ -949,7 +944,7 @@ match_address_p(cmd, input) } -static void do_list P_((int line_len)); +static void do_list (int line_len); static void do_list(line_len) int line_len; @@ -1010,13 +1005,8 @@ do_list(line_len) } -static void append_replacement P_((struct line *, struct replacement *, - struct re_registers *)); -static void -append_replacement (buf, p, regs) - struct line *buf; - struct replacement *p; - struct re_registers *regs; +static void append_replacement (struct line *buf, struct replacement *p, + struct re_registers *regs) { enum replacement_types repl_mod = 0; @@ -1056,7 +1046,7 @@ append_replacement (buf, p, regs) } } -static void do_subst P_((struct subst *)); +static void do_subst (struct subst *); static void do_subst(sub) struct subst *sub; @@ -1217,7 +1207,7 @@ do_subst(sub) static countT branches; -static countT count_branches P_((struct vector *)); +static countT count_branches (struct vector *); static countT count_branches(program) struct vector *program; @@ -1240,7 +1230,7 @@ count_branches(program) return cnt; } -static struct sed_cmd *shrink_program P_((struct vector *, struct sed_cmd *)); +static struct sed_cmd *shrink_program (struct vector *, struct sed_cmd *); static struct sed_cmd * shrink_program(vec, cur_cmd) struct vector *vec; @@ -1267,7 +1257,7 @@ shrink_program(vec, cur_cmd) /* Execute the program `vec' on the current input line. Return exit status if caller should quit, -1 otherwise. */ -static int execute_program P_((struct vector *, struct input *)); +static int execute_program (struct vector *, struct input *); static int execute_program(vec, input) struct vector *vec; @@ -124,20 +124,20 @@ struct Word /* Forward declarations. */ -static bool get_paragraph P_ ((void)); -static int get_line P_ ((int c)); -static int get_space P_ ((int c)); -static int copy_rest P_ ((int c)); -static bool same_para P_ ((int c)); -static void flush_paragraph P_ ((void)); -static void fmt_paragraph P_ ((void)); -static void check_punctuation P_ ((WORD *w)); -static COST base_cost P_ ((WORD *this)); -static COST line_cost P_ ((WORD *next, int len)); -static void put_paragraph P_ ((WORD *finish)); -static void put_line P_ ((WORD *w, int indent)); -static void put_word P_ ((WORD *w)); -static void put_space P_ ((int space)); +static bool get_paragraph (void); +static int get_line (int c); +static int get_space (int c); +static int copy_rest (int c); +static bool same_para (int c); +static void flush_paragraph (void); +static void fmt_paragraph (void); +static void check_punctuation (WORD *w); +static COST base_cost (WORD *this); +static COST line_cost (WORD *next, int len); +static void put_paragraph (WORD *finish); +static void put_line (WORD *w, int indent); +static void put_word (WORD *w); +static void put_space (int space); /* Option values. */ @@ -69,7 +69,7 @@ countT lcmd_out_line_len = 70; /* The complete compiled SED program that we are going to run: */ static struct vector *the_program = NULL; -static void usage P_((int)); +static void usage (int); static void contact(errmsg) int errmsg; @@ -88,7 +88,7 @@ Be sure to include the word ``%s'' somewhere in the ``Subject:'' field.\n"), PACKAGE_BUGREPORT, PACKAGE); } -static void usage P_((int)); +static void usage (int); static void usage(status) int status; @@ -181,27 +181,27 @@ struct sed_cmd { -void bad_prog P_((const char *why)); -size_t normalize_text P_((char *text, size_t len, enum text_types buftype)); -struct vector *compile_string P_((struct vector *, char *str, size_t len)); -struct vector *compile_file P_((struct vector *, const char *cmdfile)); -void check_final_program P_((struct vector *)); -void rewind_read_files P_((void)); -void finish_program P_((struct vector *)); - -struct regex *compile_regex P_((struct buffer *b, int flags, int needed_sub)); -int match_regex P_((struct regex *regex, - char *buf, size_t buflen, size_t buf_start_offset, - struct re_registers *regarray, int regsize)); +void bad_prog (const char *why); +size_t normalize_text (char *text, size_t len, enum text_types buftype); +struct vector *compile_string (struct vector *, char *str, size_t len); +struct vector *compile_file (struct vector *, const char *cmdfile); +void check_final_program (struct vector *); +void rewind_read_files (void); +void finish_program (struct vector *); + +struct regex *compile_regex (struct buffer *b, int flags, int needed_sub); +int match_regex (struct regex *regex, + char *buf, size_t buflen, size_t buf_start_offset, + struct re_registers *regarray, int regsize); #ifdef DEBUG_LEAKS -void release_regex P_((struct regex *)); +void release_regex (struct regex *); #endif -int process_files P_((struct vector *, char **argv)); +int process_files (struct vector *, char **argv); -int main P_((int, char **)); +int main (int, char **); -extern void fmt P_ ((const char *line, const char *line_end, int max_length, FILE *output_file)); +extern void fmt (const char *line, const char *line_end, int max_length, FILE *output_file); extern int extended_regexp_flags; @@ -260,5 +260,6 @@ extern bool is_utf8; #define BRLEN(ch, ps) \ (mb_cur_max == 1 ? 1 : brlen (ch, ps)) -extern int brlen P_ ((int ch, mbstate_t *ps)); +extern int brlen (int ch, mbstate_t *ps); +extern void initialize_mbcs (void); diff --git a/sed/utils.c b/sed/utils.c index 26dc798..aa674fd 100644 --- a/sed/utils.c +++ b/sed/utils.c @@ -47,7 +47,7 @@ struct open_file }; static struct open_file *open_files = NULL; -static void do_ck_fclose P_((FILE *fp)); +static void do_ck_fclose (FILE *fp); /* Print an error message and exit */ @@ -82,7 +82,7 @@ panic(const char *str, ...) /* Internal routine to get a filename from open_files */ -static const char *utils_fp_name P_((FILE *fp)); +static const char *utils_fp_name (FILE *fp); static const char * utils_fp_name(fp) FILE *fp; @@ -528,7 +528,7 @@ size_buffer(b) return b->length; } -static void resize_buffer P_((struct buffer *b, size_t newlen)); +static void resize_buffer (struct buffer *b, size_t newlen); static void resize_buffer(b, newlen) struct buffer *b; diff --git a/sed/utils.h b/sed/utils.h index 144ae9a..4b44cd8 100644 --- a/sed/utils.h +++ b/sed/utils.h @@ -20,31 +20,31 @@ #include "basicdefs.h" -void panic P_((const char *str, ...)); - -FILE *ck_fopen P_((const char *name, const char *mode, int fail)); -FILE *ck_fdopen P_((int fd, const char *name, const char *mode, int fail)); -void ck_fwrite P_((const void *ptr, size_t size, size_t nmemb, FILE *stream)); -size_t ck_fread P_((void *ptr, size_t size, size_t nmemb, FILE *stream)); -void ck_fflush P_((FILE *stream)); -void ck_fclose P_((FILE *stream)); -const char *follow_symlink P_((const char *path)); -size_t ck_getdelim P_((char **text, size_t *buflen, char buffer_delimiter, FILE *stream)); -FILE * ck_mkstemp P_((char **p_filename, const char *tmpdir, const char *base, - const char *mode)); -void ck_rename P_((const char *from, const char *to, const char *unlink_if_fail)); - -void *ck_malloc P_((size_t size)); -void *xmalloc P_((size_t size)); -void *ck_realloc P_((void *ptr, size_t size)); -char *ck_strdup P_((const char *str)); -void *ck_memdup P_((const void *buf, size_t len)); - -struct buffer *init_buffer P_((void)); -char *get_buffer P_((struct buffer *b)); -size_t size_buffer P_((struct buffer *b)); -char *add_buffer P_((struct buffer *b, const char *p, size_t n)); -char *add1_buffer P_((struct buffer *b, int ch)); -void free_buffer P_((struct buffer *b)); +void panic (const char *str, ...); + +FILE *ck_fopen (const char *name, const char *mode, int fail); +FILE *ck_fdopen (int fd, const char *name, const char *mode, int fail); +void ck_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream); +size_t ck_fread (void *ptr, size_t size, size_t nmemb, FILE *stream); +void ck_fflush (FILE *stream); +void ck_fclose (FILE *stream); +const char *follow_symlink (const char *path); +size_t ck_getdelim (char **text, size_t *buflen, char buffer_delimiter, FILE *stream); +FILE * ck_mkstemp (char **p_filename, const char *tmpdir, const char *base, + const char *mode); +void ck_rename (const char *from, const char *to, const char *unlink_if_fail); + +void *ck_malloc (size_t size); +void *xmalloc (size_t size); +void *ck_realloc (void *ptr, size_t size); +char *ck_strdup (const char *str); +void *ck_memdup (const void *buf, size_t len); + +struct buffer *init_buffer (void); +char *get_buffer (struct buffer *b); +size_t size_buffer (struct buffer *b); +char *add_buffer (struct buffer *b, const char *p, size_t n); +char *add1_buffer (struct buffer *b, int ch); +void free_buffer (struct buffer *b); extern const char *myname; |