Fix (i)strip_CR

This commit is contained in:
Ilari Liusvaara 2012-02-23 23:18:41 +02:00
parent e88023a17f
commit c5633cc2ea

View file

@ -9,16 +9,15 @@ std::string strip_CR(const std::string& str)
void istrip_CR(std::string& str) void istrip_CR(std::string& str)
{ {
std::string x = str;
size_t crc = 0; size_t crc = 0;
size_t xl = x.length(); size_t xl = str.length();
while(crc < xl) { while(crc < xl) {
char y = x[xl - crc - 1]; char y = str[xl - crc - 1];
if(y != '\r' && y != '\n') if(y != '\r' && y != '\n')
break; break;
crc++; crc++;
} }
x.substr(0, xl - crc); str = str.substr(0, xl - crc);
} }
int firstchar(const std::string& str) int firstchar(const std::string& str)