2 $Header: /cvs/src/tdl/remove.c,v 1.5.2.1 2004/01/07 00:09:05 richard Exp $
4 tdl - A console program for managing to-do lists
5 Copyright (C) 2001-2004 Richard P. Curnow
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25 static void delete_from_bottom_up(struct links *x)/*{{{*/
28 for (y = x->next; y != (struct node *) x; y = ny) {
30 /* Calculate this now in case y gets deleted later */
34 delete_from_bottom_up(&y->kids);
39 fprintf(stderr, "Cannot delete %s, it has sub-tasks\n", y->scratch);
41 /* Just unlink from the chain for now, don't bother about full clean up. */
42 struct node *next, *prev;
45 prev->chain.next = next;
46 next->chain.prev = prev;
54 int process_remove(char **x)/*{{{*/
62 do_descendents = include_descendents(*x); /* May modify *x */
63 n = lookup_node(*x, 0, NULL);
67 mark_all_descendents(n);
69 n->scratch = *x; /* *x has long lifetime => OK to alias */
73 delete_from_bottom_up(&top);