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_branch_reviewer_remove(change::pointer cp,string_ty * usrnam)27 change_branch_reviewer_remove(change::pointer cp, string_ty *usrnam)
28 {
29     cstate_ty       *cstate_data;
30     cstate_branch_reviewer_list_ty *lp;
31     size_t              j;
32 
33     trace(("change_branch_reviewer_remove(cp = %p, "
34         "usrnam = \"%s\")\n{\n", cp, usrnam->str_text));
35     cstate_data = cp->cstate_get();
36     assert(cstate_data->branch);
37     if (!cstate_data->branch->reviewer)
38     {
39         cstate_data->branch->reviewer =
40             (cstate_branch_reviewer_list_ty *)
41             cstate_branch_reviewer_list_type.alloc();
42     }
43     lp = cstate_data->branch->reviewer;
44 
45     //
46     // Remove the name from the list, if it is on the list.
47     // Be conservative, look for duplicates.
48     //
49     for (j = 0; j < lp->length; ++j)
50     {
51         if (str_equal(usrnam, lp->list[j]))
52         {
53             size_t              k;
54 
55             str_free(lp->list[j]);
56             for (k = j + 1; k < lp->length; ++k)
57                 lp->list[k - 1] = lp->list[k];
58             lp->length--;
59             j--;
60         }
61     }
62     trace(("}\n"));
63 }
64 
65 
66 // vim: set ts=8 sw=4 et :
67