From 012507c38a5033e91093366d63fbe5710565633a Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Wed, 24 Mar 2004 18:35:04 +0000 Subject: [PATCH] fixed getline function --- amxmodx/CFile.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/amxmodx/CFile.cpp b/amxmodx/CFile.cpp index 4963591a..f63824e0 100755 --- a/amxmodx/CFile.cpp +++ b/amxmodx/CFile.cpp @@ -94,6 +94,7 @@ File& operator>>( File& f, char* n ) int File::getline( char* buf, int sz ) { int a = sz; + char *origBuf = buf; if ( *this ) { int c; @@ -101,6 +102,15 @@ int File::getline( char* buf, int sz ) *buf++ = c; *buf = 0; } + + // trim 0x0a and 0x0d characters at the end + while (buf != origBuf) + { + if (*buf == 0x0a || *buf == 0x0d) + *buf = 0; + --buf; + } + return a - sz; }