From 08d97e4bfec42162b7953efe80cc2b410b63fdcd Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi

Date: Fri, 15 Dec 2023 17:50:37 +0200

Subject: [PATCH 1/1] StringList: Implemented missing iterator remove and

take methods


CHANGES.md | 1 +

src/stringlist.c | 27 ++++++++++++++++++++++++++-

tests/t_string.c | 34 +++++++++++++++++++++++++++++++---

3 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md

index ba891bd..59b43d4 100644

--- a/CHANGES.md

+++ b/CHANGES.md

@@ -2,6 +2,7 @@

1.7.1

+* StringList: Implemented missing iterator remove and take methods.

1.7

diff --git a/src/stringlist.c b/src/stringlist.c

index 70ae6ec..e16d63e 100644

--- a/src/stringlist.c

+++ b/src/stringlist.c

@@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <stdlib.h>

#include <stdarg.h>

-#define iStringListMaxStringsPerNode 1024

+#define iStringListMaxStringsPerNode 512 /* TODO: could be a per-list dynamic setting */

iDeclareType(StringListNode)

@@ -101,6 +101,7 @@ void clear_StringList(iStringList *d) {

static iStringListNode *locateNode_StringList_(const iStringList *d, size_t pos, size_t *start_out) {

 iAssert(pos < d->size);

 if (isEmpty_List(&d->list)) {

     return NULL;

 }

 const iBool forwards = (pos < d->size / 2);

@@ -330,6 +331,11 @@ void init_StringListIterator(iStringListIterator *d, iStringList *list) {

void next_StringListIterator(iStringListIterator *d) {

 d->pos++;

 d->nodePos++;

 if (d->nodePos == size_StringListNode_(d->node)) {

     d->nodePos = 0;

     d->node = next_StringListNode_(d->node);

@@ -341,6 +347,25 @@ void next_StringListIterator(iStringListIterator *d) {

 updateValue_StringListIterator(d);

}

+void remove_StringListIterator(iStringListIterator *d) {

+}

+iString *take_StringListIterator(iStringListIterator *d) {

+}

void init_StringListConstIterator(iStringListConstIterator *d, const iStringList *list) {

 d->node = front_List(&list->list);

 d->list = list;

diff --git a/tests/t_string.c b/tests/t_string.c

index e95b196..1e17811 100644

--- a/tests/t_string.c

+++ b/tests/t_string.c

@@ -42,12 +42,12 @@ int main(int argc, char *argv[]) {

     const iString str = iStringLiteral("Ääkkönén");

     iString *upper = collect_String(upper_String(&str));

     iString *lower = collect_String(lower_String(&str));

            cstrLocal_String(&str), cstrLocal_String(upper), cstrLocal_String(lower));

 }

 /* Test Unicode strings. */ {

     iString *s = collect_String(newCStr_String("A_Äö\U0001f698a"));

         cstrLocal_String(s), length_String(s), size_String(s)); {

         iConstForEach(String, i, s) {

             printf(" char: %06x [%s]\n", i.value, cstrLocal_Char(i.value));

@@ -60,7 +60,7 @@ int main(int argc, char *argv[]) {

     }

     printf("Starts with: %i %i\n", startsWith_String(s, "a"), startsWithCase_String(s, "a"));

     printf("Ends with: %i %i\n", endsWith_String(s, "a"), endsWithCase_String(s, "A"));

     printf("%s is at: %zu %zu\n", cstrLocal_Char(u'ö'), indexOfCStr_String(s, "ö"), indexOf_String(s, U'ö'));

     truncate_String(s, 3);

     printf("Truncated: %s\n", cstrLocal_String(s));

@@ -105,6 +105,34 @@ int main(int argc, char *argv[]) {

     }

     iRelease(file);

 }

 /* Splitting a string. */ {

     const iString *str = &iStringLiteral("/usr/local/bin");

     const iRangecc rng = range_String(str);

--

2.25.1

Proxy Information
Original URL
gemini://git.skyjake.fi/the_Foundation/release-1.2/patch/08d97e4bfec42162b7953efe80cc2b410b63fdcd.patch
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
27.610524 milliseconds
Gemini-to-HTML Time
2.007624 milliseconds

This content has been proxied by September (ba2dc).