commit f2fce2eb1e47acdb12655fab7c1159bf31fa7ee2
Author:     Laslo Hunhold <[email protected]>
AuthorDate: Mon Jun 1 12:18:43 2020 +0200
Commit:     Laslo Hunhold <[email protected]>
CommitDate: Mon Jun 1 12:18:43 2020 +0200

    Ensure POSIX-conformance in the data tables
    
    Explicitly "cast" the constants to 32 bits, as POSIX only guarantees
    16 bits for int and the constants might overflow otherwise.
    
    Signed-off-by: Laslo Hunhold <[email protected]>

diff --git a/data/emo.awk b/data/emo.awk
index 3897b71..a8920d9 100644
--- a/data/emo.awk
+++ b/data/emo.awk
@@ -47,7 +47,7 @@ function mktable(name, array, arrlen) {
                upper = sprintf("0x%s", upper);
 
                # print lower bound
-               printf("\t{ %s, ", lower);
+               printf("\t{ UINT32_C(%s), ", lower);
 
                for (; j < arrlen - 1; j++) {
                        # look ahead and check if we have adjacent arrays
@@ -70,7 +70,7 @@ function mktable(name, array, arrlen) {
                }
 
                # print upper bound
-               printf("%s },\n", upper);
+               printf("UINT32_C(%s) },\n", upper);
        }
 
        printf("};\n");
diff --git a/data/gbp.awk b/data/gbp.awk
index 92038ca..0847ed9 100644
--- a/data/gbp.awk
+++ b/data/gbp.awk
@@ -71,7 +71,7 @@ function mktable(name, array, arrlen) {
                upper = sprintf("0x%s", upper);
 
                # print lower bound
-               printf("\t{ %s, ", lower);
+               printf("\t{ UINT32_C(%s), ", lower);
 
                for (; j < arrlen - 1; j++) {
                        # look ahead and check if we have adjacent arrays
@@ -94,7 +94,7 @@ function mktable(name, array, arrlen) {
                }
 
                # print upper bound
-               printf("%s },\n", upper);
+               printf("UINT32_C(%s) },\n", upper);
        }
 
        printf("};\n");
diff --git a/data/gbt.awk b/data/gbt.awk
index f76e665..264edd5 100644
--- a/data/gbt.awk
+++ b/data/gbt.awk
@@ -40,7 +40,7 @@ $0 ~ /^#/ || $0 ~ /^\s*$/ { next }
        # print code points
        printf("\t{\n\t\t.cp     = (uint32_t[]){ ");
        for (i = 0; i < ncps; i++) {
-               printf("0x%s", cp[i]);
+               printf("UINT32_C(0x%s)", cp[i]);
                if (i + 1 < ncps) {
                        printf(", ");
                }

Reply via email to