String cleanup.

This commit is contained in:
Leonardo Zide 2017-02-07 09:35:11 -08:00
parent 93ef02919a
commit e22d127660
4 changed files with 17 additions and 23 deletions

View file

@ -30,14 +30,10 @@ typedef quint64 lcuint64;
typedef quintptr lcuintptr;
#ifdef Q_OS_WIN
#define snprintf _snprintf
#define strcasecmp stricmp
#define strncasecmp strnicmp
char* strcasestr(const char *s, const char *find);
#else
char* strupr(char* string);
char* strlwr(char* string);
int stricmp(const char* str1, const char* str2);
#endif
// Version number.

View file

@ -753,10 +753,11 @@ bool lcModel::LoadBinary(lcFile* file)
file->Seek(sh, SEEK_CUR);
else
{
String Author;
file->ReadBuffer(Author.GetBuffer(sh), sh);
Author.Buffer()[sh] = 0;
mProperties.mAuthor = QString::fromUtf8(Author.Buffer());
QByteArray Author;
Author.resize(sh + 1);
file->ReadBuffer(Author.data(), sh);
Author[sh] = 0;
mProperties.mAuthor = QString::fromUtf8(Author);
}
file->ReadBuffer(&ch, 1);
@ -765,10 +766,11 @@ bool lcModel::LoadBinary(lcFile* file)
file->Seek(sh, SEEK_CUR);
else
{
String Description;
file->ReadBuffer(Description.GetBuffer(sh), sh);
Description.Buffer()[sh] = 0;
mProperties.mDescription = QString::fromUtf8(Description.Buffer());
QByteArray Description;
Description.resize(sh + 1);
file->ReadBuffer(Description.data(), sh);
Description[sh] = 0;
mProperties.mDescription = QString::fromUtf8(Description);
}
file->ReadBuffer(&ch, 1);
@ -777,10 +779,11 @@ bool lcModel::LoadBinary(lcFile* file)
file->Seek(sh, SEEK_CUR);
else
{
String Comments;
file->ReadBuffer(Comments.GetBuffer(sh), sh);
Comments.Buffer()[sh] = 0;
mProperties.mComments = QString::fromUtf8(Comments.Buffer());
QByteArray Comments;
Comments.resize(sh + 1);
file->ReadBuffer(Comments.data(), sh);
Comments[sh] = 0;
mProperties.mComments = QString::fromUtf8(Comments);
mProperties.mComments.replace(QLatin1String("\r\n"), QLatin1String("\n"));
}
}

View file

@ -595,7 +595,7 @@ bool lcZipFile::ExtractFile(const char* FileName, lcMemFile& File, lcuint32 MaxL
{
lcZipFileInfo& FileInfo = mFiles[FileIdx];
if (!stricmp(FileInfo.file_name, FileName))
if (!qstricmp(FileInfo.file_name, FileName))
return ExtractFile(FileIdx, File, MaxLength);
}

View file

@ -19,7 +19,7 @@ char* strcasestr(const char *s, const char *find)
if ((sc = *s++) == 0)
return (NULL);
} while ((char)tolower((unsigned char)sc) != c);
} while (strncasecmp(s, find, len) != 0);
} while (qstrnicmp(s, find, len) != 0);
s--;
}
return ((char *)s);
@ -43,9 +43,4 @@ char* strlwr(char *string)
return string;
}
int stricmp(const char *str1, const char *str2)
{
return strcasecmp(str1, str2);
}
#endif