Re: vim patch: fixing resetting dictionary function

2006-06-15 Thread Bram Moolenaar

Richard Emberson wrote:

> The attached file was produced with "diff -c eval.c  eval.c.original".

That's easier to understand, thanks.

-- 
hundred-and-one symptoms of being an internet addict:
246. You use up your free 100 hours in less than a week.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: vim patch: fixing resetting dictionary function

2006-06-15 Thread Richard Emberson

The attached file was produced with "diff -c eval.c  eval.c.original".


Eric Arnold wrote:

I think Bram was asking you to use "diff -c"  or  "diff -u"  to create
the patch file.



On 6/15/06, Richard Emberson <[EMAIL PROTECTED]> wrote:

Attached is a patch file. Is this what you wanted?
Its been almost 20 years since I programmed in 'c'
and the vim 'c' code is rather hard to grok if one
is looking at it for the first time, so I do not
claim that my patch is the best way to do it.

It seems that after the function is defined, it is
then referenced by its number, but the function
definition code expects a function name.

Richard

Bram Moolenaar wrote:
> Richard Emberson wrote:
>
>> In the following I am creating a dictionary, associating a function
>> with the dictionary and then reassociating a new function
>> with the name of the original function.
>>
>> Try this without the fix and you get:
>> ADD
>> n=9
>> Error detected while processing /home/emberson/vim/foo.vim:
>> line   14:
>> E475: Invalid argument: 1
>> ADD
>> n=9
>>
>> Note that "1" is the index of the function in the dictionary.
>>
>> Try it with the fix you get:
>> ADD
>> n=9
>> MULTIPLY
>> n=20
>
> This makes sense.  Can you please provide a context diff so that it's
> easier to see what you are changing?
>


--
This email message is for the sole use of the intended recipient(s) and
may contain confidential information.  Any unauthorized review, use,
disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies of the original message.


patch for eval.c:

18410c18410,18420
< while (arg[j] != NUL && (j == 0 ?  eval_isnamec1(arg[j])
---
> /* The name can be an index into a dictionary. */
> /* There maybe a better way, this demonstrates a fix. */
> while (arg[j] != NUL && VIM_ISDIGIT(arg[j]))
> ++j;
> if (arg[j] != NUL)
> {
> if (*arg == K_SPECIAL)
> j = 3;
> else
> j = 0;
> while (arg[j] != NUL && (j == 0 ?  eval_isnamec1(arg[j])
18413,18414c18423,18425
< if (arg[j] != NUL)
< emsg_funcname(_(e_invarg2), arg);
---
> if (arg[j] != NUL)
> emsg_funcname(_(e_invarg2), arg);
> }










--
This email message is for the sole use of the intended recipient(s) and
may contain confidential information.  Any unauthorized review, use,
disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies of the original message.
*** eval.c  2006-06-15 11:05:16.0 -0700
--- eval.c.original 2006-06-15 11:02:59.0 -0700
***
*** 18407,18435 
j = 3;
else
j = 0;
- /* The name can be an index into a dictionary. */
- /* There maybe a better way, this demonstrates a fix. */
- while (arg[j] != NUL && VIM_ISDIGIT(arg[j]))
- ++j;
- if (arg[j] != NUL)
- {
- if (*arg == K_SPECIAL)
- j = 3;
- else
- j = 0;
- while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
-   : eval_isnamec(arg[j])))
- ++j;
- if (arg[j] != NUL)
- emsg_funcname(_(e_invarg2), arg);
- }
- /*
while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
  : eval_isnamec(arg[j])))
++j;
if (arg[j] != NUL)
emsg_funcname(_(e_invarg2), arg);
- */
}
  }
  
--- 18407,18417 


Re: vim patch: fixing resetting dictionary function

2006-06-15 Thread Eric Arnold

I think Bram was asking you to use "diff -c"  or  "diff -u"  to create
the patch file.



On 6/15/06, Richard Emberson <[EMAIL PROTECTED]> wrote:

Attached is a patch file. Is this what you wanted?
Its been almost 20 years since I programmed in 'c'
and the vim 'c' code is rather hard to grok if one
is looking at it for the first time, so I do not
claim that my patch is the best way to do it.

It seems that after the function is defined, it is
then referenced by its number, but the function
definition code expects a function name.

Richard

Bram Moolenaar wrote:
> Richard Emberson wrote:
>
>> In the following I am creating a dictionary, associating a function
>> with the dictionary and then reassociating a new function
>> with the name of the original function.
>>
>> Try this without the fix and you get:
>> ADD
>> n=9
>> Error detected while processing /home/emberson/vim/foo.vim:
>> line   14:
>> E475: Invalid argument: 1
>> ADD
>> n=9
>>
>> Note that "1" is the index of the function in the dictionary.
>>
>> Try it with the fix you get:
>> ADD
>> n=9
>> MULTIPLY
>> n=20
>
> This makes sense.  Can you please provide a context diff so that it's
> easier to see what you are changing?
>


--
This email message is for the sole use of the intended recipient(s) and
may contain confidential information.  Any unauthorized review, use,
disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies of the original message.


