PATCH: allow multiple spaces before the last argument to :cscope find

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

PATCH: allow multiple spaces before the last argument to :cscope find

Lech Lorens
The attached patch makes it possible for the last argument in the
:cscope find [sgdctefi0-8] ...
command to be preceded by multiple spaces.

--
Cheers,
Lech

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---


Index: src/if_cscope.c
===================================================================
--- src/if_cscope.c (revision 1341)
+++ src/if_cscope.c (working copy)
@@ -962,8 +962,7 @@
  return FALSE;
     }
 
-    pat = opt + strlen(opt) + 1;
-    if (pat >= (char *)eap->arg + eap_arg_len)
+    if ((pat = strtok((char *)NULL, (const char *)" ")) == NULL)
     {
  cs_usage_msg(Find);
  return FALSE;
Index: runtime/doc/todo.txt
===================================================================
--- runtime/doc/todo.txt (revision 1341)
+++ runtime/doc/todo.txt (working copy)
@@ -268,9 +268,6 @@
 
 Win32: Patch for cscope external command. (Mike Williams, 2007 Aug 7)
 
-":cscope find f  filename" doesn't work because of the extra space. (Ethan
-Mallove)
-
 Win32: XPM support only works with path without spaces.  Patch by Mathias
 Michaelis, 2006 Jun 9.  Another patch for more path names, 2006 May 31.
 New version: http://members.tcnet.ch/michaelis/vim/patches.zip (also for other
Reply | Threaded
Open this post in threaded view
|

Re: PATCH: allow multiple spaces before the last argument to :cscope find

Dominique Pellé

Lech Lorens wrote:

> The attached patch makes it possible for the last argument in the
> :cscope find [sgdctefi0-8] ...
> command to be preceded by multiple spaces.

But isn't being able to search for something beginning with a space a feature?

For example:

:cs find e  foo
:cs find e foo

The first one searches for " foo"
The second one searches for "foo"

There is another old thread in vim_dev where this was discussed:

http://groups.google.com/group/vim_dev/browse_thread/thread/cafcb4b1fc5fdb90

-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: PATCH: allow multiple spaces before the last argument to :cscope find

Lech Lorens

On 31-01-2009 Dominique Pelle <[hidden email]> wrote:

>
> Lech Lorens wrote:
>
> > The attached patch makes it possible for the last argument in the
> > :cscope find [sgdctefi0-8] ...
> > command to be preceded by multiple spaces.
>
> But isn't being able to search for something beginning with a space a feature?
>
> For example:
>
> :cs find e  foo
> :cs find e foo
>
> The first one searches for " foo"
> The second one searches for "foo"
>
> There is another old thread in vim_dev where this was discussed:
>
> http://groups.google.com/group/vim_dev/browse_thread/thread/cafcb4b1fc5fdb90

Agreed. It seems to me a little bit inconsistent with the other Vim
commands that need to have spaces in their arguments escaped, though.

Anyway, the behaviour I corrected is listed in todo.txt under "Known
bugs" (the patch deletes it from the list). The list is quite long and
I'm trying to make it shorter. This is the second time today that I got
to fixing something listed as a bug, that is a feature in fact. The
other one was:

