From e0e6bbbbe2a0ea0772a4590feb0275a962c74cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 11 Mar 2024 22:47:16 +0100 Subject: [PATCH] Minor cleanup of `CLineReader` - Use `nullptr` instead of `0`. - Use `\0` instead of `0`. - Move variable declaration. --- src/engine/shared/linereader.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/engine/shared/linereader.cpp b/src/engine/shared/linereader.cpp index 4eae22a88..9bc62d8ba 100644 --- a/src/engine/shared/linereader.cpp +++ b/src/engine/shared/linereader.cpp @@ -24,7 +24,6 @@ char *CLineReader::Get() // fetch more // move the remaining part to the front - unsigned Read; unsigned Left = m_BufferSize - LineStart; if(LineStart > m_BufferSize) @@ -34,7 +33,7 @@ char *CLineReader::Get() m_BufferPos = Left; // fill the buffer - Read = io_read(m_File, &m_aBuffer[m_BufferPos], m_BufferMaxSize - m_BufferPos); + unsigned Read = io_read(m_File, &m_aBuffer[m_BufferPos], m_BufferMaxSize - m_BufferPos); m_BufferSize = Left + Read; LineStart = 0; @@ -42,7 +41,7 @@ char *CLineReader::Get() { if(Left) { - m_aBuffer[Left] = 0; // return the last line + m_aBuffer[Left] = '\0'; // return the last line m_BufferPos = Left; m_BufferSize = Left; if(!str_utf8_check(m_aBuffer)) @@ -53,8 +52,7 @@ char *CLineReader::Get() } return m_aBuffer; } - else - return 0x0; // we are done! + return nullptr; // we are done! } } else @@ -72,9 +70,9 @@ char *CLineReader::Get() continue; } else if(m_aBuffer[m_BufferPos + 1] == '\n') - m_aBuffer[m_BufferPos++] = 0; + m_aBuffer[m_BufferPos++] = '\0'; } - m_aBuffer[m_BufferPos++] = 0; + m_aBuffer[m_BufferPos++] = '\0'; if(!str_utf8_check(&m_aBuffer[LineStart])) { LineStart = m_BufferPos; @@ -86,7 +84,7 @@ char *CLineReader::Get() else if(CRLFBreak) { if(m_aBuffer[m_BufferPos] == '\n') - m_aBuffer[m_BufferPos++] = 0; + m_aBuffer[m_BufferPos++] = '\0'; if(!str_utf8_check(&m_aBuffer[LineStart])) { LineStart = m_BufferPos;