Re: [bug] lambda expressions

2016-09-25 Fir de Conversatie Ken Takata
Hi Bram,

2016/9/23 Fri 3:46:32 UTC+9 Bram Moolenaar wrote:
> Ken Takata wrote:
> 
> > 2016/9/22 Thu 2:37:29 UTC+9 Bram Moolenaar wrote:
> > > Christian Brabandt wrote:
> > > 
> > > > Am 2016-09-21 00:00, schrieb Ken Takata:
> > > > > 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)})
> > > > 
> > > > Hm, should there be an error when only one argument is given?
> > > > Or at least it should be more stressed in the documentatio, that two
> > > > arguments are expected.
> > > 
> > > How about extending the example in the help:
> > > 
> > >   If {expr2} is a |Funcref| it is called with two arguments:
> > >   1. The key or the index of the current item.
> > >   2. the value of the current item.
> > >   The function must return the new value of the item. Example
> > >   that changes each value by "key-value": >
> > >   func KeyValue(key, val)
> > > return a:key . '-' . a:val
> > >   endfunc
> > >   call map(myDict, function('KeyValue'))
> > > < It is shorter when using a |lambda|: >
> > >   call map(myDict, {key, val -> key . '-' . val})
> > > < If you do not use "val" you can leave it out: >
> > >   call map(myDict, {key -> 'item: ' . key})
> > 
> > A similar update might be needed for `:help filter()`.
> 
> How about this:
> 
>   If {expr2} is a |Funcref| it must take two arguments:
>   1. the key or the index of the current item.
>   2. the value of the current item.
>   The function must return |TRUE| if the item should be kept.
>   Example that keeps the odd items of a list: >
>   func Odd(idx, val)
> return a:idx % 2 == 1
>   endfunc
>   call filter(mylist, function('Odd'))
> < It is shorter when using a |lambda|: >
>   call filter(myList, {idx, val -> idx * val <= 42})
> < If you do not use "val" you can leave it out: >
>   call filter(myList, {idx -> idx % 2 == 1})

I found a typo.
Please check the attached patch.

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.
# HG changeset patch
# Parent  483030e5352aa4f69a442102bfc486ee3701166b

diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3732,7 +3732,7 @@ filter({expr1}, {expr2})*filter()*
 			call filter(myList, {idx, val -> idx * val <= 42})
 <		If you do not use "val" you can leave it out: >
 			call filter(myList, {idx -> idx % 2 == 1})
-
+<
 		The operation is done in-place.  If you want a |List| or
 		|Dictionary| to remain unmodified make a copy first: >
 			:let l = filter(copy(mylist), 'v:val =~ "KEEP"')


Patch 8.0.0013

2016-09-25 Fir de Conversatie Bram Moolenaar

Patch 8.0.0013 (after 8.0.0011)
Problem:Missing comma in list.
Solution:   Add the comma.
Files:  src/testdir/runtest.vim


*** ../vim-8.0.0012/src/testdir/runtest.vim 2016-09-25 21:02:58.873621345 
+0200
--- src/testdir/runtest.vim 2016-09-25 22:26:25.141880622 +0200
***
*** 148,154 
\ 'Test_reltime()',
\ 'Test_nb_basic()',
\ 'Test_communicate()',
!   \ 'Test_pipe_through_sort_all()'
\ 'Test_pipe_through_sort_some()'
\ ]
  
--- 148,154 
\ 'Test_reltime()',
\ 'Test_nb_basic()',
\ 'Test_communicate()',
!   \ 'Test_pipe_through_sort_all()',
\ 'Test_pipe_through_sort_some()'
\ ]
  
