Patch 8.2.0047

18 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 27, 2019, 7:50:17 AM12/27/19
to vim...@googlegroups.com

Patch 8.2.0047
Problem: Cannot skip tests for specific MS-Windows platform.
Solution: Add windowsversion().
Files: src/os_win32.c, src/globals.h, src/evalfunc.c,
runtime/doc/eval.txt, src/testdir/gen_opt_test.vim,
src/testdir/test_options.vim


*** ../vim-8.2.0046/src/os_win32.c 2019-12-11 22:56:40.000000000 +0100
--- src/os_win32.c 2019-12-27 13:48:37.745102976 +0100
***************
*** 758,765 ****
# define VER_PLATFORM_WIN32_WINDOWS 1
#endif

- DWORD g_PlatformId;
-
#ifdef HAVE_ACL
# ifndef PROTO
# include <aclapi.h>
--- 758,763 ----
***************
*** 806,813 ****
#endif

/*
! * Set g_PlatformId to VER_PLATFORM_WIN32_NT (NT) or
! * VER_PLATFORM_WIN32_WINDOWS (Win95).
*/
void
PlatformId(void)
--- 804,810 ----
#endif

/*
! * Set "win8_or_later" and fill in "windowsVersion".
*/
void
PlatformId(void)
***************
*** 821,827 ****
ovi.dwOSVersionInfoSize = sizeof(ovi);
GetVersionEx(&ovi);

! g_PlatformId = ovi.dwPlatformId;

if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
|| ovi.dwMajorVersion > 6)
--- 818,825 ----
ovi.dwOSVersionInfoSize = sizeof(ovi);
GetVersionEx(&ovi);

! vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
! (int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion);

if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
|| ovi.dwMajorVersion > 6)
*** ../vim-8.2.0046/src/globals.h 2019-12-23 22:59:14.264820697 +0100
--- src/globals.h 2019-12-27 13:28:25.877759683 +0100
***************
*** 1724,1729 ****
--- 1724,1732 ----

// Used for checking if local variables or arguments used in a lambda.
EXTERN int *eval_lavars_used INIT(= NULL);
+
+ // Only filled for Win32.
+ EXTERN char windowsVersion[20] INIT(= {0});
#endif

#ifdef MSWIN
*** ../vim-8.2.0046/src/evalfunc.c 2019-12-01 21:10:25.000000000 +0100
--- src/evalfunc.c 2019-12-27 13:40:15.002978266 +0100
***************
*** 276,281 ****
--- 276,282 ----
static void f_virtcol(typval_T *argvars, typval_T *rettv);
static void f_visualmode(typval_T *argvars, typval_T *rettv);
static void f_wildmenumode(typval_T *argvars, typval_T *rettv);
+ static void f_windowsversion(typval_T *argvars, typval_T *rettv);
static void f_wordcount(typval_T *argvars, typval_T *rettv);
static void f_xor(typval_T *argvars, typval_T *rettv);

***************
*** 864,869 ****
--- 865,871 ----
{"win_splitmove", 2, 3, FEARG_1, f_win_splitmove},
{"winbufnr", 1, 1, FEARG_1, f_winbufnr},
{"wincol", 0, 0, 0, f_wincol},
+ {"windowsversion", 0, 0, 0, f_windowsversion},
{"winheight", 1, 1, FEARG_1, f_winheight},
{"winlayout", 0, 1, FEARG_1, f_winlayout},
{"winline", 0, 0, 0, f_winline},
***************
*** 8408,8413 ****
--- 8410,8425 ----
}

