mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-01 03:25:29 +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 *e = NULL;
|
||||
struct edit **last = &e;
|
||||
struct edit *edits = NULL, *e;
|
||||
struct edit **last = &edits;
|
||||
const char *start;
|
||||
int have_text = 0;
|
||||
char *end;
|
||||
@ -187,12 +187,13 @@ struct edit *text2edit(const char *s)
|
||||
if (*s == '\n' && !have_text)
|
||||
continue;
|
||||
|
||||
*last = malloc(sizeof(struct edit));
|
||||
if (!*last)
|
||||
e = malloc(sizeof(struct edit));
|
||||
if (!e)
|
||||
abort();
|
||||
(*last)->type = edit_nl; /* pick something without data */
|
||||
(*last)->next = NULL;
|
||||
last = &(*last)->next;
|
||||
e->type = edit_nl; /* pick something without data */
|
||||
e->next = NULL;
|
||||
*last = e;
|
||||
last = &e->next;
|
||||
|
||||
if (*s == '\n')
|
||||
continue;
|
||||
@ -238,7 +239,7 @@ struct edit *text2edit(const char *s)
|
||||
}
|
||||
if (s != start)
|
||||
add_string(&last, start, s-start);
|
||||
return e;
|
||||
return edits;
|
||||
|
||||
fail:
|
||||
free_edit(e);
|
||||
|
Loading…
Reference in New Issue
Block a user