mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Fixed return codes for mcview_get_utf() function
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
c1aae6cb4e
commit
79660a7588
@ -164,9 +164,9 @@ mcview_get_utf (mcview_t * view, off_t byte_index, int *char_width, gboolean * r
|
|||||||
int res = -1;
|
int res = -1;
|
||||||
gunichar ch;
|
gunichar ch;
|
||||||
gchar *next_ch = NULL;
|
gchar *next_ch = NULL;
|
||||||
int width = 0;
|
|
||||||
|
|
||||||
*result = TRUE;
|
*char_width = 0;
|
||||||
|
*result = FALSE;
|
||||||
|
|
||||||
switch (view->datasource)
|
switch (view->datasource)
|
||||||
{
|
{
|
||||||
@ -185,18 +185,14 @@ mcview_get_utf (mcview_t * view, off_t byte_index, int *char_width, gboolean * r
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
{
|
|
||||||
*result = FALSE;
|
|
||||||
width = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
res = g_utf8_get_char_validated (str, -1);
|
res = g_utf8_get_char_validated (str, -1);
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
ch = *str;
|
ch = *str;
|
||||||
width = 0;
|
*char_width = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -204,16 +200,11 @@ mcview_get_utf (mcview_t * view, off_t byte_index, int *char_width, gboolean * r
|
|||||||
/* Calculate UTF-8 char width */
|
/* Calculate UTF-8 char width */
|
||||||
next_ch = g_utf8_next_char (str);
|
next_ch = g_utf8_next_char (str);
|
||||||
if (next_ch)
|
if (next_ch)
|
||||||
{
|
*char_width = next_ch - str;
|
||||||
width = next_ch - str;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
return 0;
|
||||||
ch = 0;
|
|
||||||
width = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*char_width = width;
|
*result = TRUE;
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user