Re: [RFA] new command to search memory

Daniel Jacobowitz
2008-05-02T15:33:32Z

On Wed, Apr 09, 2008 at 01:37:26PM -0700, Doug Evans wrote:
> If I want to search for 'h', 'e', 'l', 'l', 'o' I won't be able to
> use "hello" because that will now include the trailing nul. Often one
> will want the trailing nul, but it does make searching for substrings
> kinda hard. [For completeness' sake, one could change the definition
> of what "hello" means in this context, and if one wants the trailing
> nul, one has to explicitly specify it, e.g. "hello\0". It's
> C-specific though, and the find command is presumably not supposed to
> know the user is thinking in C - that's the whole point. I don't have
> an opinion either way.]
>
> Any suggestions or preferences for whether and how to make searching
> for substrings not excessively clumsy?

I think that "hello" should be five characters, for this purpose.
There's some support for that in C; it's a valid initializer for
either char[5] or char[6] (C99 6.7.8#15).

Would it help if "hello" reached this point as a TYPE_CODE_STRING
but {'a', 'b', '\0'} was TYPE_CODE_ARRAY, so that we could reliably
detect strings? I don't think it's a big deal since people will
normally leave off the braces for the array here anyway.

--
Daniel Jacobowitz
CodeSourcery