Skip to content

Add string literal concatenation using ellipses "..." (bug 4261)#5

Merged
psychonic merged 4 commits intoalliedmodders:masterfrom
peace-maker:pawn_stringconcat
Jun 11, 2014
Merged

Add string literal concatenation using ellipses "..." (bug 4261)#5
psychonic merged 4 commits intoalliedmodders:masterfrom
peace-maker:pawn_stringconcat

Conversation

@peace-maker
Copy link
Member

Backported the changes CompuPhase did to the compiler to support string
literal concatenation including all fixes in later commits from r30 on.
http://code.google.com/p/pawnscript/source/detail?r=30

Pawn uses ellipses "..." to concatenate so it looks like this:

#define PROJECT_AUTHOR "Greyscale"
#define PROJECT_COPYRIGHT "Copyright (C) 2010  " ... PROJECT_AUTHOR

This would result in PROJECT_COPYRIGHT being defined as
"Copyright (C) 2010 Greyscale"

While i've been at it, that stringizing a macro parameter feature was
ported too.
From the changelog for version 3.3.4026
(http://www.compuphase.com/pawn/pawnhistory.htm):

The macro substition processor now recognizes the "#" character for
"stringizing" a parameter. For example, if you have the definition

#define log(%1) #%1

Then the expression log(test) will result in "test".
Note that concatenation of literal strings requires an ellipsis in pawn
(which is different than C/C++). So to combine the parameter with
literal strings, use a syntax like:

#define log(%1) "logging: " ... #%1 ... "\n"

The stringize operator is only available in the replacement text of a
macro.

Doing

PrintToServer(log(hello));

would print
logging: hello\n

Corresponding bug: https://bugs.alliedmods.net/show_bug.cgi?id=4261

Backported the changes CompuPhase did to the compiler to support string
literal concatenation including all fixes in later commits from r30 on.
http://code.google.com/p/pawnscript/source/detail?r=30

Pawn uses ellipses "..." to concatenate so it looks like this:

#define PROJECT_AUTHOR "Greyscale"
#define PROJECT_COPYRIGHT "Copyright (C) 2010  " ... PROJECT_AUTHOR

This would result in PROJECT_COPYRIGHT being defined as
"Copyright (C) 2010  Greyscale"

While i've been at it, that stringizing a macro parameter feature was
ported too.
From the changelog for version 3.3.4026
(http://www.compuphase.com/pawn/pawnhistory.htm):

The macro substition processor now recognizes the "#" character for
"stringizing" a parameter. For example, if you have the definition
#define log(%1) #%1
Then the expression log(test) will result in "test".
Note that concatenation of literal strings requires an ellipsis in pawn
(which is different than C/C++). So to combine the parameter with
literal strings, use a syntax like:
#define log(%1) "logging: " ... #%1 ... "\n"
The stringize operator is only available in the replacement text of a
macro.

Doing
PrintToServer(log(hello));
would print
logging: hello\n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you #if 0 these last four conditions?

@peace-maker
Copy link
Member Author

Moved and added those #if 0

dvander pushed a commit that referenced this pull request May 28, 2014
commit cd0d318
Author: Peace-Maker <[email protected]>
Date:   Wed May 28 03:07:25 2014 +0200

    Ignore \ ctrlchar in lexing

commit cf617a4
Author: Peace-Maker <[email protected]>
Date:   Tue May 27 13:32:59 2014 +0200

    Add string literal concatenation using ellipses "..." (bug 4261)

    Backported the changes CompuPhase did to the compiler to support string
    literal concatenation including all fixes in later commits from r30 on.
    http://code.google.com/p/pawnscript/source/detail?r=30

    Pawn uses ellipses "..." to concatenate so it looks like this:

    #define PROJECT_AUTHOR "Greyscale"
    #define PROJECT_COPYRIGHT "Copyright (C) 2010  " ... PROJECT_AUTHOR

    This would result in PROJECT_COPYRIGHT being defined as
    "Copyright (C) 2010  Greyscale"

    While i've been at it, that stringizing a macro parameter feature was
    ported too.
    From the changelog for version 3.3.4026
    (http://www.compuphase.com/pawn/pawnhistory.htm):

    The macro substition processor now recognizes the "#" character for
    "stringizing" a parameter. For example, if you have the definition
    #define log(%1) #%1
    Then the expression log(test) will result in "test".
    Note that concatenation of literal strings requires an ellipsis in pawn
    (which is different than C/C++). So to combine the parameter with
    literal strings, use a syntax like:
    #define log(%1) "logging: " ... #%1 ... "\n"
    The stringize operator is only available in the replacement text of a
    macro.

    Doing
    PrintToServer(log(hello));
    would print
    logging: hello\n
@dvander
Copy link
Member

dvander commented May 28, 2014

Merged via command-line.

@dvander dvander closed this May 28, 2014
dvander added a commit that referenced this pull request May 28, 2014
@dvander
Copy link
Member

dvander commented May 28, 2014

Had to back out since the clang builds failed. https://builds.alliedmods.net/sm/builders/linux-1.6/builds/474/steps/build/logs/stdio

Maybe we should have some kind of PR-builder...

@dvander dvander reopened this May 28, 2014
@winstliu
Copy link
Contributor

Try Travis.

@Impact123
Copy link
Contributor

I would suggest jenkins together with this and this plugin.
I know you already use buildbot, buy maybe you'll find jenkins interesting enough to try it out.

@winstliu
Copy link
Contributor

Jenkins could work (and is what I use), but Travis has GitHub support already built-in. Jenkins probably is the better long-term solution though.

@WildCard65
Copy link
Contributor

Idk how well one could get AMBuilder going with travis.

@dvander
Copy link
Member

dvander commented May 28, 2014

Hi folks - please keep in mind that, just like Bugzilla, this is our tool for code review. These off-topic discussions make it harder for us to communicate. Please be mindful of what patch authors have to read through to figure out the current state of their PR.

peace-maker added a commit to peace-maker/sourcemod that referenced this pull request Jun 7, 2014
…lliedmodders#5)

commit cd0d318
Author: Peace-Maker <[email protected]>
Date:   Wed May 28 03:07:25 2014 +0200

    Ignore \ ctrlchar in lexing

commit cf617a4
Author: Peace-Maker <[email protected]>
Date:   Tue May 27 13:32:59 2014 +0200

    Add string literal concatenation using ellipses "..." (bug 4261)

    Backported the changes CompuPhase did to the compiler to support string
    literal concatenation including all fixes in later commits from r30 on.
    http://code.google.com/p/pawnscript/source/detail?r=30

    Pawn uses ellipses "..." to concatenate so it looks like this:

    #define PROJECT_AUTHOR "Greyscale"
    #define PROJECT_COPYRIGHT "Copyright (C) 2010  " ... PROJECT_AUTHOR

    This would result in PROJECT_COPYRIGHT being defined as
    "Copyright (C) 2010  Greyscale"

    While i've been at it, that stringizing a macro parameter feature was
    ported too.
    From the changelog for version 3.3.4026
    (http://www.compuphase.com/pawn/pawnhistory.htm):

    The macro substition processor now recognizes the "#" character for
    "stringizing" a parameter. For example, if you have the definition
    #define log(%1) #%1
    Then the expression log(test) will result in "test".
    Note that concatenation of literal strings requires an ellipsis in pawn
    (which is different than C/C++). So to combine the parameter with
    literal strings, use a syntax like:
    #define log(%1) "logging: " ... #%1 ... "\n"
    The stringize operator is only available in the replacement text of a
    macro.

    Doing
    PrintToServer(log(hello));
    would print
    logging: hello\n
peace-maker pushed a commit to peace-maker/sourcemod that referenced this pull request Jun 7, 2014
psychonic added a commit that referenced this pull request Jun 11, 2014
Add string literal concatenation using ellipses "..." (bug 4261, PR #5, r=dvander).
@psychonic psychonic merged commit feb5050 into alliedmodders:master Jun 11, 2014
@peace-maker peace-maker deleted the pawn_stringconcat branch June 11, 2014 12:30
dvander added a commit that referenced this pull request Nov 4, 2015
Don't drop objects without comments
This was referenced Aug 18, 2017
dvander added a commit to alliedmodders/sourcepawn that referenced this pull request Jan 17, 2020
RAWMODE was the ability to prefix a string such that escape characters
would be inserted literally, similar to the "r" prefix in Python. It
used sc_ctrlchar as the prefix. For reasons unknown, I requested this
feature be disabled when literal concatenation support was backported [1].
Since then, it was further broken when the lexer was rewritten and
simplified. It hasn't worked in 6 years, and no one has been clamoring
for it, so let's just remove all the offending code.

If we want to add this back and properly support it, it will not be
difficult.

[1] alliedmodders/sourcemod#5
dvander added a commit to alliedmodders/sourcepawn that referenced this pull request Jan 21, 2020
RAWMODE was the ability to prefix a string such that escape characters
would be inserted literally, similar to the "r" prefix in Python. It
used sc_ctrlchar as the prefix. For reasons unknown, I requested this
feature be disabled when literal concatenation support was backported [1].
Since then, it was further broken when the lexer was rewritten and
simplified. It hasn't worked in 6 years, and no one has been clamoring
for it, so let's just remove all the offending code.

If we want to add this back and properly support it, it will not be
difficult.

[1] alliedmodders/sourcemod#5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants