forked from enlightenment/efl
eina: cleanup eina_file_map_lines API before release.
SVN revision: 74618
This commit is contained in:
parent
7595ce698d
commit
4540fa9d0f
|
@ -19,7 +19,7 @@ read_watch_file(const char *file)
|
|||
{
|
||||
Eina_File *f;
|
||||
Eina_Iterator *it;
|
||||
Eina_File_Lines *ln;
|
||||
Eina_File_Line *ln;
|
||||
Eio_Monitor *mon;
|
||||
Eina_List *r = NULL;
|
||||
|
||||
|
@ -33,7 +33,7 @@ read_watch_file(const char *file)
|
|||
{
|
||||
const char *path;
|
||||
|
||||
path = eina_stringshare_add_length(ln->line.start, ln->length);
|
||||
path = eina_stringshare_add_length(ln->start, ln->length);
|
||||
r = eina_list_append(r, eio_monitor_add(path));
|
||||
eina_stringshare_del(path);
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ static const char *
|
|||
efreet_user_dir_get(const char *key, const char *fallback)
|
||||
{
|
||||
Eina_File *file = NULL;
|
||||
Eina_File_Lines *line;
|
||||
Eina_File_Line *line;
|
||||
Eina_Iterator *it = NULL;
|
||||
const char *config_home;
|
||||
char path[PATH_MAX];
|
||||
|
@ -358,15 +358,15 @@ efreet_user_dir_get(const char *key, const char *fallback)
|
|||
const char *eq, *end;
|
||||
|
||||
if (line->length < 3) continue;
|
||||
if (line->line.start[0] == '#') continue;
|
||||
if (strncmp(line->line.start, "XDG", 3)) continue;
|
||||
eq = memchr(line->line.start, '=', line->length);
|
||||
if (line->start[0] == '#') continue;
|
||||
if (strncmp(line->start, "XDG", 3)) continue;
|
||||
eq = memchr(line->start, '=', line->length);
|
||||
if (!eq) continue;
|
||||
if (strncmp(key, line->line.start, eq - line->line.start)) continue;
|
||||
if (++eq >= line->line.end) continue;
|
||||
if (strncmp(key, line->start, eq - line->start)) continue;
|
||||
if (++eq >= line->end) continue;
|
||||
if (*eq != '"') continue;
|
||||
if (++eq >= line->line.end) continue;
|
||||
end = memchr(eq, '"', line->line.end - eq);
|
||||
if (++eq >= line->end) continue;
|
||||
end = memchr(eq, '"', line->end - eq);
|
||||
if (!end) continue;
|
||||
ret = alloca(end - eq + 1);
|
||||
memcpy(ret, eq, end - eq);
|
||||
|
|
|
@ -810,16 +810,16 @@ efreet_mime_glob_remove(const char *glob)
|
|||
}
|
||||
|
||||
static inline const char *
|
||||
efreet_eat_space(const char *head, const Eina_File_Lines *ln, Eina_Bool not)
|
||||
efreet_eat_space(const char *head, const Eina_File_Line *ln, Eina_Bool not)
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
while (!isspace(*head) && (head < ln->line.end))
|
||||
while (!isspace(*head) && (head < ln->end))
|
||||
head++;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (isspace(*head) && (head < ln->line.end))
|
||||
while (isspace(*head) && (head < ln->end))
|
||||
head++;
|
||||
}
|
||||
|
||||
|
@ -839,7 +839,7 @@ efreet_eat_space(const char *head, const Eina_File_Lines *ln, Eina_Bool not)
|
|||
static void
|
||||
efreet_mime_mime_types_load(const char *file)
|
||||
{
|
||||
const Eina_File_Lines *ln;
|
||||
const Eina_File_Line *ln;
|
||||
Eina_Iterator *it;
|
||||
Eina_File *f;
|
||||
const char *head_line;
|
||||
|
@ -858,20 +858,20 @@ efreet_mime_mime_types_load(const char *file)
|
|||
|
||||
EINA_ITERATOR_FOREACH(it, ln)
|
||||
{
|
||||
head_line = efreet_eat_space(ln->line.start, ln, EINA_FALSE);
|
||||
if (head_line == ln->line.end) continue ;
|
||||
head_line = efreet_eat_space(ln->start, ln, EINA_FALSE);
|
||||
if (head_line == ln->end) continue ;
|
||||
|
||||
if (*head_line == '#') continue ;
|
||||
|
||||
word_start = head_line;
|
||||
head_line = efreet_eat_space(head_line, ln, EINA_TRUE);
|
||||
|
||||
if (head_line == ln->line.end) continue ;
|
||||
if (head_line == ln->end) continue ;
|
||||
mimetype = eina_stringshare_add_length(word_start, head_line - word_start);
|
||||
do
|
||||
{
|
||||
head_line = efreet_eat_space(head_line, ln, EINA_FALSE);
|
||||
if (head_line == ln->line.end) break ;
|
||||
if (head_line == ln->end) break ;
|
||||
|
||||
word_start = head_line;
|
||||
head_line = efreet_eat_space(head_line, ln, EINA_TRUE);
|
||||
|
@ -887,7 +887,7 @@ efreet_mime_mime_types_load(const char *file)
|
|||
|
||||
eina_strbuf_reset(ext);
|
||||
}
|
||||
while (head_line < ln->line.end);
|
||||
while (head_line < ln->end);
|
||||
|
||||
eina_stringshare_del(mimetype);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ typedef struct _Eina_Stat Eina_Stat;
|
|||
* @typedef Eina_File_Lines
|
||||
* A typedef to #_Eina_File_Lines.
|
||||
*/
|
||||
typedef struct _Eina_File_Lines Eina_File_Lines;
|
||||
typedef struct _Eina_File_Line Eina_File_Line;
|
||||
|
||||
/**
|
||||
* @typedef Eina_File_Dir_List_Cb
|
||||
|
@ -195,17 +195,15 @@ struct _Eina_Stat
|
|||
};
|
||||
|
||||
/**
|
||||
* @struct _Eina_File_Lines
|
||||
* @struct _Eina_File_Line
|
||||
* A structure to store information of line
|
||||
* @since 1.3
|
||||
*/
|
||||
struct _Eina_File_Lines
|
||||
struct _Eina_File_Line
|
||||
{
|
||||
struct {
|
||||
const char *start;
|
||||
const char *end;
|
||||
unsigned int index;
|
||||
} line;
|
||||
const char *start;
|
||||
const char *end;
|
||||
unsigned int index;
|
||||
unsigned long long length;
|
||||
};
|
||||
|
||||
|
|
|
@ -1137,7 +1137,7 @@ struct _Eina_Lines_Iterator
|
|||
|
||||
int boundary;
|
||||
|
||||
Eina_File_Lines current;
|
||||
Eina_File_Line current;
|
||||
};
|
||||
|
||||
/* 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)
|
|||
const char *eol;
|
||||
unsigned char match;
|
||||
|
||||
if (it->current.line.end >= it->end)
|
||||
if (it->current.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)
|
||||
match = *it->current.end;
|
||||
while ((*it->current.end == '\n' || *it->current.end == '\r')
|
||||
&& it->current.end < it->end)
|
||||
{
|
||||
if (match == *it->current.line.end)
|
||||
it->current.line.index++;
|
||||
it->current.line.end++;
|
||||
if (match == *it->current.end)
|
||||
it->current.index++;
|
||||
it->current.end++;
|
||||
}
|
||||
it->current.line.index++;
|
||||
it->current.index++;
|
||||
|
||||
if (it->current.line.end == it->end)
|
||||
if (it->current.end == it->end)
|
||||
return EINA_FALSE;
|
||||
|
||||
eol = _eina_fine_eol(it->current.line.end,
|
||||
eol = _eina_fine_eol(it->current.end,
|
||||
it->boundary,
|
||||
it->end);
|
||||
it->boundary = (uintptr_t) eol & 0x3FF;
|
||||
if (it->boundary == 0) it->boundary = 4096;
|
||||
|
||||
it->current.line.start = it->current.line.end;
|
||||
it->current.start = it->current.end;
|
||||
|
||||
it->current.line.end = eol;
|
||||
it->current.length = eol - it->current.line.start - 1;
|
||||
it->current.end = eol;
|
||||
it->current.length = eol - it->current.start - 1;
|
||||
|
||||
*data = &it->current;
|
||||
return EINA_TRUE;
|
||||
|
@ -1251,9 +1251,9 @@ eina_file_map_lines(Eina_File *file)
|
|||
|
||||
it->fp = 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.start = it->map;
|
||||
it->current.end = it->current.start;
|
||||
it->current.index = 0;
|
||||
it->current.length = 0;
|
||||
it->end = it->map + it->fp->length;
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ struct _Eina_Lines_Iterator
|
|||
|
||||
int boundary;
|
||||
|
||||
Eina_File_Lines current;
|
||||
Eina_File_Line current;
|
||||
};
|
||||
|
||||
struct _Eina_File_Direct_Iterator
|
||||
|
@ -612,32 +612,32 @@ _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)
|
||||
if (it->current.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)
|
||||
match = *it->current.end;
|
||||
while ((*it->current.end == '\n' || *it->current.end == '\r')
|
||||
&& it->current.end < it->end)
|
||||
{
|
||||
if (match == *it->current.line.end)
|
||||
it->current.line.index++;
|
||||
it->current.line.end++;
|
||||
if (match == *it->current.end)
|
||||
it->current.index++;
|
||||
it->current.end++;
|
||||
}
|
||||
it->current.line.index++;
|
||||
it->current.index++;
|
||||
|
||||
if (it->current.line.end == it->end)
|
||||
if (it->current.end == it->end)
|
||||
return EINA_FALSE;
|
||||
|
||||
eol = _eina_fine_eol(it->current.line.end,
|
||||
eol = _eina_fine_eol(it->current.end,
|
||||
it->boundary,
|
||||
it->end);
|
||||
it->boundary = (uintptr_t) eol & 0x3FF;
|
||||
if (it->boundary == 0) it->boundary = 4096;
|
||||
|
||||
it->current.line.start = it->current.line.end;
|
||||
it->current.start = it->current.end;
|
||||
|
||||
it->current.line.end = eol;
|
||||
it->current.length = eol - it->current.line.start - 1;
|
||||
it->current.end = eol;
|
||||
it->current.length = eol - it->current.start - 1;
|
||||
|
||||
*data = &it->current;
|
||||
return EINA_TRUE;
|
||||
|
@ -1187,9 +1187,9 @@ eina_file_map_lines(Eina_File *file)
|
|||
|
||||
it->fp = 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.start = it->map;
|
||||
it->current.end = it->current.start;
|
||||
it->current.index = 0;
|
||||
it->current.length = 0;
|
||||
it->end = it->map + it->fp->length;
|
||||
|
||||
|
|
Loading…
Reference in New Issue