ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=128a78940b2a77748d97d99753ff298890986e51

commit 128a78940b2a77748d97d99753ff298890986e51
Author: Andy Williams <a...@andywilliams.me>
Date:   Fri Mar 27 21:36:45 2015 +0000

    eina: include blank lines in file iterator T2237
    
    any line that would not have been included before has length == 0
---
 src/lib/eina/eina_file_common.c |  7 ++++---
 src/tests/eina/eina_test_file.c | 10 ++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index f1ef5ef..62eb617 100644
--- a/src/lib/eina/eina_file_common.c
+++ b/src/lib/eina/eina_file_common.c
@@ -552,17 +552,18 @@ _eina_file_map_lines_iterator_next(Eina_Lines_Iterator 
*it, void **data)
 
    if (it->current.end >= it->end)
      return EINA_FALSE;
-   if (it->current.index == 0)
-     it->current.index++;
 
    match = *it->current.end;
+   if (it->current.index > 0)
+     it->current.end++;
    while ((*it->current.end == '\n' || *it->current.end == '\r')
           && it->current.end < it->end)
      {
         if (match == *it->current.end)
-          it->current.index++;
+          break;
         it->current.end++;
      }
+   it->current.index++;
 
    if (it->current.end == it->end)
      return EINA_FALSE;
diff --git a/src/tests/eina/eina_test_file.c b/src/tests/eina/eina_test_file.c
index 727f872..fec6054 100644
--- a/src/tests/eina/eina_test_file.c
+++ b/src/tests/eina/eina_test_file.c
@@ -407,8 +407,7 @@ START_TEST(eina_test_file_virtualize)
    Eina_Iterator *it;
    Eina_File_Line *ln;
    void *map;
-   const unsigned int check[] = { 1, 2, 3, 6, 7 };
-   int i = 0;
+   unsigned int i = 0;
 
    eina_init();
 
@@ -430,13 +429,16 @@ START_TEST(eina_test_file_virtualize)
    it = eina_file_map_lines(f);
    EINA_ITERATOR_FOREACH(it, ln)
      {
-        fail_if(ln->index != check[i]);
         i++;
+        fail_if(ln->index != i);
+
+        if (i == 4 || i == 5)
+          fail_if(ln->length != 0);
      }
    fail_if(eina_iterator_container_get(it) != f);
    eina_iterator_free(it);
 
-   fail_if(i != 5);
+   fail_if(i != 7);
 
    eina_file_close(f);
 

-- 


Reply via email to