vmg / sundown

Standards compliant, fast, secure markdown processing library in C
1.99k stars 385 forks source link

'char' portability issues #41

Closed jdelStrother closed 12 years ago

jdelStrother commented 13 years ago

Heya, Sundown uses 'char' to store its character data in buffer.h. Normally, that would be an unsigned char, but on Solaris it's signed. One example where this causes problems is when passing the data to isspace, which expects unsigned char data but promotes its argument to an int. I discovered this when using redcarpet on Solaris, where it would mangle certain UTF-8 characters. I've patched this internally and it appears to be fine, but wasn't confident enough about its side effects in other environments to push the patch without further discussion... Any thoughts?

vmg commented 13 years ago

Hm. This is indeed some strange behavior on Solaris. What does your patch look like, exactly? Maybe it would be easier to implement our own safe isspace rather than changing the buffer class.

jdelStrother commented 13 years ago

Perhaps, but on most platforms, char defaults to unsigned anyway, right? So you're just being explicit to the compiler that yes, you really do want unsigned.

My patch is here - https://github.com/tanoku/redcarpet/commit/e6d334a6 - it still passes all the tests on both Solaris and OS X, but I haven't tried it outside of those environments.

vmg commented 12 years ago

I've just tackled this in a big UTF-8 revamp. The library should now be fully UTF-8 compliant. Cheers!