mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
![Junio C Hamano](/assets/img/avatar_default.png)
This attempts to clean up the way various compatibility functions are defined and used. - A new header file, git-compat-util.h, is introduced. This looks at various NO_XXX and does necessary function name replacements, equivalent of -Dstrcasestr=gitstrcasestr in the Makefile. - Those function name replacements are removed from the Makefile. - Common features such as usage(), die(), xmalloc() are moved from cache.h to git-compat-util.h; cache.h includes git-compat-util.h itself. Signed-off-by: Junio C Hamano <junkio@cox.net>
40 lines
639 B
C
40 lines
639 B
C
/*
|
|
* GIT - The information manager from hell
|
|
*
|
|
* Copyright (C) Linus Torvalds, 2005
|
|
*/
|
|
#include "git-compat-util.h"
|
|
|
|
static void report(const char *prefix, const char *err, va_list params)
|
|
{
|
|
fputs(prefix, stderr);
|
|
vfprintf(stderr, err, params);
|
|
fputs("\n", stderr);
|
|
}
|
|
|
|
void usage(const char *err)
|
|
{
|
|
fprintf(stderr, "usage: %s\n", err);
|
|
exit(129);
|
|
}
|
|
|
|
void die(const char *err, ...)
|
|
{
|
|
va_list params;
|
|
|
|
va_start(params, err);
|
|
report("fatal: ", err, params);
|
|
va_end(params);
|
|
exit(128);
|
|
}
|
|
|
|
int error(const char *err, ...)
|
|
{
|
|
va_list params;
|
|
|
|
va_start(params, err);
|
|
report("error: ", err, params);
|
|
va_end(params);
|
|
return -1;
|
|
}
|