1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-01 07:17:31 +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:
Werner Almesberger 2012-06-30 13:14:57 -03:00
parent ccc27577cb
commit 5e94179a29

View File

@ -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);