Browse Source

Fix eating "\r" without decrementing parse string size, that was generating garbage at the end of the formated string.

mingodad 11 years ago
parent
commit
ff59a7fa72
1 changed files with 2 additions and 2 deletions
  1. 2 2
      SquiLu/sqstdlib/sqstdstring.cpp

+ 2 - 2
SquiLu/sqstdlib/sqstdstring.cpp

@@ -107,7 +107,7 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
                         ++addlen;
                         if (*ts2 == _SC('\r') && *(ts2+1) == _SC('\n') ) {
                           ++addlen;
-                          ++ts2; //eat \r and output only \n
+                          ++ts2; --size;//eat \r and output only \n
                         }
                         else if (*ts2 == _SC('"') || *ts2 == _SC('\\') || *ts2 == _SC('\n')) {
                           ++addlen;
@@ -129,7 +129,7 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
                       *ts2++ = _SC('"');
                       while (size--) {
                         if (*ts == _SC('\r') && *(ts+1) == _SC('\n') ) {
-                          ++ts; //eat \r and output only \n
+                          ++ts; --size;//eat \r and output only \n
                         }
                         if (*ts == _SC('"') || *ts == _SC('\\')) {
                             *ts2++ = _SC('\\');