forked from enlightenment/efl
efl_io_queue_example: use eina_slice_endswith().
make the code more readable and clear. Also document when the line may miss a trailing line delimiter in the slice.
This commit is contained in:
parent
45c0002929
commit
27d428a6e1
|
@ -48,13 +48,14 @@ _receiver_data(void *data EINA_UNUSED, const Eo_Event *event)
|
||||||
*/
|
*/
|
||||||
if (slice.len == 0) return;
|
if (slice.len == 0) return;
|
||||||
|
|
||||||
if (slice.len < line_delimiter.len)
|
/*
|
||||||
{
|
* If the server didn't send us the line terminator and closed the
|
||||||
fprintf(stderr, "ERROR: received short line '" EINA_SLICE_STR_FMT "'\n",
|
* connection (ie: efl_io_reader_eos_get() == true) or if the
|
||||||
EINA_SLICE_STR_PRINT(slice));
|
* efl_io_copier_buffer_limit_set() was reached (note we do not set
|
||||||
}
|
* it in this example), then we may have a line without a trailing
|
||||||
else if (memcmp(slice.bytes + slice.len - line_delimiter.len,
|
* delimiter. Check for that.
|
||||||
line_delimiter.bytes, line_delimiter.len) != 0)
|
*/
|
||||||
|
if (!eina_slice_endswith(slice, line_delimiter))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "WARNING: received without line-delimiter '"
|
fprintf(stderr, "WARNING: received without line-delimiter '"
|
||||||
EINA_SLICE_STR_FMT "'\n",
|
EINA_SLICE_STR_FMT "'\n",
|
||||||
|
|
Loading…
Reference in New Issue