summaryrefslogtreecommitdiffstats
path: root/translate.cxx
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-04-20 12:56:51 +0200
committerTim Moore <timoore@redhat.com>2009-04-20 19:01:06 +0200
commit764b562f42c6ac7f02e0911cab47f87c827bf3bd (patch)
tree45cb4a80e108aeef69cfaeb1c4a34c030d63380a /translate.cxx
parent9a6d143c6e2c79cee1082d0455da92cfa78b03c7 (diff)
downloadsystemtap-steved-764b562f42c6ac7f02e0911cab47f87c827bf3bd.tar.gz
systemtap-steved-764b562f42c6ac7f02e0911cab47f87c827bf3bd.tar.xz
systemtap-steved-764b562f42c6ac7f02e0911cab47f87c827bf3bd.zip
fix a bug with %% in format strings
* translate.cxx (c_unparser::visit_print_format): Always use _stp_printf if a format string contains "%%". Previously a format string with no arguments would always be printed with _stp_print. * testsuite/systemtap.printf/basic6.stp: New test for %% in format strings. * testsuite/systemtap.printf/basic6.exp: test driver * testsuite/systemtap.examples/grapher.stp: Remove workaround for "%%" literal problem.
Diffstat (limited to 'translate.cxx')
-rw-r--r--translate.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/translate.cxx b/translate.cxx
index 46fea6e7..f7868ceb 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4172,7 +4172,8 @@ c_unparser::visit_print_format (print_format* e)
int use_print = 0;
string format_string = print_format::components_to_string(components);
- if (tmp.size() == 0 || (tmp.size() == 1 && format_string == "%s"))
+ if ((tmp.size() == 0 && format_string.find("%%") == std::string::npos)
+ || (tmp.size() == 1 && format_string == "%s"))
use_print = 1;
else if (tmp.size() == 1
&& e->args[0]->tok->type == tok_string