diff options
| -rw-r--r-- | xs.h | 24 | ||||
| -rw-r--r-- | xs_regex.h | 5 | ||||
| -rw-r--r-- | xs_set.h | 5 | ||||
| -rw-r--r-- | xs_url.h | 5 | ||||
| -rw-r--r-- | xs_version.h | 2 |
5 files changed, 21 insertions, 20 deletions
| @@ -798,11 +798,10 @@ int xs_list_len(const xs_list *list) | |||
| 798 | { | 798 | { |
| 799 | XS_ASSERT_TYPE_NULL(list, XSTYPE_LIST); | 799 | XS_ASSERT_TYPE_NULL(list, XSTYPE_LIST); |
| 800 | 800 | ||
| 801 | int c = 0; | 801 | int c = 0, ct = 0; |
| 802 | xs_list *p = (xs_list *)list; | ||
| 803 | const xs_val *v; | 802 | const xs_val *v; |
| 804 | 803 | ||
| 805 | while (xs_list_iter(&p, &v)) | 804 | while (xs_list_next(list, &v, &ct)) |
| 806 | c++; | 805 | c++; |
| 807 | 806 | ||
| 808 | return c; | 807 | return c; |
| @@ -817,11 +816,10 @@ const xs_val *xs_list_get(const xs_list *list, int num) | |||
| 817 | if (num < 0) | 816 | if (num < 0) |
| 818 | num = xs_list_len(list) + num; | 817 | num = xs_list_len(list) + num; |
| 819 | 818 | ||
| 820 | int c = 0; | 819 | int c = 0, ct = 0; |
| 821 | xs_list *p = (xs_list *)list; | ||
| 822 | const xs_val *v; | 820 | const xs_val *v; |
| 823 | 821 | ||
| 824 | while (xs_list_iter(&p, &v)) { | 822 | while (xs_list_next(list, &v, &ct)) { |
| 825 | if (c == num) | 823 | if (c == num) |
| 826 | return v; | 824 | return v; |
| 827 | 825 | ||
| @@ -880,16 +878,16 @@ xs_list *xs_list_dequeue(xs_list *list, xs_val **data, int last) | |||
| 880 | { | 878 | { |
| 881 | XS_ASSERT_TYPE(list, XSTYPE_LIST); | 879 | XS_ASSERT_TYPE(list, XSTYPE_LIST); |
| 882 | 880 | ||
| 883 | xs_list *p = list; | 881 | int ct = 0; |
| 884 | const xs_val *v = NULL; | 882 | const xs_val *v = NULL; |
| 885 | 883 | ||
| 886 | if (!last) { | 884 | if (!last) { |
| 887 | /* get the first */ | 885 | /* get the first */ |
| 888 | xs_list_iter(&p, &v); | 886 | xs_list_next(list, &v, &ct); |
| 889 | } | 887 | } |
| 890 | else { | 888 | else { |
| 891 | /* iterate to the end */ | 889 | /* iterate to the end */ |
| 892 | while (xs_list_iter(&p, &v)); | 890 | while (xs_list_next(list, &v, &ct)); |
| 893 | } | 891 | } |
| 894 | 892 | ||
| 895 | if (v != NULL) { | 893 | if (v != NULL) { |
| @@ -909,11 +907,11 @@ int xs_list_in(const xs_list *list, const xs_val *val) | |||
| 909 | XS_ASSERT_TYPE_NULL(list, XSTYPE_LIST); | 907 | XS_ASSERT_TYPE_NULL(list, XSTYPE_LIST); |
| 910 | 908 | ||
| 911 | int n = 0; | 909 | int n = 0; |
| 912 | xs_list *p = (xs_list *)list; | 910 | int ct = 0; |
| 913 | const xs_val *v; | 911 | const xs_val *v; |
| 914 | int sz = xs_size(val); | 912 | int sz = xs_size(val); |
| 915 | 913 | ||
| 916 | while (xs_list_iter(&p, &v)) { | 914 | while (xs_list_next(list, &v, &ct)) { |
| 917 | if (sz == xs_size(v) && memcmp(val, v, sz) == 0) | 915 | if (sz == xs_size(v) && memcmp(val, v, sz) == 0) |
| 918 | return n; | 916 | return n; |
| 919 | 917 | ||
| @@ -930,13 +928,13 @@ xs_str *xs_join(const xs_list *list, const char *sep) | |||
| 930 | XS_ASSERT_TYPE(list, XSTYPE_LIST); | 928 | XS_ASSERT_TYPE(list, XSTYPE_LIST); |
| 931 | 929 | ||
| 932 | xs_str *s = NULL; | 930 | xs_str *s = NULL; |
| 933 | xs_list *p = (xs_list *)list; | ||
| 934 | const xs_val *v; | 931 | const xs_val *v; |
| 935 | int c = 0; | 932 | int c = 0; |
| 933 | int ct = 0; | ||
| 936 | int offset = 0; | 934 | int offset = 0; |
| 937 | int ssz = strlen(sep); | 935 | int ssz = strlen(sep); |
| 938 | 936 | ||
| 939 | while (xs_list_iter(&p, &v)) { | 937 | while (xs_list_next(list, &v, &ct)) { |
| 940 | /* refuse to join non-string values */ | 938 | /* refuse to join non-string values */ |
| 941 | if (xs_type(v) == XSTYPE_STRING) { | 939 | if (xs_type(v) == XSTYPE_STRING) { |
| 942 | int sz; | 940 | int sz; |
| @@ -16,6 +16,11 @@ xs_list *xs_regex_replace_in(xs_str *str, const char *rx, const char *rep, int c | |||
| 16 | 16 | ||
| 17 | #ifdef XS_IMPLEMENTATION | 17 | #ifdef XS_IMPLEMENTATION |
| 18 | 18 | ||
| 19 | #ifdef __TINYC__ | ||
| 20 | /* fix a compilation error in tcc */ | ||
| 21 | #define _REGEX_NELTS(n) | ||
| 22 | #endif | ||
| 23 | |||
| 19 | #include <regex.h> | 24 | #include <regex.h> |
| 20 | 25 | ||
| 21 | xs_list *xs_regex_split_n(const char *str, const char *rx, int count) | 26 | xs_list *xs_regex_split_n(const char *str, const char *rx, int count) |
| @@ -85,7 +85,6 @@ int xs_set_add(xs_set *s, const xs_val *data) | |||
| 85 | { | 85 | { |
| 86 | /* is it 'full'? */ | 86 | /* is it 'full'? */ |
| 87 | if (s->used >= s->elems / 2) { | 87 | if (s->used >= s->elems / 2) { |
| 88 | char *p; | ||
| 89 | const xs_val *v; | 88 | const xs_val *v; |
| 90 | 89 | ||
| 91 | /* expand! */ | 90 | /* expand! */ |
| @@ -96,8 +95,8 @@ int xs_set_add(xs_set *s, const xs_val *data) | |||
| 96 | memset(s->hash, '\0', s->elems * sizeof(int)); | 95 | memset(s->hash, '\0', s->elems * sizeof(int)); |
| 97 | 96 | ||
| 98 | /* add the list elements back */ | 97 | /* add the list elements back */ |
| 99 | p = s->list; | 98 | int ct = 0; |
| 100 | while (xs_list_iter(&p, &v)) | 99 | while (xs_list_next(s->list, &v, &ct)) |
| 101 | _store_hash(s, v, v - s->list); | 100 | _store_hash(s, v, v - s->list); |
| 102 | } | 101 | } |
| 103 | 102 | ||
| @@ -51,11 +51,10 @@ xs_dict *xs_url_vars(const char *str) | |||
| 51 | /* split by arguments */ | 51 | /* split by arguments */ |
| 52 | xs *args = xs_split(str, "&"); | 52 | xs *args = xs_split(str, "&"); |
| 53 | 53 | ||
| 54 | xs_list *l; | 54 | int ct = 0; |
| 55 | const xs_val *v; | 55 | const xs_val *v; |
| 56 | 56 | ||
| 57 | l = args; | 57 | while (xs_list_next(args, &v, &ct)) { |
| 58 | while (xs_list_iter(&l, &v)) { | ||
| 59 | xs *kv = xs_split_n(v, "=", 1); | 58 | xs *kv = xs_split_n(v, "=", 1); |
| 60 | 59 | ||
| 61 | if (xs_list_len(kv) == 2) { | 60 | if (xs_list_len(kv) == 2) { |
diff --git a/xs_version.h b/xs_version.h index 9fb70ef..7a7ba53 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* 65265483c102909393287bfb173d1a7ae9c3be00 2024-05-23T09:57:20+02:00 */ | /* 65769f25ed99b886a643522bef21628396cd118d 2024-05-25T08:18:51+02:00 */ | ||