[git] GnuPG - branch, master, updated. gnupg-2.1.3-3-g454f603

by Werner Koch cvs at cvs.gnupg.org
Mon Apr 13 09:59:17 CEST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  454f60399c7318fffd3de2afadd58c7a490178bd (commit)
      from  eb54282e39fe4bc7bea447e6f0d1f446c529b482 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 454f60399c7318fffd3de2afadd58c7a490178bd
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Apr 13 09:57:33 2015 +0200

    common: Do without nested fucntions to support non-gcc.
    
    * common/t-stringhelp.c (test_strsplit): Remove nested function.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/t-stringhelp.c b/common/t-stringhelp.c
index f5b6cd9..9d1d20c 100644
--- a/common/t-stringhelp.c
+++ b/common/t-stringhelp.c
@@ -482,58 +482,60 @@ test_make_absfilename_try (void)
 static void
 test_strsplit (void)
 {
-  int test_count = 0;
-  void test (const char *s, char delim, char replacement,
-	     const char *fields_expected[])
-  {
-    char *s2;
-    int field_count;
-    char **fields;
-    int field_count_expected;
-    int i;
-
-    /* Count the fields.  */
-    for (field_count_expected = 0;
-	 fields_expected[field_count_expected];
-	 field_count_expected ++)
-      ;
-
-    test_count ++;
-
-    /* We need to copy s since strsplit modifies it in place.  */
-    s2 = xstrdup (s);
-    fields = strsplit (s2, delim, replacement, &field_count);
-
-    if (field_count != field_count_expected)
-      fail (test_count * 1000);
-
-    for (i = 0; i < field_count_expected; i ++)
-      if (strcmp (fields_expected[i], fields[i]) != 0)
-	{
-	  printf ("For field %d, expected '%s', but got '%s'\n",
-		  i, fields_expected[i], fields[i]);
-	  fail (test_count * 1000 + i + 1);
-	}
-
-    xfree (s2);
-  }
-
-  {
-    const char *expected_result[] =
-      { "a", "bc", "cde", "fghi", "jklmn", "", "foo", "", NULL };
-    test ("a:bc:cde:fghi:jklmn::foo:", ':', '\0', expected_result);
-  }
-
-  {
-    const char *expected_result[] =
-      { "!a!bc!!def!", "a!bc!!def!", "bc!!def!", "!def!", "def!", "", NULL };
-    test (",a,bc,,def,", ',', '!', expected_result);
-  }
-
-  {
-    const char *expected_result[] = { "", NULL };
-    test ("", ':', ',', expected_result);
-  }
+  struct {
+    const char *s;
+    char delim;
+    char replacement;
+    const char *fields_expected[10];
+  } tv[] = {
+    {
+      "a:bc:cde:fghi:jklmn::foo:", ':', '\0',
+      { "a", "bc", "cde", "fghi", "jklmn", "", "foo", "", NULL }
+    },
+    {
+      ",a,bc,,def,", ',', '!',
+      { "!a!bc!!def!", "a!bc!!def!", "bc!!def!", "!def!", "def!", "", NULL }
+    },
+    {
+      "", ':', ',',
+      { "", NULL }
+    }
+  };
+
+  int tidx;
+
+  for (tidx = 0; tidx < DIM(tv); tidx++)
+    {
+      char *s2;
+      int field_count;
+      char **fields;
+      int field_count_expected;
+      int i;
+
+      /* Count the fields.  */
+      for (field_count_expected = 0;
+           tv[tidx].fields_expected[field_count_expected];
+           field_count_expected ++)
+        ;
+
+      /* We need to copy s since strsplit modifies it in place.  */
+      s2 = xstrdup (tv[tidx].s);
+      fields = strsplit (s2, tv[tidx].delim, tv[tidx].replacement,
+                         &field_count);
+
+      if (field_count != field_count_expected)
+        fail (tidx * 1000);
+
+      for (i = 0; i < field_count_expected; i ++)
+        if (strcmp (tv[tidx].fields_expected[i], fields[i]) != 0)
+          {
+            printf ("For field %d, expected '%s', but got '%s'\n",
+                    i, tv[tidx].fields_expected[i], fields[i]);
+            fail (tidx * 1000 + i + 1);
+          }
+
+      xfree (s2);
+    }
 }
 
 int

-----------------------------------------------------------------------

Summary of changes:
 common/t-stringhelp.c | 106 +++++++++++++++++++++++++-------------------------
 1 file changed, 54 insertions(+), 52 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list