Skip to content

Commit

Permalink
move {errorf,warnf}_low common logic to a func
Browse files Browse the repository at this point in the history
Ref: #250 (comment)
Suggested-by: Jacob Mealey
Closes #xxx
  • Loading branch information
vszakats committed Nov 14, 2023
1 parent af2d476 commit c31f64f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,17 @@ static char *curl_url_strerror(CURLUcode error)
}
#endif

static void warnf_low(const char *fmt, va_list ap)
static void message_low(const char *prefix, const char *suffix,
const char *fmt, va_list ap)
{
fputs(WARN_PREFIX, stderr);
fputs(prefix, stderr);
vfprintf(stderr, fmt, ap);
fputs("\n", stderr);
fputs(suffix, stderr);
}

static void warnf_low(const char *fmt, va_list ap)
{
message_low(WARN_PREFIX, "\n", fmt, ap);
}

static void warnf(const char *fmt, ...)
Expand Down Expand Up @@ -295,9 +301,8 @@ static void trurl_cleanup_options(struct option *o)

static void errorf_low(const char *fmt, va_list ap)
{
fputs(ERROR_PREFIX, stderr);
vfprintf(stderr, fmt, ap);
fputs("\n" ERROR_PREFIX "Try " PROGNAME " -h for help\n", stderr);
message_low(ERROR_PREFIX, "\n"
ERROR_PREFIX "Try " PROGNAME " -h for help\n", fmt, ap);
}

static void errorf(struct option *o, int exit_code, const char *fmt, ...)
Expand Down

0 comments on commit c31f64f

Please sign in to comment.