-------------------------------------------------------------------------*\ * Reads a line terminated by a CR LF pair or just by a LF. The CR and LF * are not returned by the function and are discarded from the buffer \*-------------------------------------------------------------------------*/
| 222 | * are not returned by the function and are discarded from the buffer |
| 223 | \*-------------------------------------------------------------------------*/ |
| 224 | static int recvline(p_buffer buf, luaL_Buffer *b) { |
| 225 | int err = IO_DONE; |
| 226 | while (err == IO_DONE) { |
| 227 | size_t count, pos; const char *data; |
| 228 | err = buffer_get(buf, &data, &count); |
| 229 | pos = 0; |
| 230 | while (pos < count && data[pos] != '\n') { |
| 231 | /* we ignore all \r's */ |
| 232 | if (data[pos] != '\r') luaL_addchar(b, data[pos]); |
| 233 | pos++; |
| 234 | } |
| 235 | if (pos < count) { /* found '\n' */ |
| 236 | buffer_skip(buf, pos+1); /* skip '\n' too */ |
| 237 | break; /* we are done */ |
| 238 | } else /* reached the end of the buffer */ |
| 239 | buffer_skip(buf, pos); |
| 240 | } |
| 241 | return err; |
| 242 | } |
| 243 | |
| 244 | /*-------------------------------------------------------------------------*\ |
| 245 | * Skips a given number of bytes from read buffer. No data is read from the |
no test coverage detected