1 /*
2 Copyright (c) 2005-2013 uim Project https://github.com/uim/uim
3
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or
7 without modification, are permitted provided that the
8 following conditions are met:
9
10 1. Redistributions of source code must retain the above
11 copyright notice, this list of conditions and the
12 following disclaimer.
13 2. Redistributions in binary form must reproduce the above
14 copyright notice, this list of conditions and the
15 following disclaimer in the documentation and/or other
16 materials provided with the distribution.
17 3. Neither the name of authors nor the names of its
18 contributors may be used to endorse or promote products
19 derived from this software without specific prior written
20 permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #include "commit.h"
38
39 char *
add_commit_string(char * comstr,const char * str)40 add_commit_string(char *comstr, const char *str)
41 {
42 int buflen;
43
44 debug_printf(DEBUG_NOTE,
45 "add_commit_string str: %s\n", str);
46
47 buflen = (comstr != (char *)NULL) ? strlen(comstr) : 0;
48
49 if (str != (const char *)NULL) {
50
51 debug_printf(DEBUG_NOTE,
52 "add_commit_string comstr: len:%d (%p)\n",
53 buflen + strlen(str) + 1, comstr);
54
55 comstr = uim_realloc(comstr, buflen + strlen(str) + 1);
56 comstr[buflen] = '\0';
57
58 debug_printf(DEBUG_NOTE,
59 "add_commit_string comstr: %s (%p)\n", comstr, comstr);
60
61 strlcat(comstr, str, buflen + strlen(str) + 1);
62 }
63
64 debug_printf(DEBUG_NOTE,
65 "add_commit_string comstr: %s (%p)\n", comstr, comstr);
66
67 return comstr;
68 }
69
70
71 int
show_commit_string(char * comstr)72 show_commit_string(char *comstr)
73 {
74 if (!comstr) return -1;
75
76 a_printf("( s ");
77 output_with_escape(comstr);
78 a_printf(" ) ");
79 return 1;
80 }
81
82
83 void
reset_commit_string(char * comstr)84 reset_commit_string(char *comstr)
85 {
86 debug_printf(DEBUG_NOTE,
87 "reset_commit_string comstr: %p\n", comstr);
88
89 free(comstr);
90 }
91
92