mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Minor cleanup of CLineReader
- Use `nullptr` instead of `0`. - Use `\0` instead of `0`. - Move variable declaration.
This commit is contained in:
parent
0f94d0d72c
commit
e0e6bbbbe2
|
@ -24,7 +24,6 @@ char *CLineReader::Get()
|
||||||
// fetch more
|
// fetch more
|
||||||
|
|
||||||
// move the remaining part to the front
|
// move the remaining part to the front
|
||||||
unsigned Read;
|
|
||||||
unsigned Left = m_BufferSize - LineStart;
|
unsigned Left = m_BufferSize - LineStart;
|
||||||
|
|
||||||
if(LineStart > m_BufferSize)
|
if(LineStart > m_BufferSize)
|
||||||
|
@ -34,7 +33,7 @@ char *CLineReader::Get()
|
||||||
m_BufferPos = Left;
|
m_BufferPos = Left;
|
||||||
|
|
||||||
// fill the buffer
|
// 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;
|
m_BufferSize = Left + Read;
|
||||||
LineStart = 0;
|
LineStart = 0;
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ char *CLineReader::Get()
|
||||||
{
|
{
|
||||||
if(Left)
|
if(Left)
|
||||||
{
|
{
|
||||||
m_aBuffer[Left] = 0; // return the last line
|
m_aBuffer[Left] = '\0'; // return the last line
|
||||||
m_BufferPos = Left;
|
m_BufferPos = Left;
|
||||||
m_BufferSize = Left;
|
m_BufferSize = Left;
|
||||||
if(!str_utf8_check(m_aBuffer))
|
if(!str_utf8_check(m_aBuffer))
|
||||||
|
@ -53,8 +52,7 @@ char *CLineReader::Get()
|
||||||
}
|
}
|
||||||
return m_aBuffer;
|
return m_aBuffer;
|
||||||
}
|
}
|
||||||
else
|
return nullptr; // we are done!
|
||||||
return 0x0; // we are done!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -72,9 +70,9 @@ char *CLineReader::Get()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(m_aBuffer[m_BufferPos + 1] == '\n')
|
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]))
|
if(!str_utf8_check(&m_aBuffer[LineStart]))
|
||||||
{
|
{
|
||||||
LineStart = m_BufferPos;
|
LineStart = m_BufferPos;
|
||||||
|
@ -86,7 +84,7 @@ char *CLineReader::Get()
|
||||||
else if(CRLFBreak)
|
else if(CRLFBreak)
|
||||||
{
|
{
|
||||||
if(m_aBuffer[m_BufferPos] == '\n')
|
if(m_aBuffer[m_BufferPos] == '\n')
|
||||||
m_aBuffer[m_BufferPos++] = 0;
|
m_aBuffer[m_BufferPos++] = '\0';
|
||||||
if(!str_utf8_check(&m_aBuffer[LineStart]))
|
if(!str_utf8_check(&m_aBuffer[LineStart]))
|
||||||
{
|
{
|
||||||
LineStart = m_BufferPos;
|
LineStart = m_BufferPos;
|
||||||
|
|
Loading…
Reference in a new issue