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