diff options
Diffstat (limited to 'source/luametatex/source/utilities')
4 files changed, 33 insertions, 27 deletions
diff --git a/source/luametatex/source/utilities/auxarithmetic.h b/source/luametatex/source/utilities/auxarithmetic.h index 8daf6f29a..ac01c10ca 100644 --- a/source/luametatex/source/utilities/auxarithmetic.h +++ b/source/luametatex/source/utilities/auxarithmetic.h @@ -53,7 +53,7 @@ in some places we clip to the official maxima but not always. //define zround(r) ((r>2147483647.0) ? 2147483647 : ((r<-2147483647.0) ? -2147483647 : ((r >= 0.0) ? (int)(r + 0.5) : ((int)(r-0.5))))) //define zround(r) ((r>2147483647.0) ? 2147483647 : ((r<-2147483647.0) ? -2147483647 : (int) lround(r))) -# define scaledround(x) ((scaled) lround((double) x)) +# define scaledround(x) ((scaled) lround((double) (x))) # define longlonground llround # define clippedround(r) ((r>2147483647.0) ? 2147483647 : ((r<-2147483647.0) ? -2147483647 : (int) lround(r))) # define glueround(x) clippedround((double) (x)) diff --git a/source/luametatex/source/utilities/auxsparsearray.c b/source/luametatex/source/utilities/auxsparsearray.c index c3f2c7687..3ea8f1c46 100644 --- a/source/luametatex/source/utilities/auxsparsearray.c +++ b/source/luametatex/source/utilities/auxsparsearray.c @@ -128,21 +128,23 @@ int sa_get_item_2(const sa_tree head, int n) return (int) head->dflt.ushort_value[n%2]; } -sa_tree_item sa_get_item_4(const sa_tree head, int n) +int sa_get_item_4(const sa_tree head, int n, sa_tree_item *v) { if (head->tree) { int h = LMT_SA_H_PART(n); if (head->tree[h]) { int m = LMT_SA_M_PART(n); if (head->tree[h][m]) { - return head->tree[h][m][LMT_SA_L_PART(n)]; + *v = head->tree[h][m][LMT_SA_L_PART(n)]; + return 1; } } } - return head->dflt; + *v = head->dflt; + return 0; } -sa_tree_item sa_get_item_8(const sa_tree head, int n, sa_tree_item *v2) +int sa_get_item_8(const sa_tree head, int n, sa_tree_item *v1, sa_tree_item *v2) { if (head->tree != NULL) { int h = LMT_SA_H_PART(n); @@ -150,13 +152,15 @@ sa_tree_item sa_get_item_8(const sa_tree head, int n, sa_tree_item *v2) int m = LMT_SA_M_PART(n); if (head->tree[h][m]) { int l = 2*LMT_SA_L_PART(n); + *v1 = head->tree[h][m][l]; *v2 = head->tree[h][m][l+1]; - return head->tree[h][m][l]; + return 1; } } } + *v1 = head->dflt; *v2 = head->dflt; - return head->dflt; + return 0; } void sa_set_item_1(sa_tree head, int n, int v, int gl) diff --git a/source/luametatex/source/utilities/auxsparsearray.h b/source/luametatex/source/utilities/auxsparsearray.h index a1a902c54..91e310074 100644 --- a/source/luametatex/source/utilities/auxsparsearray.h +++ b/source/luametatex/source/utilities/auxsparsearray.h @@ -105,24 +105,24 @@ typedef struct sa_tree_head { typedef sa_tree_head *sa_tree; -extern int sa_get_item_1 (const sa_tree head, int n); -extern int sa_get_item_2 (const sa_tree head, int n); -extern sa_tree_item sa_get_item_4 (const sa_tree head, int n); -extern sa_tree_item sa_get_item_8 (const sa_tree head, int n, sa_tree_item * v2); -extern void sa_set_item_1 (sa_tree head, int n, int v, int gl); -extern void sa_set_item_2 (sa_tree head, int n, int v, int gl); -extern void sa_set_item_4 (sa_tree head, int n, sa_tree_item v, int gl); -extern void sa_set_item_8 (sa_tree head, int n, sa_tree_item v1, sa_tree_item v2, int gl); -extern sa_tree sa_new_tree (int size, int bytes, sa_tree_item dflt); -extern sa_tree sa_copy_tree (sa_tree head); -extern void sa_destroy_tree (sa_tree head); -extern void sa_dump_tree (dumpstream f, sa_tree a); -extern sa_tree sa_undump_tree (dumpstream f); -extern void sa_restore_stack (sa_tree a, int gl); -extern void sa_clear_stack (sa_tree a); - -extern void sa_set_item_n (const sa_tree head, int n, int v, int gl); -extern int sa_get_item_n (const sa_tree head, int n); +extern int sa_get_item_1 (const sa_tree head, int n); /* these return the value or dflt */ +extern int sa_get_item_2 (const sa_tree head, int n); /* these return the value or dflt */ +extern int sa_get_item_4 (const sa_tree head, int n, sa_tree_item *v); /* these return success */ +extern int sa_get_item_8 (const sa_tree head, int n, sa_tree_item *v1, sa_tree_item *v2); /* these return success */ +extern void sa_set_item_1 (sa_tree head, int n, int v, int gl); +extern void sa_set_item_2 (sa_tree head, int n, int v, int gl); +extern void sa_set_item_4 (sa_tree head, int n, sa_tree_item v, int gl); +extern void sa_set_item_8 (sa_tree head, int n, sa_tree_item v1, sa_tree_item v2, int gl); +extern sa_tree sa_new_tree (int size, int bytes, sa_tree_item dflt); +extern sa_tree sa_copy_tree (sa_tree head); +extern void sa_destroy_tree (sa_tree head); +extern void sa_dump_tree (dumpstream f, sa_tree a); +extern sa_tree sa_undump_tree (dumpstream f); +extern void sa_restore_stack (sa_tree a, int gl); +extern void sa_clear_stack (sa_tree a); + +extern void sa_set_item_n (const sa_tree head, int n, int v, int gl); +extern int sa_get_item_n (const sa_tree head, int n); inline static halfword sa_return_item_1(sa_tree head, halfword n) { diff --git a/source/luametatex/source/utilities/auxunistring.c b/source/luametatex/source/utilities/auxunistring.c index 30dc518e6..10ae6393d 100644 --- a/source/luametatex/source/utilities/auxunistring.c +++ b/source/luametatex/source/utilities/auxunistring.c @@ -58,8 +58,9 @@ unsigned char *aux_uni2str(unsigned unic) buf[2] = (unsigned char) (0x80 | (unic & 0x3f)); buf[3] = '\0'; } else if (unic < 0x110000) { + int u; unic -= 0x10000; - int u = (int) (((unic & 0xf0000) >> 16) + 1); + u = (int) (((unic & 0xf0000) >> 16) + 1); buf[0] = (unsigned char) (0xf0 | (u >> 2)); buf[1] = (unsigned char) (0x80 | ((u & 3) << 4) | ((unic & 0x0f000) >> 12)); buf[2] = (unsigned char) (0x80 | ((unic & 0x00fc0) >> 6)); @@ -92,8 +93,9 @@ char *aux_uni2string(char *utf8_text, unsigned unic) *utf8_text++ = (char) (0x80 | ((unic >> 6) & 0x3f)); *utf8_text++ = (char) (0x80 | (unic & 0x3f)); } else if (unic < 0x110000) { + unsigned u; unic -= 0x10000; - unsigned u = ((unic & 0xf0000) >> 16) + 1; + u = ((unic & 0xf0000) >> 16) + 1; *utf8_text++ = (char) (0xf0 | (u >> 2)); *utf8_text++ = (char) (0x80 | ((u & 3) << 4) | ((unic & 0x0f000) >> 12)); *utf8_text++ = (char) (0x80 | ((unic & 0x00fc0) >> 6)); |