[ragel-users] signed/unsigned portability issue

Adrian Thurston thurston at complang.org
Sat Nov 2 14:52:37 UTC 2013


Definitely a bug. We take the min and max values for the type from CHAR_MIN and
CHAR_MAX, which should be set appropriately for the architecture.

However, there is an isSigned bit that is not drawn from the compilation
environment. We should be doing that somehow.

This code is in common.{h,cc}

-Adrian

On Thu, Oct 24, 2013 at 08:52:17PM +0200, Peter van Dijk wrote:
> Hello folks,
> 
> 
> 
> we (PowerDNS) have a small Ragel parser for segmenting and unescaping DNS TXT record data. Some time ago, we expanded the allowed inputs for this parser to the full 8 bit 'extended ASCII' range (which Ragel calls 'extend').
> 
> This works well on most platforms - but it failed for us on Debian/s390x.
> 
> After a lot of digging I found that char is unsigned on s390x, while it is signed on amd64, i386 and many other platforms.
> 
> I have added 'alphtype unsigned char' to our Ragel file. This makes the parser work reliably on both amd64 and s390x (and,  hopefully, many other platforms).
> 
> However, I feel something is wrong. It seems that on s390x, Ragel is mostly confused about the type of char. It generates a parser that treats extend as -128..127, but maps non-ASCII inputs in the 128..255 range. This discrepancy feels like a Ragel issue to me.
> 
> A much longer version of this story is at https://www.evernote.com/shard/s344/sh/cb968134-4d58-4e46-8b5e-47366a129038/60fafaf56d5a350edf891cf82cefc66d
> 
> My question: is this a Ragel bug? Regardless of yes/no, is what I did (alphtype unsigned char) the best workaround?
> 
> I did most of the debugging with ragel 6.7-1 (Debian version number), but verified that the problem is identical in 6.8-1.
> 
> Kind regards,
> -- 
> Peter van Dijk
> Netherlabs Computer Consulting BV - http://www.netherlabs.nl/
> 



> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users


_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users



More information about the ragel-users mailing list