Menu

#188 OnBC: Adjacent String Constants should be merged.

Bug
open
None
5
2008-04-10
2005-09-06
No

From my message here:
http://sourceforge.net/mailarchive/forum.php?thread_id=8127909&forum_id=9982

Pairs of string constants aren't concatenated, as per:
http://eli-project.sourceforge.net/c_html/c.html#s6.1.4
("Sequences of string literals are translated as single
strings.")

Boz suggested I start looking here:
For the first one (concatenating string constants),
take a look at
compile.c, ~line 3009. (Search for DoubleQuote), which
is where quoted strings are handled.

Discussion

  • Blake Winton

    Blake Winton - 2005-09-06
    • assigned_to: nobody --> bwinton
     
  • Blake Winton

    Blake Winton - 2005-09-06

    Logged In: YES
    user_id=116787

    From my digging, it looks like it might be easier to add it
    into OnBoardC.c, near line 643. (i.e. make multiple string
    constants into a single string token), since it looks like
    the code to emit a string constant is generated before the
    next token is processed, and so there's not a good place to
    hook into in compile.c...

    Any comments? Is compile.c a better place for the change,
    philosophically?

     
  • Blake Winton

    Blake Winton - 2005-09-07

    Patch to implement Concatenation of String Constants.

     
  • Blake Winton

    Blake Winton - 2005-09-07

    Logged In: YES
    user_id=116787

    Okay, I've got something that looks like it will work, at
    least for the simple case of:
    Char* foo = "aaa" "bbb" "ccc";

    I think I might try some more complicated tests next.

     
  • Blake Winton

    Blake Winton - 2005-09-08
     
  • Blake Winton

    Blake Winton - 2005-09-08

    Logged In: YES
    user_id=116787

    After discussing it with people on the mailing list, I think
    this patch is a little cleaner...

     
  • John Wilund

    John Wilund - 2008-04-02
    • milestone: 355801 -->
     
  • John Wilund

    John Wilund - 2008-04-09

    Logged In: YES
    user_id=574706
    Originator: NO

    Steve, please take a look at this patch.

     
  • John Wilund

    John Wilund - 2008-04-09
    • milestone: --> Bug
     
  • Blake Winton

    Blake Winton - 2008-04-10

    Logged In: YES
    user_id=116787
    Originator: YES

    It was a while ago, but I seem to remember that there were some odd corner cases that this patch didn't handle. And I'm afraid I'm not going to be much use in figuring them out, since my Palm broke. :(

    Good luck!

     
  • Steve Little

    Steve Little - 2008-04-10
    • assigned_to: bwinton --> boz_x
     
  • Steve Little

    Steve Little - 2008-04-10

    Logged In: YES
    user_id=583634
    Originator: NO

    I've looked at both the patches, and there's a couple of changes I'd like to make before committing this fix. (Specifically with the way multiple nodes are chained together in the AST)

    Reassigning to me, since Blake has said he won't be able to work on this anymore.

    (Thanks for the initial work, Blake, it's 90% there, just needs a little tweak)

     

Log in to post a comment.