From 5ddc5963ce06ecea574e90ca503a3ee598522d8f Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Fri, 4 Dec 2009 13:08:01 +0100 Subject: support multiline data output from scripts run under the grapher This is accompanied by support for multiline output in hover text. * grapher/StapParser.cxx (ioCallback): Read data 'til the end of line character, not just '\n'. Be careful to use I/O functions that don't treat '\n' specially. * grapher/StapParser.hxx: ditto * grapher/CairoWidget.cxx (CairoTextBox::draw): Perform line breaks for hover text. * testsuite/systemtap.examples/general/grapher.stp: Do multiline output of keyboard events. Also, fix longstanding breaking in the pty probe. --- grapher/StapParser.cxx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'grapher/StapParser.cxx') diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index 6218e229..2a246475 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -76,14 +77,14 @@ vector commaSplit(const boost::sub_range& range) _win->hide(); return true; } - buf[bytes_read] = '\0'; - _buffer += buf; + _buffer.append(buf, bytes_read); string::size_type ret = string::npos; - while ((ret = _buffer.find('\n')) != string::npos) + while ((ret = _buffer.find(_lineEndChar)) != string::npos) { Glib::ustring dataString(_buffer, 0, ret); - // %DataSet and %CSV declare a data set; all other statements begin with - // the name of a data set. + // %DataSet and %CSV declare a data set; all other + // statements begin with the name of a data set. + // Except %LineEnd :) sub_range found; if (dataString[0] == '%') { @@ -142,6 +143,15 @@ vector commaSplit(const boost::sub_range& range) setIter->second)); } } + else if ((found = find_first(dataString, "%LineEnd:"))) + { + istringstream stream(Glib::ustring(found.end(), + dataString.end())); + int charAsInt = 0; + // parse hex and octal numbers too + stream >> std::setbase(0) >> charAsInt; + _lineEndChar = static_cast(charAsInt); + } else { cerr << "Unknown declaration " << dataString << endl; @@ -199,9 +209,10 @@ vector commaSplit(const boost::sub_range& range) else { int64_t time; - string data; - stream >> time >> data; - parseData(itr->second, time, data); + stringbuf data; + stream >> time; + stream.get(data, _lineEndChar); + parseData(itr->second, time, data.str()); } } } -- cgit