mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-01 07:24:58 +02:00
tools/libtxt/edit.c (text2edit): disentangle confused logic of "e" variable
We used it for the whole list and the current element, which didn't work very well.
This commit is contained in:
parent
ccc27577cb
commit
5e94179a29
@ -168,8 +168,8 @@ static int parse_coord(struct edit *e, const char *s,
|
|||||||
|
|
||||||
struct edit *text2edit(const char *s)
|
struct edit *text2edit(const char *s)
|
||||||
{
|
{
|
||||||
struct edit *e = NULL;
|
struct edit *edits = NULL, *e;
|
||||||
struct edit **last = &e;
|
struct edit **last = &edits;
|
||||||
const char *start;
|
const char *start;
|
||||||
int have_text = 0;
|
int have_text = 0;
|
||||||
char *end;
|
char *end;
|
||||||
@ -187,12 +187,13 @@ struct edit *text2edit(const char *s)
|
|||||||
if (*s == '\n' && !have_text)
|
if (*s == '\n' && !have_text)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
*last = malloc(sizeof(struct edit));
|
e = malloc(sizeof(struct edit));
|
||||||
if (!*last)
|
if (!e)
|
||||||
abort();
|
abort();
|
||||||
(*last)->type = edit_nl; /* pick something without data */
|
e->type = edit_nl; /* pick something without data */
|
||||||
(*last)->next = NULL;
|
e->next = NULL;
|
||||||
last = &(*last)->next;
|
*last = e;
|
||||||
|
last = &e->next;
|
||||||
|
|
||||||
if (*s == '\n')
|
if (*s == '\n')
|
||||||
continue;
|
continue;
|
||||||
@ -238,7 +239,7 @@ struct edit *text2edit(const char *s)
|
|||||||
}
|
}
|
||||||
if (s != start)
|
if (s != start)
|
||||||
add_string(&last, start, s-start);
|
add_string(&last, start, s-start);
|
||||||
return e;
|
return edits;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
free_edit(e);
|
free_edit(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user