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: use __iconv on FreeBSD to skip invalid bytes #3379

Merged
merged 1 commit into from
Oct 6, 2016

Conversation

ysbaddaden
Copy link
Contributor

@ysbaddaden ysbaddaden commented Oct 3, 2016

The GNU extensions from "libiconv" aren't supported on FreeBSD. We must use __iconv to skip invalid bytes instead of adding //IGNORE to the charsets.

There are now only 3 specs failing. One is minor (EINVAL is reported instead of EILSEQ), the 2 others should raise, but they don't... so maybe there is another issue (maybe in the way we should report invalids with __iconv)?

refs #3271

@ysbaddaden
Copy link
Contributor Author

@zarianu can you test if it works for you, now?

@zarianu
Copy link

zarianu commented Oct 3, 2016

Yes! Works like a charm now, merci!

As a FreeBSD user I can check on other 3 failing specs if you want.

@zarianu
Copy link

zarianu commented Oct 3, 2016

Just looked at failing spec at spec/std/string_spec.cr:1904.

Looks like FreeBSD's iconv interface is pretty limited according to manuals. GNU iconv can detect invalid multibyte sequences by setting errno = EILSEQ, while FreeBSD iconv/__iconv (POSIX legacy) returns number of invalid characters. So maybe Crystal's iconv API should handle iconv.convert return values other than -1 on FreeBSD platform.

@asterite
Copy link
Member

asterite commented Oct 5, 2016

@ysbaddaden As always, feel free to merge this whenever you think it's ready. I didn't test it on FreeBSD but I trust you.

I'll make a release this Friday, mostly to have the atomic instructions support in the compiler to continue working on that more easily. By the way, if you release a new version of shards before that I can also include it in the next Crystal release, if you have time or if there are new features or bug fixes in shards.

@ysbaddaden ysbaddaden merged commit e1b98a5 into crystal-lang:master Oct 6, 2016
@ysbaddaden ysbaddaden deleted the core-iconv-freebsd-skip branch October 6, 2016 07:39
@asterite asterite added this to the 0.19.4 milestone Oct 6, 2016
@0x1eef 0x1eef mentioned this pull request Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants