MCPcopy Create free account
hub / github.com/bdring/FluidNC / readLine

Method readLine

FluidNC/src/InputFile.cpp:15–36  ·  view source on GitHub ↗

Read a line from the file Returns Error::Ok if a line was read, even if the line was empty. Returns Error::EOF on end of file. Returns other Error code on error, after displaying a message. */

Source from the content-addressed store, hash-verified

13 Returns other Error code on error, after displaying a message.
14*/
15Error InputFile::readLine(char* line, size_t maxlen) {
16 size_t len = 0;
17 int c;
18 while ((c = read()) >= 0) {
19 if (len >= maxlen) {
20 return Error::LineLengthExceeded;
21 }
22 if (c == '\r') {
23 continue;
24 }
25 if (c == '\n') {
26 ++_line_number;
27 if (len == 0) {
28 ++_blank_lines;
29 }
30 break;
31 }
32 line[len++] = c;
33 }
34 line[len] = '\0';
35 return len || c >= 0 ? Error::Ok : Error::Eof;
36}
37
38void InputFile::ack(Error status) {
39 if (status != Error::Ok) {

Callers 2

showFileFunction · 0.45
fileShowSomeFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected