fixed length string read refinement

This commit is contained in:
Jack Andersen 2015-06-19 10:54:21 -10:00
parent 2d8aeb70e8
commit 687a7eef64
3 changed files with 17 additions and 13 deletions

View File

@ -1,7 +1,7 @@
# PKGBUILD for libAthena
_pkgname=libathena
pkgname=$_pkgname-git
pkgver=1.1.0.37.g3dfb001
pkgver=1.1.0.39.g2d8aeb7
pkgrel=1
pkgdesc="Basic cross platform IO library"
arch=('i686' 'x86_64')

View File

@ -346,12 +346,13 @@ std::string FileReader::readString(atInt32 fixedLen)
atUint8 chr = readByte();
atInt32 i;
for (i = 0 ; chr != 0 ; ++i)
for (i = 1 ; chr != 0 ; ++i)
{
if (fixedLen >= 0 && i >= fixedLen - 1)
ret += chr;
if (fixedLen >= 0 && i >= fixedLen)
break;
ret += chr;
chr = readByte();
}
@ -367,12 +368,13 @@ std::wstring FileReader::readWString(atInt32 fixedLen)
atUint16 chr = readUint16();
atInt32 i;
for (i = 0 ; chr != 0 ; ++i)
for (i = 1 ; chr != 0 ; ++i)
{
if (fixedLen >= 0 && i >= fixedLen - 1)
ret += chr;
if (fixedLen >= 0 && i >= fixedLen)
break;
ret += chr;
chr = readUint16();
}

View File

@ -528,12 +528,13 @@ std::string MemoryReader::readString(atInt32 fixedLen)
atUint8 chr = readByte();
atInt32 i;
for (i = 0 ; chr != 0 ; ++i)
for (i = 1 ; chr != 0 ; ++i)
{
if (fixedLen >= 0 && i >= fixedLen - 1)
ret += chr;
if (fixedLen >= 0 && i >= fixedLen)
break;
ret += chr;
chr = readByte();
}
@ -549,12 +550,13 @@ std::wstring MemoryReader::readWString(atInt32 fixedLen)
atUint16 chr = readUint16();
atInt32 i;
for (i = 0 ; chr != 0 ; ++i)
for (i = 1 ; chr != 0 ; ++i)
{
if (fixedLen >= 0 && i >= fixedLen - 1)
ret += chr;
if (fixedLen >= 0 && i >= fixedLen)
break;
ret += chr;
chr = readUint16();
}