ucx/properties.c

branch
dav-2
changeset 894
e86049631677
parent 891
4d58cbcc9efa
--- a/ucx/properties.c	Tue Dec 30 21:39:38 2025 +0100
+++ b/ucx/properties.c	Wed Dec 31 16:41:16 2025 +0100
@@ -112,7 +112,7 @@
         cxstring nl = cx_strchr(input, '\n');
         while (nl.length > 0) {
             // check for line continuation
-            char previous = nl.ptr > input.ptr ? nl.ptr[-1] : prop->buffer.space[prop->buffer.size-1];
+            char previous = nl.ptr > input.ptr ? nl.ptr[-1] : cx_strat(cx_bstr(&prop->buffer), -1);
             if (previous == continuation) {
                 // this nl is a line continuation, check the next newline
                 nl = cx_strchr(cx_strsubs(nl, 1), '\n');
@@ -128,7 +128,7 @@
 
             if (cxBufferAppend(input.ptr, 1,
                 len_until_nl, &prop->buffer) < len_until_nl) {
-                return CX_PROPERTIES_BUFFER_ALLOC_FAILED;
+                return CX_PROPERTIES_BUFFER_ALLOC_FAILED; // LCOV_EXCL_LINE
             }
 
             // advance the position in the input buffer
@@ -197,7 +197,7 @@
                 cxBufferReset(&prop->buffer);
             }
             if (cxBufferAppend(buf, 1, len, &prop->buffer) < len) {
-                return CX_PROPERTIES_BUFFER_ALLOC_FAILED;
+                return CX_PROPERTIES_BUFFER_ALLOC_FAILED; // LCOV_EXCL_LINE
             }
             // reset the input buffer (make way for a re-fill)
             cxBufferReset(&prop->input);
@@ -256,7 +256,7 @@
                         prop->buffer.size = 0;
                         prop->buffer.pos = 0;
                         if (cxBufferWrite(val.ptr, 1, val.length, &prop->buffer) != val.length) {
-                            return CX_PROPERTIES_BUFFER_ALLOC_FAILED;
+                            return CX_PROPERTIES_BUFFER_ALLOC_FAILED; // LCOV_EXCL_LINE
                         }
                         val.ptr = prop->buffer.space;
                         ptr = prop->buffer.space;
@@ -338,12 +338,12 @@
     }
 
     // initialize the parser
-    char linebuf[cx_properties_load_buf_size];
-    char fillbuf[cx_properties_load_fill_size];
+    char linebuf[CX_PROPERTIES_LOAD_BUF_SIZE];
+    char fillbuf[CX_PROPERTIES_LOAD_FILL_SIZE];
     CxPropertiesStatus status;
     CxProperties parser;
     cxPropertiesInit(&parser, config);
-    cxPropertiesUseStack(&parser, linebuf, cx_properties_load_buf_size);
+    cxPropertiesUseStack(&parser, linebuf, CX_PROPERTIES_LOAD_BUF_SIZE);
 
     // read/fill/parse loop
     status = CX_PROPERTIES_NO_DATA;
@@ -351,15 +351,19 @@
     while (true) {
         size_t r = fread(fillbuf, 1, cx_properties_load_fill_size, f);
         if (ferror(f)) {
+            // LCOV_EXCL_START
             status = CX_PROPERTIES_FILE_ERROR;
             break;
+            // LCOV_EXCL_STOP
         }
         if (r == 0) {
             break;
         }
         if (cxPropertiesFilln(&parser, fillbuf, r)) {
+            // LCOV_EXCL_START
             status = CX_PROPERTIES_BUFFER_ALLOC_FAILED;
             break;
+            // LCOV_EXCL_STOP
         }
         cxstring key, value;
         while (true) {
@@ -368,15 +372,19 @@
                 break;
             } else {
                 cxmutstr v = cx_strdup_a(allocator, value);
+                // LCOV_EXCL_START
                 if (v.ptr == NULL) {
                     status = CX_PROPERTIES_MAP_ERROR;
                     break;
                 }
+                // LCOV_EXCL_STOP
                 void *mv = use_cstring ? (void*)v.ptr : &v;
                 if (cxMapPut(target, key, mv)) {
+                    // LCOV_EXCL_START
                     cx_strfree(&v);
                     status = CX_PROPERTIES_MAP_ERROR;
                     break;
+                    // LCOV_EXCL_STOP
                 }
                 keys_found++;
             }

mercurial