[PATCH 3/3] tests: let GETTEXT_POISON be disabled at run time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Do not poison translations unless the GIT_GETTEXT_POISON environment
variable is set.  This way, a copy of git with GETTEXT_POISON set is
still generally usable and testers can avoid building two copies of
git to compare behavior with and without poison.

Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
Thanks again for your help.  Hopefully that turned out okay.  Please
feel free to ack or complain to indicate either way.

 Makefile      |    1 +
 gettext.c     |   14 ++++++++++++++
 gettext.h     |    2 +-
 t/test-lib.sh |    8 +++++++-
 4 files changed, 23 insertions(+), 2 deletions(-)
 create mode 100644 gettext.c

diff --git a/Makefile b/Makefile
index c348bb7..142ed86 100644
--- a/Makefile
+++ b/Makefile
@@ -1374,6 +1374,7 @@ ifdef NO_SYMLINK_HEAD
 	BASIC_CFLAGS += -DNO_SYMLINK_HEAD
 endif
 ifdef GETTEXT_POISON
+	LIB_OBJS += gettext.o
 	BASIC_CFLAGS += -DGETTEXT_POISON
 endif
 ifdef NO_STRCASESTR
diff --git a/gettext.c b/gettext.c
new file mode 100644
index 0000000..9688c8b
--- /dev/null
+++ b/gettext.c
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2010 Ãvar ArnfjÃrà Bjarmason
+ */
+
+#include "git-compat-util.h"
+#include "gettext.h"
+
+int use_poison(void)
+{
+	static int poison_requested = -1;
+	if (poison_requested == -1)
+		poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
+	return poison_requested;
+}
diff --git a/gettext.h b/gettext.h
index 6daa57c..051bf11 100644
--- a/gettext.h
+++ b/gettext.h
@@ -16,7 +16,7 @@
 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
 
 #ifdef GETTEXT_POISON
-#define use_poison() 1
+extern int use_poison(void);
 #else
 #define use_poison() 0
 #endif
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0840e4a..f4c1e04 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1080,7 +1080,13 @@ test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
 # Can we rely on git's output in the C locale?
-test -z "$GETTEXT_POISON" && test_set_prereq C_LOCALE_OUTPUT
+if test -n "$GETTEXT_POISON"
+then
+	GIT_GETTEXT_POISON=YesPlease
+	export GIT_GETTEXT_POISON
+else
+	test_set_prereq C_LOCALE_OUTPUT
+fi
 
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]