From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 4/5] Integrate wildmatch to git
Date: Mon, 17 Sep 2012 19:40:20 +0700 [thread overview]
Message-ID: <20120917124020.GA21798@lanh> (raw)
In-Reply-To: <7vd31lw5vy.fsf@alter.siamese.dyndns.org>
On Sun, Sep 16, 2012 at 10:54:57PM -0700, Junio C Hamano wrote:
> Yeah, popt.h it is. It is a bit distasteful that we have a build
> dependency only to build test-* helper on something that we do not
> even have runtime dependency on.
Perhaps this squash-in? It kills libpopt and removes the "#include
"wildmatch.c"". Now we really do test what libgit.a carries.
-- 8< --
diff --git a/Makefile b/Makefile
index 745e88c..093ab9c 100644
--- a/Makefile
+++ b/Makefile
@@ -2589,9 +2589,6 @@ test-svn-fe$X: vcs-svn/lib.a
test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
-test-wildmatch$X: test-wildmatch.o GIT-LDFLAGS
- $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) -lpopt
-
check-sha1:: test-sha1$X
./test-sha1.sh
diff --git a/test-wildmatch.c b/test-wildmatch.c
index 828188a..b94921b 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -19,17 +19,18 @@
/*#define COMPARE_WITH_FNMATCH*/
-#define WILD_TEST_ITERATIONS
-#include "wildmatch.c"
+#include "cache.h"
+#include "parse-options.h"
+#include "wildmatch.h"
+#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
+#endif
#ifdef NO_STRLCPY
#include "compat/strlcpy.c"
#define strlcpy gitstrlcpy
#endif
-#include <popt.h>
-
#ifdef COMPARE_WITH_FNMATCH
#include <fnmatch.h>
@@ -41,18 +42,16 @@ char number_separator = ',';
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;
+char *empties;
-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 struct option options[] = {
+ OPT_STRING('e', "empties", &empties, "", ""),
+ OPT_INTEGER('x', "explode", &explode_mod, ""),
+ OPT_END(),
};
/* match just at the start of string (anchored tests) */
@@ -106,51 +105,33 @@ run_test(int line, bool matches,
fnmatch_errors++;
}
#endif
- if (output_iterations) {
- printf("%d: \"%s\" iterations = %d\n", line, pattern,
- wildmatch_iteration_count);
- }
}
int
main(int argc, char **argv)
{
char buf[2048], *s, *string[2], *end[2];
- const char *arg;
FILE *fp;
- int opt, line, i, flag[2];
- poptContext pc = poptGetContext("wildtest", argc, (const char**)argv,
- long_options, 0);
-
- while ((opt = poptGetNextOpt(pc)) != -1) {
- switch (opt) {
- case 'e':
- arg = poptGetOptArg(pc);
- empties_mod = atoi(arg);
- if (strchr(arg, 's'))
- empty_at_start = 1;
- if (strchr(arg, 'e'))
- empty_at_end = 1;
- if (!explode_mod)
- explode_mod = 1024;
- break;
- default:
- fprintf(stderr, "%s: %s\n",
- poptBadOption(pc, POPT_BADOPTION_NOALIAS),
- poptStrerror(opt));
- exit(1);
- }
+ int line, i, flag[2];
+ const char *help[] = { NULL };
+
+ argc = parse_options(argc, (const char **)argv, "", options, help, 0);
+ if (argc != 1)
+ die("redundant options");
+ if (empties) {
+ const char *arg = empties;
+ empties_mod = atoi(arg);
+ if (strchr(empties, 's'))
+ empty_at_start = 1;
+ if (strchr(arg, 'e'))
+ empty_at_end = 1;
+ if (!explode_mod)
+ explode_mod = 1024;
}
if (explode_mod && !empties_mod)
empties_mod = 1024;
- argv = (char**)poptGetArgs(pc);
- if (!argv || argv[1]) {
- fprintf(stderr, "Usage: wildtest [OPTIONS] TESTFILE\n");
- exit(1);
- }
-
if ((fp = fopen(*argv, "r")) == NULL) {
fprintf(stderr, "Unable to open %s\n", *argv);
exit(1);
diff --git a/wildmatch.c b/wildmatch.c
index 625cb0c..f153f8a 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -59,10 +59,6 @@ typedef unsigned char uchar;
#define ISUPPER(c) (ISASCII(c) && isupper(c))
#define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
-#ifdef WILD_TEST_ITERATIONS
-int wildmatch_iteration_count;
-#endif
-
/* Match pattern "p" against the a virtually-joined string consisting
* of "text" and any strings in array "a". */
static int dowild(const uchar *p, const uchar *text,
@@ -70,10 +66,6 @@ static int dowild(const uchar *p, const uchar *text,
{
uchar p_ch;
-#ifdef WILD_TEST_ITERATIONS
- wildmatch_iteration_count++;
-#endif
-
for ( ; (p_ch = *p) != '\0'; text++, p++) {
int matched, special;
uchar t_ch, prev_ch;
@@ -295,9 +287,6 @@ static const uchar *trailing_N_elements(const uchar*const **a_ptr, int count)
int wildmatch(const char *pattern, const char *text)
{
static const uchar *nomore[1]; /* A NULL pointer. */
-#ifdef WILD_TEST_ITERATIONS
- wildmatch_iteration_count = 0;
-#endif
return dowild((const uchar*)pattern, (const uchar*)text, nomore, 0) == TRUE;
}
@@ -306,9 +295,6 @@ int iwildmatch(const char *pattern, const char *text)
{
static const uchar *nomore[1]; /* A NULL pointer. */
int ret;
-#ifdef WILD_TEST_ITERATIONS
- wildmatch_iteration_count = 0;
-#endif
ret = dowild((const uchar*)pattern, (const uchar*)text, nomore, 1) == TRUE;
return ret;
}
@@ -325,10 +311,6 @@ int wildmatch_array(const char *pattern, const char*const *texts, int where)
const uchar *text;
int matched;
-#ifdef WILD_TEST_ITERATIONS
- wildmatch_iteration_count = 0;
-#endif
-
if (where > 0)
text = trailing_N_elements(&a, where);
else
-- 8< --
next prev parent reply other threads:[~2012-09-17 12:40 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-15 12:01 [PATCH 0/5] Support matching "**" in .gitattributes and .gitignore Nguyễn Thái Ngọc Duy
2012-09-15 12:02 ` [PATCH 1/5] Import wildmatch from rsync Nguyễn Thái Ngọc Duy
2012-09-16 6:49 ` Junio C Hamano
2012-09-15 12:02 ` [PATCH 2/5] compat/wildmatch: remove static variable force_lower_case Nguyễn Thái Ngọc Duy
2012-09-15 12:02 ` [PATCH 3/5] compat/wildmatch: fix case-insensitive matching Nguyễn Thái Ngọc Duy
2012-09-15 12:02 ` [PATCH 4/5] Integrate wildmatch to git Nguyễn Thái Ngọc Duy
2012-09-15 12:02 ` [PATCH 5/5] Support "**" in .gitignore and .gitattributes patterns using wildmatch() Nguyễn Thái Ngọc Duy
2012-09-15 14:27 ` How to create the " [PATCH 0/5]" first email? Philip Oakley
2012-09-15 17:08 ` Junio C Hamano
2012-09-17 22:55 ` Philip Oakley
2012-09-17 23:49 ` Junio C Hamano
2012-09-18 0:15 ` Jeff King
2012-09-18 0:36 ` Junio C Hamano
2012-09-18 18:55 ` Jeff King
2012-09-18 19:11 ` Junio C Hamano
2012-09-18 19:16 ` Jeff King
2012-09-18 19:47 ` Junio C Hamano
2012-09-18 20:10 ` Philip Oakley
2012-09-18 20:16 ` Jeff King
2012-09-18 20:16 ` Jeff King
2012-09-18 20:42 ` Wesley J. Landaker
2012-09-23 12:03 ` Jan Engelhardt
2012-09-16 15:27 ` [PATCH v2 0/5] Support matching "**" in .gitattributes and .gitignore Nguyễn Thái Ngọc Duy
2012-09-16 15:27 ` [PATCH v2 1/5] Import wildmatch from rsync Nguyễn Thái Ngọc Duy
2012-09-16 15:27 ` [PATCH v2 2/5] compat/wildmatch: remove static variable force_lower_case Nguyễn Thái Ngọc Duy
2012-09-16 15:27 ` [PATCH v2 3/5] compat/wildmatch: fix case-insensitive matching Nguyễn Thái Ngọc Duy
2012-09-16 15:27 ` [PATCH v2 4/5] Integrate wildmatch to git Nguyễn Thái Ngọc Duy
2012-09-17 5:31 ` Junio C Hamano
2012-09-17 5:54 ` Junio C Hamano
2012-09-17 5:57 ` Nguyen Thai Ngoc Duy
2012-09-17 12:40 ` Nguyen Thai Ngoc Duy [this message]
2012-09-17 17:20 ` Junio C Hamano
2012-09-16 15:27 ` [PATCH v2 5/5] Support "**" in .gitignore and .gitattributes patterns using wildmatch() Nguyễn Thái Ngọc Duy
2012-09-25 7:01 ` [PATCH 6/5] side-step a make rule that builds t3070-wildmatch Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120917124020.GA21798@lanh \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.