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

Fix the string replace #479

Merged
merged 2 commits into from May 17, 2016
Merged

Fix the string replace #479

merged 2 commits into from May 17, 2016

Conversation

@thirdwing
Copy link
Member

@thirdwing thirdwing commented May 16, 2016

The CRAN version:

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
String replace() {
  String foo("abba");
  return foo.replace_first("ba", "BA");
}

/*
> Rcpp::sourceCpp("test.cpp")
> replace()
[1] "BAba"
*/

After fix:

> Rcpp::sourceCpp("test.cpp")
> replace()
[1] "abBA"

@kevinushey

Qiang Kou added 2 commits May 16, 2016
Qiang Kou
@eddelbuettel
Copy link
Member

@eddelbuettel eddelbuettel commented May 16, 2016

Looks good first glance.

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented May 16, 2016

Looks good to me as well -- I kind of wish we could get away without copying the C strings into std::strings, but I'm fine with the PR as-is.

@eddelbuettel eddelbuettel merged commit 43f2ee6 into RcppCore:master May 17, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented May 17, 2016

Thanks for doing the legwork @thirdwing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.