Commit fe08cd61beb6c7daf12730e8be77360640deb16c

Thomas de Grivel 2024-12-19T20:54:04

str: str_sw_pos_to_uw

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/libkc3/str.c b/libkc3/str.c
index 8705bd3..0868519 100644
--- a/libkc3/str.c
+++ b/libkc3/str.c
@@ -1406,13 +1406,13 @@ uw * str_sw_pos_to_uw (sw pos, uw max_pos, uw *dest)
     *dest = (uw) pos;
   }
   else {
-    if (max_pos > SW_MAX || pos >= (sw) -max_pos)
+    if (max_pos > SW_MAX || pos + 1 >= (sw) -max_pos)
       *dest = max_pos + pos + 1;
     else {
       err_write_1("str_sw_pos_to_uw: index too low: ");
       err_inspect_sw(&pos);
       err_write_1(" < -");
-      err_inspect_uw(&max_pos);
+      err_inspect_uw_decimal(&max_pos);
       err_write_1("\n");
       assert(! "str_sw_pos_to_uw: index too low");
       return NULL;