summaryrefslogtreecommitdiff
path: root/legacy/eina
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-07-31 07:23:16 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-07-31 07:23:16 +0000
commit4540fa9d0f163e0a3b598debeebd79eea2818ac2 (patch)
tree05abfd2be1685d2f91097168b4e562f726443743 /legacy/eina
parent7595ce698daf995914ea80d8fbe0a2c9096559ab (diff)
eina: cleanup eina_file_map_lines API before release.
SVN revision: 74618
Diffstat (limited to 'legacy/eina')
-rw-r--r--legacy/eina/src/include/eina_file.h14
-rw-r--r--legacy/eina/src/lib/eina_file.c34
-rw-r--r--legacy/eina/src/lib/eina_file_win32.c34
3 files changed, 40 insertions, 42 deletions
diff --git a/legacy/eina/src/include/eina_file.h b/legacy/eina/src/include/eina_file.h
index 0518c12655..31c4eb5b62 100644
--- a/legacy/eina/src/include/eina_file.h
+++ b/legacy/eina/src/include/eina_file.h
@@ -102,7 +102,7 @@ typedef struct _Eina_Stat Eina_Stat;
102 * @typedef Eina_File_Lines 102 * @typedef Eina_File_Lines
103 * A typedef to #_Eina_File_Lines. 103 * A typedef to #_Eina_File_Lines.
104 */ 104 */
105typedef struct _Eina_File_Lines Eina_File_Lines; 105typedef struct _Eina_File_Line Eina_File_Line;
106 106
107/** 107/**
108 * @typedef Eina_File_Dir_List_Cb 108 * @typedef Eina_File_Dir_List_Cb
@@ -195,17 +195,15 @@ struct _Eina_Stat
195}; 195};
196 196
197/** 197/**
198 * @struct _Eina_File_Lines 198 * @struct _Eina_File_Line
199 * A structure to store information of line 199 * A structure to store information of line
200 * @since 1.3 200 * @since 1.3
201 */ 201 */
202struct _Eina_File_Lines 202struct _Eina_File_Line
203{ 203{
204 struct { 204 const char *start;
205 const char *start; 205 const char *end;
206 const char *end; 206 unsigned int index;
207 unsigned int index;
208 } line;
209 unsigned long long length; 207 unsigned long long length;
210}; 208};
211 209
diff --git a/legacy/eina/src/lib/eina_file.c b/legacy/eina/src/lib/eina_file.c
index 7538c0c31b..bdfe2a76a8 100644
--- a/legacy/eina/src/lib/eina_file.c
+++ b/legacy/eina/src/lib/eina_file.c
@@ -1137,7 +1137,7 @@ struct _Eina_Lines_Iterator
1137 1137
1138 int boundary; 1138 int boundary;
1139 1139
1140 Eina_File_Lines current; 1140 Eina_File_Line current;
1141}; 1141};
1142 1142
1143/* search '\r' and '\n' by preserving cache locality and page locality 1143/* search '\r' and '\n' by preserving cache locality and page locality
@@ -1177,32 +1177,32 @@ _eina_file_map_lines_iterator_next(Eina_Lines_Iterator *it, void **data)
1177 const char *eol; 1177 const char *eol;
1178 unsigned char match; 1178 unsigned char match;
1179 1179
1180 if (it->current.line.end >= it->end) 1180 if (it->current.end >= it->end)
1181 return EINA_FALSE; 1181 return EINA_FALSE;
1182 1182
1183 match = *it->current.line.end; 1183 match = *it->current.end;
1184 while ((*it->current.line.end == '\n' || *it->current.line.end == '\r') 1184 while ((*it->current.end == '\n' || *it->current.end == '\r')
1185 && it->current.line.end < it->end) 1185 && it->current.end < it->end)
1186 { 1186 {
1187 if (match == *it->current.line.end) 1187 if (match == *it->current.end)
1188 it->current.line.index++; 1188 it->current.index++;
1189 it->current.line.end++; 1189 it->current.end++;
1190 } 1190 }
1191 it->current.line.index++; 1191 it->current.index++;
1192 1192
1193 if (it->current.line.end == it->end) 1193 if (it->current.end == it->end)
1194 return EINA_FALSE; 1194 return EINA_FALSE;
1195 1195
1196 eol = _eina_fine_eol(it->current.line.end, 1196 eol = _eina_fine_eol(it->current.end,
1197 it->boundary, 1197 it->boundary,
1198 it->end); 1198 it->end);
1199 it->boundary = (uintptr_t) eol & 0x3FF; 1199 it->boundary = (uintptr_t) eol & 0x3FF;
1200 if (it->boundary == 0) it->boundary = 4096; 1200 if (it->boundary == 0) it->boundary = 4096;
1201 1201
1202 it->current.line.start = it->current.line.end; 1202 it->current.start = it->current.end;
1203 1203
1204 it->current.line.end = eol; 1204 it->current.end = eol;
1205 it->current.length = eol - it->current.line.start - 1; 1205 it->current.length = eol - it->current.start - 1;
1206 1206
1207 *data = &it->current; 1207 *data = &it->current;
1208 return EINA_TRUE; 1208 return EINA_TRUE;
@@ -1251,9 +1251,9 @@ eina_file_map_lines(Eina_File *file)
1251 1251
1252 it->fp = file; 1252 it->fp = file;
1253 it->boundary = 4096; 1253 it->boundary = 4096;
1254 it->current.line.start = it->map; 1254 it->current.start = it->map;
1255 it->current.line.end = it->current.line.start; 1255 it->current.end = it->current.start;
1256 it->current.line.index = 0; 1256 it->current.index = 0;
1257 it->current.length = 0; 1257 it->current.length = 0;
1258 it->end = it->map + it->fp->length; 1258 it->end = it->map + it->fp->length;
1259 1259
diff --git a/legacy/eina/src/lib/eina_file_win32.c b/legacy/eina/src/lib/eina_file_win32.c
index f507bf9467..af547fa122 100644
--- a/legacy/eina/src/lib/eina_file_win32.c
+++ b/legacy/eina/src/lib/eina_file_win32.c
@@ -117,7 +117,7 @@ struct _Eina_Lines_Iterator
117 117
118 int boundary; 118 int boundary;
119 119
120 Eina_File_Lines current; 120 Eina_File_Line current;
121}; 121};
122 122
123struct _Eina_File_Direct_Iterator 123struct _Eina_File_Direct_Iterator
@@ -612,32 +612,32 @@ _eina_file_map_lines_iterator_next(Eina_Lines_Iterator *it, void **data)
612 const char *eol; 612 const char *eol;
613 unsigned char match; 613 unsigned char match;
614 614
615 if (it->current.line.end >= it->end) 615 if (it->current.end >= it->end)
616 return EINA_FALSE; 616 return EINA_FALSE;
617 617
618 match = *it->current.line.end; 618 match = *it->current.end;
619 while ((*it->current.line.end == '\n' || *it->current.line.end == '\r') 619 while ((*it->current.end == '\n' || *it->current.end == '\r')
620 && it->current.line.end < it->end) 620 && it->current.end < it->end)
621 { 621 {
622 if (match == *it->current.line.end) 622 if (match == *it->current.end)
623 it->current.line.index++; 623 it->current.index++;
624 it->current.line.end++; 624 it->current.end++;
625 } 625 }
626 it->current.line.index++; 626 it->current.index++;
627 627
628 if (it->current.line.end == it->end) 628 if (it->current.end == it->end)
629 return EINA_FALSE; 629 return EINA_FALSE;
630 630
631 eol = _eina_fine_eol(it->current.line.end, 631 eol = _eina_fine_eol(it->current.end,
632 it->boundary, 632 it->boundary,
633 it->end); 633 it->end);
634 it->boundary = (uintptr_t) eol & 0x3FF; 634 it->boundary = (uintptr_t) eol & 0x3FF;
635 if (it->boundary == 0) it->boundary = 4096; 635 if (it->boundary == 0) it->boundary = 4096;
636 636
637 it->current.line.start = it->current.line.end; 637 it->current.start = it->current.end;
638 638
639 it->current.line.end = eol; 639 it->current.end = eol;
640 it->current.length = eol - it->current.line.start - 1; 640 it->current.length = eol - it->current.start - 1;
641 641
642 *data = &it->current; 642 *data = &it->current;
643 return EINA_TRUE; 643 return EINA_TRUE;
@@ -1187,9 +1187,9 @@ eina_file_map_lines(Eina_File *file)
1187 1187
1188 it->fp = file; 1188 it->fp = file;
1189 it->boundary = 4096; 1189 it->boundary = 4096;
1190 it->current.line.start = it->map; 1190 it->current.start = it->map;
1191 it->current.line.end = it->current.line.start; 1191 it->current.end = it->current.start;
1192 it->current.line.index = 0; 1192 it->current.index = 0;
1193 it->current.length = 0; 1193 it->current.length = 0;
1194 it->end = it->map + it->fp->length; 1194 it->end = it->map + it->fp->length;
1195 1195