mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Merge branch 'jk/report-fn-typedef'
Code clean-up. * jk/report-fn-typedef: usage: define a type for a reporting function
This commit is contained in:
commit
01194384d6
|
@ -489,11 +489,13 @@ static inline int const_error(void)
|
|||
#define error_errno(...) (error_errno(__VA_ARGS__), const_error())
|
||||
#endif
|
||||
|
||||
void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
|
||||
void set_error_routine(void (*routine)(const char *err, va_list params));
|
||||
extern void (*get_error_routine(void))(const char *err, va_list params);
|
||||
void set_warn_routine(void (*routine)(const char *warn, va_list params));
|
||||
extern void (*get_warn_routine(void))(const char *warn, va_list params);
|
||||
typedef void (*report_fn)(const char *, va_list params);
|
||||
|
||||
void set_die_routine(NORETURN_PTR report_fn routine);
|
||||
void set_error_routine(report_fn routine);
|
||||
report_fn get_error_routine(void);
|
||||
void set_warn_routine(report_fn routine);
|
||||
report_fn get_warn_routine(void);
|
||||
void set_die_is_recursing_routine(int (*routine)(void));
|
||||
|
||||
int starts_with(const char *str, const char *prefix);
|
||||
|
|
18
usage.c
18
usage.c
|
@ -108,33 +108,33 @@ static int die_is_recursing_builtin(void)
|
|||
|
||||
/* If we are in a dlopen()ed .so write to a global variable would segfault
|
||||
* (ugh), so keep things static. */
|
||||
static NORETURN_PTR void (*usage_routine)(const char *err, va_list params) = usage_builtin;
|
||||
static NORETURN_PTR void (*die_routine)(const char *err, va_list params) = die_builtin;
|
||||
static void (*error_routine)(const char *err, va_list params) = error_builtin;
|
||||
static void (*warn_routine)(const char *err, va_list params) = warn_builtin;
|
||||
static NORETURN_PTR report_fn usage_routine = usage_builtin;
|
||||
static NORETURN_PTR report_fn die_routine = die_builtin;
|
||||
static report_fn error_routine = error_builtin;
|
||||
static report_fn warn_routine = warn_builtin;
|
||||
static int (*die_is_recursing)(void) = die_is_recursing_builtin;
|
||||
|
||||
void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params))
|
||||
void set_die_routine(NORETURN_PTR report_fn routine)
|
||||
{
|
||||
die_routine = routine;
|
||||
}
|
||||
|
||||
void set_error_routine(void (*routine)(const char *err, va_list params))
|
||||
void set_error_routine(report_fn routine)
|
||||
{
|
||||
error_routine = routine;
|
||||
}
|
||||
|
||||
void (*get_error_routine(void))(const char *err, va_list params)
|
||||
report_fn get_error_routine(void)
|
||||
{
|
||||
return error_routine;
|
||||
}
|
||||
|
||||
void set_warn_routine(void (*routine)(const char *warn, va_list params))
|
||||
void set_warn_routine(report_fn routine)
|
||||
{
|
||||
warn_routine = routine;
|
||||
}
|
||||
|
||||
void (*get_warn_routine(void))(const char *warn, va_list params)
|
||||
report_fn get_warn_routine(void)
|
||||
{
|
||||
return warn_routine;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue