Thiago Farina wrote:
On Fri, Oct 5, 2012 at 1:41 AM, Nguyễn Thái Ngọc Duy
<> wrote:
This makes wildmatch.c part of libgit.a and builds test-wildmatch;
the dependency on libpopt in the original has been replaced with the
of our parse-options. Global variables in test-wildmatch are marked
static to avoid sparse warnings.

Signed-off-by: Nguyễn Thái Ngọc Duy <>
Signed-off-by: Ramsay Jones <>
Signed-off-by: Junio C Hamano <>
 .gitignore           |  1 +
 Makefile             |  3 ++
 t/ | 27 ++++++++++++++++
 test-wildmatch.c     | 88
 ++++++++++++++++++++++------------------------------ wildmatch.c
 | 26 +++++----------- 5 files changed, 75 insertions(+), 70
 deletions(-) create mode 100755 t/

diff --git a/test-wildmatch.c b/test-wildmatch.c
index 88585c2..bb726c8 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -19,34 +19,38 @@


-#include "lib/wildmatch.c"
+#include "cache.h"
+#include "parse-options.h"
+#include "wildmatch.h"

-#include <popt.h>
+#define MAXPATHLEN 1024
+#ifdef NO_STRLCPY
+#include "compat/strlcpy.c"
+#define strlcpy gitstrlcpy

 #include <fnmatch.h>

-int fnmatch_errors = 0;
+static int fnmatch_errors = 0;

-int wildmatch_errors = 0;
-char number_separator = ',';
+static int wildmatch_errors = 0;

 typedef char bool;

-int output_iterations = 0;
-int explode_mod = 0;
-int empties_mod = 0;
-int empty_at_start = 0;
-int empty_at_end = 0;
-static struct poptOption long_options[] = {
-  /* longName, shortName, argInfo, argPtr, value, descrip, argDesc
-  {"iterations",     'i', POPT_ARG_NONE,   &output_iterations, 0,
0, 0},
-  {"empties",        'e', POPT_ARG_STRING, 0, 'e', 0, 0},
-  {"explode",        'x', POPT_ARG_INT,    &explode_mod, 0, 0, 0},
-  {0,0,0,0, 0, 0, 0}
+static int explode_mod = 0;
Isn't static variables like this initialized to zero by default? There
is a high chance that I might be wrong though.

C99, All objects with static storage duration shall be initialized (set to their initial values) before program startup. An object whose identifier is declared with external or internal linkage, or with the storage-class specifier static has static storage duration. Its lifetime is the entire execution of the program and its stored value is initialized only once, prior to program startup. If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate. If an object that has static storage duration is not initialized explicitly, then:
— if it has pointer type, it is initialized to a null pointer;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero; — if it is an aggregate, every member is initialized (recursively) according to these rules; — if it is a union, the first named member is initialized (recursively) according to these rules.

So seems you're right ;-)

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to