introduce line_nconc()

This commit is contained in:
rlar 2016-08-31 20:01:19 +02:00
parent 17a8faf1bb
commit 93531c2488
2 changed files with 19 additions and 0 deletions

View File

@ -295,6 +295,23 @@ line_free_x(struct line *deck, bool recurse)
}
}
/* concatenate two lists, destructively altering the first one */
struct line *
line_nconc(struct line *head, struct line *rest)
{
struct line *p = head;
if (!rest)
return head;
if (!head)
return rest;
while (p->li_next)
p = p->li_next;
p->li_next = rest;
return head;
}
/* reverse the linked list struct line */
struct line *
line_reverse(struct line *head)

View File

@ -214,6 +214,8 @@ extern void inp_list(FILE *file, struct line *deck, struct line *extras, int typ
extern struct line *inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile);
extern FILE *inp_pathopen(char *name, char *mode);
extern char *search_identifier(char *str, const char *identifier, char *str_begin);
extern struct line *line_nconc(struct line *head, struct line *rest);
extern struct line *line_reverse(struct line *head);
extern void mc_free(void);
void eval_seed_opt(struct line *deck);