To: vim_dev@googlegroups.com Subject: Patch 7.4.2222 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2222 Problem: Sourcing a script where a character has 0x80 as a second byte does not work. (Filipe L B Correia) Solution: Turn 0x80 into K_SPECIAL KS_SPECIAL KE_FILLER. (Christian Brabandt, closes #728) Add a test case. Files: src/getchar.c, src/proto/getchar.pro, src/misc1.c, src/testdir/test_regexp_utf8.vim *** ../vim-7.4.2221/src/getchar.c 2016-06-04 20:25:01.181991001 +0200 --- src/getchar.c 2016-08-16 22:46:18.568743633 +0200 *************** *** 3060,3066 **** if (typebuf_changed(tb_change_cnt)) return 0; ! return fix_input_buffer(buf, len, script_char >= 0); } /* --- 3060,3066 ---- if (typebuf_changed(tb_change_cnt)) return 0; ! return fix_input_buffer(buf, len); } /* *************** *** 3069,3078 **** * Returns the new length. */ int ! fix_input_buffer( ! char_u *buf, ! int len, ! int script) /* TRUE when reading from a script */ { int i; char_u *p = buf; --- 3069,3075 ---- * Returns the new length. */ int ! fix_input_buffer(char_u *buf, int len) { int i; char_u *p = buf; *************** *** 3083,3089 **** * Replace NUL by K_SPECIAL KS_ZERO KE_FILLER * Replace K_SPECIAL by K_SPECIAL KS_SPECIAL KE_FILLER * Replace CSI by K_SPECIAL KS_EXTRA KE_CSI - * Don't replace K_SPECIAL when reading a script file. */ for (i = len; --i >= 0; ++p) { --- 3080,3085 ---- *************** *** 3106,3112 **** } else #endif ! if (p[0] == NUL || (p[0] == K_SPECIAL && !script #ifdef FEAT_AUTOCMD /* timeout may generate K_CURSORHOLD */ && (i < 2 || p[1] != KS_EXTRA || p[2] != (int)KE_CURSORHOLD) --- 3102,3108 ---- } else #endif ! if (p[0] == NUL || (p[0] == K_SPECIAL #ifdef FEAT_AUTOCMD /* timeout may generate K_CURSORHOLD */ && (i < 2 || p[1] != KS_EXTRA || p[2] != (int)KE_CURSORHOLD) *** ../vim-7.4.2221/src/proto/getchar.pro 2016-06-04 13:32:31.042331459 +0200 --- src/proto/getchar.pro 2016-08-16 22:46:46.660486711 +0200 *************** *** 47,53 **** int vpeekc_any(void); int char_avail(void); void vungetc(int c); ! int fix_input_buffer(char_u *buf, int len, int script); int input_available(void); int do_map(int maptype, char_u *arg, int mode, int abbrev); int get_map_mode(char_u **cmdp, int forceit); --- 47,53 ---- int vpeekc_any(void); int char_avail(void); void vungetc(int c); ! int fix_input_buffer(char_u *buf, int len); int input_available(void); int do_map(int maptype, char_u *arg, int mode, int abbrev); int get_map_mode(char_u **cmdp, int forceit); *** ../vim-7.4.2221/src/misc1.c 2016-07-24 21:58:39.708057598 +0200 --- src/misc1.c 2016-08-16 22:46:33.996602532 +0200 *************** *** 3416,3422 **** if (n > 0) { /* Replace zero and CSI by a special key code. */ ! n = fix_input_buffer(buf + len, n, FALSE); len += n; waited = 0; } --- 3416,3422 ---- if (n > 0) { /* Replace zero and CSI by a special key code. */ ! n = fix_input_buffer(buf + len, n); len += n; waited = 0; } *** ../vim-7.4.2221/src/testdir/test_regexp_utf8.vim 2016-07-21 20:33:28.835262339 +0200 --- src/testdir/test_regexp_utf8.vim 2016-08-16 22:42:47.786671780 +0200 *************** *** 25,35 **** --- 25,37 ---- func Test_equivalence_re1() set re=1 call s:equivalence_test() + set re=0 endfunc func Test_equivalence_re2() set re=2 call s:equivalence_test() + set re=0 endfunc func s:classes_test() *************** *** 82,90 **** --- 84,109 ---- func Test_classes_re1() set re=1 call s:classes_test() + set re=0 endfunc func Test_classes_re2() set re=2 call s:classes_test() + set re=0 + endfunc + + func Test_source_utf8() + " check that sourcing a script with 0x80 as second byte works + new + call setline(1, [':%s/àx/--à1234--/g', ':%s/Àx/--À1234--/g']) + write! Xscript + bwipe! + new + call setline(1, [' àx ', ' Àx ']) + source! Xscript | echo + call assert_equal(' --à1234-- ', getline(1)) + call assert_equal(' --À1234-- ', getline(2)) + bwipe! + call delete('Xscript') endfunc *** ../vim-7.4.2221/src/version.c 2016-08-16 21:58:36.726878365 +0200 --- src/version.c 2016-08-16 22:49:49.850811543 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2222, /**/ -- How To Keep A Healthy Level Of Insanity: 15. Five days in advance, tell your friends you can't attend their party because you're not in the mood. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///