[CLI] Bugfix: <list> command doesn't work properly for sources with
authorOleg Lekarev <o.lekarev@samsung.com>
Thu, 29 Jun 2023 12:35:37 +0000 (15:35 +0300)
committerGleb Balykov/Advanced System SW Lab /SRR/Staff Engineer/Samsung Electronics <g.balykov@samsung.com>
Fri, 7 Jul 2023 09:44:26 +0000 (12:44 +0300)
              unix/linux line ending style.

src/protocols/sourcestorage.cpp

index 2342fdbb89ea344368fc9b6845133f3b2567b22e..631e43a2cdd368e9c4892412e7c2765ed889c6b5 100644 (file)
@@ -63,9 +63,15 @@ namespace netcoredbg
         for(char* bufptr = sf->text; bufptr < sf->text + fileLen; )
         {
             sf->lines.push_back(bufptr);
-            while(*bufptr != '\r')
+            while(*bufptr != '\r' && *bufptr != '\n' && *bufptr != '\0')
                 bufptr++;
-            *bufptr++ = '\0';
+            if (*bufptr == '\0')
+            {
+                bufptr++;
+                continue;
+            }
+            if (*bufptr == '\r')
+                *bufptr++ = '\0';
             if (*bufptr == '\n')
                 *bufptr++ = '\0';
         }