1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2001, 2003-2008, 2012 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19
20 #include <common/ac/assert.h>
21
22 #include <common/trace.h>
23 #include <libaegis/change/branch.h>
24
25
26 void
change_history_delta_name_delete(change::pointer cp,string_ty * delta_name)27 change_history_delta_name_delete(change::pointer cp, string_ty *delta_name)
28 {
29 cstate_ty *cstate_data;
30 cstate_branch_history_list_ty *h;
31 size_t j;
32
33 trace(("change_history_delta_name_delete(cp = %p, "
34 "delta_name = \"%s\")\n{\n", cp, delta_name->str_text));
35 cstate_data = cp->cstate_get();
36 assert(cstate_data->branch);
37 h = cstate_data->branch->history;
38 assert(h);
39 assert(h->length);
40 for (j = 0; j < h->length; ++j)
41 {
42 cstate_branch_history_ty *he;
43 cstate_branch_history_name_list_ty *nlp;
44 size_t k, m;
45
46 he = h->list[j];
47 nlp = he->name;
48 if (!nlp || !nlp->length)
49 continue;
50 for (k = 0; k < nlp->length; ++k)
51 {
52 if (!str_equal(nlp->list[k], delta_name))
53 continue;
54
55 //
56 // remove the name from the list
57 //
58 str_free(nlp->list[k]);
59 for (m = k + 1; m < nlp->length; ++m)
60 nlp->list[m - 1] = nlp->list[m];
61 k--;
62
63 nlp->length--;
64 if (nlp->length == 0)
65 {
66 he->name = 0;
67 cstate_branch_history_name_list_type.free(nlp);
68 break;
69 }
70 }
71 }
72 trace(("}\n"));
73 }
74
75
76 // vim: set ts=8 sw=4 et :
77