[PATCH] nls: unify and allow people to fully disable

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

 



Currently, cpufrequtils assumes NLS functions are always available
regardless of the NLS= make setting.  This can be problematic on
systems where NLS is fully disabled in the system -- no headers and
no functions available.  So when people say NLS=false, don't attempt
to include any NLS headers or call any NLS functions.

Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx>
---
 Makefile     |    1 +
 lib/nls.h    |   16 ++++++++++++++++
 utils/info.c |    7 +------
 utils/set.c  |    6 +-----
 4 files changed, 19 insertions(+), 11 deletions(-)
 create mode 100644 lib/nls.h

diff --git a/Makefile b/Makefile
index f44f817..d3ba1b5 100644
--- a/Makefile
+++ b/Makefile
@@ -136,6 +136,7 @@ endif
 ifeq ($(strip $(NLS)),true)
 	INSTALL_NLS += install-gmo
 	COMPILE_NLS += update-gmo
+	CPPFLAGS += -DNLS
 endif
 
 ifeq ($(strip $(CPUFRQ_BENCH)),true)
diff --git a/lib/nls.h b/lib/nls.h
new file mode 100644
index 0000000..d4d0bef
--- /dev/null
+++ b/lib/nls.h
@@ -0,0 +1,16 @@
+/*
+ * Simple NLS helpers
+ *
+ *  Licensed under the terms of the GNU GPL License version 2.
+ */
+
+#ifdef NLS
+#include <libintl.h>
+#define _(String) gettext(String)
+#else
+#define _(String) gettext_noop(String)
+#define gettext(String) gettext_noop(String)
+#define textdomain(String)
+#endif
+#define gettext_noop(String) String
+#define N_(String) gettext_noop(String)
diff --git a/utils/info.c b/utils/info.c
index 38d906a..d77edfa 100644
--- a/utils/info.c
+++ b/utils/info.c
@@ -10,17 +10,12 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
-#include <libintl.h>
 #include <locale.h>
 
 #include <getopt.h>
 
 #include "cpufreq.h"
-
-
-#define _(String) gettext (String)
-#define gettext_noop(String) String
-#define N_(String) gettext_noop (String)
+#include "nls.h"
 
 #define LINE_LEN 10
 
diff --git a/utils/set.c b/utils/set.c
index 2ece47e..b44f372 100644
--- a/utils/set.c
+++ b/utils/set.c
@@ -12,16 +12,12 @@
 #include <limits.h>
 #include <string.h>
 #include <ctype.h>
-#include <libintl.h>
 #include <locale.h>
 
 #include <getopt.h>
 
 #include "cpufreq.h"
-
-#define _(String) gettext(String)
-#define gettext_noop(String) String
-#define N_(String) gettext_noop(String)
+#include "nls.h"
 
 #define NORM_FREQ_LEN 32
 
-- 
1.6.6

--
To unsubscribe from this list: send the line "unsubscribe cpufreq" 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 Devel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Forum]     [Linux SCSI]

  Powered by Linux