git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 08/10] Integrate wildmatch to git

From
Joachim Schmitz <jojo@schmitz-digital.de>
Date
Oct 6, 2012, 09:25 UTC
Message-ID
<k4otes$jll$1@ger.gmane.org>
In-Reply-To
<CACnwZYeob34c6hbMX-CNvJ67Qu5b+v7J8SbfcBOgZv6Qu+aqFg@mail.gmail.com>
Thiago Farina wrote:
Show 73 quoted lines
> On Fri, Oct 5, 2012 at 1:41 AM, Nguyễn Thái Ngọc Duy
> <pclouds@gmail.com> 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
>> use
>> 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 <pclouds@gmail.com>
>> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>> ---
>>  .gitignore           |  1 +
>>  Makefile             |  3 ++
>>  t/t3070-wildmatch.sh | 27 ++++++++++++++++
>>  test-wildmatch.c     | 88
>>  ++++++++++++++++++++++------------------------------ wildmatch.c
>>  | 26 +++++----------- 5 files changed, 75 insertions(+), 70
>>  deletions(-) create mode 100755 t/t3070-wildmatch.sh
>>
>> 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 @@
>>
>>  /*#define COMPARE_WITH_FNMATCH*/
>>
>> -#define WILD_TEST_ITERATIONS
>> -#include "lib/wildmatch.c"
>> +#include "cache.h"
>> +#include "parse-options.h"
>> +#include "wildmatch.h"
>>
>> -#include <popt.h>
>> +#ifndef MAXPATHLEN
>> +#define MAXPATHLEN 1024
>> +#endif
>> +#ifdef NO_STRLCPY
>> +#include "compat/strlcpy.c"
>> +#define strlcpy gitstrlcpy
>> +#endif
>>
>>  #ifdef COMPARE_WITH_FNMATCH
>>  #include <fnmatch.h>
>>
>> -int fnmatch_errors = 0;
>> +static int fnmatch_errors = 0;
>>  #endif
>>
>> -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, 5.1.2.1: All objects with static storage duration shall be initialized (set to their initial values) before program startup. 6.2.4.2: 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. 6.7.8.10: 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 ;-) 
Previous: Thiago FarinaNext: Nguyễn Thái Ngọc Duy
Message 20 of 22 in “nd/wildmatch take 2”
  1. 00/10 nd/wildmatch take 2Nguyễn Thái Ngọc Duy, Oct 5, 2012
  2. 01/10 gitignore: make pattern parsing code a separate functionNguyễn Thái Ngọc Duy, Oct 5, 2012
  3. 02/10 attr: avoid strlen() on every matchNguyễn Thái Ngọc Duy, Oct 5, 2012
  4. 03/10 attr: avoid searching for basename on every matchNguyễn Thái Ngọc Duy, Oct 5, 2012
  5. 04/10 attr: more matching optimizations from .gitignoreNguyễn Thái Ngọc Duy, Oct 5, 2012
  6. Junio C HamanoOct 5, 2012
  7. Nguyen Thai Ngoc DuyOct 6, 2012
  8. Junio C HamanoOct 6, 2012
  9. Nguyen Thai Ngoc DuyOct 6, 2012
  10. Junio C HamanoOct 6, 2012
  11. Nguyen Thai Ngoc DuyOct 8, 2012
  12. Junio C HamanoOct 8, 2012
  13. 05/10 Import wildmatch from rsyncNguyễn Thái Ngọc Duy, Oct 5, 2012
  14. Peter KreftingOct 5, 2012
  15. Nguyen Thai Ngoc DuyOct 5, 2012
  16. 06/10 wildmatch: remove static variable force_lower_caseNguyễn Thái Ngọc Duy, Oct 5, 2012
  17. 07/10 wildmatch: fix case-insensitive matchingNguyễn Thái Ngọc Duy, Oct 5, 2012
  18. 08/10 Integrate wildmatch to gitNguyễn Thái Ngọc Duy, Oct 5, 2012
  19. Thiago FarinaOct 5, 2012
  20. Joachim SchmitzOct 6, 2012
  21. 09/10 Support "**" in .gitignore and .gitattributes patterns using wildmatch()Nguyễn Thái Ngọc Duy, Oct 5, 2012
  22. 10/10 gitignore: forbid "abc**def"Nguyễn Thái Ngọc Duy, Oct 5, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.