barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=27d428a6e18c79d9d0883ab91de4b668e5ddaf62

commit 27d428a6e18c79d9d0883ab91de4b668e5ddaf62
Author: Gustavo Sverzut Barbieri <barbi...@profusion.mobi>
Date:   Tue Aug 23 21:27:45 2016 -0300

    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.
---
 src/examples/ecore/efl_io_queue_example.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/examples/ecore/efl_io_queue_example.c 
b/src/examples/ecore/efl_io_queue_example.c
index 71fa846..710b5ac 100644
--- a/src/examples/ecore/efl_io_queue_example.c
+++ b/src/examples/ecore/efl_io_queue_example.c
@@ -48,13 +48,14 @@ _receiver_data(void *data EINA_UNUSED, const Eo_Event 
*event)
     */
    if (slice.len == 0) return;
 
-   if (slice.len < line_delimiter.len)
-     {
-        fprintf(stderr, "ERROR: received short line '" EINA_SLICE_STR_FMT 
"'\n",
-           EINA_SLICE_STR_PRINT(slice));
-     }
-   else if (memcmp(slice.bytes + slice.len - line_delimiter.len,
-                   line_delimiter.bytes, line_delimiter.len) != 0)
+   /*
+    * If the server didn't send us the line terminator and closed the
+    * connection (ie: efl_io_reader_eos_get() == true) or if the
+    * 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
+    * delimiter. Check for that.
+    */
+   if (!eina_slice_endswith(slice,  line_delimiter))
      {
         fprintf(stderr, "WARNING: received without line-delimiter '"
                 EINA_SLICE_STR_FMT "'\n",

-- 


Reply via email to