This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: Support for Pascal strings


On Wed, Jun 20, 2001 at 03:21:54PM -0700, Mark Mitchell wrote:

> I think the questions boil down to:
> 
>   - What is the type of "\p..."?
> 
>   - What is the representation of "\p..."?
> 
> I think the answers are:
> 
>   - `char[n]' where `n' is one greater than the number of characters in the
>     string itself , in order to allow room for the `\p'.  And make the 
> elements
>     of the array `const char' in those modes where we do the same for an 
> ordinary
>     string literal.
> 
>   - The string, without a trailing NUL, prefaced with a length byte.

It seems that the answers are actually

   - (const) unsigned char[n] -- makes sense; you want str[0] to be
     usable without a cast in the case where the string is long enough
     that a signed char value would be negative.

   - The string, *with* a trailing NUL, prefaced with a length byte,
     which does not count the NUL.  -- handy in order to pass these
     strings to C-library routines, just add one to the address.

Also I see no reason to forbid C89 string constant concatenation as
long as the \p is at the beginning of the first string constant in the
sequence.  This is difficult with the current logic but will be easy
once string constant concatenation moves into lex_string.

There's also the question of wide strings.  It seems most people are
happy to forbid L"\p...".

-- 
zw               "Shouldn't a witch be eccentric?"
                 "I hope not. I've never been good at cackling."
                 	-- Reinder Dijkhuis, _Rogues of Clwyd-Rhan_


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]