Ticket #2372: mc-4.7.5.5-mceditutf8fix.patch

File mc-4.7.5.5-mceditutf8fix.patch, 862 bytes (added by sergem, 13 years ago)

simplified version of the 2372_fix.diff, cosmetics

  • src/editor/edit.c

    diff -urN mc-4.7.5.5.orig/src/editor/edit.c mc-4.7.5.5/src/editor/edit.c
    old new  
    16841684    gunichar ch; 
    16851685    gchar *next_ch = NULL; 
    16861686    int width = 0; 
     1687    gchar utf8buf[6 + 1]; 
    16871688 
    16881689    if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0) 
    16891690    { 
     
    17011702 
    17021703    res = g_utf8_get_char_validated (str, -1); 
    17031704 
     1705    if (res < 0) 
     1706    { 
     1707        /* Retry with explicit bytes to make sure it's not a buffer boundary */ 
     1708        int i; 
     1709        for (i = 0; i < 6; i++) 
     1710            utf8buf[i] = edit_get_byte (edit, byte_index + i); 
     1711        utf8buf[6] = '\0'; 
     1712        str = utf8buf; 
     1713        res = g_utf8_get_char_validated (str, -1); 
     1714    } 
     1715 
    17041716    if (res < 0) 
    17051717    { 
    17061718        ch = *str;