chiark / gitweb /
16-bit safety, maybe
authorBen Harris <bjh21@bjh21.me.uk>
Wed, 10 Jul 2024 13:38:53 +0000 (14:38 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Wed, 10 Jul 2024 13:57:49 +0000 (14:57 +0100)
commit1281b34c53561b75fd682eb0235d49bc335e0440
tree463cd76070977902852779d449c38af0590ca1e5
parent08bbcb04f66e8bc37920a65b4320faf2d53cb857
16-bit safety, maybe

Bedstead claims to be written in ISO C.  ISO C allows "int" to be only
16 bits wide, which is a bit of a problem.  In fact, it's not much of
a problem because Bedstead mostly deals in small numbers.  The main
exception is Unicode code points, which can exceed 16 bits.

To hopefully fix this, Bedstead now mostly uses "long" for Unicode
code points.  The main exception is in the gklph table where that
seems a bit profligate on 64-bit systems so I've used int_least32_t
instead.

The fiddliest bits of this are around uses of printf(), which cares
whether it's being passed an "int" or a "long".

This is untested on an actual 16-bit system, but at least on a 64-bit
system it continues to produce correct results.
bedstead.c