src/properties.c

changeset 1558
fc863c877a75
parent 1557
03fbf1c99e73
child 1559
9e50f45f8736
--- a/src/properties.c	Mon Dec 08 23:09:11 2025 +0100
+++ b/src/properties.c	Tue Dec 09 17:27:58 2025 +0100
@@ -283,6 +283,7 @@
 
     // read/fill/parse loop
     status = CX_PROPERTIES_NO_DATA;
+    size_t keys_found = 0;
     while (true) {
         size_t r = fread(fillbuf, 1, cx_properties_load_fill_size, f);
         if (ferror(f)) {
@@ -313,13 +314,11 @@
                     status = CX_PROPERTIES_MAP_ERROR;
                     break;
                 }
+                keys_found++;
             }
         }
         if (status > CX_PROPERTIES_OK) {
             break;
-        } else if (status == CX_PROPERTIES_NO_DATA) {
-            // we want to report this case differently in this function
-            status = CX_PROPERTIES_NO_ERROR;
         }
     }
 
@@ -327,5 +326,9 @@
     fclose(f);
     cxPropertiesDestroy(&parser);
     cx_strfree(&fname);
-    return status;
+    if (status == CX_PROPERTIES_NO_DATA && keys_found > 0) {
+        return CX_PROPERTIES_NO_ERROR;
+    } else {
+        return status;
+    }
 }

mercurial