Commit 1fc3c987717f7f89188a53dc3a0dbc2ea02dcdee

Thomas de Grivel 2024-06-14T09:41:23

fix compilation on i386

diff --git a/libc3/buf_parse_s.c.in b/libc3/buf_parse_s.c.in
index b2fcb89..b77468d 100644
--- a/libc3/buf_parse_s.c.in
+++ b/libc3/buf_parse_s.c.in
@@ -121,7 +121,7 @@ sw buf_parse_s_bits$_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || radix > S_BITS$_MAX) {
+  if (radix < 2 || (SW_MAX > S_BITS$_MAX && radix > S_BITS$_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_s_bits$_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_s16.c b/libc3/buf_parse_s16.c
index 91b9fd3..97330c4 100644
--- a/libc3/buf_parse_s16.c
+++ b/libc3/buf_parse_s16.c
@@ -121,7 +121,7 @@ sw buf_parse_s16_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || radix > S16_MAX) {
+  if (radix < 2 || (SW_MAX > S16_MAX && radix > S16_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_s16_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_s32.c b/libc3/buf_parse_s32.c
index 2ec54b5..f48202a 100644
--- a/libc3/buf_parse_s32.c
+++ b/libc3/buf_parse_s32.c
@@ -121,7 +121,7 @@ sw buf_parse_s32_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || radix > S32_MAX) {
+  if (radix < 2 || (SW_MAX > S32_MAX && radix > S32_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_s32_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_s64.c b/libc3/buf_parse_s64.c
index e7f1c13..2971dcc 100644
--- a/libc3/buf_parse_s64.c
+++ b/libc3/buf_parse_s64.c
@@ -121,7 +121,7 @@ sw buf_parse_s64_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || radix > S64_MAX) {
+  if (radix < 2 || (SW_MAX > S64_MAX && radix > S64_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_s64_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_s8.c b/libc3/buf_parse_s8.c
index 8275d59..a2a41f2 100644
--- a/libc3/buf_parse_s8.c
+++ b/libc3/buf_parse_s8.c
@@ -121,7 +121,7 @@ sw buf_parse_s8_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || radix > S8_MAX) {
+  if (radix < 2 || (SW_MAX > S8_MAX && radix > S8_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_s8_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_sw.c b/libc3/buf_parse_sw.c
index 22f1be4..306b9bc 100644
--- a/libc3/buf_parse_sw.c
+++ b/libc3/buf_parse_sw.c
@@ -121,7 +121,7 @@ sw buf_parse_sw_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || radix > SW_MAX) {
+  if (radix < 2 || (SW_MAX > SW_MAX && radix > SW_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_sw_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_u.c.in b/libc3/buf_parse_u.c.in
index 0bcd372..04297a8 100644
--- a/libc3/buf_parse_u.c.in
+++ b/libc3/buf_parse_u.c.in
@@ -109,7 +109,7 @@ sw buf_parse_u_bits$_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || (uw) radix > U_BITS$_MAX) {
+  if (radix < 2 || (UW_MAX > U_BITS$_MAX && (uw) radix > U_BITS$_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_u_bits$_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_u16.c b/libc3/buf_parse_u16.c
index 46b8373..5bb628d 100644
--- a/libc3/buf_parse_u16.c
+++ b/libc3/buf_parse_u16.c
@@ -109,7 +109,7 @@ sw buf_parse_u16_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || (uw) radix > U16_MAX) {
+  if (radix < 2 || (UW_MAX > U16_MAX && (uw) radix > U16_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_u16_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_u32.c b/libc3/buf_parse_u32.c
index 42ad19f..031d4aa 100644
--- a/libc3/buf_parse_u32.c
+++ b/libc3/buf_parse_u32.c
@@ -109,7 +109,7 @@ sw buf_parse_u32_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || (uw) radix > U32_MAX) {
+  if (radix < 2 || (UW_MAX > U32_MAX && (uw) radix > U32_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_u32_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_u64.c b/libc3/buf_parse_u64.c
index 02ebdde..4ff1f11 100644
--- a/libc3/buf_parse_u64.c
+++ b/libc3/buf_parse_u64.c
@@ -109,7 +109,7 @@ sw buf_parse_u64_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || (uw) radix > U64_MAX) {
+  if (radix < 2 || (UW_MAX > U64_MAX && (uw) radix > U64_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_u64_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_u8.c b/libc3/buf_parse_u8.c
index b2d4580..b996f73 100644
--- a/libc3/buf_parse_u8.c
+++ b/libc3/buf_parse_u8.c
@@ -109,7 +109,7 @@ sw buf_parse_u8_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || (uw) radix > U8_MAX) {
+  if (radix < 2 || (UW_MAX > U8_MAX && (uw) radix > U8_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_u8_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/buf_parse_uw.c b/libc3/buf_parse_uw.c
index 425ab2c..aefc9ec 100644
--- a/libc3/buf_parse_uw.c
+++ b/libc3/buf_parse_uw.c
@@ -109,7 +109,7 @@ sw buf_parse_uw_base (s_buf *buf, const s_str *base,
   assert(dest);
   buf_save_init(buf, &save);
   radix = str_length_utf8(base);
-  if (radix < 2 || (uw) radix > UW_MAX) {
+  if (radix < 2 || (UW_MAX > UW_MAX && (uw) radix > UW_MAX)) {
     buf_save_clean(buf, &save);
     err_write_1("buf_parse_uw_base: invalid radix: ");
     err_inspect_sw(&radix);
diff --git a/libc3/tag_add.c b/libc3/tag_add.c
index 248dd82..1503642 100644
--- a/libc3/tag_add.c
+++ b/libc3/tag_add.c
@@ -1007,7 +1007,7 @@ s_tag * tag_add (const s_tag *a, const s_tag *b, s_tag *dest)
       else
         return tag_init_sw(dest, a->data.sw + (sw) b->data.u16);
     case TAG_U32:
-      if (a->data.sw > SW_MAX - b->data.u32) {
+      if (a->data.sw > (sw) (SW_MAX - b->data.u32)) {
         integer_init_sw(&tmp, a->data.sw);
         integer_init_u32(&tmp2, b->data.u32);
         dest->type = TAG_INTEGER;
@@ -1299,7 +1299,7 @@ s_tag * tag_add (const s_tag *a, const s_tag *b, s_tag *dest)
       else
         return tag_init_s64(dest, (s64) a->data.u32 + b->data.s64);
     case TAG_SW:
-      if (a->data.u32 > SW_MAX - b->data.sw) {
+      if (a->data.u32 > (u32) (SW_MAX - b->data.sw)) {
         integer_init_u32(&tmp, a->data.u32);
         integer_init_sw(&tmp2, b->data.sw);
         dest->type = TAG_INTEGER;
diff --git a/libc3/tag_div.c b/libc3/tag_div.c
index f2b6b1c..260bacc 100644
--- a/libc3/tag_div.c
+++ b/libc3/tag_div.c
@@ -643,7 +643,7 @@ s_tag * tag_div (const s_tag *a, const s_tag *b, s_tag *dest)
       else
         return tag_init_s64(dest, a->data.s64 / (s64) b->data.u64);
     case TAG_UW:
-      if (b->data.uw > S64_MAX)
+      if (UW_MAX > S64_MAX && b->data.uw > S64_MAX)
         return tag_init_s64(dest, 0);
       else
         return tag_init_s64(dest, a->data.s64 / (s64) b->data.uw);
@@ -970,7 +970,7 @@ s_tag * tag_div (const s_tag *a, const s_tag *b, s_tag *dest)
       ratio_clean(&r);
       return dest;
     case TAG_S8:
-      if (a->data.uw > S64_MAX) {
+      if (UW_MAX > S64_MAX && a->data.uw > S64_MAX) {
         integer_init_uw(&tmp, a->data.uw);
         integer_init_s32(&tmp2, (s32) b->data.s8);
         dest->type = TAG_INTEGER;
@@ -982,7 +982,7 @@ s_tag * tag_div (const s_tag *a, const s_tag *b, s_tag *dest)
       else
         return tag_init_s64(dest, (s64) a->data.uw / (s64) b->data.s8);
     case TAG_S16:
-      if (a->data.uw > S64_MAX) {
+      if (UW_MAX > S64_MAX && a->data.uw > S64_MAX) {
         integer_init_uw(&tmp, a->data.uw);
         integer_init_s32(&tmp2, (s32) b->data.s16);
         dest->type = TAG_INTEGER;
@@ -995,7 +995,7 @@ s_tag * tag_div (const s_tag *a, const s_tag *b, s_tag *dest)
         return tag_init_s64(dest, (s64) a->data.uw /
                             (s64) b->data.s16);
     case TAG_S32:
-      if (a->data.uw > S64_MAX) {
+      if (UW_MAX > S64_MAX && a->data.uw > S64_MAX) {
         integer_init_uw(&tmp, a->data.uw);
         integer_init_s32(&tmp2, b->data.s32);
         dest->type = TAG_INTEGER;
@@ -1008,7 +1008,7 @@ s_tag * tag_div (const s_tag *a, const s_tag *b, s_tag *dest)
         return tag_init_s64(dest, (s64) a->data.uw /
                             (s64) b->data.s32);
     case TAG_S64:
-      if (a->data.uw > S64_MAX) {
+      if (UW_MAX > S64_MAX && a->data.uw > S64_MAX) {
         integer_init_uw(&tmp, a->data.uw);
         integer_init_s64(&tmp2, b->data.s64);
         dest->type = TAG_INTEGER;
diff --git a/libc3_window/sdl2/gl_vtext.c b/libc3_window/sdl2/gl_vtext.c
index 3eafe60..4a5fb31 100644
--- a/libc3_window/sdl2/gl_vtext.c
+++ b/libc3_window/sdl2/gl_vtext.c
@@ -221,8 +221,8 @@ bool gl_vtext_render_to_texture_random (s_gl_text *text, uw len)
   FT_GlyphSlot glyph;
   FT_UInt glyph_index;
   sw i;
-  sw j;
-  sw k;
+  uw j;
+  uw k;
   sw line_height;
   sw max_ascent;
   sw max_descent;