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

[PATCH/RFC 2/3] compat/regex: hacks to get the gawk regex engine to compile within git

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 17, 2010, 03:25 UTC
Message-ID
<1282015548-19074-3-git-send-email-avarab@gmail.com>
In-Reply-To
<AANLkTik4FL56EM4HdpfZ7ha8GNkbLsJeb415WFWUh+O_@mail.gmail.com>

The gawk regex engine didn't include stdio.h, and only include stddef.h if HAVE_STDDEF_H is set.

Adding -DHAVE_STDDEF_H caused some internal errors in by /usr/include headers, so change the regex.h code to include it unconditionally.

We also need to define -DGAWK so that e.g. "bool", "MAX" and other similar things used inside gawk get defined.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Makefile             |    4 ++++
 compat/regex/regex.h |    7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index b4745a5..6704780 100644
--- a/Makefile
+++ b/Makefile
@@ -1443,6 +1443,10 @@ ifdef UNRELIABLE_FSTAT
 	BASIC_CFLAGS += -DUNRELIABLE_FSTAT
 endif
 ifdef NO_REGEX
+	# TODO: How do I compile just regex.o with this flag, not the
+	# whole of Git?
+	BASIC_CFLAGS += -DGAWK
+
 	COMPAT_CFLAGS += -Icompat/regex
 	COMPAT_OBJS += compat/regex/regex.o
 endif
diff --git a/compat/regex/regex.h b/compat/regex/regex.h
index de93327..508bc80 100644
--- a/compat/regex/regex.h
+++ b/compat/regex/regex.h
@@ -22,9 +22,12 @@
 #ifndef _REGEX_H
 #define _REGEX_H 1
 
-#ifdef HAVE_STDDEF_H
+#include <stdio.h>
+/*
+  Git: Was in `#ifdef HAVE_STDDEF_H` in gawk, adding -DHAVE_STDDEF_H makes a
+  *lot* of other things break
+*/
 #include <stddef.h>
-#endif
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
-- 
1.7.2.1.389.gc3d0b
Previous: Ævar Arnfjörð BjarmasonNext: Jonathan Nieder
Message 18 of 36 in “grep: Don't pass a TODO test if REG_STARTEND is supported”
  1. grep: Don't pass a TODO test if REG_STARTEND is supportedÆvar Arnfjörð Bjarmason, Jul 8, 2010
  2. Junio C HamanoJul 8, 2010
  3. Ævar Arnfjörð BjarmasonJul 8, 2010
  4. René ScharfeJul 8, 2010
  5. Ævar Arnfjörð BjarmasonJul 15, 2010
  6. Junio C HamanoJul 15, 2010
  7. Ævar Arnfjörð BjarmasonJul 15, 2010
  8. Ævar Arnfjörð BjarmasonJul 16, 2010
  9. Jonathan NiederJul 16, 2010
  10. Ævar Arnfjörð BjarmasonJul 16, 2010
  11. Jonathan NiederJul 16, 2010
  12. Ævar Arnfjörð BjarmasonJul 16, 2010
  13. Ævar Arnfjörð BjarmasonJul 16, 2010
  14. Andreas SchwabJul 16, 2010
  15. Ævar Arnfjörð BjarmasonAug 15, 2010
  16. Paolo BonziniAug 16, 2010
  17. 0/3 Update compat/regexÆvar Arnfjörð Bjarmason, Aug 17, 2010
  18. 2/3 compat/regex: hacks to get the gawk regex engine to compile within gitÆvar Arnfjörð Bjarmason, Aug 17, 2010
  19. Jonathan NiederAug 17, 2010
  20. 3/3 t/t7008-grep-binary.sh: un-TODO a test that needs REG_STARTENDÆvar Arnfjörð Bjarmason, Aug 17, 2010
  21. 0/3 Update compat/regexÆvar Arnfjörð Bjarmason, Aug 17, 2010
  22. Jonathan NiederAug 17, 2010
  23. 0/5 Update compat/regexÆvar Arnfjörð Bjarmason, Aug 17, 2010
  24. Paolo BonziniAug 17, 2010
  25. Junio C HamanoAug 17, 2010
  26. Jonathan NiederAug 17, 2010
  27. Ævar Arnfjörð BjarmasonAug 18, 2010
  28. 2/5 compat/regex: get the gawk regex engine to compile within gitÆvar Arnfjörð Bjarmason, Aug 17, 2010
  29. 3/5 Change regerror() declaration from K&R style to ANSI C (C89)Ævar Arnfjörð Bjarmason, Aug 17, 2010
  30. 4/5 t/t7008-grep-binary.sh: un-TODO a test that needs REG_STARTENDÆvar Arnfjörð Bjarmason, Aug 17, 2010
  31. 5/5 autoconf: don't use platform regex if it lacks REG_STARTENDÆvar Arnfjörð Bjarmason, Aug 17, 2010
  32. 2/3 compat/regex: get the gawk regex engine to compile within gitÆvar Arnfjörð Bjarmason, Aug 17, 2010
  33. 3/3 t/t7008-grep-binary.sh: un-TODO a test that needs REG_STARTENDÆvar Arnfjörð Bjarmason, Aug 17, 2010
  34. Jonathan NiederAug 17, 2010
  35. Ævar Arnfjörð BjarmasonAug 17, 2010
  36. Jonathan NiederAug 17, 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.