MCPcopy Create free account
hub / github.com/defold/defold / recvline

Function recvline

engine/script/src/luasocket/buffer.c:224–242  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * 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 \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

222* are not returned by the function and are discarded from the buffer
223\*-------------------------------------------------------------------------*/
224static 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

Callers 1

buffer_meth_receiveFunction · 0.85

Calls 2

buffer_getFunction · 0.85
buffer_skipFunction · 0.85

Tested by

no test coverage detected