eina: also track lines index.
authorCedric BAIL <cedric.bail@free.fr>
Fri, 29 Jun 2012 10:45:58 +0000 (10:45 +0000)
committerCedric BAIL <cedric.bail@free.fr>
Fri, 29 Jun 2012 10:45:58 +0000 (10:45 +0000)
SVN revision: 73029

legacy/eina/src/include/eina_file.h
legacy/eina/src/lib/eina_file.c

index 246410f..0518c12 100644 (file)
@@ -204,6 +204,7 @@ struct _Eina_File_Lines
   struct {
     const char *start;
     const char *end;
+    unsigned int index;
   } line;
   unsigned long long length;
 };
index 33137cc..b5dd5cd 100644 (file)
@@ -1175,13 +1175,20 @@ static Eina_Bool
 _eina_file_map_lines_iterator_next(Eina_Lines_Iterator *it, void **data)
 {
    const char *eol;
+   unsigned char match;
 
    if (it->current.line.end >= it->end)
      return EINA_FALSE;
 
+   match = *it->current.line.end;
    while ((*it->current.line.end == '\n' || *it->current.line.end == '\r')
           && it->current.line.end < it->end)
-     it->current.line.end++;
+     {
+        if (match == *it->current.line.end)
+          it->current.line.index++;
+        it->current.line.end++;
+     }
+   it->current.line.index++;
 
    if (it->current.line.end == it->end)
      return EINA_FALSE;
@@ -1246,6 +1253,7 @@ eina_file_map_lines(Eina_File *file)
    it->boundary = 4096;
    it->current.line.start = it->map;
    it->current.line.end = it->current.line.start;
+   it->current.line.index = 0;
    it->current.length = 0;
    it->end = it->map + it->fp->length;