Compare commits

...

9 Commits

Author SHA1 Message Date
Bram Moolenaar
130f65d46b patch 8.2.4084: memory leak when looking for autoload prefixed variable
Problem:    Memory leak when looking for autoload prefixed variable.
Solution:   Free the concatenated string.
2022-01-13 20:39:41 +00:00
Bram Moolenaar
0e3e7ba05f patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable
Problem:    Vim9: no test for "vim9script autoload' and using script variable
            in the same script.
Solution:   Add a simple test.  Fix uncovered problem.
2022-01-13 20:18:56 +00:00
Bram Moolenaar
3049fcf0a1 patch 8.2.4082: check for autoload file name and prefix fails
Problem:    Check for autoload file name and prefix fails. (Christian J.
            Robinson)
Solution:   Only lower case the prefix on systems where the file name is not
            case sensitive.
2022-01-13 19:25:50 +00:00
ichizok
4050305bfd patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Problem:    CodeQL reports problem in if_cscope causing it to fail.
Solution:   Use execvp() instead of execl().  Merge the header file into the
            source file. (Ozaki Kiichi, closes #9519)
2022-01-13 18:09:11 +00:00
Erik Auerswald
a00e622a29 patch 8.2.4080: not sufficient test coverage for xxd
Problem:    Not sufficient test coverage for xxd.
Solution:   Add a few more test cases. (Erki Auerswald, closes #9515)
2022-01-13 17:42:28 +00:00
K.Takata
33b25d1317 patch 8.2.4079: MS-Windows: "gvim --version" didn't work with VIMDLL
Problem:    MS-Windows: "gvim --version" didn't work when build with VIMDLL.
Solution:   Adjust #ifdef. (Ken Takata, closes #9517)
2022-01-13 16:06:45 +00:00
Bram Moolenaar
ced2b38a56 patch 8.2.4078: terminal test for current directory not used on FreeBSD
Problem:    Terminal test for current directory not used on FreeBSD.
Solution:   Make it work on FreeBSD. (Ozaki Kiichi, closes #9516) Add
            TermWait() inside Run_shell_in_terminal() as a generic solution.
2022-01-13 15:25:32 +00:00
Bram Moolenaar
8d9e470aa9 patch 8.2.4077: not all Libsensors files are recognized
Problem:    Not all Libsensors files are recognized.
Solution:   Add "sensors.d/*" pattern. (Doug Kearns)
2022-01-13 14:49:10 +00:00
Bram Moolenaar
71930f174d patch 8.2.4076: memory leak in autoload import
Problem:    Memory leak in autoload import.
Solution:   Do not overwrite the autoload prefix.
2022-01-13 13:47:43 +00:00
22 changed files with 236 additions and 135 deletions

View File

@@ -497,7 +497,6 @@ SRC_UNIX = \
SRC_DOS_UNIX = \
src/gui_xim.c \
src/if_cscope.c \
src/if_cscope.h \
src/if_lua.c \
src/if_mzsch.c \
src/if_mzsch.h \

View File

@@ -2286,6 +2286,9 @@ au BufNewFile,BufRead Kconfig.* call s:StarSetf('kconfig')
" Lilo: Linux loader
au BufNewFile,BufRead lilo.conf* call s:StarSetf('lilo')
" Libsensors
au BufNewFile,BufRead */etc/sensors.d/[^.]* call s:StarSetf('sensors')
" Logcheck
au BufNewFile,BufRead */etc/logcheck/*.d*/* call s:StarSetf('logcheck')

View File

@@ -1237,7 +1237,7 @@ $(OUTDIR)/gui_beval.o: gui_beval.c $(INCL) $(GUI_INCL)
$(OUTDIR)/gui_w32.o: gui_w32.c $(INCL) $(GUI_INCL) version.h
$(CC) -c $(CFLAGS) gui_w32.c -o $@
$(OUTDIR)/if_cscope.o: if_cscope.c $(INCL) if_cscope.h
$(OUTDIR)/if_cscope.o: if_cscope.c $(INCL)
$(CC) -c $(CFLAGS) if_cscope.c -o $@
$(OUTDIR)/if_mzsch.o: if_mzsch.c $(INCL) $(MZSCHEME_INCL) $(MZ_EXTRA_DEP)

View File

@@ -1670,7 +1670,7 @@ $(OUTDIR)/gui_w32.obj: $(OUTDIR) gui_w32.c $(INCL) $(GUI_INCL) version.h
$(OUTDIR)/gui_dwrite.obj: $(OUTDIR) gui_dwrite.cpp gui_dwrite.h
$(OUTDIR)/if_cscope.obj: $(OUTDIR) if_cscope.c $(INCL) if_cscope.h
$(OUTDIR)/if_cscope.obj: $(OUTDIR) if_cscope.c $(INCL)
$(OUTDIR)/if_lua.obj: $(OUTDIR) if_lua.c $(INCL)
$(CC) $(CFLAGS_OUTDIR) $(LUA_INC) if_lua.c

View File

@@ -908,7 +908,7 @@ highlight.obj : highlight.c vim.h [.auto]config.h feature.h os_unix.h \
if_cscope.obj : if_cscope.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h termdefs.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
errors.h globals.h if_cscope.h
errors.h globals.h
if_xcmdsrv.obj : if_xcmdsrv.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h termdefs.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \

View File

@@ -3922,7 +3922,7 @@ objects/highlight.o: highlight.c vim.h protodef.h auto/config.h feature.h \
objects/if_cscope.o: if_cscope.c vim.h protodef.h auto/config.h feature.h \
os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h errors.h if_cscope.h
proto.h globals.h errors.h
objects/if_xcmdsrv.o: if_xcmdsrv.c vim.h protodef.h auto/config.h feature.h \
os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \

View File

@@ -2874,6 +2874,32 @@ find_var(char_u *name, hashtab_T **htp, int no_autoload)
}
}
// When using "vim9script autoload" script-local items are prefixed but can
// be used with s:name.
if (SCRIPT_ID_VALID(current_sctx.sc_sid)
&& name[0] == 's' && name[1] == ':')
{
scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
if (si->sn_autoload_prefix != NULL)
{
char_u *auto_name = concat_str(si->sn_autoload_prefix, name + 2);
if (auto_name != NULL)
{
ht = &globvarht;
ret = find_var_in_ht(ht, *name, auto_name, TRUE);
vim_free(auto_name);
if (ret != NULL)
{
if (htp != NULL)
*htp = ht;
return ret;
}
}
}
}
return NULL;
}
@@ -3318,7 +3344,7 @@ set_var(
}
/*
* Set variable "name" to value in "tv".
* Set variable "name" to value in "tv_arg".
* When "sid" is non-zero "name" is in the script with this ID.
* If the variable already exists and "is_const" is FALSE the value is updated.
* Otherwise the variable is created.

View File

@@ -18,7 +18,62 @@
#if defined(UNIX)
# include <sys/wait.h>
#endif
#include "if_cscope.h"
#if defined (MSWIN)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
#endif
#define CSCOPE_SUCCESS 0
#define CSCOPE_FAILURE -1
#define CSCOPE_DBFILE "cscope.out"
#define CSCOPE_PROMPT ">> "
/*
* See ":help cscope-find" for the possible queries.
*/
typedef struct {
char * name;
int (*func)(exarg_T *eap);
char * help;
char * usage;
int cansplit; // if supports splitting window
} cscmd_T;
typedef struct csi {
char * fname; // cscope db name
char * ppath; // path to prepend (the -P option)
char * flags; // additional cscope flags/options (e.g, -p2)
#if defined(UNIX)
pid_t pid; // PID of the connected cscope process.
dev_t st_dev; // ID of dev containing cscope db
ino_t st_ino; // inode number of cscope db
#else
# if defined(MSWIN)
DWORD pid; // PID of the connected cscope process.
HANDLE hProc; // cscope process handle
DWORD nVolume; // Volume serial number, instead of st_dev
DWORD nIndexHigh; // st_ino has no meaning in the Windows
DWORD nIndexLow;
# endif
#endif
FILE * fr_fp; // from cscope: FILE.
FILE * to_fp; // to cscope: FILE.
} csinfo_T;
typedef enum { Add, Find, Help, Kill, Reset, Show } csid_e;
typedef enum {
Store,
Get,
Free,
Print
} mcmd_e;
static int cs_add(exarg_T *eap);
static int cs_add_common(char *, char *, char *);
@@ -811,12 +866,16 @@ err_closing:
return CSCOPE_FAILURE;
}
switch (csinfo[i].pid = fork())
if ((csinfo[i].pid = fork()) == -1)
{
case -1:
(void)emsg(_(e_could_not_fork_for_cscope));
goto err_closing;
case 0: // child: run cscope.
}
else if (csinfo[i].pid == 0) // child: run cscope.
{
char **argv = NULL;
int argc = 0;
if (dup2(to_cs[0], STDIN_FILENO) == -1)
PERROR("cs_create_connection 1");
if (dup2(from_cs[1], STDOUT_FILENO) == -1)
@@ -856,7 +915,7 @@ err_closing:
if ((prog = alloc(MAXPATHL + 1)) == NULL)
{
#ifdef UNIX
return CSCOPE_FAILURE;
exit(EXIT_FAILURE);
#else
// MSWIN
goto err_closing;
@@ -873,7 +932,7 @@ err_closing:
{
vim_free(prog);
#ifdef UNIX
return CSCOPE_FAILURE;
exit(EXIT_FAILURE);
#else
// MSWIN
goto err_closing;
@@ -892,20 +951,16 @@ err_closing:
vim_free(prog);
vim_free(ppath);
#ifdef UNIX
return CSCOPE_FAILURE;
exit(EXIT_FAILURE);
#else
// MSWIN
goto err_closing;
#endif
}
// run the cscope command; is there execl for non-unix systems?
#if defined(UNIX)
(void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname);
#else
// MSWIN
// run the cscope command
(void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname);
#endif
if (csinfo[i].ppath != NULL)
{
(void)strcat(cmd, " -P");
@@ -932,12 +987,17 @@ err_closing:
PERROR(_("cs_create_connection setpgid failed"));
# endif
# endif
if (execl("/bin/sh", "sh", "-c", cmd, (char *)NULL) == -1)
if (build_argv_from_string((char_u *)cmd, &argv, &argc) == FAIL)
exit(EXIT_FAILURE);
if (execvp(argv[0], argv) == -1)
PERROR(_("cs_create_connection exec failed"));
exit(127);
// NOTREACHED
default: // parent.
}
else // parent.
{
/*
* Save the file descriptors for later duplication, and
* reopen as streams.
@@ -950,10 +1010,7 @@ err_closing:
// close unused
(void)close(to_cs[0]);
(void)close(from_cs[1]);
break;
}
#else
// MSWIN
// Create a new process to run cscope and use pipes to talk with it

View File

@@ -1,71 +0,0 @@
/* vi:set ts=8 sts=4 sw=4 noet:
*
* CSCOPE support for Vim added by Andy Kahn <kahn@zk3.dec.com>
* Ported to Win32 by Sergey Khorev <sergey.khorev@gmail.com>
*
* The basic idea/structure of cscope for Vim was borrowed from Nvi.
* There might be a few lines of code that look similar to what Nvi
* has. If this is a problem and requires inclusion of the annoying
* BSD license, then sue me; I'm not worth much anyway.
*/
#if defined(FEAT_CSCOPE) || defined(PROTO)
#if defined (MSWIN)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
#endif
#define CSCOPE_SUCCESS 0
#define CSCOPE_FAILURE -1
#define CSCOPE_DBFILE "cscope.out"
#define CSCOPE_PROMPT ">> "
/*
* See ":help cscope-find" for the possible queries.
*/
typedef struct {
char * name;
int (*func)(exarg_T *eap);
char * help;
char * usage;
int cansplit; // if supports splitting window
} cscmd_T;
typedef struct csi {
char * fname; // cscope db name
char * ppath; // path to prepend (the -P option)
char * flags; // additional cscope flags/options (e.g, -p2)
#if defined(UNIX)
pid_t pid; // PID of the connected cscope process.
dev_t st_dev; // ID of dev containing cscope db
ino_t st_ino; // inode number of cscope db
#else
# if defined(MSWIN)
DWORD pid; // PID of the connected cscope process.
HANDLE hProc; // cscope process handle
DWORD nVolume; // Volume serial number, instead of st_dev
DWORD nIndexHigh; // st_ino has no meaning in the Windows
DWORD nIndexLow;
# endif
#endif
FILE * fr_fp; // from cscope: FILE.
FILE * to_fp; // to cscope: FILE.
} csinfo_T;
typedef enum { Add, Find, Help, Kill, Reset, Show } csid_e;
typedef enum {
Store,
Get,
Free,
Print
} mcmd_e;
#endif // FEAT_CSCOPE

View File

@@ -2004,7 +2004,7 @@ command_line_scan(mparm_T *parmp)
{
Columns = 80; // need to init Columns
info_message = TRUE; // use mch_msg(), not mch_errmsg()
#if defined(FEAT_GUI) && !defined(ALWAYS_USE_GUI)
#if defined(FEAT_GUI) && !defined(ALWAYS_USE_GUI) && !defined(VIMDLL)
gui.starting = FALSE; // not starting GUI, will exit
#endif
list_version();

View File

@@ -2156,7 +2156,11 @@ get_autoload_prefix(scriptitem_T *si)
if (p == NULL)
return NULL;
#ifdef CASE_INSENSITIVE_FILENAME
prefix = strlow_save(p);
#else
prefix = vim_strsave(p);
#endif
if (prefix == NULL)
return NULL;

View File

@@ -24,6 +24,7 @@ func StopShellInTerminal(buf)
call term_sendkeys(a:buf, "exit\r")
let job = term_getjob(a:buf)
call WaitForAssert({-> assert_equal("dead", job_status(job))})
call TermWait(a:buf)
endfunc
" Wrapper around term_wait() to allow more time for re-runs of flaky tests
@@ -176,6 +177,10 @@ func Run_shell_in_terminal(options)
let string = string({'job': buf->term_getjob()})
call assert_match("{'job': 'process \\d\\+ run'}", string)
" On slower systems it may take a bit of time before the shell is ready to
" accept keys. This mainly matters when using term_sendkeys() next.
call TermWait(buf)
return buf
endfunc

View File

@@ -246,7 +246,7 @@ func Test_cscopeWithCscopeConnections()
" Test: 'csprg' option
call assert_equal('cscope', &csprg)
set csprg=doesnotexist
call assert_fails('cscope add Xcscope2.out', 'E609:')
call assert_fails('cscope add Xcscope2.out', 'E262:')
set csprg=cscope
" Test: multiple cscope connections

View File

@@ -448,7 +448,7 @@ let s:filename_checks = {
\ 'sdl': ['file.sdl', 'file.pr'],
\ 'sed': ['file.sed'],
\ 'svelte': ['file.svelte'],
\ 'sensors': ['/etc/sensors.conf', '/etc/sensors3.conf', 'any/etc/sensors.conf', 'any/etc/sensors3.conf'],
\ 'sensors': ['/etc/sensors.conf', '/etc/sensors3.conf', '/etc/sensors.d/file', 'any/etc/sensors.conf', 'any/etc/sensors3.conf', 'any/etc/sensors.d/file'],
\ 'services': ['/etc/services', 'any/etc/services'],
\ 'setserial': ['/etc/serial.conf', 'any/etc/serial.conf'],
\ 'sh': ['.bashrc', 'file.bash', '/usr/share/doc/bash-completion/filter.sh','/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf'],

View File

@@ -976,7 +976,6 @@ func Test_map_cmdkey()
call assert_equal('t', m)
call assert_equal('t', mode(1))
call StopShellInTerminal(buf)
call TermWait(buf)
close!
tunmap <F3>
endif

View File

@@ -26,7 +26,6 @@ func Test_terminal_basic()
call assert_fails('set modifiable', 'E946:')
call StopShellInTerminal(buf)
call TermWait(buf)
call assert_equal('n', mode())
call assert_match('%aF[^\n]*finished]', execute('ls'))
call assert_match('%aF[^\n]*finished]', execute('ls F'))
@@ -48,7 +47,6 @@ func Test_terminal_no_name()
call assert_equal("", bufname(buf))
call assert_match('\[No Name\]', execute('file'))
call StopShellInTerminal(buf)
call TermWait(buf)
endfunc
func Test_terminal_TerminalWinOpen()
@@ -71,7 +69,6 @@ endfunc
func Test_terminal_make_change()
let buf = Run_shell_in_terminal({})
call StopShellInTerminal(buf)
call TermWait(buf)
setlocal modifiable
exe "normal Axxx\<Esc>"
@@ -109,7 +106,6 @@ endfunc
func Test_terminal_split_quit()
let buf = Run_shell_in_terminal({})
call TermWait(buf)
split
quit!
call TermWait(buf)
@@ -363,7 +359,6 @@ func Test_terminal_scrollback()
call assert_inrange(91, 100, lines)
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
set termwinscroll&
call delete('Xtext')
@@ -751,7 +746,6 @@ func Test_terminal_noblock()
let g:job = term_getjob(buf)
call StopShellInTerminal(buf)
call TermWait(buf)
unlet g:job
bwipe
endfunc
@@ -934,7 +928,6 @@ func TerminalTmap(remap)
call term_sendkeys(buf, "\r")
call StopShellInTerminal(buf)
call TermWait(buf)
tunmap 123
tunmap 456
@@ -952,7 +945,6 @@ func Test_terminal_wall()
let buf = Run_shell_in_terminal({})
wall
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
unlet g:job
endfunc
@@ -961,7 +953,6 @@ func Test_terminal_wqall()
let buf = Run_shell_in_terminal({})
call assert_fails('wqall', 'E948:')
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
unlet g:job
endfunc
@@ -2001,7 +1992,6 @@ func Test_terminal_ansicolors_default()
let buf = Run_shell_in_terminal({})
call assert_equal(colors, term_getansicolors(buf))
call StopShellInTerminal(buf)
call TermWait(buf)
call assert_equal([], term_getansicolors(buf))
exe buf . 'bwipe'
@@ -2026,7 +2016,6 @@ func Test_terminal_ansicolors_global()
let buf = Run_shell_in_terminal({})
call assert_equal(g:terminal_ansi_colors, term_getansicolors(buf))
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
unlet g:terminal_ansi_colors
@@ -2060,7 +2049,6 @@ func Test_terminal_ansicolors_func()
call assert_fails('call term_setansicolors(buf, {})', 'E714:')
call StopShellInTerminal(buf)
call TermWait(buf)
call assert_equal(0, term_setansicolors(buf, []))
exe buf . 'bwipe'
endfunc

View File

@@ -49,7 +49,6 @@ func Test_terminal_termwinsize_option_zero()
let win = bufwinid(buf)
call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
set termwinsize=7x0
@@ -57,7 +56,6 @@ func Test_terminal_termwinsize_option_zero()
let win = bufwinid(buf)
call assert_equal([7, winwidth(win)], term_getsize(buf))
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
set termwinsize=0x33
@@ -65,7 +63,6 @@ func Test_terminal_termwinsize_option_zero()
let win = bufwinid(buf)
call assert_equal([winheight(win), 33], term_getsize(buf))
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
set termwinsize=
@@ -95,7 +92,6 @@ func Test_terminal_termwinsize_minimum()
call assert_equal(30, winwidth(win))
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
set termwinsize=0*0
@@ -103,7 +99,6 @@ func Test_terminal_termwinsize_minimum()
let win = bufwinid(buf)
call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
set termwinsize=
@@ -287,7 +282,6 @@ func Test_zz1_terminal_in_gui()
call assert_equal(1, winnr('$'))
let buf = Run_shell_in_terminal({'term_finish': 'close'})
call StopShellInTerminal(buf)
call TermWait(buf)
" closing window wipes out the terminal buffer a with finished job
call WaitForAssert({-> assert_equal(1, winnr('$'))})
@@ -572,7 +566,6 @@ func Test_term_gettty()
call assert_equal('', term_gettty(buf + 1))
call StopShellInTerminal(buf)
call TermWait(buf)
exe buf . 'bwipe'
endfunc

View File

@@ -779,8 +779,6 @@ endfunc
func Test_terminal_sync_shell_dir()
CheckUnix
" The test always use sh (see src/testdir/unix.vim).
" However, BSD's sh doesn't seem to play well with OSC 7 escape sequence.
CheckNotBSD
set asd
" , is
@@ -789,15 +787,15 @@ func Test_terminal_sync_shell_dir()
let chars = ",a"
" "," is url-encoded as '%2C'
let chars_url = "%2Ca"
let tmpfolder = fnamemodify(tempname(),':h').'/'.chars
let tmpfolder_url = fnamemodify(tempname(),':h').'/'.chars_url
let tmpfolder = fnamemodify(tempname(),':h') .. '/' .. chars
let tmpfolder_url = fnamemodify(tempname(),':h') .. '/' .. chars_url
call mkdir(tmpfolder, "p")
let buf = Run_shell_in_terminal({})
call term_sendkeys(buf, "echo -ne $'\\e\]7;file://".tmpfolder_url."\\a'\<CR>")
"call term_sendkeys(buf, "cd ".tmpfolder."\<CR>")
call term_sendkeys(buf, "echo $'\\e\]7;file://" .. tmpfolder_url .. "\\a'\<CR>")
"call term_sendkeys(buf, "cd " .. tmpfolder .. "\<CR>")
call TermWait(buf)
if has("mac")
let expected = "/private".tmpfolder
let expected = "/private" .. tmpfolder
else
let expected = tmpfolder
endif

View File

@@ -1091,7 +1091,7 @@ def Test_import_gone_when_sourced_twice()
enddef
" test using an auto-loaded function and variable
def Test_vim9_autoload()
def Test_vim9_autoload_full_name()
var lines =<< trim END
vim9script
def some#gettest(): string
@@ -1146,11 +1146,16 @@ def Test_vim9script_autoload()
return 'test'
enddef
export func GetMore()
return Gettest() .. 'more'
export var name = 'name'
export func GetFunc()
return Gettest() .. 'more' .. s:name
endfunc
export var name = 'name'
export def GetDef(): string
return Gettest() .. 'more' .. name
enddef
export final fname = 'final'
export const cname = 'const'
END
@@ -1165,7 +1170,8 @@ def Test_vim9script_autoload()
assert_equal('test', prefixed.Gettest())
assert_equal(1, g:prefixed_loaded)
assert_equal('testmore', prefixed.GetMore())
assert_equal('testmorename', prefixed.GetFunc())
assert_equal('testmorename', prefixed.GetDef())
assert_equal('name', prefixed.name)
assert_equal('final', prefixed.fname)
assert_equal('const', prefixed.cname)
@@ -1178,7 +1184,7 @@ def Test_vim9script_autoload()
# can also get the items by autoload name
lines =<< trim END
call assert_equal('test', prefixed#Gettest())
call assert_equal('testmore', prefixed#GetMore())
call assert_equal('testmorename', prefixed#GetFunc())
call assert_equal('name', prefixed#name)
call assert_equal('final', prefixed#fname)
call assert_equal('const', prefixed#cname)
@@ -1375,6 +1381,31 @@ def Test_vim9_aucmd_autoload()
&rtp = save_rtp
enddef
" test using a autoloaded file that is case sensitive
def Test_vim9_autoload_case_sensitive()
var lines =<< trim END
vim9script autoload
export def CaseSensitive(): string
return 'done'
enddef
END
mkdir('Xdir/autoload', 'p')
writefile(lines, 'Xdir/autoload/CaseSensitive.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
lines =<< trim END
vim9script
import autoload 'CaseSensitive.vim'
assert_equal('done', CaseSensitive.CaseSensitive())
END
CheckScriptSuccess(lines)
delete('Xdir', 'rf')
&rtp = save_rtp
enddef
" This was causing a crash because suppress_errthrow wasn't reset.
def Test_vim9_autoload_error()
var lines =<< trim END

View File

@@ -205,8 +205,19 @@ func Test_xxd()
exe '%!' . s:xxd_cmd . ' -c 21 -d %'
call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
" TODO:
" -o -offset
" Test 16: -o -offset
let s:test += 1
let expected = [
\ '0000000f: 310a 320a 330a 340a 350a 360a 370a 380a 1.2.3.4.5.6.7.8.',
\ '0000001f: 390a 3130 0a31 310a 3132 0a31 330a 3134 9.10.11.12.13.14',
\ '0000002f: 0a31 350a 3136 0a31 370a 3138 0a31 390a .15.16.17.18.19.',
\ '0000003f: 3230 0a32 310a 3232 0a32 330a 3234 0a32 20.21.22.23.24.2',
\ '0000004f: 350a 3236 0a32 370a 3238 0a32 390a 3330 5.26.27.28.29.30',
\ '0000005f: 0a .']
for arg in ['-o 15', '-offset 15', '-o15']
exe '%!' . s:xxd_cmd . ' ' . arg . ' %'
call assert_equal(expected, getline(1,'$'), s:Mess(s:test))
endfor
%d
bwipe!
@@ -255,7 +266,7 @@ endfunc
" Various ways with wrong arguments that trigger the usage output.
func Test_xxd_usage()
for arg in ['-c', '-g', '-o', '-s', '-l', '-X', 'one two three']
for arg in ['-h', '-c', '-g', '-o', '-s', '-l', '-X', 'one two three']
new
exe 'r! ' . s:xxd_cmd . ' ' . arg
call assert_match("Usage:", join(getline(1, 3)))
@@ -284,4 +295,43 @@ func Test_xxd_version()
bwipe!
endfunc
" number of columns must be non-negative
func Test_xxd_min_cols()
for cols in ['-c-1', '-c -1', '-cols -1']
for fmt in ['', '-b', '-e', '-i', '-p', ]
new
exe 'r! printf "ignored" | ' . s:xxd_cmd . ' ' . cols . ' ' . fmt
call assert_match("invalid number of columns", join(getline(1, '$')))
bwipe!
endfor
endfor
endfunc
" some hex formats limit columns to 256 (a #define in xxd.c)
func Test_xxd_max_cols()
for cols in ['-c257', '-c 257', '-cols 257']
for fmt in ['', '-b', '-e' ]
new
exe 'r! printf "ignored" | ' . s:xxd_cmd . ' ' . cols . ' ' . fmt
call assert_match("invalid number of columns", join(getline(1, '$')))
bwipe!
endfor
endfor
endfunc
" -c0 selects the format specific default column value, as if no -c was given
func Test_xxd_c0_is_def_cols()
call writefile(["abcdefghijklmnopqrstuvwxyz0123456789"], 'Xxdin')
for cols in ['-c0', '-c 0', '-cols 0']
for fmt in ['', '-b', '-e', '-i', '-p', ]
exe 'r! ' . s:xxd_cmd . ' ' . fmt ' Xxdin > Xxdout1'
exe 'r! ' . s:xxd_cmd . ' ' . cols . ' ' . fmt ' Xxdin > Xxdout2'
call assert_equalfile('Xxdout1', 'Xxdout2')
endfor
endfor
call delete('Xxdin')
call delete('Xxdout1')
call delete('Xxdout2')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -750,6 +750,24 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4084,
/**/
4083,
/**/
4082,
/**/
4081,
/**/
4080,
/**/
4079,
/**/
4078,
/**/
4077,
/**/
4076,
/**/
4075,
/**/

View File

@@ -133,7 +133,8 @@ ex_vim9script(exarg_T *eap UNUSED)
si->sn_state = SN_STATE_HAD_COMMAND;
// Store the prefix with the script. It isused to find exported functions.
si->sn_autoload_prefix = get_autoload_prefix(si);
if (si->sn_autoload_prefix == NULL)
si->sn_autoload_prefix = get_autoload_prefix(si);
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
si->sn_version = SCRIPT_VERSION_VIM9;