i18n: simplify numeric error reporting

Signed-off-by: Jean-Noel Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jean-Noel Avila committed Aug 21, 2016 at 16:50 UTC 078fe30523f6361849a895999c04cf5f377a1656
1 file changed +16 -28
config.c
+16 -28
@@ -652,46 +652,34 @@ int git_parse_ulong(const char *value, unsigned long *ret)
652 NORETURN
653 static void die_bad_number(const char *name, const char *value)
654 {
655 + const char * error_type = (errno == ERANGE)? _("out of range"):_("invalid unit");
656 +
657 if (!value)
658 value = "";
659
660 if (!(cf && cf->name))
659 - die(errno == ERANGE
660 - ? _("bad numeric config value '%s' for '%s': out of range")
661 - : _("bad numeric config value '%s' for '%s': invalid unit"),
662 - value, name);
661 + die(_("bad numeric config value '%s' for '%s': %s"),
662 + value, name, error_type);
663
664 switch (cf->origin_type) {
665 case CONFIG_ORIGIN_BLOB:
666 - die(errno == ERANGE
667 - ? _("bad numeric config value '%s' for '%s' in blob %s: out of range")
668 - : _("bad numeric config value '%s' for '%s' in blob %s: invalid unit"),
669 - value, name, cf->name);
666 + die(_("bad numeric config value '%s' for '%s' in blob %s: %s"),
667 + value, name, cf->name, error_type);
668 case CONFIG_ORIGIN_FILE:
671 - die(errno == ERANGE
672 - ? _("bad numeric config value '%s' for '%s' in file %s: out of range")
673 - : _("bad numeric config value '%s' for '%s' in file %s: invalid unit"),
674 - value, name, cf->name);
669 + die(_("bad numeric config value '%s' for '%s' in file %s: %s"),
670 + value, name, cf->name, error_type);
671 case CONFIG_ORIGIN_STDIN:
676 - die(errno == ERANGE
677 - ? _("bad numeric config value '%s' for '%s' in standard input: out of range")
678 - : _("bad numeric config value '%s' for '%s' in standard input: invalid unit"),
679 - value, name);
672 + die(_("bad numeric config value '%s' for '%s' in standard input: %s"),
673 + value, name, error_type);
674 case CONFIG_ORIGIN_SUBMODULE_BLOB:
681 - die(errno == ERANGE
682 - ? _("bad numeric config value '%s' for '%s' in submodule-blob %s: out of range")
683 - : _("bad numeric config value '%s' for '%s' in submodule-blob %s: invalid unit"),
684 - value, name, cf->name);
675 + die(_("bad numeric config value '%s' for '%s' in submodule-blob %s: %s"),
676 + value, name, cf->name, error_type);
677 case CONFIG_ORIGIN_CMDLINE:
686 - die(errno == ERANGE
687 - ? _("bad numeric config value '%s' for '%s' in command line %s: out of range")
688 - : _("bad numeric config value '%s' for '%s' in command line %s: invalid unit"),
689 - value, name, cf->name);
678 + die(_("bad numeric config value '%s' for '%s' in command line %s: %s"),
679 + value, name, cf->name, error_type);
680 default:
691 - die(errno == ERANGE
692 - ? _("bad numeric config value '%s' for '%s' in %s: out of range")
693 - : _("bad numeric config value '%s' for '%s' in %s: invalid unit"),
694 - value, name, cf->name);
681 + die(_("bad numeric config value '%s' for '%s' in %s: %s"),
682 + value, name, cf->name, error_type);
683 }
684 }
685