Subject: [PATCH 6/8] gettext: use an enum for the mode of GETTEXT POISONing

From: SZEDER Gábor <[email-masked]>
Date: Mon, 22 Oct 2018 22:22:39 +0200

The next patch will add a different mode of GETTEXT POISON-ing,
therefore named constants will be better than magic numbers.

Signed-off-by: SZEDER Gábor <[email-masked]>
---
 gettext.c | 12 ++++++------
 gettext.h | 12 +++++++++---
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gettext.c b/gettext.c
index a9509a5df3..c50d1e0377 100644
--- a/gettext.c
+++ b/gettext.c
@@ -47,17 +47,17 @@ const char *get_preferred_languages(void)
 }
 
 #ifdef GETTEXT_POISON
-int use_gettext_poison(void)
+enum poison_mode use_gettext_poison(void)
 {
-	static int poison_requested = -1;
-	if (poison_requested == -1) {
+	static enum poison_mode poison_mode = poison_mode_uninitialized;
+	if (poison_mode == poison_mode_uninitialized) {
 		const char *v = getenv("GIT_GETTEXT_POISON");
 		if (v && *v)
-			poison_requested = 1;
+			poison_mode = poison_mode_default;
 		else
-			poison_requested = 0;
+			poison_mode = poison_mode_none;
 	}
-	return poison_requested;
+	return poison_mode;
 }
 #endif
 
diff --git a/gettext.h b/gettext.h
index 8e279622f6..fcb6bfaa2c 100644
--- a/gettext.h
+++ b/gettext.h
@@ -42,7 +42,13 @@ static inline int gettext_width(const char *s)
 #endif
 
 #ifdef GETTEXT_POISON
-extern int use_gettext_poison(void);
+enum poison_mode {
+	poison_mode_uninitialized = -1,
+	poison_mode_none = 0,
+	poison_mode_default
+};
+
+extern enum poison_mode use_gettext_poison(void);
 
 #define GETTEXT_POISON_MAGIC "# GETTEXT POISON #"
 #endif
@@ -52,7 +58,7 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 	if (!*msgid)
 		return "";
 #ifdef GETTEXT_POISON
-	if (use_gettext_poison())
+	if (use_gettext_poison() == poison_mode_default)
 		return GETTEXT_POISON_MAGIC;
 #endif
 	return gettext(msgid);
@@ -62,7 +68,7 @@ static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
 const char *Q_(const char *msgid, const char *plu, unsigned long n)
 {
 #ifdef GETTEXT_POISON
-	if (use_gettext_poison())
+	if (use_gettext_poison() == poison_mode_default)
 		return GETTEXT_POISON_MAGIC;
 #endif
 	return ngettext(msgid, plu, n);
-- 
2.19.1.681.g6bd79da3f5