git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] i18n: simplify numeric error reporting

From
Jean-Noel Avila <jn.avila@free.fr>
Date
Aug 21, 2016, 14:50 UTC
Message-ID
<20160821145039.12121-3-jn.avila@free.fr>
In-Reply-To
<20160821145039.12121-1-jn.avila@free.fr>
Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
---
 config.c | 43 +++++++++++++++----------------------------
 1 file changed, 15 insertions(+), 28 deletions(-)
diff --git a/config.c b/config.c
index 584cacf..e33c703 100644
--- a/config.c
+++ b/config.c
@@ -655,43 +655,30 @@ static void die_bad_number(const char *name, const char *value)
 	if (!value)
 		value = "";
 
+	const char * error_type = (errno == ERANGE)? _("out of range"):_("invalid unit");
 	if (!(cf && cf->name))
-		die(errno == ERANGE
-		    ? _("bad numeric config value '%s' for '%s': out of range")
-		    : _("bad numeric config value '%s' for '%s': invalid unit"),
-		    value, name);
+		die(_("bad numeric config value '%s' for '%s': %s"),
+		    value, name, error_type);
 
 	switch (cf->origin_type) {
 	case CONFIG_ORIGIN_BLOB:
-		die(errno == ERANGE
-		    ? _("bad numeric config value '%s' for '%s' in blob %s: out of range")
-		    : _("bad numeric config value '%s' for '%s' in blob %s: invalid unit"),
-		    value, name, cf->name);
+		die(_("bad numeric config value '%s' for '%s' in blob %s: %s"),
+		    value, name, cf->name, error_type);
 	case CONFIG_ORIGIN_FILE:
-		die(errno == ERANGE
-		    ? _("bad numeric config value '%s' for '%s' in file %s: out of range")
-		    : _("bad numeric config value '%s' for '%s' in file %s: invalid unit"),
-		    value, name, cf->name);
+		die(_("bad numeric config value '%s' for '%s' in file %s: %s"),
+		    value, name, cf->name, error_type);
 	case CONFIG_ORIGIN_STDIN:
-		die(errno == ERANGE
-		    ? _("bad numeric config value '%s' for '%s' in standard input: out of range")
-		    : _("bad numeric config value '%s' for '%s' in standard input: invalid unit"),
-		    value, name);
+		die(_("bad numeric config value '%s' for '%s' in standard input: %s"),
+		    value, name, error_type);
 	case CONFIG_ORIGIN_SUBMODULE_BLOB:
-		die(errno == ERANGE
-		    ? _("bad numeric config value '%s' for '%s' in submodule-blob %s: out of range")
-		    : _("bad numeric config value '%s' for '%s' in submodule-blob %s: invalid unit"),
-		    value, name, cf->name);
+		die(_("bad numeric config value '%s' for '%s' in submodule-blob %s: %s"),
+		    value, name, cf->name, error_type);
 	case CONFIG_ORIGIN_CMDLINE:
-		die(errno == ERANGE
-		    ? _("bad numeric config value '%s' for '%s' in command line %s: out of range")
-		    : _("bad numeric config value '%s' for '%s' in command line %s: invalid unit"),
-		    value, name, cf->name);
+		die(_("bad numeric config value '%s' for '%s' in command line %s: %s"),
+		    value, name, cf->name, error_type);
 	default:
-		die(errno == ERANGE
-		    ? _("bad numeric config value '%s' for '%s' in %s: out of range")
-		    : _("bad numeric config value '%s' for '%s' in %s: invalid unit"),
-		    value, name, cf->name);
+		die(_("bad numeric config value '%s' for '%s' in %s: %s"),
+		    value, name, cf->name, error_type);
 	}
 }
 
-- 
2.10.0.rc0.37.gd7d1c14.dirty
Previous: Jean-Noel AvilaNext: Junio C Hamano
Message 10 of 15 in “[L10N] Kickoff of translation for Git 2.10.0 round 1”
  1. Jiang XinAug 15, 2016
  2. Jean-Noël AVILAAug 20, 2016
  3. Junio C HamanoAug 20, 2016
  4. Jean-Noël AVILAAug 20, 2016
  5. Jiang XinAug 21, 2016
  6. Junio C HamanoAug 23, 2016
  7. Jean-Noël AVILAAug 23, 2016
  8. 1/3 i18n: fix typos for translationJean-Noel Avila, Aug 21, 2016
  9. 2/3 i18n: fix git rebase interactive commit messagesJean-Noel Avila, Aug 21, 2016
  10. 3/3 i18n: simplify numeric error reportingJean-Noel Avila, Aug 21, 2016
  11. Junio C HamanoAug 24, 2016
  12. Junio C HamanoAug 23, 2016
  13. Junio C HamanoAug 24, 2016
  14. Junio C HamanoAug 24, 2016
  15. Alex HenrieAug 25, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.