*** ../vim-8.0.0012/src/version.c   2016-09-25 21:44:59.445600117 +0200
--- src/version.c   2016-09-25 22:27:03.213581523 +0200
***
*** 766,767 
--- 766,769 
  {   /* Add new patch number below this line */
+ /**/
+ 13,
  /**/

-- 
**  Hello and Welcome to the Psychiatric Hotline **
If you are obsessive-compulsive, please press 1 repeatedly.
If you are co-dependent, please ask someone to press 2.
If you have multiple personalities, please press 3, 4, 5 and 6.
If you are paranoid-delusional, we know who you are and what you want
   - just stay on the line so we can trace the call.
If you are schizophrenic, listen carefully and a little voice will
   tell you which number to press next.
If you are manic-depressive, it doesn't matter which number you press
   - no one will answer.
If you suffer from panic attacks, push every button you can find.
If you are sane, please hold on - we have the rest of humanity on the
other line and they desparately want to ask you a few questions.

 /// 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: Patch 8.0.0009

2016-09-25 Fir de Conversatie Bram Moolenaar

Tony Mechelynck wrote:

> On Sun, Sep 25, 2016 at 8:22 PM, Bram Moolenaar  wrote:
> >
> > Patch 8.0.0009
> > Problem:Unecessary workround for AppVeyor.
> > Solution:   Revert patch 7.4.990. (Christian Brabandt)
> > Files:  appveyor.yml
> 
> appveyor.yml includes the following section near the end:
> 
> test_script:
>   - cd src/testdir
> # Testing with MSVC gvim
>   - path C:\Python35-x64;%PATH%
>   - nmake -f Make_dos.mak VIMPROG=..\gvim
>   - nmake -f Make_dos.mak clean
> # Testing with MingW console version
>   - nmake -f Make_dos.mak VIMPROG=..\vim
> 
> invoking AFAICT the Make_dos.mak makefile, which has been removed. Or
> do I misunderstand?

src/testdir/Make_dos.mak exists and is used for MS-Windows tests.

-- 
Overflow on /dev/null, please empty the bit bucket.

 /// 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.0012

2016-09-25 Fir de Conversatie Bram Moolenaar

Patch 8.0.0012
Problem:Typos in comments.
Solution:   Change "its" to "it's". (Matthew Brener, closes #1088)
Files:  src/evalfunc.c, src/main.aap, src/nbdebug.c, src/netbeans.c,
src/quickfix.c, src/workshop.c, src/wsdebug.c


*** ../vim-8.0.0011/src/evalfunc.c  2016-09-14 22:16:09.859803666 +0200
--- src/evalfunc.c  2016-09-25 21:41:24.523287983 +0200
***
*** 6874,6880 
return;
  
  #ifdef FEAT_LIBCALL
! /* The first two args must be strings, otherwise its meaningless */
  if (argvars[0].v_type == VAR_STRING && argvars[1].v_type == VAR_STRING)
  {
string_in = NULL;
--- 6874,6880 
return;
  
  #ifdef FEAT_LIBCALL
! /* The first two args must be strings, otherwise it's meaningless */
  if (argvars[0].v_type == VAR_STRING && argvars[1].v_type == VAR_STRING)
  {
string_in = NULL;
*** ../vim-8.0.0011/src/main.aap2016-02-27 18:04:31.0 +0100
--- src/main.aap2016-09-25 21:41:24.523287983 +0200
***
*** 69,75 
  --with-mac-arch=$arch
  --cache-file=auto/config.cache
  
! # Configure arguments: create an empty "config.arg" file when its missing
  config.arg:
  :touch {exist} config.arg
  
--- 69,75 
  --with-mac-arch=$arch
  --cache-file=auto/config.cache
  
! # Configure arguments: create an empty "config.arg" file when it's missing
  config.arg:
  :touch {exist} config.arg
  
*** ../vim-8.0.0011/src/nbdebug.c   2016-08-29 22:42:20.0 +0200
--- src/nbdebug.c   2016-09-25 21:41:24.523287983 +0200
***
*** 41,47 
  
  /*
   * nbdebug_wait   -   This function can be used to delay or stop 
execution of vim.
!  *Its normally used to delay startup while attaching a
   *debugger to a running process. Since workshop starts gvim
   *from a background process this is the only way to debug
   *startup problems.
--- 41,47 
  
  /*
   * nbdebug_wait   -   This function can be used to delay or stop 
execution of vim.
!  *It's normally used to delay startup while attaching a
   *debugger to a running process. Since workshop starts gvim
   *from a background process this is the only way to debug
   *startup problems.
*** ../vim-8.0.0011/src/netbeans.c  2016-08-29 22:42:20.0 +0200
--- src/netbeans.c  2016-09-25 21:41:24.523287983 +0200
***
*** 2156,2162 
else if (streq((char *)cmd, "save"))
{
/*
!* NOTE - This command is obsolete wrt NetBeans. Its left in
 * only for historical reasons.
 */
if (buf == NULL || buf->bufp == NULL)
--- 2156,2162 
else if (streq((char *)cmd, "save"))
{
/*
!* NOTE - This command is obsolete wrt NetBeans. It's left in
 * only for historical reasons.
 */
if (buf == NULL || buf->bufp == NULL)
***
*** 2242,2248 
  
  /*
   * Is this needed? I moved the netbeans_Xt_connect() later during startup
!  * and it may no longer be necessary. If its not needed then needupdate
   * and do_update can also be removed.
   */
  if (buf != NULL && buf->initDone && do_update)
--- 2242,2248 
  
  /*
   * Is this needed? I moved the netbeans_Xt_connect() later during startup
!  * and it may no longer be necessary. If it's not needed then needupdate
   * and do_update can also be removed.
   */
  if (buf != NULL && buf->initDone && do_update)
***
*** 2856,2862 
  }
  
  /*
!  * Send a button release event back to netbeans. Its up to netbeans
   * to decide what to do (if anything) with this event.
   */
  void
--- 2856,2862 
  }
  
  /*
!  * Send a button release event back to netbeans. It's up to netbeans
   * to decide what to do (if anything) with this event.
   */
  void
***
*** 3453,3459 
  
  
  /*
!  * This message is printed after NetBeans opens a new file. Its
   * similar to the message readfile() uses, but since NetBeans
   * doesn't normally call readfile, we do our own.
   */
--- 3453,3459 
  
  
  /*
!  * This message is printed after NetBeans opens a new file. It's
   * similar to the message readfile() uses, but since NetBeans
   * doesn't normally call readfile, we do our own.
   */
*** ../vim-8.0.0011/src/quickfix.c  2016-09-01 15:40:55.0 +0200
--- src/quickfix.c  2016-09-25 21:41:24.523287983 +0200
***
*** 3569,3575 
STRCAT(name, p + 2);
if (mch_getperm(name) < 0
  #ifdef HAVE_LSTAT
!   /* Don't accept a symbolic link, its a security risk. */
&& mch_lstat((char *)name, &sb) < 0
  #endif
)
-

Re: ratpoison.vim syntax update

2016-09-25 Fir de Conversatie Bram Moolenaar

Magnus Woldrich wrote:

> Attached is a patch, 
>   - fixing missing 'gravity' highlighting
>   - introducing the "new" 'maxundos' setting
>   - introducing the (in ratpoison) undocumented setting 'framefmt' which takes
> the same arguments as 'winfmt'

This is a patch without context, that can easily go wrong, esp. with new
lines.  Please send the whole file to me, it's not that big.

This patch reverts the change to use "hi def link" instead of "HiLink".
Please first include those changes.


-- 
Why doesn't Tarzan have a beard?

 /// 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: [vim/vim] Vim 8.0.5 crashes if unecrypted file text begins exactly like text in encrypted Vim file (#1096)

2016-09-25 Fir de Conversatie Bram Moolenaar

Christian Brabandt wrote:

> > Hi Bram!
> > 
> > On Do, 22 Sep 2016, Bram Moolenaar wrote:
> > 
> > > 
> > > Christian Brabandt wrote:
> > > 
> > > > This patch fixes it.
> > > > ```patch
> > > > diff --git a/src/fileio.c b/src/fileio.c
> > > > index ea1f338..193e4fd 100644
> > > > --- a/src/fileio.c
> > > > +++ b/src/fileio.c
> > > > @@ -3011,6 +3011,9 @@ check_for_cryptkey(
> > > > 
> > > > /* Remove cryptmethod specific header from the text. */
> > > > header_len = crypt_get_header_len(method);
> > > > +   if (*sizep <= header_len)
> > > > +   /* buffer can't be encrypted */
> > > > +   return NULL;
> > > > *filesizep += header_len;
> > > > *sizep -= header_len;
> > > > mch_memmove(ptr, ptr + header_len, (size_t)*sizep);
> > > > ```
> > > 
> > > Thanks.  Would be good to have a test.  Should be possible by writing an
> > > encrypted file and then opening it in binary mode.
> > 
> > Updated patch attached.
> 
> Sorry, the patch did not survive github. This time really attached to 
> the vim-dev list.

I had just sent out a patch with a similar test.  It was based on the
original problem description.  Sorry for being impatient!


-- 
FATHER:Who are you?
PRINCE:I'm ... your son ...
FATHER:Not you.
LAUNCELOT: I'm ... er ... Sir Launcelot, sir.
 "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.


Re: Patch 8.0.0009

2016-09-25 Fir de Conversatie Tony Mechelynck
On Sun, Sep 25, 2016 at 8:22 PM, Bram Moolenaar  wrote:
>
> Patch 8.0.0009
> Problem:Unecessary workround for AppVeyor.
> Solution:   Revert patch 7.4.990. (Christian Brabandt)
> Files:  appveyor.yml

appveyor.yml includes the following section near the end:

test_script:
  - cd src/testdir
# Testing with MSVC gvim
  - path C:\Python35-x64;%PATH%
  - nmake -f Make_dos.mak VIMPROG=..\gvim
  - nmake -f Make_dos.mak clean
# Testing with MingW console version
  - nmake -f Make_dos.mak VIMPROG=..\vim

invoking AFAICT the Make_dos.mak makefile, which has been removed. Or
do I misunderstand?


Best regards,
Tony.

-- 
-- 
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.0011

2016-09-25 Fir de Conversatie Bram Moolenaar

Patch 8.0.0011
Problem:On OSX Test_pipe_through_sort_all() sometimes fails.
Solution:   Add the test to the list of flaky tests.
Files:  src/testdir/runtest.vim

*** ../vim-8.0.0010/src/testdir/runtest.vim 2016-09-12 13:29:37.0 
+0200
--- src/testdir/runtest.vim 2016-09-25 21:01:20.110404552 +0200
***
*** 148,153 
--- 148,154 
\ 'Test_reltime()',
\ 'Test_nb_basic()',
\ 'Test_communicate()',
+   \ 'Test_pipe_through_sort_all()'
\ 'Test_pipe_through_sort_some()'
\ ]
  
*** ../vim-8.0.0010/src/version.c   2016-09-25 20:54:46.549538851 +0200
--- src/version.c   2016-09-25 21:01:17.658424012 +0200
***
*** 766,767 
--- 766,769 
  {   /* Add new patch number below this line */
+ /**/
+ 11,
  /**/

-- 
FIRST GUARD: Ah!  Now ... we're not allowed to ...
   SIR LAUNCELOT runs him through,  grabs his spear and stabs the other
   guard who collapses in a heap.  Hiccoughs quietly.
 "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.0010

2016-09-25 Fir de Conversatie Bram Moolenaar

Patch 8.0.0010
Problem:Crash when editing file that starts with crypt yeader. (igor2x)
Solution:   Check for length of text. (Christian Brabandt) Add a test.
Files:  src/fileio.c, src/testdir/test_crypt.vim, src/Makefile,
src/testdir/Make_all.mak


*** ../vim-8.0.0009/src/fileio.c2016-09-03 16:58:56.0 +0200
--- src/fileio.c2016-09-25 20:45:03.194238557 +0200
***
*** 3011,3016 
--- 3011,3019 
  
/* Remove cryptmethod specific header from the text. */
header_len = crypt_get_header_len(method);
+   if (*sizep <= header_len)
+   /* invalid header, buffer can't be encrypted */
+   return NULL;
*filesizep += header_len;
*sizep -= header_len;
mch_memmove(ptr, ptr + header_len, (size_t)*sizep);
*** ../vim-8.0.0009/src/testdir/test_crypt.vim  2016-09-25 20:50:18.387694352 
+0200
--- src/testdir/test_crypt.vim  2016-09-25 20:49:42.123986969 +0200
***
*** 0 
--- 1,21 
+ " Tests for encryption.
+ " TODO: include tests from test71.
+ 
+ func Common_head_only(text)
+   " This was crashing Vim
+   split Xtest.txt
+   call setline(1, a:text)
+   wq
+   call feedkeys(":split Xtest.txt\foobar\", "tx")
+   call delete('Xtest.txt')
+   call assert_match('VimCrypt', getline(1))
+   bwipe!
+ endfunc
+ 
+ func Test_head_only_2()
+   call Common_head_only('VimCrypt~02!abc')
+ endfunc
+ 
+ func Test_head_only_3()
+   call Common_head_only('VimCrypt~03!abc')
+ endfunc
*** ../vim-8.0.0009/src/Makefile2016-09-12 13:41:08.0 +0200
--- src/Makefile2016-09-25 20:38:05.889563491 +0200
***
*** 2066,2071 
--- 2066,2072 
test_channel \
test_charsearch \
test_cmdline \
+   test_crypt \
test_cscope \
test_cursor_func \
test_delete \
*** ../vim-8.0.0009/src/testdir/Make_all.mak2016-09-07 20:37:01.0 
+0200
--- src/testdir/Make_all.mak2016-09-25 20:38:28.705380237 +0200
***
*** 149,154 
--- 149,155 
test_channel.res \
test_charsearch.res \
test_cmdline.res \
+   test_crypt.res \
test_cscope.res \
test_diffmode.res \
test_digraph.res \
*** ../vim-8.0.0009/src/version.c   2016-09-25 20:21:58.333062395 +0200
--- src/version.c   2016-09-25 20:50:47.543459277 +0200
***
*** 766,767 
--- 766,769 
  {   /* Add new patch number below this line */
+ /**/
+ 10,
  /**/

-- 
   LAUNCELOT leaps into SHOT with a mighty cry and runs the GUARD through and
   hacks him to the floor.  Blood.  Swashbuckling music (perhaps).
   LAUNCELOT races through into the castle screaming.
SECOND SENTRY: Hey!
 "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.


Re: [vim/vim] Vim 8.0.5 crashes if unecrypted file text begins exactly like text in encrypted Vim file (#1096)

2016-09-25 Fir de Conversatie Christian Brabandt
On So, 25 Sep 2016, vim-dev ML wrote:

> Hi Bram!
> 
> On Do, 22 Sep 2016, Bram Moolenaar wrote:
> 
> > 
> > Christian Brabandt wrote:
> > 
> > > This patch fixes it.
> > > ```patch
> > > diff --git a/src/fileio.c b/src/fileio.c
> > > index ea1f338..193e4fd 100644
> > > --- a/src/fileio.c
> > > +++ b/src/fileio.c
> > > @@ -3011,6 +3011,9 @@ check_for_cryptkey(
> > > 
> > > /* Remove cryptmethod specific header from the text. */
> > > header_len = crypt_get_header_len(method);
> > > +   if (*sizep <= header_len)
> > > +   /* buffer can't be encrypted */
> > > +   return NULL;
> > > *filesizep += header_len;
> > > *sizep -= header_len;
> > > mch_memmove(ptr, ptr + header_len, (size_t)*sizep);
> > > ```
> > 
> > Thanks.  Would be good to have a test.  Should be possible by writing an
> > encrypted file and then opening it in binary mode.
> 
> Updated patch attached.

Sorry, the patch did not survive github. This time really attached to 
the vim-dev list.

Best,
Christian
-- 
Wenn man einen Tausendfüßler erklären lassen würde, nach welchem
Schema er eigentlich gehe, so wird dieser auf der Stelle unfähig sein,
auch nur einen einzelnen Schritt zu machen.
-- Josef Mittendorfer

-- 
-- 
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.
From aabead5922feab118f30e2d80b236da22d4843cd Mon Sep 17 00:00:00 2001
From: Christian Brabandt 
Date: Sun, 25 Sep 2016 20:50:00 +0200
Subject: [PATCH] Add safety check, when trying to read a file, that looks
 encrypted

---
 src/fileio.c   |  3 +++
 src/testdir/Make_all.mak   |  1 +
 src/testdir/test_crypt.vim | 16 
 3 files changed, 20 insertions(+)
 create mode 100644 src/testdir/test_crypt.vim

diff --git a/src/fileio.c b/src/fileio.c
index ea1f338..5cddca2 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3011,6 +3011,9 @@ check_for_cryptkey(
 
 	/* Remove cryptmethod specific header from the text. */
 	header_len = crypt_get_header_len(method);
+if (*sizep <= header_len)
+		/* buffer can't be encrypted */
+		return NULL;
 	*filesizep += header_len;
 	*sizep -= header_len;
 	mch_memmove(ptr, ptr + header_len, (size_t)*sizep);
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 65ad3ee..999f519 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -149,6 +149,7 @@ NEW_TESTS = test_arglist.res \
 	test_channel.res \
 	test_charsearch.res \
 	test_cmdline.res \
+	test_crypt.res \
 	test_cscope.res \
 	test_diffmode.res \
 	test_digraph.res \
diff --git a/src/testdir/test_crypt.vim b/src/testdir/test_crypt.vim
new file mode 100644
index 000..53367b4
--- /dev/null
+++ b/src/testdir/test_crypt.vim
@@ -0,0 +1,16 @@
+" Test for crypt mode
+
+fun! Test_crypted()
+  new
+  call append(0, 'VimCrypt~02!abc')
+  w! Xnon_crypted.txt
+  bw!
+  new
+  f Xnon_crypted.txt
+  set key=key
+  e!
+  call assert_equal('VimCrypt~02!abc', getline(1))
+  set key=
+  bw!
+  call delete('Xnon_crypted.txt')
+endfu
-- 
2.1.4



Patch 8.0.0009

2016-09-25 Fir de Conversatie Bram Moolenaar

Patch 8.0.0009
Problem:Unecessary workround for AppVeyor.
Solution:   Revert patch 7.4.990. (Christian Brabandt)
Files:  appveyor.yml


*** ../vim-8.0.0008/appveyor.yml2016-09-02 22:23:53.0 +0200
--- appveyor.yml2016-09-25 20:20:56.657530826 +0200
***
*** 16,24 
  
  before_build:
- '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 
/release'
-   # Work around for Python 2.7.11's bug
-   - reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 
HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:32
-   - reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 
HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:64
  
  build_script:
- src/appveyor.bat
--- 16,21 
*** ../vim-8.0.0008/src/version.c   2016-09-22 21:27:08.360782126 +0200
--- src/version.c   2016-09-25 20:21:15.549387313 +0200
***
*** 766,767 
--- 766,769 
  {   /* Add new patch number below this line */
+ /**/
+ 9,
  /**/

-- 
Apologies for taking up the bandwidth with the apology.  Anything else I
can apologise for .. er no can't think of anything, sorry about that.
Andy Hunt (Member of British Olympic Apology Squad)

 /// 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: setpos() behaves erratically at times

2016-09-25 Fir de Conversatie Axel Bender
IS the conclusion I made in my previous post correct?

Can we generally NOT assume to start in CHARWISE Visual mode when entering 
operator-pending mode?

If so, where would that be described in the docs?

-- 
-- 
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.