Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libeconf for openSUSE:Factory 
checked in at 2021-11-15 15:25:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libeconf (Old)
 and      /work/SRC/openSUSE:Factory/.libeconf.new.1890 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libeconf"

Mon Nov 15 15:25:58 2021 rev:12 rq:930885 version:0.4.2+git20211111.c7a2c52

Changes:
--------
--- /work/SRC/openSUSE:Factory/libeconf/libeconf.changes        2021-07-12 
01:24:33.769449858 +0200
+++ /work/SRC/openSUSE:Factory/.libeconf.new.1890/libeconf.changes      
2021-11-15 15:27:28.769841631 +0100
@@ -1,0 +2,10 @@
+Thu Nov 11 14:22:24 UTC 2021 - sch...@suse.com
+
+- Update to version libeconf-0.4.2+git20211111.c7a2c52:
+  * CMake fixes regarding document installation.
+  * Fixed different issues while writing string values to file.
+  * Writing comments to file too.
+  * Fixed memory leaks.
+  * Fixed crash while merging values.
+
+-------------------------------------------------------------------

Old:
----
  libeconf-0.4.1+git20210709.cf671f2.tar.xz

New:
----
  libeconf-0.4.2+git20211111.c7a2c52.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libeconf.spec ++++++
--- /var/tmp/diff_new_pack.PO9blg/_old  2021-11-15 15:27:29.257841768 +0100
+++ /var/tmp/diff_new_pack.PO9blg/_new  2021-11-15 15:27:29.257841768 +0100
@@ -18,7 +18,7 @@
 
 %define lname  libeconf0
 Name:           libeconf
-Version:        0.4.1+git20210709.cf671f2
+Version:        0.4.2+git20211111.c7a2c52
 Release:        0
 Summary:        Enhanced config file parser ala systemd
 License:        LGPL-2.1-or-later

++++++ _service ++++++
--- /var/tmp/diff_new_pack.PO9blg/_old  2021-11-15 15:27:29.285841775 +0100
+++ /var/tmp/diff_new_pack.PO9blg/_new  2021-11-15 15:27:29.285841775 +0100
@@ -1,7 +1,7 @@
 <services>
   <service name="tar_scm" mode="disabled">
-    <param name="version">0.4.1</param>
-    <param name="versionformat">0.4.1+git%cd.%h</param>
+    <param name="version">0.4.2</param>
+    <param name="versionformat">0.4.2+git%cd.%h</param>
     <param name="url">git://github.com/openSUSE/libeconf.git</param>
     <param name="scm">git</param>
     <param name="changesgenerate">enable</param>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.PO9blg/_old  2021-11-15 15:27:29.305841781 +0100
+++ /var/tmp/diff_new_pack.PO9blg/_new  2021-11-15 15:27:29.305841781 +0100
@@ -1,6 +1,6 @@
 <servicedata>
   <service name="tar_scm">
     <param name="url">git://github.com/openSUSE/libeconf.git</param>
-    <param 
name="changesrevision">cf671f26a6b4fd6f66b194bd59574c14943c0c82</param>
+    <param 
name="changesrevision">c7a2c52816aab57c381dcbf771450ff942e8ac9c</param>
  </service>
 </servicedata>
\ No newline at end of file

++++++ libeconf-0.4.1+git20210709.cf671f2.tar.xz -> 
libeconf-0.4.2+git20211111.c7a2c52.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libeconf-0.4.1+git20210709.cf671f2/INSTALL.md 
new/libeconf-0.4.2+git20211111.c7a2c52/INSTALL.md
--- old/libeconf-0.4.1+git20210709.cf671f2/INSTALL.md   2021-07-09 
09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/INSTALL.md   2021-11-11 
14:57:43.000000000 +0100
@@ -12,6 +12,7 @@
 $ meson build
 $ ninja -C build
 $ ninja -C build test
+$ sudo ninja -C build install
 ```
 
 If you want to build with the address sanitizer enabled, add
@@ -28,6 +29,7 @@
 $ make -C build
 $ make -C build check
 $ make -C build doc
+$ sudo make -C build install
 ```
 
 If you want to build with the address sanitizer enabled, add
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libeconf-0.4.1+git20210709.cf671f2/NEWS 
new/libeconf-0.4.2+git20211111.c7a2c52/NEWS
--- old/libeconf-0.4.1+git20210709.cf671f2/NEWS 2021-07-09 09:11:42.000000000 
+0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/NEWS 2021-11-11 14:57:43.000000000 
+0100
@@ -1,3 +1,10 @@
+Version 0.4.2
+* CMake fixes regarding document installation.
+* Fixed different issues while writing string values to file.
+* Writing comments to file too.
+* Fixed memory leaks.
+* Fixed crash while merging values.
+
 Version 0.4.1
 * CMake fixes regarding installation of econftool and man pages.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libeconf-0.4.1+git20210709.cf671f2/doc/CMakeLists.txt 
