Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | extern int | - |
4 | pcre16_get_stringnumber(const pcre16 *code, const unsigned short * stringname) | - |
5 | | - |
6 | { | - |
7 | int rc; | - |
8 | int entrysize; | - |
9 | int top, bot; | - |
10 | pcre_uchar *nametable; | - |
11 | if ((rc = pcre16_fullinfo(code, ((void *)0), 8, &top)) != 0) partially evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 8, &top)) != 0 no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
12 | return rc; never executed: return rc; | 0 |
13 | if (top <= 0) return (-7); never executed: return (-7); partially evaluated: top <= 0 no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
14 | | - |
15 | if ((rc = pcre16_fullinfo(code, ((void *)0), 7, &entrysize)) != 0) partially evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 7, &entrysize)) != 0 no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
16 | return rc; never executed: return rc; | 0 |
17 | if ((rc = pcre16_fullinfo(code, ((void *)0), 9, &nametable)) != 0) partially evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 9, &nametable)) != 0 no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
18 | return rc; never executed: return rc; | 0 |
19 | | - |
20 | | - |
21 | bot = 0; | - |
22 | while (top > bot) evaluated: top > bot yes Evaluation Count:17 | yes Evaluation Count:6 |
| 6-17 |
23 | { | - |
24 | int mid = (top + bot) / 2; | - |
25 | pcre_uchar *entry = nametable + entrysize*mid; | - |
26 | int c = _pcre16_strcmp_uc_uc(((pcre_uchar *)stringname), ((pcre_uchar *)(entry + 1))); | - |
27 | | - |
28 | if (c == 0) return entry[0]; executed: return entry[0]; Execution Count:6 evaluated: c == 0 yes Evaluation Count:6 | yes Evaluation Count:11 |
| 6-11 |
29 | if (c > 0) bot = mid + 1; else top = mid; executed: bot = mid + 1; Execution Count:6 executed: top = mid; Execution Count:5 evaluated: c > 0 yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
30 | } | - |
31 | | - |
32 | return (-7); executed: return (-7); Execution Count:6 | 6 |
33 | } | - |
34 | extern int | - |
35 | pcre16_get_stringtable_entries(const pcre16 *code, const unsigned short * stringname, | - |
36 | unsigned short **firstptr, unsigned short **lastptr) | - |
37 | | - |
38 | { | - |
39 | int rc; | - |
40 | int entrysize; | - |
41 | int top, bot; | - |
42 | pcre_uchar *nametable, *lastentry; | - |
43 | if ((rc = pcre16_fullinfo(code, ((void *)0), 8, &top)) != 0) never evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 8, &top)) != 0 | 0 |
44 | return rc; never executed: return rc; | 0 |
45 | if (top <= 0) return (-7); never evaluated: top <= 0 never executed: return (-7); | 0 |
46 | | - |
47 | if ((rc = pcre16_fullinfo(code, ((void *)0), 7, &entrysize)) != 0) never evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 7, &entrysize)) != 0 | 0 |
48 | return rc; never executed: return rc; | 0 |
49 | if ((rc = pcre16_fullinfo(code, ((void *)0), 9, &nametable)) != 0) never evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 9, &nametable)) != 0 | 0 |
50 | return rc; never executed: return rc; | 0 |
51 | | - |
52 | | - |
53 | lastentry = nametable + entrysize * (top - 1); | - |
54 | bot = 0; | - |
55 | while (top > bot) never evaluated: top > bot | 0 |
56 | { | - |
57 | int mid = (top + bot) / 2; | - |
58 | pcre_uchar *entry = nametable + entrysize*mid; | - |
59 | int c = _pcre16_strcmp_uc_uc(((pcre_uchar *)stringname), ((pcre_uchar *)(entry + 1))); | - |
60 | | - |
61 | if (c == 0) | 0 |
62 | { | - |
63 | pcre_uchar *first = entry; | - |
64 | pcre_uchar *last = entry; | - |
65 | while (first > nametable) never evaluated: first > nametable | 0 |
66 | { | - |
67 | if (_pcre16_strcmp_uc_uc(((pcre_uchar *)stringname), ((pcre_uchar *)(first - entrysize + 1))) != 0) break; never evaluated: _pcre16_strcmp_uc_uc(((pcre_uchar *)stringname), ((pcre_uchar *)(first - entrysize + 1))) != 0 | 0 |
68 | | - |
69 | first -= entrysize; | - |
70 | } | 0 |
71 | while (last < lastentry) never evaluated: last < lastentry | 0 |
72 | { | - |
73 | if (_pcre16_strcmp_uc_uc(((pcre_uchar *)stringname), ((pcre_uchar *)(last + entrysize + 1))) != 0) break; never evaluated: _pcre16_strcmp_uc_uc(((pcre_uchar *)stringname), ((pcre_uchar *)(last + entrysize + 1))) != 0 | 0 |
74 | | - |
75 | last += entrysize; | - |
76 | } | 0 |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | *firstptr = (unsigned short *)first; | - |
82 | *lastptr = (unsigned short *)last; | - |
83 | | - |
84 | return entrysize; never executed: return entrysize; | 0 |
85 | } | - |
86 | if (c > 0) bot = mid + 1; else top = mid; never executed: bot = mid + 1; never executed: top = mid; | 0 |
87 | } | - |
88 | | - |
89 | return (-7); never executed: return (-7); | 0 |
90 | } | - |
91 | static int | - |
92 | get_first_set(const pcre16 *code, const unsigned short * stringname, int *ovector) | - |
93 | | - |
94 | { | - |
95 | const real_pcre16 *re = (const real_pcre16 *)code; | - |
96 | int entrysize; | - |
97 | pcre_uchar *entry; | - |
98 | | - |
99 | | - |
100 | | - |
101 | unsigned short *first, *last; | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | if ((re->options & 0x00080000) == 0 && (re->flags & 0x0400) == 0) never evaluated: (re->options & 0x00080000) == 0 never evaluated: (re->flags & 0x0400) == 0 | 0 |
110 | return pcre16_get_stringnumber(code, stringname); never executed: return pcre16_get_stringnumber(code, stringname); | 0 |
111 | entrysize = pcre16_get_stringtable_entries(code, stringname, &first, &last); | - |
112 | | - |
113 | if (entrysize <= 0) return entrysize; never executed: return entrysize; never evaluated: entrysize <= 0 | 0 |
114 | for (entry = (pcre_uchar *)first; entry <= (pcre_uchar *)last; entry += entrysize) never evaluated: entry <= (pcre_uchar *)last | 0 |
115 | { | - |
116 | int n = entry[0]; | - |
117 | if (ovector[n*2] >= 0) return n; never executed: return n; never evaluated: ovector[n*2] >= 0 | 0 |
118 | } | 0 |
119 | return entry[0]; never executed: return entry[0]; | 0 |
120 | } | - |
121 | extern int | - |
122 | pcre16_copy_substring(const unsigned short * subject, int *ovector, int stringcount, | - |
123 | int stringnumber, unsigned short *buffer, int size) | - |
124 | | - |
125 | { | - |
126 | int yield; | - |
127 | if (stringnumber < 0 || stringnumber >= stringcount) never evaluated: stringnumber < 0 never evaluated: stringnumber >= stringcount | 0 |
128 | return (-7); never executed: return (-7); | 0 |
129 | stringnumber *= 2; | - |
130 | yield = ovector[stringnumber+1] - ovector[stringnumber]; | - |
131 | if (size < yield + 1) return (-6); never executed: return (-6); never evaluated: size < yield + 1 | 0 |
132 | memcpy(buffer, subject + ovector[stringnumber], ((yield) << 1)); | - |
133 | buffer[yield] = 0; | - |
134 | return yield; never executed: return yield; | 0 |
135 | } | - |
136 | extern int | - |
137 | pcre16_copy_named_substring(const pcre16 *code, const unsigned short * subject, | - |
138 | int *ovector, int stringcount, const unsigned short * stringname, | - |
139 | unsigned short *buffer, int size) | - |
140 | | - |
141 | { | - |
142 | int n = get_first_set(code, stringname, ovector); | - |
143 | if (n <= 0) return n; never executed: return n; | 0 |
144 | | - |
145 | | - |
146 | | - |
147 | return pcre16_copy_substring(subject, ovector, stringcount, n, buffer, size); never executed: return pcre16_copy_substring(subject, ovector, stringcount, n, buffer, size); | 0 |
148 | | - |
149 | } | - |
150 | extern int | - |
151 | pcre16_get_substring_list(const unsigned short * subject, int *ovector, int stringcount, | - |
152 | const unsigned short * **listptr) | - |
153 | | - |
154 | { | - |
155 | int i; | - |
156 | int size = sizeof(pcre_uchar *); | - |
157 | int double_count = stringcount * 2; | - |
158 | pcre_uchar **stringlist; | - |
159 | pcre_uchar *p; | - |
160 | | - |
161 | for (i = 0; i < double_count; i += 2) never evaluated: i < double_count | 0 |
162 | size += sizeof(pcre_uchar *) + ((ovector[i+1] - ovector[i] + 1) << 1); never executed: size += sizeof(pcre_uchar *) + ((ovector[i+1] - ovector[i] + 1) << 1); | 0 |
163 | | - |
164 | stringlist = (pcre_uchar **)(pcre16_malloc)(size); | - |
165 | if (stringlist == ((void *)0)) return (-6); never executed: return (-6); never evaluated: stringlist == ((void *)0) | 0 |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | *listptr = (const unsigned short * *)stringlist; | - |
171 | | - |
172 | p = (pcre_uchar *)(stringlist + stringcount + 1); | - |
173 | | - |
174 | for (i = 0; i < double_count; i += 2) never evaluated: i < double_count | 0 |
175 | { | - |
176 | int len = ovector[i+1] - ovector[i]; | - |
177 | memcpy(p, subject + ovector[i], ((len) << 1)); | - |
178 | *stringlist++ = p; | - |
179 | p += len; | - |
180 | *p++ = 0; | - |
181 | } | 0 |
182 | | - |
183 | *stringlist = ((void *)0); | - |
184 | return 0; never executed: return 0; | 0 |
185 | } | - |
186 | extern void | - |
187 | pcre16_free_substring_list(const unsigned short * *pointer) | - |
188 | | - |
189 | { | - |
190 | (pcre16_free)((void *)pointer); | - |
191 | } | 0 |
192 | extern int | - |
193 | pcre16_get_substring(const unsigned short * subject, int *ovector, int stringcount, | - |
194 | int stringnumber, const unsigned short * *stringptr) | - |
195 | | - |
196 | { | - |
197 | int yield; | - |
198 | pcre_uchar *substring; | - |
199 | if (stringnumber < 0 || stringnumber >= stringcount) never evaluated: stringnumber < 0 never evaluated: stringnumber >= stringcount | 0 |
200 | return (-7); never executed: return (-7); | 0 |
201 | stringnumber *= 2; | - |
202 | yield = ovector[stringnumber+1] - ovector[stringnumber]; | - |
203 | substring = (pcre_uchar *)(pcre16_malloc)(((yield + 1) << 1)); | - |
204 | if (substring == ((void *)0)) return (-6); never executed: return (-6); never evaluated: substring == ((void *)0) | 0 |
205 | memcpy(substring, subject + ovector[stringnumber], ((yield) << 1)); | - |
206 | substring[yield] = 0; | - |
207 | | - |
208 | | - |
209 | | - |
210 | *stringptr = (const unsigned short *)substring; | - |
211 | | - |
212 | return yield; never executed: return yield; | 0 |
213 | } | - |
214 | extern int | - |
215 | pcre16_get_named_substring(const pcre16 *code, const unsigned short * subject, | - |
216 | int *ovector, int stringcount, const unsigned short * stringname, | - |
217 | const unsigned short * *stringptr) | - |
218 | | - |
219 | { | - |
220 | int n = get_first_set(code, stringname, ovector); | - |
221 | if (n <= 0) return n; never executed: return n; | 0 |
222 | | - |
223 | | - |
224 | | - |
225 | return pcre16_get_substring(subject, ovector, stringcount, n, stringptr); never executed: return pcre16_get_substring(subject, ovector, stringcount, n, stringptr); | 0 |
226 | | - |
227 | } | - |
228 | extern void | - |
229 | pcre16_free_substring(const unsigned short * pointer) | - |
230 | | - |
231 | { | - |
232 | (pcre16_free)((void *)pointer); | - |
233 | } | 0 |
234 | | - |
| | |