1 //
2 //	aegis - project change supervisor
3 //	Copyright (C) 1999, 2003-2008 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 <libaegis/change.h>
21 #include <libaegis/project.h>
22 #include <libaegis/sub.h>
23 
24 
25 void
change_error(change::pointer cp,sub_context_ty * scp,const char * s)26 change_error(change::pointer cp, sub_context_ty *scp, const char *s)
27 {
28     string_ty       *msg;
29     int             need_to_delete;
30 
31     if (!scp)
32     {
33 	scp = sub_context_new();
34 	need_to_delete = 1;
35     }
36     else
37 	need_to_delete = 0;
38 
39     //
40     // asemble the message
41     //
42     subst_intl_change(scp, cp);
43     msg = subst_intl(scp, s);
44 
45     //
46     // get ready to pass the message to the project error function
47     //
48     // re-use substitution context
49     sub_var_set_string(scp, "MeSsaGe", msg);
50     str_free(msg);
51 
52     //
53     // the form of the project error message depends on what kind of
54     // change this is
55     //
56     if (cp->bogus)
57 	project_error(cp->pp, scp, i18n("$message"));
58     else if (cp->number == TRUNK_CHANGE_NUMBER)
59 	project_error(cp->pp, scp, i18n("trunk: $message"));
60     else
61     {
62 	subst_intl_change(scp, cp);
63 	project_error(cp->pp, scp, i18n("change $change: $message"));
64     }
65 
66     if (need_to_delete)
67 	sub_context_delete(scp);
68 }
69