patch for eval.c:

18410c18410,18420
< while (arg[j] != NUL && (j == 0 ?  eval_isnamec1(arg[j])
---
> /* The name can be an index into a dictionary. */
> /* There maybe a better way, this demonstrates a fix. */
> while (arg[j] != NUL && VIM_ISDIGIT(arg[j]))
> ++j;
> if (arg[j] != NUL)
> {
> if (*arg == K_SPECIAL)
> j = 3;
> else
> j = 0;
> while (arg[j] != NUL && (j == 0 ?  eval_isnamec1(arg[j])
18413,18414c18423,18425
< if (arg[j] != NUL)
< emsg_funcname(_(e_invarg2), arg);
---
> if (arg[j] != NUL)
> emsg_funcname(_(e_invarg2), arg);
> }







Re: vim patch: fixing resetting dictionary function

2006-06-15 Thread Richard Emberson

Attached is a patch file. Is this what you wanted?
Its been almost 20 years since I programmed in 'c'
and the vim 'c' code is rather hard to grok if one
is looking at it for the first time, so I do not
claim that my patch is the best way to do it.

It seems that after the function is defined, it is
then referenced by its number, but the function
definition code expects a function name.

Richard

Bram Moolenaar wrote:

Richard Emberson wrote:


In the following I am creating a dictionary, associating a function
with the dictionary and then reassociating a new function
with the name of the original function.

Try this without the fix and you get:
ADD
n=9
Error detected while processing /home/emberson/vim/foo.vim:
line   14:
E475: Invalid argument: 1
ADD
n=9

Note that "1" is the index of the function in the dictionary.

Try it with the fix you get:
ADD
n=9
MULTIPLY
n=20


This makes sense.  Can you please provide a context diff so that it's
easier to see what you are changing?




--
This email message is for the sole use of the intended recipient(s) and
may contain confidential information.  Any unauthorized review, use,
disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies of the original message.
patch for eval.c:

18410c18410,18420
< while (arg[j] != NUL && (j == 0 ?  eval_isnamec1(arg[j])
---
> /* The name can be an index into a dictionary. */
> /* There maybe a better way, this demonstrates a fix. */
> while (arg[j] != NUL && VIM_ISDIGIT(arg[j]))
> ++j;
> if (arg[j] != NUL)
> {
> if (*arg == K_SPECIAL)
> j = 3;
> else
> j = 0;
> while (arg[j] != NUL && (j == 0 ?  eval_isnamec1(arg[j])
18413,18414c18423,18425
< if (arg[j] != NUL)
< emsg_funcname(_(e_invarg2), arg);
---
> if (arg[j] != NUL)
> emsg_funcname(_(e_invarg2), arg);
> }




Re: vim patch: fixing resetting dictionary function

2006-06-15 Thread Bram Moolenaar

Richard Emberson wrote:

> In the following I am creating a dictionary, associating a function
> with the dictionary and then reassociating a new function
> with the name of the original function.
> 
> Try this without the fix and you get:
> ADD
> n=9
> Error detected while processing /home/emberson/vim/foo.vim:
> line   14:
> E475: Invalid argument: 1
> ADD
> n=9
> 
> Note that "1" is the index of the function in the dictionary.
> 
> Try it with the fix you get:
> ADD
> n=9
> MULTIPLY
> n=20

This makes sense.  Can you please provide a context diff so that it's
easier to see what you are changing?

-- 
hundred-and-one symptoms of being an internet addict:
244. You use more than 20 passwords.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


vim patch: fixing resetting dictionary function

2006-05-18 Thread Richard Emberson

In the following I am creating a dictionary, associating a function
with the dictionary and then reassociating a new function
with the name of the original function.

Try this without the fix and you get:
ADD
n=9
Error detected while processing /home/emberson/vim/foo.vim:
line   14:
E475: Invalid argument: 1
ADD
n=9

Note that "1" is the index of the function in the dictionary.

Try it with the fix you get:
ADD
n=9
MULTIPLY
n=20

script:

let x = {}

function x.foo(a,b) dict
echo "ADD"
return a:a + a:b
endfunction

let n = x.foo(4,5)
echo "n=" . n

function! x.foo(a,b) dict
echo "MULTIPLY"
return a:a * a:b
endfunction

let n = x.foo(4,5)
echo "n=" . n


patch for eval.c:

18410c18410,18420
<   while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
---
> /* The name can be an index into a dictionary. */
> /* There maybe a better way, this demonstrates a fix. */
>   while (arg[j] != NUL && VIM_ISDIGIT(arg[j]))
>   ++j;
> if (arg[j] != NUL)
> {
>   if (*arg == K_SPECIAL)
>   j = 3;
>   else
>   j = 0;
>   while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
18413,18414c18423,18425
<   if (arg[j] != NUL)
<   emsg_funcname(_(e_invarg2), arg);
---
>   if (arg[j] != NUL)
>   emsg_funcname(_(e_invarg2), arg);
> }


--
This email message is for the sole use of the intended recipient(s) and
may contain confidential information.  Any unauthorized review, use,
disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies of the original message.