This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Support for Pascal strings
- To: Mark Mitchell <mark at codesourcery dot com>
- Subject: Re: PATCH: Support for Pascal strings
- From: "Zack Weinberg" <zackw at Stanford dot EDU>
- Date: Tue, 19 Jun 2001 23:26:29 -0700
- Cc: Stan Shebs <shebs at apple dot com>, "Joseph S. Myers" <jsm28 at cam dot ac dot uk>, Neil Booth <neil at daikokuya dot demon dot co dot uk>, Ziemowit Laski <zlaski at apple dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
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_