chiark / gitweb /
Use "unsigned long" when we need an unsigned Unicode type
authorBen Harris <bjh21@bjh21.me.uk>
Mon, 17 Nov 2025 21:48:40 +0000 (21:48 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 13 Jan 2026 21:55:10 +0000 (21:55 +0000)
On 16-bit systems, "unsigned int" won't get us beyond the Basic
Multilingual Plane.

bedstead.c

index 2dea36bb754897993dd55ce95140fb8bde7155ce..e333594d20eb3f08c9833ccbf83ba9fdaa51a82b 100644 (file)
@@ -3502,8 +3502,8 @@ compare_glyphs_by_ffid(const void *va, const void *vb)
        if (strcmp(a->name, ".notdef") == 0) return -1;
        if (strcmp(b->name, ".notdef") == 0) return +1;
        /* Then characters with Unicode code-points in order. */
-       if ((unsigned int)a->unicode < (unsigned int)b->unicode) return -1;
-       if ((unsigned int)a->unicode > (unsigned int)b->unicode) return +1;
+       if ((unsigned long)a->unicode < (unsigned long)b->unicode) return -1;
+       if ((unsigned long)a->unicode > (unsigned long)b->unicode) return +1;
        /* Finally sort by glyph name for an arbitrary stable order. */
        return namecmp(a->name, b->name);
 }
@@ -5159,9 +5159,9 @@ byunicode(const void *va, const void *vb)
        struct glyph const *a = *(struct glyph const **)va,
                *b = *(struct glyph const **)vb;
 
-       /* Cast to unsigned int so -1 sorts last. */
-       if ((unsigned int)a->unicode < (unsigned int)b->unicode) return -1;
-       if ((unsigned int)a->unicode > (unsigned int)b->unicode) return +1;
+       /* Cast to unsigned long so -1 sorts last. */
+       if ((unsigned long)a->unicode < (unsigned long)b->unicode) return -1;
+       if ((unsigned long)a->unicode > (unsigned long)b->unicode) return +1;
        return namecmp(a->name, b->name);
 }