i18n: simplify numeric error reporting
Signed-off-by: Jean-Noel Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
8aa6dc1d9e
commit
078fe30523
44
config.c
44
config.c
|
@ -652,46 +652,34 @@ int git_parse_ulong(const char *value, unsigned long *ret)
|
||||||
NORETURN
|
NORETURN
|
||||||
static void die_bad_number(const char *name, const char *value)
|
static void die_bad_number(const char *name, const char *value)
|
||||||
{
|
{
|
||||||
|
const char * error_type = (errno == ERANGE)? _("out of range"):_("invalid unit");
|
||||||
|
|
||||||
if (!value)
|
if (!value)
|
||||||
value = "";
|
value = "";
|
||||||
|
|
||||||
if (!(cf && cf->name))
|
if (!(cf && cf->name))
|
||||||
die(errno == ERANGE
|
die(_("bad numeric config value '%s' for '%s': %s"),
|
||||||
? _("bad numeric config value '%s' for '%s': out of range")
|
value, name, error_type);
|
||||||
: _("bad numeric config value '%s' for '%s': invalid unit"),
|
|
||||||
value, name);
|
|
||||||
|
|
||||||
switch (cf->origin_type) {
|
switch (cf->origin_type) {
|
||||||
case CONFIG_ORIGIN_BLOB:
|
case CONFIG_ORIGIN_BLOB:
|
||||||
die(errno == ERANGE
|
die(_("bad numeric config value '%s' for '%s' in blob %s: %s"),
|
||||||
? _("bad numeric config value '%s' for '%s' in blob %s: out of range")
|
value, name, cf->name, error_type);
|
||||||
: _("bad numeric config value '%s' for '%s' in blob %s: invalid unit"),
|
|
||||||
value, name, cf->name);
|
|
||||||
case CONFIG_ORIGIN_FILE:
|
case CONFIG_ORIGIN_FILE:
|
||||||
die(errno == ERANGE
|
die(_("bad numeric config value '%s' for '%s' in file %s: %s"),
|
||||||
? _("bad numeric config value '%s' for '%s' in file %s: out of range")
|
value, name, cf->name, error_type);
|
||||||
: _("bad numeric config value '%s' for '%s' in file %s: invalid unit"),
|
|
||||||
value, name, cf->name);
|
|
||||||
case CONFIG_ORIGIN_STDIN:
|
case CONFIG_ORIGIN_STDIN:
|
||||||
die(errno == ERANGE
|
die(_("bad numeric config value '%s' for '%s' in standard input: %s"),
|
||||||
? _("bad numeric config value '%s' for '%s' in standard input: out of range")
|
value, name, error_type);
|
||||||
: _("bad numeric config value '%s' for '%s' in standard input: invalid unit"),
|
|
||||||
value, name);
|
|
||||||
case CONFIG_ORIGIN_SUBMODULE_BLOB:
|
case CONFIG_ORIGIN_SUBMODULE_BLOB:
|
||||||
die(errno == ERANGE
|
die(_("bad numeric config value '%s' for '%s' in submodule-blob %s: %s"),
|
||||||
? _("bad numeric config value '%s' for '%s' in submodule-blob %s: out of range")
|
value, name, cf->name, error_type);
|
||||||
: _("bad numeric config value '%s' for '%s' in submodule-blob %s: invalid unit"),
|
|
||||||
value, name, cf->name);
|
|
||||||
case CONFIG_ORIGIN_CMDLINE:
|
case CONFIG_ORIGIN_CMDLINE:
|
||||||
die(errno == ERANGE
|
die(_("bad numeric config value '%s' for '%s' in command line %s: %s"),
|
||||||
? _("bad numeric config value '%s' for '%s' in command line %s: out of range")
|
value, name, cf->name, error_type);
|
||||||
: _("bad numeric config value '%s' for '%s' in command line %s: invalid unit"),
|
|
||||||
value, name, cf->name);
|
|
||||||
default:
|
default:
|
||||||
die(errno == ERANGE
|
die(_("bad numeric config value '%s' for '%s' in %s: %s"),
|
||||||
? _("bad numeric config value '%s' for '%s' in %s: out of range")
|
value, name, cf->name, error_type);
|
||||||
: _("bad numeric config value '%s' for '%s' in %s: invalid unit"),
|
|
||||||
value, name, cf->name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue