Ticket #256: 00-79-utf8-backward-word-off-by-one.patch

File 00-79-utf8-backward-word-off-by-one.patch, 950 bytes (added by egmont, 11 years ago)

Fix for the bug.

  • src/widget.c

    Fix off-by-one misbehavior of Ctrl-Left and Alt-Backspace.
    
    diff -Naurdp mc-4.6.1.orig/src/widget.c mc-4.6.1/src/widget.c
    old new backward_word (WInput *in) 
    13851385    memset (&mbs, 0, sizeof (mbs)); 
    13861386    while (in->point > 0) { 
    13871387      wchar_t c; 
    1388       char *p = in->buffer + charpos(in,in->point); 
     1388      char *p = in->buffer + charpos(in,in->point-1); 
    13891389      size_t res = mbrtowc(&c, p, strlen(p), &mbs); 
    13901390      if (*p && (res <= 0 || !(iswspace (c) || iswpunct (c)))) 
    13911391          break; 
    backward_word (WInput *in) 
    13961396 
    13971397    while (in->point > 0) { 
    13981398      wchar_t c; 
    1399       char *p = in->buffer + charpos(in,in->point); 
     1399      char *p = in->buffer + charpos(in,in->point-1); 
    14001400      size_t res = mbrtowc(&c, p, strlen(p), &mbs); 
    14011401      if (*p && (res <= 0 || !iswalnum (c))) 
    14021402          break;