aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2019-01-08 10:48:07 +0100
committerGerald Combs <gerald@wireshark.org>2019-01-08 16:21:41 +0000
commit546cb252568f712525a7e892bffd6d05c40ff028 (patch)
tree4eac3ee6a91916657cd38d21ef47851a4ed3bf19
parentea001cd6c16b21a993fe7358cef65715dc015e90 (diff)
Qt: Fix copy ASCII characters from ByteView
Only copy ASCII characters when doing "Copy Bytes as Hex + ASCII Dump" from the ByteView. This is what we do in all other Hex Dumps. Also change the parameter name to reflect this. Change-Id: I63cc79ffa014fd9aa50c84d765ee168f0b1ea44a Reviewed-on: https://code.wireshark.org/review/31442 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--ui/qt/utils/data_printer.cpp13
-rw-r--r--ui/qt/utils/data_printer.h2
2 files changed, 8 insertions, 7 deletions
diff --git a/ui/qt/utils/data_printer.cpp b/ui/qt/utils/data_printer.cpp
index a0a233a40c..260721ecad 100644
--- a/ui/qt/utils/data_printer.cpp
+++ b/ui/qt/utils/data_printer.cpp
@@ -114,7 +114,7 @@ int DataPrinter::hexChars()
return (row_width * chars_per_byte) + ((row_width - 1) / separatorInterval());
}
-QString DataPrinter::hexTextDump(const QByteArray printData, bool showText)
+QString DataPrinter::hexTextDump(const QByteArray printData, bool showASCII)
{
QString clipboard_text;
@@ -125,12 +125,13 @@ QString DataPrinter::hexTextDump(const QByteArray printData, bool showText)
while ( cnt < printData.length() )
{
byteStr += QString(" %1").arg((uint8_t) printData[cnt], 2, 16, QChar('0'));
- if ( showText )
+ if ( showASCII )
{
QChar ch(printData[cnt]);
- if (!ch.isPrint())
- ch = '.';
- dataStr += ch;
+ if (g_ascii_isprint(printData[cnt]))
+ dataStr += printData[cnt];
+ else
+ dataStr += '.';
}
cnt++;
}
@@ -146,7 +147,7 @@ QString DataPrinter::hexTextDump(const QByteArray printData, bool showText)
clipboard_text += QString("%1 ").arg(offset, 4, 16, QChar('0'));
clipboard_text += byteStr.mid(offset * 3, byteLineLength_ * 3);
- if ( showText )
+ if ( showASCII )
{
/* separation bytes for byte and text */
clipboard_text += QString(3, ' ');
diff --git a/ui/qt/utils/data_printer.h b/ui/qt/utils/data_printer.h
index ce43477486..b5a5720f5f 100644
--- a/ui/qt/utils/data_printer.h
+++ b/ui/qt/utils/data_printer.h
@@ -51,7 +51,7 @@ protected slots:
void copyIDataBytes(bool);
private:
- QString hexTextDump(const QByteArray printData, bool append_text);
+ QString hexTextDump(const QByteArray printData, bool showASCII);
void binaryDump(const QByteArray printData);
int byteLineLength_;