From 293d1fd3723df8d5acc281cdcdfd3a21fe4f6233 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Fri, 3 Aug 2018 23:10:55 -0600 Subject: [PATCH] maint: syntax-check: prohibit-form-feed * cfg.mk (sc_prohibit-form-feed): Copied from coreutils' cfg.mk. * sed/compile.c, sed/execute.c, sed/regexp.c, sed/sed.h, sed/utils.c: Remove form feed characters. --- cfg.mk | 7 +++++++ sed/compile.c | 9 --------- sed/execute.c | 7 ------- sed/regexp.c | 2 -- sed/sed.h | 1 - sed/utils.c | 3 --- 6 files changed, 7 insertions(+), 22 deletions(-) diff --git a/cfg.mk b/cfg.mk index c5787f3..edc6658 100644 --- a/cfg.mk +++ b/cfg.mk @@ -206,6 +206,13 @@ sc_space_before_open_paren: fi ########################################################### +sc_prohibit-form-feed: + @prohibit=$$'\f' \ + in_vc_files='\.[chly]$$' \ + halt='Form Feed (^L) detected' \ + $(_sc_search_regexp) + + update-copyright-env = \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79 diff --git a/sed/compile.c b/sed/compile.c index a0deaf6..2637ba6 100644 --- a/sed/compile.c +++ b/sed/compile.c @@ -27,7 +27,6 @@ #include "progname.h" #include "xalloc.h" - #define YMAP_LENGTH 256 /*XXX shouldn't this be (UCHAR_MAX+1)?*/ #define VECTOR_ALLOC_INCREMENT 40 @@ -87,7 +86,6 @@ static struct special_files special_files[] = { { { NULL, false, NULL, NULL }, NULL } }; - /* Where we are in the processing of the input. */ static struct prog_info prog; static struct error_info cur_input; @@ -197,7 +195,6 @@ static const char errors[] = static struct output *file_read = NULL; static struct output *file_write = NULL; - /* Complain about an unknown command and exit. */ static void bad_command (char ch) @@ -224,7 +221,6 @@ bad_prog (const char *why) exit (EXIT_BAD_USAGE); } - /* 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. */ @@ -354,7 +350,6 @@ convert_number (char *result, char *buf, const char *bufend, int base) return p; } - /* Read in a filename for a `r', `w', or `s///w' command. */ static struct buffer * read_filename (void) @@ -426,7 +421,6 @@ get_openfile (struct output **file_ptrs, const char *mode, int fail) return p; } - static struct sed_cmd * next_cmd_entry (struct vector **vectorp) { @@ -678,7 +672,6 @@ mark_subst_opts (struct subst *cmd) } } - /* read in a label for a `:', `b', or `t' command */ static char * read_label (void) @@ -903,7 +896,6 @@ read_text (struct text_buf *buf, int leadin_ch) pending_text = NULL; } - /* Try to read an address for a sed command. If it succeeds, return non-zero and store the resulting address in `*addr'. If the input doesn't look like an address read nothing @@ -1381,7 +1373,6 @@ compile_program (struct vector *vector) return vector; } - /* deal with \X escapes */ size_t normalize_text (char *buf, size_t len, enum text_types buftype) diff --git a/sed/execute.c b/sed/execute.c index e4dbb79..635f8c8 100644 --- a/sed/execute.c +++ b/sed/execute.c @@ -125,7 +125,6 @@ static struct line buffer; static struct append_queue *append_head = NULL; 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 @@ -375,7 +374,6 @@ line_exchange (struct line *a, struct line *b, int state) } } - /* dummy function to simplify read_pattern_space() */ static bool read_always_fail (struct input *input _GL_UNUSED) @@ -403,7 +401,6 @@ read_file_line (struct input *input) return true; } - static inline void output_missing_newline (struct output *outf) { @@ -507,7 +504,6 @@ dump_append_queue (void) release_append_queue (); } - /* Compute the name of the backup file for in-place editing */ static char * get_backup_file_name (const char *name) @@ -748,7 +744,6 @@ read_pattern_space (struct input *input, struct vector *the_program, int append) return true; } - static bool last_file_with_data_p (struct input *input) { @@ -903,7 +898,6 @@ match_address_p (struct sed_cmd *cmd, struct input *input) return true; } - static void do_list (int line_len) { @@ -1647,7 +1641,6 @@ execute_program (struct vector *vec, struct input *input) return -1; } - /* Apply the compiled script to all the named files. */ int diff --git a/sed/regexp.c b/sed/regexp.c index 7dd223d..8eba866 100644 --- a/sed/regexp.c +++ b/sed/regexp.c @@ -40,7 +40,6 @@ static const char errors[] = #define NO_REGEX (errors) #define BAD_MODIF (NO_REGEX + sizeof(N_("no previous regular expression"))) - void dfaerror (char const *mesg) @@ -55,7 +54,6 @@ dfawarn (char const *mesg) dfaerror (mesg); } - static void compile_regex_1 (struct regex *new_regex, int needed_sub) diff --git a/sed/sed.h b/sed/sed.h index 290f0ce..93b2c7f 100644 --- a/sed/sed.h +++ b/sed/sed.h @@ -184,7 +184,6 @@ struct sed_cmd { }; - _Noreturn 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); diff --git a/sed/utils.c b/sed/utils.c index a3b694f..5314ea4 100644 --- a/sed/utils.c +++ b/sed/utils.c @@ -80,7 +80,6 @@ panic (const char *str, ...) exit (EXIT_PANIC); } - /* Internal routine to get a filename from open_files */ static const char * _GL_ATTRIBUTE_PURE utils_fp_name (FILE *fp) @@ -284,7 +283,6 @@ do_ck_fclose (FILE *fp) if (fclose (fp) == EOF) panic ("couldn't close %s: %s", utils_fp_name (fp), strerror (errno)); } - /* Follow symlink and panic if something fails. Return the ultimate symlink target, stored in a temporary buffer that the caller should @@ -393,7 +391,6 @@ ck_rename (const char *from, const char *to, const char *unlink_if_fail) - /* Implement a variable sized buffer of `stuff'. We don't know what it is, nor do we care, as long as it doesn't mind being aligned by malloc. */