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 'Rf_mkCharLenCE() as appropriate #917

Merged
merged 2 commits into from
Nov 3, 2018

Conversation

kevinushey
Copy link
Contributor

Closes #916, taking option (1) -- signal an error if an embedded NUL byte is encountered, as R does.

@@ -395,9 +395,12 @@ namespace Rcpp {
enc = encoding;

if (valid) {
data = Rcpp_ReplaceObject(data, Rf_mkCharCE(Rf_translateCharUTF8(data), encoding));
const void* vmax = vmaxget();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that translateCharUTF8() has, in the R sources:

https://github.com/wch/r-source/blob/61132afa07832f4e855da35773fa1341f1a8b481/src/main/sysutils.c#L992-L994

so it's recommended that we manage the stack after usage. Not sure if we should do this in this PR or just leave it out for now though.

@kevinushey
Copy link
Contributor Author

It just occurred to me that we don't want the R error (ie the longjmp) so we'll have to do our own error checking before calling Rf_mkCharLenCE().

@eddelbuettel
Copy link
Member

That sounds like a worthwhile change.

@eddelbuettel
Copy link
Member

@kevinushey Do you want to add an error check before Rf_mkCharLenCE() ?

@kevinushey
Copy link
Contributor Author

Yes, sorry -- I'll try to get to it soon.

@eddelbuettel
Copy link
Member

No worries -- that was the right call. No rush.

@eddelbuettel
Copy link
Member

I'm confused. Did you amend the initial commit in this PR? I am only seeing one commit when there should have been two.

@kevinushey
Copy link
Contributor Author

Yes, I amended the original commit -- I tend to do this on feature branches just to keep the commit history clean. (Although perhaps it's better to just squash and merge rather than retroactively change history on the branch)

@eddelbuettel
Copy link
Member

Yes, we could settle on just squashing. I also don't single / non-parallel branches merging back.

In any event here the downside was that your repo co-user, ie me, got lost :).

@kevinushey
Copy link
Contributor Author

Sorry for the confusion :-)

Ultimately, this should be ready to go now.

@kevinushey
Copy link
Contributor Author

It looks like the h5 package is deprecated, so updated to CRAN may not be as timely as we might like. For that reason I'm going to just work around the issue and use the old-school Rf_mkCharCE() when h5 is detected.

@eddelbuettel
Copy link
Member

eddelbuettel commented Nov 2, 2018

Interesting. Have we ever done that? Explicitly accomodate other packages?

(And yes, hdf5 package seem to be a in constant state of flux. Too bad CRAN doesn't just patch...)

Edit: I also know the h5 maintainer so I can always ask...

@kevinushey
Copy link
Contributor Author

Interesting. Have we ever done that? Explicitly accomodate other packages?

Not that I can recall, but given that it's one package with a simple workaround, I don't mind having this live in Rcpp if it means existing code depending on h5 can still work fine. What do you think?

@eddelbuettel
Copy link
Member

It is on the hack-ish side of things but if we mean it to be temporary I can live with it. Let me email Mario and see what he says.

@eddelbuettel
Copy link
Member

Oh, and I just now see the rather nice ticket you opened there already. Well done.

@eddelbuettel eddelbuettel merged commit 2f72ff8 into master Nov 3, 2018
@eddelbuettel eddelbuettel deleted the bugfix/string-embedded-nul branch November 25, 2018 13:33
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.

None yet

2 participants