eina: include blank lines in file iterator T2237
authorAndy Williams <andy@andywilliams.me>
Fri, 27 Mar 2015 21:36:45 +0000 (21:36 +0000)
committerAndy Williams <andy@andywilliams.me>
Fri, 27 Mar 2015 21:42:45 +0000 (21:42 +0000)
any line that would not have been included before has length == 0

src/lib/eina/eina_file_common.c
src/tests/eina/eina_test_file.c

index f1ef5ef..62eb617 100644 (file)
@@ -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;
index 727f872..fec6054 100644 (file)
@@ -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);