diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-08 13:33:20 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-08 13:33:20 -0500 |
| commit | 0e9dbb4f8a145022cba56de7692d4fe56aad7a3f (patch) | |
| tree | 46580f1034537a3b0bf8e5267bbe564dd2864684 | |
| parent | 139da8e55f831dad28d2383060052aa54930c201 (diff) | |
Bugfix arrays
| -rw-r--r-- | builtins/array.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/builtins/array.c b/builtins/array.c index 93c20bab..4b557e1c 100644 --- a/builtins/array.c +++ b/builtins/array.c @@ -44,7 +44,7 @@ public void Array__compact(array_t *arr, const TypeInfo *type) public void Array__insert(array_t *arr, const void *item, int64_t index, const TypeInfo *type) { - if (index < 1) index = arr->length + index; + if (index <= 0) index = arr->length + index + 1; if (index < 1) index = 1; else if (index > (int64_t)arr->length + 1) index = (int64_t)arr->length + 1; @@ -79,7 +79,7 @@ public void Array__insert(array_t *arr, const void *item, int64_t index, const T public void Array__insert_all(array_t *arr, array_t to_insert, int64_t index, const TypeInfo *type) { - if (index < 1) index = arr->length + index; + if (index < 1) index = arr->length + index + 1; if (index < 1) index = 1; else if (index > (int64_t)arr->length + 1) index = (int64_t)arr->length + 1; @@ -112,7 +112,7 @@ public void Array__insert_all(array_t *arr, array_t to_insert, int64_t index, co public void Array__remove(array_t *arr, int64_t index, int64_t count, const TypeInfo *type) { - if (index < 1) index = arr->length + index; + if (index < 1) index = arr->length + index + 1; if (index < 1 || index > (int64_t)arr->length || count < 1) return; |
