Re: [PATCH v3 28/39] i18n: config: unfold error messages marked for translation
- From
Vasco Almeida <vascomalmeida@sapo.pt>
- Date
- Jun 2, 2016, 09:28 UTC
- Message-ID
- <574FFC49.9040409@sapo.pt>
- In-Reply-To
- <xmqqzir4yfcq.fsf@gitster.mtv.corp.google.com>
Às 17:43 de 01-06-2016, Junio C Hamano escreveu:
Show 33 quoted lines
> Vasco Almeida <vascomalmeida@sapo.pt> writes:
>
>> 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.
>
>> @@ -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? Because, in this patch, error_msg is used in the following way
if (cf->die_on_error)
die(error_msg);
else
return error(error_msg);