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; typedef quintptr lcuintptr;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#define snprintf _snprintf
#define strcasecmp stricmp
#define strncasecmp strnicmp
char* strcasestr(const char *s, const char *find); char* strcasestr(const char *s, const char *find);
#else #else
char* strupr(char* string); char* strupr(char* string);
char* strlwr(char* string); char* strlwr(char* string);
int stricmp(const char* str1, const char* str2);
#endif #endif
// Version number. // Version number.

View file

@ -753,10 +753,11 @@ bool lcModel::LoadBinary(lcFile* file)
file->Seek(sh, SEEK_CUR); file->Seek(sh, SEEK_CUR);
else else
{ {
String Author; QByteArray Author;
file->ReadBuffer(Author.GetBuffer(sh), sh); Author.resize(sh + 1);
Author.Buffer()[sh] = 0; file->ReadBuffer(Author.data(), sh);
mProperties.mAuthor = QString::fromUtf8(Author.Buffer()); Author[sh] = 0;
mProperties.mAuthor = QString::fromUtf8(Author);
} }
file->ReadBuffer(&ch, 1); file->ReadBuffer(&ch, 1);
@ -765,10 +766,11 @@ bool lcModel::LoadBinary(lcFile* file)
file->Seek(sh, SEEK_CUR); file->Seek(sh, SEEK_CUR);
else else
{ {
String Description; QByteArray Description;
file->ReadBuffer(Description.GetBuffer(sh), sh); Description.resize(sh + 1);
Description.Buffer()[sh] = 0; file->ReadBuffer(Description.data(), sh);
mProperties.mDescription = QString::fromUtf8(Description.Buffer()); Description[sh] = 0;
mProperties.mDescription = QString::fromUtf8(Description);
} }
file->ReadBuffer(&ch, 1); file->ReadBuffer(&ch, 1);
@ -777,10 +779,11 @@ bool lcModel::LoadBinary(lcFile* file)
file->Seek(sh, SEEK_CUR); file->Seek(sh, SEEK_CUR);
else else
{ {
String Comments; QByteArray Comments;
file->ReadBuffer(Comments.GetBuffer(sh), sh); Comments.resize(sh + 1);
Comments.Buffer()[sh] = 0; file->ReadBuffer(Comments.data(), sh);
mProperties.mComments = QString::fromUtf8(Comments.Buffer()); Comments[sh] = 0;
mProperties.mComments = QString::fromUtf8(Comments);
mProperties.mComments.replace(QLatin1String("\r\n"), QLatin1String("\n")); 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]; lcZipFileInfo& FileInfo = mFiles[FileIdx];
if (!stricmp(FileInfo.file_name, FileName)) if (!qstricmp(FileInfo.file_name, FileName))
return ExtractFile(FileIdx, File, MaxLength); return ExtractFile(FileIdx, File, MaxLength);
} }

View file

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