diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-10-06 12:56:39 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-10-06 12:57:39 -0400 |
commit | 0a0dc74b9103d757bf5c2cd2b8c14e5b825b232a (patch) | |
tree | 5b87c6ec4e5865890b76f4f5aa439b2ca8f27a36 | |
parent | 1312165d6501c02406b33eba8a3daf78e8938b9a (diff) | |
download | bfs-0a0dc74b9103d757bf5c2cd2b8c14e5b825b232a.tar.xz |
printf: Adjust some calling conventions
-rw-r--r-- | parse.c | 6 | ||||
-rw-r--r-- | printf.c | 18 | ||||
-rw-r--r-- | printf.h | 20 |
3 files changed, 22 insertions, 22 deletions
@@ -110,7 +110,7 @@ void free_expr(struct expr *expr) { free(expr->regex); } - free_bfs_printf(expr->printf); + bfs_printf_free(expr->printf); free_bfs_exec(expr->execbuf); free_expr(expr->lhs); @@ -1272,7 +1272,7 @@ static struct expr *parse_fprintf(struct parser_state *state, int arg1, int arg2 goto fail; } - expr->printf = parse_bfs_printf(format, state->ctx); + expr->printf = bfs_printf_parse(state->ctx, format); if (!expr->printf) { goto fail; } @@ -2010,7 +2010,7 @@ static struct expr *parse_printf(struct parser_state *state, int arg1, int arg2) init_print_expr(state, expr); - expr->printf = parse_bfs_printf(expr->sdata, state->ctx); + expr->printf = bfs_printf_parse(state->ctx, expr->sdata); if (!expr->printf) { free_expr(expr); return NULL; @@ -550,7 +550,7 @@ static struct bfs_printf **append_literal(struct bfs_printf **tail, struct bfs_p } } -struct bfs_printf *parse_bfs_printf(const char *format, struct bfs_ctx *ctx) { +struct bfs_printf *bfs_printf_parse(const struct bfs_ctx *ctx, const char *format) { struct bfs_printf *head = NULL; struct bfs_printf **tail = &head; @@ -853,14 +853,14 @@ done: error: free_directive(literal); - free_bfs_printf(head); + bfs_printf_free(head); return NULL; } -int bfs_printf(FILE *file, const struct bfs_printf *command, const struct BFTW *ftwbuf) { +int bfs_printf(FILE *file, const struct bfs_printf *format, const struct BFTW *ftwbuf) { int ret = 0, error = 0; - for (const struct bfs_printf *directive = command; directive; directive = directive->next) { + for (const struct bfs_printf *directive = format; directive; directive = directive->next) { if (directive->fn(file, directive, ftwbuf) < 0) { ret = -1; error = errno; @@ -871,10 +871,10 @@ int bfs_printf(FILE *file, const struct bfs_printf *command, const struct BFTW * return ret; } -void free_bfs_printf(struct bfs_printf *command) { - while (command) { - struct bfs_printf *next = command->next; - free_directive(command); - command = next; +void bfs_printf_free(struct bfs_printf *format) { + while (format) { + struct bfs_printf *next = format->next; + free_directive(format); + format = next; } } @@ -21,11 +21,12 @@ #ifndef BFS_PRINTF_H #define BFS_PRINTF_H -#include "bftw.h" -#include "ctx.h" #include <stdbool.h> #include <stdio.h> +struct BFTW; +struct bfs_ctx; + /** * A printf command, the result of parsing a single format string. */ @@ -34,33 +35,32 @@ struct bfs_printf; /** * Parse a -printf format string. * - * @param format - * The format string to parse. * @param ctx * The bfs context. + * @param format + * The format string to parse. * @return * The parsed printf command, or NULL on failure. */ -struct bfs_printf *parse_bfs_printf(const char *format, struct bfs_ctx *ctx); +struct bfs_printf *bfs_printf_parse(const struct bfs_ctx *ctx, const char *format); /** * Evaluate a parsed format string. * * @param file * The FILE to print to. - * @param command + * @param format * The parsed printf format. * @param ftwbuf - * The bftw() data for the current file. If needs_stat is true, statbuf - * must be non-NULL. + * The bftw() data for the current file. * @return * 0 on success, -1 on failure. */ -int bfs_printf(FILE *file, const struct bfs_printf *command, const struct BFTW *ftwbuf); +int bfs_printf(FILE *file, const struct bfs_printf *format, const struct BFTW *ftwbuf); /** * Free a parsed format string. */ -void free_bfs_printf(struct bfs_printf *command); +void bfs_printf_free(struct bfs_printf *format); #endif // BFS_PRINTF_H |