MCPcopy Create free account
hub / github.com/ddnet/ddnet / Get

Method Get

src/engine/shared/linereader.cpp:48–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48const char *CLineReader::Get()
49{
50 dbg_assert(m_pBuffer != nullptr, "Line reader not initialized");
51 if(m_ReadLastLine)
52 {
53 return nullptr;
54 }
55
56 unsigned LineStart = m_BufferPos;
57 while(true)
58 {
59 if(m_pBuffer[m_BufferPos] == '\0' || m_pBuffer[m_BufferPos] == '\n' || (m_pBuffer[m_BufferPos] == '\r' && m_pBuffer[m_BufferPos + 1] == '\n'))
60 {
61 if(m_pBuffer[m_BufferPos] == '\0')
62 {
63 m_ReadLastLine = true;
64 }
65 else
66 {
67 if(m_pBuffer[m_BufferPos] == '\r')
68 {
69 m_pBuffer[m_BufferPos] = '\0';
70 ++m_BufferPos;
71 }
72 m_pBuffer[m_BufferPos] = '\0';
73 ++m_BufferPos;
74 }
75
76 if(!str_utf8_check(&m_pBuffer[LineStart]))
77 {
78 // Skip lines containing invalid UTF-8
79 if(m_ReadLastLine)
80 {
81 return nullptr;
82 }
83 LineStart = m_BufferPos;
84 continue;
85 }
86 // Skip trailing empty line
87 if(m_ReadLastLine && m_pBuffer[LineStart] == '\0')
88 {
89 return nullptr;
90 }
91 return &m_pBuffer[LineStart];
92 }
93 ++m_BufferPos;
94 }
95}

Callers

nothing calls this directly

Calls 1

str_utf8_checkFunction · 0.85

Tested by

no test coverage detected