From 035dbc05163f897ad74487afbb9d6c778b683b61 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 4 Feb 2016 12:40:43 -0500 Subject: Don't use typedefs to avoid struct/enum tags. --- bfs.h | 88 +++++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 43 insertions(+), 45 deletions(-) (limited to 'bfs.h') diff --git a/bfs.h b/bfs.h index a8efffb..15f25ee 100644 --- a/bfs.h +++ b/bfs.h @@ -17,20 +17,15 @@ #include #include -/** - * The parsed command line. - */ -typedef struct cmdline cmdline; - /** * A command line expression. */ -typedef struct expression expression; +struct expr; /** * Ephemeral state for evaluating an expression. */ -typedef struct eval_state eval_state; +struct eval_state; /** * Expression evaluation function. @@ -42,8 +37,11 @@ typedef struct eval_state eval_state; * @return * The result of the test. */ -typedef bool eval_fn(const expression *expr, eval_state *state); +typedef bool eval_fn(const struct expr *expr, struct eval_state *state); +/** + * The parsed command line. + */ struct cmdline { /** The array of paths to start from. */ const char **roots; @@ -51,7 +49,7 @@ struct cmdline { size_t nroots; /** Color data. */ - color_table *colors; + struct color_table *colors; /** -color option. */ bool color; @@ -64,7 +62,7 @@ struct cmdline { int flags; /** The command line expression. */ - expression *expr; + struct expr *expr; /** The current time. */ struct timespec now; @@ -73,24 +71,24 @@ struct cmdline { /** * Possible types of numeric comparison. */ -typedef enum { +enum cmpflag { /** Exactly n. */ CMP_EXACT, /** Less than n. */ CMP_LESS, /** Greater than n. */ CMP_GREATER, -} cmpflag; +}; -struct expression { +struct expr { /** The left hand side of the expression. */ - expression *lhs; + struct expr *lhs; /** The right hand side of the expression. */ - expression *rhs; + struct expr *rhs; /** The function that evaluates this expression. */ eval_fn *eval; /** The comparison flag. */ - cmpflag cmp; + enum cmpflag cmp; /** Optional integer data for this expression. */ int idata; /** Optional string data for this expression. */ @@ -100,52 +98,52 @@ struct expression { /** * Parse the command line. */ -cmdline *parse_cmdline(int argc, char *argv[]); +struct cmdline *parse_cmdline(int argc, char *argv[]); /** * Evaluate the command line. */ -int eval_cmdline(cmdline *cl); +int eval_cmdline(struct cmdline *cl); /** * Free the parsed command line. */ -void free_cmdline(cmdline *cl); +void free_cmdline(struct cmdline *cl); // Predicate evaluation functions -bool eval_true(const expression *expr, eval_state *state); -bool eval_false(const expression *expr, eval_state *state); +bool eval_true(const struct expr *expr, struct eval_state *state); +bool eval_false(const struct expr *expr, struct eval_state *state); -bool eval_access(const expression *expr, eval_state *state); +bool eval_access(const struct expr *expr, struct eval_state *state); -bool eval_amin(const expression *expr, eval_state *state); -bool eval_atime(const expression *expr, eval_state *state); -bool eval_cmin(const expression *expr, eval_state *state); -bool eval_ctime(const expression *expr, eval_state *state); -bool eval_mmin(const expression *expr, eval_state *state); -bool eval_mtime(const expression *expr, eval_state *state); +bool eval_amin(const struct expr *expr, struct eval_state *state); +bool eval_atime(const struct expr *expr, struct eval_state *state); +bool eval_cmin(const struct expr *expr, struct eval_state *state); +bool eval_ctime(const struct expr *expr, struct eval_state *state); +bool eval_mmin(const struct expr *expr, struct eval_state *state); +bool eval_mtime(const struct expr *expr, struct eval_state *state); -bool eval_gid(const expression *expr, eval_state *state); -bool eval_uid(const expression *expr, eval_state *state); +bool eval_gid(const struct expr *expr, struct eval_state *state); +bool eval_uid(const struct expr *expr, struct eval_state *state); -bool eval_empty(const expression *expr, eval_state *state); -bool eval_hidden(const expression *expr, eval_state *state); -bool eval_type(const expression *expr, eval_state *state); +bool eval_empty(const struct expr *expr, struct eval_state *state); +bool eval_hidden(const struct expr *expr, struct eval_state *state); +bool eval_type(const struct expr *expr, struct eval_state *state); -bool eval_name(const expression *expr, eval_state *state); -bool eval_path(const expression *expr, eval_state *state); +bool eval_name(const struct expr *expr, struct eval_state *state); +bool eval_path(const struct expr *expr, struct eval_state *state); -bool eval_delete(const expression *expr, eval_state *state); -bool eval_nohidden(const expression *expr, eval_state *state); -bool eval_print(const expression *expr, eval_state *state); -bool eval_print0(const expression *expr, eval_state *state); -bool eval_prune(const expression *expr, eval_state *state); -bool eval_quit(const expression *expr, eval_state *state); +bool eval_delete(const struct expr *expr, struct eval_state *state); +bool eval_nohidden(const struct expr *expr, struct eval_state *state); +bool eval_print(const struct expr *expr, struct eval_state *state); +bool eval_print0(const struct expr *expr, struct eval_state *state); +bool eval_prune(const struct expr *expr, struct eval_state *state); +bool eval_quit(const struct expr *expr, struct eval_state *state); // Operator evaluation functions -bool eval_not(const expression *expr, eval_state *state); -bool eval_and(const expression *expr, eval_state *state); -bool eval_or(const expression *expr, eval_state *state); -bool eval_comma(const expression *expr, eval_state *state); +bool eval_not(const struct expr *expr, struct eval_state *state); +bool eval_and(const struct expr *expr, struct eval_state *state); +bool eval_or(const struct expr *expr, struct eval_state *state); +bool eval_comma(const struct expr *expr, struct eval_state *state); #endif // BFS_H -- cgit v1.2.3