Re: [bug] lambda expressions
Hi Christian, 2016/9/21 Wed 5:31:26 UTC+9 Christian Brabandt wrote: > Hi, > I think I found a bug with lambda expressions. > > I was looking into writing some automated tests and was trying to use > the new lambda expressions. However this does not work as expected: > > Here is an example: > #v+ > let a = ['FOOBAR"word"', 'FOOBAR"word2"'] > let pat='^FOOBAR\s\+\zs"[^"]\+"' > let pat2='^FOOBAR\s\+\("[^"]\+"\)' > :echo map(copy(a), 'matchstr(v:val, g:pat)') > -> result ['"word"', '"word2"'] > :echo map(copy(a), {val -> matchstr(val, g:pat)}) > -> BUG: result ['""', '""'], expected ['"word"', '"word2"'] > :echo map(copy(a), 'substitute(v:val, g:pat2, ''\=submatch(1)'',"")') > -> result ['"word"', '"word2"'] > :echo map(copy(a), {val -> substitute(val, g:pat2, '\=submatch(1)', '')}) > -> BUG: result ['0', '1'], expected ['"word", '"word2"'] > #v- This is not a bug. map() always passes two arguments (key and val) to the specified Funcref. So, > :echo map(copy(a), {val -> matchstr(val, g:pat)}) this should be: :echo map(copy(a), {key, val -> matchstr(val, g:pat)}) Or you can still use v:val: :echo map(copy(a), {-> matchstr(v:val, g:pat)}) Regards, Ken Takata -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[bug] lambda expressions
Hi, I think I found a bug with lambda expressions. I was looking into writing some automated tests and was trying to use the new lambda expressions. However this does not work as expected: Here is an example: #v+ let a = ['FOOBAR"word"', 'FOOBAR"word2"'] let pat='^FOOBAR\s\+\zs"[^"]\+"' let pat2='^FOOBAR\s\+\("[^"]\+"\)' :echo map(copy(a), 'matchstr(v:val, g:pat)') -> result ['"word"', '"word2"'] :echo map(copy(a), {val -> matchstr(val, g:pat)}) -> BUG: result ['""', '""'], expected ['"word"', '"word2"'] :echo map(copy(a), 'substitute(v:val, g:pat2, ''\=submatch(1)'',"")') -> result ['"word"', '"word2"'] :echo map(copy(a), {val -> substitute(val, g:pat2, '\=submatch(1)', '')}) -> BUG: result ['0', '1'], expected ['"word", '"word2"'] #v- Best, Christian -- In den ersten Lebensjahren eines Kindes bringen ihm die Eltern Gehen und Sprechen bei, in den späteren verlangen sie dann, daß es stillsitzt und den Mund hält. -- Johann Nepomuk Nestroy -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Proposal][patch] Add `const` for reference only pointer C function argument
Hirohito Higashi wrote: > Title is as it is. > > Merit: > - Compiler optimizations will be a bit smarter. > - Execution speed will be a bit faster. > - Compiler us warn the code assignment wrong. > > Demerit: > - None. (maybe) > > I made a patch for proposal. > How about this? > > When it's Okay, I'll continue with the remaining of the work. In my experience using "const" does not really bring an advantage. Changing the variable anyway would already cause a problem. There is some inconvenience when a called function doesn't have "const", it usually causes a ripple effect of changes. I can't remember a mistake where using "const" would have avoided the problem. -- GALAHAD: No, please. Please! I can defeat them! There's only a hundred. GIRLS: He will beat us easily. We haven't a chance. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- b...@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/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Patch 8.0.0006
Patch 8.0.0006 Problem:":lb" is interpreted as ":lbottom" while the documentation says it means ":lbuffer". Solution: Adjust the order of the commands. (haya14busa, closes #1093) Files: src/ex_cmds.h *** ../vim-8.0.0005/src/ex_cmds.h 2016-08-29 22:42:20.0 +0200 --- src/ex_cmds.h 2016-09-20 21:31:38.097546014 +0200 *** *** 730,741 EX(CMD_later, "later",ex_later, TRLBAR|EXTRA|NOSPC|CMDWIN, ADDR_LINES), - EX(CMD_lbottom, "lbottom", ex_cbottom, - TRLBAR, - ADDR_LINES), EX(CMD_lbuffer, "lbuffer", ex_cbuffer, BANG|RANGE|NOTADR|WORD1|TRLBAR, ADDR_LINES), EX(CMD_lcd, "lcd", ex_cd, BANG|FILE1|TRLBAR|CMDWIN, ADDR_LINES), --- 730,741 EX(CMD_later, "later",ex_later, TRLBAR|EXTRA|NOSPC|CMDWIN, ADDR_LINES), EX(CMD_lbuffer, "lbuffer", ex_cbuffer, BANG|RANGE|NOTADR|WORD1|TRLBAR, ADDR_LINES), + EX(CMD_lbottom, "lbottom", ex_cbottom, + TRLBAR, + ADDR_LINES), EX(CMD_lcd, "lcd", ex_cd, BANG|FILE1|TRLBAR|CMDWIN, ADDR_LINES), *** ../vim-8.0.0005/src/version.c 2016-09-15 11:44:23.361477614 +0200 --- src/version.c 2016-09-20 21:33:28.468757112 +0200 *** *** 766,767 --- 766,769 { /* Add new patch number below this line */ + /**/ + 6, /**/ -- "Intelligence has much less practical application than you'd think." -- Scott Adams, Dilbert. /// Bram Moolenaar -- b...@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/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: NUL in syntax/cdl.vim
Gary Johnson wrote: > While grepping for a certain string under $VIMRUNTIME, I discovered > that syntax/cdl.vim contains a NUL (^@) in a comment (at line 33). > This causes grep to classify it as a binary file and file to > classify it as data. > > The NUL should be removed and replaced with a UTF-8 character, or > better yet, ASCII. > > I tried to send email to the maintainer, Raul Segura Acevedo, but it > was returned because the recipient address was rejected by the > remote host. > > Would someone like to take over maintainership of that file and fix > this? I can fix it, but I don't use CDL, so I wouldn't be an > appropriate maintainer. Let me at least remove that NUL. -- ### Hiroshima 45, Chernobyl 86, Windows 95 ### /// Bram Moolenaar -- b...@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/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Proposal][patch] Add `const` for reference only pointer C function argument
Hi Bram and list, Title is as it is. Merit: - Compiler optimizations will be a bit smarter. - Execution speed will be a bit faster. - Compiler us warn the code assignment wrong. Demerit: - None. (maybe) I made a patch for proposal. How about this? When it's Okay, I'll continue with the remaining of the work. -- Best regards, Hirohito Higashi (a.k.a. h_east) -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. diff --git a/src/buffer.c b/src/buffer.c index b013295..b2fe5fa 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -377,7 +377,7 @@ set_bufref(bufref_T *bufref, buf_T *buf) * Only goes through the buffer list if buf_free_count changed. */ int -bufref_valid(bufref_T *bufref) +bufref_valid(const bufref_T *bufref) { return bufref->br_buf_free_count == buf_free_count ? TRUE : buf_valid(bufref->br_buf); @@ -388,7 +388,7 @@ bufref_valid(bufref_T *bufref) * This can be slow if there are many buffers, prefer using bufref_valid(). */ int -buf_valid(buf_T *buf) +buf_valid(const buf_T *buf) { buf_T *bp; diff --git a/src/eval.c b/src/eval.c index 6873b97..5ec9733 100644 --- a/src/eval.c +++ b/src/eval.c @@ -6696,7 +6696,7 @@ v_throwpoint(char_u *oldval) * Must always be called in pairs! */ char_u * -set_cmdarg(exarg_T *eap, char_u *oldarg) +set_cmdarg(const exarg_T *eap, char_u *oldarg) { char_u *oldval; char_u *newval; diff --git a/src/fileio.c b/src/fileio.c index ea1f338..44f381d 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -7780,7 +7780,7 @@ static char_u *find_end_event(char_u *arg, int have_group); static int event_ignored(event_T event); static int au_get_grouparg(char_u **argp); static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd, int forceit, int group); -static int apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, int force, int group, buf_T *buf, exarg_T *eap); +static int apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, int force, int group, const buf_T *buf, const exarg_T *eap); static void auto_next_pat(AutoPatCmd *apc, int stop_at_last); #if defined(FEAT_AUTOCMD) || defined(FEAT_WILDIGN) static int match_file_pat(char_u *pattern, regprog_T **prog, char_u *fname, char_u *sfname, char_u *tail, int allow_dirs); @@ -7949,7 +7949,7 @@ au_cleanup(void) * autocmds. */ void -aubuflocal_remove(buf_T *buf) +aubuflocal_remove(const buf_T *buf) { AutoPat *ap; event_T event; @@ -9098,7 +9098,7 @@ apply_autocmds( char_u *fname, /* NULL or empty means use actual file name */ char_u *fname_io, /* fname to use for on cmdline */ int force, /* when TRUE, ignore autocmd_busy */ -buf_T *buf) /* buffer for */ +const buf_T *buf) /* buffer for */ { return apply_autocmds_group(event, fname, fname_io, force, AUGROUP_ALL, buf, NULL); @@ -9263,8 +9263,8 @@ apply_autocmds_group( use fname */ int force, /* when TRUE, ignore autocmd_busy */ int group, /* group ID, or AUGROUP_ALL */ -buf_T *buf, /* buffer for */ -exarg_T *eap) /* command arguments */ +const buf_T *buf, /* buffer for */ +const exarg_T *eap) /* command arguments */ { char_u *sfname = NULL; /* short file name */ char_u *tail; diff --git a/src/fold.c b/src/fold.c index d3635a6..42d92ab 100644 --- a/src/fold.c +++ b/src/fold.c @@ -100,7 +100,7 @@ static int foldendmarkerlen; * Copy that folding state from window "wp_from" to window "wp_to". */ void -copyFoldingState(win_T *wp_from, win_T *wp_to) +copyFoldingState(const win_T *wp_from, win_T *wp_to) { wp_to->w_fold_manual = wp_from->w_fold_manual; wp_to->w_foldinvalid = wp_from->w_foldinvalid; @@ -1083,17 +1083,17 @@ foldAdjustCursor(void) * Return FAIL if the operation cannot be completed, otherwise OK. */ void -cloneFoldGrowArray(garray_T *from, garray_T *to) +cloneFoldGrowArray(const garray_T *from, garray_T *to) { int i; -fold_T *from_p; +const fold_T *from_p; fold_T *to_p; ga_init2(to, from->ga_itemsize, from->ga_growsize); if (from->ga_len == 0 || ga_grow(to, from->ga_len) == FAIL) return; -from_p = (fold_T *)from->ga_data; +from_p = (const fold_T *)from->ga_data; to_p = (fold_T *)to->ga_data; for (i = 0; i < from->ga_len; i++) diff --git a/src/mark.c b/src/mark.c index 0627a7c..04e7abf 100644 --- a/src/mark.c +++ b/src/mark.c @@ -1315,7 +1315,7 @@ cleanup_jumplist(void) * Copy the jumplist from window "from" to window
Re: NUL in syntax/cdl.vim
On 2016-09-20, 01:15 GMT, Gary Johnson wrote: > I tried to send email to the maintainer, Raul Segura Acevedo, > but it was returned because the recipient address was rejected > by the remote host. > > Would someone like to take over maintainership of that file > and fix this? I can fix it, but I don't use CDL, so > I wouldn't be an appropriate maintainer. It is git now, so nothing stops from adding a link to your pull suggesting a fix for the issue. Something like https://github.com/vim/vim/pull/1103 ? Best, Matěj -- https://matej.ceplovi.cz/blog/, Jabber: mc...@ceplovi.cz GPG Finger: 3C76 A027 CA45 AD70 98B5 BC1D 7920 5802 880B C9D8 As a rule of thumb, the more qualifiers there are before the name of a country, the more corrupt the rulers. A country called The Socialist People's Democratic Republic of X is probably the last place in the world you'd want to live. -- Paul Graham discussing (not only) Nigerian spam (http://www.paulgraham.com/spam.html) -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.