Replaced strcpy with a safe function.

This commit is contained in:
Leonardo Zide
2025-12-07 16:48:07 -08:00
parent 6b7f9faad1
commit 2da8a27095
14 changed files with 74 additions and 49 deletions
+2 -3
View File
@@ -4,8 +4,7 @@
#include "lc_library.h"
#include "lc_model.h"
#include "pieceinf.h"
#include "lc_partselectionwidget.h"
#include "lc_mainwindow.h"
#include "lc_string.h"
#ifdef Q_OS_WIN
#include <windows.h>
@@ -238,7 +237,7 @@ std::vector<bool> lcPieceIdStringModel::GetFilteredRows(const QString& FilterTex
{
const PieceInfo* Info = mSortedPieces[PieceInfoIndex];
FilteredRows[PieceInfoIndex] = (strcasestr(Info->m_strDescription, Text.c_str()) || strcasestr(Info->mFileName, Text.c_str()));
FilteredRows[PieceInfoIndex] = (lcstrcasestr(Info->m_strDescription, Text.c_str()) || lcstrcasestr(Info->mFileName, Text.c_str()));
}
return FilteredRows;
-36
View File
@@ -1,36 +0,0 @@
#include "lc_global.h"
#ifdef Q_OS_WIN
char* strcasestr(const char* s, const char* find)
{
char c, sc;
if ((c = *find++) != 0)
{
c = tolower((unsigned char)c);
const int len = (int)strlen(find);
do
{
do
{
if ((sc = *s++) == 0)
return (nullptr);
} while ((char)tolower((unsigned char)sc) != c);
} while (qstrnicmp(s, find, len) != 0);
s--;
}
return ((char *)s);
}
#else
char* strupr(char* string)
{
for (char* c = string; *c; c++)
*c = toupper(*c);
return string;
}
#endif