This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH v2] fixes for ENABLE_NLS=0
- From: groleo at gmail dot com
- To: systemtap at sourceware dot org
- Cc: Adrian Marius Negreanu <adrian dot m dot negreanu at intel dot com>
- Date: Fri, 22 Mar 2013 20:13:34 +0200
- Subject: [PATCH v2] fixes for ENABLE_NLS=0
From: Adrian Marius Negreanu <adrian.m.negreanu@intel.com>
v2:
[Josh Stone]: replace _F(_N(a,b,c),...) with _NF(a,b,c,...)
Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu@intel.com>
---
elaborate.cxx | 4 ++--
main.cxx | 5 ++++-
nsscommon.h | 4 +++-
parse.cxx | 6 +++---
session.cxx | 9 +++++----
session.h | 2 ++
staprun/stapio.c | 4 ++--
staprun/staprun.h | 8 ++++++--
tapsets.cxx | 12 ++++++------
translate.cxx | 4 ++--
util.h | 2 ++
11 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/elaborate.cxx b/elaborate.cxx
index 19a3e7f..97b7093 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -143,7 +143,7 @@ probe_point*
derived_probe::sole_location () const
{
if (locations.size() == 0 || locations.size() > 1)
- throw semantic_error (ngettext("derived_probe with no locations",
+ throw semantic_error (_N("derived_probe with no locations",
"derived_probe with no locations",
locations.size()), this->tok);
else
@@ -160,7 +160,7 @@ derived_probe::script_location () const
if (a) return a;
const vector<probe_point*>& locs = p->locations;
if (locs.size() == 0 || locs.size() > 1)
- throw semantic_error (ngettext("derived_probe with no locations",
+ throw semantic_error (_N("derived_probe with no locations",
"derived_probe with too many locations",
locs.size()), this->tok);
else
diff --git a/main.cxx b/main.cxx
index e1e864e..1fb1d70 100644
--- a/main.cxx
+++ b/main.cxx
@@ -26,8 +26,10 @@
#include "tapsets.h"
#include "setupdwfl.h"
+#if ENABLE_NLS
#include <libintl.h>
#include <locale.h>
+#endif
#include "stap-probe.h"
@@ -988,10 +990,11 @@ main (int argc, char * const argv [])
// Initialize defaults.
try {
systemtap_session s;
-
+#if ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+#endif
// Set up our handler to catch routine signals, to allow clean
// and reasonably timely exit.
diff --git a/nsscommon.h b/nsscommon.h
index 483cbea..729ebee 100644
--- a/nsscommon.h
+++ b/nsscommon.h
@@ -14,9 +14,11 @@ extern "C" {
#endif
#include <pk11func.h>
+#include "config.h"
+#if ENABLE_NLS
#include <libintl.h>
#include <locale.h>
-#include "config.h"
+#endif
#if ENABLE_NLS
#define _(string) gettext(string)
diff --git a/parse.cxx b/parse.cxx
index 243055d..43a2aab 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -592,12 +592,12 @@ parser::scan_pp1 ()
if (! (t && t->type == tok_operator && t->content == "("))
{
delete new_act;
- throw parse_error (_F(ngettext
+ throw parse_error (_NF
("expected '(' in invocation of macro '@%s'"
" taking %d parameter",
"expected '(' in invocation of macro '@%s'"
" taking %d parameters",
- num_params), name.c_str(), num_params), t);
+ num_params, name.c_str(), num_params), t);
}
// XXX perhaps parse/count the full number of params,
@@ -1838,7 +1838,7 @@ parser::parse ()
}
else if (num_errors > 0)
{
- cerr << _F(ngettext("%d parse error.", "%d parse errors.", num_errors), num_errors) << endl;
+ cerr << _NF("%d parse error.", "%d parse errors.", num_errors, num_errors) << endl;
delete f;
f = 0;
}
diff --git a/session.cxx b/session.cxx
index 40dde6e..927433a 100644
--- a/session.cxx
+++ b/session.cxx
@@ -1542,8 +1542,9 @@ systemtap_session::parse_kernel_config ()
}
if (verbose > 2)
clog << _F("Parsed kernel \"%s\", ", kernel_config_file.c_str())
- << _F(ngettext("containing %zu tuple", "containing %zu tuples",
- kernel_config.size()), kernel_config.size()) << endl;
+ << _NF("containing %zu tuple", "containing %zu tuples",
+ kernel_config.size(), kernel_config.size()) << endl;
+
kcf.close();
return 0;
@@ -1579,9 +1580,9 @@ systemtap_session::parse_kernel_exports ()
kernel_exports.insert (tokens[1]);
}
if (verbose > 2)
- clog << _F(ngettext("Parsed kernel %s, which contained one vmlinux export",
+ clog << _NF("Parsed kernel %s, which contained one vmlinux export",
"Parsed kernel %s, which contained %zu vmlinux exports",
- kernel_exports.size()), kernel_exports_file.c_str(),
+ kernel_exports.size(), kernel_exports_file.c_str(),
kernel_exports.size()) << endl;
kef.close();
diff --git a/session.h b/session.h
index 5e65beb..019b7b3 100644
--- a/session.h
+++ b/session.h
@@ -10,8 +10,10 @@
#define SESSION_H
#include "config.h"
+#if ENABLE_NLS
#include <libintl.h>
#include <locale.h>
+#endif
#include <list>
#include <string>
diff --git a/staprun/stapio.c b/staprun/stapio.c
index e8daf0e..1dc6119 100644
--- a/staprun/stapio.c
+++ b/staprun/stapio.c
@@ -25,11 +25,11 @@ char *__name__ = "stapio";
int main(int argc, char **argv)
{
-
+#if ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
-
+#endif
setup_signals();
parse_args(argc, argv);
diff --git a/staprun/staprun.h b/staprun/staprun.h
index 39cbcae..0dfe4a1 100644
--- a/staprun/staprun.h
+++ b/staprun/staprun.h
@@ -37,13 +37,17 @@
#include <sys/wait.h>
#include <sys/statfs.h>
#include <syslog.h>
-#include <libintl.h>
-#include <locale.h>
/* Include config.h to pick up dependency for --prefix usage. */
#include "../config.h"
#include "../privilege.h"
+#if ENABLE_NLS
+#include <libintl.h>
+#include <locale.h>
+#endif
+
+
/* define gettext options if NLS is set */
#if ENABLE_NLS
#define _(string) gettext(string)
diff --git a/tapsets.cxx b/tapsets.cxx
index 7bcfa13..b7968a2 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -2327,9 +2327,9 @@ var_expanding_visitor::rewrite_lvalue(const token* tok, const std::string& eop,
ops.resize(ops.size() - 1); // chop off the last ','
// Throw the error.
- throw semantic_error (_F(ngettext("Only the following assign operator is implemented on target variables: %s",
+ throw semantic_error (_NF("Only the following assign operator is implemented on target variables: %s",
"Only the following assign operators are implemented on target variables: %s",
- valid_ops_size), ops.c_str()), tok);
+ valid_ops_size, ops.c_str()), tok);
}
@@ -6873,14 +6873,14 @@ dwarf_builder::build(systemtap_session & sess,
}
}
- sess.print_warning (_F(ngettext("cannot probe .return of %u inlined function %s",
+ sess.print_warning (_NF("cannot probe .return of %u inlined function %s",
"cannot probe .return of %u inlined functions %s",
- quicklist.size()), i_n_r, quicklist.c_str()));
+ quicklist.size(), i_n_r, quicklist.c_str()));
// There will be also a "no matches" semantic error generated.
}
if (sess.verbose > 1)
- clog << _F(ngettext("skipped .return probe of %u inlined function",
- "skipped .return probe of %u inlined functions", i_n_r), i_n_r) << endl;
+ clog << _NF("skipped .return probe of %u inlined function",
+ "skipped .return probe of %u inlined functions", i_n_r, i_n_r) << endl;
if ((sess.verbose > 3) || (sess.verbose > 2 && results_pre == results_post)) // issue details with high verbosity
{
for (set<string>::iterator it = q.inlined_non_returnable.begin();
diff --git a/translate.cxx b/translate.cxx
index 04e1f80..595716c 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4988,8 +4988,8 @@ c_unparser::visit_print_format (print_format* e)
// PR10750: Enforce a reasonable limit on # of varargs
// 32 varargs leads to max 256 bytes on the stack
if (e->args.size() > 32)
- throw semantic_error(_F(ngettext("additional argument to print", "too many arguments to print (%zu)",
- e->args.size()), e->args.size()), e->tok);
+ throw semantic_error(_NF("additional argument to print", "too many arguments to print (%zu)",
+ e->args.size(), e->args.size()), e->tok);
// Compute actual arguments
vector<tmpvar> tmp;
diff --git a/util.h b/util.h
index eb35106..8ffd02f 100644
--- a/util.h
+++ b/util.h
@@ -15,8 +15,10 @@
#include <iomanip>
#include <map>
extern "C" {
+#if ENABLE_NLS
#include <libintl.h>
#include <locale.h>
+#endif
#include <signal.h>
#include <stdint.h>
#include <spawn.h>
--
1.8.0