Author Topic: Problem with '%' in editor abbreviations  (Read 8399 times)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Problem with '%' in editor abbreviations
« Reply #15 on: November 14, 2006, 06:54:06 pm »
Well, I implemented it a few weeks ago... replaced '$$' with '\b' before doing variable expansion, and replaced '\b' with '$' after variable expansion.
It did not work, and that was because the same string was being expanded again.
One could leave the "special char" as it is, or one could substitute back to the escape sequence. That would work, but then client code would have to manually strip each string as the last thing, which is not good (error-prone).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Problem with '%' in editor abbreviations
« Reply #16 on: November 14, 2006, 07:57:13 pm »
Well, I implemented it a few weeks ago... replaced '$$' with '\b' before doing variable expansion, and replaced '\b' with '$' after variable expansion.
It did not work, and that was because the same string was being expanded again.
One could leave the "special char" as it is, or one could substitute back to the escape sequence. That would work, but then client code would have to manually strip each string as the last thing, which is not good (error-prone).

What 's wrong with the standard escape char '\' ?
The easiest thing to do is to add this escape char in the regular expressions: just put something like [^\\]* at the start of each regex and there you go. Am I missing something?
Be patient!
This bug will be fixed soon...

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Problem with '%' in editor abbreviations
« Reply #17 on: November 14, 2006, 08:24:57 pm »
It doesn't matter what you use. If you add '\' as escape char, you will have to remove it in the end, as you don't want it to appear in the final output.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Problem with '%' in editor abbreviations
« Reply #18 on: November 14, 2006, 08:46:54 pm »
It doesn't matter what you use. If you add '\' as escape char, you will have to remove it in the end, as you don't want it to appear in the final output.

Right, but *in the end*. Right before the result is returned, a replace runs and changes \$ to $ (and \% to %). What's so complicated about that?
Be patient!
This bug will be fixed soon...

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Problem with '%' in editor abbreviations
« Reply #19 on: November 14, 2006, 09:23:00 pm »
What 's wrong with the standard escape char '\' ?
The easiest thing to do is to add this escape char in the regular expressions: just put something like [^\\]* at the start of each regex and there you go. Am I missing something?

The problem with \ as an escape char is that if it is used for windows paths and c/c++ string literals. e.g. "This is the path to a source file in the root folder \\\\$PROJECT_FILE"

Backslash could be offered as a standard escape character (with a corresponding pre-compiled regex if speed is a concern), but there should be a way to specify an alternative escape string for some purposes.

Quote from: mandrav
What's so complicated about that?

i think the complication is this:

Quote from: thomas
1. the same string gets passed to MacrosManger several times during build (not during abbrevations, though). This could be considered a bug (at the very least, it is unnecessary),

until this is fixed, one could make not handling escapes the default behavior of the macro manager variable replace function (by adding optional argument for an escape string whose default value is an empty string)
« Last Edit: November 14, 2006, 09:29:15 pm by dmoore »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Problem with '%' in editor abbreviations [Resolved]
« Reply #20 on: November 15, 2006, 06:01:35 pm »
Resolved: thomas fixed this in SVN 3222

thanks thomas