Skip to content

Commit

Permalink
patch 8.1.0811: too many #ifdefs
Browse files Browse the repository at this point in the history
Problem:    Too many #ifdefs.
Solution:   Graduate FEAT_MBYTE, the final chapter.
  • Loading branch information
brammool committed Jan 24, 2019
1 parent 264b74f commit 30276f2
Show file tree
Hide file tree
Showing 54 changed files with 122 additions and 325 deletions.
12 changes: 6 additions & 6 deletions src/appveyor.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd %APPVEYOR_BUILD_FOLDER%
cd src
echo "Building MinGW 32bit console version"
set PATH=c:\msys64\mingw32\bin;%PATH%
mingw32-make.exe -f Make_ming.mak GUI=no OPTIMIZE=speed IME=yes MBYTE=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
mingw32-make.exe -f Make_ming.mak GUI=no OPTIMIZE=speed IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
:: Save vim.exe before Make clean, moved back below.
copy vim.exe testdir
mingw32-make.exe -f Make_ming.mak clean
Expand All @@ -16,24 +16,24 @@ mingw32-make.exe -f Make_ming.mak clean
:: with specified features without python.
echo "Building MinGW 32bit GUI version"
if "%FEATURE%" == "HUGE" (
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed CHANNEL=yes GUI=yes IME=yes MBYTE=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35 FEATURES=%FEATURE% || exit 1
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed CHANNEL=yes GUI=yes IME=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35 FEATURES=%FEATURE% || exit 1
) ELSE (
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed GUI=yes IME=yes MBYTE=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed GUI=yes IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
)
.\gvim -u NONE -c "redir @a | ver |0put a | wq" ver_ming.txt

echo "Building MSVC 64bit console Version"
sed -e "s/\$(LINKARGS2)/\$(LINKARGS2) | sed -e 's#.*\\\\r.*##'/" Make_mvc.mak > Make_mvc2.mak
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=no IME=yes MBYTE=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=no IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
nmake -f Make_mvc2.mak clean

:: build MSVC huge version with python and channel support
:: GUI needs to be last, so that testing works
echo "Building MSVC 64bit GUI Version"
if "%FEATURE%" == "HUGE" (
nmake -f Make_mvc2.mak DIRECTX=yes CPU=AMD64 CHANNEL=yes OLE=no GUI=yes IME=yes MBYTE=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27-x64 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35-x64 FEATURES=%FEATURE% || exit 1
nmake -f Make_mvc2.mak DIRECTX=yes CPU=AMD64 CHANNEL=yes OLE=no GUI=yes IME=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27-x64 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35-x64 FEATURES=%FEATURE% || exit 1
) ELSE (
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=yes IME=yes MBYTE=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=yes IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
)
.\gvim -u NONE -c "redir @a | ver |0put a | wq" ver_msvc.txt

Expand Down
5 changes: 1 addition & 4 deletions src/auto/configure
Original file line number Diff line number Diff line change
Expand Up @@ -7937,10 +7937,7 @@ fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_multibyte" >&5
$as_echo "$enable_multibyte" >&6; }
if test "$enable_multibyte" = "yes"; then
$as_echo "#define FEAT_MBYTE 1" >>confdefs.h

else
if test "$enable_multibyte" != "yes"; then
as_fn_error $? "The multi-byte feature can no longer be disabled. If you have
a problem with this, discuss on the Vim mailing list." "$LINENO" 5
fi
Expand Down
3 changes: 0 additions & 3 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,6 @@
/* Define if you want to include the Cscope interface. */
#undef FEAT_CSCOPE

/* Define if you want to include multibyte support. */
#undef FEAT_MBYTE

/* Define if you don't want to include right-left support. */
#undef DISABLE_RIGHTLEFT

Expand Down
4 changes: 1 addition & 3 deletions src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2124,9 +2124,7 @@ AC_ARG_ENABLE(multibyte,
[ --enable-multibyte Include multibyte editing support.], ,
[enable_multibyte="yes"])
AC_MSG_RESULT($enable_multibyte)
if test "$enable_multibyte" = "yes"; then
AC_DEFINE(FEAT_MBYTE)
else
if test "$enable_multibyte" != "yes"; then
AC_MSG_ERROR([The multi-byte feature can no longer be disabled. If you have
a problem with this, discuss on the Vim mailing list.])
fi
Expand Down
4 changes: 0 additions & 4 deletions src/crypt_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
*/

/* Need a type that should be 32 bits. 64 also works but wastes space. */
# if VIM_SIZEOF_INT >= 4
typedef unsigned int u32_T; /* int is at least 32 bits */
# else
typedef unsigned long u32_T; /* long should be 32 bits or more */
# endif

/* The state of encryption, referenced by cryptstate_T. */
typedef struct {
Expand Down
13 changes: 3 additions & 10 deletions src/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
*
* Disabled for EBCDIC as it requires multibyte.
*/
#if defined(FEAT_BIG) && !defined(DISABLE_ARABIC) && VIM_SIZEOF_INT >= 4 && !defined(EBCDIC)
#if defined(FEAT_BIG) && !defined(DISABLE_ARABIC) && !defined(EBCDIC)
# define FEAT_ARABIC
#endif
#ifdef FEAT_ARABIC
Expand Down Expand Up @@ -600,21 +600,14 @@
* +multi_byte Generic multi-byte character handling.
* Now always enabled.
*/
#if !defined(FEAT_MBYTE)
# define FEAT_MBYTE
#endif
#if VIM_SIZEOF_INT < 4 && !defined(PROTO)
Error: Vim only works with 32 bit int or larger
#endif

/* Define this if you want to use 16 bit Unicode only, reduces memory used for
* the screen structures. */
/* #define UNICODE16 */

/*
* +multi_byte_ime Win32 IME input method. Requires +multi_byte.
* Only for far-east Windows, so IME can be used to input
* chars. Not tested much!
* +multi_byte_ime Win32 IME input method. Only for far-east Windows, so
* IME can be used to input chars. Not tested much!
*/
#if defined(FEAT_GUI_W32) && !defined(FEAT_MBYTE_IME)
/* #define FEAT_MBYTE_IME */
Expand Down
16 changes: 3 additions & 13 deletions src/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,31 +1178,21 @@ readfile(
*/
if (!skip_read)
{
#if VIM_SIZEOF_INT > 2
# if defined(SSIZE_MAX) && (SSIZE_MAX < 0x10000L)
#if defined(SSIZE_MAX) && (SSIZE_MAX < 0x10000L)
size = SSIZE_MAX; /* use max I/O size, 52K */
# else
#else
/* Use buffer >= 64K. Add linerest to double the size if the
* line gets very long, to avoid a lot of copying. But don't
* read more than 1 Mbyte at a time, so we can be interrupted.
*/
size = 0x10000L + linerest;
if (size > 0x100000L)
size = 0x100000L;
# endif
#else
size = 0x7ff0L - linerest; /* limit buffer to 32K */
#endif
}

/* Protect against the argument of lalloc() going negative. */
if (
#if VIM_SIZEOF_INT <= 2
linerest >= 0x7ff0
#else
size < 0 || size + linerest + 1 < 0 || linerest >= MAXCOL
#endif
)
if (size < 0 || size + linerest + 1 < 0 || linerest >= MAXCOL)
{
++split;
*ptr = NL; /* split line by inserting a NL */
Expand Down
4 changes: 0 additions & 4 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -4492,14 +4492,10 @@ vim_vsnprintf_typval(
{
/* Don't put the #if inside memchr(), it can be a
* macro. */
# if VIM_SIZEOF_INT <= 2
char *q = memchr(str_arg, '\0', precision);
# else
/* memchr on HP does not like n > 2^31 !!! */
char *q = memchr(str_arg, '\0',
precision <= (size_t)0x7fffffffL ? precision
: (size_t)0x7fffffffL);
# endif
str_arg_l = (q == NULL) ? precision
: (size_t)(q - str_arg);
}
Expand Down
6 changes: 0 additions & 6 deletions src/os_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,14 @@
char_u *str = (char_u*)[string UTF8String];
int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];

#ifdef FEAT_MBYTE
if (input_conv.vc_type != CONV_NONE)
str = string_convert(&input_conv, str, &len);
#endif

if (str)
clip_yank_selection(motion_type, str, len, cbd);

#ifdef FEAT_MBYTE
if (input_conv.vc_type != CONV_NONE)
vim_free(str);
#endif

releasepool:
[pool release];
Expand Down Expand Up @@ -169,7 +165,6 @@

/* TODO: Avoid overflow. */
int len = (int)llen;
#ifdef FEAT_MBYTE
if (output_conv.vc_type != CONV_NONE)
{
char_u *conv_str = string_convert(&output_conv, str, &len);
Expand All @@ -179,7 +174,6 @@
str = conv_str;
}
}
#endif

if (len > 0)
{
Expand Down
4 changes: 0 additions & 4 deletions src/spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@

/* Type used for indexes in the word tree need to be at least 4 bytes. If int
* is 8 bytes we could use something smaller, but what? */
#if VIM_SIZEOF_INT > 3
typedef int idx_T;
#else
typedef long idx_T;
#endif

typedef int salfirst_T;

Expand Down
16 changes: 2 additions & 14 deletions src/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,8 @@ struct u_header
/*
* structures used in undo.c
*/
#if VIM_SIZEOF_INT > 2
# define ALIGN_LONG /* longword alignment and use filler byte */
# define ALIGN_SIZE (sizeof(long))
#else
# define ALIGN_SIZE (sizeof(short))
#endif
#define ALIGN_LONG /* longword alignment and use filler byte */
#define ALIGN_SIZE (sizeof(long))

#define ALIGN_MASK (ALIGN_SIZE - 1)

Expand Down Expand Up @@ -1229,19 +1225,11 @@ typedef unsigned long uvarnumber_T;
# endif
#else
/* Use 32-bit Number. */
# if VIM_SIZEOF_INT <= 3 /* use long if int is smaller than 32 bits */
typedef long varnumber_T;
typedef unsigned long uvarnumber_T;
#define VARNUM_MIN LONG_MIN
#define VARNUM_MAX LONG_MAX
#define UVARNUM_MAX ULONG_MAX
# else
typedef int varnumber_T;
typedef unsigned int uvarnumber_T;
#define VARNUM_MIN INT_MIN
#define VARNUM_MAX INT_MAX
#define UVARNUM_MAX UINT_MAX
# endif
#endif

typedef double float_T;
Expand Down
10 changes: 3 additions & 7 deletions src/testdir/runtest.vim
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@ source setup.vim
" This also enables use of line continuation.
set nocp viminfo+=nviminfo

" Use utf-8 or latin1 by default, instead of whatever the system default
" happens to be. Individual tests can overrule this at the top of the file.
if has('multi_byte')
set encoding=utf-8
else
set encoding=latin1
endif
" Use utf-8 by default, instead of whatever the system default happens to be.
" Individual tests can overrule this at the top of the file.
set encoding=utf-8

" REDIR_TEST_TO_NULL has a very permissive SwapExists autocommand which is for
" the test_name.vim file itself. Replace it here with a more restrictive one,
Expand Down
3 changes: 1 addition & 2 deletions src/testdir/test_alot_utf8.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
" This makes testing go faster, since Vim doesn't need to restart.

" These tests use utf8 'encoding'. Setting 'encoding' is already done in
" runtest.vim. Checking for the multi_byte feature is in the individual
" files, so that they can be run by themselves.
" runtest.vim.

source test_charsearch_utf8.vim
source test_expr_utf8.vim
Expand Down
2 changes: 1 addition & 1 deletion src/testdir/test_arabic.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" NOTE: This just checks if the code works. If you know Arabic please add
" functional tests that check the shaping works with real text.

if !has('arabic') || !has('multi_byte')
if !has('arabic')
finish
endif

Expand Down
3 changes: 0 additions & 3 deletions src/testdir/test_charsearch_utf8.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
" Tests for related f{char} and t{char} using utf-8.
if !has('multi_byte')
finish
endif

" Test for t,f,F,T movement commands
func Test_search_cmds()
Expand Down
10 changes: 4 additions & 6 deletions src/testdir/test_cmdline.vim
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func Test_setcmdpos()
endfunc

func Test_cmdline_overstrike()
let encodings = has('multi_byte') ? [ 'latin1', 'utf8' ] : [ 'latin1' ]
let encodings = ['latin1', 'utf8']
let encoding_save = &encoding

for e in encodings
Expand All @@ -601,11 +601,9 @@ func Test_cmdline_overstrike()
call assert_equal('"ab0cd3ef4', @:)
endfor

if has('multi_byte')
" Test overstrike with multi-byte characters.
call feedkeys(":\"テキストエディタ\<home>\<right>\<right>ab\<right>\<insert>cd\<enter>", 'xt')
call assert_equal('"テabキcdエディタ', @:)
endif
" Test overstrike with multi-byte characters.
call feedkeys(":\"テキストエディタ\<home>\<right>\<right>ab\<right>\<insert>cd\<enter>", 'xt')
call assert_equal('"テabキcdエディタ', @:)

let &encoding = encoding_save
endfunc
Expand Down
5 changes: 1 addition & 4 deletions src/testdir/test_digraph.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" Tests for digraphs

if !has("digraphs") || !has("multi_byte")
if !has("digraphs")
finish
endif

Expand Down Expand Up @@ -466,9 +466,6 @@ func Test_show_digraph()
endfunc

func Test_show_digraph_cp1251()
if !has('multi_byte')
return
endif
new
set encoding=cp1251
call Put_Dig("='")
Expand Down
2 changes: 1 addition & 1 deletion src/testdir/test_display.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func Test_display_foldcolumn()
endfunc

func Test_display_foldtext_mbyte()
if !has("folding") || !has("multi_byte")
if !has("folding")
return
endif
call NewWindow(10, 40)
Expand Down
29 changes: 13 additions & 16 deletions src/testdir/test_edit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ func Test_edit_01()
call assert_equal([''], getline(1,'$'))
%d
" 4) delete a multibyte character
if has("multi_byte")
call setline(1, "\u0401")
call feedkeys("i\<del>\<esc>", 'tnix')
call assert_equal([''], getline(1,'$'))
%d
endif
call setline(1, "\u0401")
call feedkeys("i\<del>\<esc>", 'tnix')
call assert_equal([''], getline(1,'$'))
%d
" 5.1) delete linebreak with 'bs' option containing eol
let _bs=&bs
set bs=eol
Expand Down Expand Up @@ -440,7 +438,7 @@ endfunc

func Test_edit_CTRL_()
" disabled for Windows builds, why?
if !has("multi_byte") || !has("rightleft") || has("win32")
if !has("rightleft") || has("win32")
return
endif
let _encoding=&encoding
Expand Down Expand Up @@ -608,15 +606,14 @@ func Test_edit_CTRL_K()
endtry
call delete('Xdictionary.txt')

if has("multi_byte")
call test_override("char_avail", 1)
set showcmd
%d
call feedkeys("A\<c-k>a:\<esc>", 'tnix')
call assert_equal(['ä'], getline(1, '$'))
call test_override("char_avail", 0)
set noshowcmd
endif
call test_override("char_avail", 1)
set showcmd
%d
call feedkeys("A\<c-k>a:\<esc>", 'tnix')
call assert_equal(['ä'], getline(1, '$'))
call test_override("char_avail", 0)
set noshowcmd

bw!
endfunc

Expand Down
Loading

0 comments on commit 30276f2

Please sign in to comment.