Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/lib/sh/shquote.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
11 | extern char *ansic_quote (char *, int, int *); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
12 | extern int ansic_shouldquote (const char *); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 | static const char bstab[256] = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
16 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
17 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
18 | 0, 1, 1, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
19 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
20 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
22 | 1, 1, 1, 0, 1, 0, 1, 1, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
23 | 1, 1, 1, 0, 1, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
24 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
25 | 0, 0, 0, 1, 1, 0, 1, 1, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
27 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
28 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
29 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
30 | 0, 0, 0, 1, 1, 1, 1, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
32 | 1, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
34 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
35 | 0, 0, 0, 1, 1, 1, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
37 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
38 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
39 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
40 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
42 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
43 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
44 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
45 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
46 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
47 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
48 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
49 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
50 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
52 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
53 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
54 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
55 | 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
56 | }; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
57 | char * | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
58 | sh_single_quote (string) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
59 | const char *string; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
60 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
61 | register int c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
62 | char *result, *r; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
63 | const char *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
65 | result = (char *)sh_xmalloc((3 + (4 * strlen (string))), "shquote.c", 102); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
66 | r = result; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
68 | if (string[0] == '\''
| 7-2948 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
69 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
70 | *r++ = '\\'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | *r++ = '\''; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
72 | *r++ = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
73 | return executed 15 times by 1 test: result;return result; Executed by:
executed 15 times by 1 test: return result; Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
74 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
76 | *r++ = '\''; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
78 | for (s = string; s
| 0-13989 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
79 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
80 | *r++ = c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
82 | if (c == '\''
| 23-11011 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
83 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
84 | *r++ = '\\'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
85 | *r++ = '\''; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
86 | *r++ = '\''; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
87 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
88 | } executed 11034 times by 1 test: end of block Executed by:
| 11034 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
90 | *r++ = '\''; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
91 | *r = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
93 | return executed 2955 times by 1 test: (result);return (result); Executed by:
executed 2955 times by 1 test: return (result); Executed by:
| 2955 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
94 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
97 | char * | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
98 | sh_double_quote (string) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
99 | const char *string; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
100 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
101 | register unsigned char c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
102 | char *result, *r; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
103 | const char *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
105 | result = (char *)sh_xmalloc((3 + (2 * strlen (string))), "shquote.c", 142); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
106 | r = result; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
107 | *r++ = '"'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
109 | for (s = string; s
| 0-4669 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
110 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
112 | if ((
| 0-3618 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
113 | * executed 83 times by 1 test: r++ = '\\';*r++ = '\\'; Executed by:
executed 83 times by 1 test: *r++ = '\\'; Executed by:
| 83 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
115 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
120 | *r++ = c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
121 | } executed 3701 times by 1 test: end of block Executed by:
| 3701 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
123 | *r++ = '"'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
124 | *r = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
126 | return executed 968 times by 1 test: (result);return (result); Executed by:
executed 968 times by 1 test: return (result); Executed by:
| 968 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
127 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
131 | char * | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
132 | sh_mkdoublequoted (s, slen, flags) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
133 | const char *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
134 | int slen, flags; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
135 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
136 | char *r, *ret; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
137 | int rlen; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
139 | rlen = (
| 0-35 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
140 | ret = r = (char *)sh_xmalloc((rlen), "shquote.c", 177); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
142 | *r++ = '"'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
143 | while (*
| 35-290 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
144 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
145 | if (flags
| 0-290 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
146 | * never executed: r++ = '\\';*r++ = '\\'; never executed: *r++ = '\\'; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
147 | *r++ = *s++; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
148 | } executed 290 times by 1 test: end of block Executed by:
| 290 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
149 | *r++ = '"'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
150 | *r = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
152 | return executed 35 times by 1 test: ret;return ret; Executed by:
executed 35 times by 1 test: return ret; Executed by:
| 35 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
153 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
155 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
158 | char * | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
159 | sh_un_double_quote (string) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
160 | char *string; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
161 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
162 | register int c, pass_next; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
163 | char *result, *r, *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
165 | r = result = (char *)sh_xmalloc((strlen (string) + 1), "shquote.c", 202); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
167 | for (pass_next = 0, s = string; s
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
168 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
169 | if (pass_next
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
170 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
171 | *r++ = c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
172 | pass_next = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
173 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
174 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
175 | if (c == '\\'
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
176 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
177 | pass_next = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
178 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
179 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
180 | *r++ = c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
181 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
182 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
183 | *r = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
184 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
185 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
186 | char * | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
187 | sh_backslash_quote (string, table, flags) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
188 | char *string; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
189 | char *table; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
190 | int flags; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
191 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
192 | int c, mb_cur_max; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
193 | size_t slen; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
194 | char *result, *r, *s, *backslash_table, *send; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
195 | mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
197 | slen = strlen (string); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
198 | send = string + slen; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
199 | result = (char *)sh_xmalloc((2 * slen + 1), "shquote.c", 247); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
201 | backslash_table = table
| 0-541 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
202 | mb_cur_max = | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
203 | (__ctype_get_mb_cur_max ()) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
204 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
206 | for (r = result, s = string; s
| 0-3221 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
207 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
209 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
210 | if (c >= 0
| 0-2586 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
211 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
212 | *r++ = '\\'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
213 | *r++ = c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
214 | continue; executed 7 times by 1 test: continue; Executed by:
| 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
215 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
216 | if (mb_cur_max > 1
| 1-2578 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
217 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
218 | do { if (locale_mb_cur_max > 1
never executed: else if (locale_utf8localemblength = 1;
never executed: else { state_bak = state; mblength = mbrlen ((s), (send) - (s), &state); }mblength = 1; executed 94 times by 1 test: if (mblength == (size_t)-2end of block Executed by:
never executed: else mblength = (end of block
executed 94 times by 1 test: for (_k = 0; _k < mblengthmblength = (mblength < 1) ? 1 : mblength; Executed by:
executed 188 times by 1 test: r)++ = *(s)++;*(r)++ = *(s)++; Executed by:
executed 188 times by 1 test: }*(r)++ = *(s)++; Executed by:
executed 94 times by 1 test: else *(end of block Executed by:
never executed: r)++ = *(s)++;*(r)++ = *(s)++; never executed: } while (0);*(r)++ = *(s)++; | 0-188 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
219 | s--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
220 | continue; executed 94 times by 1 test: continue; Executed by:
| 94 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
221 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
223 | if (backslash_table[(unsigned char)c] == 1
| 0-2579 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
224 | * never executed: r++ = '\\';*r++ = '\\'; never executed: *r++ = '\\'; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
225 | else if (c == '#'
| 0-2579 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
226 | * never executed: r++ = '\\';*r++ = '\\'; never executed: *r++ = '\\'; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
227 | else if ((
| 0-2579 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
230 | * executed 1 time by 1 test: r++ = '\\';*r++ = '\\'; Executed by:
executed 1 time by 1 test: *r++ = '\\'; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
231 | else if ((
| 0-2578 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
232 | * never executed: r++ = '\\';*r++ = '\\'; never executed: *r++ = '\\'; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
233 | *r++ = c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
234 | } executed 2579 times by 1 test: end of block Executed by:
| 2579 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
236 | *r = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
237 | return executed 541 times by 1 test: (result);return (result); Executed by:
executed 541 times by 1 test: return (result); Executed by:
| 541 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
238 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
239 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
243 | char * | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
244 | sh_backslash_quote_for_double_quotes (string) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
245 | char *string; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
246 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
247 | unsigned char c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
248 | char *result, *r, *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
250 | result = (char *)sh_xmalloc((2 * strlen (string) + 1), "shquote.c", 296); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
251 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
252 | for (r = result, s = string; s
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
253 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
254 | if (sh_syntaxtab[c] & 0x0040
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
255 | * never executed: r++ = '\\';*r++ = '\\'; never executed: *r++ = '\\'; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
256 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
257 | else if (c == '\001'
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
258 | * never executed: r++ = '\001';*r++ = '\001'; never executed: *r++ = '\001'; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
259 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
260 | *r++ = c; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
261 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
263 | *r = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
264 | return never executed: (result);return (result); never executed: return (result); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
265 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
266 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
268 | char * | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
269 | sh_quote_reusable (s, flags) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
270 | char *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
271 | int flags; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
272 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
273 | char *ret; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
275 | if (s == 0
| 0-49 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
276 | return never executed: s;return s; never executed: return s; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
277 | else if (*
| 5-44 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
278 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
279 | ret = (char *)sh_xmalloc((3), "shquote.c", 325); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
280 | ret[0] = ret[1] = '\''; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
281 | ret[2] = '\0'; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
282 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
283 | else if (ansic_shouldquote (s)
| 3-41 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
284 | ret = ansic_quote (s, 0, (int *)0); executed 3 times by 1 test: ret = ansic_quote (s, 0, (int *)0); Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
285 | else if (flags
| 0-41 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
286 | ret = sh_backslash_quote (s, 0, 1); never executed: ret = sh_backslash_quote (s, 0, 1); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
287 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
288 | ret = sh_single_quote (s); executed 41 times by 1 test: ret = sh_single_quote (s); Executed by:
| 41 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
290 | return executed 49 times by 1 test: ret;return ret; Executed by:
executed 49 times by 1 test: return ret; Executed by:
| 49 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
291 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
293 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
294 | sh_contains_shell_metas (string) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
295 | const char *string; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
296 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
297 | const char *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
299 | for (s = string; s
| 0-6077 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
300 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
301 | switch (*s) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
302 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
303 | case executed 27 times by 1 test: ' ':case ' ': Executed by:
executed 27 times by 1 test: casecase ' ': Executed by:
never executed: '\t':case '\t': never executed: casecase '\t': never executed: '\n':case '\n': never executed: case '\n': | 0-27 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
304 | case executed 16 times by 1 test: '\'':case '\'': Executed by:
executed 16 times by 1 test: casecase '\'': Executed by:
executed 12 times by 1 test: '"':case '"': Executed by:
executed 12 times by 1 test: casecase '"': Executed by:
executed 6 times by 1 test: '\\':case '\\': Executed by:
executed 6 times by 1 test: case '\\': Executed by:
| 6-16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
305 | case never executed: '|':case '|': never executed: casecase '|': never executed: '&':case '&': never executed: casecase '&': never executed: ';':case ';': never executed: case ';': | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
306 | case executed 6 times by 1 test: '(':case '(': Executed by:
executed 6 times by 1 test: casecase '(': Executed by:
executed 1 time by 1 test: ')':case ')': Executed by:
executed 1 time by 1 test: casecase ')': Executed by:
never executed: '<':case '<': never executed: casecase '<': never executed: '>':case '>': never executed: case '>': | 0-6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
307 | case never executed: '!':case '!': never executed: casecase '!': never executed: '{':case '{': never executed: casecase '{': never executed: '}':case '}': never executed: case '}': | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
308 | case never executed: '*':case '*': never executed: casecase '*': executed 2 times by 1 test: '[':case '[': Executed by:
executed 2 times by 1 test: casecase '[': Executed by:
never executed: '?':case '?': never executed: casecase '?': executed 11 times by 1 test: ']':case ']': Executed by:
executed 11 times by 1 test: case ']': Executed by:
| 0-11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
309 | case never executed: '^':case '^': never executed: case '^': | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
310 | case executed 3 times by 1 test: '$':case '$': Executed by:
executed 3 times by 1 test: casecase '$': Executed by:
executed 6 times by 1 test: '`':case '`': Executed by:
executed 6 times by 1 test: case '`': Executed by:
| 3-6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
311 | return executed 90 times by 1 test: (1);return (1); Executed by:
executed 90 times by 1 test: return (1); Executed by:
| 90 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
312 | case executed 3 times by 1 test: '~':case '~': Executed by:
executed 3 times by 1 test: case '~': Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
313 | if (s == string
| 0-3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
314 | return executed 3 times by 1 test: (1);return (1); Executed by:
executed 3 times by 1 test: return (1); Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
315 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
316 | case executed 4 times by 1 test: '#':case '#': Executed by:
executed 4 times by 1 test: case '#': Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
317 | if (s == string
| 1-3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
318 | return executed 1 time by 1 test: (1);return (1); Executed by:
executed 1 time by 1 test: return (1); Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
319 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
320 | default executed 5542 times by 1 test: :default: Executed by:
executed 5542 times by 1 test: default: Executed by:
code before this statement executed 3 times by 1 test: default: Executed by:
| 3-5542 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
321 | break; executed 5542 times by 1 test: break; Executed by:
| 5542 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
322 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
323 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
325 | return executed 441 times by 1 test: (0);return (0); Executed by:
executed 441 times by 1 test: return (0); Executed by:
| 441 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
326 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
328 | int | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
329 | sh_contains_quotes (string) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
330 | const char *string; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
331 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
332 | const char *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
334 | for (s = string; s
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
335 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
336 | if (*
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
337 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
338 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
339 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
340 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |