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 Fri, Jun 15, 2001 at 05:54:30PM -0700, Stan Shebs wrote:
> "Joseph S. Myers" wrote:
> > 
> > On Sat, 16 Jun 2001, Neil Booth wrote:
> > 
> > > Ziemowit Laski wrote:-
> > > > I would humbly like to propose to add support for Pascal-style
> > > > string literals in gcc.
> > >
> 
> > I agree this extension is a mess and a bad idea.
> 
> Perhaps, but it's already been in use in the Mac world for about 15
> years or so, and there are millions of lines of code that use \p in
> strings.  I first implemented it in GCC in 1989 or so, so it's not
> even new for GCC.

Is it the extension itself or the implementation you are objecting to,
Neil, Joseph?  The extension itself doesn't seem any worse than any of
the other extensions we have for compatibility with various systems.

The implementation is a mess, I agree.  It ought to be possible to do
it in a much less invasive manner.  You don't need to touch cpplib at
all.  Let "\pfoo" survive intact all the way to lex_string in
c-lex.c.  There, special case a leading \p.  Delete it, leave a null
byte, then come back at the end and write in the correct length
instead of inserting the terminating null.  [If I remember correctly,
these strings aren't supposed to have terminating nulls?]  Adjust the
type, and pass it up to combine_strings.  Don't forget to issue an
error if the string is too long.

combine_strings has to handle "\pblah" "blah" and issue an error for
"blah" "\pblah".  It is not safe to use the tree type to detect Pascal
strings, because if 'char' is unsigned, char_type_node == your
unsigned_char_type_node (am I mistaken here?) so you will need a flag
bit or something.

I don't see any reason not to allow pascal wide strings.  They can
even be longer than normal...

-- 
zw    If punishments don't compensate the victims and don't prevent future
      crimes they seem to me to be indistinguishable from random acts of
      sadism.
      	-- Bernard Peek


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