Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std.regex.replaceAll instead of replace(). #82

Merged
merged 2 commits into from
Aug 28, 2013

Conversation

quickfur
Copy link
Member

replace() is now deprecated and required the regex to be compiled with
specific flags; the new API uses replaceAll().

Fixes issue 10896.

replace() is now deprecated and required the regex to be compiled with
specific flags; the new API uses replaceAll().
@quickfur
Copy link
Member Author

The second commit isn't strictly necessary, but is a better example of proper D code. :)

@ghost
Copy link

ghost commented Aug 28, 2013

I got confused for a second when I ran the unittests since the app seemingly got stuck, I forgot that ddemangle waits for input from stdin. If we ever add the tools to the test-suite we should make the app exit after unit-testing (perhaps by sending CTRL+C).

Alternatively this can be used:

version(unittest) { void main(string[] args) { } }
else
void main(string[] args)
{
    // Parse command-line arguments
    try
    {
...

@ghost
Copy link

ghost commented Aug 28, 2013

Btw I'm very happy to see a replaceAll function in std.regex, the "g" option becoming non-default was a silent breaking change that I never liked.

@quickfur
Copy link
Member Author

On Tue, Aug 27, 2013 at 05:41:41PM -0700, Andrej Mitrovic wrote:

I got confused for a second when I ran the unittests since the app
seemingly got stuck, I forgot that ddemangle waits for input from
stdin.
[...]

Haha, so I'm not the only one who stared at the screen for a good long
while before I realized what was happening. :) Actually it was worse, I
thought there was a bug in the unittest so I went back to revise it.

T

Bare foot: (n.) A device for locating thumb tacks on the floor.

I'm ashamed of the fact that I wrote this program with zero unittests!
@quickfur
Copy link
Member Author

Updated code based on Martin's suggestions and rebased.

@quickfur
Copy link
Member Author

Heh, just realized there was a latent bug that got fixed by the refactoring: the old code went through all the trouble to open a file specified on the command-line, only to always read from stdin instead.

MartinNowak added a commit that referenced this pull request Aug 28, 2013
Use std.regex.replaceAll instead of replace().
@MartinNowak MartinNowak merged commit 4f762a6 into dlang:master Aug 28, 2013
@ghost
Copy link

ghost commented Aug 28, 2013

Thanks!

@quickfur quickfur deleted the replaceAll branch August 8, 2014 17:52
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.

2 participants