Thread (1 message) 1 message, 1 author, 2016-06-16

Re: [PATCH v3 28/39] i18n: config: unfold error messages marked for translation

From: Junio C Hamano <hidden>
Date: 2016-06-16 02:19:42

Vasco Almeida [off-list ref] writes:
Às 17:43 de 01-06-2016, Junio C Hamano escreveu:
quoted
Vasco Almeida [off-list ref] writes:
quoted
Introduced in 473166b ("config: add 'origin_type' to config_source
struct", 2016-02-19), Git can inform the user about the origin of a
config error, but the implementation does not allow translators to
translate the keywords 'file', 'blob, 'standard input', and
'submodule-blob'. Moreover, for the second message, a reason for the
error is appended to the message, not allowing translators to translate
that reason either.
Good intentions.
quoted
@@ -417,6 +417,7 @@ static int git_parse_source(config_fn_t fn, void *data)
 	int comment = 0;
 	int baselen = 0;
 	struct strbuf *var = &cf->var;
+	char error_msg[128];
 
 	/* U+FEFF Byte Order Mark in UTF8 */
 	const char *bomptr = utf8_bom;
@@ -471,10 +472,38 @@ static int git_parse_source(config_fn_t fn, void *data)
 		if (get_value(fn, data, var) < 0)
 			break;
 	}
+
+	switch (cf->origin_type) {
+	case CFG_BLOB:
+		xsnprintf(error_msg, sizeof(error_msg),
+			  _("bad config line %d in blob %s"),
+			  cf->linenr, cf->name);
Use xstrfmt() intead, perhaps?  That would be cleaner.
Wouldn't that create a memory leak?
Yes, I didn't mean to suggest "use xstrfmt() instead of xsnprintf()
without changing anything else".  It was merely to suggest that you
do not have to have 128-byte limit if you used xstrfmt(); having to
free the result was too obvious that I left it unsaid, and as expected,
you noticed the need to do so, which is good ;-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help