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

[PATCH] Fix compat/regex ANSIfication on MinGW

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Aug 26, 2010, 07:58 UTC
Message-ID
<4C761EA2.2060904@viscovery.net>
In-Reply-To
<loom.20100825T200539-742@post.gmane.org>
From: Johannes Sixt <j6t@kdbg.org>

compat/regexec.c had a weird combination of function declaration in ANSI style and function definition in K&R style, for example:

 static unsigned
 re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
      int nregs, int regs_allocated) internal_function;
 static unsigned
 re_copy_regs (regs, pmatch, nregs, regs_allocated)
     struct re_registers *regs;
     regmatch_t *pmatch;
     int nregs, regs_allocated;
 { ... }
with this #define:
 #ifndef _LIBC
 # ifdef __i386__
 #  define internal_function   __attribute ((regparm (3), stdcall))
 # else
 #  define internal_function
 # endif
 #endif

The original version as shown above was fine, but with the ANSIfied function definition and in the case where internal_function is not empty, gcc identifies the declaration and definition as different and bails out.

Adding internal_function to the definition doesn't help (it results in a syntax error); hence, remove it from the subset of declarations that gcc flags as erroneous.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
Am 8/25/2010 20:24, schrieb Karsten Blees:
Show 7 quoted lines
> this doesn't compile if internal_function is #defined non-empty (e.g. on
> mingw/msysgit). The old-style definitions work.
> 
> In file included from compat/regex/regex.c:78:
> compat/regex/regexec.c:357: error: conflicting types for 're_search_2_stub'
> compat/regex/regexec.c:44: note: previous declaration of 're_search_2_stub' was
> here
Here's a fix.
 compat/regex/regexec.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/compat/regex/regexec.c b/compat/regex/regexec.c
index b49585a..0194965 100644
--- a/compat/regex/regexec.c
+++ b/compat/regex/regexec.c
@@ -40,20 +40,19 @@ static reg_errcode_t re_search_internal (const regex_t *preg,
 					 const char *string, int length,
 					 int start, int range, int stop,
 					 size_t nmatch, regmatch_t pmatch[],
-					 int eflags) internal_function;
+					 int eflags);
 static int re_search_2_stub (struct re_pattern_buffer *bufp,
 			     const char *string1, int length1,
 			     const char *string2, int length2,
 			     int start, int range, struct re_registers *regs,
-			     int stop, int ret_len) internal_function;
+			     int stop, int ret_len);
 static int re_search_stub (struct re_pattern_buffer *bufp,
 			   const char *string, int length, int start,
 			   int range, int stop, struct re_registers *regs,
-			   int ret_len) internal_function;
+			   int ret_len);
 static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
-			      int nregs, int regs_allocated) internal_function;
-static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
-     internal_function;
+			      int nregs, int regs_allocated);
+static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx);
 static int check_matching (re_match_context_t *mctx, int fl_longest_match,
 			   int *p_match_first) internal_function;
 static int check_halt_state_context (const re_match_context_t *mctx,
-- 
1.7.2.2.1305.g4e2a
Previous: Karsten BleesNext: Ævar Arnfjörð Bjarmason
Message 18 of 23 in “What's cooking in git.git (Aug 2010, #04; Wed, 18)”
  1. Junio C HamanoAug 18, 2010
  2. Jonathan NiederAug 19, 2010
  3. Johannes SixtAug 19, 2010
  4. Ævar Arnfjörð BjarmasonAug 19, 2010
  5. Ævar Arnfjörð BjarmasonAug 19, 2010
  6. jn/update-contrib-example-merge in puJonathan Nieder, Aug 19, 2010
  7. Ævar Arnfjörð BjarmasonAug 19, 2010
  8. Ævar Arnfjörð BjarmasonAug 19, 2010
  9. Aharon RobbinsAug 19, 2010
  10. compat/regex: define out variables only used under RE_ENABLE_I18NÆvar Arnfjörð Bjarmason, Aug 19, 2010
  11. Junio C HamanoAug 19, 2010
  12. Ævar Arnfjörð BjarmasonAug 19, 2010
  13. Junio C HamanoAug 19, 2010
  14. Ævar Arnfjörð BjarmasonAug 19, 2010
  15. compat/regex: get rid of old-style definitionJunio C Hamano, Aug 19, 2010
  16. Ævar Arnfjörð BjarmasonAug 20, 2010
  17. Karsten BleesAug 25, 2010
  18. Fix compat/regex ANSIfication on MinGWJohannes Sixt, Aug 26, 2010
  19. Ævar Arnfjörð BjarmasonAug 26, 2010
  20. karsten.blees@dcon.deSep 3, 2010
  21. Ævar Arnfjörð BjarmasonSep 3, 2010
  22. Junio C HamanoSep 4, 2010
  23. Johannes SixtSep 7, 2010

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.