MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / nextLine

Method nextLine

other_src/astyle/src/astyle_main.cpp:121–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119 */
120template<typename T>
121string ASStreamIterator<T>::nextLine(bool emptyLineWasDeleted)
122{
123 // verify that the current position is correct
124 assert (peekStart == 0);
125
126 // a deleted line may be replaced if break-blocks is requested
127 // this sets up the compare to check for a replaced empty line
128 if (prevLineDeleted)
129 {
130 prevLineDeleted = false;
131 checkForEmptyLine = true;
132 }
133 if (!emptyLineWasDeleted)
134 prevBuffer = buffer;
135 else
136 prevLineDeleted = true;
137
138 // read the next record
139 buffer.clear();
140 char ch;
141 inStream->get(ch);
142
143 while (!inStream->eof() && ch != '\n' && ch != '\r')
144 {
145 buffer.append(1, ch);
146 inStream->get(ch);
147 }
148
149 if (inStream->eof())
150 {
151 return buffer;
152 }
153
154 int peekCh = inStream->peek();
155
156 // find input end-of-line characters
157 if (!inStream->eof())
158 {
159 if (ch == '\r') // CR+LF is windows otherwise Mac OS 9
160 {
161 if (peekCh == '\n')
162 {
163 inStream->get();
164 eolWindows++;
165 }
166 else
167 eolMacOld++;
168 }
169 else // LF is Linux, allow for improbable LF/CR
170 {
171 if (peekCh == '\r')
172 {
173 inStream->get();
174 eolWindows++;
175 }
176 else
177 eolLinux++;
178 }

Callers 3

formatCinToCoutMethod · 0.45
formatFileMethod · 0.45
AStyleMainFunction · 0.45

Calls 3

clearMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected