mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-11 18:32:53 +03:00
Ticket #3783: mcview: fix interpretation of invalid utf-8 symbols.
(mcview_get_utf): report invalid utf-8 as negative integer. The bug was introduced in 4d65a731c28d53a536a044a85e82223a7aa46bd5. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
cea0973393
commit
5e238fae95
@ -341,6 +341,8 @@ mcview_char_display (const WView * view, int c, char *s)
|
|||||||
* Normally: stores c, updates state, returns TRUE.
|
* Normally: stores c, updates state, returns TRUE.
|
||||||
* At EOF: state is unchanged, c is undefined, returns FALSE.
|
* At EOF: state is unchanged, c is undefined, returns FALSE.
|
||||||
*
|
*
|
||||||
|
* Just as with mcview_get_utf(), invalid UTF-8 is reported using negative integers.
|
||||||
|
*
|
||||||
* Also, temporary hack: handle force_max here.
|
* Also, temporary hack: handle force_max here.
|
||||||
* TODO: move it to lower layers (datasource.c)?
|
* TODO: move it to lower layers (datasource.c)?
|
||||||
*/
|
*/
|
||||||
|
@ -147,6 +147,8 @@ mcview_get_ptr_file (WView * view, off_t byte_index)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* Invalid UTF-8 is reported as negative integers (one for each byte),
|
||||||
|
* see ticket 3783. */
|
||||||
gboolean
|
gboolean
|
||||||
mcview_get_utf (WView * view, off_t byte_index, int *ch, int *ch_len)
|
mcview_get_utf (WView * view, off_t byte_index, int *ch, int *ch_len)
|
||||||
{
|
{
|
||||||
@ -200,7 +202,8 @@ mcview_get_utf (WView * view, off_t byte_index, int *ch, int *ch_len)
|
|||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
*ch = (unsigned char) (*str);
|
/* Implicit conversion from signed char to signed int keeps negative values. */
|
||||||
|
*ch = *str;
|
||||||
*ch_len = 1;
|
*ch_len = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user