eina: include blank lines in file iterator T2237

any line that would not have been included before has length == 0
This commit is contained in:
Andy Williams 2015-03-27 21:36:45 +00:00
parent 3a64b0ccd3
commit 128a78940b
2 changed files with 10 additions and 7 deletions

View 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;

View 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);