From b32fd4cef20329ffa49fe11b252a2f304dda7a72 Mon Sep 17 00:00:00 2001 From: ballessay Date: Thu, 13 Apr 2017 00:12:01 +0200 Subject: [PATCH] Remove banned.h from widgets The banned string is only used once so define it there. --- src/iaito.pro | 1 - src/widgets/banned.h | 27 --------------------------- src/widgets/importswidget.cpp | 18 +++++++++++++++--- 3 files changed, 15 insertions(+), 31 deletions(-) delete mode 100644 src/widgets/banned.h diff --git a/src/iaito.pro b/src/iaito.pro index 2f73802f..14e8f81d 100644 --- a/src/iaito.pro +++ b/src/iaito.pro @@ -96,7 +96,6 @@ HEADERS += \ widgets/omnibar.h \ widgets/dashboard.h \ dialogs/xrefsdialog.h \ - widgets/banned.h \ hexhighlighter.h \ widgets/sectionsdock.h diff --git a/src/widgets/banned.h b/src/widgets/banned.h deleted file mode 100644 index 61a132a3..00000000 --- a/src/widgets/banned.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef BANNED_H -#define BANNED_H - -#include - -class Banned : public QObject -{ - Q_OBJECT -public: - - QString banned = "[a-zA-Z_.]*(system|strcpy|strcpyA|strcpyW|wcscpy|_tcscpy|_mbscpy|StrCpy|StrCpyA|StrCpyW|lstrcpy|lstrcpyA|lstrcpyW" \ - "|_tccpy|_mbccpy|_ftcscpy|strcat|strcatA|strcatW|wcscat|_tcscat|_mbscat|StrCat|StrCatA|StrCatW|lstrcat|lstrcatA|" \ - "lstrcatW|StrCatBuff|StrCatBuffA|StrCatBuffW|StrCatChainW|_tccat|_mbccat|_ftcscat|sprintfW|sprintfA|wsprintf|wsprintfW|" \ - "wsprintfA|sprintf|swprintf|_stprintf|wvsprintf|wvsprintfA|wvsprintfW|vsprintf|_vstprintf|vswprintf|strncpy|wcsncpy|" \ - "_tcsncpy|_mbsncpy|_mbsnbcpy|StrCpyN|StrCpyNA|StrCpyNW|StrNCpy|strcpynA|StrNCpyA|StrNCpyW|lstrcpyn|lstrcpynA|lstrcpynW|" \ - "strncat|wcsncat|_tcsncat|_mbsncat|_mbsnbcat|StrCatN|StrCatNA|StrCatNW|StrNCat|StrNCatA|StrNCatW|lstrncat|lstrcatnA|" \ - "lstrcatnW|lstrcatn|gets|_getts|_gettws|IsBadWritePtr|IsBadHugeWritePtr|IsBadReadPtr|IsBadHugeReadPtr|IsBadCodePtr|" \ - "IsBadStringPtr|memcpy|RtlCopyMemory|CopyMemory|wmemcpy|wnsprintf|wnsprintfA|wnsprintfW|_snwprintf|_snprintf|_sntprintf|" \ - "_vsnprintf|vsnprintf|_vsnwprintf|_vsntprintf|wvnsprintf|wvnsprintfA|wvnsprintfW|strtok|_tcstok|wcstok|_mbstok|makepath|" \ - "_tmakepath| _makepath|_wmakepath|_splitpath|_tsplitpath|_wsplitpath|scanf|wscanf|_tscanf|sscanf|swscanf|_stscanf|snscanf|" \ - "snwscanf|_sntscanf|_itoa|_itow|_i64toa|_i64tow|_ui64toa|_ui64tot|_ui64tow|_ultoa|_ultot|_ultow|CharToOem|CharToOemA|CharToOemW|" \ - "OemToChar|OemToCharA|OemToCharW|CharToOemBuffA|CharToOemBuffW|alloca|_alloca|strlen|wcslen|_mbslen|_mbstrlen|StrLen|lstrlen|" \ - "ChangeWindowMessageFilter)"; - -}; - -#endif // BANNED_H diff --git a/src/widgets/importswidget.cpp b/src/widgets/importswidget.cpp index 785547fd..72a2b1c2 100644 --- a/src/widgets/importswidget.cpp +++ b/src/widgets/importswidget.cpp @@ -2,7 +2,6 @@ #include "ui_importswidget.h" #include -#include "widgets/banned.h" #include "mainwindow.h" void CMyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const @@ -59,8 +58,21 @@ void ImportsWidget::fillImports() void ImportsWidget::highlightUnsafe() { - Banned *ban = new Banned(); - QList clist = this->importsTreeWidget->findItems(ban->banned, Qt::MatchRegExp, 4); + static const QString banned("[a-zA-Z_.]*(system|strcpy|strcpyA|strcpyW|wcscpy|_tcscpy|_mbscpy|StrCpy|StrCpyA|StrCpyW|lstrcpy|lstrcpyA|lstrcpyW" \ + "|_tccpy|_mbccpy|_ftcscpy|strcat|strcatA|strcatW|wcscat|_tcscat|_mbscat|StrCat|StrCatA|StrCatW|lstrcat|lstrcatA|" \ + "lstrcatW|StrCatBuff|StrCatBuffA|StrCatBuffW|StrCatChainW|_tccat|_mbccat|_ftcscat|sprintfW|sprintfA|wsprintf|wsprintfW|" \ + "wsprintfA|sprintf|swprintf|_stprintf|wvsprintf|wvsprintfA|wvsprintfW|vsprintf|_vstprintf|vswprintf|strncpy|wcsncpy|" \ + "_tcsncpy|_mbsncpy|_mbsnbcpy|StrCpyN|StrCpyNA|StrCpyNW|StrNCpy|strcpynA|StrNCpyA|StrNCpyW|lstrcpyn|lstrcpynA|lstrcpynW|" \ + "strncat|wcsncat|_tcsncat|_mbsncat|_mbsnbcat|StrCatN|StrCatNA|StrCatNW|StrNCat|StrNCatA|StrNCatW|lstrncat|lstrcatnA|" \ + "lstrcatnW|lstrcatn|gets|_getts|_gettws|IsBadWritePtr|IsBadHugeWritePtr|IsBadReadPtr|IsBadHugeReadPtr|IsBadCodePtr|" \ + "IsBadStringPtr|memcpy|RtlCopyMemory|CopyMemory|wmemcpy|wnsprintf|wnsprintfA|wnsprintfW|_snwprintf|_snprintf|_sntprintf|" \ + "_vsnprintf|vsnprintf|_vsnwprintf|_vsntprintf|wvnsprintf|wvnsprintfA|wvnsprintfW|strtok|_tcstok|wcstok|_mbstok|makepath|" \ + "_tmakepath| _makepath|_wmakepath|_splitpath|_tsplitpath|_wsplitpath|scanf|wscanf|_tscanf|sscanf|swscanf|_stscanf|snscanf|" \ + "snwscanf|_sntscanf|_itoa|_itow|_i64toa|_i64tow|_ui64toa|_ui64tot|_ui64tow|_ultoa|_ultot|_ultow|CharToOem|CharToOemA|CharToOemW|" \ + "OemToChar|OemToCharA|OemToCharW|CharToOemBuffA|CharToOemBuffW|alloca|_alloca|strlen|wcslen|_mbslen|_mbstrlen|StrLen|lstrlen|" \ + "ChangeWindowMessageFilter)"); + + QList clist = this->importsTreeWidget->findItems(banned, Qt::MatchRegExp, 4); foreach (QTreeWidgetItem *item, clist) { item->setText(3, "Unsafe");