/*
+ * "windowsversion()" function
+ */
+ static void
+ f_windowsversion(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
+ {
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strsave((char_u *)windowsVersion);
+ }
+
+ /*
* "wordcount()" function
*/
static void
*** ../vim-8.2.0046/runtime/doc/eval.txt 2019-12-17 22:40:11.938933015 +0100
--- runtime/doc/eval.txt 2019-12-27 13:43:44.450192194 +0100
***************
*** 10383,10388 ****
--- 10382,10394 ----
cursor in the window. This is counting screen cells from the
left side of the window. The leftmost column is one.

+ *windowsversion()*
+ windowsversion()
+ The result is a String. For MS-Windows it indicates the OS
+ version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
+ Windows XP is "5.1". For non-MS-Windows systems the result is
+ an empty string.
+
winheight({nr}) *winheight()*
The result is a Number, which is the height of window {nr}.
{nr} can be the window number or the |window-ID|.
*** ../vim-8.2.0046/src/testdir/gen_opt_test.vim 2019-09-14 14:57:37.000000000 +0200
--- src/testdir/gen_opt_test.vim 2019-12-27 13:34:50.672218777 +0100
***************
*** 10,15 ****
--- 10,17 ----
" The terminal size is restored at the end.
" Clear out t_WS, we don't want to resize the actual terminal.
let script = [
+ \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
+ \ '',
\ 'let save_columns = &columns',
\ 'let save_lines = &lines',
\ 'let save_term = &term',
***************
*** 123,129 ****
\ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
\ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
\ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
! \ 'renderoptions': [['', 'type:directx'], ['xxx']],
\ 'selection': [['old', 'inclusive'], ['', 'xxx']],
\ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
\ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
--- 125,131 ----
\ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
\ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
\ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
! \ 'renderoptions': [[''], ['xxx']],
\ 'selection': [['old', 'inclusive'], ['', 'xxx']],
\ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
\ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
*** ../vim-8.2.0046/src/testdir/test_options.vim 2019-10-19 20:14:41.000000000 +0200
--- src/testdir/test_options.vim 2019-12-27 13:46:57.213475283 +0100
***************
*** 389,394 ****
--- 389,403 ----
endif
endfunc

+ func Test_renderoptions()
+ " Only do this for Windows Vista and later, fails on Windows XP and earlier.
+ " Doesn't hurt to do this on a non-Windows system.
+ if windowsversion() !~ '^[345]\.'
+ set renderoptions=type:directx
+ set rop=type:directx
+ endif
+ endfunc
+
func ResetIndentexpr()
set indentexpr=
endfunc
*** ../vim-8.2.0046/src/version.c 2019-12-26 14:30:11.763609692 +0100
--- src/version.c 2019-12-27 13:47:13.789413807 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 47,
/**/

--
[clop clop]
ARTHUR: Old woman!
DENNIS: Man!
ARTHUR: Man, sorry. What knight lives in that castle over there?
DENNIS: I'm thirty seven.
ARTHUR: What?
DENNIS: I'm thirty seven -- I'm not old!
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Br...@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 ///

Dominique Pellé

unread,
Dec 27, 2019, 8:35:44 AM12/27/19
to vim_dev
> + *windowsversion()*
> + windowsversion()
> + The result is a String. For MS-Windows it indicates the OS
> + version. E.g, Windows 10 is "10.0", Windows 8 is "6.2",
> + Windows XP is "5.1". For non-MS-Windows systems the result is
> + an empty string.

Hard-coding the OS name in the function name seems
inelegant and not flexible. What if we also need the version
of macOs, etc.?

How about instead a more general function systeminfo()
(any better name?) which returns a dictionary with keys for:

* os name ("Windows", "GNU/Linux", "macOs", …)
* os version (a version number/string, specific to OS)
* possibly other keys e.g. architecture: "x86", "x86_64", ...

Regards
Dominique

Bram Moolenaar

unread,
Dec 27, 2019, 8:54:26 AM12/27/19
to vim...@googlegroups.com, Dominique Pellé
It's possible to make it more generic, but it would then start out as
only implemented for MS-Windows. And I have no idea when we would need
anything for other systems. For Linux/Unix there usually is a way to
get info about the system with a shell command, e.g. with "uname".

Also, we already have has('unix'), has('mac'), etc.

--
A mathematician is a device for turning coffee into theorems.
Paul Erdos
A computer programmer is a device for turning coffee into bugs.
Bram Moolenaar
Reply all
Reply to author
Forward
0 new messages