Skip to content

Commit 61f2344

Browse files
committed
using QRegularExpression over QRegExp where easy to do so
1 parent 1359622 commit 61f2344

File tree

8 files changed

+33
-29
lines changed

8 files changed

+33
-29
lines changed

plugins/Assembler/DialogAssembler.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2929
#include <QLineEdit>
3030
#include <QMessageBox>
3131
#include <QProcess>
32-
#include <QRegExp>
32+
#include <QRegularExpression>
3333
#include <QSettings>
3434
#include <QTemporaryFile>
3535
#include <QTextDocument>
@@ -104,12 +104,14 @@ QString fixup_syntax(QString insn) {
104104
"tbyte",
105105
"xmmword",
106106
"ymmword",
107-
"zmmword"};
107+
"zmmword",
108+
};
108109

109110
for (const QString &size : sizes) {
110111
const QString replacement = opSizes.attribute(size);
111112
if (!replacement.isEmpty()) {
112-
insn.replace(QRegExp("\\b" + size + "\\b"), replacement);
113+
const QRegularExpression re("\\b" + size + "\\b");
114+
insn.replace(re, replacement);
113115
}
114116
}
115117

plugins/ODbgRegisterView/DialogEditSimdRegister.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3131
#include <QLineEdit>
3232
#include <QRadioButton>
3333
#include <QRegExp>
34-
#include <QRegExpValidator>
34+
#include <QRegularExpression>
35+
#include <QRegularExpressionValidator>
3536
#include <cstring>
3637
#include <limits>
3738
#include <type_traits>
@@ -56,10 +57,10 @@ void DialogEditSimdRegister::setupEntries(const QString &label, std::array<Numbe
5657

5758
DialogEditSimdRegister::DialogEditSimdRegister(QWidget *parent, Qt::WindowFlags f)
5859
: QDialog(parent, f),
59-
byteHexValidator_(new QRegExpValidator(QRegExp("[0-9a-fA-F]{0,2}"), this)),
60-
wordHexValidator_(new QRegExpValidator(QRegExp("[0-9a-fA-F]{0,4}"), this)),
61-
dwordHexValidator_(new QRegExpValidator(QRegExp("[0-9a-fA-F]{0,8}"), this)),
62-
qwordHexValidator_(new QRegExpValidator(QRegExp("[0-9a-fA-F]{0,16}"), this)),
60+
byteHexValidator_(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,2}"), this)),
61+
wordHexValidator_(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,4}"), this)),
62+
dwordHexValidator_(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,8}"), this)),
63+
qwordHexValidator_(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{0,16}"), this)),
6364
byteSignedValidator_(new QLongValidator(INT8_MIN, INT8_MAX, this)),
6465
wordSignedValidator_(new QLongValidator(INT16_MIN, INT16_MAX, this)),
6566
dwordSignedValidator_(new QLongValidator(INT32_MIN, INT32_MAX, this)),

plugins/ODbgRegisterView/DialogEditSimdRegister.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class QDialogButtonBox;
3131
class QHBoxLayout;
3232
class QLongValidator;
3333
class QRadioButton;
34-
class QRegExpValidator;
34+
class QRegularExpressionValidator;
3535
class QULongValidator;
3636
class QValidator;
3737

@@ -128,10 +128,10 @@ private Q_SLOTS:
128128
std::array<NumberEdit *, NumBytes> bytes_;
129129
std::array<QLabel *, NumBytes> columnLabels_;
130130

131-
QRegExpValidator *byteHexValidator_;
132-
QRegExpValidator *wordHexValidator_;
133-
QRegExpValidator *dwordHexValidator_;
134-
QRegExpValidator *qwordHexValidator_;
131+
QRegularExpressionValidator *byteHexValidator_;
132+
QRegularExpressionValidator *wordHexValidator_;
133+
QRegularExpressionValidator *dwordHexValidator_;
134+
QRegularExpressionValidator *qwordHexValidator_;
135135

136136
QLongValidator *byteSignedValidator_;
137137
QLongValidator *wordSignedValidator_;

plugins/ODbgRegisterView/GprEdit.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
#include "QULongValidator.h"
2121
#include "util/Font.h"
2222
#include <QApplication>
23-
#include <QRegExpValidator>
23+
#include <QRegularExpressionValidator>
2424
#include <cmath>
2525
#include <cstring>
2626

2727
namespace ODbgRegisterView {
2828
namespace {
2929

30-
const QRegExpValidator byteHexValidator(QRegExp("[0-9a-fA-F]{0,2}"));
31-
const QRegExpValidator wordHexValidator(QRegExp("[0-9a-fA-F]{0,4}"));
32-
const QRegExpValidator dwordHexValidator(QRegExp("[0-9a-fA-F]{0,8}"));
33-
const QRegExpValidator qwordHexValidator(QRegExp("[0-9a-fA-F]{0,16}"));
30+
const QRegularExpressionValidator byteHexValidator(QRegularExpression("[0-9a-fA-F]{0,2}"));
31+
const QRegularExpressionValidator wordHexValidator(QRegularExpression("[0-9a-fA-F]{0,4}"));
32+
const QRegularExpressionValidator dwordHexValidator(QRegularExpression("[0-9a-fA-F]{0,8}"));
33+
const QRegularExpressionValidator qwordHexValidator(QRegularExpression("[0-9a-fA-F]{0,16}"));
3434
const QLongValidator byteSignedValidator(INT8_MIN, INT8_MAX);
3535
const QLongValidator wordSignedValidator(INT16_MIN, INT16_MAX);
3636
const QLongValidator dwordSignedValidator(INT32_MIN, INT32_MAX);
@@ -40,7 +40,7 @@ const QULongValidator wordUnsignedValidator(0, UINT16_MAX);
4040
const QULongValidator dwordUnsignedValidator(0, UINT32_MAX);
4141
const QULongValidator qwordUnsignedValidator(0, UINT64_MAX);
4242

43-
const std::map<int, const QRegExpValidator *> hexValidators = {
43+
const std::map<int, const QRegularExpressionValidator *> hexValidators = {
4444
{1, &byteHexValidator},
4545
{2, &wordHexValidator},
4646
{4, &dwordHexValidator},

plugins/ODbgRegisterView/arch/x86-generic/DialogEditFPU.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2525
#include <QGridLayout>
2626
#include <QLabel>
2727
#include <QLineEdit>
28-
#include <QRegExp>
28+
#include <QRegularExpression>
29+
#include <QRegularExpressionValidator>
2930
#include <QVBoxLayout>
3031
#include <array>
3132
#include <cmath>
@@ -95,7 +96,7 @@ DialogEditFPU::DialogEditFPU(QWidget *parent, Qt::WindowFlags f)
9596
connect(floatEntry_, &Float80Edit::textEdited, this, &DialogEditFPU::onFloatEdited);
9697
connect(hexEntry_, &QLineEdit::textEdited, this, &DialogEditFPU::onHexEdited);
9798

98-
hexEntry_->setValidator(new QRegExpValidator(QRegExp("[0-9a-fA-F ]{,20}"), this));
99+
hexEntry_->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F ]{,20}"), this));
99100
connect(floatEntry_, &Float80Edit::defocussed, this, &DialogEditFPU::updateFloatEntry);
100101

101102
hexEntry_->installEventFilter(this);

src/DialogInputValue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2323
#include "edb.h"
2424

2525
#include <QDebug>
26-
#include <QRegExpValidator>
26+
#include <QRegularExpressionValidator>
2727

2828
#include <limits>
2929

@@ -37,7 +37,7 @@ DialogInputValue::DialogInputValue(QWidget *parent, Qt::WindowFlags f)
3737
ui.setupUi(this);
3838

3939
// Apply some defaults
40-
ui.hexInput->setValidator(new QRegExpValidator(QRegExp("[A-Fa-f0-9]{0,16}"), this));
40+
ui.hexInput->setValidator(new QRegularExpressionValidator(QRegularExpression("[A-Fa-f0-9]{0,16}"), this));
4141
ui.signedInput->setValidator(new QLongValidator(std::numeric_limits<long long>::min(), std::numeric_limits<long long>::max(), this));
4242
ui.unsignedInput->setValidator(new QULongValidator(0, std::numeric_limits<unsigned long long>::max(), this));
4343
}
@@ -72,7 +72,7 @@ void DialogInputValue::setValue(Register &reg) {
7272
mask_ = unsignedMax;
7373
valueLength_ = reg.bitSize() / 8;
7474

75-
ui.hexInput->setValidator(new QRegExpValidator(QRegExp(regex), this));
75+
ui.hexInput->setValidator(new QRegularExpressionValidator(QRegularExpression(regex), this));
7676
ui.signedInput->setValidator(new QLongValidator(signedMin, signedMax, this));
7777
ui.unsignedInput->setValidator(new QULongValidator(0, unsignedMax, this));
7878
}

src/FloatX.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ QValidator::State FloatXValidator<Float>::validate(QString &input, int &) const
379379
}
380380

381381
// OK, so we failed to read it or it is unfinished. Let's check whether it's intermediate or invalid.
382-
QRegExp basicFormat("[+-]?[0-9]*\\.?[0-9]*(e([+-]?[0-9]*)?)?");
383-
QRegExp specialFormat("[+-]?[sq]?nan|[+-]?inf", Qt::CaseInsensitive);
384-
QRegExp hexfloatFormat("[+-]?0x[0-9a-f]*\\.?[0-9a-f]*(p([+-]?[0-9]*)?)?", Qt::CaseInsensitive);
385-
QRegExp specialFormatUnfinished("[+-]?[sq]?(n(an?)?)?|[+-]?(i(nf?)?)?", Qt::CaseInsensitive);
382+
static const QRegExp basicFormat("[+-]?[0-9]*\\.?[0-9]*(e([+-]?[0-9]*)?)?");
383+
static const QRegExp specialFormat("[+-]?[sq]?nan|[+-]?inf", Qt::CaseInsensitive);
384+
static const QRegExp hexfloatFormat("[+-]?0x[0-9a-f]*\\.?[0-9a-f]*(p([+-]?[0-9]*)?)?", Qt::CaseInsensitive);
385+
static const QRegExp specialFormatUnfinished("[+-]?[sq]?(n(an?)?)?|[+-]?(i(nf?)?)?", Qt::CaseInsensitive);
386386

387387
if (hexfloatFormat.exactMatch(input)) {
388388
return QValidator::Intermediate;

src/widgets/QDisassemblyView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ QString QDisassemblyView::instructionString(const edb::Instruction &inst) const
576576

577577
const bool showSymbolicAddresses = edb::v1::config().show_symbolic_addresses;
578578

579-
static const QRegExp addrPattern(QLatin1String("#?0x[0-9a-fA-F]+"));
579+
static const QRegularExpression addrPattern(QLatin1String("#?0x[0-9a-fA-F]+"));
580580
const edb::address_t target = oper->imm;
581581

582582
const bool showLocalModuleNames = edb::v1::config().show_local_module_name_in_jump_targets;

0 commit comments

Comments
 (0)