new/libeconf-0.4.2+git20211111.c7a2c52/doc/CMakeLists.txt
--- old/libeconf-0.4.1+git20210709.cf671f2/doc/CMakeLists.txt   2021-07-09 
09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/doc/CMakeLists.txt   2021-11-11 
14:57:43.000000000 +0100
@@ -18,7 +18,7 @@
         COMMENT "Generating API documentation with Doxygen"
         VERBATIM)
 
-    install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
+    install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../html DESTINATION 
share/doc)
 endif()
 
 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man/libeconf.3 DESTINATION 
${CMAKE_INSTALL_MANDIR}/man3)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libeconf-0.4.1+git20210709.cf671f2/lib/getfilecontents.c 
new/libeconf-0.4.2+git20211111.c7a2c52/lib/getfilecontents.c
--- old/libeconf-0.4.1+git20210709.cf671f2/lib/getfilecontents.c        
2021-07-09 09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/lib/getfilecontents.c        
2021-11-11 14:57:43.000000000 +0100
@@ -27,14 +27,15 @@
 #include "helpers.h"
 
 #include <errno.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 
 /*info for reporting scan errors (line Nr, filename) */
-uint64_t last_scanned_line_nr = 0;
-char *last_scanned_filename = NULL;
+static uint64_t last_scanned_line_nr = 0;
+static char last_scanned_filename[PATH_MAX];
 
 static econf_err
 join_same_entries(econf_file *ef)
