../3rdparty/pcre/pcre_get.c

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3extern int -
4pcre16_get_stringnumber(const pcre16 *code, const unsigned short * stringname) -
5 -
6{ -
7int rc; -
8int entrysize; -
9int top, bot; -
10pcre_uchar *nametable; -
11if ((rc = pcre16_fullinfo(code, ((void *)0), 8, &top)) != 0)
partially evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 8, &top)) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
12 return rc;
never executed: return rc;
0
13if (top <= 0) return (-7);
never executed: return (-7);
partially evaluated: top <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
14 -
15if ((rc = pcre16_fullinfo(code, ((void *)0), 7, &entrysize)) != 0)
partially evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 7, &entrysize)) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
16 return rc;
never executed: return rc;
0
17if ((rc = pcre16_fullinfo(code, ((void *)0), 9, &nametable)) != 0)
partially evaluated: (rc = pcre16_fullinfo(code, ((void *)0), 9, &nametable)) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
18 return rc;
never executed: return rc;
0
19 -
20 -
21bot = 0; -
22while (top > bot)
evaluated: top > bot
TRUEFALSE
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
TRUEFALSE
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
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:5
5-6
30 } -
31 -
32return (-7);
executed: return (-7);
Execution Count:6
6
33} -
34extern int -
35pcre16_get_stringtable_entries(const pcre16 *code, const unsigned short * stringname, -
36 unsigned short **firstptr, unsigned short **lastptr) -
37 -
38{ -
39int rc; -
40int entrysize; -
41int top, bot; -
42pcre_uchar *nametable, *lastentry; -
43if ((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
45if (top <= 0) return (-7);
never evaluated: top <= 0
never executed: return (-7);
0
46 -
47if ((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
49if ((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 -
53lastentry = nametable + entrysize * (top - 1); -
54bot = 0; -
55while (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)
never evaluated: 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 executed: break;
never evaluated: _pcre16_strcmp_uc_uc(((pcre_uchar *)stringname), ((pcre_uchar *)(first - entrysize + 1))) != 0
0
68 -
69 first -= entrysize; -
70 }
never executed: }
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 executed: break;
never evaluated: _pcre16_strcmp_uc_uc(((pcre_uchar *)stringname), ((pcre_uchar *)(last + entrysize + 1))) != 0
0
74 -
75 last += entrysize; -
76 }
never executed: }
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;
never evaluated: c > 0
0
87 } -
88 -
89return (-7);
never executed: return (-7);
0
90} -
91static int -
92get_first_set(const pcre16 *code, const unsigned short * stringname, int *ovector) -
93 -
94{ -
95const real_pcre16 *re = (const real_pcre16 *)code; -
96int entrysize; -
97pcre_uchar *entry; -
98 -
99 -
100 -
101unsigned short *first, *last; -
102 -
103 -
104 -
105 -
106 -
107 -
108 -
109if ((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
111entrysize = pcre16_get_stringtable_entries(code, stringname, &first, &last); -
112 -
113if (entrysize <= 0) return entrysize;
never executed: return entrysize;
never evaluated: entrysize <= 0
0
114for (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 }
never executed: }
0
119return entry[0];
never executed: return entry[0];
0
120} -
121extern int -
122pcre16_copy_substring(const unsigned short * subject, int *ovector, int stringcount, -
123 int stringnumber, unsigned short *buffer, int size) -
124 -
125{ -
126int yield; -
127if (stringnumber < 0 || stringnumber >= stringcount)
never evaluated: stringnumber < 0
never evaluated: stringnumber >= stringcount
0
128 return (-7);
never executed: return (-7);
0
129stringnumber *= 2; -
130yield = ovector[stringnumber+1] - ovector[stringnumber]; -
131if (size < yield + 1) return (-6);
never executed: return (-6);
never evaluated: size < yield + 1
0
132memcpy(buffer, subject + ovector[stringnumber], ((yield) << 1)); -
133buffer[yield] = 0; -
134return yield;
never executed: return yield;
0
135} -
136extern int -
137pcre16_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{ -
142int n = get_first_set(code, stringname, ovector); -
143if (n <= 0) return n;
never executed: return n;
never evaluated: n <= 0
0
144 -
145 -
146 -
147return pcre16_copy_substring(subject, ovector, stringcount, n, buffer, size);
never executed: return pcre16_copy_substring(subject, ovector, stringcount, n, buffer, size);
0
148 -
149} -
150extern int -
151pcre16_get_substring_list(const unsigned short * subject, int *ovector, int stringcount, -
152 const unsigned short * **listptr) -
153 -
154{ -
155int i; -
156int size = sizeof(pcre_uchar *); -
157int double_count = stringcount * 2; -
158pcre_uchar **stringlist; -
159pcre_uchar *p; -
160 -
161for (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 -
164stringlist = (pcre_uchar **)(pcre16_malloc)(size); -
165if (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 -
172p = (pcre_uchar *)(stringlist + stringcount + 1); -
173 -
174for (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 }
never executed: }
0
182 -
183*stringlist = ((void *)0); -
184return 0;
never executed: return 0;
0
185} -
186extern void -
187pcre16_free_substring_list(const unsigned short * *pointer) -
188 -
189{ -
190(pcre16_free)((void *)pointer); -
191}
never executed: }
0
192extern int -
193pcre16_get_substring(const unsigned short * subject, int *ovector, int stringcount, -
194 int stringnumber, const unsigned short * *stringptr) -
195 -
196{ -
197int yield; -
198pcre_uchar *substring; -
199if (stringnumber < 0 || stringnumber >= stringcount)
never evaluated: stringnumber < 0
never evaluated: stringnumber >= stringcount
0
200 return (-7);
never executed: return (-7);
0
201stringnumber *= 2; -
202yield = ovector[stringnumber+1] - ovector[stringnumber]; -
203substring = (pcre_uchar *)(pcre16_malloc)(((yield + 1) << 1)); -
204if (substring == ((void *)0)) return (-6);
never executed: return (-6);
never evaluated: substring == ((void *)0)
0
205memcpy(substring, subject + ovector[stringnumber], ((yield) << 1)); -
206substring[yield] = 0; -
207 -
208 -
209 -
210*stringptr = (const unsigned short *)substring; -
211 -
212return yield;
never executed: return yield;
0
213} -
214extern int -
215pcre16_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{ -
220int n = get_first_set(code, stringname, ovector); -
221if (n <= 0) return n;
never executed: return n;
never evaluated: n <= 0
0
222 -
223 -
224 -
225return pcre16_get_substring(subject, ovector, stringcount, n, stringptr);
never executed: return pcre16_get_substring(subject, ovector, stringcount, n, stringptr);
0
226 -
227} -
228extern void -
229pcre16_free_substring(const unsigned short * pointer) -
230 -
231{ -
232(pcre16_free)((void *)pointer); -
233}
never executed: }
0
234 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial