mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
(translate_file): refactoring.
Allocate buffer only if charset converter is created successfully. g_string_free() returns NULL if second argument is TRUE. Use that to get rig of 'if' statement. Reduce variable scope. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
a6c142ed48
commit
5b4ec9b033
24
src/help.c
24
src/help.c
@ -940,26 +940,20 @@ static void
|
||||
translate_file (char *filedata)
|
||||
{
|
||||
GIConv conv;
|
||||
GString *translated_data;
|
||||
|
||||
/* initial allocation for largest whole help file */
|
||||
translated_data = g_string_sized_new (32 * 1024);
|
||||
|
||||
conv = str_crt_conv_from ("UTF-8");
|
||||
|
||||
if (conv == INVALID_CONV)
|
||||
g_string_free (translated_data, TRUE);
|
||||
else
|
||||
if (conv != INVALID_CONV)
|
||||
{
|
||||
GString *translated_data;
|
||||
gboolean nok;
|
||||
|
||||
g_free (fdata);
|
||||
|
||||
if (str_convert (conv, filedata, translated_data) != ESTR_FAILURE)
|
||||
fdata = g_string_free (translated_data, FALSE);
|
||||
else
|
||||
{
|
||||
fdata = NULL;
|
||||
g_string_free (translated_data, TRUE);
|
||||
}
|
||||
/* initial allocation for largest whole help file */
|
||||
translated_data = g_string_sized_new (32 * 1024);
|
||||
nok = (str_convert (conv, filedata, translated_data) == ESTR_FAILURE);
|
||||
fdata = g_string_free (translated_data, nok);
|
||||
|
||||
str_close_conv (conv);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user