@@ -120,6 +121,7 @@
 store (econf_file *ef, const char *group, const char *key,
        const char *value, const uint64_t line_number,
        const char *comment_before_key, const char *comment_after_value,
+       const bool quotes,
        const bool append_entry)
 {
   if (append_entry)
@@ -178,6 +180,8 @@
 
   ef->file_entry[ef->length-1].line_number = line_number;
 
+  ef->file_entry[ef->length-1].quotes |= quotes;
+
   if (group)
     ef->file_entry[ef->length-1].group = strdup(group);
   else
@@ -243,13 +247,7 @@
   if (kf == NULL)
     return ECONF_NOFILE;
 
-  if (last_scanned_filename != NULL)
-    free(last_scanned_filename);
-  last_scanned_filename = strdup(file);
-  if (last_scanned_filename == NULL) {
-    fclose (kf);
-    return ECONF_NOMEM;
-  }
+  snprintf(last_scanned_filename, sizeof(last_scanned_filename), "%s", file);
 
   check_delim(delim, &has_wsp, &has_nonwsp);
 
@@ -401,6 +399,7 @@
         org_buf[strlen(org_buf)-1] = 0;
       retval = store(ef, current_group, name, org_buf, line,
                     current_comment_before_key, current_comment_after_value,
+                    false, /* Quotes does not matter in the following lines */
                     true /* appending entry */);
       free(current_comment_before_key);
       current_comment_before_key = NULL;
@@ -467,7 +466,7 @@
       while (p > data && (isspace((unsigned)*p)))
        p--;
       /* Strip double quotes only if both leading and trainling quote exist. */
-      if (p > data && quote_seen) {
+      if (p >= data && quote_seen) {
        if (*p == '"')
          p--;
        else
@@ -479,6 +478,7 @@
 
     retval = store(ef, current_group, name, data, line,
                   current_comment_before_key, current_comment_after_value,
+                  quote_seen,
                   false /* new entry */);
     free(current_comment_before_key);
     current_comment_before_key = NULL;
@@ -508,5 +508,5 @@
 void last_scanned_file(char **filename, uint64_t *line_nr)
 {
   *line_nr = last_scanned_line_nr;
-  *filename = last_scanned_filename ? strdup(last_scanned_filename) : NULL;
+  *filename = strdup(last_scanned_filename);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libeconf-0.4.1+git20210709.cf671f2/lib/keyfile.h 
new/libeconf-0.4.2+git20211111.c7a2c52/lib/keyfile.h
--- old/libeconf-0.4.1+git20210709.cf671f2/lib/keyfile.h        2021-07-09 
09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/lib/keyfile.h        2021-11-11 
14:57:43.000000000 +0100
@@ -44,6 +44,7 @@
     char *group, *key, *value;
     char *comment_before_key, *comment_after_value;
     uint64_t line_number;
+    bool quotes; /*Value is enclosed by quotes*/
   } * file_entry;
   /* length represents the current amount of key/value entries in econf_file 
and
      alloc_length the the amount of currently allocated file_entry elements
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libeconf-0.4.1+git20210709.cf671f2/lib/libeconf.c 
new/libeconf-0.4.2+git20211111.c7a2c52/lib/libeconf.c
--- old/libeconf-0.4.1+git20210709.cf671f2/lib/libeconf.c       2021-07-09 
09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/lib/libeconf.c       2021-11-11 
14:57:43.000000000 +0100
@@ -354,6 +354,7 @@
 
   // Write to file
   for (size_t i = 0; i < key_file->length; i++) {
+    // Writing group
     if (!i || strcmp(key_file->file_entry[i - 1].group,
                      key_file->file_entry[i].group)) {
       if (i)
@@ -361,8 +362,46 @@
       if (strcmp(key_file->file_entry[i].group, KEY_FILE_NULL_VALUE))
         fprintf(kf, "%s\n", key_file->file_entry[i].group);
     }
-    fprintf(kf, "%s%c%s\n", key_file->file_entry[i].key, key_file->delimiter,
-            key_file->file_entry[i].value);
+
+    // Writing heading comments
+    if (key_file->file_entry[i].comment_before_key &&
+       strlen(key_file->file_entry[i].comment_before_key) > 0) {
+      char buf[BUFSIZ];
+      char *line;
+      char *value_string = buf;
+
+      strncpy(buf,key_file->file_entry[i].comment_before_key,BUFSIZ-1);
+      while ((line = strsep(&value_string, "\n")) != NULL) {
+       fprintf(kf, "%c%s\n",
+               key_file->comment,
+               line);
+      }
+    }
+
+    // Writing values
+    fprintf(kf, "%s%c", key_file->file_entry[i].key, key_file->delimiter);
+    if (key_file->file_entry[i].value != NULL) {
+      if (key_file->file_entry[i].quotes)
+       fprintf(kf, "\"%s\"", key_file->file_entry[i].value);
+      else
+       fprintf(kf, "%s", key_file->file_entry[i].value);
+    }
+
+    // Writing rest of comments
+    if (key_file->file_entry[i].comment_after_value &&
+       strlen(key_file->file_entry[i].comment_after_value) > 0) {
+      char buf[BUFSIZ];
+      char *line;
+      char *value_string = buf;
+
+      strncpy(buf,key_file->file_entry[i].comment_after_value,BUFSIZ-1);
+      while ((line = strsep(&value_string, "\n")) != NULL) {
+       fprintf(kf, " %c%s\n",
+               key_file->comment,
+               line);
+      }
+    }
+    fprintf(kf, "\n");
   }
 
   // Clean up
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libeconf-0.4.1+git20210709.cf671f2/lib/mergefiles.c 
new/libeconf-0.4.2+git20211111.c7a2c52/lib/mergefiles.c
--- old/libeconf-0.4.1+git20210709.cf671f2/lib/mergefiles.c     2021-07-09 
09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/lib/mergefiles.c     2021-11-11 
14:57:43.000000000 +0100
@@ -49,7 +49,7 @@
 // uf: usr_file, ef: etc_file
 size_t merge_existing_groups(struct file_entry **fe, econf_file *uf, 
econf_file *ef,
                              const size_t etc_start) {
-  char new_key;
+  bool new_key;
   size_t merge_length = etc_start, tmp = etc_start, added_keys = etc_start;
   if (uf && ef) {
     for (size_t i = 0; i <= uf->length; i++) {
@@ -59,13 +59,13 @@
        for (size_t j = etc_start; j < ef->length; j++) {
          // Check for matching groups
          if (!strcmp(uf->file_entry[i - 1].group, ef->file_entry[j].group)) {
-           new_key = 1;
+           new_key = true;
            for (size_t k = merge_length; k < i + tmp; k++) {
              // If an existing key is found in ef take the value from ef
              if (!strcmp((*fe)[k].key, ef->file_entry[j].key)) {
                free((*fe)[k].value);
-               (*fe)[k].value = strdup(ef->file_entry[j].value);
-               new_key = 0;
+               (*fe)[k].value = ef->file_entry[j].value ? 
strdup(ef->file_entry[j].value) : strdup("");
+               new_key = false;
                break;
              }
            }
@@ -89,15 +89,15 @@
 size_t add_new_groups(struct file_entry **fe, econf_file *uf, econf_file *ef,
                       const size_t merge_length) {
   size_t added_keys = merge_length;
-  char new_key;
+  bool new_key;
   if (uf && ef) {
     for (size_t i = 0; i < ef->length; i++) {
       if (!strcmp(ef->file_entry[i].group, KEY_FILE_NULL_VALUE))
        continue;
-      new_key = 1;
+      new_key = true;
       for (size_t j = 0; j < uf->length; j++) {
        if (!strcmp(uf->file_entry[j].group, ef->file_entry[i].group)) {
-         new_key = 0;
+         new_key = false;
          break;
        }
       }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libeconf-0.4.1+git20210709.cf671f2/meson.build 
new/libeconf-0.4.2+git20211111.c7a2c52/meson.build
--- old/libeconf-0.4.1+git20210709.cf671f2/meson.build  2021-07-09 
09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/meson.build  2021-11-11 
14:57:43.000000000 +0100
@@ -7,7 +7,7 @@
                  'b_pie=true',
                  'warning_level=3',],
   license : 'MIT',
-  version : '0.4.1',
+  version : '0.4.2',
 )
 
 cc = meson.get_compiler('c')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libeconf-0.4.1+git20210709.cf671f2/tests/CMakeLists.txt 
new/libeconf-0.4.2+git20211111.c7a2c52/tests/CMakeLists.txt
--- old/libeconf-0.4.1+git20210709.cf671f2/tests/CMakeLists.txt 2021-07-09 
09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/tests/CMakeLists.txt 2021-11-11 
14:57:43.000000000 +0100
@@ -55,7 +55,8 @@
           tst-quote1
          tst-parse-error
          tst-getpath
-          )
+         tst-write-string-data
+         tst-write-comments )
 
 foreach (TESTCASE ${TESTS})
   BuildAndAddTest(${TESTCASE})
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libeconf-0.4.1+git20210709.cf671f2/tests/meson.build 
new/libeconf-0.4.2+git20211111.c7a2c52/tests/meson.build
--- old/libeconf-0.4.1+git20210709.cf671f2/tests/meson.build    2021-07-09 
09:11:42.000000000 +0200
+++ new/libeconf-0.4.2+git20211111.c7a2c52/tests/meson.build    2021-11-11 
14:57:43.000000000 +0100
@@ -18,13 +18,16 @@
 tst_merge5_exe = executable('tst-merge5', 'tst-merge5.c', c_args: test_args, 
dependencies : libeconf_dep)
 test('tst-merge5', tst_merge5_exe)
 
+tst_write_string_data_exe = executable('tst-write-string-data', 
'tst-write-string-data.c', c_args: test_args, dependencies : libeconf_dep)
+test('tst-write-string-data', tst_write_string_data_exe)
+tst_write_comments_exe = executable('tst-write-comments', 
'tst-write-comments.c', c_args: test_args, dependencies : libeconf_dep)
+test('tst-write-comments', tst_write_comments_exe)
 
 tst_logindefs1_exe = executable('tst-logindefs1', 'tst-logindefs1.c', c_args: 
test_args, dependencies : libeconf_dep)
 test('tst-logindefs1', tst_logindefs1_exe)
 tst_logindefs2_exe = executable('tst-logindefs2', 'tst-logindefs2.c', c_args: 
test_args, dependencies : libeconf_dep)
 test('tst-logindefs2', tst_logindefs2_exe)
 
-
 tst_arguments1_exe = executable('tst-arguments1', 'tst-arguments1.c', c_args: 
test_args, dependencies : libeconf_dep)
 test('tst-arguments1', tst_arguments1_exe)
 tst_arguments2_exe = executable('tst-arguments2', 'tst-arguments2.c', c_args: 
test_args, dependencies : libeconf_dep)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libeconf-0.4.1+git20210709.cf671f2/tests/tst-write-comments/arguments.conf 
new/libeconf-0.4.2+git20211111.c7a2c52/tests/tst-write-comments/arguments.conf
--- 
old/libeconf-0.4.1+git20210709.cf671f2/tests/tst-write-comments/arguments.conf  
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/libeconf-0.4.2+git20211111.c7a2c52/tests/tst-write-comments/arguments.conf  
    2021-11-11 14:57:43.000000000 +0100
@@ -0,0 +1,22 @@
+none_comment = 1
+# header_without_value test
+header_without_value = string with spaces
+
+# header_with_value test
+header_with_value = string with spaces #value desription
+# line 1
+# line 2
+#
+# line 3
+multiline_header = multiline header
+
+# header multiline
+multiline_entry = line one # line 1
+    line two               # line 2
+multiline_entry_with_blank =
+    line one # line 1
+    line two
+    line three # line 3
+# header escaped string
+string_escaped_with_newlines = "line one
+    line two" # line 2
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libeconf-0.4.1+git20210709.cf671f2/tests/tst-write-comments.c 
new/libeconf-0.4.2+git20211111.c7a2c52/tests/tst-write-comments.c
--- old/libeconf-0.4.1+git20210709.cf671f2/tests/tst-write-comments.c   
1970-01-01 01:00:00.000000000 +0100
+++ new/libeconf-0.4.2+git20211111.c7a2c52/tests/tst-write-comments.c   
2021-11-11 14:57:43.000000000 +0100
@@ -0,0 +1,112 @@
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include "libeconf_ext.h"
+
+/* Test case:
+ *  Tests writing several comment. 
+ */
+
+static int
+print_error_get (const char *key, econf_err error)
+{
+  fprintf (stderr, "ERROR: tried to get '%s': %s\n",
+          key, econf_errString(error));
+  return 1;
+}
+
+static bool
+check_comments (econf_file *key_file, const char *key,
+               const char *comment_before_key,
+               const char *comment_after_value)
+{
+  econf_err error;
+  econf_ext_value *ext_val;
+
+  if ((error = econf_getExtValue(key_file, NULL, key, &ext_val)))
+  {
+    print_error_get (key, error);
+    econf_freeExtValue(ext_val);
+    return false;
+  }
+
+  if ((ext_val->comment_before_key != NULL && comment_before_key == NULL) ||
+      (ext_val->comment_before_key == NULL && comment_before_key != NULL) ||
+      (ext_val->comment_before_key != NULL && comment_before_key != NULL &&
+       strcmp(ext_val->comment_before_key, comment_before_key) != 0))
+  {
+    fprintf (stderr, "ERROR: %s\nExpected String:\n'%s'\nGot:\n'%s'\n",
+            key, comment_before_key, ext_val->comment_before_key);
+    econf_freeExtValue(ext_val);
+    return false;
+  }
+
+  if ((ext_val->comment_after_value != NULL && comment_after_value == NULL) ||
+      (ext_val->comment_after_value == NULL && comment_after_value != NULL) ||
+      (ext_val->comment_after_value != NULL && comment_after_value != NULL &&
+       strcmp(ext_val->comment_after_value, comment_after_value) != 0))
+  {
+    fprintf (stderr, "ERROR: %s\nExpected String:\n'%s'\nGot:\n'%s'\n",
+            key, comment_after_value, ext_val->comment_after_value);
+    econf_freeExtValue(ext_val);
+    return false;
+  }
+  
+  econf_freeExtValue(ext_val);
+  return true;
+}
+
+int
+main(void)
+{
+  econf_file *key_file = NULL;
+  econf_err error;
+  int retval = 0;
+
+  static const struct {
+    const char *const key;
+    const char *const comment_before_key;
+    const char *const comment_after_value;
+  } tests[] = {
+    { "none_comment", NULL, NULL },
+    { "header_without_value", " header_without_value test", NULL },
+    { "header_with_value", " header_with_value test", "value desription" },
+    { "multiline_header", " line 1\n line 2\n\n line 3", NULL },
+  };
+  unsigned int i;  
+
+  error = econf_readFile (&key_file, 
TESTSDIR"tst-write-comments/arguments.conf", "=", "#");
+  if (error)
+  {
+    fprintf (stderr, "ERROR: couldn't read configuration file: %s\n", 
econf_errString(error));
+    return 1;
+  }
+
+  // Rewrite file to disk
+  econf_writeFile(key_file, TESTSDIR"tst-write-comments/", "out.ini");
+
+  // And reading it again
+  econf_file *key_compare;
+  error = econf_readFile(&key_compare,
+                        TESTSDIR"tst-write-comments/out.ini", "=", "#");
+  if (error || key_compare == NULL) {
+    fprintf (stderr, "ERROR: couldn't read written /usr/etc configuration 
file: %s\n", econf_errString(error));
+    return 1;
+  }
+  remove(TESTSDIR"tst-write-comments/out.ini");
+
+  for (i = 0; i < sizeof(tests)/sizeof(*tests); i++)
+  {
+    if (!check_comments(key_compare, tests[i].key, tests[i].comment_before_key,
+                       tests[i].comment_after_value))
+      retval = 1;
+  }
+
+  econf_free(key_file);
+  econf_free(key_compare);
+  return retval;  
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libeconf-0.4.1+git20210709.cf671f2/tests/tst-write-string-data/usr/etc/tst-string-data.conf
 
new/libeconf-0.4.2+git20211111.c7a2c52/tests/tst-write-string-data/usr/etc/tst-string-data.conf
--- 
old/libeconf-0.4.1+git20210709.cf671f2/tests/tst-write-string-data/usr/etc/tst-string-data.conf
     1970-01-01 01:00:00.000000000 +0100
+++ 
new/libeconf-0.4.2+git20211111.c7a2c52/tests/tst-write-string-data/usr/etc/tst-string-data.conf
     2021-11-11 14:57:43.000000000 +0100
@@ -0,0 +1,7 @@
+[test]
+test=
+test2=""
+test3="string"
+test4=string
+test5=" string "
+test6=string test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libeconf-0.4.1+git20210709.cf671f2/tests/tst-write-string-data.c 
new/libeconf-0.4.2+git20211111.c7a2c52/tests/tst-write-string-data.c
--- old/libeconf-0.4.1+git20210709.cf671f2/tests/tst-write-string-data.c        
1970-01-01 01:00:00.000000000 +0100
+++ new/libeconf-0.4.2+git20211111.c7a2c52/tests/tst-write-string-data.c        
2021-11-11 14:57:43.000000000 +0100
@@ -0,0 +1,75 @@
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "libeconf.h"
+
+/* Test case:
+ * Reading, merging and writing string data
+*/
+
+int
+main(void)
+{
+  econf_err error;  
+
+  // Read test data
+  econf_file *kf_fromfile;
+  error = econf_readFile(&kf_fromfile,
+                        
TESTSDIR"tst-write-string-data/usr/etc/tst-string-data.conf",
+                        "=", "#");
+  if (error || kf_fromfile == NULL)
+  {
+    fprintf (stderr, "ERROR: couldn't read /usr/etc configuration file: %s\n", 
econf_errString(error));
+    return 1;
+  }
+
+  // Rewrite file to disk
+  econf_writeFile(kf_fromfile, TESTSDIR"tst-write-string-data/", "out.ini");
+
+  // And reading it again
+  econf_file *kf_compare;
+  error = econf_readFile(&kf_compare,
+                        TESTSDIR"tst-write-string-data/out.ini", "=", "#");
+  if (error || kf_compare == NULL) {
+    fprintf (stderr, "ERROR: couldn't read written /usr/etc configuration 
file: %s\n", econf_errString(error));
+    return 1;
+  }
+  remove(TESTSDIR"tst-write-string-data/out.ini");
+
+  // Comparing the data
+  const char *compare[] = {"test", "test2", "test3", "test4", "test5", 
"test6"};
+  for (int i = 0; i < 6; i++) {
+    char *val_fromfile, *val_compare;
+    econf_getStringValue(kf_fromfile, "test", compare[i], &val_fromfile);
+    econf_getStringValue(kf_compare, "test", compare[i], &val_compare);
+    if (val_fromfile == NULL && val_compare == NULL)
+      continue;
+    if (val_fromfile == NULL || val_compare == NULL) {
+      fprintf (stderr, "ERROR: saved values are different\n");
+      return 1;
+    }
+    if(strcmp(val_fromfile, val_compare) != 0) {
+      fprintf (stderr, "ERROR: saved values are different '%s' - '%s'\n",
+              val_fromfile, val_compare);
+      return 1;
+    }
+    free(val_fromfile);
+    free(val_compare);
+  }
+
+  // Merge two econf_files. One value is a NULL value.
+  econf_file *kf_freshini;
+  econf_newIniFile(&kf_freshini);
+  econf_setStringValue(kf_freshini, "test", "test", NULL);  
+  econf_file *kf_merged;
+  econf_mergeFiles(&kf_merged, kf_freshini, kf_fromfile);
+
+  econf_free(kf_freshini);
+  econf_free(kf_merged);
+  econf_free(kf_compare);
+  econf_free(kf_fromfile);
+  return 0;
+}

Reply via email to