mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-26 06:45:37 +03:00
fixed getline function
This commit is contained in:
parent
a9a46e20b2
commit
012507c38a
@ -94,6 +94,7 @@ File& operator>>( File& f, char* n )
|
|||||||
int File::getline( char* buf, int sz )
|
int File::getline( char* buf, int sz )
|
||||||
{
|
{
|
||||||
int a = sz;
|
int a = sz;
|
||||||
|
char *origBuf = buf;
|
||||||
if ( *this )
|
if ( *this )
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
@ -101,6 +102,15 @@ int File::getline( char* buf, int sz )
|
|||||||
*buf++ = c;
|
*buf++ = c;
|
||||||
*buf = 0;
|
*buf = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trim 0x0a and 0x0d characters at the end
|
||||||
|
while (buf != origBuf)
|
||||||
|
{
|
||||||
|
if (*buf == 0x0a || *buf == 0x0d)
|
||||||
|
*buf = 0;
|
||||||
|
--buf;
|
||||||
|
}
|
||||||
|
|
||||||
return a - sz;
|
return a - sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user