summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorfche <fche>2007-08-08 03:36:25 +0000
committerfche <fche>2007-08-08 03:36:25 +0000
commit3f99432cc11977a4345c881bed3aa60a1a614238 (patch)
tree70dc99d601a65cec051658402531ba39fa2b2dad /util.h
parent98be953834c60aaa2ae7504890f1cf11815e558a (diff)
downloadsystemtap-steved-3f99432cc11977a4345c881bed3aa60a1a614238.tar.gz
systemtap-steved-3f99432cc11977a4345c881bed3aa60a1a614238.tar.xz
systemtap-steved-3f99432cc11977a4345c881bed3aa60a1a614238.zip
2007-08-07 Frank Ch. Eigler <fche@redhat.com>
PR 4846 * parse.cxx (input_put): New function, sort of like stdio ungetc. (input_get): Skip cursor position changing for input_put strings. (scan): Rework $.../@... substitution into character pasting. * parse.h: Corresponding changes. * util.h (lex_cast_qstring): Octal-quote unprintable characters. * stap.1.in, NEWS: Document new behaviour. 2007-08-07 Frank Ch. Eigler <fche@redhat.com> PR 4846 * parseko/preprocess13.stp, parseok/nineteen.stp, semok/twentyfive.stp: New tests.
Diffstat (limited to 'util.h')
-rw-r--r--util.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/util.h b/util.h
index a076a1a3..f9c298ec 100644
--- a/util.h
+++ b/util.h
@@ -3,7 +3,7 @@
#include <iostream>
#include <sstream>
#include <stdexcept>
-
+#include <cctype>
const char *get_home_directory(void);
int copy_file(const char *src, const char *dest);
@@ -65,9 +65,22 @@ lex_cast_qstring(IN const & in)
out2 += '"';
for (unsigned i=0; i<out.length(); i++)
{
- if (out[i] == '"' || out[i] == '\\') // XXX others?
- out2 += '\\';
- out2 += out[i];
+ char c = out[i];
+ if (! isprint(c))
+ {
+ out2 += '\\';
+ // quick & dirty octal converter
+ out2 += "01234567" [(c >> 6) & 0x07];
+ out2 += "01234567" [(c >> 3) & 0x07];
+ out2 += "01234567" [(c >> 0) & 0x07];
+ }
+ else if (c == '"' || c == '\\')
+ {
+ out2 += '\\';
+ out2 += c;
+ }
+ else
+ out2 += c;
}
out2 += '"';
return out2;