[PATCH 1/2] maint: convert tabs to spaces in source files.
James Youngman <[email protected]> Sat, 11 Jul 2026 12:49:17 +0100
| Newsgroups | gmane.comp.gnu.findutils.patches,gmane.comp.gnu.findutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
* find/defs.h: Convert tabs to spaces.
* find/exec.c: Likewise.
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/print.c: Likewise.
* find/print.h: Likewise.
* find/sharefile.c: Likewise.
* find/sharefile.h: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* gnulib-local/lib/gcc-function-attributes.h: Likewise.
* lib/bugreports.c: Likewise.
* lib/bugreports.h: Likewise.
* lib/buildcmd.c: Likewise.
* lib/buildcmd.h: Likewise.
* lib/dircallback.c: Likewise.
* lib/dircallback.h: Likewise.
* lib/extendbuf.c: Likewise.
* lib/extendbuf.h: Likewise.
* lib/fdleak.c: Likewise.
* lib/fdleak.h: Likewise.
* lib/findutils-version.c: Likewise.
* lib/findutils-version.h: Likewise.
* lib/listfile.c: Likewise.
* lib/listfile.h: Likewise.
* lib/printquoted.c: Likewise.
* lib/printquoted.h: Likewise.
* lib/qmark.c: Likewise.
* lib/regexprops.c: Likewise.
* lib/regextype.c: Likewise.
* lib/regextype.h: Likewise.
* lib/safe-atoi.c: Likewise.
* lib/splitstring.c: Likewise.
* lib/splitstring.h: Likewise.
* lib/system.h: Likewise.
* lib/test_splitstring.c: Likewise.
* lib/unused-result.h: Likewise.
* locate/frcode.c: Likewise.
* locate/locate.c: Likewise.
* locate/locatedb.h: Likewise.
* locate/word_io.c: Likewise.
* tests/xargs/test-sigusr.c: Likewise.
* xargs/xargs.c: Likewise.
---
find/defs.h | 471 ++++----
find/exec.c | 48 +-
find/fstype.c | 32 +-
find/ftsfind.c | 137 ++-
find/parser.c | 1206 +++++++++++---------
find/pred.c | 322 +++---
find/print.c | 308 ++---
find/print.h | 6 +-
find/sharefile.c | 23 +-
find/sharefile.h | 8 +-
find/tree.c | 440 +++----
find/util.c | 174 +--
gnulib-local/lib/gcc-function-attributes.h | 35 +-
lib/bugreports.c | 16 +-
lib/bugreports.h | 2 +-
lib/buildcmd.c | 163 ++-
lib/buildcmd.h | 55 +-
lib/dircallback.c | 10 +-
lib/dircallback.h | 5 +-
lib/extendbuf.c | 12 +-
lib/extendbuf.h | 4 +-
lib/fdleak.c | 30 +-
lib/fdleak.h | 2 +-
lib/findutils-version.c | 6 +-
lib/findutils-version.h | 2 +-
lib/listfile.c | 71 +-
lib/listfile.h | 5 +-
lib/printquoted.c | 4 +-
lib/printquoted.h | 5 +-
lib/qmark.c | 115 +-
lib/regexprops.c | 111 +-
lib/regextype.c | 56 +-
lib/regextype.h | 17 +-
lib/safe-atoi.c | 4 +-
lib/splitstring.c | 6 +-
lib/splitstring.h | 4 +-
lib/system.h | 4 +-
lib/test_splitstring.c | 40 +-
lib/unused-result.h | 2 +-
locate/frcode.c | 40 +-
locate/locate.c | 415 +++----
locate/locatedb.h | 15 +-
locate/word_io.c | 18 +-
tests/xargs/test-sigusr.c | 240 ++--
xargs/xargs.c | 405 ++++---
45 files changed, 2707 insertions(+), 2387 deletions(-)
diff --git a/find/defs.h b/find/defs.h
index f1c8d706..64d9a809 100644
--- a/find/defs.h
+++ b/find/defs.h
@@ -32,10 +32,7 @@
# error "<config.h> should be #included before defs.h, and indeed before any other header"
Please stop compiling the program now
# endif
-
-
# include <sys/types.h>
-
/* XXX: some of these includes probably don't belong in a common header file */
# include <sys/stat.h>
# include <stdio.h> /* for FILE* */
@@ -46,28 +43,22 @@ Please stop compiling the program now
# include <limits.h> /* for CHAR_BIT */
# include <stdbool.h> /* for bool */
# include <stdint.h> /* for uintmax_t */
-# include <sys/stat.h> /* S_ISUID etc. */
+# include <sys/stat.h> /* S_ISUID etc. */
# include <selinux/selinux.h>
-
-
-
# ifndef CHAR_BIT
# define CHAR_BIT 8
# endif
-
# include <inttypes.h>
-
# include "regex.h"
# include "timespec.h"
# include "buildcmd.h"
# include "quotearg.h"
# include "sharefile.h"
# include "gcc-function-attributes.h"
-
int optionl_stat (const char *name, struct stat *p);
int optionp_stat (const char *name, struct stat *p);
int optionh_stat (const char *name, struct stat *p);
-int debug_stat (const char *file, struct stat *bufp);
+int debug_stat (const char *file, struct stat *bufp);
void set_stat_placeholders (struct stat *p);
int get_statinfo (const char *pathname, const char *name, struct stat *p);
@@ -84,7 +75,8 @@ struct predicate;
struct options;
/* Pointer to a predicate function. */
-typedef bool (*PRED_FUNC)(const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr);
+typedef bool (*PRED_FUNC) (const char *pathname, struct stat * stat_buf,
+ struct predicate * pred_ptr);
/* The number of seconds in a day. */
# define DAYSECS 86400
@@ -128,7 +120,7 @@ enum predicate_precedence
struct long_val
{
enum comparison_type kind;
- bool negative; /* Defined only when representing time_t. */
+ bool negative; /* Defined only when representing time_t. */
uintmax_t l_val;
};
@@ -144,7 +136,7 @@ struct samefile_file_id
{
ino_t ino;
dev_t dev;
- int fd;
+ int fd;
};
struct size_val
@@ -156,36 +148,36 @@ struct size_val
/* Supported file types for the -type/-xtype options. */
enum file_type
- {
- FTYPE_BLK,
- FTYPE_CHR,
- FTYPE_DIR,
- FTYPE_REG,
+{
+ FTYPE_BLK,
+ FTYPE_CHR,
+ FTYPE_DIR,
+ FTYPE_REG,
# ifdef S_IFLNK
- FTYPE_LNK,
+ FTYPE_LNK,
# endif
# ifdef S_IFIFO
- FTYPE_FIFO,
+ FTYPE_FIFO,
# endif
# ifdef S_IFSOCK
- FTYPE_SOCK,
+ FTYPE_SOCK,
# endif
# ifdef S_IFDOOR
- FTYPE_DOOR,
+ FTYPE_DOOR,
# endif
- FTYPE_COUNT
- };
+ FTYPE_COUNT
+};
enum xval
- {
- XVAL_ATIME, XVAL_BIRTHTIME, XVAL_CTIME, XVAL_MTIME, XVAL_TIME
- };
+{
+ XVAL_ATIME, XVAL_BIRTHTIME, XVAL_CTIME, XVAL_MTIME, XVAL_TIME
+};
struct time_val
{
- enum xval xval;
+ enum xval xval;
enum comparison_type kind;
- struct timespec ts;
+ struct timespec ts;
};
@@ -193,11 +185,11 @@ struct exec_val
{
bool multiple; /* -exec {} \+ denotes multiple argument. */
struct buildcmd_control ctl;
- struct buildcmd_state state;
+ struct buildcmd_state state;
char **replace_vec; /* Command arguments (for ";" style) */
int num_args;
bool close_stdin; /* If true, close stdin in the child. */
- struct saved_cwd *wd_for_exec; /* What directory to perform the exec in. */
+ struct saved_cwd *wd_for_exec; /* What directory to perform the exec in. */
int last_child_status; /* Status of the most recent child. */
};
@@ -208,11 +200,11 @@ struct exec_val
/* Special values for the `kind' field of `struct segment'. */
enum SegmentKind
- {
- KIND_PLAIN=0, /* Segment containing just plain text. */
- KIND_STOP=1, /* \c -- stop printing and flush output. */
- KIND_FORMAT, /* Regular format */
- };
+{
+ KIND_PLAIN = 0, /* Segment containing just plain text. */
+ KIND_STOP = 1, /* \c -- stop printing and flush output. */
+ KIND_FORMAT, /* Regular format */
+};
struct segment
{
@@ -305,7 +297,7 @@ struct predicate
union
{
const char *str; /* fstype [i]lname [i]name [i]path */
- struct re_pattern_buffer *regex; /* regex */
+ struct re_pattern_buffer *regex; /* regex */
struct exec_val exec_vec; /* exec ok */
struct long_val numinfo; /* gid inum links uid */
struct size_val size; /* size */
@@ -315,8 +307,8 @@ struct predicate
struct perm_val perm; /* perm */
struct samefile_file_id samefileid; /* samefile */
bool types[FTYPE_COUNT]; /* file type(s) */
- struct format_val printf_vec; /* printf fprintf fprint ls fls print0 fprint0 print */
- char *scontext; /* security context */
+ struct format_val printf_vec; /* printf fprintf fprint ls fls print0 fprint0 print */
+ char *scontext; /* security context */
} args;
/* The next predicate in the user input sequence,
@@ -332,11 +324,11 @@ struct predicate
struct predicate_performance_info perf;
- const struct parser_table* parser_entry;
+ const struct parser_table *parser_entry;
};
/* ftsfind.c */
-bool is_fts_cwdfd_enabled(void);
+bool is_fts_cwdfd_enabled (void);
/* find library function declarations. */
@@ -346,59 +338,66 @@ bool is_fts_cwdfd_enabled(void);
* -P, -L or -P (default) on the command line.
*/
enum SymlinkOption
- {
- SYMLINK_NEVER_DEREF, /* Option -P */
- SYMLINK_ALWAYS_DEREF, /* Option -L */
- SYMLINK_DEREF_ARGSONLY /* Option -H */
- };
+{
+ SYMLINK_NEVER_DEREF, /* Option -P */
+ SYMLINK_ALWAYS_DEREF, /* Option -L */
+ SYMLINK_DEREF_ARGSONLY /* Option -H */
+};
void set_follow_state (enum SymlinkOption opt);
-void cleanup(void);
+void cleanup (void);
/* fstype.c */
char *filesystem_type (const struct stat *statp, const char *path);
-bool is_used_fs_type(const char *name);
-dev_t * get_mounted_devices (size_t *);
+bool is_used_fs_type (const char *name);
+dev_t *get_mounted_devices (size_t *);
enum arg_type
- {
- ARG_OPTION, /* regular options like -maxdepth */
- ARG_NOOP, /* does nothing, returns true, internal use only */
- ARG_POSITIONAL_OPTION, /* options whose position is important (-follow) */
- ARG_TEST, /* a like -name */
- ARG_SPECIAL_PARSE, /* complex to parse, don't eat the test name before calling parse_xx(). */
- ARG_PUNCTUATION, /* like -o or ( */
- ARG_ACTION /* like -print */
- };
+{
+ ARG_OPTION, /* regular options like -maxdepth */
+ ARG_NOOP, /* does nothing, returns true, internal use only */
+ ARG_POSITIONAL_OPTION, /* options whose position is important (-follow) */
+ ARG_TEST, /* a like -name */
+ ARG_SPECIAL_PARSE, /* complex to parse, don't eat the test name before calling parse_xx(). */
+ ARG_PUNCTUATION, /* like -o or ( */
+ ARG_ACTION /* like -print */
+};
struct parser_table;
/* Pointer to a parser function. */
-typedef bool (*PARSE_FUNC)(const struct parser_table *p,
- char *argv[], int *arg_ptr);
+typedef bool (*PARSE_FUNC) (const struct parser_table * p,
+ char *argv[], int *arg_ptr);
struct parser_table
{
enum arg_type type;
const char *parser_name;
PARSE_FUNC parser_func;
- PRED_FUNC pred_func;
+ PRED_FUNC pred_func;
};
/* parser.c */
-const struct parser_table* find_parser (const char *search_name);
-bool parse_print (const struct parser_table*, char *argv[], int *arg_ptr);
+const struct parser_table *find_parser (const char *search_name);
+bool parse_print (const struct parser_table *, char *argv[], int *arg_ptr);
void pred_sanity_check (const struct predicate *predicates);
void check_option_combinations (const struct predicate *p);
-void parse_begin_user_args (char **args, int argno, const struct predicate *last, const struct predicate *predicates);
-void parse_end_user_args (char **args, int argno, const struct predicate *last, const struct predicate *predicates);
-bool parse_openparen (const struct parser_table* entry, char *argv[], int *arg_ptr);
-bool parse_closeparen (const struct parser_table* entry, char *argv[], int *arg_ptr);
+void parse_begin_user_args (char **args, int argno,
+ const struct predicate *last,
+ const struct predicate *predicates);
+void parse_end_user_args (char **args, int argno,
+ const struct predicate *last,
+ const struct predicate *predicates);
+bool parse_openparen (const struct parser_table *entry, char *argv[],
+ int *arg_ptr);
+bool parse_closeparen (const struct parser_table *entry, char *argv[],
+ int *arg_ptr);
/* pred.c */
-typedef bool PREDICATEFUNCTION(const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr);
+typedef bool PREDICATEFUNCTION (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr);
PREDICATEFUNCTION pred_amin;
PREDICATEFUNCTION pred_and;
@@ -459,224 +458,238 @@ PREDICATEFUNCTION pred_writable;
PREDICATEFUNCTION pred_xtype;
PREDICATEFUNCTION pred_context;
-bool pred_quit (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+bool
+pred_quit (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
_GL_ATTRIBUTE_NORETURN;
-void print_predicate (FILE *fp, const struct predicate *p);
-void print_tree (FILE*, struct predicate *node, int indent);
-void print_list (FILE*, struct predicate *node);
-void print_optlist (FILE *fp, const struct predicate *node);
-void show_success_rates(const struct predicate *node);
-bool predicate_uses_exec(const struct predicate*);
+ void print_predicate (FILE *fp, const struct predicate *p);
+ void print_tree (FILE *, struct predicate *node, int indent);
+ void print_list (FILE *, struct predicate *node);
+ void print_optlist (FILE *fp, const struct predicate *node);
+ void show_success_rates (const struct predicate *node);
+ bool predicate_uses_exec (const struct predicate *);
# define pred_is(node, fn) ( ((node)->pred_func) == (fn) )
/* tree.c */
-bool matches_start_point(const char * glob, bool foldcase);
-struct predicate * build_expression_tree (int argc, char *argv[], int end_of_leading_options);
-struct predicate * get_eval_tree (void);
-struct predicate *get_new_pred_noarg (const struct parser_table *entry);
-struct predicate *get_new_pred (const struct parser_table *entry);
-struct predicate *get_new_pred_chk_op (const struct parser_table *entry,
- const char *arg);
-float calculate_derived_rates (struct predicate *p);
+ bool matches_start_point (const char *glob, bool foldcase);
+ struct predicate *build_expression_tree (int argc, char *argv[],
+ int end_of_leading_options);
+ struct predicate *get_eval_tree (void);
+ struct predicate *get_new_pred_noarg (const struct parser_table *entry);
+ struct predicate *get_new_pred (const struct parser_table *entry);
+ struct predicate *get_new_pred_chk_op (const struct parser_table *entry,
+ const char *arg);
+ float calculate_derived_rates (struct predicate *p);
/* util.c */
-struct predicate *insert_primary (const struct parser_table *entry, const char *arg);
-struct predicate *insert_primary_noarg (const struct parser_table *entry);
-struct predicate *insert_primary_withpred (const struct parser_table *entry, PRED_FUNC fptr, const char *arg);
-void usage (int status) _GL_ATTRIBUTE_NORETURN;
-extern bool check_nofollow(void);
-void complete_pending_execs(struct predicate *p);
-void complete_pending_execdirs (void);
-const char *safely_quote_err_filename (int n, char const *arg);
-void record_initial_cwd (void);
-bool is_exec_in_local_dir(const PRED_FUNC pred_func);
-
-void fatal_target_file_error (int errno_value, const char *name) _GL_ATTRIBUTE_NORETURN;
-void fatal_nontarget_file_error (int errno_value, const char *name) _GL_ATTRIBUTE_NORETURN;
-void nonfatal_target_file_error (int errno_value, const char *name);
-void nonfatal_nontarget_file_error (int errno_value, const char *name);
-
-
-int process_leading_options (int argc, char *argv[]);
-void set_option_defaults (struct options *p);
+ struct predicate *insert_primary (const struct parser_table *entry,
+ const char *arg);
+ struct predicate *insert_primary_noarg (const struct parser_table
+ *entry);
+ struct predicate *insert_primary_withpred (const struct parser_table
+ *entry, PRED_FUNC fptr,
+ const char *arg);
+ void usage (int status) _GL_ATTRIBUTE_NORETURN;
+ extern bool check_nofollow (void);
+ void complete_pending_execs (struct predicate *p);
+ void complete_pending_execdirs (void);
+ const char *safely_quote_err_filename (int n, char const *arg);
+ void record_initial_cwd (void);
+ bool is_exec_in_local_dir (const PRED_FUNC pred_func);
+
+ void fatal_target_file_error (int errno_value,
+ const char *name) _GL_ATTRIBUTE_NORETURN;
+ void fatal_nontarget_file_error (int errno_value,
+ const char *name)
+ _GL_ATTRIBUTE_NORETURN;
+ void nonfatal_target_file_error (int errno_value, const char *name);
+ void nonfatal_nontarget_file_error (int errno_value, const char *name);
+
+
+ int process_leading_options (int argc, char *argv[]);
+ void set_option_defaults (struct options *p);
# if 0
# define apply_predicate(pathname, stat_buf_ptr, node) \
(*(node)->pred_func)((pathname), (stat_buf_ptr), (node))
# else
-bool apply_predicate(const char *pathname, struct stat *stat_buf, struct predicate *p);
+ bool apply_predicate (const char *pathname, struct stat *stat_buf,
+ struct predicate *p);
# endif
/* util.c. */
-bool following_links (void);
-bool digest_mode (mode_t *mode, const char *pathname, const char *name, struct stat *pstat, bool leaf);
-bool default_prints (struct predicate *pred);
-bool looks_like_expression (const char *arg, bool leading);
+ bool following_links (void);
+ bool digest_mode (mode_t *mode, const char *pathname, const char *name,
+ struct stat *pstat, bool leaf);
+ bool default_prints (struct predicate *pred);
+ bool looks_like_expression (const char *arg, bool leading);
-enum DebugOption
- {
- DebugNone = 0,
- DebugExpressionTree = 1 << 0,
- DebugStat = 1 << 1,
- DebugSearch = 1 << 2,
- DebugTreeOpt = 1 << 3,
- DebugHelp = 1 << 4,
- DebugExec = 1 << 5,
- DebugSuccessRates = 1 << 6,
- DebugTime = 1 << 7,
-
- DebugAll = ~DebugNone & ~DebugHelp, /* all but help */
- };
-
-struct options
-{
- /* If true, process directory before contents. True unless -depth given. */
- bool do_dir_first;
- /* If true, -depth was EXPLICITLY set (as opposed to having been turned
- * on by -delete, for example).
- */
- bool explicit_depth;
+ enum DebugOption
+ {
+ DebugNone = 0,
+ DebugExpressionTree = 1 << 0,
+ DebugStat = 1 << 1,
+ DebugSearch = 1 << 2,
+ DebugTreeOpt = 1 << 3,
+ DebugHelp = 1 << 4,
+ DebugExec = 1 << 5,
+ DebugSuccessRates = 1 << 6,
+ DebugTime = 1 << 7,
- /* If >=0, don't descend more than this many levels of subdirectories. */
- int maxdepth;
+ DebugAll = ~DebugNone & ~DebugHelp, /* all but help */
+ };
- /* If >=0, don't process files above this level. */
- int mindepth;
+ struct options
+ {
+ /* If true, process directory before contents. True unless -depth given. */
+ bool do_dir_first;
+ /* If true, -depth was EXPLICITLY set (as opposed to having been turned
+ * on by -delete, for example).
+ */
+ bool explicit_depth;
- /* If true, do not assume that files in directories with nlink == 2
- are non-directories. */
- bool no_leaf_check;
+ /* If >=0, don't descend more than this many levels of subdirectories. */
+ int maxdepth;
- /* If true, skip files on other devices. */
- bool mount;
+ /* If >=0, don't process files above this level. */
+ int mindepth;
- /* If true, don't cross filesystem boundaries. */
- bool xdev;
+ /* If true, do not assume that files in directories with nlink == 2
+ are non-directories. */
+ bool no_leaf_check;
- /* If true, we ignore the problem where we find that a directory entry
- * no longer exists by the time we get around to processing it.
- */
- bool ignore_readdir_race;
+ /* If true, skip files on other devices. */
+ bool mount;
- /* If true, pass control characters through. If false, escape them
- * or turn them into harmless things.
- */
- bool literal_control_chars;
+ /* If true, don't cross filesystem boundaries. */
+ bool xdev;
- /* If true, we issue warning messages
- */
- bool warnings;
+ /* If true, we ignore the problem where we find that a directory entry
+ * no longer exists by the time we get around to processing it.
+ */
+ bool ignore_readdir_race;
- /* If true, avoid POSIX-incompatible behaviours
- * (this functionality is currently incomplete
- * and at the moment affects mainly warning messages).
- */
- bool posixly_correct;
+ /* If true, pass control characters through. If false, escape them
+ * or turn them into harmless things.
+ */
+ bool literal_control_chars;
- struct timespec start_time; /* Time at start of execution. */
+ /* If true, we issue warning messages
+ */
+ bool warnings;
- /* Either one day before now (the default), or the start of today (if -daystart is given). */
- struct timespec cur_day_start;
+ /* If true, avoid POSIX-incompatible behaviours
+ * (this functionality is currently incomplete
+ * and at the moment affects mainly warning messages).
+ */
+ bool posixly_correct;
- /* If true, cur_day_start has been adjusted to the start of the day. */
- bool full_days;
+ struct timespec start_time; /* Time at start of execution. */
- int output_block_size; /* Output block size. */
+ /* Either one day before now (the default), or the start of today (if -daystart is given). */
+ struct timespec cur_day_start;
- /* bitmask for debug options */
- unsigned long debug_options;
+ /* If true, cur_day_start has been adjusted to the start of the day. */
+ bool full_days;
- enum SymlinkOption symlink_handling;
+ int output_block_size; /* Output block size. */
+ /* bitmask for debug options */
+ unsigned long debug_options;
- /* Pointer to the function used to stat files. */
- int (*xstat) (const char *name, struct stat *statbuf);
+ enum SymlinkOption symlink_handling;
- /* Indicate if we can implement safely_chdir() using the O_NOFOLLOW
- * flag to open(2).
- */
- bool open_nofollow_available;
+ /* Pointer to the function used to stat files. */
+ int (*xstat) (const char *name, struct stat *statbuf);
- /* The variety of regular expression that we support.
- * The default is POSIX Basic Regular Expressions, but this
- * can be changed with the positional option, -regextype.
- */
- int regex_options;
- /* function used to get file context */
- int (*x_getfilecon) (int, const char *, char **);
+ /* Indicate if we can implement safely_chdir() using the O_NOFOLLOW
+ * flag to open(2).
+ */
+ bool open_nofollow_available;
- /* Optimisation level. One is the default.
- */
- unsigned short optimisation_level;
+ /* The variety of regular expression that we support.
+ * The default is POSIX Basic Regular Expressions, but this
+ * can be changed with the positional option, -regextype.
+ */
+ int regex_options;
+ /* function used to get file context */
+ int (*x_getfilecon) (int, const char *, char **);
- /* How should we quote filenames in error messages and so forth?
- */
- enum quoting_style err_quoting_style;
+ /* Optimisation level. One is the default.
+ */
+ unsigned short optimisation_level;
- /* Read starting points from FILE (instead of argv). */
- const char *files0_from;
- /* True if actions like -ok, -okdir need a user confirmation via stdin. */
- bool ok_prompt_stdin;
-};
+ /* How should we quote filenames in error messages and so forth?
+ */
+ enum quoting_style err_quoting_style;
+ /* Read starting points from FILE (instead of argv). */
+ const char *files0_from;
-struct state
-{
- /* Current depth; 0 means current path is a command line arg. */
- int curdepth;
+ /* True if actions like -ok, -okdir need a user confirmation via stdin. */
+ bool ok_prompt_stdin;
+ };
- /* If true, we have called stat on the current path. */
- bool have_stat;
- /* If true, we know the type of the current path. */
- bool have_type;
- mode_t type; /* this is the actual type */
+ struct state
+ {
+ /* Current depth; 0 means current path is a command line arg. */
+ int curdepth;
- /* The file being operated on, relative to the current directory.
- Used for stat, readlink, remove, and opendir. */
- const char *rel_pathname;
+ /* If true, we have called stat on the current path. */
+ bool have_stat;
- /* The directory fd to which rel_pathname is relative. This is relevant
- * when we're navigating the hierarchy with fts() and using FTS_CWDFD.
- */
- int cwd_dir_fd;
+ /* If true, we know the type of the current path. */
+ bool have_type;
+ mode_t type; /* this is the actual type */
- /* Length of starting path. */
- int starting_path_length;
+ /* The file being operated on, relative to the current directory.
+ Used for stat, readlink, remove, and opendir. */
+ const char *rel_pathname;
- /* If true, don't descend past current directory.
- Can be set by -prune, -maxdepth, -mount and -xdev. */
- bool stop_at_current_level;
+ /* The directory fd to which rel_pathname is relative. This is relevant
+ * when we're navigating the hierarchy with fts() and using FTS_CWDFD.
+ */
+ int cwd_dir_fd;
- /* Status value to return to system. */
- int exit_status;
+ /* Length of starting path. */
+ int starting_path_length;
- /* True if there are any execdirs. This saves us a pair of fchdir()
- * calls for every directory we leave if it is false. This is just
- * an optimisation. Set to true if you want to be conservative.
- */
- bool execdirs_outstanding;
+ /* If true, don't descend past current directory.
+ Can be set by -prune, -maxdepth, -mount and -xdev. */
+ bool stop_at_current_level;
- /* Shared files, opened via the interface in sharefile.h. */
- sharefile_handle shared_files;
+ /* Status value to return to system. */
+ int exit_status;
- /* Avoid multiple error messages for the same file. */
- bool already_issued_stat_error_msg;
-};
+ /* True if there are any execdirs. This saves us a pair of fchdir()
+ * calls for every directory we leave if it is false. This is just
+ * an optimisation. Set to true if you want to be conservative.
+ */
+ bool execdirs_outstanding;
+
+ /* Shared files, opened via the interface in sharefile.h. */
+ sharefile_handle shared_files;
+
+ /* Avoid multiple error messages for the same file. */
+ bool already_issued_stat_error_msg;
+ };
/* exec.c */
-bool impl_pred_exec (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr);
-int launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv);
+ bool impl_pred_exec (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr);
+ int launch (struct buildcmd_control *ctl, void *usercontext, int argc,
+ char **argv);
/* finddata.c */
-extern struct options options;
-extern struct state state;
-extern struct saved_cwd *initial_wd;
+ extern struct options options;
+ extern struct state state;
+ extern struct saved_cwd *initial_wd;
#endif
diff --git a/find/exec.c b/find/exec.c
index 4ac5b121..d7b661f8 100644
--- a/find/exec.c
+++ b/find/exec.c
@@ -76,7 +76,7 @@ record_exec_dir (struct exec_val *execp)
We deal with this by extracting any directory part and using
that to adjust what goes into execp->wd_for_exec.
- */
+ */
if (strchr (state.rel_pathname, '/'))
{
char *dir = mdir_name (state.rel_pathname);
@@ -97,8 +97,7 @@ record_exec_dir (struct exec_val *execp)
bool
impl_pred_exec (const char *pathname,
- struct stat *stat_buf,
- struct predicate *pred_ptr)
+ struct stat *stat_buf, struct predicate *pred_ptr)
{
struct exec_val *execp = &pred_ptr->args.exec_vec;
char *buf = NULL;
@@ -114,15 +113,14 @@ impl_pred_exec (const char *pathname,
/* For -execdir/-okdir predicates, the parser did not fill in
the wd_for_exec member of struct exec_val. So for those
predicates, we do so now.
- */
+ */
if (!record_exec_dir (execp))
{
error (EXIT_FAILURE, errno,
_("Failed to save working directory in order to "
"run a command on %s"),
safely_quote_err_filename (0, pathname));
- /*NOTREACHED*/
- }
+ /*NOTREACHED*/}
target = buf = base_name (state.rel_pathname);
if ('/' == target[0])
{
@@ -142,7 +140,7 @@ impl_pred_exec (const char *pathname,
have set wd_for_exec to initial_wd, indicating
that the exec should take place from find's initial
working directory.
- */
+ */
assert (execp->wd_for_exec == initial_wd);
target = pathname;
prefix = NULL;
@@ -157,9 +155,7 @@ impl_pred_exec (const char *pathname,
*/
bc_push_arg (&execp->ctl,
&execp->state,
- target, strlen (target)+1,
- prefix, pfxlen,
- 0);
+ target, strlen (target) + 1, prefix, pfxlen, 0);
/* remember that there are pending execdirs. */
if (execp->state.todo)
@@ -174,23 +170,21 @@ impl_pred_exec (const char *pathname,
{
int i;
- for (i=0; i<execp->num_args; ++i)
+ for (i = 0; i < execp->num_args; ++i)
{
bc_do_insert (&execp->ctl,
&execp->state,
execp->replace_vec[i],
strlen (execp->replace_vec[i]),
- prefix, pfxlen,
- target, strlen (target),
- 0);
+ prefix, pfxlen, target, strlen (target), 0);
}
/* Actually invoke the command. */
bc_do_exec (&execp->ctl, &execp->state);
- if (WIFEXITED(execp->last_child_status))
+ if (WIFEXITED (execp->last_child_status))
{
- if (0 == WEXITSTATUS(execp->last_child_status))
- result = true; /* The child succeeded. */
+ if (0 == WEXITSTATUS (execp->last_child_status))
+ result = true; /* The child succeeded. */
else
result = false;
}
@@ -245,16 +239,17 @@ prep_child_for_exec (bool close_stdin, const struct saved_cwd *wd)
{
if (open (inputfile, O_RDONLY
#if defined O_LARGEFILE
- |O_LARGEFILE
+ | O_LARGEFILE
#endif
- ) < 0)
+ ) < 0)
{
/* This is not entirely fatal, since
* executing the child with a closed
* stdin is almost as good as executing it
* with its stdin attached to /dev/null.
*/
- error (0, errno, "%s", safely_quote_err_filename (0, inputfile));
+ error (0, errno, "%s",
+ safely_quote_err_filename (0, inputfile));
/* do not set ok=false, it is OK to continue anyway. */
}
}
@@ -283,7 +278,8 @@ prep_child_for_exec (bool close_stdin, const struct saved_cwd *wd)
int
-launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv)
+launch (struct buildcmd_control *ctl, void *usercontext, int argc,
+ char **argv)
{
pid_t child_pid;
static int first_time = 1;
@@ -297,7 +293,7 @@ launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv)
int i;
fprintf (stderr, "DebugExec: launching process (argc=%" PRIuMAX "):",
(uintmax_t) execp->state.cmd_argc - 1);
- for (i=0; i<execp->state.cmd_argc -1; ++i)
+ for (i = 0; i < execp->state.cmd_argc - 1; ++i)
{
fprintf (stderr, " %s",
safely_quote_err_filename (0, execp->state.cmd_argv[i]));
@@ -348,16 +344,16 @@ launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv)
else
execvp (argv[0], argv);
/* TODO: use a pipe to pass back the errno value, like xargs does */
- error (0, errno, "%s",
- safely_quote_err_filename (0, argv[0]));
+ error (0, errno, "%s", safely_quote_err_filename (0, argv[0]));
_exit (1);
}
- while (waitpid (child_pid, &(execp->last_child_status), 0) == (pid_t) -1)
+ while (waitpid (child_pid, &(execp->last_child_status), 0) == (pid_t) - 1)
{
if (errno != EINTR)
{
- error (0, errno, _("error waiting for the command we executed for %s"),
+ error (0, errno,
+ _("error waiting for the command we executed for %s"),
safely_quote_err_filename (0, argv[0]));
state.exit_status = EXIT_FAILURE;
return 0; /* FAIL */
diff --git a/find/fstype.c b/find/fstype.c
index f132f677..add952eb 100644
--- a/find/fstype.c
+++ b/find/fstype.c
@@ -55,8 +55,7 @@
#include "system.h"
static char *file_system_type_uncached (const struct stat *statp,
- const char *path,
- bool *fstype_known);
+ const char *path, bool *fstype_known);
static void
@@ -98,7 +97,7 @@ in_afs (char *path)
if (pioctl (path, VIOC_FILE_CELL_NAME, &vi, 1)
&& (errno == EINVAL || errno == ENOENT))
- return 0;
+ return 0;
return 1;
}
#endif /* AFS */
@@ -115,14 +114,14 @@ get_file_system_list (bool need_fs_type)
/* Remember if the list contains the ME_TYPE members. */
static bool has_fstype = false;
- if (mount_list && ! has_fstype && need_fs_type)
+ if (mount_list && !has_fstype && need_fs_type)
{
free_file_system_list (mount_list);
mount_list = NULL;
}
- if (! mount_list)
+ if (!mount_list)
{
- mount_list = read_file_system_list(need_fs_type);
+ mount_list = read_file_system_list (need_fs_type);
has_fstype = need_fs_type;
}
return mount_list;
@@ -154,9 +153,9 @@ filesystem_type (const struct stat *statp, const char *path)
}
bool
-is_used_fs_type(const char *name)
+is_used_fs_type (const char *name)
{
- if (0 == strcmp("afs", name))
+ if (0 == strcmp ("afs", name))
{
/* I guess AFS may not appear in /etc/mtab (or equivalent) but still be in use,
so assume we always need to check for AFS. */
@@ -164,13 +163,13 @@ is_used_fs_type(const char *name)
}
else
{
- const struct mount_entry *entries = get_file_system_list(false);
+ const struct mount_entry *entries = get_file_system_list (false);
if (entries)
{
const struct mount_entry *entry;
for (entry = entries; entry; entry = entry->me_next)
{
- if (0 == strcmp(name, entry->me_type))
+ if (0 == strcmp (name, entry->me_type))
return true;
}
}
@@ -187,10 +186,10 @@ set_fstype_devno (struct mount_entry *p)
{
struct stat stbuf;
- if (p->me_dev == (dev_t)-1)
+ if (p->me_dev == (dev_t) - 1)
{
set_stat_placeholders (&stbuf);
- if (0 == (options.xstat)(p->me_mountdir, &stbuf))
+ if (0 == (options.xstat) (p->me_mountdir, &stbuf))
{
p->me_dev = stbuf.st_dev;
return 0;
@@ -235,7 +234,7 @@ file_system_type_uncached (const struct stat *statp, const char *path,
*/
error (EXIT_FAILURE, 0, _("Cannot read mounted file system list"));
}
- for (type=NULL, entry=entries; entry; entry=entry->me_next)
+ for (type = NULL, entry = entries; entry; entry = entry->me_next)
{
#ifdef MNTTYPE_IGNORE
if (!strcmp (entry->me_type, MNTTYPE_IGNORE))
@@ -251,7 +250,7 @@ file_system_type_uncached (const struct stat *statp, const char *path,
symlink to /proc/mounts) can have duplicate entries
in the filesystem list. This happens most frequently
for /.
- */
+ */
}
}
}
@@ -287,10 +286,9 @@ get_mounted_devices (size_t *n)
* but we never need the information, there is no need to fail.
*/
for (entry = entries = read_file_system_list (false);
- entry;
- entry = entry->me_next)
+ entry; entry = entry->me_next)
{
- void *p = extendbuf (result, sizeof(dev_t)*(used+1), &alloc_size);
+ void *p = extendbuf (result, sizeof (dev_t) * (used + 1), &alloc_size);
if (p)
{
result = p;
diff --git a/find/ftsfind.c b/find/ftsfind.c
index fecc0d87..1532fc76 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -64,19 +64,23 @@
/* FTS_TIGHT_CYCLE_CHECK tries to work around Savannah bug #17877
* (but actually using it doesn't fix the bug).
*/
-static int ftsoptions = FTS_NOSTAT|FTS_TIGHT_CYCLE_CHECK|FTS_CWDFD|FTS_VERBATIM;
+static int ftsoptions =
+ FTS_NOSTAT | FTS_TIGHT_CYCLE_CHECK | FTS_CWDFD | FTS_VERBATIM;
-static int prev_depth = INT_MIN; /* fts_level can be < 0 */
+static int prev_depth = INT_MIN; /* fts_level can be < 0 */
static int curr_fd = -1;
-static bool find (char *arg) __attribute_warn_unused_result__;
-static bool process_all_startpoints (int argc, char *argv[]) __attribute_warn_unused_result__;
+static bool
+find (char *arg)
+ __attribute_warn_unused_result__;
+ static bool process_all_startpoints (int argc,
+ char *argv[])
+ __attribute_warn_unused_result__;
-static void
-left_dir (void)
+ static void left_dir (void)
{
if (ftsoptions & FTS_CWDFD)
{
@@ -148,20 +152,20 @@ get_fts_info_name (int info)
static char buf[1 + INT_BUFSIZE_BOUND (info) + 1];
switch (info)
{
- HANDLECASE(FTS_D);
- HANDLECASE(FTS_DC);
- HANDLECASE(FTS_DEFAULT);
- HANDLECASE(FTS_DNR);
- HANDLECASE(FTS_DOT);
- HANDLECASE(FTS_DP);
- HANDLECASE(FTS_ERR);
- HANDLECASE(FTS_F);
- HANDLECASE(FTS_INIT);
- HANDLECASE(FTS_NS);
- HANDLECASE(FTS_NSOK);
- HANDLECASE(FTS_SL);
- HANDLECASE(FTS_SLNONE);
- HANDLECASE(FTS_W);
+ HANDLECASE (FTS_D);
+ HANDLECASE (FTS_DC);
+ HANDLECASE (FTS_DEFAULT);
+ HANDLECASE (FTS_DNR);
+ HANDLECASE (FTS_DOT);
+ HANDLECASE (FTS_DP);
+ HANDLECASE (FTS_ERR);
+ HANDLECASE (FTS_F);
+ HANDLECASE (FTS_INIT);
+ HANDLECASE (FTS_NS);
+ HANDLECASE (FTS_NSOK);
+ HANDLECASE (FTS_SL);
+ HANDLECASE (FTS_SLNONE);
+ HANDLECASE (FTS_W);
default:
sprintf (buf, "[%d]", info);
return buf;
@@ -175,7 +179,7 @@ visit (FTS *p, FTSENT *ent, struct stat *pstat)
state.have_stat = (ent->fts_info != FTS_NS) && (ent->fts_info != FTS_NSOK);
state.rel_pathname = ent->fts_accpath;
- state.cwd_dir_fd = p->fts_cwd_fd;
+ state.cwd_dir_fd = p->fts_cwd_fd;
/* Apply the predicates to this path. */
eval_tree = get_eval_tree ();
@@ -200,12 +204,13 @@ visit (FTS *p, FTSENT *ent, struct stat *pstat)
* will skip that directory entry.
*/
static void
-issue_loop_warning (FTSENT * ent)
+issue_loop_warning (FTSENT *ent)
{
- if (S_ISLNK(ent->fts_statp->st_mode))
+ if (S_ISLNK (ent->fts_statp->st_mode))
{
error (0, 0,
- _("Symbolic link %s is part of a loop in the directory hierarchy; we have already visited the directory to which it points."),
+ _
+ ("Symbolic link %s is part of a loop in the directory hierarchy; we have already visited the directory to which it points."),
safely_quote_err_filename (0, ent->fts_path));
}
else
@@ -254,15 +259,16 @@ consider_visiting (FTS *p, FTSENT *ent)
"fts_path=%s, fts_accpath=%s\n",
quotearg_n_style (0, options.err_quoting_style, ent->fts_path),
get_fts_info_name (ent->fts_info),
- (int)ent->fts_level, prev_depth,
+ (int) ent->fts_level, prev_depth,
quotearg_n_style (1, options.err_quoting_style, ent->fts_path),
- quotearg_n_style (2, options.err_quoting_style, ent->fts_accpath));
+ quotearg_n_style (2, options.err_quoting_style,
+ ent->fts_accpath));
if (ent->fts_info == FTS_DP)
{
left_dir ();
}
- else if (ent->fts_level > prev_depth || ent->fts_level==0)
+ else if (ent->fts_level > prev_depth || ent->fts_level == 0)
{
left_dir ();
}
@@ -333,9 +339,9 @@ consider_visiting (FTS *p, FTSENT *ent)
}
else
{
- /* Ignore ENOENT error for vanished files. */
- if (ENOENT == ent->fts_errno && options.ignore_readdir_race)
- return;
+ /* Ignore ENOENT error for vanished files. */
+ if (ENOENT == ent->fts_errno && options.ignore_readdir_race)
+ return;
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
/* Continue despite the error, as file name without stat info
@@ -355,7 +361,7 @@ consider_visiting (FTS *p, FTSENT *ent)
/* Cope with the usual cases. */
if (ent->fts_info == FTS_NSOK
- || ent->fts_info == FTS_NS /* e.g. symlink loop */)
+ || ent->fts_info == FTS_NS /* e.g. symlink loop */ )
{
assert (!state.have_stat);
assert (ent->fts_info == FTS_NSOK || state.type == 0);
@@ -372,7 +378,8 @@ consider_visiting (FTS *p, FTSENT *ent)
{
/* Savannah bug #16378. */
error (0, 0, _("WARNING: file %s appears to have mode 0000"),
- quotearg_n_style (0, options.err_quoting_style, ent->fts_path));
+ quotearg_n_style (0, options.err_quoting_style,
+ ent->fts_path));
}
}
@@ -388,10 +395,9 @@ consider_visiting (FTS *p, FTSENT *ent)
/* examine this item. */
ignore = 0;
- isdir = S_ISDIR(mode)
- || (FTS_D == ent->fts_info)
- || (FTS_DP == ent->fts_info)
- || (FTS_DC == ent->fts_info);
+ isdir = S_ISDIR (mode)
+ || (FTS_D == ent->fts_info)
+ || (FTS_DP == ent->fts_info) || (FTS_DC == ent->fts_info);
if (isdir && (ent->fts_info == FTS_NSOK))
{
@@ -408,19 +414,19 @@ consider_visiting (FTS *p, FTSENT *ent)
{
if (ent->fts_level >= options.maxdepth)
{
- fts_set (p, ent, FTS_SKIP); /* descend no further */
+ fts_set (p, ent, FTS_SKIP); /* descend no further */
if (ent->fts_level > options.maxdepth)
ignore = 1; /* don't even look at this one */
}
}
- if ( (ent->fts_info == FTS_D) && !options.do_dir_first )
+ if ((ent->fts_info == FTS_D) && !options.do_dir_first)
{
/* this is the preorder visit, but user said -depth */
ignore = 1;
}
- else if ( (ent->fts_info == FTS_DP) && options.do_dir_first )
+ else if ((ent->fts_info == FTS_DP) && options.do_dir_first)
{
/* this is the postorder visit, but user didn't say -depth */
ignore = 1;
@@ -455,7 +461,7 @@ consider_visiting (FTS *p, FTSENT *ent)
static bool
find (char *arg)
{
- char * arglist[2];
+ char *arglist[2];
FTS *p;
FTSENT *ent;
@@ -468,11 +474,11 @@ find (char *arg)
switch (options.symlink_handling)
{
case SYMLINK_ALWAYS_DEREF:
- ftsoptions |= FTS_COMFOLLOW|FTS_LOGICAL;
+ ftsoptions |= FTS_COMFOLLOW | FTS_LOGICAL;
break;
case SYMLINK_DEREF_ARGSONLY:
- ftsoptions |= FTS_COMFOLLOW|FTS_PHYSICAL;
+ ftsoptions |= FTS_COMFOLLOW | FTS_PHYSICAL;
break;
case SYMLINK_NEVER_DEREF:
@@ -497,9 +503,9 @@ find (char *arg)
{
int level = INT_MIN;
- while ( (errno=0, ent=fts_read (p)) != NULL )
+ while ((errno = 0, ent = fts_read (p)) != NULL)
{
- if (state.execdirs_outstanding && ((int)ent->fts_level != level))
+ if (state.execdirs_outstanding && ((int) ent->fts_level != level))
{
/* If we changed level, perform any outstanding
* execdirs. If we see a sequence of directory entries
@@ -510,7 +516,7 @@ find (char *arg)
*/
complete_pending_execdirs ();
}
- level = (int)ent->fts_level;
+ level = (int) ent->fts_level;
state.already_issued_stat_error_msg = false;
state.have_stat = false;
@@ -550,10 +556,11 @@ static bool
process_all_startpoints (int argc, char *argv[])
{
/* Did the user pass starting points on the command line? */
- bool argv_starting_points = 0 < argc && !looks_like_expression (argv[0], true);
+ bool argv_starting_points = 0 < argc
+ && !looks_like_expression (argv[0], true);
FILE *stream = NULL;
- char const* files0_filename_quoted = NULL;
+ char const *files0_filename_quoted = NULL;
struct argv_iterator *ai;
if (options.files0_from)
@@ -562,9 +569,10 @@ process_all_startpoints (int argc, char *argv[])
* on the command line. */
if (argv_starting_points)
{
- error (0, 0, _("extra operand %s"), safely_quote_err_filename (0, argv[0]));
+ error (0, 0, _("extra operand %s"),
+ safely_quote_err_filename (0, argv[0]));
error (EXIT_FAILURE, 0,
- _("file operands cannot be combined with -files0-from"));
+ _("file operands cannot be combined with -files0-from"));
}
if (0 == strcmp (options.files0_from, "-"))
@@ -575,14 +583,17 @@ process_all_startpoints (int argc, char *argv[])
if (options.ok_prompt_stdin)
{
error (EXIT_FAILURE, 0,
- _("when -ok or -okdir is in use, the option -files0-from cannot also read from standard input"));
+ _
+ ("when -ok or -okdir is in use, the option -files0-from cannot also read from standard input"));
}
- files0_filename_quoted = safely_quote_err_filename (0, _("(standard input)"));
+ files0_filename_quoted =
+ safely_quote_err_filename (0, _("(standard input)"));
stream = stdin;
}
else
{
- files0_filename_quoted = safely_quote_err_filename (0, options.files0_from);
+ files0_filename_quoted =
+ safely_quote_err_filename (0, options.files0_from);
stream = fopen (options.files0_from, "r");
if (stream == NULL)
{
@@ -603,15 +614,16 @@ process_all_startpoints (int argc, char *argv[])
*/
struct stat sb1, sb2;
if (fstat (fd, &sb1) == 0 && fstat (STDIN_FILENO, &sb2) == 0
- && SAME_INODE (sb1, sb2))
+ && SAME_INODE (sb1, sb2))
{
error (EXIT_FAILURE, 0,
- _("when -ok or -okdir is in use, the option -files0-from cannot also read from standard input, but the file (%s) used for -files0-from appears to refer to the same file as the standard input"),
+ _
+ ("when -ok or -okdir is in use, the option -files0-from cannot also read from standard input, but the file (%s) used for -files0-from appears to refer to the same file as the standard input"),
files0_filename_quoted);
}
}
set_cloexec_flag (fd, true);
- }
+ }
ai = argv_iter_init_stream (stream);
}
else
@@ -647,7 +659,7 @@ process_all_startpoints (int argc, char *argv[])
{
case AI_ERR_EOF:
goto argv_iter_done;
- case AI_ERR_READ: /* may only happen with -files0-from */
+ case AI_ERR_READ: /* may only happen with -files0-from */
error (0, errno, _("%s: read error"), files0_filename_quoted);
state.exit_status = EXIT_FAILURE;
ok = false;
@@ -687,14 +699,14 @@ process_all_startpoints (int argc, char *argv[])
if (!options.files0_from && looks_like_expression (file_name, true))
break;
- state.starting_path_length = strlen (file_name); /* TODO: is this redundant? */
+ state.starting_path_length = strlen (file_name); /* TODO: is this redundant? */
if (!find (file_name))
{
ok = false;
goto argv_iter_done;
}
}
- argv_iter_done:
+argv_iter_done:
argv_iter_free (ai);
@@ -710,7 +722,7 @@ process_all_startpoints (int argc, char *argv[])
int
main (int argc, char **argv)
{
- int end_of_leading_options = 0; /* First arg after any -H/-L etc. */
+ int end_of_leading_options = 0; /* First arg after any -H/-L etc. */
struct predicate *eval_tree;
if (argv[0])
@@ -761,7 +773,8 @@ main (int argc, char **argv)
if (options.debug_options & DebugTime)
- fprintf (stderr, "cur_day_start = %s", ctime (&options.cur_day_start.tv_sec));
+ fprintf (stderr, "cur_day_start = %s",
+ ctime (&options.cur_day_start.tv_sec));
/* We are now processing the part of the "find" command line
@@ -793,8 +806,8 @@ main (int argc, char **argv)
* be safe to call cleanup() since we might complete an execdir in
* the wrong directory for example.
*/
- if (process_all_startpoints (argc-end_of_leading_options,
- argv+end_of_leading_options))
+ if (process_all_startpoints (argc - end_of_leading_options,
+ argv + end_of_leading_options))
{
/* If "-exec ... {} +" has been used, there may be some
* partially-full command lines which have been built,
diff --git a/find/parser.c b/find/parser.c
index 9847ad7d..dec494c3 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -86,233 +86,300 @@
# define isnan(x) ((x) != (x))
#endif
-static bool parse_accesscheck (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_amin (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_and (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_anewer (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_cmin (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_cnewer (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_comma (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_daystart (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_delete (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_d (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_depth (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_empty (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_exec (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_execdir (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_false (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_files0_from (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_fls (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_fprintf (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_follow (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_fprint (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_fprint0 (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_fstype (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_gid (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_group (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_ilname (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_iname (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_inum (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_ipath (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_iregex (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_iwholename (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_links (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_lname (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_ls (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_maxdepth (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_mindepth (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_mmin (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_mount (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_name (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_negate (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_newer (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_newerXY (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_noleaf (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_nogroup (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_nouser (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_nowarn (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_ok (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_okdir (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_or (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_path (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_perm (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_print0 (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_printf (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_prune (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_regex (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_regextype (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_samefile (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_size (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_time (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_true (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_type (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_uid (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_used (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_user (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_wholename (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_xdev (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_ignore_race (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_noignore_race (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_warn (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_xtype (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_quit (const struct parser_table*, char *argv[], int *arg_ptr);
-static bool parse_context (const struct parser_table*, char *argv[], int *arg_ptr);
-
-static bool parse_help (const struct parser_table* entry, char **argv, int *arg_ptr)
- _GL_ATTRIBUTE_NORETURN;
-static bool parse_version (const struct parser_table*, char *argv[], int *arg_ptr)
- _GL_ATTRIBUTE_NORETURN;
-
-
-static bool insert_type (char **argv, int *arg_ptr,
- const struct parser_table *entry,
- PRED_FUNC which_pred);
-static bool insert_regex (char *argv[], int *arg_ptr,
- const struct parser_table *entry,
- int regex_options);
-static bool insert_exec_ok (const char *action,
- const struct parser_table *entry,
- char *argv[],
+static bool parse_accesscheck (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_amin (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_and (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_anewer (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_cmin (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_cnewer (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_comma (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_daystart (const struct parser_table *, char *argv[],
int *arg_ptr);
-static bool get_comp_type (const char **str,
- enum comparison_type *comp_type);
-static bool get_relative_timestamp (const char *str,
- struct time_val *tval,
- struct timespec origin,
- double sec_per_unit,
- const char *overflowmessage);
-static bool get_num (const char *str,
- uintmax_t *num,
- enum comparison_type *comp_type);
-static struct predicate* insert_num (char *argv[], int *arg_ptr,
- const struct parser_table *entry);
-static void open_output_file (const char *path, struct format_val *p);
-static void open_stdout (struct format_val *p);
-static bool stream_is_tty(FILE *fp);
-static bool parse_noop (const struct parser_table* entry,
- char **argv, int *arg_ptr);
+static bool parse_delete (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_d (const struct parser_table *, char *argv[], int *arg_ptr);
+static bool parse_depth (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_empty (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_exec (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_execdir (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_false (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_files0_from (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_fls (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_fprintf (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_follow (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_fprint (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_fprint0 (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_fstype (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_gid (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_group (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_ilname (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_iname (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_inum (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_ipath (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_iregex (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_iwholename (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_links (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_lname (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_ls (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_maxdepth (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_mindepth (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_mmin (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_mount (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_name (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_negate (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_newer (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_newerXY (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_noleaf (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_nogroup (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_nouser (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_nowarn (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_ok (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_okdir (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_or (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_path (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_perm (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_print0 (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_printf (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_prune (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_regex (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_regextype (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_samefile (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_size (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_time (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_true (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_type (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_uid (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_used (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_user (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_wholename (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_xdev (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_ignore_race (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_noignore_race (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_warn (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_xtype (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_quit (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+static bool parse_context (const struct parser_table *, char *argv[],
+ int *arg_ptr);
+
+static bool
+parse_help (const struct parser_table *entry, char **argv, int *arg_ptr)
+ _GL_ATTRIBUTE_NORETURN;
+ static bool parse_version (const struct parser_table *, char *argv[],
+ int *arg_ptr) _GL_ATTRIBUTE_NORETURN;
+
+
+ static bool insert_type (char **argv, int *arg_ptr,
+ const struct parser_table *entry,
+ PRED_FUNC which_pred);
+ static bool insert_regex (char *argv[], int *arg_ptr,
+ const struct parser_table *entry,
+ int regex_options);
+ static bool insert_exec_ok (const char *action,
+ const struct parser_table *entry,
+ char *argv[], int *arg_ptr);
+ static bool get_comp_type (const char **str,
+ enum comparison_type *comp_type);
+ static bool get_relative_timestamp (const char *str,
+ struct time_val *tval,
+ struct timespec origin,
+ double sec_per_unit,
+ const char *overflowmessage);
+ static bool get_num (const char *str,
+ uintmax_t *num, enum comparison_type *comp_type);
+ static struct predicate *insert_num (char *argv[], int *arg_ptr,
+ const struct parser_table *entry);
+ static void open_output_file (const char *path, struct format_val *p);
+ static void open_stdout (struct format_val *p);
+ static bool stream_is_tty (FILE *fp);
+ static bool parse_noop (const struct parser_table *entry,
+ char **argv, int *arg_ptr);
/* Predicates we cannot handle in the usual way. If you add an entry
* to this table, double-check the switch statement in
* pred_sanity_check() to make sure that the new case is being
* correctly handled.
*/
-static struct parser_table const parse_entry_newerXY =
- {
- ARG_SPECIAL_PARSE, "newerXY", parse_newerXY, pred_newerXY /* BSD */
- };
+ static struct parser_table const parse_entry_newerXY = {
+ ARG_SPECIAL_PARSE, "newerXY", parse_newerXY, pred_newerXY /* BSD */
+ };
/* GNU find predicates that are not mentioned in POSIX are marked `GNU'.
If they are in some Unix versions of find, they are marked `Unix'. */
-static struct parser_table const parse_table[] =
-{
+static struct parser_table const parse_table[] = {
/* Regular options: no PRED function. */
- { ARG_OPTION, "d", parse_d, NULL }, /* Mac OS X, FreeBSD, NetBSD, OpenBSD */
- /* but deprecated in favour of -depth */
- { ARG_OPTION, "depth", parse_depth, NULL }, /* POSIX */
- { ARG_OPTION, "files0-from", parse_files0_from, NULL }, /* GNU */
- { ARG_OPTION, "ignore_readdir_race", parse_ignore_race, NULL }, /* GNU */
- { ARG_OPTION, "maxdepth", parse_maxdepth, NULL }, /* GNU */
- { ARG_OPTION, "mindepth", parse_mindepth, NULL }, /* GNU */
- { ARG_OPTION, "mount", parse_mount, NULL }, /* POSIX */
- { ARG_OPTION, "noleaf", parse_noleaf, NULL }, /* GNU */
- { ARG_OPTION, "noignore_readdir_race", parse_noignore_race, NULL }, /* GNU */
- { ARG_OPTION, "xdev", parse_xdev, NULL }, /* POSIX */
+ {ARG_OPTION, "d", parse_d, NULL}, /* Mac OS X, FreeBSD, NetBSD, OpenBSD */
+ /* but deprecated in favour of -depth */
+ {ARG_OPTION, "depth", parse_depth, NULL}, /* POSIX */
+ {ARG_OPTION, "files0-from", parse_files0_from, NULL}, /* GNU */
+ {ARG_OPTION, "ignore_readdir_race", parse_ignore_race, NULL}, /* GNU */
+ {ARG_OPTION, "maxdepth", parse_maxdepth, NULL}, /* GNU */
+ {ARG_OPTION, "mindepth", parse_mindepth, NULL}, /* GNU */
+ {ARG_OPTION, "mount", parse_mount, NULL}, /* POSIX */
+ {ARG_OPTION, "noleaf", parse_noleaf, NULL}, /* GNU */
+ {ARG_OPTION, "noignore_readdir_race", parse_noignore_race, NULL}, /* GNU */
+ {ARG_OPTION, "xdev", parse_xdev, NULL}, /* POSIX */
/* GNU mandated, general options. */
- { ARG_OPTION, "help", parse_help, NULL }, /* GNU */
- { ARG_OPTION, "-help", parse_help, NULL }, /* GNU */
- { ARG_OPTION, "version", parse_version, NULL }, /* GNU */
- { ARG_OPTION, "-version", parse_version, NULL }, /* GNU */
+ {ARG_OPTION, "help", parse_help, NULL}, /* GNU */
+ {ARG_OPTION, "-help", parse_help, NULL}, /* GNU */
+ {ARG_OPTION, "version", parse_version, NULL}, /* GNU */
+ {ARG_OPTION, "-version", parse_version, NULL}, /* GNU */
/* Positional options (whose position is important). */
- { ARG_POSITIONAL_OPTION, "daystart", parse_daystart, NULL }, /* GNU */
- { ARG_POSITIONAL_OPTION, "follow", parse_follow, NULL }, /* GNU, Unix */
- { ARG_POSITIONAL_OPTION, "nowarn", parse_nowarn, NULL }, /* GNU */
- { ARG_POSITIONAL_OPTION, "regextype", parse_regextype, NULL }, /* GNU */
- { ARG_POSITIONAL_OPTION, "warn", parse_warn, NULL }, /* GNU */
+ {ARG_POSITIONAL_OPTION, "daystart", parse_daystart, NULL}, /* GNU */
+ {ARG_POSITIONAL_OPTION, "follow", parse_follow, NULL}, /* GNU, Unix */
+ {ARG_POSITIONAL_OPTION, "nowarn", parse_nowarn, NULL}, /* GNU */
+ {ARG_POSITIONAL_OPTION, "regextype", parse_regextype, NULL}, /* GNU */
+ {ARG_POSITIONAL_OPTION, "warn", parse_warn, NULL}, /* GNU */
/* Punctuation. */
- { ARG_PUNCTUATION, "!", parse_negate, pred_negate }, /* POSIX */
- { ARG_PUNCTUATION, "not", parse_negate, pred_negate }, /* GNU */
- { ARG_PUNCTUATION, "(", parse_openparen, pred_openparen }, /* POSIX */
- { ARG_PUNCTUATION, ")", parse_closeparen, pred_closeparen }, /* POSIX */
- { ARG_PUNCTUATION, ",", parse_comma, pred_comma }, /* GNU */
- { ARG_PUNCTUATION, "a", parse_and, pred_and }, /* POSIX */
- { ARG_PUNCTUATION, "and", parse_and, pred_and }, /* GNU */
- { ARG_PUNCTUATION, "o", parse_or, pred_or }, /* POSIX */
- { ARG_PUNCTUATION, "or", parse_or, pred_or }, /* GNU */
+ {ARG_PUNCTUATION, "!", parse_negate, pred_negate}, /* POSIX */
+ {ARG_PUNCTUATION, "not", parse_negate, pred_negate}, /* GNU */
+ {ARG_PUNCTUATION, "(", parse_openparen, pred_openparen}, /* POSIX */
+ {ARG_PUNCTUATION, ")", parse_closeparen, pred_closeparen}, /* POSIX */
+ {ARG_PUNCTUATION, ",", parse_comma, pred_comma}, /* GNU */
+ {ARG_PUNCTUATION, "a", parse_and, pred_and}, /* POSIX */
+ {ARG_PUNCTUATION, "and", parse_and, pred_and}, /* GNU */
+ {ARG_PUNCTUATION, "o", parse_or, pred_or}, /* POSIX */
+ {ARG_PUNCTUATION, "or", parse_or, pred_or}, /* GNU */
/* Tests. */
- { ARG_TEST, "amin", parse_amin, pred_amin }, /* GNU */
- { ARG_TEST, "anewer", parse_anewer, pred_anewer }, /* GNU */
- { ARG_TEST, "atime", parse_time, pred_atime }, /* POSIX */
- { ARG_TEST, "cmin", parse_cmin, pred_cmin }, /* GNU */
- { ARG_TEST, "cnewer", parse_cnewer, pred_cnewer }, /* GNU */
- { ARG_TEST, "ctime", parse_time, pred_ctime }, /* POSIX */
- { ARG_TEST, "context", parse_context, pred_context }, /* GNU */
- { ARG_TEST, "empty", parse_empty, pred_empty }, /* GNU */
- { ARG_TEST, "executable", parse_accesscheck, pred_executable }, /* GNU, 4.3.0+ */
- { ARG_TEST, "false", parse_false, pred_false }, /* GNU */
- { ARG_TEST, "fstype", parse_fstype, pred_fstype }, /* GNU, Unix */
- { ARG_TEST, "gid", parse_gid, pred_gid }, /* GNU */
- { ARG_TEST, "group", parse_group, pred_group }, /* POSIX */
- { ARG_TEST, "ilname", parse_ilname, pred_ilname }, /* GNU */
- { ARG_TEST, "iname", parse_iname, pred_iname }, /* GNU */
- { ARG_TEST, "inum", parse_inum, pred_inum }, /* GNU, Unix */
- { ARG_TEST, "ipath", parse_ipath, pred_ipath }, /* GNU */
- { ARG_TEST, "iregex", parse_iregex, pred_regex }, /* GNU */
- { ARG_TEST, "iwholename", parse_iwholename, pred_ipath }, /* GNU */
- { ARG_TEST, "links", parse_links, pred_links }, /* POSIX */
- { ARG_TEST, "lname", parse_lname, pred_lname }, /* GNU */
- { ARG_TEST, "mmin", parse_mmin, pred_mmin }, /* GNU */
- { ARG_TEST, "mtime", parse_time, pred_mtime }, /* POSIX */
- { ARG_TEST, "name", parse_name, pred_name }, /* POSIX */
- { ARG_TEST, "newer", parse_newer, pred_newer }, /* POSIX */
- { ARG_TEST, "nogroup", parse_nogroup, pred_nogroup }, /* POSIX */
- { ARG_TEST, "nouser", parse_nouser, pred_nouser }, /* POSIX */
- { ARG_TEST, "path", parse_path, pred_path }, /* POSIX */
- { ARG_TEST, "perm", parse_perm, pred_perm }, /* POSIX */
- { ARG_TEST, "readable", parse_accesscheck, pred_readable }, /* GNU, 4.3.0+ */
- { ARG_TEST, "regex", parse_regex, pred_regex }, /* GNU */
- { ARG_TEST, "samefile", parse_samefile, pred_samefile }, /* GNU */
- { ARG_TEST, "size", parse_size, pred_size }, /* POSIX */
- { ARG_TEST, "true", parse_true, pred_true }, /* GNU */
- { ARG_TEST, "type", parse_type, pred_type }, /* POSIX */
- { ARG_TEST, "uid", parse_uid, pred_uid }, /* GNU */
- { ARG_TEST, "used", parse_used, pred_used }, /* GNU */
- { ARG_TEST, "user", parse_user, pred_user }, /* POSIX */
- { ARG_TEST, "wholename", parse_wholename, pred_path }, /* GNU, replaced -path, but now -path is standardized since POSIX 2008 */
- { ARG_TEST, "writable", parse_accesscheck, pred_writable }, /* GNU, 4.3.0+ */
- { ARG_TEST, "xtype", parse_xtype, pred_xtype }, /* GNU */
+ {ARG_TEST, "amin", parse_amin, pred_amin}, /* GNU */
+ {ARG_TEST, "anewer", parse_anewer, pred_anewer}, /* GNU */
+ {ARG_TEST, "atime", parse_time, pred_atime}, /* POSIX */
+ {ARG_TEST, "cmin", parse_cmin, pred_cmin}, /* GNU */
+ {ARG_TEST, "cnewer", parse_cnewer, pred_cnewer}, /* GNU */
+ {ARG_TEST, "ctime", parse_time, pred_ctime}, /* POSIX */
+ {ARG_TEST, "context", parse_context, pred_context}, /* GNU */
+ {ARG_TEST, "empty", parse_empty, pred_empty}, /* GNU */
+ {ARG_TEST, "executable", parse_accesscheck, pred_executable}, /* GNU, 4.3.0+ */
+ {ARG_TEST, "false", parse_false, pred_false}, /* GNU */
+ {ARG_TEST, "fstype", parse_fstype, pred_fstype}, /* GNU, Unix */
+ {ARG_TEST, "gid", parse_gid, pred_gid}, /* GNU */
+ {ARG_TEST, "group", parse_group, pred_group}, /* POSIX */
+ {ARG_TEST, "ilname", parse_ilname, pred_ilname}, /* GNU */
+ {ARG_TEST, "iname", parse_iname, pred_iname}, /* GNU */
+ {ARG_TEST, "inum", parse_inum, pred_inum}, /* GNU, Unix */
+ {ARG_TEST, "ipath", parse_ipath, pred_ipath}, /* GNU */
+ {ARG_TEST, "iregex", parse_iregex, pred_regex}, /* GNU */
+ {ARG_TEST, "iwholename", parse_iwholename, pred_ipath}, /* GNU */
+ {ARG_TEST, "links", parse_links, pred_links}, /* POSIX */
+ {ARG_TEST, "lname", parse_lname, pred_lname}, /* GNU */
+ {ARG_TEST, "mmin", parse_mmin, pred_mmin}, /* GNU */
+ {ARG_TEST, "mtime", parse_time, pred_mtime}, /* POSIX */
+ {ARG_TEST, "name", parse_name, pred_name}, /* POSIX */
+ {ARG_TEST, "newer", parse_newer, pred_newer}, /* POSIX */
+ {ARG_TEST, "nogroup", parse_nogroup, pred_nogroup}, /* POSIX */
+ {ARG_TEST, "nouser", parse_nouser, pred_nouser}, /* POSIX */
+ {ARG_TEST, "path", parse_path, pred_path}, /* POSIX */
+ {ARG_TEST, "perm", parse_perm, pred_perm}, /* POSIX */
+ {ARG_TEST, "readable", parse_accesscheck, pred_readable}, /* GNU, 4.3.0+ */
+ {ARG_TEST, "regex", parse_regex, pred_regex}, /* GNU */
+ {ARG_TEST, "samefile", parse_samefile, pred_samefile}, /* GNU */
+ {ARG_TEST, "size", parse_size, pred_size}, /* POSIX */
+ {ARG_TEST, "true", parse_true, pred_true}, /* GNU */
+ {ARG_TEST, "type", parse_type, pred_type}, /* POSIX */
+ {ARG_TEST, "uid", parse_uid, pred_uid}, /* GNU */
+ {ARG_TEST, "used", parse_used, pred_used}, /* GNU */
+ {ARG_TEST, "user", parse_user, pred_user}, /* POSIX */
+ {ARG_TEST, "wholename", parse_wholename, pred_path}, /* GNU, replaced -path, but now -path is standardized since POSIX 2008 */
+ {ARG_TEST, "writable", parse_accesscheck, pred_writable}, /* GNU, 4.3.0+ */
+ {ARG_TEST, "xtype", parse_xtype, pred_xtype}, /* GNU */
/* Actions. */
- { ARG_ACTION, "delete", parse_delete, pred_delete }, /* GNU, Mac OS, FreeBSD */
- { ARG_ACTION, "exec", parse_exec, pred_exec }, /* POSIX */
- { ARG_ACTION, "execdir", parse_execdir, pred_execdir }, /* *BSD, GNU */
- { ARG_ACTION, "fls", parse_fls, pred_fls }, /* GNU */
- { ARG_ACTION, "fprint", parse_fprint, pred_fprint }, /* GNU */
- { ARG_ACTION, "fprint0", parse_fprint0, pred_fprint0 }, /* GNU */
- { ARG_ACTION, "fprintf", parse_fprintf, pred_fprintf }, /* GNU */
- { ARG_ACTION, "ls", parse_ls, pred_ls }, /* GNU, Unix */
- { ARG_ACTION, "ok", parse_ok, pred_ok }, /* POSIX */
- { ARG_ACTION, "okdir", parse_okdir, pred_okdir }, /* GNU (-execdir is BSD) */
- { ARG_ACTION, "print", parse_print, pred_print }, /* POSIX */
- { ARG_ACTION, "print0", parse_print0, pred_print0 }, /* GNU */
- { ARG_ACTION, "printf", parse_printf, pred_fprintf }, /* GNU */
- { ARG_ACTION, "prune", parse_prune, pred_prune }, /* POSIX */
- { ARG_ACTION, "quit", parse_quit, pred_quit }, /* GNU */
+ {ARG_ACTION, "delete", parse_delete, pred_delete}, /* GNU, Mac OS, FreeBSD */
+ {ARG_ACTION, "exec", parse_exec, pred_exec}, /* POSIX */
+ {ARG_ACTION, "execdir", parse_execdir, pred_execdir}, /* *BSD, GNU */
+ {ARG_ACTION, "fls", parse_fls, pred_fls}, /* GNU */
+ {ARG_ACTION, "fprint", parse_fprint, pred_fprint}, /* GNU */
+ {ARG_ACTION, "fprint0", parse_fprint0, pred_fprint0}, /* GNU */
+ {ARG_ACTION, "fprintf", parse_fprintf, pred_fprintf}, /* GNU */
+ {ARG_ACTION, "ls", parse_ls, pred_ls}, /* GNU, Unix */
+ {ARG_ACTION, "ok", parse_ok, pred_ok}, /* POSIX */
+ {ARG_ACTION, "okdir", parse_okdir, pred_okdir}, /* GNU (-execdir is BSD) */
+ {ARG_ACTION, "print", parse_print, pred_print}, /* POSIX */
+ {ARG_ACTION, "print0", parse_print0, pred_print0}, /* GNU */
+ {ARG_ACTION, "printf", parse_printf, pred_fprintf}, /* GNU */
+ {ARG_ACTION, "prune", parse_prune, pred_prune}, /* POSIX */
+ {ARG_ACTION, "quit", parse_quit, pred_quit}, /* GNU */
#ifdef UNIMPLEMENTED_UNIX
/* It's pretty ugly for find to know about archive formats.
Plus what it could do with cpio/ncpio archives is very limited.
Better to leave it out. */
- "ncpio", /* Unix */
- "cpio", /* Unix */
+ "ncpio", /* Unix */
+ "cpio", /* Unix */
#endif
/* Internal pseudo-option, therefore 3 minus: ---noop. */
- { ARG_NOOP, "--noop", NULL, pred_true }, /* GNU, internal use only */
+ {ARG_NOOP, "--noop", NULL, pred_true}, /* GNU, internal use only */
{0, NULL, NULL, NULL}
};
@@ -329,24 +396,25 @@ fallback_getfilecon (int fd, const char *name, char **p, int prev_rv)
* Otherwise, admit defeat. */
switch (errno)
{
- case ENOENT:
- case ENOTDIR:
- if (options.debug_options & DebugStat)
- {
- fprintf (stderr, "fallback_getfilecon(): getfilecon(%s) failed; falling "
- "back on lgetfilecon()\n", name);
- }
- return lgetfileconat (fd, name, p);
-
- case EACCES:
- case EIO:
- case ELOOP:
- case ENAMETOOLONG:
+ case ENOENT:
+ case ENOTDIR:
+ if (options.debug_options & DebugStat)
+ {
+ fprintf (stderr,
+ "fallback_getfilecon(): getfilecon(%s) failed; falling "
+ "back on lgetfilecon()\n", name);
+ }
+ return lgetfileconat (fd, name, p);
+
+ case EACCES:
+ case EIO:
+ case ELOOP:
+ case ENAMETOOLONG:
#ifdef EOVERFLOW
- case EOVERFLOW: /* EOVERFLOW is not #defined on UNICOS. */
+ case EOVERFLOW: /* EOVERFLOW is not #defined on UNICOS. */
#endif
- default:
- return prev_rv;
+ default:
+ return prev_rv;
}
}
@@ -388,7 +456,7 @@ optionl_getfilecon (int fd, const char *name, char **p)
{
int rv = getfileconat (fd, name, p);
if (0 == rv)
- return 0; /* normal case. */
+ return 0; /* normal case. */
else
return fallback_getfilecon (fd, name, p, rv);
}
@@ -405,7 +473,8 @@ optionp_getfilecon (int fd, const char *name, char **p)
void
check_option_combinations (const struct predicate *p)
{
- enum { seen_delete=1u, seen_prune=2u };
+ enum
+ { seen_delete = 1u, seen_prune = 2u };
unsigned int predicates = 0u;
while (p)
@@ -446,7 +515,7 @@ check_option_combinations (const struct predicate *p)
}
-static const struct parser_table*
+static const struct parser_table *
get_noop (void)
{
int i;
@@ -454,7 +523,7 @@ get_noop (void)
{
for (i = 0; parse_table[i].parser_name != NULL; i++)
{
- if (ARG_NOOP ==parse_table[i].type)
+ if (ARG_NOOP == parse_table[i].type)
{
noop = &(parse_table[i]);
break;
@@ -465,9 +534,7 @@ get_noop (void)
}
static int
-get_stat_Ytime (const struct stat *p,
- char what,
- struct timespec *ret)
+get_stat_Ytime (const struct stat *p, char what, struct timespec *ret)
{
switch (what)
{
@@ -508,7 +575,7 @@ set_follow_state (enum SymlinkOption opt)
*/
break;
- case SYMLINK_DEREF_ARGSONLY: /* -H */
+ case SYMLINK_DEREF_ARGSONLY: /* -H */
options.xstat = optionh_stat;
options.x_getfilecon = optionh_getfilecon;
options.no_leaf_check = true;
@@ -563,7 +630,7 @@ should_issue_warnings (void)
/* Check that it is legal to find the given primary in its
* position and return it.
*/
-static const struct parser_table*
+static const struct parser_table *
found_parser (const char *original_arg, const struct parser_table *entry)
{
/* If this is an option, but we have already had a
@@ -582,7 +649,7 @@ found_parser (const char *original_arg, const struct parser_table *entry)
if (entry->type != ARG_POSITIONAL_OPTION)
{
if (entry->type == ARG_NOOP)
- return NULL; /* internal use only, trap -noop here. */
+ return NULL; /* internal use only, trap -noop here. */
/* Something other than -follow/-daystart.
* If this is an option, check if it followed
@@ -590,8 +657,7 @@ found_parser (const char *original_arg, const struct parser_table *entry)
*/
if (entry->type == ARG_OPTION)
{
- if ((first_nonoption_arg != NULL)
- && should_issue_warnings ())
+ if ((first_nonoption_arg != NULL) && should_issue_warnings ())
{
/* option which follows a non-option */
error (0, 0,
@@ -600,9 +666,7 @@ found_parser (const char *original_arg, const struct parser_table *entry)
"positional, i.e., %s affects tests specified before it "
"as well as those specified after it. "
"Please specify global options before other arguments."),
- original_arg,
- first_nonoption_arg,
- original_arg);
+ original_arg, first_nonoption_arg, original_arg);
}
}
else
@@ -626,15 +690,14 @@ found_parser (const char *original_arg, const struct parser_table *entry)
SEARCH_NAME.
Return NULL if SEARCH_NAME is not a valid predicate name. */
-const struct parser_table*
+const struct parser_table *
find_parser (const char *search_name)
{
int i;
const char *original_arg = search_name;
/* Ugh. Special case -newerXY. */
- if (0 == strncmp ("-newer", search_name, 6)
- && (8 == strlen (search_name)))
+ if (0 == strncmp ("-newer", search_name, 6) && (8 == strlen (search_name)))
{
return found_parser (original_arg, &parse_entry_newerXY);
}
@@ -648,16 +711,16 @@ find_parser (const char *search_name)
{
/* FIXME >4.11: fix parser to disallow dashed operators like '-!'.
* Meanwhile, issue a warning. */
- if ( (original_arg < search_name) /* with '-' */
+ if ((original_arg < search_name) /* with '-' */
&& (ARG_PUNCTUATION == parse_table[i].type)
- && ( search_name[0] == '!' || search_name[0] == ','
+ && (search_name[0] == '!' || search_name[0] == ','
|| search_name[0] == '(' || search_name[0] == ')')
&& (search_name[1] == '\0'))
{
error (0, 0,
_("warning: operator '%s' (with leading dash '-') will "
"no longer be accepted in future findutils releases!"),
- original_arg);
+ original_arg);
}
return found_parser (original_arg, &parse_table[i]);
@@ -740,7 +803,7 @@ collect_arg_stat_info (char **argv, int *arg_ptr, struct stat *p,
if (collect_arg (argv, arg_ptr, &filename))
{
*argument = filename;
- if (0 != (options.xstat)(filename, p))
+ if (0 != (options.xstat) (filename, p))
{
fatal_target_file_error (errno, filename);
}
@@ -765,7 +828,7 @@ collect_arg_stat_info (char **argv, int *arg_ptr, struct stat *p,
static bool
-parse_and (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_and (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -781,7 +844,7 @@ parse_and (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_anewer (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_anewer (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct stat stat_newer;
const char *arg;
@@ -793,14 +856,15 @@ parse_anewer (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred->args.reftime.xval = XVAL_ATIME;
our_pred->args.reftime.ts = get_stat_mtime (&stat_newer);
our_pred->args.reftime.kind = COMP_GT;
- our_pred->est_success_rate = estimate_timestamp_success_rate (stat_newer.st_mtime);
+ our_pred->est_success_rate =
+ estimate_timestamp_success_rate (stat_newer.st_mtime);
return true;
}
return false;
}
bool
-parse_closeparen (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_closeparen (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -816,7 +880,7 @@ parse_closeparen (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_cnewer (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_cnewer (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct stat stat_newer;
const char *arg;
@@ -828,14 +892,15 @@ parse_cnewer (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred->args.reftime.xval = XVAL_CTIME; /* like -newercm */
our_pred->args.reftime.ts = get_stat_mtime (&stat_newer);
our_pred->args.reftime.kind = COMP_GT;
- our_pred->est_success_rate = estimate_timestamp_success_rate (stat_newer.st_mtime);
+ our_pred->est_success_rate =
+ estimate_timestamp_success_rate (stat_newer.st_mtime);
return true;
}
return false;
}
static bool
-parse_comma (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_comma (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -852,7 +917,7 @@ parse_comma (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_daystart (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_daystart (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct tm *local;
@@ -868,14 +933,15 @@ parse_daystart (const struct parser_table* entry, char **argv, int *arg_ptr)
options.cur_day_start.tv_sec -= (local
? (local->tm_sec + local->tm_min * 60
+ local->tm_hour * 3600)
- : options.cur_day_start.tv_sec % DAYSECS);
+ : options.cur_day_start.tv_sec %
+ DAYSECS);
options.full_days = true;
}
return true;
}
static bool
-parse_delete (const struct parser_table* entry, char *argv[], int *arg_ptr)
+parse_delete (const struct parser_table *entry, char *argv[], int *arg_ptr)
{
struct predicate *our_pred;
(void) argv;
@@ -896,7 +962,7 @@ parse_delete (const struct parser_table* entry, char *argv[], int *arg_ptr)
}
static bool
-parse_depth (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_depth (const struct parser_table *entry, char **argv, int *arg_ptr)
{
(void) entry;
(void) argv;
@@ -907,7 +973,7 @@ parse_depth (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_d (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_d (const struct parser_table *entry, char **argv, int *arg_ptr)
{
if (should_issue_warnings ())
{
@@ -920,36 +986,36 @@ parse_d (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_empty (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_empty (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
(void) argv;
(void) arg_ptr;
our_pred = insert_primary_noarg (entry);
- our_pred->est_success_rate = 0.01f; /* assume 1% of files are empty. */
+ our_pred->est_success_rate = 0.01f; /* assume 1% of files are empty. */
return true;
}
static bool
-parse_exec (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_exec (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_exec_ok ("-exec", entry, argv, arg_ptr);
}
static bool
-parse_execdir (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_execdir (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_exec_ok ("-execdir", entry, argv, arg_ptr);
}
static bool
-insert_false(void)
+insert_false (void)
{
struct predicate *our_pred;
const struct parser_table *entry_false;
- entry_false = find_parser("false");
+ entry_false = find_parser ("false");
our_pred = insert_primary_noarg (entry_false);
our_pred->need_stat = our_pred->need_type = false;
our_pred->side_effects = our_pred->no_default_print = false;
@@ -959,7 +1025,7 @@ insert_false(void)
static bool
-parse_false (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_false (const struct parser_table *entry, char **argv, int *arg_ptr)
{
(void) entry;
(void) argv;
@@ -968,7 +1034,8 @@ parse_false (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_files0_from (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_files0_from (const struct parser_table *entry, char **argv,
+ int *arg_ptr)
{
const char *filename;
if (collect_arg (argv, arg_ptr, &filename))
@@ -980,7 +1047,7 @@ parse_files0_from (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-insert_fls (const struct parser_table* entry, const char *filename)
+insert_fls (const struct parser_table *entry, const char *filename)
{
struct predicate *our_pred = insert_primary_noarg (entry);
if (filename)
@@ -994,7 +1061,7 @@ insert_fls (const struct parser_table* entry, const char *filename)
static bool
-parse_fls (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_fls (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *filename;
if (collect_arg (argv, arg_ptr, &filename))
@@ -1002,20 +1069,20 @@ parse_fls (const struct parser_table* entry, char **argv, int *arg_ptr)
if (insert_fls (entry, filename))
return true;
else
- --*arg_ptr; /* don't consume the invalid arg. */
+ -- * arg_ptr; /* don't consume the invalid arg. */
}
return false;
}
static bool
-parse_follow (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_follow (const struct parser_table *entry, char **argv, int *arg_ptr)
{
set_follow_state (SYMLINK_ALWAYS_DEREF);
return parse_noop (entry, argv, arg_ptr);
}
static bool
-parse_fprint (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_fprint (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
const char *filename;
@@ -1035,7 +1102,7 @@ parse_fprint (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-insert_fprint (const struct parser_table* entry, const char *filename)
+insert_fprint (const struct parser_table *entry, const char *filename)
{
struct predicate *our_pred = insert_primary (entry, filename);
if (filename)
@@ -1050,7 +1117,7 @@ insert_fprint (const struct parser_table* entry, const char *filename)
static bool
-parse_fprint0 (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_fprint0 (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *filename;
if (collect_arg (argv, arg_ptr, &filename))
@@ -1058,21 +1125,22 @@ parse_fprint0 (const struct parser_table* entry, char **argv, int *arg_ptr)
if (insert_fprint (entry, filename))
return true;
else
- --*arg_ptr; /* don't consume the bad arg. */
+ -- * arg_ptr; /* don't consume the bad arg. */
}
return false;
}
-static float estimate_fstype_success_rate (const char *fsname)
+static float
+estimate_fstype_success_rate (const char *fsname)
{
struct stat dir_stat;
const char *the_root_dir = "/";
- if (0 == stat (the_root_dir, &dir_stat)) /* it's an absolute path anyway */
+ if (0 == stat (the_root_dir, &dir_stat)) /* it's an absolute path anyway */
{
const char *fstype = filesystem_type (&dir_stat, the_root_dir);
/* Assume most files are on the same file system type as the root fs. */
if (0 == strcmp (fsname, fstype))
- return 0.7f;
+ return 0.7f;
else
return 0.3f;
}
@@ -1082,7 +1150,7 @@ static float estimate_fstype_success_rate (const char *fsname)
static bool
-parse_fstype (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_fstype (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *typename;
if (collect_arg (argv, arg_ptr, &typename))
@@ -1097,7 +1165,8 @@ parse_fstype (const struct parser_table* entry, char **argv, int *arg_ptr)
* because we probably don't want to promote this test to the
* front anyway.
*/
- our_pred->est_success_rate = estimate_fstype_success_rate (typename);
+ our_pred->est_success_rate =
+ estimate_fstype_success_rate (typename);
return true;
}
else
@@ -1122,7 +1191,7 @@ parse_fstype (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_gid (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_gid (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *p = insert_num (argv, arg_ptr, entry);
if (p)
@@ -1135,7 +1204,7 @@ parse_gid (const struct parser_table* entry, char **argv, int *arg_ptr)
static bool
-parse_group (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_group (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *groupname;
@@ -1153,7 +1222,7 @@ parse_group (const struct parser_table* entry, char **argv, int *arg_ptr)
{
uintmax_t num;
if ((xstrtoumax (groupname, NULL, 10, &num, "") != LONGINT_OK)
- || (GID_T_MAX < num))
+ || (GID_T_MAX < num))
{
error (EXIT_FAILURE, 0,
_("invalid group name or GID argument to -group: %s"),
@@ -1171,7 +1240,7 @@ parse_group (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_help (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_help (const struct parser_table *entry, char **argv, int *arg_ptr)
{
(void) entry;
(void) argv;
@@ -1183,7 +1252,7 @@ parse_help (const struct parser_table* entry, char **argv, int *arg_ptr)
static float
estimate_pattern_match_rate (const char *pattern, int is_regex)
{
- if (strpbrk (pattern, "*?[") || (is_regex && strpbrk(pattern, ".")))
+ if (strpbrk (pattern, "*?[") || (is_regex && strpbrk (pattern, ".")))
{
/* A wildcard; assume the pattern matches most files. */
return 0.8f;
@@ -1195,7 +1264,7 @@ estimate_pattern_match_rate (const char *pattern, int is_regex)
}
static bool
-parse_ilname (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_ilname (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *name;
if (collect_arg (argv, arg_ptr, &name))
@@ -1205,7 +1274,8 @@ parse_ilname (const struct parser_table* entry, char **argv, int *arg_ptr)
/* Use the generic glob pattern estimator to figure out how many
* links will match, but bear in mind that most files won't be links.
*/
- our_pred->est_success_rate = 0.1f * estimate_pattern_match_rate (name, 0);
+ our_pred->est_success_rate =
+ 0.1f * estimate_pattern_match_rate (name, 0);
return true;
}
else
@@ -1229,7 +1299,8 @@ fnmatch_sanitycheck (void)
|| 0 != fnmatch ("Foo", "foo", FNM_CASEFOLD))
{
error (EXIT_FAILURE, 0,
- _("basic correctness check of the fnmatch() library function failed."));
+ _
+ ("basic correctness check of the fnmatch() library function failed."));
return false;
}
checked = true;
@@ -1241,13 +1312,14 @@ fnmatch_sanitycheck (void)
static void
check_name_arg (const char *pred, const char *alt, const char *arg)
{
- if (should_issue_warnings () && strchr (arg, '/') && (0 != strcmp ("/", arg)))
+ if (should_issue_warnings () && strchr (arg, '/')
+ && (0 != strcmp ("/", arg)))
{
error (0, 0,
_("warning: %s matches against basenames only, "
- "but the given pattern contains a directory separator (%s), "
- "thus the expression will evaluate to false all the time. "
- "Did you mean %s?"),
+ "but the given pattern contains a directory separator (%s), "
+ "thus the expression will evaluate to false all the time. "
+ "Did you mean %s?"),
safely_quote_err_filename (0, pred),
safely_quote_err_filename (1, "/"),
safely_quote_err_filename (2, alt));
@@ -1257,7 +1329,7 @@ check_name_arg (const char *pred, const char *alt, const char *arg)
static bool
-parse_iname (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_iname (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *name;
fnmatch_sanitycheck ();
@@ -1276,9 +1348,9 @@ parse_iname (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_inum (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_inum (const struct parser_table *entry, char **argv, int *arg_ptr)
{
- struct predicate *p = insert_num (argv, arg_ptr, entry);
+ struct predicate *p = insert_num (argv, arg_ptr, entry);
if (p)
{
/* inode number is exact match only, so very low proportions of
@@ -1294,13 +1366,14 @@ parse_inum (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_iregex (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_iregex (const struct parser_table *entry, char **argv, int *arg_ptr)
{
- return insert_regex (argv, arg_ptr, entry, RE_ICASE|options.regex_options);
+ return insert_regex (argv, arg_ptr, entry,
+ RE_ICASE | options.regex_options);
}
static bool
-parse_links (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_links (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *p = insert_num (argv, arg_ptr, entry);
if (p)
@@ -1317,7 +1390,7 @@ parse_links (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_lname (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_lname (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *name;
fnmatch_sanitycheck ();
@@ -1325,14 +1398,15 @@ parse_lname (const struct parser_table* entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred = insert_primary (entry, name);
our_pred->args.str = name;
- our_pred->est_success_rate = 0.1f * estimate_pattern_match_rate (name, 0);
+ our_pred->est_success_rate =
+ 0.1f * estimate_pattern_match_rate (name, 0);
return true;
}
return false;
}
static bool
-parse_ls (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_ls (const struct parser_table *entry, char **argv, int *arg_ptr)
{
(void) &argv;
(void) &arg_ptr;
@@ -1340,12 +1414,12 @@ parse_ls (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-insert_depthspec (const struct parser_table* entry, char **argv, int *arg_ptr,
+insert_depthspec (const struct parser_table *entry, char **argv, int *arg_ptr,
int *limitptr)
{
const char *depthstr;
int depth_len;
- const char *predicate = argv[(*arg_ptr)-1];
+ const char *predicate = argv[(*arg_ptr) - 1];
if (collect_arg (argv, arg_ptr, &depthstr))
{
depth_len = strspn (depthstr, "0123456789");
@@ -1358,9 +1432,10 @@ insert_depthspec (const struct parser_table* entry, char **argv, int *arg_ptr,
}
}
error (EXIT_FAILURE, 0,
- _("Expected a positive decimal integer argument to %s, but got %s"),
- predicate,
- quotearg_n_style (0, options.err_quoting_style, depthstr));
+ _
+ ("Expected a positive decimal integer argument to %s, but got %s"),
+ predicate, quotearg_n_style (0, options.err_quoting_style,
+ depthstr));
/* NOTREACHED */
return false;
}
@@ -1370,23 +1445,21 @@ insert_depthspec (const struct parser_table* entry, char **argv, int *arg_ptr,
static bool
-parse_maxdepth (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_maxdepth (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_depthspec (entry, argv, arg_ptr, &options.maxdepth);
}
static bool
-parse_mindepth (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_mindepth (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_depthspec (entry, argv, arg_ptr, &options.mindepth);
}
static bool
-do_parse_xmin (const struct parser_table* entry,
- char **argv,
- int *arg_ptr,
- enum xval xv)
+do_parse_xmin (const struct parser_table *entry,
+ char **argv, int *arg_ptr, enum xval xv)
{
const char *minutes;
const int saved_argc = *arg_ptr;
@@ -1403,7 +1476,8 @@ do_parse_xmin (const struct parser_table* entry,
{
struct predicate *our_pred = insert_primary (entry, minutes);
our_pred->args.reftime = tval;
- our_pred->est_success_rate = estimate_timestamp_success_rate (tval.ts.tv_sec);
+ our_pred->est_success_rate =
+ estimate_timestamp_success_rate (tval.ts.tv_sec);
return true;
}
else
@@ -1414,27 +1488,28 @@ do_parse_xmin (const struct parser_table* entry,
}
return false;
}
+
static bool
-parse_amin (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_amin (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return do_parse_xmin (entry, argv, arg_ptr, XVAL_ATIME);
}
static bool
-parse_cmin (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_cmin (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return do_parse_xmin (entry, argv, arg_ptr, XVAL_CTIME);
}
static bool
-parse_mmin (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_mmin (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return do_parse_xmin (entry, argv, arg_ptr, XVAL_MTIME);
}
static bool
-parse_name (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_name (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *name;
fnmatch_sanitycheck ();
@@ -1453,7 +1528,7 @@ parse_name (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_negate (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_negate (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -1469,7 +1544,7 @@ parse_negate (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_newer (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_newer (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
struct stat stat_newer;
@@ -1482,7 +1557,8 @@ parse_newer (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred->args.reftime.ts = get_stat_mtime (&stat_newer);
our_pred->args.reftime.xval = XVAL_MTIME;
our_pred->args.reftime.kind = COMP_GT;
- our_pred->est_success_rate = estimate_timestamp_success_rate (stat_newer.st_mtime);
+ our_pred->est_success_rate =
+ estimate_timestamp_success_rate (stat_newer.st_mtime);
return true;
}
return false;
@@ -1490,7 +1566,7 @@ parse_newer (const struct parser_table* entry, char **argv, int *arg_ptr)
static bool
-parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_newerXY (const struct parser_table *entry, char **argv, int *arg_ptr)
{
(void) argv;
(void) arg_ptr;
@@ -1517,7 +1593,8 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
if ('B' == x || 'B' == y)
{
error (0, 0,
- _("This system does not provide a way to find the birth time of a file."));
+ _
+ ("This system does not provide a way to find the birth time of a file."));
return false;
}
#endif
@@ -1525,7 +1602,7 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
/* -newertY (for any Y) is invalid. */
if (x == 't'
|| (NULL == strchr (validchars, x))
- || (NULL == strchr ( validchars, y)))
+ || (NULL == strchr (validchars, y)))
{
return false;
}
@@ -1536,10 +1613,12 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
/* Because this item is ARG_SPECIAL_PARSE, we have to advance arg_ptr
* past the test name (for most other tests, this is already done)
*/
- if (argv[1+*arg_ptr] == NULL)
+ if (argv[1 + *arg_ptr] == NULL)
{
- error (EXIT_FAILURE, 0, _("The %s test needs to be followed by an argument"),
- quotearg_n_style (0, options.err_quoting_style, argv[*arg_ptr]));
+ error (EXIT_FAILURE, 0,
+ _("The %s test needs to be followed by an argument"),
+ quotearg_n_style (0, options.err_quoting_style,
+ argv[*arg_ptr]));
}
else
{
@@ -1571,12 +1650,13 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
if ('t' == y)
{
if (!parse_datetime (&our_pred->args.reftime.ts,
- argv[*arg_ptr],
- &options.start_time))
+ argv[*arg_ptr], &options.start_time))
{
error (EXIT_FAILURE, 0,
- _("I cannot figure out how to interpret %s as a date or time"),
- quotearg_n_style (0, options.err_quoting_style, argv[*arg_ptr]));
+ _
+ ("I cannot figure out how to interpret %s as a date or time"),
+ quotearg_n_style (0, options.err_quoting_style,
+ argv[*arg_ptr]));
}
}
else
@@ -1588,7 +1668,8 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
if ((*options.xstat) (argv[*arg_ptr], &stat_newer))
fatal_target_file_error (errno, argv[*arg_ptr]);
- if (!get_stat_Ytime (&stat_newer, y, &our_pred->args.reftime.ts))
+ if (!get_stat_Ytime
+ (&stat_newer, y, &our_pred->args.reftime.ts))
{
/* We cannot extract a timestamp from the struct stat. */
error (EXIT_FAILURE, 0,
@@ -1597,7 +1678,9 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
}
}
our_pred->args.reftime.kind = COMP_GT;
- our_pred->est_success_rate = estimate_timestamp_success_rate (our_pred->args.reftime.ts.tv_sec);
+ our_pred->est_success_rate =
+ estimate_timestamp_success_rate (our_pred->args.reftime.
+ ts.tv_sec);
(*arg_ptr)++;
assert (our_pred->pred_func != NULL);
@@ -1610,14 +1693,14 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
static bool
-parse_noleaf (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_noleaf (const struct parser_table *entry, char **argv, int *arg_ptr)
{
options.no_leaf_check = true;
return parse_noop (entry, argv, arg_ptr);
}
static bool
-parse_nogroup (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_nogroup (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -1630,7 +1713,7 @@ parse_nogroup (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_nouser (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_nouser (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
(void) argv;
@@ -1643,26 +1726,26 @@ parse_nouser (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_nowarn (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_nowarn (const struct parser_table *entry, char **argv, int *arg_ptr)
{
options.warnings = false;
return parse_noop (entry, argv, arg_ptr);
}
static bool
-parse_ok (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_ok (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_exec_ok ("-ok", entry, argv, arg_ptr);
}
static bool
-parse_okdir (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_okdir (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_exec_ok ("-okdir", entry, argv, arg_ptr);
}
bool
-parse_openparen (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_openparen (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -1678,7 +1761,7 @@ parse_openparen (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_or (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_or (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -1715,8 +1798,9 @@ is_feasible_path_argument (const char *arg, bool foldcase)
static bool
-insert_path_check (const struct parser_table* entry, char **argv, int *arg_ptr,
- const char *predicate_name, PREDICATEFUNCTION pred)
+insert_path_check (const struct parser_table *entry, char **argv,
+ int *arg_ptr, const char *predicate_name,
+ PREDICATEFUNCTION pred)
{
const char *name;
bool foldcase = false;
@@ -1728,7 +1812,8 @@ insert_path_check (const struct parser_table* entry, char **argv, int *arg_ptr,
if (collect_arg (argv, arg_ptr, &name))
{
- struct predicate *our_pred = insert_primary_withpred (entry, pred, name);
+ struct predicate *our_pred =
+ insert_primary_withpred (entry, pred, name);
our_pred->need_stat = our_pred->need_type = false;
our_pred->args.str = name;
our_pred->est_success_rate = estimate_pattern_match_rate (name, 0);
@@ -1744,8 +1829,7 @@ insert_path_check (const struct parser_table* entry, char **argv, int *arg_ptr,
* warning: -path z/q/ will not match anything...
*/
error (0, 0, _("warning: -%s %s will not match anything "
- "because it ends with /."),
- predicate_name, name);
+ "because it ends with /."), predicate_name, name);
our_pred->est_success_rate = 1.0e-8;
}
return true;
@@ -1762,13 +1846,13 @@ insert_path_check (const struct parser_table* entry, char **argv, int *arg_ptr,
* since it is standardized since POSIX 2008.
*/
static bool
-parse_path (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_path (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_path_check (entry, argv, arg_ptr, "path", pred_path);
}
static bool
-parse_wholename (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_wholename (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_path_check (entry, argv, arg_ptr, "wholename", pred_path);
}
@@ -1780,20 +1864,20 @@ parse_wholename (const struct parser_table* entry, char **argv, int *arg_ptr)
* However, -path is now standardised so I un-deprecated -ipath.
*/
static bool
-parse_ipath (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_ipath (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_path_check (entry, argv, arg_ptr, "ipath", pred_ipath);
}
static bool
-parse_iwholename (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_iwholename (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_path_check (entry, argv, arg_ptr, "iwholename", pred_ipath);
}
static bool
-parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_perm (const struct parser_table *entry, char **argv, int *arg_ptr)
{
mode_t perm_val[2];
float rate;
@@ -1874,7 +1958,7 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
* own system that "-type l -xtype l" fails for (i.e. unbroken symlinks).
* Actual totals are 1472 and 1073833.
*/
- rate = 0.9986; /* probably matches anything but a broken symlink */
+ rate = 0.9986; /* probably matches anything but a broken symlink */
}
our_pred = insert_primary (entry, perm_expr);
@@ -1885,7 +1969,7 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
}
bool
-parse_print (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_print (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -1903,7 +1987,7 @@ parse_print (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_print0 (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_print0 (const struct parser_table *entry, char **argv, int *arg_ptr)
{
(void) entry;
(void) argv;
@@ -1912,7 +1996,7 @@ parse_print0 (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_printf (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_printf (const struct parser_table *entry, char **argv, int *arg_ptr)
{
char *format;
const int saved_argc = *arg_ptr;
@@ -1927,7 +2011,7 @@ parse_printf (const struct parser_table* entry, char **argv, int *arg_ptr)
}
else
{
- *arg_ptr = saved_argc; /* don't consume the invalid argument. */
+ *arg_ptr = saved_argc; /* don't consume the invalid argument. */
return false;
}
}
@@ -1935,7 +2019,7 @@ parse_printf (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_fprintf (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_fprintf (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *filename;
char *format;
@@ -1953,12 +2037,12 @@ parse_fprintf (const struct parser_table* entry, char **argv, int *arg_ptr)
return true;
}
}
- *arg_ptr = saved_argc; /* don't consume the invalid argument. */
+ *arg_ptr = saved_argc; /* don't consume the invalid argument. */
return false;
}
static bool
-parse_prune (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_prune (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -1976,21 +2060,21 @@ parse_prune (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_quit (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_quit (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred = insert_primary_noarg (entry);
(void) argv;
(void) arg_ptr;
our_pred->need_stat = our_pred->need_type = false;
- our_pred->side_effects = true; /* Exiting is a side effect... */
- our_pred->no_default_print = false; /* Don't inhibit the default print, though. */
+ our_pred->side_effects = true; /* Exiting is a side effect... */
+ our_pred->no_default_print = false; /* Don't inhibit the default print, though. */
our_pred->est_success_rate = 1.0f;
return true;
}
static bool
-parse_regextype (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_regextype (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *type_name;
if (collect_arg (argv, arg_ptr, &type_name))
@@ -2004,7 +2088,7 @@ parse_regextype (const struct parser_table* entry, char **argv, int *arg_ptr)
static bool
-parse_regex (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_regex (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_regex (argv, arg_ptr, entry, options.regex_options);
}
@@ -2012,15 +2096,15 @@ parse_regex (const struct parser_table* entry, char **argv, int *arg_ptr)
static bool
insert_regex (char **argv,
int *arg_ptr,
- const struct parser_table *entry,
- int regex_options)
+ const struct parser_table *entry, int regex_options)
{
const char *rx;
if (collect_arg (argv, arg_ptr, &rx))
{
struct re_pattern_buffer *re;
const char *error_message;
- struct predicate *our_pred = insert_primary_withpred (entry, pred_regex, rx);
+ struct predicate *our_pred =
+ insert_primary_withpred (entry, pred_regex, rx);
our_pred->need_stat = our_pred->need_type = false;
re = xmalloc (sizeof (struct re_pattern_buffer));
our_pred->args.regex = re;
@@ -2035,7 +2119,7 @@ insert_regex (char **argv,
error_message = re_compile_pattern (rx, strlen (rx), re);
if (error_message)
{
- error (EXIT_FAILURE, 0,
+ error (EXIT_FAILURE, 0,
_("failed to compile regular expression '%s': %s"),
rx, error_message);
}
@@ -2046,7 +2130,7 @@ insert_regex (char **argv,
}
static bool
-parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_size (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
char *arg;
@@ -2087,12 +2171,12 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
break;
case 'M': /* Mebibytes */
- blksize = 1024*1024;
+ blksize = 1024 * 1024;
arg[len - 1] = '\0';
break;
case 'G': /* Gibibytes */
- blksize = 1024*1024*1024;
+ blksize = 1024 * 1024 * 1024;
arg[len - 1] = '\0';
break;
@@ -2126,8 +2210,7 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
tail[1] = 0;
error (EXIT_FAILURE, 0,
- _("Invalid argument `%s%s' to -size"),
- arg, tail);
+ _("Invalid argument `%s%s' to -size"), arg, tail);
return false;
}
our_pred = insert_primary (entry, arg);
@@ -2138,9 +2221,9 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred->need_type = false;
if (COMP_GT == c_type)
- our_pred->est_success_rate = (num*blksize > 20480) ? 0.1 : 0.9;
+ our_pred->est_success_rate = (num * blksize > 20480) ? 0.1 : 0.9;
else if (COMP_LT == c_type)
- our_pred->est_success_rate = (num*blksize > 20480) ? 0.9 : 0.1;
+ our_pred->est_success_rate = (num * blksize > 20480) ? 0.9 : 0.1;
else
our_pred->est_success_rate = 0.01;
@@ -2150,7 +2233,7 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
static bool
-parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_samefile (const struct parser_table *entry, char **argv, int *arg_ptr)
{
/* General idea: stat the file, remember device and inode numbers.
* If a candidate file matches those, it's the same file.
@@ -2183,7 +2266,7 @@ parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr)
}
else
{
- if (S_ISLNK(st.st_mode))
+ if (S_ISLNK (st.st_mode))
{
/* no way to ensure that a symlink will not be followed
* by open(2), so fall back on using lstat(). Accept
@@ -2238,7 +2321,7 @@ parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr)
if ((options.symlink_handling == SYMLINK_NEVER_DEREF)
&& (!options.open_nofollow_available))
{
- if (S_ISLNK(st.st_mode))
+ if (S_ISLNK (st.st_mode))
{
/* We lost the race. Leave the data in st. The
* file descriptor points to the wrong thing.
@@ -2289,7 +2372,7 @@ parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred = insert_primary (entry, filename);
our_pred->args.samefileid.ino = st.st_ino;
our_pred->args.samefileid.dev = st.st_dev;
- our_pred->args.samefileid.fd = fd;
+ our_pred->args.samefileid.fd = fd;
our_pred->need_type = false;
/* smarter way: compare type and inode number first. */
/* TODO: maybe optimize this away by being optimistic */
@@ -2299,7 +2382,7 @@ parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_true (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_true (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -2313,14 +2396,15 @@ parse_true (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_noop (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_noop (const struct parser_table *entry, char **argv, int *arg_ptr)
{
(void) entry;
return parse_true (get_noop (), argv, arg_ptr);
}
static bool
-parse_accesscheck (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_accesscheck (const struct parser_table *entry, char **argv,
+ int *arg_ptr)
{
struct predicate *our_pred;
(void) argv;
@@ -2328,7 +2412,7 @@ parse_accesscheck (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred = insert_primary_noarg (entry);
our_pred->need_stat = our_pred->need_type = false;
our_pred->side_effects = our_pred->no_default_print = false;
- if (pred_is(our_pred, pred_executable))
+ if (pred_is (our_pred, pred_executable))
our_pred->est_success_rate = 0.2;
else
our_pred->est_success_rate = 0.9;
@@ -2336,13 +2420,13 @@ parse_accesscheck (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_type (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_type (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_type (argv, arg_ptr, entry, pred_type);
}
static bool
-parse_uid (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_uid (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *p = insert_num (argv, arg_ptr, entry);
if (p)
@@ -2354,30 +2438,31 @@ parse_uid (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_used (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_used (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
struct time_val tval;
const char *offset_str;
- const char *errmsg = "arithmetic overflow while converting %s days to a number of seconds";
+ const char *errmsg =
+ "arithmetic overflow while converting %s days to a number of seconds";
if (collect_arg (argv, arg_ptr, &offset_str))
{
/* The timespec is actually a delta value, so we use an origin of 0. */
- struct timespec zero = {0,0};
+ struct timespec zero = { 0, 0 };
if (get_relative_timestamp (offset_str, &tval, zero, DAYSECS, errmsg))
{
our_pred = insert_primary (entry, offset_str);
our_pred->args.reftime = tval;
- our_pred->est_success_rate = estimate_file_age_success_rate (tval.ts.tv_sec / DAYSECS);
+ our_pred->est_success_rate =
+ estimate_file_age_success_rate (tval.ts.tv_sec / DAYSECS);
return true;
}
else
{
error (EXIT_FAILURE, 0,
_("Invalid argument %s to -used"), offset_str);
- /*NOTREACHED*/
- return false;
+ /*NOTREACHED*/ return false;
}
}
else
@@ -2387,7 +2472,7 @@ parse_used (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_user (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_user (const struct parser_table *entry, char **argv, int *arg_ptr)
{
const char *username;
@@ -2405,7 +2490,7 @@ parse_user (const struct parser_table* entry, char **argv, int *arg_ptr)
{
uintmax_t num;
if ((xstrtoumax (username, NULL, 10, &num, "") != LONGINT_OK)
- || (UID_T_MAX < num))
+ || (UID_T_MAX < num))
{
error (EXIT_FAILURE, 0,
_("invalid user name or UID argument to -user: %s"),
@@ -2423,7 +2508,7 @@ parse_user (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_version (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_version (const struct parser_table *entry, char **argv, int *arg_ptr)
{
(void) entry;
(void) argv;
@@ -2459,14 +2544,14 @@ parse_version (const struct parser_table* entry, char **argv, int *arg_ptr)
printf ("FTS() ");
}
- printf ("CBO(level=%d) ", (int)(options.optimisation_level));
+ printf ("CBO(level=%d) ", (int) (options.optimisation_level));
printf ("\n");
exit (EXIT_SUCCESS);
}
static bool
-parse_context (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_context (const struct parser_table *entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
@@ -2489,56 +2574,57 @@ parse_context (const struct parser_table* entry, char **argv, int *arg_ptr)
}
static bool
-parse_mount (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_mount (const struct parser_table *entry, char **argv, int *arg_ptr)
{
options.mount = true;
return parse_noop (entry, argv, arg_ptr);
}
static bool
-parse_xdev (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_xdev (const struct parser_table *entry, char **argv, int *arg_ptr)
{
options.xdev = true;
return parse_noop (entry, argv, arg_ptr);
}
static bool
-parse_ignore_race (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_ignore_race (const struct parser_table *entry, char **argv,
+ int *arg_ptr)
{
options.ignore_readdir_race = true;
return parse_noop (entry, argv, arg_ptr);
}
static bool
-parse_noignore_race (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_noignore_race (const struct parser_table *entry, char **argv,
+ int *arg_ptr)
{
options.ignore_readdir_race = false;
return parse_noop (entry, argv, arg_ptr);
}
static bool
-parse_warn (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_warn (const struct parser_table *entry, char **argv, int *arg_ptr)
{
options.warnings = true;
return parse_noop (entry, argv, arg_ptr);
}
static bool
-parse_xtype (const struct parser_table* entry, char **argv, int *arg_ptr)
+parse_xtype (const struct parser_table *entry, char **argv, int *arg_ptr)
{
return insert_type (argv, arg_ptr, entry, pred_xtype);
}
static bool
insert_type (char **argv, int *arg_ptr,
- const struct parser_table *entry,
- PRED_FUNC which_pred)
+ const struct parser_table *entry, PRED_FUNC which_pred)
{
struct predicate *our_pred;
const char *typeletter;
const char *pred_string = which_pred == pred_xtype ? "-xtype" : "-type";
- if (! collect_arg (argv, arg_ptr, &typeletter))
+ if (!collect_arg (argv, arg_ptr, &typeletter))
return false;
if (!*typeletter)
@@ -2546,8 +2632,7 @@ insert_type (char **argv, int *arg_ptr,
error (EXIT_FAILURE, 0,
_("Arguments to %s should contain at least one letter"),
pred_string);
- /*NOTREACHED*/
- return false;
+ /*NOTREACHED*/ return false;
}
our_pred = insert_primary_withpred (entry, which_pred, typeletter);
@@ -2564,7 +2649,7 @@ insert_type (char **argv, int *arg_ptr,
}
else
{
- our_pred->need_stat = false; /* struct dirent is enough */
+ our_pred->need_stat = false; /* struct dirent is enough */
our_pred->need_type = true;
}
@@ -2577,90 +2662,89 @@ insert_type (char **argv, int *arg_ptr,
c 2233 0.000443
s 80 1.59e-05
p 38 7.54e-06
- */
+ */
- for (; *typeletter; )
+ for (; *typeletter;)
{
unsigned int type_cell;
float rate = 0.01;
switch (*typeletter)
- {
- case 'b': /* block special */
- type_cell = FTYPE_BLK;
- rate = 0.000888f;
- break;
- case 'c': /* character special */
- type_cell = FTYPE_CHR;
- rate = 0.000443f;
- break;
- case 'd': /* directory */
- type_cell = FTYPE_DIR;
- rate = 0.0922f;
- break;
- case 'f': /* regular file */
- type_cell = FTYPE_REG;
- rate = 0.875f;
- break;
- case 'l': /* symbolic link */
+ {
+ case 'b': /* block special */
+ type_cell = FTYPE_BLK;
+ rate = 0.000888f;
+ break;
+ case 'c': /* character special */
+ type_cell = FTYPE_CHR;
+ rate = 0.000443f;
+ break;
+ case 'd': /* directory */
+ type_cell = FTYPE_DIR;
+ rate = 0.0922f;
+ break;
+ case 'f': /* regular file */
+ type_cell = FTYPE_REG;
+ rate = 0.875f;
+ break;
+ case 'l': /* symbolic link */
#ifdef S_IFLNK
- type_cell = FTYPE_LNK;
- rate = 0.0311f;
+ type_cell = FTYPE_LNK;
+ rate = 0.0311f;
#else
- type_cell = 0;
- error (EXIT_FAILURE, 0,
- _("%s %c is not supported because symbolic links "
- "are not supported on the platform find was compiled on."),
- pred_string, (*typeletter));
+ type_cell = 0;
+ error (EXIT_FAILURE, 0,
+ _("%s %c is not supported because symbolic links "
+ "are not supported on the platform find was compiled on."),
+ pred_string, (*typeletter));
#endif
- break;
- case 'p': /* pipe */
+ break;
+ case 'p': /* pipe */
#ifdef S_IFIFO
- type_cell = FTYPE_FIFO;
- rate = 7.554e-6f;
+ type_cell = FTYPE_FIFO;
+ rate = 7.554e-6f;
#else
- type_cell = 0;
- error (EXIT_FAILURE, 0,
- _("%s %c is not supported because FIFOs "
- "are not supported on the platform find was compiled on."),
- pred_string, (*typeletter));
+ type_cell = 0;
+ error (EXIT_FAILURE, 0,
+ _("%s %c is not supported because FIFOs "
+ "are not supported on the platform find was compiled on."),
+ pred_string, (*typeletter));
#endif
- break;
- case 's': /* socket */
+ break;
+ case 's': /* socket */
#ifdef S_IFSOCK
- type_cell = FTYPE_SOCK;
- rate = 1.59e-5f;
+ type_cell = FTYPE_SOCK;
+ rate = 1.59e-5f;
#else
- type_cell = 0;
- error (EXIT_FAILURE, 0,
- _("%s %c is not supported because named sockets "
- "are not supported on the platform find was compiled on."),
- pred_string, (*typeletter));
+ type_cell = 0;
+ error (EXIT_FAILURE, 0,
+ _("%s %c is not supported because named sockets "
+ "are not supported on the platform find was compiled on."),
+ pred_string, (*typeletter));
#endif
- break;
- case 'D': /* Solaris door */
+ break;
+ case 'D': /* Solaris door */
#ifdef S_IFDOOR
- type_cell = FTYPE_DOOR;
- /* There are no Solaris doors on the example system surveyed
- * above, but if someone uses -type D, they are presumably
- * expecting to find a non-zero number. We guess at a
- * rate. */
- rate = 1.0e-5f;
+ type_cell = FTYPE_DOOR;
+ /* There are no Solaris doors on the example system surveyed
+ * above, but if someone uses -type D, they are presumably
+ * expecting to find a non-zero number. We guess at a
+ * rate. */
+ rate = 1.0e-5f;
#else
- type_cell = 0;
- error (EXIT_FAILURE, 0,
- _("%s %c is not supported because Solaris doors "
- "are not supported on the platform find was compiled on."),
- pred_string, (*typeletter));
+ type_cell = 0;
+ error (EXIT_FAILURE, 0,
+ _("%s %c is not supported because Solaris doors "
+ "are not supported on the platform find was compiled on."),
+ pred_string, (*typeletter));
#endif
- break;
- default: /* None of the above ... nuke 'em. */
- type_cell = 0;
- error (EXIT_FAILURE, 0,
- _("Unknown argument to %s: %c"), pred_string, (*typeletter));
- /*NOTREACHED*/
- return false;
- }
+ break;
+ default: /* None of the above ... nuke 'em. */
+ type_cell = 0;
+ error (EXIT_FAILURE, 0,
+ _("Unknown argument to %s: %c"), pred_string, (*typeletter));
+ /*NOTREACHED*/ return false;
+ }
if (our_pred->args.types[type_cell])
{
@@ -2683,8 +2767,7 @@ insert_type (char **argv, int *arg_ptr,
error (EXIT_FAILURE, 0,
_("Must separate multiple arguments to %s using: ','"),
pred_string);
- /*NOTREACHED*/
- return false;
+ /*NOTREACHED*/ return false;
}
typeletter++;
if (!*typeletter)
@@ -2693,8 +2776,7 @@ insert_type (char **argv, int *arg_ptr,
_("Last file type in list argument to %s "
"is missing, i.e., list is ending on: ','"),
pred_string);
- /*NOTREACHED*/
- return false;
+ /*NOTREACHED*/ return false;
}
}
}
@@ -2711,7 +2793,7 @@ stream_is_tty (FILE *fp)
int fd = fileno (fp);
if (-1 == fd)
{
- return false; /* not a valid stream */
+ return false; /* not a valid stream */
}
else
{
@@ -2754,8 +2836,7 @@ check_path_safety (const char *action)
"combination with the %s action of find. "
"Please remove the current directory from your "
"$PATH (that is, remove \".\", doubled colons, "
- "or leading or trailing colons)"),
- action);
+ "or leading or trailing colons)"), action);
}
else if (path[pos] != '/')
{
@@ -2765,21 +2846,20 @@ check_path_safety (const char *action)
"environment variable, which is insecure in "
"combination with the %s action of find. "
"Please remove that entry from $PATH"),
- safely_quote_err_filename (0, relpath ? relpath : &path[pos]),
+ safely_quote_err_filename (0,
+ relpath ? relpath : &path[pos]),
action);
- /*NOTREACHED*/
- free (relpath);
+ /*NOTREACHED*/ free (relpath);
}
- } while (splitstring (path, path_separators, false, &pos, &len));
+ }
+ while (splitstring (path, path_separators, false, &pos, &len));
}
/* handles both exec and ok predicate */
static bool
insert_exec_ok (const char *action,
- const struct parser_table *entry,
- char **argv,
- int *arg_ptr)
+ const struct parser_table *entry, char **argv, int *arg_ptr)
{
int start, end; /* Indexes in ARGV of start & end of cmd. */
int i; /* Index into cmd args */
@@ -2800,7 +2880,7 @@ insert_exec_ok (const char *action,
our_pred->side_effects = our_pred->no_default_print = true;
our_pred->need_type = our_pred->need_stat = false;
- assert(predicate_uses_exec (our_pred));
+ assert (predicate_uses_exec (our_pred));
execp = &our_pred->args.exec_vec;
execp->wd_for_exec = NULL;
@@ -2840,14 +2920,14 @@ insert_exec_ok (const char *action,
* Also figure out if the command is terminated by ";" or by "+".
*/
start = *arg_ptr;
- for (end = start, prev_was_braces_only=false, brace_count=0, brace_arg=NULL;
- (argv[end] != NULL)
- && ((argv[end][0] != ';') || (argv[end][1] != '\0'));
- end++)
+ for (end = start, prev_was_braces_only = false, brace_count = 0, brace_arg =
+ NULL;
+ (argv[end] != NULL) && ((argv[end][0] != ';')
+ || (argv[end][1] != '\0')); end++)
{
/* For -exec and -execdir, "{} +" can terminate the command. */
if (allow_plus && prev_was_braces_only
- && argv[end][0] == '+' && argv[end][1] == 0)
+ && argv[end][0] == '+' && argv[end][1] == 0)
{
our_pred->args.exec_vec.multiple = 1;
break;
@@ -2856,7 +2936,7 @@ insert_exec_ok (const char *action,
prev_was_braces_only = false;
if (mbsstr (argv[end], "{}"))
{
- if (0 == strcmp(argv[end], "{}"))
+ if (0 == strcmp (argv[end], "{}"))
{
/* Savannah bug 66365: + only terminates the predicate
* immediately after an argument which is exactly, "{}".
@@ -2911,12 +2991,15 @@ insert_exec_ok (const char *action,
}
else if (strlen (brace_arg) != 2u)
{
- enum { MsgBufSize = 19 };
+ enum
+ { MsgBufSize = 19 };
char buf[MsgBufSize];
- const size_t needed = snprintf (buf, MsgBufSize, "-exec%s ... {} +", suffix);
- assert (needed <= MsgBufSize); /* If this assertion fails, correct the value of MsgBufSize. */
+ const size_t needed =
+ snprintf (buf, MsgBufSize, "-exec%s ... {} +", suffix);
+ assert (needed <= MsgBufSize); /* If this assertion fails, correct the value of MsgBufSize. */
error (EXIT_FAILURE, 0,
- _("In %s the %s must appear by itself, but you specified %s"),
+ _
+ ("In %s the %s must appear by itself, but you specified %s"),
quotearg_n_style (0, options.err_quoting_style, buf),
quotearg_n_style (1, options.err_quoting_style, "{}"),
quotearg_n_style (2, options.err_quoting_style, brace_arg));
@@ -2954,22 +3037,20 @@ insert_exec_ok (const char *action,
execp->replace_vec = NULL;
execp->ctl.replace_pat = NULL;
execp->ctl.rplen = 0;
- execp->ctl.lines_per_exec = 0; /* no limit */
- execp->ctl.args_per_exec = 0; /* no limit */
+ execp->ctl.lines_per_exec = 0; /* no limit */
+ execp->ctl.args_per_exec = 0; /* no limit */
/* remember how many arguments there are */
- execp->ctl.initial_argc = (end-start) - 1;
+ execp->ctl.initial_argc = (end - start) - 1;
/* execp->state = xmalloc(sizeof struct buildcmd_state); */
bc_init_state (&execp->ctl, &execp->state, execp);
/* Gather the initial arguments. Skip the {}. */
- for (i=start; i<end-1; ++i)
+ for (i = start; i < end - 1; ++i)
{
bc_push_arg (&execp->ctl, &execp->state,
- argv[i], strlen (argv[i])+1,
- NULL, 0,
- 1);
+ argv[i], strlen (argv[i]) + 1, NULL, 0, 1);
}
}
else
@@ -2981,18 +3062,18 @@ insert_exec_ok (const char *action,
execp->ctl.replace_pat = "{}";
execp->ctl.rplen = strlen (execp->ctl.replace_pat);
- execp->ctl.lines_per_exec = 0; /* no limit */
- execp->ctl.args_per_exec = 0; /* no limit */
- execp->replace_vec = xmalloc (sizeof(char*)*execp->num_args);
+ execp->ctl.lines_per_exec = 0; /* no limit */
+ execp->ctl.args_per_exec = 0; /* no limit */
+ execp->replace_vec = xmalloc (sizeof (char *) * execp->num_args);
/* execp->state = xmalloc(sizeof(*(execp->state))); */
bc_init_state (&execp->ctl, &execp->state, execp);
/* Remember the (pre-replacement) arguments for later. */
- for (i=0; i<execp->num_args; ++i)
+ for (i = 0; i < execp->num_args; ++i)
{
- execp->replace_vec[i] = argv[i+start];
+ execp->replace_vec[i] = argv[i + start];
}
}
@@ -3023,8 +3104,7 @@ static bool
get_relative_timestamp (const char *str,
struct time_val *result,
struct timespec origin,
- double sec_per_unit,
- const char *overflowmessage)
+ double sec_per_unit, const char *overflowmessage)
{
double offset, seconds, nanosec;
static const long nanosec_per_sec = 1000000000;
@@ -3034,10 +3114,14 @@ get_relative_timestamp (const char *str,
/* Invert the sense of the comparison */
switch (result->kind)
{
- case COMP_LT: result->kind = COMP_GT; break;
- case COMP_GT: result->kind = COMP_LT; break;
+ case COMP_LT:
+ result->kind = COMP_GT;
+ break;
+ case COMP_GT:
+ result->kind = COMP_LT;
+ break;
case COMP_EQ:
- break; /* inversion leaves it unchanged */
+ break; /* inversion leaves it unchanged */
}
/* Convert the ASCII number into floating-point. */
@@ -3045,8 +3129,8 @@ get_relative_timestamp (const char *str,
{
if (isnan (offset))
{
- error (EXIT_FAILURE, 0, _("invalid not-a-number argument: `%s'"),
- str);
+ error (EXIT_FAILURE, 0,
+ _("invalid not-a-number argument: `%s'"), str);
}
/* Separate the floating point number the user specified
@@ -3063,7 +3147,7 @@ get_relative_timestamp (const char *str,
* does not require this approach to work, but I am aware
* of no platforms where it fails.
*/
- result->ts.tv_sec = origin.tv_sec - seconds;
+ result->ts.tv_sec = origin.tv_sec - seconds;
if ((origin.tv_sec < result->ts.tv_sec) != (seconds < 0))
{
/* an overflow has occurred. */
@@ -3075,7 +3159,7 @@ get_relative_timestamp (const char *str,
{
/* Perform a carry operation */
result->ts.tv_nsec += nanosec_per_sec;
- result->ts.tv_sec -= 1;
+ result->ts.tv_sec -= 1;
}
return true;
}
@@ -3104,7 +3188,7 @@ get_relative_timestamp (const char *str,
Used by -atime, -ctime, and -mtime parsers. */
static bool
-parse_time (const struct parser_table* entry, char *argv[], int *arg_ptr)
+parse_time (const struct parser_table *entry, char *argv[], int *arg_ptr)
{
struct predicate *our_pred;
struct time_val tval;
@@ -3129,12 +3213,13 @@ parse_time (const struct parser_table* entry, char *argv[], int *arg_ptr)
*/
if (COMP_LT == comp)
{
- uintmax_t expected = origin.tv_sec + (DAYSECS-1);
- origin.tv_sec += (DAYSECS-1);
- if (expected != (uintmax_t)origin.tv_sec)
+ uintmax_t expected = origin.tv_sec + (DAYSECS - 1);
+ origin.tv_sec += (DAYSECS - 1);
+ if (expected != (uintmax_t) origin.tv_sec)
{
error (EXIT_FAILURE, 0,
- _("arithmetic overflow when trying to calculate the end of today"));
+ _
+ ("arithmetic overflow when trying to calculate the end of today"));
}
}
}
@@ -3153,7 +3238,8 @@ parse_time (const struct parser_table* entry, char *argv[], int *arg_ptr)
our_pred = insert_primary (entry, orig_timearg);
our_pred->args.reftime = tval;
- our_pred->est_success_rate = estimate_timestamp_success_rate (tval.ts.tv_sec);
+ our_pred->est_success_rate =
+ estimate_timestamp_success_rate (tval.ts.tv_sec);
if (options.debug_options & DebugExpressionTree)
{
@@ -3162,17 +3248,20 @@ parse_time (const struct parser_table* entry, char *argv[], int *arg_ptr)
fprintf (stderr, "inserting %s\n", our_pred->p_name);
fprintf (stderr, " type: %s %s ",
(tval.kind == COMP_GT) ? "gt" :
- ((tval.kind == COMP_LT) ? "lt" : ((tval.kind == COMP_EQ) ? "eq" : "?")),
- (tval.kind == COMP_GT) ? " >" :
- ((tval.kind == COMP_LT) ? " <" : ((tval.kind == COMP_EQ) ? ">=" : " ?")));
+ ((tval.kind ==
+ COMP_LT) ? "lt" : ((tval.kind == COMP_EQ) ? "eq" : "?")),
+ (tval.kind ==
+ COMP_GT) ? " >" : ((tval.kind ==
+ COMP_LT) ? " <" : ((tval.kind ==
+ COMP_EQ) ? ">=" :
+ " ?")));
t = our_pred->args.reftime.ts.tv_sec;
- fprintf (stderr, "%"PRIuMAX" %s",
- (uintmax_t) our_pred->args.reftime.ts.tv_sec,
- ctime (&t));
+ fprintf (stderr, "%" PRIuMAX " %s",
+ (uintmax_t) our_pred->args.reftime.ts.tv_sec, ctime (&t));
if (tval.kind == COMP_EQ)
{
t = our_pred->args.reftime.ts.tv_sec + DAYSECS;
- fprintf (stderr, " < %"PRIuMAX" %s",
+ fprintf (stderr, " < %" PRIuMAX " %s",
(uintmax_t) t, ctime (&t));
}
}
@@ -3221,9 +3310,7 @@ get_comp_type (const char **str, enum comparison_type *comp_type)
Return true if all okay, false if input error. */
static bool
-get_num (const char *str,
- uintmax_t *num,
- enum comparison_type *comp_type)
+get_num (const char *str, uintmax_t *num, enum comparison_type *comp_type)
{
char *pend;
@@ -3258,39 +3345,44 @@ insert_num (char **argv, int *arg_ptr, const struct parser_table *entry)
const char *numstr;
if (collect_arg (argv, arg_ptr, &numstr))
- {
- uintmax_t num;
- enum comparison_type c_type;
-
- if (get_num (numstr, &num, &c_type))
- {
- struct predicate *our_pred = insert_primary (entry, numstr);
- our_pred->args.numinfo.kind = c_type;
- our_pred->args.numinfo.l_val = num;
-
- if (options.debug_options & DebugExpressionTree)
- {
- fprintf (stderr, "inserting %s\n", our_pred->p_name);
- fprintf (stderr, " type: %s %s ",
- (c_type == COMP_GT) ? "gt" :
- ((c_type == COMP_LT) ? "lt" : ((c_type == COMP_EQ) ? "eq" : "?")),
- (c_type == COMP_GT) ? " >" :
- ((c_type == COMP_LT) ? " <" : ((c_type == COMP_EQ) ? " =" : " ?")));
- fprintf (stderr, "%"PRIuMAX"\n", our_pred->args.numinfo.l_val);
- }
- return our_pred;
- }
- else
- {
- const char *predicate = argv[(*arg_ptr)-2];
- error (EXIT_FAILURE, 0,
- _("non-numeric argument to %s: %s"),
- predicate,
- quotearg_n_style (0, options.err_quoting_style, numstr));
- /*NOTREACHED*/
- return NULL;
- }
- }
+ {
+ uintmax_t num;
+ enum comparison_type c_type;
+
+ if (get_num (numstr, &num, &c_type))
+ {
+ struct predicate *our_pred = insert_primary (entry, numstr);
+ our_pred->args.numinfo.kind = c_type;
+ our_pred->args.numinfo.l_val = num;
+
+ if (options.debug_options & DebugExpressionTree)
+ {
+ fprintf (stderr, "inserting %s\n", our_pred->p_name);
+ fprintf (stderr, " type: %s %s ",
+ (c_type == COMP_GT) ? "gt" :
+ ((c_type ==
+ COMP_LT) ? "lt" : ((c_type ==
+ COMP_EQ) ? "eq" : "?")),
+ (c_type ==
+ COMP_GT) ? " >" : ((c_type ==
+ COMP_LT) ? " <" : ((c_type ==
+ COMP_EQ) ?
+ " =" : " ?")));
+ fprintf (stderr, "%" PRIuMAX "\n",
+ our_pred->args.numinfo.l_val);
+ }
+ return our_pred;
+ }
+ else
+ {
+ const char *predicate = argv[(*arg_ptr) - 2];
+ error (EXIT_FAILURE, 0,
+ _("non-numeric argument to %s: %s"),
+ predicate,
+ quotearg_n_style (0, options.err_quoting_style, numstr));
+ /*NOTREACHED*/ return NULL;
+ }
+ }
return NULL;
}
diff --git a/find/pred.c b/find/pred.c
index c6af86ce..02e4d823 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -32,7 +32,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <unistd.h> /* for unlinkat() */
+#include <unistd.h> /* for unlinkat() */
/* gnulib headers. */
#include "areadlink.h"
@@ -59,7 +59,8 @@
# define CLOSEDIR(d) closedir (d)
#endif
-static bool match_lname (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr, bool ignore_case);
+static bool match_lname (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr, bool ignore_case);
/* Predicate processing routines.
@@ -78,7 +79,8 @@ static bool match_lname (const char *pathname, struct stat *stat_buf, struct pre
* COMP_EQ: after the specified time but by not more than WINDOW seconds.
*/
static bool
-pred_timewindow (struct timespec ts, struct predicate const *pred_ptr, int window)
+pred_timewindow (struct timespec ts, struct predicate const *pred_ptr,
+ int window)
{
switch (pred_ptr->args.reftime.kind)
{
@@ -105,7 +107,7 @@ pred_timewindow (struct timespec ts, struct predicate const *pred_ptr, int windo
*/
struct timespec delta = timespec_sub (ts, pred_ptr->args.reftime.ts);
return (timespec_cmp (delta, make_timespec (0, 0)) > 0
- && timespec_cmp (delta, make_timespec (window, 0)) <= 0);
+ && timespec_cmp (delta, make_timespec (window, 0)) <= 0);
}
}
assert (0);
@@ -114,14 +116,16 @@ pred_timewindow (struct timespec ts, struct predicate const *pred_ptr, int windo
bool
-pred_amin (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_amin (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) &pathname;
- return pred_timewindow (get_stat_atime(stat_buf), pred_ptr, 60);
+ return pred_timewindow (get_stat_atime (stat_buf), pred_ptr, 60);
}
bool
-pred_and (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_and (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
if (pred_ptr->pred_left == NULL
|| apply_predicate (pathname, stat_buf, pred_ptr->pred_left))
@@ -133,22 +137,26 @@ pred_and (const char *pathname, struct stat *stat_buf, struct predicate *pred_pt
}
bool
-pred_anewer (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_anewer (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) &pathname;
assert (COMP_GT == pred_ptr->args.reftime.kind);
- return timespec_cmp (get_stat_atime(stat_buf), pred_ptr->args.reftime.ts) > 0;
+ return timespec_cmp (get_stat_atime (stat_buf),
+ pred_ptr->args.reftime.ts) > 0;
}
bool
-pred_atime (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_atime (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) &pathname;
- return pred_timewindow (get_stat_atime(stat_buf), pred_ptr, DAYSECS);
+ return pred_timewindow (get_stat_atime (stat_buf), pred_ptr, DAYSECS);
}
bool
-pred_closeparen (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_closeparen (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) &pathname;
(void) &stat_buf;
@@ -158,36 +166,41 @@ pred_closeparen (const char *pathname, struct stat *stat_buf, struct predicate *
}
bool
-pred_cmin (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_cmin (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
- return pred_timewindow (get_stat_ctime(stat_buf), pred_ptr, 60);
+ return pred_timewindow (get_stat_ctime (stat_buf), pred_ptr, 60);
}
bool
-pred_cnewer (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_cnewer (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
assert (COMP_GT == pred_ptr->args.reftime.kind);
- return timespec_cmp (get_stat_ctime(stat_buf), pred_ptr->args.reftime.ts) > 0;
+ return timespec_cmp (get_stat_ctime (stat_buf),
+ pred_ptr->args.reftime.ts) > 0;
}
bool
-pred_comma (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_comma (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
if (pred_ptr->pred_left != NULL)
{
- apply_predicate (pathname, stat_buf,pred_ptr->pred_left);
+ apply_predicate (pathname, stat_buf, pred_ptr->pred_left);
}
return apply_predicate (pathname, stat_buf, pred_ptr->pred_right);
}
bool
-pred_ctime (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_ctime (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) &pathname;
- return pred_timewindow (get_stat_ctime(stat_buf), pred_ptr, DAYSECS);
+ return pred_timewindow (get_stat_ctime (stat_buf), pred_ptr, DAYSECS);
}
static bool
@@ -198,14 +211,15 @@ perform_delete (int flags)
bool
-pred_delete (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_delete (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pred_ptr;
(void) stat_buf;
if (strcmp (state.rel_pathname, "."))
{
- int flags=0;
- if (state.have_stat && S_ISDIR(stat_buf->st_mode))
+ int flags = 0;
+ if (state.have_stat && S_ISDIR (stat_buf->st_mode))
flags |= AT_REMOVEDIR;
if (perform_delete (flags))
{
@@ -274,7 +288,8 @@ compare_num (enum comparison_type kind, uintmax_t l_val, uintmax_t val)
}
bool
-pred_empty (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_empty (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) pred_ptr;
@@ -291,7 +306,8 @@ pred_empty (const char *pathname, struct stat *stat_buf, struct predicate *pred_
#if defined O_LARGEFILE
| O_LARGEFILE
#endif
- | O_CLOEXEC | O_DIRECTORY | O_NOCTTY | O_NONBLOCK)) < 0)
+ | O_CLOEXEC | O_DIRECTORY | O_NOCTTY | O_NONBLOCK)) <
+ 0)
{
error (0, errno, "%s", safely_quote_err_filename (0, pathname));
state.exit_status = EXIT_FAILURE;
@@ -342,20 +358,23 @@ pred_empty (const char *pathname, struct stat *stat_buf, struct predicate *pred_
bool
-pred_exec (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_exec (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
return impl_pred_exec (pathname, stat_buf, pred_ptr);
}
bool
-pred_execdir (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_execdir (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
- (void) &pathname;
- return impl_pred_exec (state.rel_pathname, stat_buf, pred_ptr);
+ (void) &pathname;
+ return impl_pred_exec (state.rel_pathname, stat_buf, pred_ptr);
}
bool
-pred_false (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_false (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) &pathname;
(void) &stat_buf;
@@ -366,9 +385,10 @@ pred_false (const char *pathname, struct stat *stat_buf, struct predicate *pred_
}
bool
-pred_fls (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_fls (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
- FILE * stream = pred_ptr->args.printf_vec.stream;
+ FILE *stream = pred_ptr->args.printf_vec.stream;
list_file (pathname, state.cwd_dir_fd, state.rel_pathname, stat_buf,
options.start_time.tv_sec,
options.output_block_size,
@@ -377,23 +397,23 @@ pred_fls (const char *pathname, struct stat *stat_buf, struct predicate *pred_pt
}
bool
-pred_fprint (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_fprint (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) &pathname;
(void) &stat_buf;
print_quoted (pred_ptr->args.printf_vec.stream,
pred_ptr->args.printf_vec.quote_opts,
- pred_ptr->args.printf_vec.dest_is_tty,
- "%s\n",
- pathname);
+ pred_ptr->args.printf_vec.dest_is_tty, "%s\n", pathname);
return true;
}
bool
-pred_fprint0 (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_fprint0 (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
- FILE * fp = pred_ptr->args.printf_vec.stream;
+ FILE *fp = pred_ptr->args.printf_vec.stream;
(void) &stat_buf;
@@ -405,7 +425,8 @@ pred_fprint0 (const char *pathname, struct stat *stat_buf, struct predicate *pre
bool
-pred_fstype (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_fstype (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
@@ -416,17 +437,18 @@ pred_fstype (const char *pathname, struct stat *stat_buf, struct predicate *pred
}
bool
-pred_gid (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_gid (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
return compare_num (pred_ptr->args.numinfo.kind,
- pred_ptr->args.numinfo.l_val,
- stat_buf->st_gid);
+ pred_ptr->args.numinfo.l_val, stat_buf->st_gid);
}
bool
-pred_group (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_group (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
@@ -437,7 +459,8 @@ pred_group (const char *pathname, struct stat *stat_buf, struct predicate *pred_
}
bool
-pred_ilname (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_ilname (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
return match_lname (pathname, stat_buf, pred_ptr, true);
}
@@ -468,24 +491,26 @@ pred_name_common (const char *pathname, const char *str, int flags)
}
bool
-pred_iname (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_iname (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) stat_buf;
return pred_name_common (pathname, pred_ptr->args.str, FNM_CASEFOLD);
}
bool
-pred_inum (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_inum (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
return compare_num (pred_ptr->args.numinfo.kind,
- pred_ptr->args.numinfo.l_val,
- stat_buf->st_ino);
+ pred_ptr->args.numinfo.l_val, stat_buf->st_ino);
}
bool
-pred_ipath (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_ipath (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) stat_buf;
@@ -495,23 +520,25 @@ pred_ipath (const char *pathname, struct stat *stat_buf, struct predicate *pred_
}
bool
-pred_links (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_links (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
return compare_num (pred_ptr->args.numinfo.kind,
- pred_ptr->args.numinfo.l_val,
- stat_buf->st_nlink);
+ pred_ptr->args.numinfo.l_val, stat_buf->st_nlink);
}
bool
-pred_lname (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_lname (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
return match_lname (pathname, stat_buf, pred_ptr, false);
}
static bool
-match_lname (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr, bool ignore_case)
+match_lname (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr, bool ignore_case)
{
bool ret = false;
#ifdef S_ISLNK
@@ -536,49 +563,57 @@ match_lname (const char *pathname, struct stat *stat_buf, struct predicate *pred
}
bool
-pred_ls (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_ls (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
return pred_fls (pathname, stat_buf, pred_ptr);
}
bool
-pred_mmin (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_mmin (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) &pathname;
- return pred_timewindow (get_stat_mtime(stat_buf), pred_ptr, 60);
+ return pred_timewindow (get_stat_mtime (stat_buf), pred_ptr, 60);
}
bool
-pred_mtime (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_mtime (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
- return pred_timewindow (get_stat_mtime(stat_buf), pred_ptr, DAYSECS);
+ return pred_timewindow (get_stat_mtime (stat_buf), pred_ptr, DAYSECS);
}
bool
-pred_name (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_name (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) stat_buf;
return pred_name_common (pathname, pred_ptr->args.str, 0);
}
bool
-pred_negate (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_negate (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
return !apply_predicate (pathname, stat_buf, pred_ptr->pred_right);
}
bool
-pred_newer (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_newer (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
assert (COMP_GT == pred_ptr->args.reftime.kind);
- return timespec_cmp (get_stat_mtime(stat_buf), pred_ptr->args.reftime.ts) > 0;
+ return timespec_cmp (get_stat_mtime (stat_buf),
+ pred_ptr->args.reftime.ts) > 0;
}
bool
-pred_newerXY (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_newerXY (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
struct timespec ts;
bool collected = false;
@@ -624,7 +659,8 @@ pred_newerXY (const char *pathname, struct stat *stat_buf, struct predicate *pre
}
bool
-pred_nogroup (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_nogroup (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) pred_ptr;
@@ -632,7 +668,8 @@ pred_nogroup (const char *pathname, struct stat *stat_buf, struct predicate *pre
}
bool
-pred_nouser (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_nouser (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) pred_ptr;
@@ -648,7 +685,7 @@ is_ok (const char *program, const char *arg)
the last non-blank character of this prompt be '?'.
The exact format is not specified.
This standard does not have requirements for locales other than POSIX
- */
+ */
/* XXX: printing UNTRUSTED data here. */
if (fprintf (stderr, _("< %s ... %s > ? "), program, arg) < 0)
{
@@ -659,17 +696,17 @@ is_ok (const char *program, const char *arg)
}
bool
-predicate_uses_exec(const struct predicate* p)
+predicate_uses_exec (const struct predicate *p)
{
- return pred_is(p, pred_exec)
- || pred_is(p, pred_execdir)
- || pred_is(p, pred_ok)
- || pred_is(p, pred_okdir);
+ return pred_is (p, pred_exec)
+ || pred_is (p, pred_execdir)
+ || pred_is (p, pred_ok) || pred_is (p, pred_okdir);
}
bool
-pred_ok (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_ok (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
if (is_ok (pred_ptr->args.exec_vec.replace_vec[0], pathname))
return impl_pred_exec (pathname, stat_buf, pred_ptr);
@@ -678,7 +715,8 @@ pred_ok (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr
}
bool
-pred_okdir (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_okdir (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
if (is_ok (pred_ptr->args.exec_vec.replace_vec[0], pathname))
return impl_pred_exec (state.rel_pathname, stat_buf, pred_ptr);
@@ -687,7 +725,8 @@ pred_okdir (const char *pathname, struct stat *stat_buf, struct predicate *pred_
}
bool
-pred_openparen (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_openparen (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) stat_buf;
@@ -696,7 +735,8 @@ pred_openparen (const char *pathname, struct stat *stat_buf, struct predicate *p
}
bool
-pred_or (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_or (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
if (pred_ptr->pred_left == NULL
|| !apply_predicate (pathname, stat_buf, pred_ptr->pred_left))
@@ -708,7 +748,8 @@ pred_or (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr
}
bool
-pred_path (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_path (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) stat_buf;
if (fnmatch (pred_ptr->args.str, pathname, 0) == 0)
@@ -717,7 +758,8 @@ pred_path (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
}
bool
-pred_perm (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_perm (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
mode_t mode = stat_buf->st_mode;
mode_t perm_val = pred_ptr->args.perm.val[S_ISDIR (mode) != 0];
@@ -757,7 +799,8 @@ pred_perm (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
bool
-pred_executable (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_executable (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) stat_buf;
@@ -768,7 +811,8 @@ pred_executable (const char *pathname, struct stat *stat_buf, struct predicate *
}
bool
-pred_readable (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_readable (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) stat_buf;
@@ -779,7 +823,8 @@ pred_readable (const char *pathname, struct stat *stat_buf, struct predicate *pr
}
bool
-pred_writable (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_writable (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) stat_buf;
@@ -790,36 +835,38 @@ pred_writable (const char *pathname, struct stat *stat_buf, struct predicate *pr
}
bool
-pred_print (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_print (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) stat_buf;
(void) pred_ptr;
print_quoted (pred_ptr->args.printf_vec.stream,
pred_ptr->args.printf_vec.quote_opts,
- pred_ptr->args.printf_vec.dest_is_tty,
- "%s\n", pathname);
+ pred_ptr->args.printf_vec.dest_is_tty, "%s\n", pathname);
return true;
}
bool
-pred_print0 (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_print0 (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
- return pred_fprint0(pathname, stat_buf, pred_ptr);
+ return pred_fprint0 (pathname, stat_buf, pred_ptr);
}
bool
-pred_prune (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_prune (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) pred_ptr;
- if (options.do_dir_first == true) { /* no effect with -depth */
- assert (state.have_stat);
- if (stat_buf != NULL &&
- S_ISDIR(stat_buf->st_mode))
- state.stop_at_current_level = true;
- }
+ if (options.do_dir_first == true)
+ { /* no effect with -depth */
+ assert (state.have_stat);
+ if (stat_buf != NULL && S_ISDIR (stat_buf->st_mode))
+ state.stop_at_current_level = true;
+ }
/* findutils used to return options.do_dir_first here, so that -prune
* returns true only if -depth is not in effect. But POSIX requires
@@ -829,7 +876,8 @@ pred_prune (const char *pathname, struct stat *stat_buf, struct predicate *pred_
}
bool
-pred_quit (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_quit (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) stat_buf;
@@ -847,10 +895,11 @@ pred_quit (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
}
bool
-pred_regex (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_regex (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
int len = strlen (pathname);
-(void) stat_buf;
+ (void) stat_buf;
if (re_match (pred_ptr->args.regex, pathname, len, 0,
(struct re_registers *) NULL) == len)
return (true);
@@ -858,7 +907,8 @@ pred_regex (const char *pathname, struct stat *stat_buf, struct predicate *pred_
}
bool
-pred_size (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_size (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
uintmax_t f_val;
@@ -867,12 +917,12 @@ pred_size (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
+ (stat_buf->st_size % pred_ptr->args.size.blocksize != 0));
return compare_num (pred_ptr->args.size.kind,
- pred_ptr->args.size.size,
- f_val);
+ pred_ptr->args.size.size, f_val);
}
bool
-pred_samefile (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_samefile (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
/* Potential optimisation: because of the loop protection, we always
* know the device of the current directory, hence the device number
@@ -913,7 +963,8 @@ pred_samefile (const char *pathname, struct stat *stat_buf, struct predicate *pr
}
bool
-pred_true (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_true (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
(void) stat_buf;
@@ -922,7 +973,8 @@ pred_true (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
}
bool
-pred_type (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_type (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
mode_t mode;
enum file_type type = FTYPE_COUNT;
@@ -940,33 +992,33 @@ pred_type (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
(void) pathname;
if (state.have_stat)
- mode = stat_buf->st_mode;
+ mode = stat_buf->st_mode;
else
- mode = state.type;
+ mode = state.type;
#ifndef S_IFMT
/* POSIX system; check `mode' the slow way.
* Search in the order of probability (f,d,l,b,c,s,p,D).
*/
if (S_ISREG (mode))
- type = FTYPE_REG;
+ type = FTYPE_REG;
else if (S_ISDIR (mode))
- type = FTYPE_DIR;
+ type = FTYPE_DIR;
# ifdef S_IFLNK
else if (S_ISLNK (mode))
- type = FTYPE_LNK;
+ type = FTYPE_LNK;
# endif
else if (S_ISBLK (mode))
- type = FTYPE_BLK;
+ type = FTYPE_BLK;
else if (S_ISCHR (mode))
- type = FTYPE_CHR;
+ type = FTYPE_CHR;
# ifdef S_IFSOCK
else if (S_ISSOCK (mode))
- type = FTYPE_SOCK;
+ type = FTYPE_SOCK;
# endif
# ifdef S_IFIFO
else if (S_ISFIFO (mode))
- type = FTYPE_FIFO;
+ type = FTYPE_FIFO;
# endif
# ifdef S_IFDOOR
else if (S_ISDOOR (mode))
@@ -1018,17 +1070,18 @@ pred_type (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
}
bool
-pred_uid (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_uid (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
return compare_num (pred_ptr->args.numinfo.kind,
- pred_ptr->args.numinfo.l_val,
- stat_buf->st_uid);
+ pred_ptr->args.numinfo.l_val, stat_buf->st_uid);
}
/* File was last accessed less than, more than or exactly n days after its status was last changed. */
bool
-pred_used (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_used (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
struct timespec delta, at, ct;
@@ -1041,18 +1094,19 @@ pred_used (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
if (timespec_cmp (at, ct) < 0)
return false;
- delta.tv_sec = ct.tv_sec - at.tv_sec;
+ delta.tv_sec = ct.tv_sec - at.tv_sec;
delta.tv_nsec = ct.tv_nsec - at.tv_nsec;
if (delta.tv_nsec < 0)
{
delta.tv_nsec += 1000000000;
- delta.tv_sec -= 1;
+ delta.tv_sec -= 1;
}
return pred_timewindow (delta, pred_ptr, DAYSECS);
}
bool
-pred_user (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_user (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
(void) pathname;
if (pred_ptr->args.uid == stat_buf->st_uid)
@@ -1062,7 +1116,7 @@ pred_user (const char *pathname, struct stat *stat_buf, struct predicate *pred_p
}
static bool
-err_signals_broken_link(int errno_value)
+err_signals_broken_link (int errno_value)
{
switch (errno_value)
{
@@ -1077,16 +1131,17 @@ err_signals_broken_link(int errno_value)
bool
-pred_xtype (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_xtype (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
struct stat sbuf; /* local copy, not stat_buf because we're using a different stat method */
- int (*ystat) (const char*, struct stat *p);
+ int (*ystat) (const char *, struct stat * p);
/* If we would normally stat the link itself, stat the target instead.
* If we would normally follow the link, stat the link itself instead.
*/
- const bool ystat_follows_links = !following_links();
+ const bool ystat_follows_links = !following_links ();
if (ystat_follows_links)
ystat = optionl_stat;
else
@@ -1186,7 +1241,7 @@ print_parenthesised (FILE *fp, struct predicate *node)
/* We print "<nothing> or X" as just "X"
* We print "<nothing> and X" as just "X"
*/
- print_parenthesised(fp, node->pred_right);
+ print_parenthesised (fp, node->pred_right);
}
else
{
@@ -1217,10 +1272,12 @@ print_optlist (FILE *fp, const struct predicate *p)
fprintf (fp, " [est success rate %.4g] ", p->est_success_rate);
if (options.debug_options & DebugSuccessRates)
{
- fprintf (fp, "[real success rate %lu/%lu", p->perf.successes, p->perf.visits);
+ fprintf (fp, "[real success rate %lu/%lu", p->perf.successes,
+ p->perf.visits);
if (p->perf.visits)
{
- double real_rate = (double)p->perf.successes / (double)p->perf.visits;
+ double real_rate =
+ (double) p->perf.successes / (double) p->perf.visits;
fprintf (fp, "=%.4g] ", real_rate);
}
else
@@ -1232,7 +1289,8 @@ print_optlist (FILE *fp, const struct predicate *p)
}
}
-void show_success_rates (const struct predicate *p)
+void
+show_success_rates (const struct predicate *p)
{
if (options.debug_options & DebugSuccessRates)
{
@@ -1262,7 +1320,7 @@ pred_sanity_check (const struct predicate *predicates)
{
const struct predicate *p;
- for (p=predicates; p != NULL; p=p->pred_next)
+ for (p = predicates; p != NULL; p = p->pred_next)
{
/* All predicates must do something. */
assert (p->pred_func != NULL);
@@ -1298,8 +1356,8 @@ pred_sanity_check (const struct predicate *predicates)
break;
case ARG_ACTION:
- assert (p->side_effects); /* actions have side effects. */
- if (!pred_is (p, pred_prune) && !pred_is(p, pred_quit))
+ assert (p->side_effects); /* actions have side effects. */
+ if (!pred_is (p, pred_prune) && !pred_is (p, pred_quit))
{
/* actions other than -prune and -quit should
* inhibit the default -print
@@ -1308,9 +1366,9 @@ pred_sanity_check (const struct predicate *predicates)
}
break;
- /* We happen to know that the only user of ARG_SPECIAL_PARSE
- * is a test, so handle it like ARG_TEST.
- */
+ /* We happen to know that the only user of ARG_SPECIAL_PARSE
+ * is a test, so handle it like ARG_TEST.
+ */
case ARG_SPECIAL_PARSE:
case ARG_TEST:
case ARG_PUNCTUATION:
diff --git a/find/print.c b/find/print.c
index e12c7c15..41c3e3c4 100644
--- a/find/print.c
+++ b/find/print.c
@@ -54,21 +54,21 @@
#undef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
-static void checked_fprintf (struct format_val *dest, const char *fmt, ...)
- _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(2, 3);
+static void
+checked_fprintf (struct format_val *dest, const char *fmt, ...)
+_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3);
/* Create a new fprintf segment in *SEGMENT, with type KIND,
from the text in FORMAT, which has length LEN.
Return the address of the `next' pointer of the new segment. */
-struct segment **
-make_segment (struct segment **segment,
- char *format,
- int len,
- int kind,
- char format_char,
- char aux_format_char,
- struct predicate *pred)
+ struct segment **make_segment (struct segment **segment,
+ char *format,
+ int len,
+ int kind,
+ char format_char,
+ char aux_format_char,
+ struct predicate *pred)
{
enum EvaluationCost mycost = NeedsNothing;
char *fmt;
@@ -89,8 +89,8 @@ make_segment (struct segment **segment,
strncpy (fmt, format, len);
fmt += len;
- if (kind == KIND_PLAIN /* Plain text string, no % conversion. */
- || kind == KIND_STOP) /* Terminate argument, no newline. */
+ if (kind == KIND_PLAIN /* Plain text string, no % conversion. */
+ || kind == KIND_STOP) /* Terminate argument, no newline. */
{
assert (0 == format_char);
assert (0 == aux_format_char);
@@ -175,7 +175,7 @@ make_segment (struct segment **segment,
*/
case 'G': /* GID number */
case 'U': /* UID number */
- case 'b': /* size in 512-byte blocks (NOT birthtime in ctime fmt)*/
+ case 'b': /* size in 512-byte blocks (NOT birthtime in ctime fmt) */
case 'D': /* Filesystem device on which the file exits */
case 'k': /* size in 1K blocks */
case 'n': /* number of links */
@@ -210,12 +210,12 @@ is_octal_char (char ch)
}
static char
-parse_octal_escape(const char *p, size_t *consumed)
+parse_octal_escape (const char *p, size_t *consumed)
{
register int n, i;
size_t pos = 0;
- for (i = n = 0; i < 3 && is_octal_char(p[pos]); i++, pos++)
+ for (i = n = 0; i < 3 && is_octal_char (p[pos]); i++, pos++)
{
n = 8 * n + p[pos] - '0';
}
@@ -225,7 +225,7 @@ parse_octal_escape(const char *p, size_t *consumed)
}
static int
-parse_escape_char(const char ch)
+parse_escape_char (const char ch)
{
char value = 0;
switch (ch)
@@ -260,7 +260,7 @@ parse_escape_char(const char ch)
static size_t
-get_format_flags_length(const char *p)
+get_format_flags_length (const char *p)
{
size_t n = 0;
/* Scan past flags, width and precision, to verify kind. */
@@ -277,7 +277,7 @@ get_format_flags_length(const char *p)
}
static size_t
-get_format_specifer_length(char ch)
+get_format_specifer_length (char ch)
{
if (strchr ("abcdDfFgGhHiklmMnpPsStuUyYZ%", ch))
{
@@ -296,12 +296,11 @@ get_format_specifer_length(char ch)
bool
insert_fprintf (struct format_val *vec,
- const struct parser_table *entry,
- char *format)
+ const struct parser_table *entry, char *format)
{
char *segstart = format;
- char *fmt_editpos; /* Current address in scanning `format'. */
- struct segment **segmentp; /* Address of current segment. */
+ char *fmt_editpos; /* Current address in scanning `format'. */
+ struct segment **segmentp; /* Address of current segment. */
struct predicate *our_pred;
our_pred = insert_primary_withpred (entry, pred_fprintf, format);
@@ -309,7 +308,7 @@ insert_fprintf (struct format_val *vec,
our_pred->args.printf_vec = *vec;
our_pred->need_type = false;
our_pred->need_stat = false;
- our_pred->p_cost = NeedsNothing;
+ our_pred->p_cost = NeedsNothing;
segmentp = &our_pred->args.printf_vec.segment;
*segmentp = NULL;
@@ -319,8 +318,7 @@ insert_fprintf (struct format_val *vec,
if (fmt_editpos[0] == '\\' && fmt_editpos[1] == 'c')
{
make_segment (segmentp, segstart, fmt_editpos - segstart,
- KIND_STOP, 0, 0,
- our_pred);
+ KIND_STOP, 0, 0, our_pred);
if (our_pred->need_stat && (our_pred->p_cost < NeedsStatInfo))
our_pred->p_cost = NeedsStatInfo;
return true;
@@ -330,19 +328,21 @@ insert_fprintf (struct format_val *vec,
size_t readpos = 1;
if (!fmt_editpos[readpos])
{
- error (0, 0, _("warning: escape `\\' followed by nothing at all"));
+ error (0, 0,
+ _("warning: escape `\\' followed by nothing at all"));
--readpos;
/* (*fmt_editpos) is already '\\' and that's a reasonable result. */
}
- else if (is_octal_char(fmt_editpos[readpos]))
+ else if (is_octal_char (fmt_editpos[readpos]))
{
size_t consumed = 0;
- *fmt_editpos = parse_octal_escape(fmt_editpos + readpos, &consumed);
+ *fmt_editpos =
+ parse_octal_escape (fmt_editpos + readpos, &consumed);
readpos += consumed;
}
else
{
- const char val = parse_escape_char(fmt_editpos[readpos]);
+ const char val = parse_escape_char (fmt_editpos[readpos]);
if (val)
{
fmt_editpos[0] = val;
@@ -357,10 +357,9 @@ insert_fprintf (struct format_val *vec,
}
segmentp = make_segment (segmentp,
segstart, fmt_editpos - segstart + 1,
- KIND_PLAIN, 0, 0,
- our_pred);
+ KIND_PLAIN, 0, 0, our_pred);
segstart = fmt_editpos + readpos + 1; /* Move past the escape. */
- fmt_editpos += readpos; /* Incremented immediately by `for'. */
+ fmt_editpos += readpos; /* Incremented immediately by `for'. */
}
else if (fmt_editpos[0] == '%')
{
@@ -372,14 +371,14 @@ insert_fprintf (struct format_val *vec,
_("error: %s at end of format string"), fmt_editpos);
}
- if (fmt_editpos[1] == '%') /* %% produces just %. */
+ if (fmt_editpos[1] == '%') /* %% produces just %. */
len = 1;
else
- len = get_format_flags_length(fmt_editpos);
+ len = get_format_flags_length (fmt_editpos);
fmt_editpos += len;
len = get_format_specifer_length (fmt_editpos[0]);
- if (len && (fmt_editpos[len-1]))
+ if (len && (fmt_editpos[len - 1]))
{
const char fmt2 = (len == 2) ? fmt_editpos[1] : 0;
segmentp = make_segment (segmentp, segstart,
@@ -393,10 +392,10 @@ insert_fprintf (struct format_val *vec,
if (strchr ("{[(", fmt_editpos[0]))
{
error (EXIT_FAILURE, 0,
- _("error: the format directive `%%%c' is reserved for future use"),
- (int)fmt_editpos[0]);
- /*NOTREACHED*/
- }
+ _
+ ("error: the format directive `%%%c' is reserved for future use"),
+ (int) fmt_editpos[0]);
+ /*NOTREACHED*/}
if (len == 2 && !fmt_editpos[1])
{
@@ -414,16 +413,15 @@ insert_fprintf (struct format_val *vec,
}
segmentp = make_segment (segmentp,
segstart, fmt_editpos + 1 - segstart,
- KIND_PLAIN, 0, 0,
- our_pred);
+ KIND_PLAIN, 0, 0, our_pred);
}
segstart = fmt_editpos + 1;
}
}
if (fmt_editpos > segstart)
- make_segment (segmentp, segstart, fmt_editpos - segstart, KIND_PLAIN, 0, 0,
- our_pred);
+ make_segment (segmentp, segstart, fmt_editpos - segstart, KIND_PLAIN, 0,
+ 0, our_pred);
return true;
}
@@ -434,11 +432,12 @@ scan_for_digit_differences (const char *p, const char *q,
bool seen = false;
size_t i;
- for (i=0; p[i] && q[i]; i++)
+ for (i = 0; p[i] && q[i]; i++)
{
if (p[i] != q[i])
{
- if (!isdigit ((unsigned char)p[i]) || !isdigit ((unsigned char)q[i]))
+ if (!isdigit ((unsigned char) p[i])
+ || !isdigit ((unsigned char) q[i]))
return false;
if (!seen)
@@ -449,7 +448,7 @@ scan_for_digit_differences (const char *p, const char *q,
}
else
{
- if (i-*first == *n)
+ if (i - *first == *n)
{
/* Still in the first sequence of differing digits. */
++*n;
@@ -470,8 +469,9 @@ scan_for_digit_differences (const char *p, const char *q,
return true;
}
-static char*
-do_time_format (const char *fmt, const struct tm *p, const char *ns, size_t ns_size)
+static char *
+do_time_format (const char *fmt, const struct tm *p, const char *ns,
+ size_t ns_size)
{
static char *buf = NULL;
static size_t buf_size;
@@ -515,12 +515,11 @@ do_time_format (const char *fmt, const struct tm *p, const char *ns, size_t ns_s
*/
size_t buf_used = strftime (buf, buf_size, timefmt, p);
if (buf_used /* Conforming POSIX system */
- && (buf_used < buf_size)) /* Solaris workaround */
+ && (buf_used < buf_size)) /* Solaris workaround */
{
char *altbuf;
size_t i = 0, n = 0;
- size_t final_len = (buf_used
- + 1u /* for \0 */
+ size_t final_len = (buf_used + 1u /* for \0 */
+ ns_size);
buf = xrealloc (buf, final_len);
buf_size = final_len;
@@ -534,10 +533,10 @@ do_time_format (const char *fmt, const struct tm *p, const char *ns, size_t ns_s
* When that happens, we just avoid inserting the nanoseconds field.
*/
if (scan_for_digit_differences (buf, altbuf, &i, &n)
- && (2==n) && !isdigit ((unsigned char)buf[i+n]))
+ && (2 == n) && !isdigit ((unsigned char) buf[i + n]))
{
const size_t end_of_seconds = i + n;
- const size_t suffix_len = buf_used-(end_of_seconds)+1;
+ const size_t suffix_len = buf_used - (end_of_seconds) + 1;
/* Move the tail (including the \0). Note that this
* is a move of an overlapping memory block, so we
@@ -545,10 +544,9 @@ do_time_format (const char *fmt, const struct tm *p, const char *ns, size_t ns_s
* the nanoseconds (but not its trailing \0).
*/
assert (end_of_seconds + ns_size + suffix_len == final_len);
- memmove (buf+end_of_seconds+ns_size,
- buf+end_of_seconds,
- suffix_len);
- memcpy (buf+i+n, ns, ns_size);
+ memmove (buf + end_of_seconds + ns_size,
+ buf + end_of_seconds, suffix_len);
+ memcpy (buf + i + n, ns, ns_size);
}
else
{
@@ -559,7 +557,7 @@ do_time_format (const char *fmt, const struct tm *p, const char *ns, size_t ns_s
*/
free (timefmt);
free (altbuf);
- return buf+1;
+ return buf + 1;
}
else
{
@@ -594,14 +592,16 @@ format_date (struct timespec ts, int kind)
* NetBSD appears to be a result of the use of uninitialized data,
* as it's not 100% reproducible (more like 25%).
*/
- enum {
+ enum
+ {
NS_BUF_LEN = 32,
- DATE_LEN_PERCENT_APLUS=21 /* length of result of %A+ (it's longer than %c)*/
+ DATE_LEN_PERCENT_APLUS = 21 /* length of result of %A+ (it's longer than %c) */
};
- static char buf[128u+10u + MAX(DATE_LEN_PERCENT_APLUS,
- MAX (LONGEST_HUMAN_READABLE + 2, NS_BUF_LEN+64+200))];
- char ns_buf[NS_BUF_LEN]; /* -.9999999990 (- sign can happen!)*/
- int charsprinted, need_ns_suffix;
+ static char buf[128u + 10u + MAX (DATE_LEN_PERCENT_APLUS,
+ MAX (LONGEST_HUMAN_READABLE + 2,
+ NS_BUF_LEN + 64 + 200))];
+ char ns_buf[NS_BUF_LEN]; /* -.9999999990 (- sign can happen!) */
+ int charsprinted, need_ns_suffix;
struct tm *tm;
char fmt[12];
@@ -659,7 +659,8 @@ format_date (struct timespec ts, int kind)
* The reason for discouraging this is that in the future, the
* granularity may not be nanoseconds.
*/
- charsprinted = snprintf (ns_buf, NS_BUF_LEN, ".%09ld0", (long int)ts.tv_nsec);
+ charsprinted =
+ snprintf (ns_buf, NS_BUF_LEN, ".%09ld0", (long int) ts.tv_nsec);
assert (charsprinted < NS_BUF_LEN);
}
else
@@ -695,7 +696,7 @@ format_date (struct timespec ts, int kind)
assert (p > buf);
assert (p < (buf + (sizeof buf)));
if (ts.tv_sec < 0)
- *--p = '-'; /* XXX: Ugh, relying on internal details of human_readable(). */
+ *--p = '-'; /* XXX: Ugh, relying on internal details of human_readable(). */
/* Add the nanoseconds part. Because we cannot enforce a
* particular implementation of human_readable, we cannot assume
@@ -705,15 +706,15 @@ format_date (struct timespec ts, int kind)
if (need_ns_suffix)
{
len = strlen (p);
- used = (p-buf) + len; /* Offset into buf of current end */
- assert (sizeof buf > used); /* Ensure we can perform subtraction safely. */
- remaining = sizeof buf - used - 1u; /* allow space for NUL */
+ used = (p - buf) + len; /* Offset into buf of current end */
+ assert (sizeof buf > used); /* Ensure we can perform subtraction safely. */
+ remaining = sizeof buf - used - 1u; /* allow space for NUL */
if (strlen (ns_buf) >= remaining)
{
error (0, 0,
"charsprinted=%ld but remaining=%lu: ns_buf=%s",
- (long)charsprinted, (unsigned long)remaining, ns_buf);
+ (long) charsprinted, (unsigned long) remaining, ns_buf);
}
assert (strlen (ns_buf) < remaining);
strcat (p, ns_buf);
@@ -722,21 +723,20 @@ format_date (struct timespec ts, int kind)
}
}
-static const char *weekdays[] =
- {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
-static const char * months[] =
- {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
+static const char *weekdays[] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
+
+static const char *months[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
static char *
ctime_format (struct timespec ts)
{
- const struct tm * ptm;
+ const struct tm *ptm;
#define TIME_BUF_LEN 1024
static char resultbuf[TIME_BUF_LEN];
int nout;
@@ -744,14 +744,14 @@ ctime_format (struct timespec ts)
ptm = localtime (&ts.tv_sec);
if (ptm)
{
- assert (ptm->tm_wday >= 0);
- assert (ptm->tm_wday < 7);
- assert (ptm->tm_mon >= 0);
- assert (ptm->tm_mon < 12);
- assert (ptm->tm_hour >= 0);
- assert (ptm->tm_hour < 24);
- assert (ptm->tm_min < 60);
- assert (ptm->tm_sec <= 61); /* allows 2 leap seconds. */
+ assert (ptm->tm_wday >= 0);
+ assert (ptm->tm_wday < 7);
+ assert (ptm->tm_mon >= 0);
+ assert (ptm->tm_mon < 12);
+ assert (ptm->tm_hour >= 0);
+ assert (ptm->tm_hour < 24);
+ assert (ptm->tm_min < 60);
+ assert (ptm->tm_sec <= 61); /* allows 2 leap seconds. */
/* wkday mon mday hh:mm:ss.nnnnnnnnn yyyy */
nout = snprintf (resultbuf, TIME_BUF_LEN,
@@ -762,8 +762,7 @@ ctime_format (struct timespec ts)
ptm->tm_hour,
ptm->tm_min,
ptm->tm_sec,
- (long int)ts.tv_nsec,
- 1900 + ptm->tm_year);
+ (long int) ts.tv_nsec, 1900 + ptm->tm_year);
assert (nout < TIME_BUF_LEN);
return resultbuf;
@@ -781,14 +780,14 @@ file_sparseness (const struct stat *p)
{
if (0 == p->st_size)
{
- if (0 == ST_NBLOCKS(*p))
+ if (0 == ST_NBLOCKS (*p))
return 1.0;
else
- return ST_NBLOCKS(*p) < 0 ? -HUGE_VAL : HUGE_VAL;
+ return ST_NBLOCKS (*p) < 0 ? -HUGE_VAL : HUGE_VAL;
}
else
{
- double blklen = ST_NBLOCKSIZE * (double)ST_NBLOCKS(*p);
+ double blklen = ST_NBLOCKSIZE * (double) ST_NBLOCKS (*p);
return blklen / p->st_size;
}
}
@@ -835,33 +834,33 @@ checked_fflush (struct format_val *dest)
}
}
-static const char*
+static const char *
mode_to_filetype (mode_t m)
{
#define HANDLE_TYPE(t,letter) if (m==t) { return letter; }
#ifdef S_IFREG
- HANDLE_TYPE(S_IFREG, "f"); /* regular file */
+ HANDLE_TYPE (S_IFREG, "f"); /* regular file */
#endif
#ifdef S_IFDIR
- HANDLE_TYPE(S_IFDIR, "d"); /* directory */
+ HANDLE_TYPE (S_IFDIR, "d"); /* directory */
#endif
#ifdef S_IFLNK
- HANDLE_TYPE(S_IFLNK, "l"); /* symbolic link */
+ HANDLE_TYPE (S_IFLNK, "l"); /* symbolic link */
#endif
#ifdef S_IFSOCK
- HANDLE_TYPE(S_IFSOCK, "s"); /* Unix domain socket */
+ HANDLE_TYPE (S_IFSOCK, "s"); /* Unix domain socket */
#endif
#ifdef S_IFBLK
- HANDLE_TYPE(S_IFBLK, "b"); /* block device */
+ HANDLE_TYPE (S_IFBLK, "b"); /* block device */
#endif
#ifdef S_IFCHR
- HANDLE_TYPE(S_IFCHR, "c"); /* character device */
+ HANDLE_TYPE (S_IFCHR, "c"); /* character device */
#endif
#ifdef S_IFIFO
- HANDLE_TYPE(S_IFIFO, "p"); /* FIFO */
+ HANDLE_TYPE (S_IFIFO, "p"); /* FIFO */
#endif
#ifdef S_IFDOOR
- HANDLE_TYPE(S_IFDOOR, "D"); /* Door (e.g. on Solaris) */
+ HANDLE_TYPE (S_IFDOOR, "D"); /* Door (e.g. on Solaris) */
#endif
return "U"; /* Unknown */
}
@@ -871,17 +870,16 @@ mode_to_filetype (mode_t m)
static void
do_fprintf (struct format_val *dest,
struct segment *segment,
- const char *pathname,
- const struct stat *stat_buf)
+ const char *pathname, const struct stat *stat_buf)
{
char hbuf[LONGEST_HUMAN_READABLE + 1];
const char *cp;
switch (segment->segkind)
{
- case KIND_PLAIN: /* Plain text string (no % conversion). */
+ case KIND_PLAIN: /* Plain text string (no % conversion). */
/* trusted */
- checked_fwrite(segment->text, 1, segment->text_len, dest);
+ checked_fwrite (segment->text, 1, segment->text_len, dest);
break;
case KIND_STOP: /* Terminate argument and flush output. */
@@ -895,7 +893,8 @@ do_fprintf (struct format_val *dest,
{
case 'a': /* atime in `ctime' format. */
/* UNTRUSTED, probably unexploitable */
- checked_fprintf (dest, segment->text, ctime_format (get_stat_atime (stat_buf)));
+ checked_fprintf (dest, segment->text,
+ ctime_format (get_stat_atime (stat_buf)));
break;
case 'b': /* size in 512-byte blocks */
/* UNTRUSTED, probably unexploitable */
@@ -906,7 +905,8 @@ do_fprintf (struct format_val *dest,
break;
case 'c': /* ctime in `ctime' format */
/* UNTRUSTED, probably unexploitable */
- checked_fprintf (dest, segment->text, ctime_format (get_stat_ctime (stat_buf)));
+ checked_fprintf (dest, segment->text,
+ ctime_format (get_stat_ctime (stat_buf)));
break;
case 'd': /* depth in search tree */
/* UNTRUSTED, probably unexploitable */
@@ -928,7 +928,8 @@ do_fprintf (struct format_val *dest,
break;
case 'F': /* file system type */
/* trusted */
- checked_print_quoted (dest, segment->text, filesystem_type (stat_buf, pathname));
+ checked_print_quoted (dest, segment->text,
+ filesystem_type (stat_buf, pathname));
break;
case 'g': /* group name */
/* trusted */
@@ -946,7 +947,7 @@ do_fprintf (struct format_val *dest,
break;
}
}
- FALLTHROUGH; /*...sometimes, so 'G' case.*/
+ FALLTHROUGH; /*...sometimes, so 'G' case. */
case 'G': /* GID number */
/* UNTRUSTED, probably unexploitable */
@@ -960,15 +961,15 @@ do_fprintf (struct format_val *dest,
char *pname = xstrdup (pathname);
/* Remove trailing slashes - unless it's the root '/' directory. */
- char *s = pname + strlen (pname) -1;
- for ( ; pname <= s; s--)
+ char *s = pname + strlen (pname) - 1;
+ for (; pname <= s; s--)
if (*s != '/')
break;
- if (pname < s && *(s+1) == '/')
- *(s+1) = '\0';
+ if (pname < s && *(s + 1) == '/')
+ *(s + 1) = '\0';
s = strrchr (pname, '/');
- if (s == NULL) /* No leading directories. */
+ if (s == NULL) /* No leading directories. */
{
/* If there is no slash in the pathname, we still
* print the string because it contains characters
@@ -988,7 +989,7 @@ do_fprintf (struct format_val *dest,
case 'H': /* ARGV element file was found under */
/* trusted */
{
- char *s = xmalloc (state.starting_path_length+1);
+ char *s = xmalloc (state.starting_path_length + 1);
memcpy (s, pathname, state.starting_path_length);
s[state.starting_path_length] = 0;
checked_fprintf (dest, segment->text, s);
@@ -1005,8 +1006,7 @@ do_fprintf (struct format_val *dest,
* arithmetic type. */
checked_fprintf (dest, segment->text,
human_readable ((uintmax_t) stat_buf->st_ino, hbuf,
- human_ceiling,
- 1, 1));
+ human_ceiling, 1, 1));
break;
case 'k': /* size in 1K blocks */
/* UNTRUSTED, but not exploitable I think */
@@ -1043,13 +1043,13 @@ do_fprintf (struct format_val *dest,
}
free (linkname);
}
-#endif /* S_ISLNK */
+#endif /* S_ISLNK */
break;
case 'M': /* mode as 10 chars (eg., "-rwxr-x--x" */
/* UNTRUSTED, probably unexploitable */
{
- char modestring[16] ;
+ char modestring[16];
filemodestring (stat_buf, modestring);
modestring[10] = '\0';
checked_fprintf (dest, segment->text, modestring);
@@ -1070,30 +1070,28 @@ do_fprintf (struct format_val *dest,
&& S_IRGRP == 00040 && S_IWGRP == 00020 && S_IXGRP == 00010
&& S_IROTH == 00004 && S_IWOTH == 00002 && S_IXOTH == 00001);
checked_fprintf (dest, segment->text,
- (traditional_numbering_scheme
- ? m & MODE_ALL
- : ((m & S_ISUID ? 04000 : 0)
- | (m & S_ISGID ? 02000 : 0)
- | (m & S_ISVTX ? 01000 : 0)
- | (m & S_IRUSR ? 00400 : 0)
- | (m & S_IWUSR ? 00200 : 0)
- | (m & S_IXUSR ? 00100 : 0)
- | (m & S_IRGRP ? 00040 : 0)
- | (m & S_IWGRP ? 00020 : 0)
- | (m & S_IXGRP ? 00010 : 0)
- | (m & S_IROTH ? 00004 : 0)
- | (m & S_IWOTH ? 00002 : 0)
- | (m & S_IXOTH ? 00001 : 0))));
+ (traditional_numbering_scheme
+ ? m & MODE_ALL
+ : ((m & S_ISUID ? 04000 : 0)
+ | (m & S_ISGID ? 02000 : 0)
+ | (m & S_ISVTX ? 01000 : 0)
+ | (m & S_IRUSR ? 00400 : 0)
+ | (m & S_IWUSR ? 00200 : 0)
+ | (m & S_IXUSR ? 00100 : 0)
+ | (m & S_IRGRP ? 00040 : 0)
+ | (m & S_IWGRP ? 00020 : 0)
+ | (m & S_IXGRP ? 00010 : 0)
+ | (m & S_IROTH ? 00004 : 0)
+ | (m & S_IWOTH ? 00002 : 0)
+ | (m & S_IXOTH ? 00001 : 0))));
}
break;
case 'n': /* number of links */
/* UNTRUSTED, probably unexploitable */
checked_fprintf (dest, segment->text,
- human_readable ((uintmax_t) stat_buf->st_nlink,
- hbuf,
- human_ceiling,
- 1, 1));
+ human_readable ((uintmax_t) stat_buf->st_nlink,
+ hbuf, human_ceiling, 1, 1));
break;
case 'p': /* pathname */
@@ -1123,8 +1121,8 @@ do_fprintf (struct format_val *dest,
case 's': /* size in bytes */
/* UNTRUSTED, probably unexploitable */
checked_fprintf (dest, segment->text,
- human_readable ((uintmax_t) stat_buf->st_size,
- hbuf, human_ceiling, 1, 1));
+ human_readable ((uintmax_t) stat_buf->st_size,
+ hbuf, human_ceiling, 1, 1));
break;
case 'S': /* sparseness */
@@ -1155,7 +1153,7 @@ do_fprintf (struct format_val *dest,
break;
}
}
- FALLTHROUGH; /* .. to case U */
+ FALLTHROUGH; /* .. to case U */
case 'U': /* UID number */
/* UNTRUSTED, probably unexploitable */
@@ -1179,14 +1177,15 @@ do_fprintf (struct format_val *dest,
* (Actually we do not even come here when following_links()
* other than the ENOENT case.)
*/
- if (fstatat (state.cwd_dir_fd, state.rel_pathname, &sbuf, 0) != 0)
+ if (fstatat (state.cwd_dir_fd, state.rel_pathname, &sbuf, 0)
+ != 0)
{
- if ( (errno == ENOENT) || (errno == ENOTDIR) )
+ if ((errno == ENOENT) || (errno == ENOTDIR))
{
checked_fprintf (dest, segment->text, "N");
break;
}
- else if ( errno == ELOOP )
+ else if (errno == ELOOP)
{
checked_fprintf (dest, segment->text, "L");
break;
@@ -1208,7 +1207,8 @@ do_fprintf (struct format_val *dest,
#endif /* S_ISLNK */
{
checked_fprintf (dest, segment->text,
- mode_to_filetype (stat_buf->st_mode & S_IFMT));
+ mode_to_filetype (stat_buf->st_mode &
+ S_IFMT));
}
}
break;
@@ -1224,8 +1224,9 @@ do_fprintf (struct format_val *dest,
case 'Z': /* SELinux security context */
{
char *scontext;
- int rv = (*options.x_getfilecon) (state.cwd_dir_fd, state.rel_pathname,
- &scontext);
+ int rv =
+ (*options.x_getfilecon) (state.cwd_dir_fd, state.rel_pathname,
+ &scontext);
if (rv < 0)
{
/* If getfilecon fails, there will in the general case
@@ -1234,7 +1235,7 @@ do_fprintf (struct format_val *dest,
checked_fprintf (dest, segment->text, "");
error (0, errno, _("getfilecon failed: %s"),
- safely_quote_err_filename (0, pathname));
+ safely_quote_err_filename (0, pathname));
state.exit_status = EXIT_FAILURE;
}
else
@@ -1255,9 +1256,9 @@ do_fprintf (struct format_val *dest,
simply to ensure that the error message matches the one
in insert_fprintf, easing the translation burden.
*/
- error (EXIT_FAILURE, 0, _("error: %s at end of format string"), "%");
- /*NOTREACHED*/
- break;
+ error (EXIT_FAILURE, 0, _("error: %s at end of format string"),
+ "%");
+ /*NOTREACHED*/ break;
}
/* end of KIND_FORMAT case */
break;
@@ -1265,14 +1266,15 @@ do_fprintf (struct format_val *dest,
}
bool
-pred_fprintf (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+pred_fprintf (const char *pathname, struct stat *stat_buf,
+ struct predicate *pred_ptr)
{
struct format_val *dest = &pred_ptr->args.printf_vec;
struct segment *segment;
for (segment = dest->segment; segment; segment = segment->next)
{
- if ( (KIND_FORMAT == segment->segkind) && segment->format_char[1]) /* Component of date. */
+ if ((KIND_FORMAT == segment->segkind) && segment->format_char[1]) /* Component of date. */
{
struct timespec ts;
int valid = 0;
diff --git a/find/print.h b/find/print.h
index 07420e05..96017885 100644
--- a/find/print.h
+++ b/find/print.h
@@ -27,11 +27,9 @@ struct segment;
struct segment **make_segment (struct segment **segment,
char *format, int len,
int kind, char format_char,
- char aux_format_char,
- struct predicate *pred);
+ char aux_format_char, struct predicate *pred);
bool
insert_fprintf (struct format_val *vec,
- const struct parser_table *entry,
- char *format);
+ const struct parser_table *entry, char *format);
#endif /* PRINT_H */
diff --git a/find/sharefile.c b/find/sharefile.c
index 9b48fc3e..6d3c8c55 100644
--- a/find/sharefile.c
+++ b/find/sharefile.c
@@ -37,9 +37,9 @@
enum
- {
- DefaultHashTableSize = 11
- };
+{
+ DefaultHashTableSize = 11
+};
struct sharefile
{
@@ -61,7 +61,7 @@ struct SharefileEntry
{
dev_t device;
ino_t inode;
- char *name; /* not the only name for this file; error messages only */
+ char *name; /* not the only name for this file; error messages only */
FILE *fp;
};
@@ -69,7 +69,7 @@ struct SharefileEntry
static bool
entry_comparator (const void *av, const void *bv)
{
- const struct SharefileEntry *a=av, *b=bv;
+ const struct SharefileEntry *a = av, *b = bv;
return (a->inode == b->inode) && (a->device == b->device);
}
@@ -108,8 +108,7 @@ sharefile_init (const char *mode)
{
p->table = hash_initialize (DefaultHashTableSize, NULL,
entry_hashfunc,
- entry_comparator,
- entry_free);
+ entry_comparator, entry_free);
if (p->table)
{
return p;
@@ -179,18 +178,18 @@ sharefile_fopen (sharefile_handle h, const char *filename)
new_entry->inode = st.st_ino;
existing = hash_lookup (p->table, new_entry);
- if (existing) /* We have previously opened that file. */
+ if (existing) /* We have previously opened that file. */
{
- entry_free (new_entry); /* don't need new_entry. */
- return ((const struct SharefileEntry*)existing)->fp;
+ entry_free (new_entry); /* don't need new_entry. */
+ return ((const struct SharefileEntry *) existing)->fp;
}
- else /* We didn't open it already */
+ else /* We didn't open it already */
{
if (hash_insert (p->table, new_entry))
{
return new_entry->fp;
}
- else /* failed to insert in hashtable. */
+ else /* failed to insert in hashtable. */
{
const int save_errno = errno;
entry_free (new_entry);
diff --git a/find/sharefile.h b/find/sharefile.h
index ae32b674..510c8010 100644
--- a/find/sharefile.h
+++ b/find/sharefile.h
@@ -22,10 +22,10 @@
# include <stdlib.h>
# include <stdio.h>
-typedef void * sharefile_handle;
+typedef void *sharefile_handle;
-sharefile_handle sharefile_init(const char *mode);
-FILE *sharefile_fopen(sharefile_handle, const char *filename);
-void sharefile_destroy(sharefile_handle);
+sharefile_handle sharefile_init (const char *mode);
+FILE *sharefile_fopen (sharefile_handle, const char *filename);
+void sharefile_destroy (sharefile_handle);
#endif
diff --git a/find/tree.c b/find/tree.c
index d0789eb9..90bd6ae7 100644
--- a/find/tree.c
+++ b/find/tree.c
@@ -35,7 +35,7 @@
static struct predicate *predicates = NULL;
/* The root of the evaluation tree. */
-static struct predicate *eval_tree = NULL;
+static struct predicate *eval_tree = NULL;
/* The last predicate allocated. */
static struct predicate *last_pred = NULL;
@@ -49,8 +49,12 @@ static size_t num_start_points = 0;
static struct predicate *scan_rest (struct predicate **input,
struct predicate *head,
short int prev_prec);
-static void merge_pred (struct predicate *beg_list, struct predicate *end_list, struct predicate **last_p);
-static struct predicate *set_new_parent (struct predicate *curr, enum predicate_precedence high_prec, struct predicate **prevp);
+static void merge_pred (struct predicate *beg_list,
+ struct predicate *end_list,
+ struct predicate **last_p);
+static struct predicate *set_new_parent (struct predicate *curr,
+ enum predicate_precedence high_prec,
+ struct predicate **prevp);
static const char *cost_name (enum EvaluationCost cost);
@@ -68,7 +72,7 @@ matches_start_point (const char *glob, bool foldcase)
if (num_start_points)
{
size_t i;
- for (i=0; i<num_start_points; i++)
+ for (i = 0; i < num_start_points; i++)
{
if (fnmatch (glob, start_points[i], fnmatch_flags) == 0)
return true;
@@ -103,8 +107,7 @@ matches_start_point (const char *glob, bool foldcase)
static struct predicate *
get_expr (struct predicate **input,
- short int prev_prec,
- const struct predicate* prev_pred)
+ short int prev_prec, const struct predicate *prev_pred)
{
struct predicate *next = NULL;
struct predicate *this_pred = (*input);
@@ -121,7 +124,8 @@ get_expr (struct predicate **input,
case BI_OP:
/* e.g. "find . -a" */
error (EXIT_FAILURE, 0,
- _("invalid expression; you have used a binary operator '%s' with nothing before it."),
+ _
+ ("invalid expression; you have used a binary operator '%s' with nothing before it."),
this_pred->p_name);
break;
@@ -130,20 +134,20 @@ get_expr (struct predicate **input,
{
/* Happens with e.g. "find -files0-from - ')' -print" */
error (EXIT_FAILURE, 0,
- _("invalid expression: expected expression before closing parentheses '%s'."),
+ _
+ ("invalid expression: expected expression before closing parentheses '%s'."),
this_pred->p_name);
}
if ((UNI_OP == prev_pred->p_type
- || BI_OP == prev_pred->p_type)
- && !this_pred->artificial)
+ || BI_OP == prev_pred->p_type) && !this_pred->artificial)
{
/* e.g. "find \( -not \)" or "find \( -true -a \)" */
error (EXIT_FAILURE, 0,
_("expected an expression between '%s' and ')'"),
prev_pred->p_name);
}
- else if ( (*input)->artificial )
+ else if ((*input)->artificial)
{
/* We have reached the end of the user-supplied predicates
* unexpectedly.
@@ -171,42 +175,45 @@ get_expr (struct predicate **input,
break;
case OPEN_PAREN:
- if ( (NULL == (*input)->pred_next) || (*input)->pred_next->artificial )
+ if ((NULL == (*input)->pred_next) || (*input)->pred_next->artificial)
{
/* user typed something like "find . (", and so the ) we are
* looking at is from the artificial "( ) -print" that we
* add.
*/
error (EXIT_FAILURE, 0,
- _("invalid expression; expected to find a ')' but didn't see one. "
- "Perhaps you need an extra predicate after '%s'"),
+ _
+ ("invalid expression; expected to find a ')' but didn't see one. "
+ "Perhaps you need an extra predicate after '%s'"),
this_pred->p_name);
}
prev_pred = (*input);
*input = (*input)->pred_next;
- if ( (*input)->p_type == CLOSE_PAREN )
+ if ((*input)->p_type == CLOSE_PAREN)
{
if (prev_pred->artificial)
{
error (EXIT_FAILURE, 0,
- _("invalid expression: expected expression before closing parentheses '%s'."),
+ _
+ ("invalid expression: expected expression before closing parentheses '%s'."),
(*input)->p_name);
}
error (EXIT_FAILURE, 0,
_("invalid expression; empty parentheses are not allowed."));
}
next = get_expr (input, NO_PREC, prev_pred);
- if ((*input == NULL)
- || ((*input)->p_type != CLOSE_PAREN))
+ if ((*input == NULL) || ((*input)->p_type != CLOSE_PAREN))
error (EXIT_FAILURE, 0,
- _("invalid expression; I was expecting to find a ')' somewhere "
- "but did not see one."));
+ _
+ ("invalid expression; I was expecting to find a ')' somewhere "
+ "but did not see one."));
*input = (*input)->pred_next; /* move over close */
break;
default:
- error (EXIT_FAILURE, 0, _("oops -- invalid expression type! This is probably a bug."));
+ error (EXIT_FAILURE, 0,
+ _("oops -- invalid expression type! This is probably a bug."));
break;
}
@@ -241,8 +248,7 @@ get_expr (struct predicate **input,
static struct predicate *
scan_rest (struct predicate **input,
- struct predicate *head,
- short int prev_prec)
+ struct predicate *head, short int prev_prec)
{
struct predicate *tree; /* The new tree we are building. */
@@ -278,8 +284,9 @@ scan_rest (struct predicate **input,
default:
error (EXIT_FAILURE, 0,
- _("oops -- invalid expression type (%d)! This is probably a bug."),
- (int)(*input)->p_type);
+ _
+ ("oops -- invalid expression type (%d)! This is probably a bug."),
+ (int) (*input)->p_type);
break;
}
}
@@ -290,10 +297,9 @@ scan_rest (struct predicate **input,
static bool
predicate_is_cost_free (const struct predicate *p)
{
- if (pred_is(p, pred_name) ||
- pred_is(p, pred_path) ||
- pred_is(p, pred_iname) ||
- pred_is(p, pred_ipath))
+ if (pred_is (p, pred_name) ||
+ pred_is (p, pred_path) ||
+ pred_is (p, pred_iname) || pred_is (p, pred_ipath))
{
/* Traditionally (at least 4.1.7 through 4.2.x) GNU find always
* optimized these cases.
@@ -302,10 +308,9 @@ predicate_is_cost_free (const struct predicate *p)
}
else if (options.optimisation_level > 0)
{
- if (pred_is(p, pred_and) ||
- pred_is(p, pred_negate) ||
- pred_is(p, pred_comma) ||
- pred_is(p, pred_or))
+ if (pred_is (p, pred_and) ||
+ pred_is (p, pred_negate) ||
+ pred_is (p, pred_comma) || pred_is (p, pred_or))
return false;
else
return NeedsNothing == p->p_cost;
@@ -317,7 +322,8 @@ predicate_is_cost_free (const struct predicate *p)
}
/* Prints a predicate */
-void print_predicate (FILE *fp, const struct predicate *p)
+void
+print_predicate (FILE *fp, const struct predicate *p)
{
if (p->arg_text)
{
@@ -344,8 +350,7 @@ predlist_init (struct predlist *p)
static void
predlist_insert (struct predlist *list,
- struct predicate *curr,
- struct predicate **pprev)
+ struct predicate *curr, struct predicate **pprev)
{
struct predicate **insertpos = &(list->head);
@@ -357,16 +362,17 @@ predlist_insert (struct predlist *list,
}
static int
-pred_cost_compare (const struct predicate *p1, const struct predicate *p2, bool wantfailure)
+pred_cost_compare (const struct predicate *p1, const struct predicate *p2,
+ bool wantfailure)
{
if (p1->p_cost == p2->p_cost)
{
if (p1->est_success_rate == p2->est_success_rate)
return 0;
else if (wantfailure)
- return p1->est_success_rate < p2->est_success_rate ? -1 : 1;
+ return p1->est_success_rate < p2->est_success_rate ? -1 : 1;
else
- return p1->est_success_rate < p2->est_success_rate ? 1 : -1;
+ return p1->est_success_rate < p2->est_success_rate ? 1 : -1;
}
else
{
@@ -376,8 +382,7 @@ pred_cost_compare (const struct predicate *p1, const struct predicate *p2, bool
static void
-predlist_merge_sort (struct predlist *list,
- struct predicate **last)
+predlist_merge_sort (struct predlist *list, struct predicate **last)
{
struct predlist new_list;
struct predicate *p, *q;
@@ -401,7 +406,7 @@ predlist_merge_sort (struct predlist *list,
q->pred_left = NULL;
/* insert it into the new list */
- for (p=new_list.head; p; p=p->pred_left)
+ for (p = new_list.head; p; p = p->pred_left)
{
/* If these operations are OR operations, we want to get a
* successful test as soon as possible, to take advantage of
@@ -413,7 +418,8 @@ predlist_merge_sort (struct predlist *list,
* pass a flag into pred_cost_compare().
*/
const bool wantfailure = (OR_PREC != p->p_prec);
- if (pred_cost_compare (p->pred_right, q->pred_right, wantfailure) >= 0)
+ if (pred_cost_compare (p->pred_right, q->pred_right, wantfailure) >=
+ 0)
break;
}
if (p)
@@ -429,7 +435,7 @@ predlist_merge_sort (struct predlist *list,
q->pred_left = new_list.head; /* prepend */
new_list.head = q;
if (NULL == new_list.tail)
- new_list.tail = q; /* first item in new list */
+ new_list.tail = q; /* first item in new list */
}
}
if (options.debug_options & DebugTreeOpt)
@@ -438,7 +444,7 @@ predlist_merge_sort (struct predlist *list,
print_tree (stderr, new_list.head, 2);
}
- calculate_derived_rates(new_list.head);
+ calculate_derived_rates (new_list.head);
merge_pred (new_list.head, new_list.tail, last);
predlist_init (list);
}
@@ -446,18 +452,17 @@ predlist_merge_sort (struct predlist *list,
static void
merge_lists (struct predlist lists[], int nlists,
struct predlist *name_list,
- struct predlist *regex_list,
- struct predicate **last)
+ struct predlist *regex_list, struct predicate **last)
{
int i;
- static void (*mergefn)(struct predlist *, struct predicate**);
+ static void (*mergefn) (struct predlist *, struct predicate **);
mergefn = predlist_merge_sort;
- mergefn (name_list, last);
- mergefn (regex_list, last);
+ mergefn (name_list, last);
+ mergefn (regex_list, last);
- for (i=0; i<nlists; i++)
+ for (i = 0; i < nlists; i++)
mergefn (&lists[i], last);
}
@@ -586,7 +591,8 @@ consider_arm_swap (struct predicate *p)
if (options.debug_options & DebugTreeOpt)
{
- fprintf (stderr, "Success rates: l=%f, r=%f\n", succ_rate_l, succ_rate_r);
+ fprintf (stderr, "Success rates: l=%f, r=%f\n", succ_rate_l,
+ succ_rate_r);
}
if (pred_is (p, pred_or))
@@ -643,12 +649,12 @@ do_arm_swaps (struct predicate *p)
{
swapped = false;
if (consider_arm_swap (p)
- || do_arm_swaps (p->pred_left)
- || do_arm_swaps (p->pred_right))
+ || do_arm_swaps (p->pred_left) || do_arm_swaps (p->pred_right))
{
swapped = true;
}
- } while (swapped);
+ }
+ while (swapped);
return swapped;
}
else
@@ -693,22 +699,22 @@ do_arm_swaps (struct predicate *p)
static bool
opt_expr (struct predicate **eval_treep)
{
- struct predlist regex_list={NULL,NULL}, name_list={NULL,NULL};
+ struct predlist regex_list = { NULL, NULL }, name_list = { NULL, NULL };
struct predlist cbo_list[NumEvaluationCosts];
int i;
struct predicate *curr;
struct predicate **prevp; /* Address of `curr' node. */
- struct predicate **last_sidep; /* Last predicate with side effects. */
+ struct predicate **last_sidep; /* Last predicate with side effects. */
PRED_FUNC pred_func;
enum predicate_type p_type;
- bool has_side_effects = false; /* Return value. */
- enum predicate_precedence prev_prec, /* precedence of last BI_OP in branch */
- biop_prec; /* topmost BI_OP precedence in branch */
+ bool has_side_effects = false; /* Return value. */
+ enum predicate_precedence prev_prec, /* precedence of last BI_OP in branch */
+ biop_prec; /* topmost BI_OP precedence in branch */
if (eval_treep == NULL || *eval_treep == NULL)
return (false);
- for (i=0; i<NumEvaluationCosts; i++)
+ for (i = 0; i < NumEvaluationCosts; i++)
predlist_init (&cbo_list[i]);
/* Set up to normalize tree as a left-linked list of ANDs or ORs.
@@ -728,7 +734,7 @@ opt_expr (struct predicate **eval_treep)
if (curr->p_type != BI_OP)
set_new_parent (curr, prev_prec, prevp);
- if (options.debug_options & (DebugExpressionTree|DebugTreeOpt))
+ if (options.debug_options & (DebugExpressionTree | DebugTreeOpt))
{
/* Normalized tree. */
fprintf (stderr, "Normalized Eval Tree:\n");
@@ -737,7 +743,7 @@ opt_expr (struct predicate **eval_treep)
/* Rearrange the predicates. */
prevp = eval_treep;
- biop_prec = NO_PREC; /* not COMMA_PREC */
+ biop_prec = NO_PREC; /* not COMMA_PREC */
if ((*prevp) && (*prevp)->p_type == BI_OP)
biop_prec = (*prevp)->p_prec;
while ((curr = *prevp) != NULL)
@@ -780,7 +786,7 @@ opt_expr (struct predicate **eval_treep)
if (options.debug_options & DebugTreeOpt)
{
fprintf (stderr, "-O%d: promoting cheap predicate ",
- (int)options.optimisation_level);
+ (int) options.optimisation_level);
print_predicate (stderr, curr->pred_right);
fprintf (stderr, " into name_list\n");
}
@@ -805,12 +811,13 @@ opt_expr (struct predicate **eval_treep)
if (options.debug_options & DebugTreeOpt)
{
fprintf (stderr, "-O%d: categorising predicate ",
- (int)options.optimisation_level);
+ (int) options.optimisation_level);
print_predicate (stderr, curr->pred_right);
fprintf (stderr, " by cost (%s)\n",
- cost_name(curr->pred_right->p_cost));
+ cost_name (curr->pred_right->p_cost));
}
- predlist_insert (&cbo_list[curr->pred_right->p_cost], curr, prevp);
+ predlist_insert (&cbo_list[curr->pred_right->p_cost], curr,
+ prevp);
continue;
}
}
@@ -834,7 +841,9 @@ opt_expr (struct predicate **eval_treep)
all of the user's parentheses. */
default:
- error (EXIT_FAILURE, 0, _("oops -- invalid expression type! This is probably a bug."));
+ error (EXIT_FAILURE, 0,
+ _
+ ("oops -- invalid expression type! This is probably a bug."));
break;
}
@@ -843,7 +852,8 @@ opt_expr (struct predicate **eval_treep)
last_sidep = prevp;
/* Incorporate lists and reset list pointers for this group. */
- merge_lists (cbo_list, NumEvaluationCosts, &name_list, ®ex_list, last_sidep);
+ merge_lists (cbo_list, NumEvaluationCosts, &name_list, ®ex_list,
+ last_sidep);
has_side_effects = true;
}
@@ -852,7 +862,8 @@ opt_expr (struct predicate **eval_treep)
/* Do final list merges. */
last_sidep = prevp;
- merge_lists (cbo_list, NumEvaluationCosts, &name_list, ®ex_list, last_sidep);
+ merge_lists (cbo_list, NumEvaluationCosts, &name_list, ®ex_list,
+ last_sidep);
return has_side_effects;
}
@@ -871,7 +882,8 @@ constrain_rate (float rate)
HIGH_PREC. */
static struct predicate *
-set_new_parent (struct predicate *curr, enum predicate_precedence high_prec, struct predicate **prevp)
+set_new_parent (struct predicate *curr, enum predicate_precedence high_prec,
+ struct predicate **prevp)
{
struct predicate *new_parent;
@@ -914,7 +926,8 @@ set_new_parent (struct predicate *curr, enum predicate_precedence high_prec, str
into the tree at LAST_P. */
static void
-merge_pred (struct predicate *beg_list, struct predicate *end_list, struct predicate **last_p)
+merge_pred (struct predicate *beg_list, struct predicate *end_list,
+ struct predicate **last_p)
{
end_list->pred_left = *last_p;
*last_p = beg_list;
@@ -933,85 +946,85 @@ merge_pred (struct predicate *beg_list, struct predicate *end_list, struct predi
struct pred_cost_lookup
{
- PRED_FUNC fn;
- enum EvaluationCost cost;
+ PRED_FUNC fn;
+ enum EvaluationCost cost;
};
-static struct pred_cost_lookup costlookup[] =
- {
- { pred_amin , NeedsStatInfo },
- { pred_and , NeedsNothing, },
- { pred_anewer , NeedsStatInfo, },
- { pred_atime , NeedsStatInfo, },
- { pred_closeparen, NeedsNothing },
- { pred_cmin , NeedsStatInfo, },
- { pred_cnewer , NeedsStatInfo, },
- { pred_comma , NeedsNothing, },
- { pred_context , NeedsAccessInfo },
- { pred_ctime , NeedsStatInfo, },
- { pred_delete , NeedsSyncDiskHit },
- { pred_empty , NeedsStatInfo },
- { pred_exec , NeedsEventualExec },
- { pred_execdir , NeedsEventualExec },
- { pred_executable, NeedsAccessInfo },
- { pred_false , NeedsNothing },
- { pred_fprint , NeedsNothing },
- { pred_fprint0 , NeedsNothing },
- { pred_fprintf , NeedsNothing },
- { pred_fstype , NeedsStatInfo }, /* true for amortised cost */
- { pred_gid , NeedsStatInfo },
- { pred_group , NeedsStatInfo },
- { pred_ilname , NeedsLinkName },
- { pred_iname , NeedsNothing },
- { pred_inum , NeedsInodeNumber },
- { pred_ipath , NeedsNothing },
- { pred_links , NeedsStatInfo },
- { pred_lname , NeedsLinkName },
- { pred_ls , NeedsStatInfo },
- { pred_fls , NeedsStatInfo },
- { pred_mmin , NeedsStatInfo },
- { pred_mtime , NeedsStatInfo },
- { pred_name , NeedsNothing },
- { pred_negate , NeedsNothing, },
- { pred_newer , NeedsStatInfo, },
- { pred_newerXY , NeedsStatInfo, },
- { pred_nogroup , NeedsStatInfo }, /* true for amortised cost if caching is on */
- { pred_nouser , NeedsStatInfo }, /* true for amortised cost if caching is on */
- { pred_ok , NeedsUserInteraction },
- { pred_okdir , NeedsUserInteraction },
- { pred_openparen , NeedsNothing },
- { pred_or , NeedsNothing, },
- { pred_path , NeedsNothing },
- { pred_perm , NeedsStatInfo },
- { pred_print , NeedsNothing },
- { pred_print0 , NeedsNothing },
- { pred_prune , NeedsNothing },
- { pred_quit , NeedsNothing },
- { pred_readable , NeedsAccessInfo },
- { pred_regex , NeedsNothing },
- { pred_samefile , NeedsStatInfo },
- { pred_size , NeedsStatInfo },
- { pred_true , NeedsNothing },
- { pred_type , NeedsType },
- { pred_uid , NeedsStatInfo },
- { pred_used , NeedsStatInfo },
- { pred_user , NeedsStatInfo },
- { pred_writable , NeedsAccessInfo },
- { pred_xtype , NeedsType } /* roughly correct unless most files are symlinks */
- };
+static struct pred_cost_lookup costlookup[] = {
+ {pred_amin, NeedsStatInfo},
+ {pred_and, NeedsNothing,},
+ {pred_anewer, NeedsStatInfo,},
+ {pred_atime, NeedsStatInfo,},
+ {pred_closeparen, NeedsNothing},
+ {pred_cmin, NeedsStatInfo,},
+ {pred_cnewer, NeedsStatInfo,},
+ {pred_comma, NeedsNothing,},
+ {pred_context, NeedsAccessInfo},
+ {pred_ctime, NeedsStatInfo,},
+ {pred_delete, NeedsSyncDiskHit},
+ {pred_empty, NeedsStatInfo},
+ {pred_exec, NeedsEventualExec},
+ {pred_execdir, NeedsEventualExec},
+ {pred_executable, NeedsAccessInfo},
+ {pred_false, NeedsNothing},
+ {pred_fprint, NeedsNothing},
+ {pred_fprint0, NeedsNothing},
+ {pred_fprintf, NeedsNothing},
+ {pred_fstype, NeedsStatInfo}, /* true for amortised cost */
+ {pred_gid, NeedsStatInfo},
+ {pred_group, NeedsStatInfo},
+ {pred_ilname, NeedsLinkName},
+ {pred_iname, NeedsNothing},
+ {pred_inum, NeedsInodeNumber},
+ {pred_ipath, NeedsNothing},
+ {pred_links, NeedsStatInfo},
+ {pred_lname, NeedsLinkName},
+ {pred_ls, NeedsStatInfo},
+ {pred_fls, NeedsStatInfo},
+ {pred_mmin, NeedsStatInfo},
+ {pred_mtime, NeedsStatInfo},
+ {pred_name, NeedsNothing},
+ {pred_negate, NeedsNothing,},
+ {pred_newer, NeedsStatInfo,},
+ {pred_newerXY, NeedsStatInfo,},
+ {pred_nogroup, NeedsStatInfo}, /* true for amortised cost if caching is on */
+ {pred_nouser, NeedsStatInfo}, /* true for amortised cost if caching is on */
+ {pred_ok, NeedsUserInteraction},
+ {pred_okdir, NeedsUserInteraction},
+ {pred_openparen, NeedsNothing},
+ {pred_or, NeedsNothing,},
+ {pred_path, NeedsNothing},
+ {pred_perm, NeedsStatInfo},
+ {pred_print, NeedsNothing},
+ {pred_print0, NeedsNothing},
+ {pred_prune, NeedsNothing},
+ {pred_quit, NeedsNothing},
+ {pred_readable, NeedsAccessInfo},
+ {pred_regex, NeedsNothing},
+ {pred_samefile, NeedsStatInfo},
+ {pred_size, NeedsStatInfo},
+ {pred_true, NeedsNothing},
+ {pred_type, NeedsType},
+ {pred_uid, NeedsStatInfo},
+ {pred_used, NeedsStatInfo},
+ {pred_user, NeedsStatInfo},
+ {pred_writable, NeedsAccessInfo},
+ {pred_xtype, NeedsType} /* roughly correct unless most files are symlinks */
+};
+
static int pred_table_sorted = 0;
static bool
check_sorted (void *base, size_t members, size_t membersize,
- int (*cmpfn)(const void*, const void*))
+ int (*cmpfn) (const void *, const void *))
{
const char *p = base;
size_t i;
- for (i=1u; i<members; ++i)
+ for (i = 1u; i < members; ++i)
{
- int result = cmpfn (p+i*membersize, p+(i-1)*membersize);
+ int result = cmpfn (p + i * membersize, p + (i - 1) * membersize);
if (result < 0)
return false;
- result = cmpfn (p+(i-1)*membersize, p+i*membersize);
+ result = cmpfn (p + (i - 1) * membersize, p + i * membersize);
assert (result <= 0);
}
return true;
@@ -1027,14 +1040,16 @@ cost_table_comparison (const void *p1, const void *p2)
*/
const struct pred_cost_lookup *pc1 = p1;
const struct pred_cost_lookup *pc2 = p2;
- union {
+ union
+ {
PRED_FUNC pfn;
char mem[sizeof (PRED_FUNC)];
- } u1, u2;
+ }
+ u1, u2;
u1.pfn = pc1->fn;
u2.pfn = pc2->fn;
- return memcmp (u1.mem, u2.mem, sizeof(u1.pfn));
+ return memcmp (u1.mem, u2.mem, sizeof (u1.pfn));
}
static enum EvaluationCost
@@ -1080,27 +1095,25 @@ get_pred_cost (const struct predicate *p)
if (!pred_table_sorted)
{
qsort (costlookup,
- sizeof(costlookup)/sizeof(costlookup[0]),
- sizeof(costlookup[0]),
- cost_table_comparison);
+ sizeof (costlookup) / sizeof (costlookup[0]),
+ sizeof (costlookup[0]), cost_table_comparison);
if (!check_sorted (costlookup,
- sizeof(costlookup)/sizeof(costlookup[0]),
- sizeof(costlookup[0]),
- cost_table_comparison))
+ sizeof (costlookup) / sizeof (costlookup[0]),
+ sizeof (costlookup[0]), cost_table_comparison))
{
- error (EXIT_FAILURE, 0, _("failed to sort the costlookup array"));
+ error (EXIT_FAILURE, 0,
+ _("failed to sort the costlookup array"));
}
pred_table_sorted = 1;
}
key.fn = p->pred_func;
entry = bsearch (&key, costlookup,
- sizeof(costlookup)/sizeof(costlookup[0]),
- sizeof(costlookup[0]),
- cost_table_comparison);
+ sizeof (costlookup) / sizeof (costlookup[0]),
+ sizeof (costlookup[0]), cost_table_comparison);
if (entry)
{
- inherent_cost = ((const struct pred_cost_lookup*)entry)->cost;
+ inherent_cost = ((const struct pred_cost_lookup *) entry)->cost;
}
else
{
@@ -1109,7 +1122,7 @@ get_pred_cost (const struct predicate *p)
should be nonzero. However, not having an entry for a predicate
will not affect the output (just the performance) so I think it
would be confusing to exit with a nonzero status.
- */
+ */
error (0, 0,
_("warning: there is no entry in the predicate evaluation "
"cost table for predicate %s; please report this as a bug"),
@@ -1132,11 +1145,11 @@ estimate_costs (struct predicate *tree)
estimate_costs (tree->pred_right);
estimate_costs (tree->pred_left);
- tree->p_cost = get_pred_cost(tree);
+ tree->p_cost = get_pred_cost (tree);
}
}
-struct predicate*
+struct predicate *
get_eval_tree (void)
{
return eval_tree;
@@ -1190,7 +1203,7 @@ calculate_derived_rates (struct predicate *p)
/* Binary operators must have two operands */
if (pred_is (p, pred_and))
{
- rate = getrate (p->pred_right) * getrate(p->pred_left);
+ rate = getrate (p->pred_right) * getrate (p->pred_left);
}
else if (pred_is (p, pred_comma))
{
@@ -1198,7 +1211,7 @@ calculate_derived_rates (struct predicate *p)
}
else if (pred_is (p, pred_or))
{
- rate = getrate (p->pred_right) + getrate(p->pred_left);
+ rate = getrate (p->pred_right) + getrate (p->pred_left);
}
else
{
@@ -1235,7 +1248,7 @@ check_normalization (struct predicate *p, bool at_root)
if (p->pred_left)
{
assert (BI_OP == p->pred_left->p_type);
- check_normalization(p->pred_left, false);
+ check_normalization (p->pred_left, false);
}
if (p->pred_right)
{
@@ -1243,10 +1256,10 @@ check_normalization (struct predicate *p, bool at_root)
}
}
-struct predicate*
+struct predicate *
build_expression_tree (int argc, char *argv[], int end_of_leading_options)
{
- const struct parser_table *parse_entry; /* Pointer to the parsing table entry for this expression. */
+ const struct parser_table *parse_entry; /* Pointer to the parsing table entry for this expression. */
char *predicate_name; /* Name of predicate being parsed. */
struct predicate *cur_pred;
const struct parser_table *entry_close, *entry_print, *entry_open;
@@ -1259,17 +1272,18 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
* first and last start point.
*/
start_points = argv + end_of_leading_options;
- for (i = end_of_leading_options; i < argc && !looks_like_expression(argv[i], true); i++)
+ for (i = end_of_leading_options;
+ i < argc && !looks_like_expression (argv[i], true); i++)
{
++num_start_points;
}
/* Enclose the expression in `( ... )' so a default -print will
apply to the whole expression. */
- entry_open = find_parser ("(");
+ entry_open = find_parser ("(");
entry_close = find_parser (")");
entry_print = find_parser ("print");
- assert (entry_open != NULL);
+ assert (entry_open != NULL);
assert (entry_close != NULL);
assert (entry_print != NULL);
@@ -1280,13 +1294,13 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
pred_sanity_check (last_pred);
/* Build the input order list. */
- while (i < argc )
+ while (i < argc)
{
state.already_issued_stat_error_msg = false;
if (!looks_like_expression (argv[i], false))
{
error (0, 0, _("paths must precede expression: `%s'"), argv[i]);
- if (access(argv[i], F_OK)==0)
+ if (access (argv[i], F_OK) == 0)
error (0, 0, _("possible unquoted pattern after predicate `%s'?"),
last_pred->p_name);
exit (EXIT_FAILURE);
@@ -1297,7 +1311,8 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
if (parse_entry == NULL)
{
/* Command line option not recognized */
- error (EXIT_FAILURE, 0, _("unknown predicate `%s'"), predicate_name);
+ error (EXIT_FAILURE, 0, _("unknown predicate `%s'"),
+ predicate_name);
}
/* We have recognised a test of the form -foo. Eat that,
@@ -1312,12 +1327,13 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
{
if (argv[i])
{
- if ( (ARG_SPECIAL_PARSE == parse_entry->type) && (i == oldi) )
+ if ((ARG_SPECIAL_PARSE == parse_entry->type) && (i == oldi))
{
/* The special parse function spat out the
* predicate. It must be invalid, or not tasty.
*/
- error (EXIT_FAILURE, 0, _("invalid predicate `%s'"), predicate_name);
+ error (EXIT_FAILURE, 0, _("invalid predicate `%s'"),
+ predicate_name);
}
else
{
@@ -1328,7 +1344,8 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
else
{
/* Command line option requires an argument */
- error (EXIT_FAILURE, 0, _("missing argument to `%s'"), predicate_name);
+ error (EXIT_FAILURE, 0, _("missing argument to `%s'"),
+ predicate_name);
}
}
else
@@ -1341,8 +1358,8 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
else
last_pred->arg_text = NULL;
}
- pred_sanity_check(last_pred);
- pred_sanity_check(predicates); /* XXX: expensive */
+ pred_sanity_check (last_pred);
+ pred_sanity_check (predicates); /* XXX: expensive */
}
parse_end_user_args (argv, argc, last_pred, predicates);
if (predicates->pred_next == NULL)
@@ -1354,8 +1371,8 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
free (cur_pred);
parse_print (entry_print, argv, &argc);
last_pred->p_name = "-print";
- pred_sanity_check(last_pred);
- pred_sanity_check(predicates); /* XXX: expensive */
+ pred_sanity_check (last_pred);
+ pred_sanity_check (predicates); /* XXX: expensive */
}
else if (!default_prints (predicates->pred_next))
{
@@ -1363,7 +1380,7 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
remove the unneeded initial `('. */
cur_pred = predicates;
predicates = predicates->pred_next;
- pred_sanity_check (predicates); /* XXX: expensive */
+ pred_sanity_check (predicates); /* XXX: expensive */
free (cur_pred);
}
else
@@ -1377,10 +1394,10 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
last_pred->p_name = "-print";
last_pred->artificial = true;
pred_sanity_check (last_pred);
- pred_sanity_check (predicates); /* XXX: expensive */
+ pred_sanity_check (predicates); /* XXX: expensive */
}
- if (options.debug_options & (DebugExpressionTree|DebugTreeOpt))
+ if (options.debug_options & (DebugExpressionTree | DebugTreeOpt))
{
fprintf (stderr, "Predicate List:\n");
print_list (stderr, predicates);
@@ -1416,7 +1433,7 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
}
}
- if (options.debug_options & (DebugExpressionTree|DebugTreeOpt))
+ if (options.debug_options & (DebugExpressionTree | DebugTreeOpt))
{
fprintf (stderr, "Eval Tree:\n");
print_tree (stderr, eval_tree, 0);
@@ -1438,7 +1455,7 @@ build_expression_tree (int argc, char *argv[], int end_of_leading_options)
/* Check that the tree is still in normalised order */
check_normalization (eval_tree, true);
- if (options.debug_options & (DebugExpressionTree|DebugTreeOpt))
+ if (options.debug_options & (DebugExpressionTree | DebugTreeOpt))
{
fprintf (stderr, "Optimized Eval Tree:\n");
print_tree (stderr, eval_tree, 0);
@@ -1518,8 +1535,7 @@ get_new_pred (const struct parser_table *entry)
predicate is an operator. If it isn't, the AND operator is inserted. */
struct predicate *
-get_new_pred_chk_op (const struct parser_table *entry,
- const char *arg)
+get_new_pred_chk_op (const struct parser_table *entry, const char *arg)
{
struct predicate *new_pred;
static const struct parser_table *entry_and = NULL;
@@ -1528,14 +1544,16 @@ get_new_pred_chk_op (const struct parser_table *entry,
if (NULL == entry_and)
entry_and = find_parser ("and");
- /* Check that it's actually there. If not, that is a bug.*/
+ /* Check that it's actually there. If not, that is a bug. */
assert (entry_and != NULL);
if (last_pred)
switch (last_pred->p_type)
{
case NO_TYPE:
- error (EXIT_FAILURE, 0, _("oops -- invalid default insertion of and! This is probably a bug."));
+ error (EXIT_FAILURE, 0,
+ _
+ ("oops -- invalid default insertion of and! This is probably a bug."));
break;
case PRIMARY_TYPE:
@@ -1570,20 +1588,19 @@ struct cost_assoc
enum EvaluationCost cost;
const char *name;
};
-static struct cost_assoc cost_table[] =
- {
- { NeedsNothing, "Nothing" },
- { NeedsInodeNumber, "InodeNumber" },
- { NeedsType, "Type" },
- { NeedsStatInfo, "StatInfo" },
- { NeedsLinkName, "LinkName" },
- { NeedsAccessInfo, "AccessInfo" },
- { NeedsSyncDiskHit, "SyncDiskHit" },
- { NeedsEventualExec, "EventualExec" },
- { NeedsImmediateExec, "ImmediateExec" },
- { NeedsUserInteraction, "UserInteraction" },
- { NeedsUnknown, "Unknown" }
- };
+static struct cost_assoc cost_table[] = {
+ {NeedsNothing, "Nothing"},
+ {NeedsInodeNumber, "InodeNumber"},
+ {NeedsType, "Type"},
+ {NeedsStatInfo, "StatInfo"},
+ {NeedsLinkName, "LinkName"},
+ {NeedsAccessInfo, "AccessInfo"},
+ {NeedsSyncDiskHit, "SyncDiskHit"},
+ {NeedsEventualExec, "EventualExec"},
+ {NeedsImmediateExec, "ImmediateExec"},
+ {NeedsUserInteraction, "UserInteraction"},
+ {NeedsUnknown, "Unknown"}
+};
struct prec_assoc
{
@@ -1591,8 +1608,7 @@ struct prec_assoc
const char *prec_name;
};
-static struct prec_assoc prec_table[] =
-{
+static struct prec_assoc prec_table[] = {
{NO_PREC, "no"},
{COMMA_PREC, "comma"},
{OR_PREC, "or"},
@@ -1608,24 +1624,23 @@ struct op_assoc
const char *type_name;
};
-static struct op_assoc type_table[] =
-{
- {NO_TYPE, "no"},
+static struct op_assoc type_table[] = {
+ {NO_TYPE, "no"},
{PRIMARY_TYPE, "primary"},
- {UNI_OP, "uni_op"},
- {BI_OP, "bi_op"},
- {OPEN_PAREN, "open_paren "},
- {CLOSE_PAREN, "close_paren "},
- {-1, "unknown"}
+ {UNI_OP, "uni_op"},
+ {BI_OP, "bi_op"},
+ {OPEN_PAREN, "open_paren "},
+ {CLOSE_PAREN, "close_paren "},
+ {-1, "unknown"}
};
static const char *
cost_name (enum EvaluationCost cost)
{
unsigned int i;
- unsigned int n = sizeof (cost_table)/sizeof(cost_table[0]);
+ unsigned int n = sizeof (cost_table) / sizeof (cost_table[0]);
- for (i = 0; i<n; ++i)
+ for (i = 0; i < n; ++i)
if (cost_table[i].cost == cost)
return cost_table[i].name;
return "unknown";
@@ -1670,11 +1685,10 @@ print_tree (FILE *fp, struct predicate *node, int indent)
fprintf (fp, "pred=[");
print_predicate (fp, node);
fprintf (fp, "] type=%s prec=%s",
- type_name (node->p_type), prec_name (node->p_prec));
+ type_name (node->p_type), prec_name (node->p_prec));
fprintf (fp, " cost=%s est_success_rate=%#.4g %sside effects ",
cost_name (node->p_cost),
- node->est_success_rate,
- (node->side_effects ? "" : "no "));
+ node->est_success_rate, (node->side_effects ? "" : "no "));
if (node->need_stat || node->need_type || node->need_inum)
{
diff --git a/find/util.c b/find/util.c
index eb02745c..9939760b 100644
--- a/find/util.c
+++ b/find/util.c
@@ -25,7 +25,7 @@
#include <fcntl.h>
#include <limits.h>
#include <string.h>
-#include <sys/stat.h> /* for fstatat() */
+#include <sys/stat.h> /* for fstatat() */
#include <sys/time.h>
#include <sys/utsname.h>
@@ -47,22 +47,25 @@
struct debug_option_assoc
{
const char *name;
- int val;
+ int val;
const char *docstring;
};
-static struct debug_option_assoc debugassoc[] =
- {
- { "exec", DebugExec, "Show diagnostic information relating to -exec, -execdir, -ok and -okdir" },
- { "opt", DebugExpressionTree|DebugTreeOpt, "Show diagnostic information relating to optimisation" },
- { "rates", DebugSuccessRates, "Indicate how often each predicate succeeded" },
- { "search",DebugSearch, "Navigate the directory tree verbosely" },
- { "stat", DebugStat, "Trace calls to stat(2) and lstat(2)" },
- { "time", DebugTime, "Show diagnostic information relating to time-of-day and timestamp comparisons" },
- { "tree", DebugExpressionTree, "Display the expression tree" },
-
- { "all", DebugAll, "Set all of the debug flags (but help)" },
- { "help", DebugHelp, "Explain the various -D options" },
- };
+static struct debug_option_assoc debugassoc[] = {
+ {"exec", DebugExec,
+ "Show diagnostic information relating to -exec, -execdir, -ok and -okdir"},
+ {"opt", DebugExpressionTree | DebugTreeOpt,
+ "Show diagnostic information relating to optimisation"},
+ {"rates", DebugSuccessRates, "Indicate how often each predicate succeeded"},
+ {"search", DebugSearch, "Navigate the directory tree verbosely"},
+ {"stat", DebugStat, "Trace calls to stat(2) and lstat(2)"},
+ {"time", DebugTime,
+ "Show diagnostic information relating to time-of-day and timestamp comparisons"},
+ {"tree", DebugExpressionTree, "Display the expression tree"},
+
+ {"all", DebugAll, "Set all of the debug flags (but help)"},
+ {"help", DebugHelp, "Explain the various -D options"},
+};
+
#define N_DEBUGASSOC (sizeof(debugassoc)/sizeof(debugassoc[0]))
@@ -86,8 +89,7 @@ static struct debug_option_assoc debugassoc[] =
struct predicate *
insert_primary_withpred (const struct parser_table *entry,
- PRED_FUNC pred_func,
- const char *arg)
+ PRED_FUNC pred_func, const char *arg)
{
struct predicate *new_pred;
@@ -137,18 +139,18 @@ show_valid_debug_options (int full)
fputs (_("Valid arguments for -D:\n"), stdout);
if (full)
{
- for (i=0; i<N_DEBUGASSOC; ++i)
+ for (i = 0; i < N_DEBUGASSOC; ++i)
{
fprintf (stdout, "%-10s %s\n",
- debugassoc[i].name,
- debugassoc[i].docstring);
+ debugassoc[i].name, debugassoc[i].docstring);
}
}
else
{
- for (i=0; i<N_DEBUGASSOC; ++i)
+ for (i = 0; i < N_DEBUGASSOC; ++i)
{
- fprintf (stdout, "%s%s", (i>0 ? ", " : " "), debugassoc[i].name);
+ fprintf (stdout, "%s%s", (i > 0 ? ", " : " "),
+ debugassoc[i].name);
}
}
}
@@ -158,15 +160,15 @@ usage (int status)
{
if (status != EXIT_SUCCESS)
{
- fprintf (stderr, _("Try '%s --help' for more information.\n"), program_name);
+ fprintf (stderr, _("Try '%s --help' for more information.\n"),
+ program_name);
exit (status);
}
#define HTL(t) fputs (t, stdout);
fprintf (stdout, _("\
-Usage: %s [-H] [-L] [-P] [-Olevel] [-D debugopts] [path...] [expression]\n"),
- program_name);
+Usage: %s [-H] [-L] [-P] [-Olevel] [-D debugopts] [path...] [expression]\n"), program_name);
HTL (_("\n\
Default path is the current directory; default expression is -print.\n\
@@ -202,7 +204,8 @@ Actions:\n\
HTL (_("\n\
Other common options:\n"));
HTL (_(" --help display this help and exit\n"));
- HTL (_(" --version output version information and exit\n\n"));
+ HTL (_
+ (" --version output version information and exit\n\n"));
HTL (_("\n\
In -newerXY, XY stands for the combination [aBcm][aBcmt]; see find(1).\n\
@@ -220,7 +223,7 @@ Use '-D help' for a description of the options, or see find(1).\n\
void
set_stat_placeholders (struct stat *p)
{
- (void) p; /* silence warning for systems lacking these fields. */
+ (void) p; /* silence warning for systems lacking these fields. */
#if HAVE_STRUCT_STAT_ST_BIRTHTIME
p->st_birthtime = 0;
#endif
@@ -265,7 +268,7 @@ get_statinfo (const char *pathname, const char *name, struct stat *p)
}
else
{
- if (!options.ignore_readdir_race || (errno != ENOENT) )
+ if (!options.ignore_readdir_race || (errno != ENOENT))
{
nonfatal_target_file_error (errno, pathname);
}
@@ -283,9 +286,7 @@ get_statinfo (const char *pathname, const char *name, struct stat *p)
* already known. Returns 0 on success (or if we did nothing).
*/
static int
-get_info (const char *pathname,
- struct stat *p,
- struct predicate *pred_ptr)
+get_info (const char *pathname, struct stat *p, struct predicate *pred_ptr)
{
bool todo = false;
@@ -306,7 +307,7 @@ get_info (const char *pathname,
{
todo = true; /* need to stat to get the inode number */
}
- else if ((!state.have_type) || S_ISDIR(p->st_mode))
+ else if ((!state.have_type) || S_ISDIR (p->st_mode))
{
/* For now we decide not to trust struct dirent.d_ino for
* directory entries that are subdirectories, in case this
@@ -331,7 +332,7 @@ bool
check_nofollow (void)
{
struct utsname uts;
- float release;
+ float release;
if (0 == O_NOFOLLOW)
{
@@ -342,13 +343,13 @@ check_nofollow (void)
{
/* POSIX requires that atof ignores "unrecognised suffixes"; we specifically
* want that behaviour. */
- double (*conversion)(const char*) = atof; /* avoid sc_prohibit_atoi_atof check. */
+ double (*conversion) (const char *) = atof; /* avoid sc_prohibit_atoi_atof check. */
release = conversion (uts.release);
if (0 == strcmp ("Linux", uts.sysname))
{
/* Linux kernels 2.1.126 and earlier ignore the O_NOFOLLOW flag. */
- return release >= 2.2f; /* close enough */
+ return release >= 2.2f; /* close enough */
}
else if (0 == strcmp ("FreeBSD", uts.sysname))
{
@@ -403,10 +404,10 @@ do_complete_pending_execdirs (struct predicate *p)
* exec. This is because the completion of work for -exec ... {} +
* happens when the program exits, not when we leave a directory.
*/
- if (pred_is(p, pred_okdir) || pred_is(p, pred_execdir))
+ if (pred_is (p, pred_okdir) || pred_is (p, pred_execdir))
{
/* It's an exec-family predicate. p->args.exec_val is valid. */
- assert(predicate_uses_exec(p));
+ assert (predicate_uses_exec (p));
if (p->args.exec_vec.multiple)
{
struct exec_val *execp = &p->args.exec_vec;
@@ -430,7 +431,7 @@ complete_pending_execdirs (void)
{
if (state.execdirs_outstanding)
{
- do_complete_pending_execdirs (get_eval_tree());
+ do_complete_pending_execdirs (get_eval_tree ());
state.execdirs_outstanding = false;
}
}
@@ -474,7 +475,8 @@ record_initial_cwd (void)
initial_wd = xmalloc (sizeof (*initial_wd));
if (0 != save_cwd (initial_wd))
{
- const char *wd_name = (initial_wd->desc < 0 && initial_wd->name) ? initial_wd->name : NULL;
+ const char *wd_name = (initial_wd->desc < 0
+ && initial_wd->name) ? initial_wd->name : NULL;
if (wd_name)
{
error (EXIT_FAILURE, errno,
@@ -499,11 +501,13 @@ cleanup_initial_cwd (void)
}
else
{
- const char *wd_name = (initial_wd->desc < 0 && initial_wd->name) ? initial_wd->name : NULL;
+ const char *wd_name = (initial_wd->desc < 0
+ && initial_wd->name) ? initial_wd->name : NULL;
if (wd_name)
{
error (0, errno,
- _("Failed to restore initial working directory %s"), wd_name);
+ _("Failed to restore initial working directory %s"),
+ wd_name);
}
else
{
@@ -516,8 +520,7 @@ cleanup_initial_cwd (void)
static void
-traverse_tree (struct predicate *tree,
- void (*callback)(struct predicate*))
+traverse_tree (struct predicate *tree, void (*callback) (struct predicate *))
{
if (tree->pred_left)
traverse_tree (tree->pred_left, callback);
@@ -537,8 +540,7 @@ undangle_file_pointers (struct predicate *p)
{
if (pred_is (p, pred_fprint)
|| pred_is (p, pred_fprintf)
- || pred_is (p, pred_fls)
- || pred_is (p, pred_fprint0))
+ || pred_is (p, pred_fls) || pred_is (p, pred_fprint0))
{
/* The file was already fclose()d by sharefile_destroy. */
p->args.printf_vec.stream = NULL;
@@ -588,15 +590,17 @@ fallback_stat (const char *name, struct stat *p, int prev_rv)
case ENOENT:
case ENOTDIR:
if (options.debug_options & DebugStat)
- fprintf(stderr, "fallback_stat(): stat(%s) failed; falling back on lstat()\n", name);
- return fstatat(state.cwd_dir_fd, name, p, AT_SYMLINK_NOFOLLOW);
+ fprintf (stderr,
+ "fallback_stat(): stat(%s) failed; falling back on lstat()\n",
+ name);
+ return fstatat (state.cwd_dir_fd, name, p, AT_SYMLINK_NOFOLLOW);
case EACCES:
case EIO:
case ELOOP:
case ENAMETOOLONG:
#ifdef EOVERFLOW
- case EOVERFLOW: /* EOVERFLOW is not #defined on UNICOS. */
+ case EOVERFLOW: /* EOVERFLOW is not #defined on UNICOS. */
#endif
default:
return prev_rv;
@@ -645,7 +649,7 @@ optionh_stat (const char *name, struct stat *p)
* link points to, not the symbolic link itself.
*/
int
-optionl_stat(const char *name, struct stat *p)
+optionl_stat (const char *name, struct stat *p)
{
int rv;
if (AT_FDCWD != state.cwd_dir_fd)
@@ -666,7 +670,7 @@ optionl_stat(const char *name, struct stat *p)
int
optionp_stat (const char *name, struct stat *p)
{
- assert ((state.cwd_dir_fd >= 0) || (state.cwd_dir_fd==AT_FDCWD));
+ assert ((state.cwd_dir_fd >= 0) || (state.cwd_dir_fd == AT_FDCWD));
set_stat_placeholders (p);
return fstatat (state.cwd_dir_fd, name, p, AT_SYMLINK_NOFOLLOW);
}
@@ -689,14 +693,13 @@ debug_stat (const char *file, struct stat *bufp)
case SYMLINK_NEVER_DEREF:
return optionp_stat (file, bufp);
}
- /*NOTREACHED*/
- assert (0);
+ /*NOTREACHED*/ assert (0);
return -1;
}
bool
-following_links(void)
+following_links (void)
{
switch (options.symlink_handling)
{
@@ -716,16 +719,14 @@ following_links(void)
bool
digest_mode (mode_t *mode,
const char *pathname,
- const char *name,
- struct stat *pstat,
- bool leaf)
+ const char *name, struct stat *pstat, bool leaf)
{
/* If we know the type of the directory entry, and it is not a
* symbolic link, we may be able to avoid a stat() or lstat() call.
*/
if (*mode)
{
- if (S_ISLNK(*mode) && following_links())
+ if (S_ISLNK (*mode) && following_links ())
{
/* mode is wrong because we should have followed the symlink. */
if (get_statinfo (pathname, name, pstat) != 0)
@@ -835,7 +836,7 @@ process_debug_options (char *arg)
{
empty = false;
- for (i=0; i<N_DEBUGASSOC; ++i)
+ for (i = 0; i < N_DEBUGASSOC; ++i)
{
if (0 == strcmp (debugassoc[i].name, p))
{
@@ -869,14 +870,15 @@ process_optimisation_option (const char *arg)
if (0 == arg[0])
{
error (EXIT_FAILURE, 0,
- _("The -O option must be immediately followed by a decimal integer"));
+ _
+ ("The -O option must be immediately followed by a decimal integer"));
}
else
{
unsigned long opt_level;
char *end;
- if (!isdigit ( (unsigned char) arg[0] ))
+ if (!isdigit ((unsigned char) arg[0]))
{
error (EXIT_FAILURE, 0,
_("Please specify a decimal number immediately after -O"));
@@ -884,20 +886,22 @@ process_optimisation_option (const char *arg)
else
{
int prev_errno = errno;
- errno = 0;
+ errno = 0;
opt_level = strtoul (arg, &end, 10);
- if ( (0==opt_level) && (end==arg) )
+ if ((0 == opt_level) && (end == arg))
{
error (EXIT_FAILURE, 0,
- _("Please specify a decimal number immediately after -O"));
+ _
+ ("Please specify a decimal number immediately after -O"));
}
else if (*end)
{
/* unwanted trailing characters. */
- error (EXIT_FAILURE, 0, _("Invalid optimisation level %s"), arg);
+ error (EXIT_FAILURE, 0, _("Invalid optimisation level %s"),
+ arg);
}
- else if ( (ULONG_MAX==opt_level) && errno)
+ else if ((ULONG_MAX == opt_level) && errno)
{
error (EXIT_FAILURE, errno,
_("Invalid optimisation level %s"), arg);
@@ -910,8 +914,7 @@ process_optimisation_option (const char *arg)
error (EXIT_FAILURE, 0,
_("Optimisation level %lu is too high. "
"If you want to find files very quickly, "
- "consider using GNU locate."),
- opt_level);
+ "consider using GNU locate."), opt_level);
}
else
{
@@ -927,7 +930,7 @@ process_leading_options (int argc, char *argv[])
{
int i, end_of_leading_options;
- for (i=1; (end_of_leading_options = i) < argc; ++i)
+ for (i = 1; (end_of_leading_options = i) < argc; ++i)
{
if (0 == strcmp ("-H", argv[i]))
{
@@ -947,22 +950,22 @@ process_leading_options (int argc, char *argv[])
else if (0 == strcmp ("--", argv[i]))
{
/* -- signifies the end of options. */
- end_of_leading_options = i+1; /* Next time start with the next option */
+ end_of_leading_options = i + 1; /* Next time start with the next option */
break;
}
else if (0 == strcmp ("-D", argv[i]))
{
- if (argc <= i+1)
+ if (argc <= i + 1)
{
error (0, 0, _("Missing argument after the -D option."));
usage (EXIT_FAILURE);
}
- process_debug_options (argv[i+1]);
+ process_debug_options (argv[i + 1]);
++i; /* skip the argument too. */
}
else if (0 == strncmp ("-O", argv[i], 2))
{
- process_optimisation_option (argv[i]+2);
+ process_optimisation_option (argv[i] + 2);
}
else
{
@@ -970,7 +973,7 @@ process_leading_options (int argc, char *argv[])
* (a) A path name
* (b) A predicate
*/
- end_of_leading_options = i; /* Next time start with this option */
+ end_of_leading_options = i; /* Next time start with this option */
break;
}
}
@@ -1053,7 +1056,7 @@ set_option_defaults (struct options *p)
p->no_leaf_check = true;
#endif
- set_follow_state (SYMLINK_NEVER_DEREF); /* The default is equivalent to -P. */
+ set_follow_state (SYMLINK_NEVER_DEREF); /* The default is equivalent to -P. */
p->err_quoting_style = locale_quoting_style;
@@ -1066,17 +1069,18 @@ set_option_defaults (struct options *p)
*
*/
bool
-apply_predicate(const char *pathname, struct stat *stat_buf, struct predicate *p)
+apply_predicate (const char *pathname, struct stat *stat_buf,
+ struct predicate *p)
{
++p->perf.visits;
if (p->need_stat || p->need_type || p->need_inum)
{
/* We may need a stat here. */
- if (get_info(pathname, stat_buf, p) != 0)
- return false;
+ if (get_info (pathname, stat_buf, p) != 0)
+ return false;
}
- if ((p->pred_func)(pathname, stat_buf, p))
+ if ((p->pred_func) (pathname, stat_buf, p))
{
++(p->perf.successes);
return true;
@@ -1109,8 +1113,8 @@ safely_quote_err_filename (int n, char const *arg)
/* report_file_err
*/
static void
-report_file_err(int exitval, int errno_value,
- bool is_target_file, const char *name)
+report_file_err (int exitval, int errno_value,
+ bool is_target_file, const char *name)
{
/* It is important that the errno value is passed in as a function
* argument before we call safely_quote_err_filename(), because otherwise
@@ -1142,11 +1146,10 @@ nonfatal_target_file_error (int errno_value, const char *name)
*
*/
void
-fatal_target_file_error(int errno_value, const char *name)
+fatal_target_file_error (int errno_value, const char *name)
{
report_file_err (1, errno_value, true, name);
- /*NOTREACHED*/
- abort ();
+ /*NOTREACHED*/ abort ();
}
/* nonfatal_nontarget_file_error
@@ -1162,7 +1165,7 @@ nonfatal_nontarget_file_error (int errno_value, const char *name)
*
*/
void
-fatal_nontarget_file_error(int errno_value, const char *name)
+fatal_nontarget_file_error (int errno_value, const char *name)
{
/* We're going to exit fatally, so make sure we always issue the error
* message, even if it will be duplicate. Motivation: otherwise it may
@@ -1170,6 +1173,5 @@ fatal_nontarget_file_error(int errno_value, const char *name)
*/
state.already_issued_stat_error_msg = false;
report_file_err (1, errno_value, false, name);
- /*NOTREACHED*/
- abort ();
+ /*NOTREACHED*/ abort ();
}
diff --git a/gnulib-local/lib/gcc-function-attributes.h b/gnulib-local/lib/gcc-function-attributes.h
index c9eb8583..79f3ebfd 100644
--- a/gnulib-local/lib/gcc-function-attributes.h
+++ b/gnulib-local/lib/gcc-function-attributes.h
@@ -102,7 +102,8 @@ visibility "default"
# if __GNUC_PREREQ(4,3)
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
# else
-# define _GL_ATTRIBUTE_ALLOC_SIZE(args) /* unsupported */
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
+ /* unsupported */
# endif
# endif
@@ -110,7 +111,7 @@ visibility "default"
# if __GNUC_PREREQ(3,1)
# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
# else
-# define _GL_ATTRIBUTE_DEPRECATED /* empty */
+# define _GL_ATTRIBUTE_DEPRECATED /* empty */
# endif
# endif
@@ -118,7 +119,7 @@ visibility "default"
# if __GNUC_PREREQ(2,7)
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
# else
-# define _GL_ATTRIBUTE_FORMAT(spec) /* unsupported */
+# define _GL_ATTRIBUTE_FORMAT(spec) /* unsupported */
# endif
# endif
@@ -127,7 +128,7 @@ visibility "default"
# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
# else
-# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(spec) /* unsupported */
+# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(spec) /* unsupported */
# endif
# endif
@@ -141,7 +142,7 @@ visibility "default"
_GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
# endif
# else
-# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(spec) /* unsupported */
+# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(spec) /* unsupported */
# endif
# endif
@@ -150,7 +151,8 @@ visibility "default"
# define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
# else
-# define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(spec) /* unsupported */
+# define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(spec)
+ /* unsupported */
# endif
# endif
@@ -164,7 +166,7 @@ visibility "default"
_GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
# endif
# else
-# define _GL_ATTRIBUTE_FORMAT_SCANF(spec) /* unsupported */
+# define _GL_ATTRIBUTE_FORMAT_SCANF(spec) /* unsupported */
# endif
# endif
@@ -172,7 +174,7 @@ visibility "default"
# if __GNUC_PREREQ(3,0)
# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
# else
-# define _GL_ATTRIBUTE_MALLOC /* unsupported */
+# define _GL_ATTRIBUTE_MALLOC /* unsupported */
# endif
# endif
@@ -181,7 +183,7 @@ visibility "default"
# if __GNUC_PREREQ(3,3)
# define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
# else
-# define _GL_ATTRIBUTE_NONNULL(m) /* unsupported */
+# define _GL_ATTRIBUTE_NONNULL(m) /* unsupported */
# endif
# endif
# ifndef _GL_ARG_NONNULL
@@ -194,7 +196,8 @@ visibility "default"
# if __GNUC_PREREQ(2,8)
# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# else
-# define _GL_ATTRIBUTE_NORETURN /* unsupported */
+# define _GL_ATTRIBUTE_NORETURN
+ /* unsupported */
# endif
# endif
@@ -202,19 +205,19 @@ visibility "default"
# if __GNUC_PREREQ(2,96)
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
-# define _GL_ATTRIBUTE_PURE /* unsupported */
+# define _GL_ATTRIBUTE_PURE /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_SENTINEL
# if __GNUC_PREREQ(4,0)
/* gnulib uses the __attribute__((__sentinel__)) variant, for which the
- argument number 0 is assumed. Arguments are counted backwards, the last
- being 0.
- */
+ argument number 0 is assumed. Arguments are counted backwards, the last
+ being 0.
+ */
# define _GL_ATTRIBUTE_SENTINEL(backward_arg_num) __attribute__ ((__sentinel__(backward_arg_num)))
# else
-# define _GL_ATTRIBUTE_SENTINEL(backward_arg_num) /* unsupported */
+# define _GL_ATTRIBUTE_SENTINEL(backward_arg_num) /* unsupported */
# endif
# endif
@@ -222,7 +225,7 @@ visibility "default"
# if __GNUC_PREREQ(3,4)
# define _GL_ATTRIBUTE_WUR __attribute__ ((__warn__unused_result__))
# else
-# define _GL_ATTRIBUTE_WUR /* unsupported */
+# define _GL_ATTRIBUTE_WUR /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_RETURN_CHECK
diff --git a/lib/bugreports.c b/lib/bugreports.c
index 33c68f87..920c84c7 100644
--- a/lib/bugreports.c
+++ b/lib/bugreports.c
@@ -25,15 +25,13 @@
int
explain_how_to_report_bugs (FILE *f, const char *program_name)
{
- return fprintf (f,_(""
-"Please see also the documentation at %s.\n"
-"You can report (and track progress on fixing) bugs in the \"%s\"\n"
-"program via the %s bug-reporting page at\n"
-"%s or, if\n"
-"you have no web access, by sending email to <%s>.\n"),
+ return fprintf (f, _(""
+ "Please see also the documentation at %s.\n"
+ "You can report (and track progress on fixing) bugs in the \"%s\"\n"
+ "program via the %s bug-reporting page at\n"
+ "%s or, if\n"
+ "you have no web access, by sending email to <%s>.\n"),
PACKAGE_URL,
program_name,
- PACKAGE_NAME,
- PACKAGE_BUGREPORT_URL,
- PACKAGE_BUGREPORT);
+ PACKAGE_NAME, PACKAGE_BUGREPORT_URL, PACKAGE_BUGREPORT);
}
diff --git a/lib/bugreports.h b/lib/bugreports.h
index b34bb14d..7a717f7f 100644
--- a/lib/bugreports.h
+++ b/lib/bugreports.h
@@ -21,6 +21,6 @@
# include <stdio.h>
/* Interpreetation of the return code is as for fprintf. */
-int explain_how_to_report_bugs (FILE *f, const char *program_name);
+int explain_how_to_report_bugs (FILE * f, const char *program_name);
#endif
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index 66bc7f95..008c9b24 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -54,8 +54,7 @@ static const char *special_terminating_arg = "do_not_care";
/* Add a terminator to the argument list. */
static void
-bc_args_complete (struct buildcmd_control *ctl,
- struct buildcmd_state *state)
+bc_args_complete (struct buildcmd_control *ctl, struct buildcmd_state *state)
{
bc_push_arg (ctl, state, special_terminating_arg, 0, NULL, 0, 0);
}
@@ -78,14 +77,13 @@ bc_do_insert (struct buildcmd_control *ctl,
struct buildcmd_state *state,
char *arg, size_t arglen,
const char *prefix, size_t pfxlen,
- const char *linebuf, size_t lblen,
- int initial_args)
+ const char *linebuf, size_t lblen, int initial_args)
{
/* Temporary copy of each arg with the replace pattern replaced by the
real arg. */
static char *insertbuf;
char *p;
- size_t bytes_left = ctl->arg_max - 1; /* Bytes left on the command line. */
+ size_t bytes_left = ctl->arg_max - 1; /* Bytes left on the command line. */
/* XXX: on systems lacking an upper limit for exec args, ctl->arg_max
* may have been set to LONG_MAX (see bc_get_arg_max()). Hence
@@ -143,10 +141,7 @@ bc_do_insert (struct buildcmd_control *ctl,
error (EXIT_FAILURE, 0, _("command too long"));
*p++ = '\0';
- bc_push_arg (ctl, state,
- insertbuf, p - insertbuf,
- NULL, 0,
- initial_args);
+ bc_push_arg (ctl, state, insertbuf, p - insertbuf, NULL, 0, initial_args);
}
@@ -155,9 +150,7 @@ bc_do_insert (struct buildcmd_control *ctl,
*/
static size_t
update_limit (struct buildcmd_control *ctl,
- struct buildcmd_state *state,
- bool success,
- size_t limit)
+ struct buildcmd_state *state, bool success, size_t limit)
{
if (success)
{
@@ -172,7 +165,8 @@ update_limit (struct buildcmd_control *ctl,
}
if (0 == (state->largest_successful_arg_count)
- || (state->smallest_failed_arg_count <= state->largest_successful_arg_count))
+ || (state->smallest_failed_arg_count <=
+ state->largest_successful_arg_count))
{
/* No success yet, or running on a system which has
limits on total argv length, but not arg count. */
@@ -186,10 +180,10 @@ update_limit (struct buildcmd_control *ctl,
limit /= 2;
}
}
- else /* We can use bisection. */
+ else /* We can use bisection. */
{
const size_t shift = (state->smallest_failed_arg_count
- - state->largest_successful_arg_count) / 2;
+ - state->largest_successful_arg_count) / 2;
if (success)
{
if (shift)
@@ -224,7 +218,7 @@ update_limit (struct buildcmd_control *ctl,
static size_t
copy_args (struct buildcmd_control *ctl,
struct buildcmd_state *state,
- char** working_args, size_t limit, size_t done)
+ char **working_args, size_t limit, size_t done)
{
size_t dst_pos = 0;
size_t src_pos = 0;
@@ -248,53 +242,53 @@ copy_args (struct buildcmd_control *ctl,
/* Execute the program with the currently-built list of arguments. */
void
-bc_do_exec (struct buildcmd_control *ctl,
- struct buildcmd_state *state)
+bc_do_exec (struct buildcmd_control *ctl, struct buildcmd_state *state)
{
- char** working_args;
- size_t limit, done;
-
- /* Terminate the args. */
- bc_args_complete (ctl, state);
- /* Verify that the argument list is terminated. */
- assert (state->cmd_argc > 0);
- assert (state->cmd_argv[state->cmd_argc-1] == NULL);
-
- working_args = xmalloc ((1+state->cmd_argc) * sizeof (char*));
- done = 0;
- limit = state->cmd_argc;
-
- do
- {
- const size_t dst_pos = copy_args (ctl, state, working_args,
- limit, done);
- if (ctl->exec_callback (ctl, state->usercontext, dst_pos, working_args))
- {
- limit = update_limit (ctl, state, true, limit);
- done += (dst_pos - ctl->initial_argc);
- }
- else /* got E2BIG, adjust arguments */
- {
- if (limit <= ctl->initial_argc + 1)
- {
- /* No room to reduce the length of the argument list.
- Issue an error message and give up. */
- error (EXIT_FAILURE, 0,
- _("can't call exec() due to argument size restrictions"));
- }
- else
- {
- /* Try fewer arguments. */
- limit = update_limit (ctl, state, false, limit);
- }
- }
- }
- while ((done + 1) < (state->cmd_argc - ctl->initial_argc));
- /* (state->cmd_argc - ctl->initial_argc) includes the terminating NULL,
- * which is why we add 1 to done in the test above. */
-
- free (working_args);
- bc_clear_args (ctl, state);
+ char **working_args;
+ size_t limit, done;
+
+ /* Terminate the args. */
+ bc_args_complete (ctl, state);
+ /* Verify that the argument list is terminated. */
+ assert (state->cmd_argc > 0);
+ assert (state->cmd_argv[state->cmd_argc - 1] == NULL);
+
+ working_args = xmalloc ((1 + state->cmd_argc) * sizeof (char *));
+ done = 0;
+ limit = state->cmd_argc;
+
+ do
+ {
+ const size_t dst_pos = copy_args (ctl, state, working_args,
+ limit, done);
+ if (ctl->exec_callback (ctl, state->usercontext, dst_pos, working_args))
+ {
+ limit = update_limit (ctl, state, true, limit);
+ done += (dst_pos - ctl->initial_argc);
+ }
+ else /* got E2BIG, adjust arguments */
+ {
+ if (limit <= ctl->initial_argc + 1)
+ {
+ /* No room to reduce the length of the argument list.
+ Issue an error message and give up. */
+ error (EXIT_FAILURE, 0,
+ _
+ ("can't call exec() due to argument size restrictions"));
+ }
+ else
+ {
+ /* Try fewer arguments. */
+ limit = update_limit (ctl, state, false, limit);
+ }
+ }
+ }
+ while ((done + 1) < (state->cmd_argc - ctl->initial_argc));
+ /* (state->cmd_argc - ctl->initial_argc) includes the terminating NULL,
+ * which is why we add 1 to done in the test above. */
+
+ free (working_args);
+ bc_clear_args (ctl, state);
}
@@ -312,7 +306,7 @@ bc_argc_limit_reached (int initial_args,
{
/* Check to see if we about to exceed a limit set by xargs' -n option */
if (!initial_args && ctl->args_per_exec &&
- ( (state->cmd_argc - ctl->initial_argc) == ctl->args_per_exec))
+ ((state->cmd_argc - ctl->initial_argc) == ctl->args_per_exec))
return 1;
/* We deliberately use an equality test here rather than >= in order
@@ -332,8 +326,7 @@ void
bc_push_arg (struct buildcmd_control *ctl,
struct buildcmd_state *state,
const char *arg, size_t len,
- const char *prefix, size_t pfxlen,
- int initial_args)
+ const char *prefix, size_t pfxlen, int initial_args)
{
const int terminate = (arg == special_terminating_arg);
@@ -346,7 +339,8 @@ bc_push_arg (struct buildcmd_control *ctl,
if (initial_args || state->cmd_argc == ctl->initial_argc)
{
error (EXIT_FAILURE, 0,
- _("cannot fit single argument within argument list size limit"));
+ _
+ ("cannot fit single argument within argument list size limit"));
}
/* xargs option -i (replace_pat) implies -x (exit_if_size_exceeded) */
@@ -359,7 +353,7 @@ bc_push_arg (struct buildcmd_control *ctl,
bc_do_exec (ctl, state);
}
if (bc_argc_limit_reached (initial_args, ctl, state))
- bc_do_exec (ctl, state);
+ bc_do_exec (ctl, state);
}
if (!initial_args)
@@ -379,7 +373,8 @@ bc_push_arg (struct buildcmd_control *ctl,
{
state->cmd_argv_alloc *= 2;
state->cmd_argv = xrealloc (state->cmd_argv,
- sizeof (char *) * state->cmd_argv_alloc);
+ sizeof (char *) *
+ state->cmd_argv_alloc);
}
}
@@ -387,7 +382,8 @@ bc_push_arg (struct buildcmd_control *ctl,
state->cmd_argv[state->cmd_argc++] = NULL;
else
{
- state->cmd_argv[state->cmd_argc++] = state->argbuf + state->cmd_argv_chars;
+ state->cmd_argv[state->cmd_argc++] =
+ state->argbuf + state->cmd_argv_chars;
if (prefix)
{
strcpy (state->argbuf + state->cmd_argv_chars, prefix);
@@ -421,7 +417,7 @@ bc_get_arg_max (void)
/* We may resort to using LONG_MAX, so check it fits. */
/* XXX: better to do a compile-time check */
- assert ( (~(size_t)0) >= LONG_MAX);
+ assert ((~(size_t) 0) >= LONG_MAX);
#ifdef _SC_ARG_MAX
val = sysconf (_SC_ARG_MAX);
@@ -452,10 +448,8 @@ bc_get_arg_max (void)
static int
-cb_exec_noop (struct buildcmd_control * ctl,
- void *usercontext,
- int argc,
- char **argv)
+cb_exec_noop (struct buildcmd_control *ctl,
+ void *usercontext, int argc, char **argv)
{
/* does nothing. */
(void) ctl;
@@ -482,8 +476,7 @@ bc_size_of_environment (void)
enum BC_INIT_STATUS
-bc_init_controlinfo (struct buildcmd_control *ctl,
- size_t headroom)
+bc_init_controlinfo (struct buildcmd_control *ctl, size_t headroom)
{
size_t size_of_environment = bc_size_of_environment ();
@@ -517,7 +510,7 @@ bc_init_controlinfo (struct buildcmd_control *ctl,
}
/* need to subtract 2 on the following line - for Linux/PPC */
- ctl->max_arg_count = (ctl->posix_arg_size_max / sizeof (char*)) - 2u;
+ ctl->max_arg_count = (ctl->posix_arg_size_max / sizeof (char *)) - 2u;
assert (ctl->max_arg_count > 0);
ctl->rplen = 0u;
ctl->replace_pat = NULL;
@@ -538,9 +531,11 @@ void
bc_use_sensible_arg_max (struct buildcmd_control *ctl)
{
#ifdef DEFAULT_ARG_SIZE
- enum { arg_size = DEFAULT_ARG_SIZE };
+ enum
+ { arg_size = DEFAULT_ARG_SIZE };
#else
- enum { arg_size = (128u * 1024u) };
+ enum
+ { arg_size = (128u * 1024u) };
#endif
/* Check against the upper and lower limits. */
@@ -557,8 +552,7 @@ bc_use_sensible_arg_max (struct buildcmd_control *ctl)
void
bc_init_state (const struct buildcmd_control *ctl,
- struct buildcmd_state *state,
- void *context)
+ struct buildcmd_state *state, void *context)
{
state->cmd_argc = 0;
state->cmd_argv_chars = 0;
@@ -613,8 +607,7 @@ exceeds (const char *env_var_name, size_t quantity)
{
error (EXIT_FAILURE, errno,
_("Environment variable %s is not set to a "
- "valid decimal number"),
- env_var_name);
+ "valid decimal number"), env_var_name);
return 0;
}
}
@@ -630,10 +623,10 @@ bc_args_exceed_testing_limit (char **argv)
{
size_t chars, args;
- for (chars=args=0; *argv; ++argv)
+ for (chars = args = 0; *argv; ++argv)
{
++args;
- chars += strlen(*argv);
+ chars += strlen (*argv);
}
return (exceeds ("__GNU_FINDUTILS_EXEC_ARG_COUNT_LIMIT", args) ||
diff --git a/lib/buildcmd.h b/lib/buildcmd.h
index df86a3c6..55eb5779 100644
--- a/lib/buildcmd.h
+++ b/lib/buildcmd.h
@@ -25,10 +25,10 @@
struct buildcmd_state
{
/* Number of valid elements in `cmd_argv', including terminating NULL. */
- size_t cmd_argc; /* 0 */
+ size_t cmd_argc; /* 0 */
/* The list of args being built. */
- char **cmd_argv; /* NULL */
+ char **cmd_argv; /* NULL */
/* Number of elements allocated for `cmd_argv'. */
size_t cmd_argv_alloc;
@@ -59,7 +59,7 @@ struct buildcmd_state
struct buildcmd_control
{
/* If true, exit if lines_per_exec or args_per_exec is exceeded. */
- int exit_if_size_exceeded; /* false */
+ int exit_if_size_exceeded; /* false */
/* POSIX limits on the argument length. */
size_t posix_arg_size_max;
@@ -84,31 +84,32 @@ struct buildcmd_control
size_t rplen;
/* If nonzero, then instead of putting the args from stdin at
- the end of the command argument list, they are each stuck into the
- initial args, replacing each occurrence of the `replace_pat' in the
- initial args. */
+ the end of the command argument list, they are each stuck into the
+ initial args, replacing each occurrence of the `replace_pat' in the
+ initial args. */
const char *replace_pat;
/* Number of initial arguments given on the command line. */
size_t initial_argc; /* 0 */
/* exec callback. */
- int (*exec_callback)(struct buildcmd_control *, void *usercontext, int argc, char **argv);
+ int (*exec_callback) (struct buildcmd_control *, void *usercontext,
+ int argc, char **argv);
/* If nonzero, the maximum number of nonblank lines from stdin to use
per command line. */
- unsigned long lines_per_exec; /* 0 */
+ unsigned long lines_per_exec; /* 0 */
/* The maximum number of arguments to use per command line. */
size_t args_per_exec;
};
enum BC_INIT_STATUS
- {
- BC_INIT_OK = 0,
- BC_INIT_ENV_TOO_BIG,
- BC_INIT_CANNOT_ACCOMODATE_HEADROOM
- };
+{
+ BC_INIT_OK = 0,
+ BC_INIT_ENV_TOO_BIG,
+ BC_INIT_CANNOT_ACCOMODATE_HEADROOM
+};
extern size_t bc_size_of_environment (void);
@@ -121,24 +122,22 @@ extern void bc_do_insert (struct buildcmd_control *ctl,
int initial_args);
extern void bc_do_exec (struct buildcmd_control *ctl,
- struct buildcmd_state *state);
+ struct buildcmd_state *state);
extern void bc_push_arg (struct buildcmd_control *ctl,
struct buildcmd_state *state,
- const char *arg, size_t len,
- const char *prefix, size_t pfxlen,
- int initial_args);
-
-extern void bc_init_state(const struct buildcmd_control *ctl,
- struct buildcmd_state *state,
- void *usercontext);
-extern enum BC_INIT_STATUS bc_init_controlinfo(struct buildcmd_control *ctl,
- size_t arglen_headroom);
-extern size_t bc_get_arg_max(void);
-extern void bc_use_sensible_arg_max(struct buildcmd_control *ctl);
-extern void bc_clear_args(const struct buildcmd_control *ctl,
- struct buildcmd_state *state);
-bool bc_args_exceed_testing_limit(char **argv);
+ const char *arg, size_t len,
+ const char *prefix, size_t pfxlen, int initial_args);
+
+extern void bc_init_state (const struct buildcmd_control *ctl,
+ struct buildcmd_state *state, void *usercontext);
+extern enum BC_INIT_STATUS bc_init_controlinfo (struct buildcmd_control *ctl,
+ size_t arglen_headroom);
+extern size_t bc_get_arg_max (void);
+extern void bc_use_sensible_arg_max (struct buildcmd_control *ctl);
+extern void bc_clear_args (const struct buildcmd_control *ctl,
+ struct buildcmd_state *state);
+bool bc_args_exceed_testing_limit (char **argv);
#endif
diff --git a/lib/dircallback.c b/lib/dircallback.c
index e868dc48..b9e5db81 100644
--- a/lib/dircallback.c
+++ b/lib/dircallback.c
@@ -36,7 +36,7 @@
int
run_in_dir (const struct saved_cwd *there,
- int (*callback)(void*), void *usercontext)
+ int (*callback) (void *), void *usercontext)
{
int err = -1;
int saved_errno = 0;
@@ -45,7 +45,7 @@ run_in_dir (const struct saved_cwd *there,
{
if (0 == restore_cwd (there))
{
- err = callback(usercontext);
+ err = callback (usercontext);
saved_errno = (err < 0 ? errno : 0);
}
else
@@ -69,11 +69,11 @@ run_in_dir (const struct saved_cwd *there,
int
-run_in_dirfd (int dir_fd, int (*callback)(void*), void *usercontext)
+run_in_dirfd (int dir_fd, int (*callback) (void *), void *usercontext)
{
if (dir_fd == AT_FDCWD)
{
- return (*callback)(usercontext);
+ return (*callback) (usercontext);
}
else
{
@@ -92,7 +92,7 @@ run_in_dirfd (int dir_fd, int (*callback)(void*), void *usercontext)
return -1;
}
- err = (*callback)(usercontext);
+ err = (*callback) (usercontext);
saved_errno = (err < 0 ? errno : 0);
if (restore_cwd (&saved_cwd) != 0)
diff --git a/lib/dircallback.h b/lib/dircallback.h
index 1b50e06d..114f7700 100644
--- a/lib/dircallback.h
+++ b/lib/dircallback.h
@@ -21,7 +21,8 @@
struct saved_cwd;
-int run_in_dirfd (int fd, int (*callback)(void*), void *usercontext);
-int run_in_dir (const struct saved_cwd*, int (*callback)(void*), void *usercontext);
+int run_in_dirfd (int fd, int (*callback) (void *), void *usercontext);
+int run_in_dir (const struct saved_cwd *, int (*callback) (void *),
+ void *usercontext);
#endif
diff --git a/lib/extendbuf.c b/lib/extendbuf.c
index 611e5557..df41228e 100644
--- a/lib/extendbuf.c
+++ b/lib/extendbuf.c
@@ -60,18 +60,18 @@ decide_size (size_t current, size_t wanted)
void *
-extendbuf (void* existing, size_t wanted, size_t *allocated)
+extendbuf (void *existing, size_t wanted, size_t *allocated)
{
int saved_errno;
size_t newsize;
- void *result; /* leave uninitialized to allow static code checkers to identify bugs */
+ void *result; /* leave uninitialized to allow static code checkers to identify bugs */
saved_errno = errno;
assert (wanted > 0u);
newsize = decide_size (*allocated, wanted);
- if ( (*allocated) == 0 )
+ if ((*allocated) == 0)
{
/* Sanity check: If there is no existing allocation size, there
* must be no existing allocated buffer.
@@ -83,7 +83,7 @@ extendbuf (void* existing, size_t wanted, size_t *allocated)
}
else
{
- if (newsize != (*allocated) )
+ if (newsize != (*allocated))
{
(*allocated) = newsize;
result = realloc (existing, newsize);
@@ -102,7 +102,7 @@ extendbuf (void* existing, size_t wanted, size_t *allocated)
{
/* malloc () or realloc () may have changed errno, but in the
success case we want to preserve the previous value.
- */
+ */
errno = saved_errno;
}
return result;
@@ -110,7 +110,7 @@ extendbuf (void* existing, size_t wanted, size_t *allocated)
void *
-xextendbuf (void* existing, size_t wanted, size_t *allocated)
+xextendbuf (void *existing, size_t wanted, size_t *allocated)
{
void *p = extendbuf (existing, wanted, allocated);
if (NULL == p)
diff --git a/lib/extendbuf.h b/lib/extendbuf.h
index 720253c6..ac841510 100644
--- a/lib/extendbuf.h
+++ b/lib/extendbuf.h
@@ -19,8 +19,8 @@
#ifndef INC_EXTENDBUF_H
# define INC_EXTENDBUF_H 1
-void *extendbuf(void* existing, size_t wanted, size_t *allocated);
-void *xextendbuf(void* existing, size_t wanted, size_t *allocated);
+void *extendbuf (void *existing, size_t wanted, size_t *allocated);
+void *xextendbuf (void *existing, size_t wanted, size_t *allocated);
#endif
diff --git a/lib/fdleak.c b/lib/fdleak.c
index a107cfd1..ada49356 100644
--- a/lib/fdleak.c
+++ b/lib/fdleak.c
@@ -79,7 +79,8 @@ get_proc_max_fd (void)
{
if (errno)
{
- error (0, errno, "%s", quotearg_n_style (0, locale_quoting_style, path));
+ error (0, errno, "%s",
+ quotearg_n_style (0, locale_quoting_style, path));
good = 0;
}
break;
@@ -138,9 +139,10 @@ get_max_fd (void)
static int
visit_open_fds (int fd_min, int fd_max,
- int (*callback)(int, void*), void *cb_context)
+ int (*callback) (int, void *), void *cb_context)
{
- enum { MAX_POLL = 64 };
+ enum
+ { MAX_POLL = 64 };
struct pollfd pf[MAX_POLL];
int rv = 0;
@@ -151,9 +153,9 @@ visit_open_fds (int fd_min, int fd_max,
if (limit > MAX_POLL)
limit = MAX_POLL;
- for (i=0; i<limit; i++)
+ for (i = 0; i < limit; i++)
{
- pf[i].events = POLLIN|POLLOUT;
+ pf[i].events = POLLIN | POLLOUT;
pf[i].revents = 0;
pf[i].fd = fd_min + i;
}
@@ -165,7 +167,7 @@ visit_open_fds (int fd_min, int fd_max,
else
{
int j;
- for (j=0; j<limit; j++)
+ for (j = 0; j < limit; j++)
{
if (pf[j].revents != POLLNVAL)
{
@@ -206,9 +208,9 @@ remember_fd_if_non_cloexec (int fd, void *context)
}
else
{
- struct remember_fd_context * const p = context;
+ struct remember_fd_context *const p = context;
void *newbuf = extendbuf (p->buf,
- sizeof (p->buf[0])*(p->used+1),
+ sizeof (p->buf[0]) * (p->used + 1),
&(p->allocated));
if (newbuf)
{
@@ -285,7 +287,7 @@ find_first_leak_callback (int fd, void *context)
static int
-find_first_leaked_fd (const int* prev_non_cloexec_fds, size_t n)
+find_first_leaked_fd (const int *prev_non_cloexec_fds, size_t n)
{
struct fd_leak_context context;
int max_fd = get_max_fd ();
@@ -307,7 +309,7 @@ static bool
o_cloexec_works (void)
{
bool result = false;
- int fd = open ("/", O_RDONLY|O_CLOEXEC);
+ int fd = open ("/", O_RDONLY | O_CLOEXEC);
if (fd >= 0)
{
result = fd_is_cloexec (fd);
@@ -349,7 +351,7 @@ open_cloexec (const char *path, int flags, ...)
cloexec_works = o_cloexec_works ();
cloexec_status_known = true;
}
- fd = open (path, flags|O_CLOEXEC, mode);
+ fd = open (path, flags | O_CLOEXEC, mode);
if ((fd >= 0) && !(O_CLOEXEC && cloexec_works))
{
set_cloexec_flag (fd, true);
@@ -381,7 +383,8 @@ void
complain_about_leaky_fds (void)
{
int no_leaks = 1;
- const int leaking_fd = find_first_leaked_fd (non_cloexec_fds, num_cloexec_fds);
+ const int leaking_fd =
+ find_first_leaked_fd (non_cloexec_fds, num_cloexec_fds);
if (leaking_fd >= 0)
{
@@ -389,8 +392,7 @@ complain_about_leaky_fds (void)
error (0, 0,
_("File descriptor %d will leak; please report this as a bug, "
"remembering to include a detailed description of the simplest "
- "way to reproduce this problem."),
- leaking_fd);
+ "way to reproduce this problem."), leaking_fd);
}
assert (no_leaks);
}
diff --git a/lib/fdleak.h b/lib/fdleak.h
index 646d1bce..330a11e3 100644
--- a/lib/fdleak.h
+++ b/lib/fdleak.h
@@ -24,6 +24,6 @@ void forget_non_cloexec_fds (void);
void complain_about_leaky_fds (void);
bool fd_leak_check_is_enabled (void);
-int open_cloexec(const char *path, int flags, ...);
+int open_cloexec (const char *path, int flags, ...);
#endif
diff --git a/lib/findutils-version.c b/lib/findutils-version.c
index 6318e81b..e1d0bdd3 100644
--- a/lib/findutils-version.c
+++ b/lib/findutils-version.c
@@ -44,8 +44,7 @@ display_findutils_version (const char *official_name)
* GNU coding standard.
*/
fflush (stderr);
- version_etc (stdout,
- official_name, PACKAGE_NAME, version_string,
+ version_etc (stdout, official_name, PACKAGE_NAME, version_string,
/* TRANSLATORS: This is a proper name. */
_("Eric B. Decker"),
/* TRANSLATORS: This is a proper name. */
@@ -53,6 +52,5 @@ display_findutils_version (const char *official_name)
/* TRANSLATORS: This is a proper name. */
_("Bernhard Voelker"),
/* TRANSLATORS: This is a proper name. */
- _("Kevin Dalley"),
- (const char*) NULL);
+ _("Kevin Dalley"), (const char *) NULL);
}
diff --git a/lib/findutils-version.h b/lib/findutils-version.h
index 5d7b3d2c..f1de5816 100644
--- a/lib/findutils-version.h
+++ b/lib/findutils-version.h
@@ -25,6 +25,6 @@
* or gfind).
*
*/
-void display_findutils_version(const char *official_name);
+void display_findutils_version (const char *official_name);
#endif
diff --git a/lib/listfile.c b/lib/listfile.c
index 464528e3..9c3fb613 100644
--- a/lib/listfile.c
+++ b/lib/listfile.c
@@ -29,7 +29,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
-#include <unistd.h> /* for readlink() */
+#include <unistd.h> /* for readlink() */
/* gnulib headers. */
#include "areadlink.h"
@@ -51,7 +51,7 @@
# ifdef MAJOR_IN_SYSMACROS
# include <sys/sysmacros.h>
# else
-# ifndef major /* Might be defined in sys/types.h. */
+# ifndef major /* Might be defined in sys/types.h. */
# define major(dev) (((dev) >> 8) & 0xff)
# define minor(dev) ((dev) & 0xff)
# endif
@@ -59,7 +59,8 @@
#endif
-static bool print_name (register const char *p, FILE *stream, int literal_control_chars);
+static bool print_name (register const char *p, FILE * stream,
+ int literal_control_chars);
/* We have some minimum field sizes, though we try to widen these fields on systems
* where we discover examples where the field width we started with is not enough. */
@@ -73,7 +74,8 @@ static int major_device_number_width = 3;
static int minor_device_number_width = 3;
static int file_size_width = 8;
-static bool print_num(FILE *stream, unsigned long num, int *width)
+static bool
+print_num (FILE *stream, unsigned long num, int *width)
{
const int chars_out = fprintf (stream, "%*lu", *width, num);
if (chars_out >= 0)
@@ -100,9 +102,7 @@ list_file (const char *name,
const char *relname,
const struct stat *statp,
time_t current_time,
- int output_block_size,
- int literal_control_chars,
- FILE *stream)
+ int output_block_size, int literal_control_chars, FILE *stream)
{
char modebuf[12];
struct tm const *when_local;
@@ -122,8 +122,7 @@ list_file (const char *name,
chars_out = fprintf (stream, "%*s", inode_number_width,
human_readable ((uintmax_t) statp->st_ino, hbuf,
- human_ceiling,
- 1u, 1u));
+ human_ceiling, 1u, 1u));
if (chars_out < 0)
{
output_good = false;
@@ -135,16 +134,16 @@ list_file (const char *name,
}
if (output_good)
{
- if (EOF == putc(' ', stream))
+ if (EOF == putc (' ', stream))
{
output_good = false;
failed_at = 150;
}
chars_out = fprintf (stream, "%*s",
block_size_width,
- human_readable ((uintmax_t) ST_NBLOCKS (*statp), hbuf,
- human_ceiling,
- ST_NBLOCKSIZE, output_block_size));
+ human_readable ((uintmax_t) ST_NBLOCKS (*statp),
+ hbuf, human_ceiling, ST_NBLOCKSIZE,
+ output_block_size));
if (chars_out < 0)
{
output_good = false;
@@ -159,7 +158,7 @@ list_file (const char *name,
if (output_good)
{
- if (EOF == putc(' ', stream))
+ if (EOF == putc (' ', stream))
{
output_good = false;
failed_at = 250;
@@ -181,8 +180,8 @@ list_file (const char *name,
has only one space between the link count and the owner name,
so we removed the trailing space. Happily this also makes it
easier to update nlink_width. */
- chars_out = fprintf (stream, "%*lu",
- nlink_width, (unsigned long) statp->st_nlink);
+ chars_out = fprintf (stream, "%*lu",
+ nlink_width, (unsigned long) statp->st_nlink);
if (chars_out < 0)
{
output_good = false;
@@ -197,7 +196,7 @@ list_file (const char *name,
if (output_good)
{
- if (EOF == putc(' ', stream))
+ if (EOF == putc (' ', stream))
{
output_good = false;
failed_at = 250;
@@ -208,13 +207,15 @@ list_file (const char *name,
int len = mbswidth (user_name, 0);
if (len > owner_width)
owner_width = len;
- output_good = (fprintf (stream, "%-*s ", owner_width, user_name) >= 0);
+ output_good =
+ (fprintf (stream, "%-*s ", owner_width, user_name) >= 0);
if (!output_good)
failed_at = 400;
}
else
{
- chars_out = fprintf (stream, "%-8lu ", (unsigned long) statp->st_uid);
+ chars_out =
+ fprintf (stream, "%-8lu ", (unsigned long) statp->st_uid);
if (chars_out > owner_width)
owner_width = chars_out;
output_good = (chars_out > 0);
@@ -231,7 +232,8 @@ list_file (const char *name,
int len = mbswidth (group_name, 0);
if (len > group_width)
group_width = len;
- output_good = (fprintf (stream, "%-*s ", group_width, group_name) >= 0);
+ output_good =
+ (fprintf (stream, "%-*s ", group_width, group_name) >= 0);
if (!output_good)
failed_at = 500;
}
@@ -244,7 +246,7 @@ list_file (const char *name,
output_good = (chars_out >= 0);
if (output_good)
{
- if (EOF == putc(' ', stream))
+ if (EOF == putc (' ', stream))
{
output_good = false;
failed_at = 525;
@@ -303,9 +305,9 @@ list_file (const char *name,
const int blocksize = output_block_size < 0 ? output_block_size : 1;
chars_out = fprintf (stream, "%*s",
file_size_width,
- human_readable ((uintmax_t) statp->st_size, hbuf,
- human_ceiling,
- 1, blocksize));
+ human_readable ((uintmax_t) statp->st_size,
+ hbuf, human_ceiling, 1,
+ blocksize));
if (chars_out < 0)
{
output_good = false;
@@ -323,7 +325,7 @@ list_file (const char *name,
if (output_good)
{
- if (EOF == putc(' ', stream))
+ if (EOF == putc (' ', stream))
{
output_good = false;
failed_at = 850;
@@ -349,8 +351,7 @@ list_file (const char *name,
char const *fmt =
((current_time - 6 * 30 * 24 * 60 * 60 <= statp->st_mtime
&& statp->st_mtime <= current_time + 60 * 60)
- ? "%b %e %H:%M"
- : "%b %e %Y");
+ ? "%b %e %H:%M" : "%b %e %Y");
while (!strftime (buf, bufsize, fmt, when_local))
buf = alloca (bufsize *= 2);
@@ -369,7 +370,7 @@ list_file (const char *name,
if (statp->st_mtime < 0)
{
- char const *num = human_readable (- (uintmax_t) statp->st_mtime,
+ char const *num = human_readable (-(uintmax_t) statp->st_mtime,
hbuf, human_ceiling, 1, 1);
int sign_width = width - strlen (num);
if (fprintf (stream, "%*s%s ",
@@ -383,8 +384,7 @@ list_file (const char *name,
{
if (fprintf (stream, "%*s ", width,
human_readable ((uintmax_t) statp->st_mtime, hbuf,
- human_ceiling,
- 1, 1)) < 0)
+ human_ceiling, 1, 1)) < 0)
{
output_good = false;
failed_at = 1100;
@@ -416,7 +416,8 @@ list_file (const char *name,
}
if (output_good)
{
- output_good = print_name (linkname, stream, literal_control_chars);
+ output_good =
+ print_name (linkname, stream, literal_control_chars);
if (!output_good)
{
failed_at = 1350;
@@ -449,7 +450,8 @@ list_file (const char *name,
}
if (!output_good)
{
- error (EXIT_FAILURE, errno, _("Failed to write output (at stage %d)"), failed_at);
+ error (EXIT_FAILURE, errno, _("Failed to write output (at stage %d)"),
+ failed_at);
}
}
@@ -508,7 +510,7 @@ print_name_with_quoting (register const char *p, FILE *stream)
{
if (EOF == putc (c, stream))
return false;
- fprintf_result = 1; /* otherwise it's used uninitialized. */
+ fprintf_result = 1; /* otherwise it's used uninitialized. */
}
else
{
@@ -521,7 +523,8 @@ print_name_with_quoting (register const char *p, FILE *stream)
return true;
}
-static bool print_name (register const char *p, FILE *stream, int literal_control_chars)
+static bool
+print_name (register const char *p, FILE *stream, int literal_control_chars)
{
if (literal_control_chars)
return print_name_without_quoting (p, stream);
diff --git a/lib/listfile.h b/lib/listfile.h
index 5e6aa94a..a04fab64 100644
--- a/lib/listfile.h
+++ b/lib/listfile.h
@@ -18,5 +18,8 @@
#if !defined LISTFILE_H
# define LISTFILE_H
-void list_file (const char *name, int dir_fd, const char *relname, const struct stat *statp, time_t current_time, int output_block_size, int literal_control_chars, FILE *stream);
+void list_file (const char *name, int dir_fd, const char *relname,
+ const struct stat *statp, time_t current_time,
+ int output_block_size, int literal_control_chars,
+ FILE * stream);
#endif
diff --git a/lib/printquoted.c b/lib/printquoted.c
index 2251b30a..30278b52 100644
--- a/lib/printquoted.c
+++ b/lib/printquoted.c
@@ -36,9 +36,7 @@
int
print_quoted (FILE *fp,
const struct quoting_options *qopts,
- bool dest_is_tty,
- const char *format,
- const char *s)
+ bool dest_is_tty, const char *format, const char *s)
{
int rv;
diff --git a/lib/printquoted.h b/lib/printquoted.h
index 315bba56..f5af308d 100644
--- a/lib/printquoted.h
+++ b/lib/printquoted.h
@@ -26,8 +26,9 @@
# include "quotearg.h"
-size_t qmark_chars(char *buf, size_t len);
-int print_quoted (FILE *fp, const struct quoting_options *qopts, bool dest_is_tty, const char *format, const char *s);
+size_t qmark_chars (char *buf, size_t len);
+int print_quoted (FILE * fp, const struct quoting_options *qopts,
+ bool dest_is_tty, const char *format, const char *s);
#endif
diff --git a/lib/qmark.c b/lib/qmark.c
index 84038943..55a1e377 100644
--- a/lib/qmark.c
+++ b/lib/qmark.c
@@ -78,7 +78,8 @@
* This code taken from coreutils' system.h header at
* Sun Jun 5 21:05:21 2005 UTC.
*/
-static inline unsigned char to_uchar (char ch)
+static inline unsigned char
+to_uchar (char ch)
{
return ch;
}
@@ -92,7 +93,7 @@ unibyte_qmark_chars (char *buf, size_t len)
while (p < plimit)
{
- if (! ISPRINT (to_uchar (*p)))
+ if (!ISPRINT (to_uchar (*p)))
*p = '?';
p++;
}
@@ -126,26 +127,98 @@ qmark_chars (char *buf, size_t len)
while (p < plimit)
switch (*p)
{
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
+ case ' ':
+ case '!':
+ case '"':
+ case '#':
+ case '%':
+ case '&':
+ case '\'':
+ case '(':
+ case ')':
+ case '*':
+ case '+':
+ case ',':
+ case '-':
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ':':
+ case ';':
+ case '<':
+ case '=':
+ case '>':
case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_':
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z':
+ case '{':
+ case '|':
+ case '}':
+ case '~':
/* These characters are printable ASCII characters. */
*q++ = *p++;
break;
@@ -205,7 +278,7 @@ qmark_chars (char *buf, size_t len)
*q++ = '?';
}
}
- while (! mbsinit (&mbstate));
+ while (!mbsinit (&mbstate));
}
break;
}
diff --git a/lib/regexprops.c b/lib/regexprops.c
index c44d578f..6813d945 100644
--- a/lib/regexprops.c
+++ b/lib/regexprops.c
@@ -98,9 +98,7 @@ enum_item (const char *s)
static void
begin_subsection (const char *name,
- const char *next,
- const char *prev,
- const char *up)
+ const char *next, const char *prev, const char *up)
{
(void) next;
(void) prev;
@@ -166,13 +164,13 @@ describe_regex_syntax (int options)
{
newpara ();
content ("The character @samp{.} matches any single character");
- if ( (options & RE_DOT_NEWLINE) == 0 )
+ if ((options & RE_DOT_NEWLINE) == 0)
{
content (" except newline");
}
if (options & RE_DOT_NOT_NULL)
{
- if ( (options & RE_DOT_NEWLINE) == 0 )
+ if ((options & RE_DOT_NEWLINE) == 0)
content (" and");
else
content (" except");
@@ -215,14 +213,15 @@ describe_regex_syntax (int options)
newpara ();
content ("Bracket expressions are used to match ranges of characters. ");
- literal ("Bracket expressions where the range is backward, for example @samp{[z-a]}, are ");
+ literal
+ ("Bracket expressions where the range is backward, for example @samp{[z-a]}, are ");
if (options & RE_NO_EMPTY_RANGES)
content ("invalid");
else
content ("ignored");
content (". ");
- if (options & RE_BACKSLASH_ESCAPE_IN_LISTS)
+ if (options & RE_BACKSLASH_ESCAPE_IN_LISTS)
literal ("Within square brackets, @samp{\\} can be used to quote "
"the following character. ");
else
@@ -238,7 +237,8 @@ describe_regex_syntax (int options)
if (options & RE_HAT_LISTS_NOT_NEWLINE)
{
- literal ("Non-matching lists @samp{[^@dots{}]} do not ever match newline.\n");
+ literal
+ ("Non-matching lists @samp{[^@dots{}]} do not ever match newline.\n");
}
newpara ();
if (options & RE_NO_GNU_OPS)
@@ -257,7 +257,8 @@ describe_regex_syntax (int options)
enum_item ("@samp{\\<} matches the beginning of a word");
enum_item ("@samp{\\>} matches the end of a word");
enum_item ("@samp{\\b} matches a word boundary");
- enum_item ("@samp{\\B} matches characters which are not a word boundary");
+ enum_item
+ ("@samp{\\B} matches characters which are not a word boundary");
enum_item ("@samp{\\`} matches the beginning of the whole input");
enum_item ("@samp{\\'} matches the end of the whole input");
endenum ();
@@ -275,7 +276,8 @@ describe_regex_syntax (int options)
}
else
{
- literal ("Grouping is performed with backslashes followed by parentheses @samp{\\(}, @samp{\\)}. ");
+ literal
+ ("Grouping is performed with backslashes followed by parentheses @samp{\\(}, @samp{\\)}. ");
}
if (options & RE_NO_BK_REFS)
@@ -284,7 +286,8 @@ describe_regex_syntax (int options)
}
else
{
- literal ("A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number. For example @samp{\\2} matches the second group expression. The order of group expressions is determined by the position of their opening parenthesis ");
+ literal
+ ("A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number. For example @samp{\\2} matches the second group expression. The order of group expressions is determined by the position of their opening parenthesis ");
if (options & RE_NO_BK_PARENS)
literal ("@samp{(}");
else
@@ -305,11 +308,13 @@ describe_regex_syntax (int options)
if (options & RE_CONTEXT_INDEP_ANCHORS)
{
- literal ("The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified.\n");
+ literal
+ ("The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified.\n");
}
else
{
- literal ("The character @samp{^} only represents the beginning of a string when it appears:");
+ literal
+ ("The character @samp{^} only represents the beginning of a string when it appears:");
beginenum ();
enum_item ("At the beginning of a regular expression");
if (options & RE_NO_BK_PARENS)
@@ -326,7 +331,7 @@ describe_regex_syntax (int options)
if (options & RE_NEWLINE_ALT)
enum_item ("After a newline");
- if (options & RE_NO_BK_VBAR )
+ if (options & RE_NO_BK_VBAR)
enum_item ("After the alternation operator @samp{|}");
else
enum_item ("After the alternation operator @samp{\\|}");
@@ -334,7 +339,8 @@ describe_regex_syntax (int options)
endenum ();
newpara ();
- literal ("The character @samp{$} only represents the end of a string when it appears:");
+ literal
+ ("The character @samp{$} only represents the end of a string when it appears:");
beginenum ();
enum_item ("At the end of a regular expression");
if (options & RE_NO_BK_PARENS)
@@ -358,12 +364,13 @@ describe_regex_syntax (int options)
endenum ();
}
newpara ();
- if (!(options & RE_LIMITED_OPS) )
+ if (!(options & RE_LIMITED_OPS))
{
if ((options & RE_CONTEXT_INDEP_OPS)
&& !(options & RE_CONTEXT_INVALID_OPS))
{
- literal ("The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression.\n");
+ literal
+ ("The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression.\n");
}
else
{
@@ -374,11 +381,13 @@ describe_regex_syntax (int options)
if (options & RE_CONTEXT_INVALID_OPS)
{
- content ("are special at any point in a regular expression except the following places, where they are not allowed:");
+ content
+ ("are special at any point in a regular expression except the following places, where they are not allowed:");
}
else
{
- content ("are special at any point in a regular expression except:");
+ content
+ ("are special at any point in a regular expression except:");
}
beginenum ();
@@ -414,23 +423,28 @@ describe_regex_syntax (int options)
literal ("Intervals are specified by @samp{@{} and @samp{@}}.\n");
if (options & RE_INVALID_INTERVAL_ORD)
{
- literal ("Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\\@{1}");
+ literal
+ ("Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\\@{1}");
}
else
{
- literal ("Invalid intervals such as @samp{a@{1z} are not accepted.\n");
+ literal
+ ("Invalid intervals such as @samp{a@{1z} are not accepted.\n");
}
}
else
{
- literal ("Intervals are specified by @samp{\\@{} and @samp{\\@}}.\n");
+ literal
+ ("Intervals are specified by @samp{\\@{} and @samp{\\@}}.\n");
if (options & RE_INVALID_INTERVAL_ORD)
{
- literal ("Invalid intervals are treated as literals, for example @samp{a\\@{1} is treated as @samp{a@{1}");
+ literal
+ ("Invalid intervals are treated as literals, for example @samp{a\\@{1} is treated as @samp{a@{1}");
}
else
{
- literal ("Invalid intervals such as @samp{a\\@{1z} are not accepted.\n");
+ literal
+ ("Invalid intervals such as @samp{a\\@{1z} are not accepted.\n");
}
}
}
@@ -438,11 +452,13 @@ describe_regex_syntax (int options)
newpara ();
if (options & RE_NO_POSIX_BACKTRACKING)
{
- content ("Matching succeeds as soon as the whole pattern is matched, meaning that the result may not be the longest possible match.");
+ content
+ ("Matching succeeds as soon as the whole pattern is matched, meaning that the result may not be the longest possible match.");
}
else
{
- content ("The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.");
+ content
+ ("The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.");
}
newpara ();
}
@@ -451,20 +467,16 @@ describe_regex_syntax (int options)
static void
copying (void)
{
- static const char *copy_para[]=
- {
- /* The copyright year number range is with "--" in Texinfo files. */
- "Copyright (C) 1994--2026 Free Software Foundation, Inc."
- ,""
- ,"Permission is granted to copy, distribute and/or modify this document"
- ,"under the terms of the GNU Free Documentation License, Version 1.3 or"
- ,"any later version published by the Free Software Foundation; with no"
- ,"Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts."
- ,"A copy of the license is included in the ``GNU Free"
- ,"Documentation License'' file as part of this distribution."
- ""
- ,NULL
- };
+ static const char *copy_para[] = {
+ /* The copyright year number range is with "--" in Texinfo files. */
+ "Copyright (C) 1994--2026 Free Software Foundation, Inc.", "",
+ "Permission is granted to copy, distribute and/or modify this document",
+ "under the terms of the GNU Free Documentation License, Version 1.3 or",
+ "any later version published by the Free Software Foundation; with no",
+ "Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.",
+ "A copy of the license is included in the ``GNU Free",
+ "Documentation License'' file as part of this distribution." "", NULL
+ };
const char **s = copy_para;
while (*s)
comment (*s++);
@@ -483,10 +495,7 @@ menu (unsigned int context)
const char *name;
output ("@menu\n", 0);
- for (i=0;
- get_regex_type_flags (i),
- name=get_regex_type_name (i);
- ++i)
+ for (i = 0; get_regex_type_flags (i), name = get_regex_type_name (i); ++i)
{
if (!ignore (i, context))
{
@@ -523,9 +532,7 @@ get_next (unsigned int ix, unsigned int context)
static void
-describe_all (const char *contextname,
- unsigned int context,
- const char *up)
+describe_all (const char *contextname, unsigned int context, const char *up)
{
const char *name, *next, *previous;
int regopts;
@@ -541,10 +548,9 @@ describe_all (const char *contextname,
previous = "";
- for (i=0;
+ for (i = 0;
regopts = get_regex_type_flags (i),
- name=get_regex_type_name (i);
- ++i)
+ name = get_regex_type_name (i); ++i)
{
if (ignore (i, context))
{
@@ -555,7 +561,7 @@ describe_all (const char *contextname,
continue;
}
- next = get_next (i+1, context);
+ next = get_next (i + 1, context);
if (NULL == next)
next = "";
begin_subsection (name, next, previous, up);
@@ -603,8 +609,7 @@ main (int argc, char *argv[])
context = CONTEXT_ALL;
else
{
- fprintf (stderr, "Unexpected context %s",
- contextname);
+ fprintf (stderr, "Unexpected context %s", contextname);
return 1;
}
}
diff --git a/lib/regextype.c b/lib/regextype.c
index bd5d7f53..a6d9080c 100644
--- a/lib/regextype.c
+++ b/lib/regextype.c
@@ -40,28 +40,29 @@
struct tagRegexTypeMap
{
const char *name;
- int context;
- int option_val;
+ int context;
+ int option_val;
};
-static struct tagRegexTypeMap regex_map[] =
- {
- { "findutils-default", CONTEXT_FINDUTILS, RE_SYNTAX_EMACS|RE_DOT_NEWLINE },
- { "awk", CONTEXT_ALL, RE_SYNTAX_AWK },
- { "ed", CONTEXT_GENERIC, RE_SYNTAX_ED },
- { "egrep", CONTEXT_ALL, RE_SYNTAX_EGREP },
- { "emacs", CONTEXT_ALL, RE_SYNTAX_EMACS },
- { "gnu-awk", CONTEXT_ALL, RE_SYNTAX_GNU_AWK },
- { "grep", CONTEXT_ALL, RE_SYNTAX_GREP },
- { "posix-awk", CONTEXT_ALL, RE_SYNTAX_POSIX_AWK },
- { "posix-basic", CONTEXT_ALL, RE_SYNTAX_POSIX_BASIC },
- { "posix-egrep", CONTEXT_ALL, RE_SYNTAX_POSIX_EGREP },
- { "posix-extended", CONTEXT_ALL, RE_SYNTAX_POSIX_EXTENDED },
- { "posix-minimal-basic", CONTEXT_GENERIC, RE_SYNTAX_POSIX_MINIMAL_BASIC },
- { "sed", CONTEXT_GENERIC, RE_SYNTAX_SED },
- /* ,{ "posix-common", CONTEXT_GENERIC, _RE_SYNTAX_POSIX_COMMON } */
- };
-enum { N_REGEX_MAP_ENTRIES = sizeof (regex_map)/sizeof (regex_map[0]) };
+static struct tagRegexTypeMap regex_map[] = {
+ {"findutils-default", CONTEXT_FINDUTILS, RE_SYNTAX_EMACS | RE_DOT_NEWLINE},
+ {"awk", CONTEXT_ALL, RE_SYNTAX_AWK},
+ {"ed", CONTEXT_GENERIC, RE_SYNTAX_ED},
+ {"egrep", CONTEXT_ALL, RE_SYNTAX_EGREP},
+ {"emacs", CONTEXT_ALL, RE_SYNTAX_EMACS},
+ {"gnu-awk", CONTEXT_ALL, RE_SYNTAX_GNU_AWK},
+ {"grep", CONTEXT_ALL, RE_SYNTAX_GREP},
+ {"posix-awk", CONTEXT_ALL, RE_SYNTAX_POSIX_AWK},
+ {"posix-basic", CONTEXT_ALL, RE_SYNTAX_POSIX_BASIC},
+ {"posix-egrep", CONTEXT_ALL, RE_SYNTAX_POSIX_EGREP},
+ {"posix-extended", CONTEXT_ALL, RE_SYNTAX_POSIX_EXTENDED},
+ {"posix-minimal-basic", CONTEXT_GENERIC, RE_SYNTAX_POSIX_MINIMAL_BASIC},
+ {"sed", CONTEXT_GENERIC, RE_SYNTAX_SED},
+ /* ,{ "posix-common", CONTEXT_GENERIC, _RE_SYNTAX_POSIX_COMMON } */
+};
+
+enum
+{ N_REGEX_MAP_ENTRIES = sizeof (regex_map) / sizeof (regex_map[0]) };
int
get_regex_type (const char *s)
@@ -71,7 +72,7 @@ get_regex_type (const char *s)
char *buf, *p;
msglen = 0u;
- for (i=0u; i<N_REGEX_MAP_ENTRIES; ++i)
+ for (i = 0u; i < N_REGEX_MAP_ENTRIES; ++i)
{
if (0 == strcmp (regex_map[i].name, s))
return regex_map[i].option_val;
@@ -83,7 +84,7 @@ get_regex_type (const char *s)
* user indicated they wanted. Tell them what the options are.
*/
p = buf = xmalloc (1u + msglen);
- for (i=0u; i<N_REGEX_MAP_ENTRIES; ++i)
+ for (i = 0u; i < N_REGEX_MAP_ENTRIES; ++i)
{
if (i > 0u)
{
@@ -95,10 +96,8 @@ get_regex_type (const char *s)
error (EXIT_FAILURE, 0,
_("Unknown regular expression type %s; valid types are %s."),
- quote (s),
- buf);
- /*NOTREACHED*/
- return -1;
+ quote (s), buf);
+ /*NOTREACHED*/ return -1;
}
@@ -120,7 +119,8 @@ get_regex_type_flags (unsigned int ix)
return -1;
}
-unsigned int get_regex_type_context (unsigned int ix)
+unsigned int
+get_regex_type_context (unsigned int ix)
{
if (ix < N_REGEX_MAP_ENTRIES)
return regex_map[ix].context;
@@ -140,7 +140,7 @@ get_regex_type_synonym (unsigned int ix, unsigned int context)
/* Terminate the loop before we get to IX, so that we always
consistently choose the same entry as a synonym (rather than
stating that x and y are synonyms of each other). */
- for (i=0u; i<ix; ++i)
+ for (i = 0u; i < ix; ++i)
{
if ((regex_map[i].context & context) == 0)
{
diff --git a/lib/regextype.h b/lib/regextype.h
index 7f9299fa..a22f8fa7 100644
--- a/lib/regextype.h
+++ b/lib/regextype.h
@@ -24,12 +24,13 @@
* This could convert "grep" into RE_SYNTAX_GREP, for example.
* Return -1 if there is no match.
*/
-int get_regex_type(const char *s);
+int get_regex_type (const char *s);
-enum {
+enum
+{
CONTEXT_FINDUTILS = 1u,
- CONTEXT_GENERIC = 2u,
- CONTEXT_ALL = CONTEXT_GENERIC|CONTEXT_FINDUTILS,
+ CONTEXT_GENERIC = 2u,
+ CONTEXT_ALL = CONTEXT_GENERIC | CONTEXT_FINDUTILS,
};
@@ -37,25 +38,25 @@ enum {
/* Returns the regex type name corresponding to index IX.
* Indexes start at 0. Returns NULL if IX is too large.
*/
-const char * get_regex_type_name(unsigned int ix);
+const char *get_regex_type_name (unsigned int ix);
/* Returns the option mask name corresponding to regular expression
* type index IX. Indexes start at 0. Behaviour is undefined if IX
* has a value which would cause get_regex_type_name to return NULL.
*/
-int get_regex_type_flags(unsigned int ix);
+int get_regex_type_flags (unsigned int ix);
/* If regular expression type IX (which is a regular expression type
* index) has one or more synonyms which is interesting in context
* CONTEXT, return the index of one of them. Otherwise, return -1.
*/
-int get_regex_type_synonym(unsigned int ix, unsigned int context);
+int get_regex_type_synonym (unsigned int ix, unsigned int context);
/* Returns one of CONTEXT_FINDUTILS, CONTEXT_GENERIC or CONTEXT_ALL.
* This identifies whether this regular expression type index is relevant for,
* respectively, findutils, general callers, or all callers.
*/
-unsigned int get_regex_type_context(unsigned int ix);
+unsigned int get_regex_type_context (unsigned int ix);
#endif
diff --git a/lib/safe-atoi.c b/lib/safe-atoi.c
index 158a3b9c..13f06228 100644
--- a/lib/safe-atoi.c
+++ b/lib/safe-atoi.c
@@ -38,7 +38,7 @@ safe_atoi (const char *s, enum quoting_style style)
errno = 0;
lval = strtol (s, &end, 10);
- if ( (LONG_MAX == lval) || (LONG_MIN == lval) )
+ if ((LONG_MAX == lval) || (LONG_MIN == lval))
{
/* max/min possible value, or an error. */
if (errno == ERANGE)
@@ -76,5 +76,5 @@ safe_atoi (const char *s, enum quoting_style style)
error (EXIT_FAILURE, errno, _("Expected an integer: %s"),
quotearg_n_style (0, style, s));
}
- return (int)lval;
+ return (int) lval;
}
diff --git a/lib/splitstring.c b/lib/splitstring.c
index 02ccaa4e..f482e07d 100644
--- a/lib/splitstring.c
+++ b/lib/splitstring.c
@@ -44,8 +44,8 @@ field_length (const char *str, const char *separators)
bool
-splitstring(const char *s, const char *separators, bool first,
- size_t *pos, size_t *len)
+splitstring (const char *s, const char *separators, bool first,
+ size_t *pos, size_t *len)
{
if (first)
{
@@ -56,7 +56,7 @@ splitstring(const char *s, const char *separators, bool first,
{
*pos += *len; /* advance to the next field. */
if (s[*pos])
- ++*pos; /* skip the separator */
+ ++ * pos; /* skip the separator */
else
return false; /* we reached the end. */
}
diff --git a/lib/splitstring.h b/lib/splitstring.h
index a9214032..23e6dec8 100644
--- a/lib/splitstring.h
+++ b/lib/splitstring.h
@@ -38,7 +38,7 @@
# include <stdbool.h>
# include <stddef.h>
-bool splitstring(const char *s, const char *separators,
- bool first, size_t *pos, size_t *len);
+bool splitstring (const char *s, const char *separators,
+ bool first, size_t *pos, size_t *len);
#endif
diff --git a/lib/system.h b/lib/system.h
index 8467c2aa..ab9d56c2 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -26,9 +26,9 @@
# include "gettext.h"
# if ! ENABLE_NLS
# undef textdomain
-# define textdomain(Domainname) /* empty */
+# define textdomain(Domainname)/* empty */
# undef bindtextdomain
-# define bindtextdomain(Domainname, Dirname) /* empty */
+# define bindtextdomain(Domainname, Dirname) /* empty */
# endif
# define _(msgid) gettext (msgid)
diff --git a/lib/test_splitstring.c b/lib/test_splitstring.c
index e9d82d2b..9deaa60a 100644
--- a/lib/test_splitstring.c
+++ b/lib/test_splitstring.c
@@ -28,13 +28,15 @@
#include "splitstring.h"
static void
-assertEqualFunc(const char *file, int line, const char *label,
- size_t expected, size_t got)
+assertEqualFunc (const char *file, int line, const char *label,
+ size_t expected, size_t got)
{
if (expected != got)
- fprintf(stderr, "%s line %d: %s: expected %lu, got %lu\n",
- file, line, label, (unsigned long)expected, (unsigned long)got);
+ fprintf (stderr, "%s line %d: %s: expected %lu, got %lu\n",
+ file, line, label, (unsigned long) expected,
+ (unsigned long) got);
}
+
#define ASSERT_EQUAL(expected,got) \
do{ \
assertEqualFunc(__FILE__,__LINE__,"ASSERT_EQUAL",expected,got); \
@@ -57,7 +59,8 @@ test_empty (void)
assert (!result);
}
-static void test_onefield (void)
+static void
+test_onefield (void)
{
size_t len, pos;
bool result;
@@ -71,7 +74,8 @@ static void test_onefield (void)
assert (!result);
}
-static void test_not_colon (void)
+static void
+test_not_colon (void)
{
size_t len, pos;
bool result;
@@ -92,7 +96,8 @@ static void test_not_colon (void)
assert (!result);
}
-static void test_empty_back (void)
+static void
+test_empty_back (void)
{
size_t len, pos;
bool result;
@@ -110,7 +115,8 @@ static void test_empty_back (void)
assert (!result);
}
-static void test_empty_front (void)
+static void
+test_empty_front (void)
{
size_t len, pos;
bool result;
@@ -128,7 +134,8 @@ static void test_empty_front (void)
assert (!result);
}
-static void test_twofields (void)
+static void
+test_twofields (void)
{
size_t len, pos;
bool result;
@@ -146,7 +153,8 @@ static void test_twofields (void)
assert (!result);
}
-static void test_twoseparators (void)
+static void
+test_twoseparators (void)
{
size_t len, pos;
bool result;
@@ -158,7 +166,7 @@ static void test_twoseparators (void)
ASSERT_EQUAL (1, len);
result = splitstring (input, ":!", false, &pos, &len);
assert (result);
- ASSERT_EQUAL (2, pos);
+ ASSERT_EQUAL (2, pos);
ASSERT_EQUAL (2, len);
result = splitstring (input, ":!", false, &pos, &len);
assert (result);
@@ -168,7 +176,8 @@ static void test_twoseparators (void)
assert (!result);
}
-static void test_consecutive_empty (void)
+static void
+test_consecutive_empty (void)
{
size_t len, pos;
bool result;
@@ -194,10 +203,11 @@ static void test_consecutive_empty (void)
assert (!result);
}
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- (void) argc; /* pacify -Werror=unused-parameter */
- (void) argv; /* pacify -Werror=unused-parameter */
+ (void) argc; /* pacify -Werror=unused-parameter */
+ (void) argv; /* pacify -Werror=unused-parameter */
test_empty ();
test_onefield ();
diff --git a/lib/unused-result.h b/lib/unused-result.h
index eff1ad5d..ad86b9bb 100644
--- a/lib/unused-result.h
+++ b/lib/unused-result.h
@@ -33,7 +33,7 @@
# define __attribute_warn_unused_result__ \
__attribute__ ((__warn_unused_result__))
# else
-# define __attribute_warn_unused_result__ /* empty */
+# define __attribute_warn_unused_result__ /* empty */
# endif
#endif
diff --git a/locate/frcode.c b/locate/frcode.c
index f7800e49..97fd0bfe 100644
--- a/locate/frcode.c
+++ b/locate/frcode.c
@@ -122,8 +122,7 @@ prefix_length (char *s1, char *s2)
return s1 - start;
}
-static struct option const longopts[] =
-{
+static struct option const longopts[] = {
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"null", no_argument, NULL, '0'},
@@ -135,13 +134,13 @@ usage (int status)
{
if (status != EXIT_SUCCESS)
{
- fprintf (stderr, _("Try '%s --help' for more information.\n"), program_name);
+ fprintf (stderr, _("Try '%s --help' for more information.\n"),
+ program_name);
exit (status);
}
fprintf (stdout,
- _("Usage: %s [-0 | --null] [--version] [--help]\n"),
- program_name);
+ _("Usage: %s [-0 | --null] [--version] [--help]\n"), program_name);
explain_how_to_report_bugs (stdout, program_name);
exit (status);
@@ -159,28 +158,25 @@ get_seclevel (char *s)
errno = 0;
result = strtol (s, &p, 10);
- if ((0==result) && (p == optarg))
+ if ((0 == result) && (p == optarg))
{
error (EXIT_FAILURE, 0,
_("You need to specify a security level as a decimal integer."));
- /*NOTREACHED*/
- return -1;
+ /*NOTREACHED*/ return -1;
}
- else if ((LONG_MIN==result || LONG_MAX==result) && errno)
+ else if ((LONG_MIN == result || LONG_MAX == result) && errno)
{
error (EXIT_FAILURE, 0,
_("Security level %s is outside the convertible range."), s);
- /*NOTREACHED*/
- return -1;
+ /*NOTREACHED*/ return -1;
}
else if (*p)
{
/* Some suffix exists */
error (EXIT_FAILURE, 0,
_("Security level %s has unexpected suffix %s."), s, p);
- /*NOTREACHED*/
- return -1;
+ /*NOTREACHED*/ return -1;
}
else
{
@@ -201,7 +197,7 @@ main (int argc, char **argv)
char *path; /* The current input entry. */
char *oldpath; /* The previous input entry. */
size_t pathsize, oldpathsize; /* Amounts allocated for them. */
- int count, oldcount, diffcount; /* Their prefix lengths & the difference. */
+ int count, oldcount, diffcount; /* Their prefix lengths & the difference. */
int line_len; /* Length of input line. */
int delimiter = '\n';
int optc;
@@ -218,7 +214,7 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, _("The atexit library function failed"));
}
- pathsize = oldpathsize = 1026; /* Increased as necessary by getline. */
+ pathsize = oldpathsize = 1026; /* Increased as necessary by getline. */
path = xmalloc (pathsize);
oldpath = xmalloc (oldpathsize);
@@ -226,7 +222,8 @@ main (int argc, char **argv)
oldcount = 0;
- while ((optc = getopt_long (argc, argv, "hv0S:", longopts, (int *) 0)) != -1)
+ while ((optc =
+ getopt_long (argc, argv, "hv0S:", longopts, (int *) 0)) != -1)
switch (optc)
{
case '0':
@@ -275,7 +272,8 @@ main (int argc, char **argv)
if (fwrite (LOCATEDB_MAGIC, 1, sizeof (LOCATEDB_MAGIC), stdout)
!= sizeof (LOCATEDB_MAGIC))
{
- error (EXIT_FAILURE, errno, _("Failed to write to standard output"));
+ error (EXIT_FAILURE, errno,
+ _("Failed to write to standard output"));
}
}
@@ -288,12 +286,12 @@ main (int argc, char **argv)
}
else
{
- path[line_len - 1] = '\0'; /* FIXME temporary: nuke the delimiter. */
+ path[line_len - 1] = '\0'; /* FIXME temporary: nuke the delimiter. */
}
count = prefix_length (oldpath, path);
diffcount = count - oldcount;
- if ( (diffcount > SHRT_MAX) || (diffcount < SHRT_MIN) )
+ if ((diffcount > SHRT_MAX) || (diffcount < SHRT_MIN))
{
/* We do this to prevent overflow of the value we
* write with put_short ()
@@ -327,8 +325,8 @@ main (int argc, char **argv)
}
}
- if ( (EOF == fputs (path + count, stdout))
- || (EOF == putc ('\0', stdout)))
+ if ((EOF == fputs (path + count, stdout))
+ || (EOF == putc ('\0', stdout)))
{
outerr ();
}
diff --git a/locate/locate.c b/locate/locate.c
index 0992f1fb..607899a4 100644
--- a/locate/locate.c
+++ b/locate/locate.c
@@ -111,19 +111,19 @@ static const char warn_name_units[] = N_("days");
#define SECONDS_PER_UNIT (60 * 60 * 24)
enum visit_result
- {
- VISIT_CONTINUE = 1, /* please call the next visitor */
- VISIT_ACCEPTED = 2, /* accepted, call no further callbacks for this file */
- VISIT_REJECTED = 4, /* rejected, process next file. */
- VISIT_ABORT = 8 /* rejected, process no more files. */
- };
+{
+ VISIT_CONTINUE = 1, /* please call the next visitor */
+ VISIT_ACCEPTED = 2, /* accepted, call no further callbacks for this file */
+ VISIT_REJECTED = 4, /* rejected, process next file. */
+ VISIT_ABORT = 8 /* rejected, process no more files. */
+};
enum ExistenceCheckType
- {
- ACCEPT_EITHER, /* Corresponds to lack of -E/-e option */
- ACCEPT_EXISTING, /* Corresponds to option -e */
- ACCEPT_NON_EXISTING /* Corresponds to option -E */
- };
+{
+ ACCEPT_EITHER, /* Corresponds to lack of -E/-e option */
+ ACCEPT_EXISTING, /* Corresponds to option -e */
+ ACCEPT_NON_EXISTING /* Corresponds to option -E */
+};
/* Check for existence of files before printing them out? */
static enum ExistenceCheckType check_existence = ACCEPT_EITHER;
@@ -133,7 +133,7 @@ static int follow_symlinks = 1;
/* What to separate the results with. */
static int separator = '\n';
-static struct quoting_options * quote_opts = NULL;
+static struct quoting_options *quote_opts = NULL;
static bool stdout_is_a_tty;
static bool print_quoted_filename;
static bool results_were_filtered;
@@ -155,7 +155,8 @@ set_max_db_age (const char *s)
if (0 == *s)
{
error (EXIT_FAILURE, 0,
- _("The argument for option --max-database-age must not be empty"));
+ _
+ ("The argument for option --max-database-age must not be empty"));
}
@@ -167,8 +168,7 @@ set_max_db_age (const char *s)
val = strtoul (s, &end, 10);
/* Diagnose number too large, non-numbes and trailing junk. */
- if ((ULONG_MAX == val && ERANGE == errno) ||
- (0 == val && EINVAL == errno))
+ if ((ULONG_MAX == val && ERANGE == errno) || (0 == val && EINVAL == errno))
{
error (EXIT_FAILURE, errno,
_("Invalid argument %s for option --max-database-age"),
@@ -202,7 +202,7 @@ get_short (FILE *fp)
return x;
}
-static const char * const metacharacters = "*?[]\\";
+static const char *const metacharacters = "*?[]\\";
/* Return nonzero if S contains any shell glob characters.
*/
@@ -232,7 +232,7 @@ contains_metacharacter (const char *s)
static int
locate_read_str (char **buf, size_t *siz, FILE *fp, int delimiter, int offs)
{
- char * p = NULL;
+ char *p = NULL;
size_t sz = 0;
int nread;
size_t needed;
@@ -256,8 +256,8 @@ locate_read_str (char **buf, size_t *siz, FILE *fp, int delimiter, int offs)
*buf = pnew;
}
}
- memcpy((*buf)+offs, p, nread + 1);
- free(p);
+ memcpy ((*buf) + offs, p, nread + 1);
+ free (p);
}
return nread;
}
@@ -285,14 +285,14 @@ static struct locate_stats statistics;
struct regular_expression
{
- struct re_pattern_buffer regex; /* for --regex */
+ struct re_pattern_buffer regex; /* for --regex */
};
struct process_data
{
int c; /* An input byte. */
- int count; /* The length of the prefix shared with the previous database entry. */
+ int count; /* The length of the prefix shared with the previous database entry. */
int len;
char *original_filename; /* The current input database entry. */
size_t pathsize; /* Amount allocated for it. */
@@ -307,13 +307,12 @@ struct process_data
};
-typedef int (*visitfunc)(struct process_data *procdata,
- void *context);
+typedef int (*visitfunc) (struct process_data * procdata, void *context);
struct visitor
{
- visitfunc inspector;
- void * context;
+ visitfunc inspector;
+ void *context;
struct visitor *next;
};
@@ -322,15 +321,15 @@ static struct visitor *inspectors = NULL;
static struct visitor *lastinspector = NULL;
static struct visitor *past_pat_inspector = NULL;
-static inline int visit (const struct visitor *p,
- int accept_flags,
- struct process_data *procdata,
- const struct visitor * const stop)
+static inline int
+visit (const struct visitor *p,
+ int accept_flags,
+ struct process_data *procdata, const struct visitor *const stop)
{
register int result = accept_flags;
- while ( (accept_flags & result) && (stop != p) )
+ while ((accept_flags & result) && (stop != p))
{
- result = (p->inspector)(procdata, p->context);
+ result = (p->inspector) (procdata, p->context);
p = p->next;
}
return result;
@@ -340,7 +339,8 @@ static inline int visit (const struct visitor *p,
static int
process_simple (struct process_data *procdata)
{
- return visit (inspectors, (VISIT_CONTINUE|VISIT_ACCEPTED), procdata, NULL);
+ return visit (inspectors, (VISIT_CONTINUE | VISIT_ACCEPTED), procdata,
+ NULL);
}
/* Accept if any pattern matches. */
@@ -349,7 +349,9 @@ process_or (struct process_data *procdata)
{
int result;
- result = visit (inspectors, (VISIT_CONTINUE|VISIT_REJECTED), procdata, past_pat_inspector);
+ result =
+ visit (inspectors, (VISIT_CONTINUE | VISIT_REJECTED), procdata,
+ past_pat_inspector);
if (result == VISIT_CONTINUE)
result = VISIT_REJECTED;
if (result & (VISIT_ABORT | VISIT_REJECTED))
@@ -368,7 +370,9 @@ process_and (struct process_data *procdata)
{
int result;
- result = visit (inspectors, (VISIT_CONTINUE|VISIT_ACCEPTED), procdata, past_pat_inspector);
+ result =
+ visit (inspectors, (VISIT_CONTINUE | VISIT_ACCEPTED), procdata,
+ past_pat_inspector);
if (result == VISIT_CONTINUE)
result = VISIT_REJECTED;
if (result & (VISIT_ABORT | VISIT_REJECTED))
@@ -381,7 +385,7 @@ process_and (struct process_data *procdata)
return result;
}
-typedef int (*processfunc)(struct process_data *procdata);
+typedef int (*processfunc) (struct process_data * procdata);
static processfunc mainprocessor = NULL;
@@ -390,7 +394,7 @@ add_visitor (visitfunc fn, void *context)
{
struct visitor *p = xmalloc (sizeof (struct visitor));
p->inspector = fn;
- p->context = context;
+ p->context = context;
p->next = NULL;
if (NULL == lastinspector)
@@ -409,8 +413,7 @@ visit_justprint_quoted (struct process_data *procdata, void *context)
{
(void) context;
print_quoted (stdout, quote_opts, stdout_is_a_tty,
- "%s",
- procdata->original_filename);
+ "%s", procdata->original_filename);
putchar (separator);
return VISIT_CONTINUE;
}
@@ -429,8 +432,7 @@ toolong (struct process_data *procdata)
{
error (EXIT_FAILURE, 0,
_("locate database %s contains a "
- "filename longer than locate can handle"),
- procdata->dbfile);
+ "filename longer than locate can handle"), procdata->dbfile);
}
static void
@@ -441,12 +443,11 @@ extend (struct process_data *procdata, size_t siz1, size_t siz2)
{
toolong (procdata);
}
- else if (procdata->pathsize < (siz1+siz2))
+ else if (procdata->pathsize < (siz1 + siz2))
{
- procdata->pathsize = siz1+siz2;
+ procdata->pathsize = siz1 + siz2;
procdata->original_filename = x2nrealloc (procdata->original_filename,
- &procdata->pathsize,
- 1);
+ &procdata->pathsize, 1);
}
}
@@ -466,7 +467,7 @@ visit_old_format (struct process_data *procdata, void *context)
int word;
procdata->count -= LOCATEDB_OLD_OFFSET;
- minval = (0 - procdata->count);
+ minval = (0 - procdata->count);
if (procdata->count >= 0)
maxval = (procdata->len - procdata->count);
else
@@ -486,7 +487,7 @@ visit_old_format (struct process_data *procdata, void *context)
/* Overlay the old path with the remainder of the new. Read
* more data until we get to the next filename.
*/
- for (i=procdata->count;
+ for (i = procdata->count;
(procdata->c = getc (procdata->fp)) > LOCATEDB_OLD_ESCAPE;)
{
if (EOF == procdata->c)
@@ -527,7 +528,7 @@ visit_locate02_format (struct process_data *procdata, void *context)
(void) context;
if (procdata->c == LOCATEDB_ESCAPE)
- procdata->count += (short)get_short (procdata->fp);
+ procdata->count += (short) get_short (procdata->fp);
else if (procdata->c > 127)
procdata->count += procdata->c - 256;
else
@@ -550,7 +551,7 @@ visit_locate02_format (struct process_data *procdata, void *context)
if (nread < 1)
return VISIT_ABORT;
procdata->c = getc (procdata->fp);
- procdata->len = procdata->count + nread - 1; /* Number of chars in path. */
+ procdata->len = procdata->count + nread - 1; /* Number of chars in path. */
if (procdata->len < 1)
{
@@ -558,14 +559,14 @@ visit_locate02_format (struct process_data *procdata, void *context)
* reading in data which is outside our control, we
* cannot prevent it.
*/
- error(1, 0, _("locate database %s is corrupt or invalid"),
- quotearg_n_style(0, locale_quoting_style, procdata->dbfile));
+ error (1, 0, _("locate database %s is corrupt or invalid"),
+ quotearg_n_style (0, locale_quoting_style, procdata->dbfile));
}
- s = procdata->original_filename + procdata->len - 1; /* Move to the last char in path. */
+ s = procdata->original_filename + procdata->len - 1; /* Move to the last char in path. */
assert (s[0] != '\0');
- assert (s[1] == '\0'); /* Our terminator. */
- assert (s[2] == '\0'); /* Added by locate_read_str. */
+ assert (s[1] == '\0'); /* Our terminator. */
+ assert (s[2] == '\0'); /* Added by locate_read_str. */
procdata->munged_filename = procdata->original_filename;
@@ -671,7 +672,8 @@ visit_non_existing_nofollow (struct process_data *procdata, void *context)
}
static int
-visit_substring_match_nocasefold_wide (struct process_data *procdata, void *context)
+visit_substring_match_nocasefold_wide (struct process_data *procdata,
+ void *context)
{
const char *pattern = context;
@@ -682,7 +684,8 @@ visit_substring_match_nocasefold_wide (struct process_data *procdata, void *cont
}
static int
-visit_substring_match_nocasefold_narrow (struct process_data *procdata, void *context)
+visit_substring_match_nocasefold_narrow (struct process_data *procdata,
+ void *context)
{
const char *pattern = context;
assert (MB_CUR_MAX == 1);
@@ -693,7 +696,8 @@ visit_substring_match_nocasefold_narrow (struct process_data *procdata, void *co
}
static int
-visit_substring_match_casefold_wide (struct process_data *procdata, void *context)
+visit_substring_match_casefold_wide (struct process_data *procdata,
+ void *context)
{
const char *pattern = context;
@@ -705,7 +709,8 @@ visit_substring_match_casefold_wide (struct process_data *procdata, void *contex
static int
-visit_substring_match_casefold_narrow (struct process_data *procdata, void *context)
+visit_substring_match_casefold_narrow (struct process_data *procdata,
+ void *context)
{
const char *pattern = context;
@@ -771,15 +776,15 @@ visit_stats (struct process_data *procdata, void *context)
p->total_filename_length += len;
highbit = whitespace = newline = 0;
- for (s=procdata->original_filename; *s; ++s)
+ for (s = procdata->original_filename; *s; ++s)
{
- if ( (int)(*s) & 128 )
+ if ((int) (*s) & 128)
highbit = 1;
if ('\n' == *s)
{
newline = whitespace = 1;
}
- else if (isspace ((unsigned char)*s))
+ else if (isspace ((unsigned char) *s))
{
whitespace = 1;
}
@@ -823,7 +828,8 @@ visit_count (struct process_data *procdata, void *context)
/* Emit the statistics.
*/
static void
-print_stats (int argc, size_t database_file_size, const struct timespec* database_mtime)
+print_stats (int argc, size_t database_file_size,
+ const struct timespec *database_mtime)
{
char hbuf1[LONGEST_HUMAN_READABLE + 1];
char hbuf2[LONGEST_HUMAN_READABLE + 1];
@@ -835,51 +841,55 @@ print_stats (int argc, size_t database_file_size, const struct timespec* databas
const struct tm *ptm = localtime (&(database_mtime->tv_sec));
if (ptm)
{
- enum { TIME_BUF_LEN = 20 };
+ enum
+ { TIME_BUF_LEN = 20 };
char whenbuf[TIME_BUF_LEN];
size_t printed = strftime (whenbuf, TIME_BUF_LEN,
"%Y:%m:%d %H:%M:%S", ptm);
/* Ensure the buffer is exactly the right length. */
- assert (printed == TIME_BUF_LEN-1);
- assert (whenbuf[TIME_BUF_LEN-1] == 0);
- assert (whenbuf[TIME_BUF_LEN-2] != 0);
+ assert (printed == TIME_BUF_LEN - 1);
+ assert (whenbuf[TIME_BUF_LEN - 1] == 0);
+ assert (whenbuf[TIME_BUF_LEN - 2] != 0);
printf (_("Database was last modified at %s.%09ld"),
whenbuf, (long int) database_mtime->tv_nsec);
printed = strftime (whenbuf, TIME_BUF_LEN, "%z", ptm);
assert (printed == 5);
- printf(" %s\n", whenbuf);
+ printf (" %s\n", whenbuf);
}
}
printf (ngettext ("Locate database size: %s byte\n",
- "Locate database size: %s bytes\n",
- database_file_size),
- human_readable ((uintmax_t) database_file_size,
- hbuf1, human_ceiling, 1, 1));
- printf ( (results_were_filtered ?
+ "Locate database size: %s bytes\n",
+ database_file_size),
+ human_readable ((uintmax_t) database_file_size,
+ hbuf1, human_ceiling, 1, 1));
+ printf ((results_were_filtered ?
_("Matching Filenames: %s\n") :
_("All Filenames: %s\n")),
human_readable (statistics.total_filename_count,
- hbuf1, human_ceiling, 1, 1));
+ hbuf1, human_ceiling, 1, 1));
/* XXX: We would ideally use ngettext () here, but I don't know
* how to use it to handle more than one possibly-plural thing/
*/
printf (_("File names have a cumulative length of %s bytes.\n"
- "Of those file names,\n"
- "\n\t%s contain whitespace, "
- "\n\t%s contain newline characters, "
- "\n\tand %s contain characters with the high bit set.\n"),
- human_readable (statistics.total_filename_length, hbuf1, human_ceiling, 1, 1),
- human_readable (statistics.whitespace_count, hbuf2, human_ceiling, 1, 1),
- human_readable (statistics.newline_count, hbuf3, human_ceiling, 1, 1),
- human_readable (statistics.highbit_filename_count, hbuf4, human_ceiling, 1, 1));
+ "Of those file names,\n"
+ "\n\t%s contain whitespace, "
+ "\n\t%s contain newline characters, "
+ "\n\tand %s contain characters with the high bit set.\n"),
+ human_readable (statistics.total_filename_length, hbuf1,
+ human_ceiling, 1, 1),
+ human_readable (statistics.whitespace_count, hbuf2, human_ceiling,
+ 1, 1), human_readable (statistics.newline_count,
+ hbuf3, human_ceiling, 1, 1),
+ human_readable (statistics.highbit_filename_count, hbuf4,
+ human_ceiling, 1, 1));
if (!argc)
{
if (results_were_filtered)
{
printf (_("Some filenames may have been filtered out, "
- "so we cannot compute the compression ratio.\n"));
+ "so we cannot compute the compression ratio.\n"));
}
else
{
@@ -892,9 +902,9 @@ print_stats (int argc, size_t database_file_size, const struct timespec* databas
* filenames, because the bigram list is 256 bytes.
*/
printf (_("Compression ratio %4.2f%% (higher is better)\n"),
- 100.0 * ((double)statistics.total_filename_length
- - (double) database_file_size)
- / (double) statistics.total_filename_length);
+ 100.0 * ((double) statistics.total_filename_length
+ - (double) database_file_size)
+ / (double) statistics.total_filename_length);
}
else
{
@@ -926,9 +936,7 @@ looking_at_gnu_locatedb (const char *data, size_t len)
*/
static int
looking_at_slocate_locatedb (const char *filename,
- const char *data,
- size_t len,
- int *seclevel)
+ const char *data, size_t len, int *seclevel)
{
assert (len <= 2);
@@ -941,7 +949,7 @@ looking_at_slocate_locatedb (const char *filename,
/* Check that the magic number is a one-byte string */
if (0 == data[1])
{
- if (isdigit ((unsigned char)data[0]))
+ if (isdigit ((unsigned char) data[0]))
{
/* looks promising. */
*seclevel = (data[0] - '0');
@@ -1012,19 +1020,16 @@ search_one_database (int argc,
int basename_only,
int use_limit,
struct locate_limits *plimit,
- int stats,
- int op_and,
- int regex,
- int regex_options)
+ int stats, int op_and, int regex, int regex_options)
{
char *pathpart; /* A pattern to consider. */
int argn; /* Index to current pattern in argv. */
- int nread; /* number of bytes read from an entry. */
+ int nread; /* number of bytes read from an entry. */
struct process_data procdata; /* Storage for data shared with visitors. */
int slocate_seclevel;
int oldformat;
int slocatedb_format;
- struct visitor* pvis; /* temp for determining past_pat_inspector. */
+ struct visitor *pvis; /* temp for determining past_pat_inspector. */
const char *format_name;
enum ExistenceCheckType do_check_existence;
@@ -1062,8 +1067,7 @@ search_one_database (int argc,
slocate_seclevel = 0;
if (looking_at_slocate_locatedb (procdata.dbfile,
procdata.original_filename,
- nread,
- &slocate_seclevel))
+ nread, &slocate_seclevel))
{
/* slocate also uses frcode, but with a different header.
* We handle the header here and then work with the data
@@ -1075,7 +1079,8 @@ search_one_database (int argc,
* so do nothing further
*/
error (0, 0,
- _("%s is an slocate database of unsupported security level %d; skipping it."),
+ _
+ ("%s is an slocate database of unsupported security level %d; skipping it."),
quotearg_n_style (0, locale_quoting_style, procdata.dbfile),
slocate_seclevel);
return 0;
@@ -1105,7 +1110,8 @@ search_one_database (int argc,
error (0, 0,
_("%s is an slocate database. "
"Turning on the '-e' option."),
- quotearg_n_style (0, locale_quoting_style, procdata.dbfile));
+ quotearg_n_style (0, locale_quoting_style,
+ procdata.dbfile));
}
do_check_existence = ACCEPT_EXISTING;
}
@@ -1120,14 +1126,16 @@ search_one_database (int argc,
slocatedb_format = 0;
extend (&procdata, sizeof (LOCATEDB_MAGIC), 0u);
- nread2 = fread (procdata.original_filename+nread, 1, sizeof (LOCATEDB_MAGIC)-nread,
- procdata.fp);
- if (looking_at_gnu_locatedb (procdata.original_filename, nread+nread2))
+ nread2 =
+ fread (procdata.original_filename + nread, 1,
+ sizeof (LOCATEDB_MAGIC) - nread, procdata.fp);
+ if (looking_at_gnu_locatedb
+ (procdata.original_filename, nread + nread2))
{
add_visitor (visit_locate02_format, NULL);
format_name = "GNU LOCATE02";
}
- else /* Use the old format */
+ else /* Use the old format */
{
int i;
@@ -1138,7 +1146,7 @@ search_one_database (int argc,
{
int more_read = fread (procdata.original_filename + nread, 1,
256 - nread, procdata.fp);
- if ( (more_read + nread) != 256 )
+ if ((more_read + nread) != 256)
{
error (EXIT_FAILURE, 0,
_("Old-format locate database %s is "
@@ -1163,7 +1171,7 @@ search_one_database (int argc,
add_visitor (visit_basename, NULL);
/* Add an inspector for each pattern we're looking for. */
- for ( argn = 0; argn < argc; argn++ )
+ for (argn = 0; argn < argc; argn++)
{
results_were_filtered = true;
pathpart = argv[argn];
@@ -1217,13 +1225,13 @@ search_one_database (int argc,
* gnulib's, so we just use strstr ().
*/
matcher = ignore_case ?
- visit_substring_match_casefold_narrow :
+ visit_substring_match_casefold_narrow :
visit_substring_match_nocasefold_narrow;
}
else
{
matcher = ignore_case ?
- visit_substring_match_casefold_wide :
+ visit_substring_match_casefold_wide :
visit_substring_match_nocasefold_wide;
}
add_visitor (matcher, pathpart);
@@ -1237,25 +1245,25 @@ search_one_database (int argc,
*/
switch (do_check_existence)
{
- case ACCEPT_EXISTING:
- results_were_filtered = true;
- if (follow_symlinks) /* -L, default */
- add_visitor (visit_existing_follow, NULL);
- else /* -P */
- add_visitor (visit_existing_nofollow, NULL);
- break;
-
- case ACCEPT_NON_EXISTING:
- results_were_filtered = true;
- if (follow_symlinks) /* -L, default */
- add_visitor (visit_non_existing_follow, NULL);
- else /* -P */
- add_visitor (visit_non_existing_nofollow, NULL);
- break;
+ case ACCEPT_EXISTING:
+ results_were_filtered = true;
+ if (follow_symlinks) /* -L, default */
+ add_visitor (visit_existing_follow, NULL);
+ else /* -P */
+ add_visitor (visit_existing_nofollow, NULL);
+ break;
- case ACCEPT_EITHER: /* Default, neither -E nor -e */
- /* do nothing; no extra processing. */
- break;
+ case ACCEPT_NON_EXISTING:
+ results_were_filtered = true;
+ if (follow_symlinks) /* -L, default */
+ add_visitor (visit_non_existing_follow, NULL);
+ else /* -P */
+ add_visitor (visit_non_existing_nofollow, NULL);
+ break;
+
+ case ACCEPT_EITHER: /* Default, neither -E nor -e */
+ /* do nothing; no extra processing. */
+ break;
}
/* Security issue: The stats visitor must be added immediately
@@ -1268,7 +1276,7 @@ search_one_database (int argc,
if (enable_print)
{
if (print_quoted_filename)
- add_visitor (visit_justprint_quoted, NULL);
+ add_visitor (visit_justprint_quoted, NULL);
else
add_visitor (visit_justprint_unquoted, NULL);
}
@@ -1294,23 +1302,21 @@ search_one_database (int argc,
if (stats)
{
printf (_("Database %s is in the %s format.\n"),
- procdata.dbfile,
- format_name);
+ procdata.dbfile, format_name);
}
procdata.c = getc (procdata.fp);
- if (slocatedb_format && (procdata.c != EOF))
+ if (slocatedb_format && (procdata.c != EOF))
{
/* Make slocate database look like GNU locate database. */
- ungetc(procdata.c, procdata.fp);
+ ungetc (procdata.c, procdata.fp);
procdata.c = 0;
}
/* If we are searching for filename patterns, the inspector list
* will contain an entry for each pattern for which we are searching.
*/
- while ( (procdata.c != EOF) &&
- (VISIT_ABORT != (mainprocessor)(&procdata)) )
+ while ((procdata.c != EOF) && (VISIT_ABORT != (mainprocessor) (&procdata)))
{
/* Do nothing; all the work is done in the visitor functions. */
}
@@ -1322,8 +1328,8 @@ search_one_database (int argc,
int host_little_endian = i_am_little_endian ();
const char *little = _("The database has little-endian "
"machine-word encoding.\n");
- const char *big = _("The database has big-endian "
- "machine-word encoding.\n");
+ const char *big = _("The database has big-endian "
+ "machine-word encoding.\n");
if (GetwordEndianStateNative == procdata.endian_state)
{
@@ -1336,7 +1342,7 @@ search_one_database (int argc,
else
{
printf (_("The database machine-word encoding order "
- "is not obvious.\n"));
+ "is not obvious.\n"));
}
}
if (filesize || (database_mtime != NULL))
@@ -1358,7 +1364,8 @@ usage (int status)
{
if (status != EXIT_SUCCESS)
{
- fprintf (stderr, _("Try '%s --help' for more information.\n"), program_name);
+ fprintf (stderr, _("Try '%s --help' for more information.\n"),
+ program_name);
exit (status);
}
@@ -1369,22 +1376,20 @@ Usage: %s [-d path | --database=path] [-e | -E | --[non-]existing]\n\
[-P | -H | --nofollow] [-L | --follow] [-m | --mmap] [-s | --stdio]\n\
[-A | --all] [-p | --print] [-r | --regex] [--regextype=TYPE]\n\
[--max-database-age D] [--version] [--help]\n\
- pattern...\n"),
- program_name);
+ pattern...\n"), program_name);
explain_how_to_report_bugs (stdout, program_name);
exit (status);
}
enum
- {
- REGEXTYPE_OPTION = CHAR_MAX + 1,
- MAX_DB_AGE
- };
+{
+ REGEXTYPE_OPTION = CHAR_MAX + 1,
+ MAX_DB_AGE
+};
-static struct option const longopts[] =
-{
+static struct option const longopts[] = {
{"database", required_argument, NULL, 'd'},
{"existing", no_argument, NULL, 'e'},
{"non-existing", no_argument, NULL, 'E'},
@@ -1395,18 +1400,18 @@ static struct option const longopts[] =
{"null", no_argument, NULL, '0'},
{"count", no_argument, NULL, 'c'},
{"wholename", no_argument, NULL, 'w'},
- {"wholepath", no_argument, NULL, 'w'}, /* Synonym. */
+ {"wholepath", no_argument, NULL, 'w'}, /* Synonym. */
{"basename", no_argument, NULL, 'b'},
{"print", no_argument, NULL, 'p'},
{"stdio", no_argument, NULL, 's'},
- {"mmap", no_argument, NULL, 'm'},
- {"limit", required_argument, NULL, 'l'},
- {"regex", no_argument, NULL, 'r'},
- {"regextype", required_argument, NULL, REGEXTYPE_OPTION},
- {"statistics", no_argument, NULL, 'S'},
- {"follow", no_argument, NULL, 'L'},
- {"nofollow", no_argument, NULL, 'P'},
- {"max-database-age", required_argument, NULL, MAX_DB_AGE},
+ {"mmap", no_argument, NULL, 'm'},
+ {"limit", required_argument, NULL, 'l'},
+ {"regex", no_argument, NULL, 'r'},
+ {"regextype", required_argument, NULL, REGEXTYPE_OPTION},
+ {"statistics", no_argument, NULL, 'S'},
+ {"follow", no_argument, NULL, 'L'},
+ {"nofollow", no_argument, NULL, 'P'},
+ {"max-database-age", required_argument, NULL, MAX_DB_AGE},
{NULL, no_argument, NULL, 0}
};
@@ -1414,10 +1419,10 @@ static struct option const longopts[] =
static int
drop_privs (void)
{
- const char * what = "failed";
+ const char *what = "failed";
const uid_t orig_euid = geteuid ();
- const uid_t uid = getuid ();
- const gid_t gid = getgid ();
+ const uid_t uid = getuid ();
+ const gid_t gid = getgid ();
#if HAVE_SETGROUPS
/* Use of setgroups () is restricted to root only. */
@@ -1485,15 +1490,15 @@ drop_privs (void)
/* success. */
return 0;
- fail:
+fail:
error (EXIT_FAILURE, errno, "%s",
quotearg_n_style (0, locale_quoting_style, what));
abort ();
kill (0, SIGKILL);
_exit (1);
- /*NOTREACHED*/
- /* ... we hope. */
- for (;;)
+ /*NOTREACHED*/
+ /* ... we hope. */
+ for (;;)
{
/* deliberate infinite loop */
}
@@ -1504,9 +1509,9 @@ opendb (const char *name)
{
int fd = open (name, O_RDONLY
#if defined O_LARGEFILE
- |O_LARGEFILE
+ | O_LARGEFILE
#endif
- );
+ );
if (fd >= 0)
{
/* Make sure it won't survive an exec */
@@ -1589,7 +1594,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
{
case '0':
separator = 0;
- print_quoted_filename = false; /* print filename 'raw'. */
+ print_quoted_filename = false; /* print filename 'raw'. */
break;
case 'A':
@@ -1678,8 +1683,8 @@ dolocate (int argc, char **argv, int secure_db_fd)
}
break;
- case 's': /* use stdio */
- case 'm': /* use mmap */
+ case 's': /* use stdio */
+ case 'm': /* use mmap */
/* These options are implemented simply for
* compatibility with FreeBSD
*/
@@ -1741,11 +1746,10 @@ dolocate (int argc, char **argv, int secure_db_fd)
off_t filesize;
statistics.compressed_bytes =
- statistics.total_filename_count =
- statistics.total_filename_length =
- statistics.whitespace_count =
- statistics.newline_count =
- statistics.highbit_filename_count = 0u;
+ statistics.total_filename_count =
+ statistics.total_filename_length =
+ statistics.whitespace_count =
+ statistics.newline_count = statistics.highbit_filename_count = 0u;
if (user_selected_locate_path)
{
@@ -1756,7 +1760,8 @@ dolocate (int argc, char **argv, int secure_db_fd)
if (did_stdin)
{
error (0, 0,
- _("warning: the locate database can only be read from standard input once."));
+ _
+ ("warning: the locate database can only be read from standard input once."));
return 0;
}
else
@@ -1776,8 +1781,9 @@ dolocate (int argc, char **argv, int secure_db_fd)
}
else
{
- path_element = strndup (&user_selected_locate_path[path_element_pos],
- path_element_len);
+ path_element =
+ strndup (&user_selected_locate_path[path_element_pos],
+ path_element_len);
db_name = path_element;
}
@@ -1812,7 +1818,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
error (0, errno, "%s",
quotearg_n_style (0, locale_quoting_style, db_name));
/* continue anyway */
- filesize = (off_t)0;
+ filesize = (off_t) 0;
have_mtime = 0;
}
else
@@ -1820,10 +1826,10 @@ dolocate (int argc, char **argv, int secure_db_fd)
time_t now;
filesize = st.st_size;
- database_mtime = get_stat_mtime(&st);
+ database_mtime = get_stat_mtime (&st);
have_mtime = 1;
- if ((time_t)-1 == time (&now))
+ if ((time_t) - 1 == time (&now))
{
/* If we can't tell the time, we don't know how old the
* database is. But since the message is just advisory,
@@ -1833,17 +1839,19 @@ dolocate (int argc, char **argv, int secure_db_fd)
}
else
{
- double age = difftime (now, st.st_mtime);
+ double age = difftime (now, st.st_mtime);
double warn_seconds = SECONDS_PER_UNIT * warn_number_units;
if (age > warn_seconds)
{
/* For example:
- warning: database `fred' is more than 8 days old (actual age is 10 days)*/
+ warning: database `fred' is more than 8 days old (actual age is 10 days) */
error (0, 0,
- _("warning: database %s is more than %u %s old (actual age is %.1f %s)"),
- quotearg_n_style (0, locale_quoting_style, db_name),
- warn_number_units, _(warn_name_units),
- (age/(double)SECONDS_PER_UNIT), _(warn_name_units));
+ _
+ ("warning: database %s is more than %u %s old (actual age is %.1f %s)"),
+ quotearg_n_style (0, locale_quoting_style, db_name),
+ warn_number_units, _(warn_name_units),
+ (age / (double) SECONDS_PER_UNIT),
+ _(warn_name_units));
}
}
}
@@ -1871,25 +1879,27 @@ dolocate (int argc, char **argv, int secure_db_fd)
quotearg_n_style (0, locale_quoting_style, db_name));
return 0;
}
- if (path_element)
+ if (path_element)
{
free (path_element);
path_element = NULL;
}
- if (!user_selected_locate_path)
- {
- /* We're not actually iterating through the values in
- $LOCATE_PATH so we don't want to check for the next
- element in user_selected_locate_path (since we manually set db_name =
- LOCATE_DB without using user_selected_locate_path). */
- break;
- }
- else if (!splitstring (user_selected_locate_path, path_separators, false,
- &path_element_pos, &path_element_len))
- {
- break;
- }
+ if (!user_selected_locate_path)
+ {
+ /* We're not actually iterating through the values in
+ $LOCATE_PATH so we don't want to check for the next
+ element in user_selected_locate_path (since we manually set db_name =
+ LOCATE_DB without using user_selected_locate_path). */
+ break;
+ }
+ else
+ if (!splitstring
+ (user_selected_locate_path, path_separators, false,
+ &path_element_pos, &path_element_len))
+ {
+ break;
+ }
}
if (just_count)
@@ -1897,7 +1907,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
printf ("%lu\n", found);
}
- if (found || (use_limit && (limits.limit==0)) || stats )
+ if (found || (use_limit && (limits.limit == 0)) || stats)
return 0;
else
return 1;
@@ -1908,13 +1918,12 @@ open_secure_db (void)
{
int fd, i;
- const char * secure_db_list[] =
- {
- LOCATE_DB,
- "/var/lib/slocate/slocate.db",
- NULL
- };
- for (i=0; secure_db_list[i]; ++i)
+ const char *secure_db_list[] = {
+ LOCATE_DB,
+ "/var/lib/slocate/slocate.db",
+ NULL
+ };
+ for (i = 0; secure_db_list[i]; ++i)
{
fd = opendb (secure_db_list[i]);
if (fd >= 0)
diff --git a/locate/locatedb.h b/locate/locatedb.h
index 0ce8b260..fb01f2c6 100644
--- a/locate/locatedb.h
+++ b/locate/locatedb.h
@@ -53,15 +53,14 @@
# define LOCATEDB_OLD_OFFSET 14
typedef enum
- {
- GetwordEndianStateInitial = 0,
- GetwordEndianStateNative = 1,
- GetwordEndianStateSwab = 2
- } GetwordEndianState;
+{
+ GetwordEndianStateInitial = 0,
+ GetwordEndianStateNative = 1,
+ GetwordEndianStateSwab = 2
+} GetwordEndianState;
-int getword (FILE *fp, const char *filename,
- size_t maxvalue,
- GetwordEndianState *endian_state_flag);
+int getword (FILE * fp, const char *filename,
+ size_t maxvalue, GetwordEndianState * endian_state_flag);
# define SLOCATE_DB_MAGIC_LEN 2
diff --git a/locate/word_io.c b/locate/word_io.c
index 03218784..a56dc7fc 100644
--- a/locate/word_io.c
+++ b/locate/word_io.c
@@ -34,13 +34,13 @@
#include "locatedb.h"
-enum { WORDBYTES=4 };
+enum
+{ WORDBYTES = 4 };
static int
decode_value (const unsigned char data[],
int limit,
- GetwordEndianState *endian_state_flag,
- const char *filename)
+ GetwordEndianState *endian_state_flag, const char *filename)
{
int swapped;
union
@@ -50,7 +50,7 @@ decode_value (const unsigned char data[],
} u;
u.ival = 0;
memcpy (&u.data, data, WORDBYTES);
- swapped = bswap_32(u.ival); /* byteswapped */
+ swapped = bswap_32 (u.ival); /* byteswapped */
if (*endian_state_flag == GetwordEndianStateInitial)
{
@@ -102,8 +102,7 @@ decode_value (const unsigned char data[],
int
getword (FILE *fp,
const char *filename,
- size_t maxvalue,
- GetwordEndianState *endian_state_flag)
+ size_t maxvalue, GetwordEndianState *endian_state_flag)
{
unsigned char data[4];
size_t bytes_read;
@@ -112,13 +111,14 @@ getword (FILE *fp,
bytes_read = fread (data, WORDBYTES, 1, fp);
if (bytes_read != 1)
{
- const char * quoted_name = quotearg_n_style (0, locale_quoting_style,
- filename);
+ const char *quoted_name = quotearg_n_style (0, locale_quoting_style,
+ filename);
/* Distinguish between a truncated database and an I/O error.
* Either condition is fatal.
*/
if (feof (fp))
- error (EXIT_FAILURE, 0, _("unexpected end-of-file in %s"), quoted_name);
+ error (EXIT_FAILURE, 0, _("unexpected end-of-file in %s"),
+ quoted_name);
else
error (EXIT_FAILURE, errno,
_("error reading a word from %s"), quoted_name);
diff --git a/tests/xargs/test-sigusr.c b/tests/xargs/test-sigusr.c
index 396378e6..7375e278 100644
--- a/tests/xargs/test-sigusr.c
+++ b/tests/xargs/test-sigusr.c
@@ -34,40 +34,41 @@
#include <error.h>
-enum { FLAGFILE_MAX = 128 };
+enum
+{ FLAGFILE_MAX = 128 };
static char flagfile_name[FLAGFILE_MAX];
-static const char* tmpdir = NULL;
+static const char *tmpdir = NULL;
static void
-remove_temporary_files(void)
+remove_temporary_files (void)
{
if (tmpdir)
{
- unlink(flagfile_name);
- rmdir(tmpdir);
+ unlink (flagfile_name);
+ rmdir (tmpdir);
}
tmpdir = NULL;
}
static void
-wait_for_flagfile(void)
+wait_for_flagfile (void)
{
struct stat st;
for (;;)
{
- if (0 == stat(flagfile_name, &st))
+ if (0 == stat (flagfile_name, &st))
{
return;
}
- sleep(1);
+ sleep (1);
}
}
static void
-delete_flagfile(void)
+delete_flagfile (void)
{
- if (0 != unlink(flagfile_name))
+ if (0 != unlink (flagfile_name))
{
if (ENOENT != errno)
{
@@ -78,71 +79,71 @@ delete_flagfile(void)
static void
-ignore_signal(int signum)
+ignore_signal (int signum)
{
struct sigaction sa;
sa.sa_handler = SIG_IGN;
sa.sa_flags = 0;
- sigemptyset(&sa.sa_mask);
- if (0 != sigaction(signum, &sa, (struct sigaction*)NULL))
+ sigemptyset (&sa.sa_mask);
+ if (0 != sigaction (signum, &sa, (struct sigaction *) NULL))
{
- error(2, errno, "sigaction failed");
+ error (2, errno, "sigaction failed");
}
}
-static void handler(int sig)
+static void
+handler (int sig)
{
/* Actually does nothing. */
}
static void
-catch_signal(int signum)
+catch_signal (int signum)
{
struct sigaction sa;
sa.sa_handler = handler;
sa.sa_flags = 0;
- if (0 != sigaction(signum, &sa, (struct sigaction*)NULL))
+ if (0 != sigaction (signum, &sa, (struct sigaction *) NULL))
{
- error(2, errno, "sigaction failed");
+ error (2, errno, "sigaction failed");
}
}
static void
-run_child(char * const argv[], int errno_fd)
+run_child (char *const argv[], int errno_fd)
{
int fd;
- close(0);
+ close (0);
- fd = open("/dev/null", O_RDONLY);
+ fd = open ("/dev/null", O_RDONLY);
if (fd < 0)
{
- error(2, errno, "failed to open /dev/null");
+ error (2, errno, "failed to open /dev/null");
}
else if (fd != 0)
{
- error(2, errno, "failed to close stdin");
+ error (2, errno, "failed to close stdin");
}
- execvp("xargs", argv);
+ execvp ("xargs", argv);
/* Exec failed, tell the parent why. */
- if (write(errno_fd, &errno, sizeof errno) != sizeof errno)
+ if (write (errno_fd, &errno, sizeof errno) != sizeof errno)
{
error (2, errno, "child failed to write errno value though pipe");
}
- error(2, errno, "unable to exec xargs in child process");
+ error (2, errno, "unable to exec xargs in child process");
- /*NOTREACHED*/
-}
+ /*NOTREACHED*/}
static void
-set_close_on_exec(int fd)
+set_close_on_exec (int fd)
{
- if (0 != fcntl(fd, F_SETFD, FD_CLOEXEC))
+ if (0 != fcntl (fd, F_SETFD, FD_CLOEXEC))
{
- error(2, errno, "F_SETFD failed");
+ error (2, errno, "F_SETFD failed");
}
}
@@ -156,71 +157,73 @@ struct status
/* Run xargs and return its exit status */
static struct status
-run_xargs(const char *option, const char *opt_arg, int send_signal)
+run_xargs (const char *option, const char *opt_arg, int send_signal)
{
int i = 0;
- enum { ARGV_MAX = 9 };
+ enum
+ { ARGV_MAX = 9 };
char *argv[ARGV_MAX];
pid_t child, dead;
int wstatus;
- struct status result = {0};
+ struct status result = { 0 };
int pipefd[2];
int child_errno;
- argv[i++] = (char*)"xargs";
+ argv[i++] = (char *) "xargs";
if (option)
{
- argv[i++] = (char*)option;
+ argv[i++] = (char *) option;
}
if (opt_arg)
{
- argv[i++] = (char*)opt_arg;
+ argv[i++] = (char *) opt_arg;
}
- argv[i++] = (char*)"sh";
- argv[i++] = (char*)"-c";
- argv[i++] = (char*)"touch \"$1\" && sleep 4";
- argv[i++] = (char*)"fnord";
+ argv[i++] = (char *) "sh";
+ argv[i++] = (char *) "-c";
+ argv[i++] = (char *) "touch \"$1\" && sleep 4";
+ argv[i++] = (char *) "fnord";
argv[i++] = flagfile_name;
argv[i++] = NULL;
- assert(i <= ARGV_MAX);
+ assert (i <= ARGV_MAX);
/* Create a pipe so that we can detect an exec call. */
/* read end is pipefd[0], write end is pipefd[1]. */
- if (0 != pipe(pipefd))
+ if (0 != pipe (pipefd))
{
- error(2, errno, "pipe");
+ error (2, errno, "pipe");
}
- set_close_on_exec(pipefd[0]);
- set_close_on_exec(pipefd[1]);
- delete_flagfile();
+ set_close_on_exec (pipefd[0]);
+ set_close_on_exec (pipefd[1]);
+ delete_flagfile ();
- while ((child=fork()) < 0 && errno == EAGAIN)
+ while ((child = fork ()) < 0 && errno == EAGAIN)
{
- perror("unable to fork yet, will try again");
- sleep(1);
+ perror ("unable to fork yet, will try again");
+ sleep (1);
}
switch (child)
{
case -1:
- error(EXIT_FAILURE, errno, "cannot fork");
+ error (EXIT_FAILURE, errno, "cannot fork");
break;
case 0: /* child */
- close(pipefd[0]); /* close read end */
+ close (pipefd[0]); /* close read end */
/* The child will close the write end of the pipe on successful exec. */
- run_child(argv, pipefd[1]);
- abort();
+ run_child (argv, pipefd[1]);
+ abort ();
break;
default: /* parent */
- close(pipefd[1]); /* close write end */
- if (read(pipefd[0], &child_errno, sizeof child_errno) < sizeof child_errno)
+ close (pipefd[1]); /* close write end */
+ if (read (pipefd[0], &child_errno, sizeof child_errno) <
+ sizeof child_errno)
{
/* The exec succeeded in the child, and its write end of the pipe was closed. */
}
else
{
/* exec failed in the child and its errno value is now in child_errno. */
- error(2, child_errno, "execvp failed in the child process");
+ error (2, child_errno, "execvp failed in the child process");
}
break;
}
@@ -228,127 +231,138 @@ run_xargs(const char *option, const char *opt_arg, int send_signal)
/* We now know that the exec succeeded and xargs is running. We
* should give it a short time to set up its signal handlers.
*/
- fputs("exec succeeded in the child...", stdout);
- fflush(stdout);
+ fputs ("exec succeeded in the child...", stdout);
+ fflush (stdout);
/* Wait for the child xargs to launch its command (so we know it
will have set any signal handlers it is going to set). */
- wait_for_flagfile();
+ wait_for_flagfile ();
if (send_signal)
{
if (0 != kill (child, send_signal))
{
- error(2, errno, "kill failed");
+ error (2, errno, "kill failed");
}
}
wstatus = 0;
- dead = waitpid(child, &wstatus, 0);
+ dead = waitpid (child, &wstatus, 0);
if (dead < 0)
{
- error(2, errno, "waitpid failed");
+ error (2, errno, "waitpid failed");
}
else if (dead == 0)
{
- error(2, 0, "test unexpectedly has more than one child");
+ error (2, 0, "test unexpectedly has more than one child");
}
else
{
- if (WIFEXITED(wstatus))
+ if (WIFEXITED (wstatus))
{
- result.retval = WEXITSTATUS(wstatus);
+ result.retval = WEXITSTATUS (wstatus);
}
- else if (WIFSIGNALED(wstatus))
+ else if (WIFSIGNALED (wstatus))
{
result.retval = -1;
- result.fatalsig = WTERMSIG(wstatus);
+ result.fatalsig = WTERMSIG (wstatus);
}
- else if (WIFSTOPPED(wstatus))
+ else if (WIFSTOPPED (wstatus))
{
- error(2, 0, "child was unexpectedly stopped");
+ error (2, 0, "child was unexpectedly stopped");
}
return result;
}
- /*NOTREACHED*/
- abort();
+ /*NOTREACHED*/ abort ();
}
static void
-verify_signal_ignored(int signum)
+verify_signal_ignored (int signum)
{
struct status status;
- printf("verifying that xargs can ignore signal %d...", signum);
- fflush(stdout);
+ printf ("verifying that xargs can ignore signal %d...", signum);
+ fflush (stdout);
- ignore_signal(signum);
- status = run_xargs(NULL, NULL, signum);
+ ignore_signal (signum);
+ status = run_xargs (NULL, NULL, signum);
if (status.fatalsig)
{
- fprintf(stderr, "xargs should not have exited fatally on receipt of signal %d\n", signum);
- exit(EXIT_FAILURE);
+ fprintf (stderr,
+ "xargs should not have exited fatally on receipt of signal %d\n",
+ signum);
+ exit (EXIT_FAILURE);
}
if (status.retval)
{
- fprintf(stderr, "xargs should not have returned a nonzero exit status %d\n", status.retval);
- exit(EXIT_FAILURE);
+ fprintf (stderr,
+ "xargs should not have returned a nonzero exit status %d\n",
+ status.retval);
+ exit (EXIT_FAILURE);
}
- fputs("OK\n", stdout);
+ fputs ("OK\n", stdout);
}
static void
-verify_signal_is_fatal(int signum)
+verify_signal_is_fatal (int signum)
{
struct status status;
- printf("verifying that signal %d will kill xargs (without -P) if it is not blocked when xargs starts...", signum);
- fflush(stdout);
- catch_signal(signum);
- status = run_xargs(NULL, NULL, signum);
+ printf
+ ("verifying that signal %d will kill xargs (without -P) if it is not blocked when xargs starts...",
+ signum);
+ fflush (stdout);
+ catch_signal (signum);
+ status = run_xargs (NULL, NULL, signum);
if (!status.fatalsig)
{
- fprintf(stderr, "xargs should have exited fatally on receipt of signal %d\n", signum);
- exit(EXIT_FAILURE);
+ fprintf (stderr,
+ "xargs should have exited fatally on receipt of signal %d\n",
+ signum);
+ exit (EXIT_FAILURE);
}
- fputs("OK\n", stdout);
+ fputs ("OK\n", stdout);
}
static void
-verify_signal_is_nonfatal_with_p(int signum)
+verify_signal_is_nonfatal_with_p (int signum)
{
struct status status;
- printf("verifying that signal %d will not kill xargs -P if it is not blocked when xargs starts...", signum);
- fflush(stdout);
- catch_signal(signum);
- status = run_xargs("-P", "5", signum);
+ printf
+ ("verifying that signal %d will not kill xargs -P if it is not blocked when xargs starts...",
+ signum);
+ fflush (stdout);
+ catch_signal (signum);
+ status = run_xargs ("-P", "5", signum);
if (status.fatalsig)
{
- fprintf(stderr, "xargs -P should not have exited fatally on receipt of signal %d\n", signum);
- exit(EXIT_FAILURE);
+ fprintf (stderr,
+ "xargs -P should not have exited fatally on receipt of signal %d\n",
+ signum);
+ exit (EXIT_FAILURE);
}
- fputs("OK\n", stdout);
+ fputs ("OK\n", stdout);
}
int
-main(int argc, char *argv[])
+main (int argc, char *argv[])
{
char tmpdir_tmpl[] = "/tmp/test-sigusr.XXXXXX";
- tmpdir = mkdtemp(tmpdir_tmpl);
+ tmpdir = mkdtemp (tmpdir_tmpl);
if (NULL == tmpdir)
{
- error(2, errno, "failed to create temporary directory");
+ error (2, errno, "failed to create temporary directory");
}
- snprintf(flagfile_name, FLAGFILE_MAX, "%s/flagfile", tmpdir);
- atexit(remove_temporary_files);
-
- verify_signal_ignored(SIGUSR1);
- verify_signal_ignored(SIGUSR2);
- fputs("\n", stdout);
-
- verify_signal_is_fatal(SIGUSR1);
- verify_signal_is_fatal(SIGUSR2);
- fputs("\n", stdout);
- verify_signal_is_nonfatal_with_p(SIGUSR1);
- verify_signal_is_nonfatal_with_p(SIGUSR2);
+ snprintf (flagfile_name, FLAGFILE_MAX, "%s/flagfile", tmpdir);
+ atexit (remove_temporary_files);
+
+ verify_signal_ignored (SIGUSR1);
+ verify_signal_ignored (SIGUSR2);
+ fputs ("\n", stdout);
+
+ verify_signal_is_fatal (SIGUSR1);
+ verify_signal_is_fatal (SIGUSR2);
+ fputs ("\n", stdout);
+ verify_signal_is_nonfatal_with_p (SIGUSR1);
+ verify_signal_is_nonfatal_with_p (SIGUSR2);
return 0;
}
diff --git a/xargs/xargs.c b/xargs/xargs.c
index da20a587..12fd7ff3 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -144,10 +144,10 @@ static volatile int child_error = EXIT_SUCCESS;
static volatile int original_exit_value;
/* If true, open /dev/tty in the child process before executing the command. */
-static bool open_tty = false; /* option -o */
+static bool open_tty = false; /* option -o */
/* If true, print each command on stderr before executing it. */
-static bool print_command = false; /* Option -t */
+static bool print_command = false; /* Option -t */
/* If true, query the user before executing each command, and only
execute the command if the user responds affirmatively. */
@@ -164,15 +164,14 @@ static char input_delimiter = '\0';
* load distribution. We guarantee not to allow two processes to run
* at the same time with the same value of this variable.
*/
-static char* slot_var_name = NULL;
+static char *slot_var_name = NULL;
enum LongOptionIdentifier
- {
- PROCESS_SLOT_VAR = CHAR_MAX+1
- };
-
-static struct option const longopts[] =
{
+ PROCESS_SLOT_VAR = CHAR_MAX + 1
+};
+
+static struct option const longopts[] = {
{"null", no_argument, NULL, '0'},
{"arg-file", required_argument, NULL, 'a'},
{"delimiter", required_argument, NULL, 'd'},
@@ -197,15 +196,17 @@ static struct option const longopts[] =
/* xargs exits with status values with specific meanings (this is a POSIX requirement).
These are the values.
*/
-enum XargsStatusValues {
+enum XargsStatusValues
+{
XARGS_EXIT_CLIENT_EXIT_NONZERO = 123, /* utility exited with nonzero status */
XARGS_EXIT_CLIENT_EXIT_255 = 124, /* utility exited with status 255 */
XARGS_EXIT_CLIENT_FATAL_SIG = 125, /* utility died from a fatal signal */
- XARGS_EXIT_COMMAND_CANNOT_BE_RUN = 126, /* cannot run the command */
- XARGS_EXIT_COMMAND_NOT_FOUND = 127, /* cannot find the command */
+ XARGS_EXIT_COMMAND_CANNOT_BE_RUN = 126, /* cannot run the command */
+ XARGS_EXIT_COMMAND_NOT_FOUND = 127, /* cannot find the command */
};
/* Exit status values the child might use. */
-enum ClientStatusValues {
+enum ClientStatusValues
+{
CHILD_EXIT_PLEASE_STOP_IMMEDIATELY = 255
};
@@ -213,7 +214,8 @@ static int read_line (void);
static int read_string (void);
static bool print_args (bool ask);
/* static void do_exec (void); */
-static int xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv);
+static int xargs_do_exec (struct buildcmd_control *ctl, void *usercontext,
+ int argc, char **argv);
static void exec_if_possible (void);
static unsigned int add_proc (pid_t pid);
static void wait_for_proc (bool all, unsigned int minreap);
@@ -221,13 +223,14 @@ static void wait_for_proc_all (void);
static void increment_proc_max (int);
static void decrement_proc_max (int);
static long parse_num (char *str, int option, long min, long max, int fatal);
-static void usage (int status) _GL_ATTRIBUTE_NORETURN;
+static void
+usage (int status)
+ _GL_ATTRIBUTE_NORETURN;
-static char
-get_char_oct_or_hex_escape (const char *s)
+ static char get_char_oct_or_hex_escape (const char *s)
{
- const char * p;
+ const char *p;
int base = 8;
unsigned long val;
char *endp;
@@ -237,20 +240,21 @@ get_char_oct_or_hex_escape (const char *s)
if ('x' == s[1])
{
/* hex */
- p = s+2;
+ p = s + 2;
base = 16;
}
else if (isdigit ((unsigned char) s[1]))
{
/* octal */
- p = s+1;
+ p = s + 1;
base = 8;
}
else
{
p = NULL; /* Silence compiler warning. */
error (EXIT_FAILURE, 0,
- _("Invalid escape sequence %s in input delimiter specification."),
+ _
+ ("Invalid escape sequence %s in input delimiter specification."),
s);
}
errno = 0;
@@ -262,22 +266,23 @@ get_char_oct_or_hex_escape (const char *s)
* value as ULONG_MAX. IF UCHAR_MAX==ULONG_MAX,
* then val can never be greater than UCHAR_MAX.
*/
- if ((ULONG_MAX == val && ERANGE == errno)
- || (val > UCHAR_MAX))
+ if ((ULONG_MAX == val && ERANGE == errno) || (val > UCHAR_MAX))
{
if (16 == base)
{
error (EXIT_FAILURE, 0,
- _("Invalid escape sequence %s in input delimiter specification; "
- "character values must not exceed %lx."),
- s, (unsigned long)UCHAR_MAX);
+ _
+ ("Invalid escape sequence %s in input delimiter specification; "
+ "character values must not exceed %lx."), s,
+ (unsigned long) UCHAR_MAX);
}
else
{
error (EXIT_FAILURE, 0,
- _("Invalid escape sequence %s in input delimiter specification; "
- "character values must not exceed %lo."),
- s, (unsigned long)UCHAR_MAX);
+ _
+ ("Invalid escape sequence %s in input delimiter specification; "
+ "character values must not exceed %lo."), s,
+ (unsigned long) UCHAR_MAX);
}
}
@@ -286,8 +291,7 @@ get_char_oct_or_hex_escape (const char *s)
{
error (EXIT_FAILURE, 0,
_("Invalid escape sequence %s in input delimiter specification; "
- "trailing characters %s not recognised."),
- s, endp);
+ "trailing characters %s not recognised."), s, endp);
}
return (char) val;
@@ -319,7 +323,7 @@ get_input_delimiter (const char *s)
case 'r':
return '\r';
case 't':
- return'\t';
+ return '\t';
case 'v':
return '\v';
case '\\':
@@ -331,12 +335,11 @@ get_input_delimiter (const char *s)
else
{
error (EXIT_FAILURE, 0,
- _("Invalid input delimiter specification %s: the delimiter must "
- "be either a single character or an escape sequence starting "
- "with \\."),
- s);
- /*NOTREACHED*/
- return 0;
+ _
+ ("Invalid input delimiter specification %s: the delimiter must "
+ "be either a single character or an escape sequence starting "
+ "with \\."), s);
+ /*NOTREACHED*/ return 0;
}
}
}
@@ -363,7 +366,8 @@ smaller_of (size_t a, size_t b)
}
-static FILE* fopen_cloexec_for_read_only (const char *file_name)
+static FILE *
+fopen_cloexec_for_read_only (const char *file_name)
{
int fd = open_cloexec (file_name, O_RDONLY);
if (fd < 0)
@@ -385,11 +389,11 @@ static FILE* fopen_cloexec_for_read_only (const char *file_name)
}
-static void warn_mutually_exclusive (const char *option, const char *offending)
+static void
+warn_mutually_exclusive (const char *option, const char *offending)
{
error (0, 0, _("warning: options %s and %s are mutually exclusive, "
- "ignoring previous %s value"),
- offending, option, offending);
+ "ignoring previous %s value"), offending, option, offending);
}
@@ -397,15 +401,16 @@ int
main (int argc, char **argv)
{
int optc, option_index;
- int show_limits = 0; /* --show-limits */
+ int show_limits = 0; /* --show-limits */
int always_run_command = 1;
const char *input_file = "-"; /* "-" is stdin */
char default_cmd[] = "echo";
char *default_arglist[1];
int (*read_args) (void) = read_line;
- void (*act_on_init_result)(void) = noop;
+ void (*act_on_init_result) (void) = noop;
enum BC_INIT_STATUS bcstatus;
- enum { XARGS_POSIX_HEADROOM = 2048u };
+ enum
+ { XARGS_POSIX_HEADROOM = 2048u };
bool catch_usr_signals = false;
/* We #define __STDC_LIMIT_MACROS above for its side effect on
@@ -484,7 +489,7 @@ main (int argc, char **argv)
* and bc_ctl.arg_max can also be greater than ARG_MAX.
*/
bc_ctl.arg_max = smaller_of (bc_ctl.arg_max,
- (size_t)val-XARGS_POSIX_HEADROOM);
+ (size_t) val - XARGS_POSIX_HEADROOM);
}
else
{
@@ -672,7 +677,9 @@ main (int argc, char **argv)
#if defined SIGUSR1 && defined SIGUSR2
catch_usr_signals = true;
#else
- error (0, 0, _("SIGUSR1 and SIGUSR2 are not both defined, so the -P option does nothing."));
+ error (0, 0,
+ _
+ ("SIGUSR1 and SIGUSR2 are not both defined, so the -P option does nothing."));
proc_max = 1;
#endif
break;
@@ -689,7 +696,8 @@ main (int argc, char **argv)
if (strchr (optarg, '='))
{
error (EXIT_FAILURE, 0,
- _("option --%s may not be set to a value which includes `='"),
+ _
+ ("option --%s may not be set to a value which includes `='"),
longopts[option_index].name);
}
slot_var_name = optarg;
@@ -699,7 +707,7 @@ main (int argc, char **argv)
may not be able to guarantee that no two children
have the same value for this variable; see
set_slot_var.
- */
+ */
error (EXIT_FAILURE, errno,
_("failed to unset environment variable %s"),
slot_var_name);
@@ -715,7 +723,8 @@ main (int argc, char **argv)
{
/* TRANSLATORS: -0 == "--null", not option "o". */
error (0, 0,
- _("warning: the -E option has no effect if -0 or -d is used.\n"));
+ _
+ ("warning: the -E option has no effect if -0 or -d is used.\n"));
}
/* If we had deferred failing due to problems in bc_init_controlinfo (),
@@ -738,17 +747,17 @@ main (int argc, char **argv)
child processes. Do this as early as possible after setting
proc_max. */
sigact.sa_handler = increment_proc_max;
- sigemptyset(&sigact.sa_mask);
+ sigemptyset (&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
- if (0 != sigaction (SIGUSR1, &sigact, (struct sigaction *)NULL))
+ if (0 != sigaction (SIGUSR1, &sigact, (struct sigaction *) NULL))
error (0, errno, _("Cannot set SIGUSR1 signal handler"));
sigact.sa_handler = decrement_proc_max;
- sigemptyset(&sigact.sa_mask);
+ sigemptyset (&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
- if (0 != sigaction (SIGUSR2, &sigact, (struct sigaction *)NULL))
+ if (0 != sigaction (SIGUSR2, &sigact, (struct sigaction *) NULL))
error (0, errno, _("Cannot set SIGUSR2 signal handler"));
-# endif /* SIGUSR2 */
+# endif/* SIGUSR2 */
#endif /* SIGUSR1 */
}
@@ -782,39 +791,41 @@ main (int argc, char **argv)
if (show_limits)
{
fprintf (stderr,
- _("Your environment variables take up %" PRIuMAX " bytes\n"),
- (uintmax_t)bc_size_of_environment ());
+ _("Your environment variables take up %" PRIuMAX " bytes\n"),
+ (uintmax_t) bc_size_of_environment ());
fprintf (stderr,
- _("POSIX upper limit on argument length (this system): %" PRIuMAX "\n"),
- (uintmax_t)bc_ctl.posix_arg_size_max);
+ _("POSIX upper limit on argument length (this system): %"
+ PRIuMAX "\n"), (uintmax_t) bc_ctl.posix_arg_size_max);
fprintf (stderr,
- _("POSIX smallest allowable upper limit on argument length (all systems): %" PRIuMAX "\n"),
- (uintmax_t)bc_ctl.posix_arg_size_min);
+ _
+ ("POSIX smallest allowable upper limit on argument length (all systems): %"
+ PRIuMAX "\n"), (uintmax_t) bc_ctl.posix_arg_size_min);
fprintf (stderr,
- _("Maximum length of command we could actually use: %" PRIuMAX "\n"),
- (uintmax_t)(bc_ctl.posix_arg_size_max - bc_size_of_environment ()));
+ _("Maximum length of command we could actually use: %" PRIuMAX
+ "\n"),
+ (uintmax_t) (bc_ctl.posix_arg_size_max -
+ bc_size_of_environment ()));
fprintf (stderr,
- _("Size of command buffer we are actually using: %" PRIuMAX "\n"),
- (uintmax_t)bc_ctl.arg_max);
+ _("Size of command buffer we are actually using: %" PRIuMAX
+ "\n"), (uintmax_t) bc_ctl.arg_max);
fprintf (stderr,
- _("Maximum parallelism (--max-procs must be no greater): %" PRIuMAX "\n"),
- (uintmax_t)MAX_PROC_MAX);
+ _("Maximum parallelism (--max-procs must be no greater): %"
+ PRIuMAX "\n"), (uintmax_t) MAX_PROC_MAX);
if (isatty (STDIN_FILENO))
{
fprintf (stderr,
- _("\n"
- "Execution of xargs will continue now, and it will "
- "try to read its input and run commands; if this is "
- "not what you wanted to happen, please type the "
- "end-of-file keystroke.\n"));
+ _("\n"
+ "Execution of xargs will continue now, and it will "
+ "try to read its input and run commands; if this is "
+ "not what you wanted to happen, please type the "
+ "end-of-file keystroke.\n"));
if (always_run_command)
{
fprintf (stderr,
- _("Warning: %s will be run at least once. "
- "If you do not want that to happen, then press "
- "the interrupt keystroke.\n"),
- argv[optind]);
+ _("Warning: %s will be run at least once. "
+ "If you do not want that to happen, then press "
+ "the interrupt keystroke.\n"), argv[optind]);
}
}
}
@@ -830,13 +841,12 @@ main (int argc, char **argv)
for (; optind < argc; optind++)
bc_push_arg (&bc_ctl, &bc_state,
argv[optind], strlen (argv[optind]) + 1,
- NULL, 0,
- initial_args);
+ NULL, 0, initial_args);
initial_args = false;
bc_ctl.initial_argc = bc_state.cmd_argc;
bc_state.cmd_initial_argv_chars = bc_state.cmd_argv_chars;
bc_ctl.initial_argc = bc_state.cmd_argc;
- /*fprintf (stderr, "setting initial_argc=%d\n", bc_state.cmd_initial_argc);*/
+ /*fprintf (stderr, "setting initial_argc=%d\n", bc_state.cmd_initial_argc); */
while ((*read_args) () != -1)
if (bc_ctl.lines_per_exec && lineno >= bc_ctl.lines_per_exec)
@@ -848,7 +858,7 @@ main (int argc, char **argv)
/* SYSV xargs seems to do at least one exec, even if the
input is empty. */
if (bc_state.cmd_argc != bc_ctl.initial_argc
- || (always_run_command && procs_executed==0))
+ || (always_run_command && procs_executed == 0))
bc_do_exec (&bc_ctl, &bc_state);
}
@@ -865,21 +875,18 @@ main (int argc, char **argv)
size_t len = (size_t) args;
/* Don't do insert on the command name. */
bc_clear_args (&bc_ctl, &bc_state);
- bc_state.cmd_argv_chars = 0; /* begin at start of buffer */
+ bc_state.cmd_argv_chars = 0; /* begin at start of buffer */
bc_push_arg (&bc_ctl, &bc_state,
argv[optind], arglen[optind] + 1,
- NULL, 0,
- initial_args);
+ NULL, 0, initial_args);
len--;
initial_args = false;
for (i = optind + 1; i < argc; i++)
bc_do_insert (&bc_ctl, &bc_state,
argv[i], arglen[i],
- NULL, 0,
- linebuf, len,
- initial_args);
+ NULL, 0, linebuf, len, initial_args);
bc_do_exec (&bc_ctl, &bc_state);
}
}
@@ -901,24 +908,25 @@ read_line (void)
{
/* States for read_line. */
enum read_line_state
- {
- NORM = 0,
- SPACE = 1,
- QUOTE = 2,
- BACKSLASH = 3
- };
+ {
+ NORM = 0,
+ SPACE = 1,
+ QUOTE = 2,
+ BACKSLASH = 3
+ };
static bool eof = false;
/* Start out in mode SPACE to always strip leading spaces (even with -i). */
- enum read_line_state state = SPACE; /* The type of character we last read. */
+ enum read_line_state state = SPACE; /* The type of character we last read. */
int prevc; /* The previous value of c. */
int quotc = 0; /* The last quote character read. */
int c = EOF;
bool first = true; /* true if reading first arg on line. */
- bool seen_arg = false; /* true if we have seen any arg (or part of one) yet */
+ bool seen_arg = false; /* true if we have seen any arg (or part of one) yet */
int len;
char *p = linebuf;
/* Including the NUL, the args must not grow past this point. */
- char *endbuf = linebuf + bc_ctl.arg_max - bc_state.cmd_initial_argv_chars - 1;
+ char *endbuf =
+ linebuf + bc_ctl.arg_max - bc_state.cmd_initial_argv_chars - 1;
if (eof)
return -1;
@@ -951,9 +959,7 @@ read_line (void)
return -1;
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
- linebuf, len,
- NULL, 0,
- initial_args);
+ linebuf, len, NULL, 0, initial_args);
return len;
}
switch (state)
@@ -962,7 +968,7 @@ read_line (void)
if (ISSPACE (c))
continue;
state = NORM;
- FALLTHROUGH; /* aaahhhh.... */
+ FALLTHROUGH; /* aaahhhh.... */
case NORM:
if (c == '\n')
@@ -991,9 +997,7 @@ read_line (void)
}
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
- linebuf, len,
- NULL, 0,
- initial_args);
+ linebuf, len, NULL, 0, initial_args);
return len;
}
seen_arg = true;
@@ -1011,9 +1015,7 @@ read_line (void)
return first ? -1 : len;
}
bc_push_arg (&bc_ctl, &bc_state,
- linebuf, len,
- NULL, 0,
- initial_args);
+ linebuf, len, NULL, 0, initial_args);
p = linebuf;
state = SPACE;
first = false;
@@ -1046,7 +1048,7 @@ read_line (void)
if (c == quotc)
{
state = NORM;
- seen_arg = true; /* Makes a difference for e.g. just '' or "" as the first arg on a line */
+ seen_arg = true; /* Makes a difference for e.g. just '' or "" as the first arg on a line */
continue;
}
break;
@@ -1056,7 +1058,7 @@ read_line (void)
break;
}
- if ( (0 == c) && !nullwarning_given )
+ if ((0 == c) && !nullwarning_given)
{
/* This is just a warning message. We only issue it once. */
error (0, 0,
@@ -1099,7 +1101,8 @@ read_string (void)
int len;
char *p = linebuf;
/* Including the NUL, the args must not grow past this point. */
- char *endbuf = linebuf + bc_ctl.arg_max - bc_state.cmd_initial_argv_chars - 1;
+ char *endbuf =
+ linebuf + bc_ctl.arg_max - bc_state.cmd_initial_argv_chars - 1;
if (eof)
return -1;
@@ -1117,9 +1120,7 @@ read_string (void)
len = p - linebuf;
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
- linebuf, len,
- NULL, 0,
- initial_args);
+ linebuf, len, NULL, 0, initial_args);
return len;
}
if (c == input_delimiter)
@@ -1129,9 +1130,7 @@ read_string (void)
len = p - linebuf;
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
- linebuf, len,
- NULL, 0,
- initial_args);
+ linebuf, len, NULL, 0, initial_args);
return len;
}
if (p >= endbuf)
@@ -1215,7 +1214,7 @@ set_slot_var (unsigned int n)
INT_MAX, the assumptions we made about how snprintf behaves (or
what UINT_MAX is) are wrong. Hence we have a design error (not
an environmental error).
- */
+ */
char buf[20];
assert (snprintf (buf, sizeof buf - 1, "%u", n) <= sizeof buf - 1);
@@ -1226,7 +1225,7 @@ set_slot_var (unsigned int n)
If the user doesn't want us to set the variable, there is
nothing to do. However, we defer the bail-out until this
point in order to get better test coverage.
- */
+ */
if (slot_var_name)
{
if (setenv (slot_var_name, buf, 1) < 0)
@@ -1284,10 +1283,11 @@ prep_child_for_exec (void)
}
if (STDIN_FILENO < fd)
{
- if (dup2(fd, STDIN_FILENO) != 0)
+ if (dup2 (fd, STDIN_FILENO) != 0)
error (EXIT_FAILURE, errno,
- _("failed to redirect standard input of the child process"));
- close(fd);
+ _
+ ("failed to redirect standard input of the child process"));
+ close (fd);
}
}
}
@@ -1302,7 +1302,8 @@ prep_child_for_exec (void)
as an atexit () function.
*/
static int
-xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv)
+xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc,
+ char **argv)
{
pid_t child;
int fd[2];
@@ -1334,7 +1335,7 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char *
seq 1 1000 | fmt | while read x ; do echo $x; sleep 1 ; done |
./xargs -P 200 -n 20 sh -c 'echo "$@"; sleep $((1 + $RANDOM % 5))' sleeper
- */
+ */
wait_for_proc (false, 0u);
if (pipe (fd))
@@ -1409,11 +1410,10 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char *
* because the parent will test our value of errno.
*/
_exit (saved_errno == ENOENT
- ? XARGS_EXIT_COMMAND_NOT_FOUND
- : XARGS_EXIT_COMMAND_CANNOT_BE_RUN);
+ ? XARGS_EXIT_COMMAND_NOT_FOUND
+ : XARGS_EXIT_COMMAND_CANNOT_BE_RUN);
- /*NOTREACHED*/
- } /* child */
+ /*NOTREACHED*/} /* child */
default:
{
@@ -1421,8 +1421,8 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char *
close (fd[1]);
}
- } /* switch (child) */
- /*fprintf (stderr, "forked child (bc_state.cmd_argc=%d) -> ", bc_state.cmd_argc);*/
+ } /* switch (child) */
+ /*fprintf (stderr, "forked child (bc_state.cmd_argc=%d) -> ", bc_state.cmd_argc); */
/* We use safe_read here in order to avoid an error if
SIGUSR[12] is handled during the read system call. */
@@ -1453,18 +1453,18 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char *
if (E2BIG == buf)
{
- return 0; /* Failure; caller should pass fewer args */
+ return 0; /* Failure; caller should pass fewer args */
}
else if (ENOENT == buf)
{
- exit (XARGS_EXIT_COMMAND_NOT_FOUND); /* command cannot be found */
+ exit (XARGS_EXIT_COMMAND_NOT_FOUND); /* command cannot be found */
}
else
{
- exit (XARGS_EXIT_COMMAND_CANNOT_BE_RUN); /* command cannot be run */
+ exit (XARGS_EXIT_COMMAND_CANNOT_BE_RUN); /* command cannot be run */
}
}
- else /* 0 == r => success */
+ else /* 0 == r => success */
{
/* Failed to read data from pipe; the exec must have
* succeeded. We call add_proc only in this case,
@@ -1484,7 +1484,8 @@ static void
exec_if_possible (void)
{
if (bc_ctl.replace_pat || initial_args ||
- bc_state.cmd_argc == bc_ctl.initial_argc || bc_ctl.exit_if_size_exceeded)
+ bc_state.cmd_argc == bc_ctl.initial_argc
+ || bc_ctl.exit_if_size_exceeded)
return;
bc_do_exec (&bc_ctl, &bc_state);
}
@@ -1507,8 +1508,8 @@ add_proc (pid_t pid)
pids = x2nrealloc (pids, &pids_alloc, sizeof *pids);
/* Zero out the new slots. */
- for (j=i; j<pids_alloc; ++j)
- pids[j] = (pid_t)0;
+ for (j = i; j < pids_alloc; ++j)
+ pids[j] = (pid_t) 0;
}
/* Verify that we are not destroying the record of some existing child. */
assert (0 == pids[i]);
@@ -1559,7 +1560,7 @@ wait_for_proc (bool all, unsigned int minreap)
* unlikely that that offers any portability advantage over
* wait these days.
*/
- while ((pid = waitpid (-1, &status, wflags)) == (pid_t) -1)
+ while ((pid = waitpid (-1, &status, wflags)) == (pid_t) - 1)
{
if (errno != EINTR)
error (EXIT_FAILURE, errno,
@@ -1624,19 +1625,22 @@ wait_for_proc (bool all, unsigned int minreap)
if (WEXITSTATUS (status) == CHILD_EXIT_PLEASE_STOP_IMMEDIATELY)
{
- error (0, 0, _("%s: exited with status 255; aborting"), bc_state.cmd_argv[0]);
- set_deferred_exit_status(XARGS_EXIT_CLIENT_EXIT_255);
+ error (0, 0, _("%s: exited with status 255; aborting"),
+ bc_state.cmd_argv[0]);
+ set_deferred_exit_status (XARGS_EXIT_CLIENT_EXIT_255);
}
if (WIFSTOPPED (status))
{
- error (0, 0, _("%s: stopped by signal %d"), bc_state.cmd_argv[0], WSTOPSIG (status));
- set_deferred_exit_status(XARGS_EXIT_CLIENT_FATAL_SIG);
+ error (0, 0, _("%s: stopped by signal %d"), bc_state.cmd_argv[0],
+ WSTOPSIG (status));
+ set_deferred_exit_status (XARGS_EXIT_CLIENT_FATAL_SIG);
}
if (WIFSIGNALED (status))
{
error (0, 0,
- _("%s: terminated by signal %d"), bc_state.cmd_argv[0], WTERMSIG (status));
- set_deferred_exit_status(XARGS_EXIT_CLIENT_FATAL_SIG);
+ _("%s: terminated by signal %d"), bc_state.cmd_argv[0],
+ WTERMSIG (status));
+ set_deferred_exit_status (XARGS_EXIT_CLIENT_FATAL_SIG);
}
if (WEXITSTATUS (status) != 0)
{
@@ -1649,7 +1653,9 @@ wait_for_proc (bool all, unsigned int minreap)
}
if (deferred_exit_status)
{
- child_error = deferred_exit_status > child_error ? deferred_exit_status : child_error;
+ child_error =
+ deferred_exit_status >
+ child_error ? deferred_exit_status : child_error;
exit (child_error);
}
}
@@ -1700,21 +1706,21 @@ wait_for_proc_all (void)
static void
increment_proc_max (int ignore)
{
- (void) ignore;
- /* If user increments from 0 to 1, we'll take it and serialize. */
- if (proc_max < MAX_PROC_MAX)
- proc_max++;
- /* If we're waiting for a process to die before doing something,
- no need to wait any more. */
- stop_waiting = 1;
+ (void) ignore;
+ /* If user increments from 0 to 1, we'll take it and serialize. */
+ if (proc_max < MAX_PROC_MAX)
+ proc_max++;
+ /* If we're waiting for a process to die before doing something,
+ no need to wait any more. */
+ stop_waiting = 1;
}
static void
decrement_proc_max (int ignore)
{
- (void) ignore;
- if (proc_max > 1)
- proc_max--;
+ (void) ignore;
+ if (proc_max > 1)
+ proc_max--;
}
@@ -1764,7 +1770,8 @@ usage (int status)
{
if (status != EXIT_SUCCESS)
{
- fprintf (stderr, _("Try '%s --help' for more information.\n"), program_name);
+ fprintf (stderr, _("Try '%s --help' for more information.\n"),
+ program_name);
exit (status);
}
@@ -1774,47 +1781,67 @@ usage (int status)
#define HTL(t) fputs (t, stdout);
- HTL (_("Run COMMAND with arguments INITIAL-ARGS and more arguments read from input.\n"
- "\n"));
- HTL (_("Mandatory and optional arguments to long options are also\n"
- "mandatory or optional for the corresponding short option.\n"));
- HTL (_(" -0, --null items are separated by a null, not whitespace;\n"
- " disables quote and backslash processing and\n"
- " logical EOF processing\n"));
- HTL (_(" -a, --arg-file=FILE read arguments from FILE, not standard input\n"));
- HTL (_(" -d, --delimiter=CHARACTER items in input stream are separated by CHARACTER,\n"
- " not by whitespace; disables quote and backslash\n"
- " processing and logical EOF processing\n"));
- HTL (_(" -E END set logical EOF string; if END occurs as a line\n"
- " of input, the rest of the input is ignored\n"
- " (ignored if -0 or -d was specified)\n"));
- HTL (_(" -e, --eof[=END] equivalent to -E END if END is specified;\n"
- " otherwise, there is no end-of-file string\n"));
+ HTL (_
+ ("Run COMMAND with arguments INITIAL-ARGS and more arguments read from input.\n"
+ "\n"));
+ HTL (_
+ ("Mandatory and optional arguments to long options are also\n"
+ "mandatory or optional for the corresponding short option.\n"));
+ HTL (_
+ (" -0, --null items are separated by a null, not whitespace;\n"
+ " disables quote and backslash processing and\n"
+ " logical EOF processing\n"));
+ HTL (_
+ (" -a, --arg-file=FILE read arguments from FILE, not standard input\n"));
+ HTL (_
+ (" -d, --delimiter=CHARACTER items in input stream are separated by CHARACTER,\n"
+ " not by whitespace; disables quote and backslash\n"
+ " processing and logical EOF processing\n"));
+ HTL (_
+ (" -E END set logical EOF string; if END occurs as a line\n"
+ " of input, the rest of the input is ignored\n"
+ " (ignored if -0 or -d was specified)\n"));
+ HTL (_
+ (" -e, --eof[=END] equivalent to -E END if END is specified;\n"
+ " otherwise, there is no end-of-file string\n"));
HTL (_(" -I R same as --replace=R\n"));
- HTL (_(" -i, --replace[=R] replace R in INITIAL-ARGS with names read\n"
- " from standard input, split at newlines;\n"
- " if R is unspecified, assume {}\n"));
- HTL (_(" -L, --max-lines=MAX-LINES use at most MAX-LINES non-blank input lines per\n"
- " command line\n"));
- HTL (_(" -l[MAX-LINES] similar to -L but defaults to at most one non-\n"
- " blank input line if MAX-LINES is not specified\n"));
- HTL (_(" -n, --max-args=MAX-ARGS use at most MAX-ARGS arguments per command line\n"));
- HTL (_(" -o, --open-tty Reopen standard input as /dev/tty in the child\n"
- " process before executing the command; useful to\n"
- " run an interactive application.\n"));
- HTL (_(" -P, --max-procs=MAX-PROCS run at most MAX-PROCS processes at a time\n"));
+ HTL (_
+ (" -i, --replace[=R] replace R in INITIAL-ARGS with names read\n"
+ " from standard input, split at newlines;\n"
+ " if R is unspecified, assume {}\n"));
+ HTL (_
+ (" -L, --max-lines=MAX-LINES use at most MAX-LINES non-blank input lines per\n"
+ " command line\n"));
+ HTL (_
+ (" -l[MAX-LINES] similar to -L but defaults to at most one non-\n"
+ " blank input line if MAX-LINES is not specified\n"));
+ HTL (_
+ (" -n, --max-args=MAX-ARGS use at most MAX-ARGS arguments per command line\n"));
+ HTL (_
+ (" -o, --open-tty Reopen standard input as /dev/tty in the child\n"
+ " process before executing the command; useful to\n"
+ " run an interactive application.\n"));
+ HTL (_
+ (" -P, --max-procs=MAX-PROCS run at most MAX-PROCS processes at a time\n"));
HTL (_(" -p, --interactive prompt before running commands\n"));
- HTL (_(" --process-slot-var=VAR set environment variable VAR in child processes\n"));
- HTL (_(" -r, --no-run-if-empty if there are no arguments, then do not run COMMAND;\n"
- " if this option is not given, COMMAND will be\n"
- " run at least once\n"));
- HTL (_(" -s, --max-chars=MAX-CHARS limit length of command line to MAX-CHARS\n"));
- HTL (_(" --show-limits show limits on command-line length\n"));
- HTL (_(" -t, --verbose print commands before executing them\n"));
- HTL (_(" -x, --exit exit if the size (see -s) is exceeded\n"));
+ HTL (_
+ (" --process-slot-var=VAR set environment variable VAR in child processes\n"));
+ HTL (_
+ (" -r, --no-run-if-empty if there are no arguments, then do not run COMMAND;\n"
+ " if this option is not given, COMMAND will be\n"
+ " run at least once\n"));
+ HTL (_
+ (" -s, --max-chars=MAX-CHARS limit length of command line to MAX-CHARS\n"));
+ HTL (_
+ (" --show-limits show limits on command-line length\n"));
+ HTL (_
+ (" -t, --verbose print commands before executing them\n"));
+ HTL (_
+ (" -x, --exit exit if the size (see -s) is exceeded\n"));
HTL (_(" --help display this help and exit\n"));
- HTL (_(" --version output version information and exit\n\n"));
+ HTL (_
+ (" --version output version information and exit\n\n"));
HTL (_("If COMMAND is omitted, the default is 'echo'.\n\n"));
explain_how_to_report_bugs (stdout, program_name);
exit (status);
--
2.47.3