1 //
2 //      aegis - project change supervisor
3 //      Copyright (C) 2001-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_branch_change_remove(change::pointer cp,long change_number)27 change_branch_change_remove(change::pointer cp, long change_number)
28 {
29     cstate_ty       *cstate_data;
30     cstate_branch_change_list_ty *lp;
31     size_t          j;
32 
33     trace(("change_branch_change_remove(cp = %p, change_number = %ld)\n{\n",
34         cp, change_number));
35     cstate_data = cp->cstate_get();
36     assert(cstate_data->branch);
37     if (!cstate_data->branch->change)
38     {
39         cstate_data->branch->change =
40             (cstate_branch_change_list_ty *)
41             cstate_branch_change_list_type.alloc();
42     }
43 
44     //
45     // Remove the name from the list, if it is on the list.
46     // Be conservative, look for duplicates.
47     //
48     lp = cstate_data->branch->change;
49     for (j = 0; j < lp->length; ++j)
50     {
51         if (change_number == lp->list[j])
52         {
53             size_t          k;
54 
55             for (k = j + 1; k < lp->length; ++k)
56                 lp->list[k - 1] = lp->list[k];
57             lp->length--;
58             j--;
59         }
60     }
61 
62     if (cstate_data->branch->sub_branch)
63     {
64         cstate_branch_sub_branch_list_ty *lp2;
65 
66         //
67         // Remove the name from the list, if it is on the list.
68         // Be conservative, look for duplicates.
69         //
70         lp2 = cstate_data->branch->sub_branch;
71         for (j = 0; j < lp2->length; ++j)
72         {
73             if (change_number == lp2->list[j])
74             {
75                 size_t          k;
76 
77                 for (k = j + 1; k < lp2->length; ++k)
78                     lp2->list[k - 1] = lp2->list[k];
79                 lp2->length--;
80                 j--;
81             }
82         }
83     }
84     trace(("}\n"));
85 }
86 
87 
88 // vim: set ts=8 sw=4 et :
89