]> granicus.if.org Git - vim/commitdiff
patch 7.4.2222 v7.4.2222
authorBram Moolenaar <Bram@vim.org>
Tue, 16 Aug 2016 20:50:55 +0000 (22:50 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 16 Aug 2016 20:50:55 +0000 (22:50 +0200)
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.

src/getchar.c
src/misc1.c
src/proto/getchar.pro
src/testdir/test_regexp_utf8.vim
src/version.c

index 03c75869e1e55a67f7979f13c13e15cbcde57e3f..1c170cc435a50b7dee7cbb4fc0580e0a3a37ba43 100644 (file)
@@ -3060,7 +3060,7 @@ inchar(
     if (typebuf_changed(tb_change_cnt))
        return 0;
 
-    return fix_input_buffer(buf, len, script_char >= 0);
+    return fix_input_buffer(buf, len);
 }
 
 /*
@@ -3069,10 +3069,7 @@ inchar(
  * Returns the new length.
  */
     int
-fix_input_buffer(
-    char_u     *buf,
-    int                len,
-    int                script)         /* TRUE when reading from a script */
+fix_input_buffer(char_u *buf, int len)
 {
     int                i;
     char_u     *p = buf;
@@ -3083,7 +3080,6 @@ fix_input_buffer(
      * 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)
     {
@@ -3106,7 +3102,7 @@ fix_input_buffer(
        }
        else
 #endif
-       if (p[0] == NUL || (p[0] == K_SPECIAL && !script
+       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)
index 2ee87b1f2053843b017a3d9b09ce0ffc96651a90..8cb3b6fd91afda83a9916aa226aa9a69518f6d89 100644 (file)
@@ -3416,7 +3416,7 @@ get_keystroke(void)
        if (n > 0)
        {
            /* Replace zero and CSI by a special key code. */
-           n = fix_input_buffer(buf + len, n, FALSE);
+           n = fix_input_buffer(buf + len, n);
            len += n;
            waited = 0;
        }
index dc117b0aca0b29369de15a3dc4dc10bf795dca17..de33bfd147b5567aa1efb143fa922dbe3ad193d6 100644 (file)
@@ -47,7 +47,7 @@ int vpeekc_nomap(void);
 int vpeekc_any(void);
 int char_avail(void);
 void vungetc(int c);
-int fix_input_buffer(char_u *buf, int len, int script);
+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);
index 81d8f5b04a8e372e39180da5eed44fde8a059f07..ea918291629575fd4959a6fc3fc8c64be377998d 100644 (file)
@@ -25,11 +25,13 @@ endfunc
 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,9 +84,26 @@ endfunc
 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
index 0395201c69d343372f4e43ca948b9ec7adab7b8d..539685dde0a9aa63836de9680de880697fb43be8 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2222,
 /**/
     2221,
 /**/