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

From: Vasco Almeida <[email-masked]>
Date: Thu, 2 Jun 2016 09:28:41 +0000

Às 17:43 de 01-06-2016, Junio C Hamano escreveu:
> Vasco Almeida <[email-masked]> 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);