> When entering a C /* comment, after typing <Enter> for 70 times the indent
> disappears. (Vincent Beffara, 2008 Jul 3)

It's a feature actually - the code responsible for indenting code is
limited to search only the last 70 lines for a comment beginning
(probably so that it doesn't take too long).

It might be a good idea to clean up todo.txt so that people don't
concentrate too much on fixing things that aren't broken.

--
Cheers,
Lech

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: PATCH: allow multiple spaces before the last argument to :cscope find

Tony Mechelynck
In reply to this post by Dominique Pellé

On 31/01/09 15:46, Dominique Pelle wrote:

> Lech Lorens wrote:
>
>> The attached patch makes it possible for the last argument in the
>> :cscope find [sgdctefi0-8] ...
>> command to be preceded by multiple spaces.
>
> But isn't being able to search for something beginning with a space a feature?
>
> For example:
>
> :cs find e  foo
> :cs find e foo
>
> The first one searches for " foo"
> The second one searches for "foo"
>
> There is another old thread in vim_dev where this was discussed:
>
> http://groups.google.com/group/vim_dev/browse_thread/thread/cafcb4b1fc5fdb90
>
> -- Dominique

Hm. What would be the result of

        :cs find e \ foo
or
        :cs find e " foo"

?


Best regards,
Tony.
--
I see a good deal of talk from Washington about lowering taxes.  I hope
they do get 'em lowered enough so people can afford to pay 'em.
                -- Will Rogers

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: PATCH: allow multiple spaces before the last argument to :cscope find

Dominique Pellé

2009/1/31 Tony Mechelynck <[hidden email]>:

>
> On 31/01/09 15:46, Dominique Pelle wrote:
>> Lech Lorens wrote:
>>
>>> The attached patch makes it possible for the last argument in the
>>> :cscope find [sgdctefi0-8] ...
>>> command to be preceded by multiple spaces.
>>
>> But isn't being able to search for something beginning with a space a feature?
>>
>> For example:
>>
>> :cs find e  foo
>> :cs find e foo
>>
>> The first one searches for " foo"
>> The second one searches for "foo"
>>
>> There is another old thread in vim_dev where this was discussed:
>>
>> http://groups.google.com/group/vim_dev/browse_thread/thread/cafcb4b1fc5fdb90
>>
>> -- Dominique
>
> Hm. What would be the result of
>).
>        :cs find e \ foo
> or
>        :cs find e " foo"
>
> ?


No.

:cs find e " foo"

... finds literaly " foo"   i.e. will find <space>foo surrounded
with double quotes.

:cs find e \ foo

... finds lines which start with foo. I'm not sure whether that's
documented but that's what I observe experimentally.

You can try yourself by building a cscope DB on vim sources
for example:

$ cd vim7/src
$ cscope -b -q
$ vim

:cs add cscope.out
:cs help
:cs find e ...

-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: PATCH: allow multiple spaces before the last argument to :cscope find

Gary Johnson-4
In reply to this post by Lech Lorens

On 2009-01-31, Lech Lorens <[hidden email]> wrote:

> Anyway, the behaviour I corrected is listed in todo.txt under "Known
> bugs" (the patch deletes it from the list). The list is quite long and
> I'm trying to make it shorter. This is the second time today that I got
> to fixing something listed as a bug, that is a feature in fact. The
> other one was:
>
> > When entering a C /* comment, after typing <Enter> for 70 times the indent
> > disappears. (Vincent Beffara, 2008 Jul 3)
>
> It's a feature actually - the code responsible for indenting code is
> limited to search only the last 70 lines for a comment beginning
> (probably so that it doesn't take too long).

I would argue that that's still a bug.   The correct, expected
behavior of the feature is that indenting work consistently within
the context of a comment.  The length of the comment should be
irrelevant.

The limit of 70 lines is a feature only in the sense that it
improves performance when indenting on slower computers.

> It might be a good idea to clean up todo.txt so that people don't
> concentrate too much on fixing things that aren't broken.

The code may not be broken in the sense that the current behavior is
the result of an intentional, correctly-coded limitation to improve
performance, but the behavior of the indenting feature is still
imperfect.  I wouldn't remove this issue from todo.txt, but I might
add a comment that the current behavior is intentional.  It could
presumably be fixed with a better algorithm, by adding an option or
command similar to ":syntax sync", or by removing the limitation
entirely, recognizing that computers have gotten faster.

We've used the term "issue" at work rather than "bug" to describe
discrepancies between actual and expected behaviors of code in part
to minimize arguments from programmers that "my code does not have a
bug; that's the way I meant it to behave."

Regards,
Gary



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---