/src/uriparser/src/UriShorten.c
Line | Count | Source |
1 | | /* |
2 | | * uriparser - RFC 3986 URI parsing library |
3 | | * |
4 | | * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> |
5 | | * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> |
6 | | * All rights reserved. |
7 | | * |
8 | | * Redistribution and use in source and binary forms, with or without |
9 | | * modification, are permitted provided that the following conditions |
10 | | * are met: |
11 | | * |
12 | | * 1. Redistributions of source code must retain the above |
13 | | * copyright notice, this list of conditions and the following |
14 | | * disclaimer. |
15 | | * |
16 | | * 2. Redistributions in binary form must reproduce the above |
17 | | * copyright notice, this list of conditions and the following |
18 | | * disclaimer in the documentation and/or other materials |
19 | | * provided with the distribution. |
20 | | * |
21 | | * 3. Neither the name of the copyright holder nor the names of |
22 | | * its contributors may be used to endorse or promote products |
23 | | * derived from this software without specific prior written |
24 | | * permission. |
25 | | * |
26 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
27 | | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
28 | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
29 | | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
30 | | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
31 | | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
32 | | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
33 | | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
34 | | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
35 | | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
36 | | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
37 | | * OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | | */ |
39 | | |
40 | | /* What encodings are enabled? */ |
41 | | #include <uriparser/UriDefsConfig.h> |
42 | | #if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) |
43 | | /* Include SELF twice */ |
44 | | # ifdef URI_ENABLE_ANSI |
45 | | # define URI_PASS_ANSI 1 |
46 | | # include "UriShorten.c" |
47 | | # undef URI_PASS_ANSI |
48 | | # endif |
49 | | # ifdef URI_ENABLE_UNICODE |
50 | | # define URI_PASS_UNICODE 1 |
51 | | # include "UriShorten.c" |
52 | | # undef URI_PASS_UNICODE |
53 | | # endif |
54 | | #else |
55 | | # ifdef URI_PASS_ANSI |
56 | | # include <uriparser/UriDefsAnsi.h> |
57 | | # else |
58 | | # include <uriparser/UriDefsUnicode.h> |
59 | | # include <wchar.h> |
60 | | # endif |
61 | | |
62 | | # ifndef URI_DOXYGEN |
63 | | # include <uriparser/Uri.h> |
64 | | # include "UriCommon.h" |
65 | | # include "UriMemory.h" |
66 | | # endif |
67 | | |
68 | | static URI_INLINE UriBool URI_FUNC(AppendSegment)(URI_TYPE(Uri) * uri, |
69 | | const URI_CHAR * first, |
70 | | const URI_CHAR * afterLast, |
71 | 1.94k | UriMemoryManager * memory) { |
72 | | /* Create segment */ |
73 | 1.94k | URI_TYPE(PathSegment) * segment = |
74 | 1.94k | memory->malloc(memory, 1 * sizeof(URI_TYPE(PathSegment))); |
75 | 1.94k | if (segment == NULL) { |
76 | 0 | return URI_FALSE; /* Raises malloc error */ |
77 | 0 | } |
78 | 1.94k | segment->next = NULL; |
79 | 1.94k | segment->text.first = first; |
80 | 1.94k | segment->text.afterLast = afterLast; |
81 | | |
82 | | /* Put into chain */ |
83 | 1.94k | if (uri->pathTail == NULL) { |
84 | 105 | uri->pathHead = segment; |
85 | 1.83k | } else { |
86 | 1.83k | uri->pathTail->next = segment; |
87 | 1.83k | } |
88 | 1.94k | uri->pathTail = segment; |
89 | | |
90 | 1.94k | return URI_TRUE; |
91 | 1.94k | } UriShorten.c:uriAppendSegmentA Line | Count | Source | 71 | 1.13k | UriMemoryManager * memory) { | 72 | | /* Create segment */ | 73 | 1.13k | URI_TYPE(PathSegment) * segment = | 74 | 1.13k | memory->malloc(memory, 1 * sizeof(URI_TYPE(PathSegment))); | 75 | 1.13k | if (segment == NULL) { | 76 | 0 | return URI_FALSE; /* Raises malloc error */ | 77 | 0 | } | 78 | 1.13k | segment->next = NULL; | 79 | 1.13k | segment->text.first = first; | 80 | 1.13k | segment->text.afterLast = afterLast; | 81 | | | 82 | | /* Put into chain */ | 83 | 1.13k | if (uri->pathTail == NULL) { | 84 | 53 | uri->pathHead = segment; | 85 | 1.08k | } else { | 86 | 1.08k | uri->pathTail->next = segment; | 87 | 1.08k | } | 88 | 1.13k | uri->pathTail = segment; | 89 | | | 90 | 1.13k | return URI_TRUE; | 91 | 1.13k | } |
UriShorten.c:uriAppendSegmentW Line | Count | Source | 71 | 807 | UriMemoryManager * memory) { | 72 | | /* Create segment */ | 73 | 807 | URI_TYPE(PathSegment) * segment = | 74 | 807 | memory->malloc(memory, 1 * sizeof(URI_TYPE(PathSegment))); | 75 | 807 | if (segment == NULL) { | 76 | 0 | return URI_FALSE; /* Raises malloc error */ | 77 | 0 | } | 78 | 807 | segment->next = NULL; | 79 | 807 | segment->text.first = first; | 80 | 807 | segment->text.afterLast = afterLast; | 81 | | | 82 | | /* Put into chain */ | 83 | 807 | if (uri->pathTail == NULL) { | 84 | 52 | uri->pathHead = segment; | 85 | 755 | } else { | 86 | 755 | uri->pathTail->next = segment; | 87 | 755 | } | 88 | 807 | uri->pathTail = segment; | 89 | | | 90 | 807 | return URI_TRUE; | 91 | 807 | } |
|
92 | | |
93 | | static URI_INLINE UriBool URI_FUNC(EqualsAuthority)(const URI_TYPE(Uri) * first, |
94 | 282 | const URI_TYPE(Uri) * second) { |
95 | | /* IPv4 */ |
96 | 282 | if (first->hostData.ip4 != NULL) { |
97 | 4 | return ((second->hostData.ip4 != NULL) |
98 | 2 | && !memcmp(first->hostData.ip4->data, second->hostData.ip4->data, 4)) |
99 | 4 | ? URI_TRUE |
100 | 4 | : URI_FALSE; |
101 | 4 | } |
102 | | |
103 | | /* IPv6 */ |
104 | 278 | if (first->hostData.ip6 != NULL) { |
105 | 36 | return ((second->hostData.ip6 != NULL) |
106 | 34 | && !memcmp(first->hostData.ip6->data, second->hostData.ip6->data, 16)) |
107 | 36 | ? URI_TRUE |
108 | 36 | : URI_FALSE; |
109 | 36 | } |
110 | | |
111 | | /* IPvFuture */ |
112 | 242 | if (first->hostData.ipFuture.first != NULL) { |
113 | 4 | return ((second->hostData.ipFuture.first != NULL) |
114 | 2 | && !URI_FUNC(CompareRange)(&first->hostData.ipFuture, |
115 | 2 | &second->hostData.ipFuture)) |
116 | 4 | ? URI_TRUE |
117 | 4 | : URI_FALSE; |
118 | 4 | } |
119 | | |
120 | 238 | return !URI_FUNC(CompareRange)(&first->hostText, &second->hostText) ? URI_TRUE |
121 | 238 | : URI_FALSE; |
122 | 242 | } UriShorten.c:uriEqualsAuthorityA Line | Count | Source | 94 | 136 | const URI_TYPE(Uri) * second) { | 95 | | /* IPv4 */ | 96 | 136 | if (first->hostData.ip4 != NULL) { | 97 | 2 | return ((second->hostData.ip4 != NULL) | 98 | 1 | && !memcmp(first->hostData.ip4->data, second->hostData.ip4->data, 4)) | 99 | 2 | ? URI_TRUE | 100 | 2 | : URI_FALSE; | 101 | 2 | } | 102 | | | 103 | | /* IPv6 */ | 104 | 134 | if (first->hostData.ip6 != NULL) { | 105 | 18 | return ((second->hostData.ip6 != NULL) | 106 | 17 | && !memcmp(first->hostData.ip6->data, second->hostData.ip6->data, 16)) | 107 | 18 | ? URI_TRUE | 108 | 18 | : URI_FALSE; | 109 | 18 | } | 110 | | | 111 | | /* IPvFuture */ | 112 | 116 | if (first->hostData.ipFuture.first != NULL) { | 113 | 2 | return ((second->hostData.ipFuture.first != NULL) | 114 | 1 | && !URI_FUNC(CompareRange)(&first->hostData.ipFuture, | 115 | 1 | &second->hostData.ipFuture)) | 116 | 2 | ? URI_TRUE | 117 | 2 | : URI_FALSE; | 118 | 2 | } | 119 | | | 120 | 114 | return !URI_FUNC(CompareRange)(&first->hostText, &second->hostText) ? URI_TRUE | 121 | 114 | : URI_FALSE; | 122 | 116 | } |
UriShorten.c:uriEqualsAuthorityW Line | Count | Source | 94 | 146 | const URI_TYPE(Uri) * second) { | 95 | | /* IPv4 */ | 96 | 146 | if (first->hostData.ip4 != NULL) { | 97 | 2 | return ((second->hostData.ip4 != NULL) | 98 | 1 | && !memcmp(first->hostData.ip4->data, second->hostData.ip4->data, 4)) | 99 | 2 | ? URI_TRUE | 100 | 2 | : URI_FALSE; | 101 | 2 | } | 102 | | | 103 | | /* IPv6 */ | 104 | 144 | if (first->hostData.ip6 != NULL) { | 105 | 18 | return ((second->hostData.ip6 != NULL) | 106 | 17 | && !memcmp(first->hostData.ip6->data, second->hostData.ip6->data, 16)) | 107 | 18 | ? URI_TRUE | 108 | 18 | : URI_FALSE; | 109 | 18 | } | 110 | | | 111 | | /* IPvFuture */ | 112 | 126 | if (first->hostData.ipFuture.first != NULL) { | 113 | 2 | return ((second->hostData.ipFuture.first != NULL) | 114 | 1 | && !URI_FUNC(CompareRange)(&first->hostData.ipFuture, | 115 | 1 | &second->hostData.ipFuture)) | 116 | 2 | ? URI_TRUE | 117 | 2 | : URI_FALSE; | 118 | 2 | } | 119 | | | 120 | 124 | return !URI_FUNC(CompareRange)(&first->hostText, &second->hostText) ? URI_TRUE | 121 | 124 | : URI_FALSE; | 122 | 126 | } |
|
123 | | |
124 | | static int URI_FUNC(RemoveBaseUriImpl)(URI_TYPE(Uri) * dest, |
125 | | const URI_TYPE(Uri) * absSource, |
126 | | const URI_TYPE(Uri) * absBase, |
127 | | UriBool domainRootMode, |
128 | 13.5k | UriMemoryManager * memory) { |
129 | 13.5k | if (dest == NULL) { |
130 | 0 | return URI_ERROR_NULL; |
131 | 0 | } |
132 | 13.5k | URI_FUNC(ResetUri)(dest); |
133 | | |
134 | 13.5k | if ((absSource == NULL) || (absBase == NULL)) { |
135 | 0 | return URI_ERROR_NULL; |
136 | 0 | } |
137 | | |
138 | | /* absBase absolute? */ |
139 | 13.5k | if (absBase->scheme.first == NULL) { |
140 | 12.8k | return URI_ERROR_REMOVEBASE_REL_BASE; |
141 | 12.8k | } |
142 | | |
143 | | /* absSource absolute? */ |
144 | 706 | if (absSource->scheme.first == NULL) { |
145 | 323 | return URI_ERROR_REMOVEBASE_REL_SOURCE; |
146 | 323 | } |
147 | | |
148 | | /* NOTE: The curly brackets here force deeper indent (and that's all) */ |
149 | 383 | { |
150 | 383 | { |
151 | 383 | { |
152 | | /* clang-format off */ |
153 | | /* [01/50] if (A.scheme != Base.scheme) then */ |
154 | | /* clang-format on */ |
155 | 383 | if (URI_FUNC(CompareRange)(&absSource->scheme, &absBase->scheme)) { |
156 | | /* clang-format off */ |
157 | | /* [02/50] T.scheme = A.scheme; */ |
158 | | /* clang-format on */ |
159 | 101 | dest->scheme = absSource->scheme; |
160 | | /* clang-format off */ |
161 | | /* [03/50] T.authority = A.authority; */ |
162 | | /* clang-format on */ |
163 | 101 | if (!URI_FUNC(CopyAuthority)(dest, absSource, memory)) { |
164 | 0 | return URI_ERROR_MALLOC; |
165 | 0 | } |
166 | | /* clang-format off */ |
167 | | /* [04/50] T.path = A.path; */ |
168 | | /* clang-format on */ |
169 | 101 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { |
170 | 0 | return URI_ERROR_MALLOC; |
171 | 0 | } |
172 | | /* clang-format off */ |
173 | | /* [05/50] else */ |
174 | | /* clang-format on */ |
175 | 282 | } else { |
176 | | /* clang-format off */ |
177 | | /* [06/50] undef(T.scheme); */ |
178 | | /* clang-format on */ |
179 | | /* NOOP */ |
180 | | /* clang-format off */ |
181 | | /* [07/50] if (A.authority != Base.authority) then */ |
182 | | /* clang-format on */ |
183 | 282 | if (!URI_FUNC(EqualsAuthority)(absSource, absBase)) { |
184 | | /* clang-format off */ |
185 | | /* [08/50] T.authority = A.authority; */ |
186 | | /* clang-format on */ |
187 | 46 | if (!URI_FUNC(CopyAuthority)(dest, absSource, memory)) { |
188 | 0 | return URI_ERROR_MALLOC; |
189 | 0 | } |
190 | | /* clang-format off */ |
191 | | /* [09/50] T.path = A.path; */ |
192 | | /* clang-format on */ |
193 | 46 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { |
194 | 0 | return URI_ERROR_MALLOC; |
195 | 0 | } |
196 | | /* clang-format off */ |
197 | | /* [10/50] else */ |
198 | | /* clang-format on */ |
199 | 236 | } else { |
200 | | /* clang-format off */ |
201 | | /* [11/50] if domainRootMode then */ |
202 | | /* clang-format on */ |
203 | 236 | if (domainRootMode == URI_TRUE) { |
204 | | /* clang-format off */ |
205 | | /* [12/50] undef(T.authority); */ |
206 | | /* clang-format on */ |
207 | | /* NOOP */ |
208 | | /* clang-format off */ |
209 | | /* [13/50] if (first(A.path) == "") then */ |
210 | | /* clang-format on */ |
211 | | /* GROUPED */ |
212 | | /* clang-format off */ |
213 | | /* [14/50] T.path = "/." + A.path; */ |
214 | | /* clang-format on */ |
215 | | /* GROUPED */ |
216 | | /* clang-format off */ |
217 | | /* [15/50] else */ |
218 | | /* clang-format on */ |
219 | | /* GROUPED */ |
220 | | /* clang-format off */ |
221 | | /* [16/50] T.path = A.path; */ |
222 | | /* clang-format on */ |
223 | | /* GROUPED */ |
224 | | /* clang-format off */ |
225 | | /* [17/50] endif; */ |
226 | | /* clang-format on */ |
227 | 30 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { |
228 | 0 | return URI_ERROR_MALLOC; |
229 | 0 | } |
230 | 30 | dest->absolutePath = URI_TRUE; |
231 | | |
232 | 30 | if (!URI_FUNC(FixAmbiguity)(dest, memory)) { |
233 | 0 | return URI_ERROR_MALLOC; |
234 | 0 | } |
235 | | /* clang-format off */ |
236 | | /* [18/50] else */ |
237 | | /* clang-format on */ |
238 | 206 | } else { |
239 | 206 | const URI_TYPE(PathSegment) * sourceSeg = absSource->pathHead; |
240 | 206 | const URI_TYPE(PathSegment) * baseSeg = absBase->pathHead; |
241 | | /* clang-format off */ |
242 | | /* [19/50] bool pathNaked = true; */ |
243 | | /* clang-format on */ |
244 | 206 | UriBool pathNaked = URI_TRUE; |
245 | | /* clang-format off */ |
246 | | /* [20/50] undef(last(Base.path)); */ |
247 | | /* clang-format on */ |
248 | | /* NOOP */ |
249 | | /* clang-format off */ |
250 | | /* [21/50] T.path = ""; */ |
251 | | /* clang-format on */ |
252 | 206 | dest->absolutePath = URI_FALSE; |
253 | | /* clang-format off */ |
254 | | /* [22/50] while (first(A.path) == first(Base.path)) do */ |
255 | | /* clang-format on */ |
256 | 206 | while ( |
257 | 1.34k | (sourceSeg != NULL) && (baseSeg != NULL) |
258 | 1.16k | && !URI_FUNC(CompareRange)(&sourceSeg->text, |
259 | 1.16k | &baseSeg->text) |
260 | 1.14k | && !((sourceSeg->text.first == sourceSeg->text.afterLast) |
261 | 698 | && ((sourceSeg->next == NULL) |
262 | 1.13k | != (baseSeg->next == NULL)))) { |
263 | | /* clang-format off */ |
264 | | /* [23/50] A.path++; */ |
265 | | /* clang-format on */ |
266 | 1.13k | sourceSeg = sourceSeg->next; |
267 | | /* clang-format off */ |
268 | | /* [24/50] Base.path++; */ |
269 | | /* clang-format on */ |
270 | 1.13k | baseSeg = baseSeg->next; |
271 | | /* clang-format off */ |
272 | | /* [25/50] endwhile; */ |
273 | | /* clang-format on */ |
274 | 1.13k | } |
275 | | /* clang-format off */ |
276 | | /* [26/50] while defined(first(Base.path)) do */ |
277 | | /* clang-format on */ |
278 | 1.25k | while ((baseSeg != NULL) && (baseSeg->next != NULL)) { |
279 | | /* clang-format off */ |
280 | | /* [27/50] Base.path++; */ |
281 | | /* clang-format on */ |
282 | 1.05k | baseSeg = baseSeg->next; |
283 | | /* clang-format off */ |
284 | | /* [28/50] T.path += "../"; */ |
285 | | /* clang-format on */ |
286 | 1.05k | if (!URI_FUNC(AppendSegment)(dest, URI_FUNC(ConstParent), |
287 | 1.05k | URI_FUNC(ConstParent) + 2, |
288 | 1.05k | memory)) { |
289 | 0 | return URI_ERROR_MALLOC; |
290 | 0 | } |
291 | | /* clang-format off */ |
292 | | /* [29/50] pathNaked = false; */ |
293 | | /* clang-format on */ |
294 | 1.05k | pathNaked = URI_FALSE; |
295 | | /* clang-format off */ |
296 | | /* [30/50] endwhile; */ |
297 | | /* clang-format on */ |
298 | 1.05k | } |
299 | | /* clang-format off */ |
300 | | /* [31/50] while defined(first(A.path)) do */ |
301 | | /* clang-format on */ |
302 | 1.06k | while (sourceSeg != NULL) { |
303 | | /* clang-format off */ |
304 | | /* [32/50] if pathNaked then */ |
305 | | /* clang-format on */ |
306 | 855 | if (pathNaked == URI_TRUE) { |
307 | | /* clang-format off */ |
308 | | /* [33/50] if (first(A.path) contains ":") then */ |
309 | | /* clang-format on */ |
310 | 72 | UriBool containsColon = URI_FALSE; |
311 | 72 | const URI_CHAR * ch = sourceSeg->text.first; |
312 | 814 | for (; ch < sourceSeg->text.afterLast; ch++) { |
313 | 765 | if (*ch == _UT(':')) { |
314 | 23 | containsColon = URI_TRUE; |
315 | 23 | break; |
316 | 23 | } |
317 | 765 | } |
318 | | |
319 | 72 | if (containsColon) { |
320 | | /* clang-format off */ |
321 | | /* [34/50] T.path += "./"; */ |
322 | | /* clang-format on */ |
323 | 23 | if (!URI_FUNC(AppendSegment)( |
324 | 23 | dest, URI_FUNC(ConstPwd), |
325 | 23 | URI_FUNC(ConstPwd) + 1, memory)) { |
326 | 0 | return URI_ERROR_MALLOC; |
327 | 0 | } |
328 | | /* clang-format off */ |
329 | | /* [35/50] elseif (first(A.path) == "") then */ |
330 | | /* clang-format on */ |
331 | 49 | } else if (sourceSeg->text.first |
332 | 49 | == sourceSeg->text.afterLast) { |
333 | | /* clang-format off */ |
334 | | /* [36/50] T.path += "/."; */ |
335 | | /* clang-format on */ |
336 | 9 | if (!URI_FUNC(AppendSegment)( |
337 | 9 | dest, URI_FUNC(ConstPwd), |
338 | 9 | URI_FUNC(ConstPwd) + 1, memory)) { |
339 | 0 | return URI_ERROR_MALLOC; |
340 | 0 | } |
341 | | /* clang-format off */ |
342 | | /* [37/50] endif; */ |
343 | | /* clang-format on */ |
344 | 9 | } |
345 | | /* clang-format off */ |
346 | | /* [38/50] endif; */ |
347 | | /* clang-format on */ |
348 | 72 | } |
349 | | /* clang-format off */ |
350 | | /* [39/50] T.path += first(A.path); */ |
351 | | /* clang-format on */ |
352 | 855 | if (!URI_FUNC(AppendSegment)(dest, sourceSeg->text.first, |
353 | 855 | sourceSeg->text.afterLast, |
354 | 855 | memory)) { |
355 | 0 | return URI_ERROR_MALLOC; |
356 | 0 | } |
357 | | /* clang-format off */ |
358 | | /* [40/50] pathNaked = false; */ |
359 | | /* clang-format on */ |
360 | 855 | pathNaked = URI_FALSE; |
361 | | /* clang-format off */ |
362 | | /* [41/50] A.path++; */ |
363 | | /* clang-format on */ |
364 | 855 | sourceSeg = sourceSeg->next; |
365 | | /* clang-format off */ |
366 | | /* [42/50] if defined(first(A.path)) then */ |
367 | | /* clang-format on */ |
368 | | /* NOOP */ |
369 | | /* clang-format off */ |
370 | | /* [43/50] T.path += + "/"; */ |
371 | | /* clang-format on */ |
372 | | /* NOOP */ |
373 | | /* clang-format off */ |
374 | | /* [44/50] endif; */ |
375 | | /* clang-format on */ |
376 | | /* NOOP */ |
377 | | /* clang-format off */ |
378 | | /* [45/50] endwhile; */ |
379 | | /* clang-format on */ |
380 | 855 | } |
381 | | /* clang-format off */ |
382 | | /* [46/50] endif; */ |
383 | | /* clang-format on */ |
384 | 206 | } |
385 | | /* clang-format off */ |
386 | | /* [47/50] endif; */ |
387 | | /* clang-format on */ |
388 | 236 | } |
389 | | /* clang-format off */ |
390 | | /* [48/50] endif; */ |
391 | | /* clang-format on */ |
392 | 282 | } |
393 | | /* clang-format off */ |
394 | | /* [49/50] T.query = A.query; */ |
395 | | /* clang-format on */ |
396 | 383 | dest->query = absSource->query; |
397 | | /* clang-format off */ |
398 | | /* [50/50] T.fragment = A.fragment; */ |
399 | | /* clang-format on */ |
400 | 383 | dest->fragment = absSource->fragment; |
401 | 383 | } |
402 | 383 | } |
403 | 383 | } |
404 | 383 | return URI_SUCCESS; |
405 | 383 | } UriShorten.c:uriRemoveBaseUriImplA Line | Count | Source | 128 | 7.01k | UriMemoryManager * memory) { | 129 | 7.01k | if (dest == NULL) { | 130 | 0 | return URI_ERROR_NULL; | 131 | 0 | } | 132 | 7.01k | URI_FUNC(ResetUri)(dest); | 133 | | | 134 | 7.01k | if ((absSource == NULL) || (absBase == NULL)) { | 135 | 0 | return URI_ERROR_NULL; | 136 | 0 | } | 137 | | | 138 | | /* absBase absolute? */ | 139 | 7.01k | if (absBase->scheme.first == NULL) { | 140 | 6.66k | return URI_ERROR_REMOVEBASE_REL_BASE; | 141 | 6.66k | } | 142 | | | 143 | | /* absSource absolute? */ | 144 | 344 | if (absSource->scheme.first == NULL) { | 145 | 151 | return URI_ERROR_REMOVEBASE_REL_SOURCE; | 146 | 151 | } | 147 | | | 148 | | /* NOTE: The curly brackets here force deeper indent (and that's all) */ | 149 | 193 | { | 150 | 193 | { | 151 | 193 | { | 152 | | /* clang-format off */ | 153 | | /* [01/50] if (A.scheme != Base.scheme) then */ | 154 | | /* clang-format on */ | 155 | 193 | if (URI_FUNC(CompareRange)(&absSource->scheme, &absBase->scheme)) { | 156 | | /* clang-format off */ | 157 | | /* [02/50] T.scheme = A.scheme; */ | 158 | | /* clang-format on */ | 159 | 57 | dest->scheme = absSource->scheme; | 160 | | /* clang-format off */ | 161 | | /* [03/50] T.authority = A.authority; */ | 162 | | /* clang-format on */ | 163 | 57 | if (!URI_FUNC(CopyAuthority)(dest, absSource, memory)) { | 164 | 0 | return URI_ERROR_MALLOC; | 165 | 0 | } | 166 | | /* clang-format off */ | 167 | | /* [04/50] T.path = A.path; */ | 168 | | /* clang-format on */ | 169 | 57 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { | 170 | 0 | return URI_ERROR_MALLOC; | 171 | 0 | } | 172 | | /* clang-format off */ | 173 | | /* [05/50] else */ | 174 | | /* clang-format on */ | 175 | 136 | } else { | 176 | | /* clang-format off */ | 177 | | /* [06/50] undef(T.scheme); */ | 178 | | /* clang-format on */ | 179 | | /* NOOP */ | 180 | | /* clang-format off */ | 181 | | /* [07/50] if (A.authority != Base.authority) then */ | 182 | | /* clang-format on */ | 183 | 136 | if (!URI_FUNC(EqualsAuthority)(absSource, absBase)) { | 184 | | /* clang-format off */ | 185 | | /* [08/50] T.authority = A.authority; */ | 186 | | /* clang-format on */ | 187 | 23 | if (!URI_FUNC(CopyAuthority)(dest, absSource, memory)) { | 188 | 0 | return URI_ERROR_MALLOC; | 189 | 0 | } | 190 | | /* clang-format off */ | 191 | | /* [09/50] T.path = A.path; */ | 192 | | /* clang-format on */ | 193 | 23 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { | 194 | 0 | return URI_ERROR_MALLOC; | 195 | 0 | } | 196 | | /* clang-format off */ | 197 | | /* [10/50] else */ | 198 | | /* clang-format on */ | 199 | 113 | } else { | 200 | | /* clang-format off */ | 201 | | /* [11/50] if domainRootMode then */ | 202 | | /* clang-format on */ | 203 | 113 | if (domainRootMode == URI_TRUE) { | 204 | | /* clang-format off */ | 205 | | /* [12/50] undef(T.authority); */ | 206 | | /* clang-format on */ | 207 | | /* NOOP */ | 208 | | /* clang-format off */ | 209 | | /* [13/50] if (first(A.path) == "") then */ | 210 | | /* clang-format on */ | 211 | | /* GROUPED */ | 212 | | /* clang-format off */ | 213 | | /* [14/50] T.path = "/." + A.path; */ | 214 | | /* clang-format on */ | 215 | | /* GROUPED */ | 216 | | /* clang-format off */ | 217 | | /* [15/50] else */ | 218 | | /* clang-format on */ | 219 | | /* GROUPED */ | 220 | | /* clang-format off */ | 221 | | /* [16/50] T.path = A.path; */ | 222 | | /* clang-format on */ | 223 | | /* GROUPED */ | 224 | | /* clang-format off */ | 225 | | /* [17/50] endif; */ | 226 | | /* clang-format on */ | 227 | 17 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { | 228 | 0 | return URI_ERROR_MALLOC; | 229 | 0 | } | 230 | 17 | dest->absolutePath = URI_TRUE; | 231 | | | 232 | 17 | if (!URI_FUNC(FixAmbiguity)(dest, memory)) { | 233 | 0 | return URI_ERROR_MALLOC; | 234 | 0 | } | 235 | | /* clang-format off */ | 236 | | /* [18/50] else */ | 237 | | /* clang-format on */ | 238 | 96 | } else { | 239 | 96 | const URI_TYPE(PathSegment) * sourceSeg = absSource->pathHead; | 240 | 96 | const URI_TYPE(PathSegment) * baseSeg = absBase->pathHead; | 241 | | /* clang-format off */ | 242 | | /* [19/50] bool pathNaked = true; */ | 243 | | /* clang-format on */ | 244 | 96 | UriBool pathNaked = URI_TRUE; | 245 | | /* clang-format off */ | 246 | | /* [20/50] undef(last(Base.path)); */ | 247 | | /* clang-format on */ | 248 | | /* NOOP */ | 249 | | /* clang-format off */ | 250 | | /* [21/50] T.path = ""; */ | 251 | | /* clang-format on */ | 252 | 96 | dest->absolutePath = URI_FALSE; | 253 | | /* clang-format off */ | 254 | | /* [22/50] while (first(A.path) == first(Base.path)) do */ | 255 | | /* clang-format on */ | 256 | 96 | while ( | 257 | 910 | (sourceSeg != NULL) && (baseSeg != NULL) | 258 | 825 | && !URI_FUNC(CompareRange)(&sourceSeg->text, | 259 | 825 | &baseSeg->text) | 260 | 817 | && !((sourceSeg->text.first == sourceSeg->text.afterLast) | 261 | 555 | && ((sourceSeg->next == NULL) | 262 | 814 | != (baseSeg->next == NULL)))) { | 263 | | /* clang-format off */ | 264 | | /* [23/50] A.path++; */ | 265 | | /* clang-format on */ | 266 | 814 | sourceSeg = sourceSeg->next; | 267 | | /* clang-format off */ | 268 | | /* [24/50] Base.path++; */ | 269 | | /* clang-format on */ | 270 | 814 | baseSeg = baseSeg->next; | 271 | | /* clang-format off */ | 272 | | /* [25/50] endwhile; */ | 273 | | /* clang-format on */ | 274 | 814 | } | 275 | | /* clang-format off */ | 276 | | /* [26/50] while defined(first(Base.path)) do */ | 277 | | /* clang-format on */ | 278 | 658 | while ((baseSeg != NULL) && (baseSeg->next != NULL)) { | 279 | | /* clang-format off */ | 280 | | /* [27/50] Base.path++; */ | 281 | | /* clang-format on */ | 282 | 562 | baseSeg = baseSeg->next; | 283 | | /* clang-format off */ | 284 | | /* [28/50] T.path += "../"; */ | 285 | | /* clang-format on */ | 286 | 562 | if (!URI_FUNC(AppendSegment)(dest, URI_FUNC(ConstParent), | 287 | 562 | URI_FUNC(ConstParent) + 2, | 288 | 562 | memory)) { | 289 | 0 | return URI_ERROR_MALLOC; | 290 | 0 | } | 291 | | /* clang-format off */ | 292 | | /* [29/50] pathNaked = false; */ | 293 | | /* clang-format on */ | 294 | 562 | pathNaked = URI_FALSE; | 295 | | /* clang-format off */ | 296 | | /* [30/50] endwhile; */ | 297 | | /* clang-format on */ | 298 | 562 | } | 299 | | /* clang-format off */ | 300 | | /* [31/50] while defined(first(A.path)) do */ | 301 | | /* clang-format on */ | 302 | 651 | while (sourceSeg != NULL) { | 303 | | /* clang-format off */ | 304 | | /* [32/50] if pathNaked then */ | 305 | | /* clang-format on */ | 306 | 555 | if (pathNaked == URI_TRUE) { | 307 | | /* clang-format off */ | 308 | | /* [33/50] if (first(A.path) contains ":") then */ | 309 | | /* clang-format on */ | 310 | 36 | UriBool containsColon = URI_FALSE; | 311 | 36 | const URI_CHAR * ch = sourceSeg->text.first; | 312 | 250 | for (; ch < sourceSeg->text.afterLast; ch++) { | 313 | 224 | if (*ch == _UT(':')) { | 314 | 10 | containsColon = URI_TRUE; | 315 | 10 | break; | 316 | 10 | } | 317 | 224 | } | 318 | | | 319 | 36 | if (containsColon) { | 320 | | /* clang-format off */ | 321 | | /* [34/50] T.path += "./"; */ | 322 | | /* clang-format on */ | 323 | 10 | if (!URI_FUNC(AppendSegment)( | 324 | 10 | dest, URI_FUNC(ConstPwd), | 325 | 10 | URI_FUNC(ConstPwd) + 1, memory)) { | 326 | 0 | return URI_ERROR_MALLOC; | 327 | 0 | } | 328 | | /* clang-format off */ | 329 | | /* [35/50] elseif (first(A.path) == "") then */ | 330 | | /* clang-format on */ | 331 | 26 | } else if (sourceSeg->text.first | 332 | 26 | == sourceSeg->text.afterLast) { | 333 | | /* clang-format off */ | 334 | | /* [36/50] T.path += "/."; */ | 335 | | /* clang-format on */ | 336 | 6 | if (!URI_FUNC(AppendSegment)( | 337 | 6 | dest, URI_FUNC(ConstPwd), | 338 | 6 | URI_FUNC(ConstPwd) + 1, memory)) { | 339 | 0 | return URI_ERROR_MALLOC; | 340 | 0 | } | 341 | | /* clang-format off */ | 342 | | /* [37/50] endif; */ | 343 | | /* clang-format on */ | 344 | 6 | } | 345 | | /* clang-format off */ | 346 | | /* [38/50] endif; */ | 347 | | /* clang-format on */ | 348 | 36 | } | 349 | | /* clang-format off */ | 350 | | /* [39/50] T.path += first(A.path); */ | 351 | | /* clang-format on */ | 352 | 555 | if (!URI_FUNC(AppendSegment)(dest, sourceSeg->text.first, | 353 | 555 | sourceSeg->text.afterLast, | 354 | 555 | memory)) { | 355 | 0 | return URI_ERROR_MALLOC; | 356 | 0 | } | 357 | | /* clang-format off */ | 358 | | /* [40/50] pathNaked = false; */ | 359 | | /* clang-format on */ | 360 | 555 | pathNaked = URI_FALSE; | 361 | | /* clang-format off */ | 362 | | /* [41/50] A.path++; */ | 363 | | /* clang-format on */ | 364 | 555 | sourceSeg = sourceSeg->next; | 365 | | /* clang-format off */ | 366 | | /* [42/50] if defined(first(A.path)) then */ | 367 | | /* clang-format on */ | 368 | | /* NOOP */ | 369 | | /* clang-format off */ | 370 | | /* [43/50] T.path += + "/"; */ | 371 | | /* clang-format on */ | 372 | | /* NOOP */ | 373 | | /* clang-format off */ | 374 | | /* [44/50] endif; */ | 375 | | /* clang-format on */ | 376 | | /* NOOP */ | 377 | | /* clang-format off */ | 378 | | /* [45/50] endwhile; */ | 379 | | /* clang-format on */ | 380 | 555 | } | 381 | | /* clang-format off */ | 382 | | /* [46/50] endif; */ | 383 | | /* clang-format on */ | 384 | 96 | } | 385 | | /* clang-format off */ | 386 | | /* [47/50] endif; */ | 387 | | /* clang-format on */ | 388 | 113 | } | 389 | | /* clang-format off */ | 390 | | /* [48/50] endif; */ | 391 | | /* clang-format on */ | 392 | 136 | } | 393 | | /* clang-format off */ | 394 | | /* [49/50] T.query = A.query; */ | 395 | | /* clang-format on */ | 396 | 193 | dest->query = absSource->query; | 397 | | /* clang-format off */ | 398 | | /* [50/50] T.fragment = A.fragment; */ | 399 | | /* clang-format on */ | 400 | 193 | dest->fragment = absSource->fragment; | 401 | 193 | } | 402 | 193 | } | 403 | 193 | } | 404 | 193 | return URI_SUCCESS; | 405 | 193 | } |
UriShorten.c:uriRemoveBaseUriImplW Line | Count | Source | 128 | 6.58k | UriMemoryManager * memory) { | 129 | 6.58k | if (dest == NULL) { | 130 | 0 | return URI_ERROR_NULL; | 131 | 0 | } | 132 | 6.58k | URI_FUNC(ResetUri)(dest); | 133 | | | 134 | 6.58k | if ((absSource == NULL) || (absBase == NULL)) { | 135 | 0 | return URI_ERROR_NULL; | 136 | 0 | } | 137 | | | 138 | | /* absBase absolute? */ | 139 | 6.58k | if (absBase->scheme.first == NULL) { | 140 | 6.22k | return URI_ERROR_REMOVEBASE_REL_BASE; | 141 | 6.22k | } | 142 | | | 143 | | /* absSource absolute? */ | 144 | 362 | if (absSource->scheme.first == NULL) { | 145 | 172 | return URI_ERROR_REMOVEBASE_REL_SOURCE; | 146 | 172 | } | 147 | | | 148 | | /* NOTE: The curly brackets here force deeper indent (and that's all) */ | 149 | 190 | { | 150 | 190 | { | 151 | 190 | { | 152 | | /* clang-format off */ | 153 | | /* [01/50] if (A.scheme != Base.scheme) then */ | 154 | | /* clang-format on */ | 155 | 190 | if (URI_FUNC(CompareRange)(&absSource->scheme, &absBase->scheme)) { | 156 | | /* clang-format off */ | 157 | | /* [02/50] T.scheme = A.scheme; */ | 158 | | /* clang-format on */ | 159 | 44 | dest->scheme = absSource->scheme; | 160 | | /* clang-format off */ | 161 | | /* [03/50] T.authority = A.authority; */ | 162 | | /* clang-format on */ | 163 | 44 | if (!URI_FUNC(CopyAuthority)(dest, absSource, memory)) { | 164 | 0 | return URI_ERROR_MALLOC; | 165 | 0 | } | 166 | | /* clang-format off */ | 167 | | /* [04/50] T.path = A.path; */ | 168 | | /* clang-format on */ | 169 | 44 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { | 170 | 0 | return URI_ERROR_MALLOC; | 171 | 0 | } | 172 | | /* clang-format off */ | 173 | | /* [05/50] else */ | 174 | | /* clang-format on */ | 175 | 146 | } else { | 176 | | /* clang-format off */ | 177 | | /* [06/50] undef(T.scheme); */ | 178 | | /* clang-format on */ | 179 | | /* NOOP */ | 180 | | /* clang-format off */ | 181 | | /* [07/50] if (A.authority != Base.authority) then */ | 182 | | /* clang-format on */ | 183 | 146 | if (!URI_FUNC(EqualsAuthority)(absSource, absBase)) { | 184 | | /* clang-format off */ | 185 | | /* [08/50] T.authority = A.authority; */ | 186 | | /* clang-format on */ | 187 | 23 | if (!URI_FUNC(CopyAuthority)(dest, absSource, memory)) { | 188 | 0 | return URI_ERROR_MALLOC; | 189 | 0 | } | 190 | | /* clang-format off */ | 191 | | /* [09/50] T.path = A.path; */ | 192 | | /* clang-format on */ | 193 | 23 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { | 194 | 0 | return URI_ERROR_MALLOC; | 195 | 0 | } | 196 | | /* clang-format off */ | 197 | | /* [10/50] else */ | 198 | | /* clang-format on */ | 199 | 123 | } else { | 200 | | /* clang-format off */ | 201 | | /* [11/50] if domainRootMode then */ | 202 | | /* clang-format on */ | 203 | 123 | if (domainRootMode == URI_TRUE) { | 204 | | /* clang-format off */ | 205 | | /* [12/50] undef(T.authority); */ | 206 | | /* clang-format on */ | 207 | | /* NOOP */ | 208 | | /* clang-format off */ | 209 | | /* [13/50] if (first(A.path) == "") then */ | 210 | | /* clang-format on */ | 211 | | /* GROUPED */ | 212 | | /* clang-format off */ | 213 | | /* [14/50] T.path = "/." + A.path; */ | 214 | | /* clang-format on */ | 215 | | /* GROUPED */ | 216 | | /* clang-format off */ | 217 | | /* [15/50] else */ | 218 | | /* clang-format on */ | 219 | | /* GROUPED */ | 220 | | /* clang-format off */ | 221 | | /* [16/50] T.path = A.path; */ | 222 | | /* clang-format on */ | 223 | | /* GROUPED */ | 224 | | /* clang-format off */ | 225 | | /* [17/50] endif; */ | 226 | | /* clang-format on */ | 227 | 13 | if (!URI_FUNC(CopyPath)(dest, absSource, memory)) { | 228 | 0 | return URI_ERROR_MALLOC; | 229 | 0 | } | 230 | 13 | dest->absolutePath = URI_TRUE; | 231 | | | 232 | 13 | if (!URI_FUNC(FixAmbiguity)(dest, memory)) { | 233 | 0 | return URI_ERROR_MALLOC; | 234 | 0 | } | 235 | | /* clang-format off */ | 236 | | /* [18/50] else */ | 237 | | /* clang-format on */ | 238 | 110 | } else { | 239 | 110 | const URI_TYPE(PathSegment) * sourceSeg = absSource->pathHead; | 240 | 110 | const URI_TYPE(PathSegment) * baseSeg = absBase->pathHead; | 241 | | /* clang-format off */ | 242 | | /* [19/50] bool pathNaked = true; */ | 243 | | /* clang-format on */ | 244 | 110 | UriBool pathNaked = URI_TRUE; | 245 | | /* clang-format off */ | 246 | | /* [20/50] undef(last(Base.path)); */ | 247 | | /* clang-format on */ | 248 | | /* NOOP */ | 249 | | /* clang-format off */ | 250 | | /* [21/50] T.path = ""; */ | 251 | | /* clang-format on */ | 252 | 110 | dest->absolutePath = URI_FALSE; | 253 | | /* clang-format off */ | 254 | | /* [22/50] while (first(A.path) == first(Base.path)) do */ | 255 | | /* clang-format on */ | 256 | 110 | while ( | 257 | 435 | (sourceSeg != NULL) && (baseSeg != NULL) | 258 | 337 | && !URI_FUNC(CompareRange)(&sourceSeg->text, | 259 | 337 | &baseSeg->text) | 260 | 327 | && !((sourceSeg->text.first == sourceSeg->text.afterLast) | 261 | 143 | && ((sourceSeg->next == NULL) | 262 | 325 | != (baseSeg->next == NULL)))) { | 263 | | /* clang-format off */ | 264 | | /* [23/50] A.path++; */ | 265 | | /* clang-format on */ | 266 | 325 | sourceSeg = sourceSeg->next; | 267 | | /* clang-format off */ | 268 | | /* [24/50] Base.path++; */ | 269 | | /* clang-format on */ | 270 | 325 | baseSeg = baseSeg->next; | 271 | | /* clang-format off */ | 272 | | /* [25/50] endwhile; */ | 273 | | /* clang-format on */ | 274 | 325 | } | 275 | | /* clang-format off */ | 276 | | /* [26/50] while defined(first(Base.path)) do */ | 277 | | /* clang-format on */ | 278 | 601 | while ((baseSeg != NULL) && (baseSeg->next != NULL)) { | 279 | | /* clang-format off */ | 280 | | /* [27/50] Base.path++; */ | 281 | | /* clang-format on */ | 282 | 491 | baseSeg = baseSeg->next; | 283 | | /* clang-format off */ | 284 | | /* [28/50] T.path += "../"; */ | 285 | | /* clang-format on */ | 286 | 491 | if (!URI_FUNC(AppendSegment)(dest, URI_FUNC(ConstParent), | 287 | 491 | URI_FUNC(ConstParent) + 2, | 288 | 491 | memory)) { | 289 | 0 | return URI_ERROR_MALLOC; | 290 | 0 | } | 291 | | /* clang-format off */ | 292 | | /* [29/50] pathNaked = false; */ | 293 | | /* clang-format on */ | 294 | 491 | pathNaked = URI_FALSE; | 295 | | /* clang-format off */ | 296 | | /* [30/50] endwhile; */ | 297 | | /* clang-format on */ | 298 | 491 | } | 299 | | /* clang-format off */ | 300 | | /* [31/50] while defined(first(A.path)) do */ | 301 | | /* clang-format on */ | 302 | 410 | while (sourceSeg != NULL) { | 303 | | /* clang-format off */ | 304 | | /* [32/50] if pathNaked then */ | 305 | | /* clang-format on */ | 306 | 300 | if (pathNaked == URI_TRUE) { | 307 | | /* clang-format off */ | 308 | | /* [33/50] if (first(A.path) contains ":") then */ | 309 | | /* clang-format on */ | 310 | 36 | UriBool containsColon = URI_FALSE; | 311 | 36 | const URI_CHAR * ch = sourceSeg->text.first; | 312 | 564 | for (; ch < sourceSeg->text.afterLast; ch++) { | 313 | 541 | if (*ch == _UT(':')) { | 314 | 13 | containsColon = URI_TRUE; | 315 | 13 | break; | 316 | 13 | } | 317 | 541 | } | 318 | | | 319 | 36 | if (containsColon) { | 320 | | /* clang-format off */ | 321 | | /* [34/50] T.path += "./"; */ | 322 | | /* clang-format on */ | 323 | 13 | if (!URI_FUNC(AppendSegment)( | 324 | 13 | dest, URI_FUNC(ConstPwd), | 325 | 13 | URI_FUNC(ConstPwd) + 1, memory)) { | 326 | 0 | return URI_ERROR_MALLOC; | 327 | 0 | } | 328 | | /* clang-format off */ | 329 | | /* [35/50] elseif (first(A.path) == "") then */ | 330 | | /* clang-format on */ | 331 | 23 | } else if (sourceSeg->text.first | 332 | 23 | == sourceSeg->text.afterLast) { | 333 | | /* clang-format off */ | 334 | | /* [36/50] T.path += "/."; */ | 335 | | /* clang-format on */ | 336 | 3 | if (!URI_FUNC(AppendSegment)( | 337 | 3 | dest, URI_FUNC(ConstPwd), | 338 | 3 | URI_FUNC(ConstPwd) + 1, memory)) { | 339 | 0 | return URI_ERROR_MALLOC; | 340 | 0 | } | 341 | | /* clang-format off */ | 342 | | /* [37/50] endif; */ | 343 | | /* clang-format on */ | 344 | 3 | } | 345 | | /* clang-format off */ | 346 | | /* [38/50] endif; */ | 347 | | /* clang-format on */ | 348 | 36 | } | 349 | | /* clang-format off */ | 350 | | /* [39/50] T.path += first(A.path); */ | 351 | | /* clang-format on */ | 352 | 300 | if (!URI_FUNC(AppendSegment)(dest, sourceSeg->text.first, | 353 | 300 | sourceSeg->text.afterLast, | 354 | 300 | memory)) { | 355 | 0 | return URI_ERROR_MALLOC; | 356 | 0 | } | 357 | | /* clang-format off */ | 358 | | /* [40/50] pathNaked = false; */ | 359 | | /* clang-format on */ | 360 | 300 | pathNaked = URI_FALSE; | 361 | | /* clang-format off */ | 362 | | /* [41/50] A.path++; */ | 363 | | /* clang-format on */ | 364 | 300 | sourceSeg = sourceSeg->next; | 365 | | /* clang-format off */ | 366 | | /* [42/50] if defined(first(A.path)) then */ | 367 | | /* clang-format on */ | 368 | | /* NOOP */ | 369 | | /* clang-format off */ | 370 | | /* [43/50] T.path += + "/"; */ | 371 | | /* clang-format on */ | 372 | | /* NOOP */ | 373 | | /* clang-format off */ | 374 | | /* [44/50] endif; */ | 375 | | /* clang-format on */ | 376 | | /* NOOP */ | 377 | | /* clang-format off */ | 378 | | /* [45/50] endwhile; */ | 379 | | /* clang-format on */ | 380 | 300 | } | 381 | | /* clang-format off */ | 382 | | /* [46/50] endif; */ | 383 | | /* clang-format on */ | 384 | 110 | } | 385 | | /* clang-format off */ | 386 | | /* [47/50] endif; */ | 387 | | /* clang-format on */ | 388 | 123 | } | 389 | | /* clang-format off */ | 390 | | /* [48/50] endif; */ | 391 | | /* clang-format on */ | 392 | 146 | } | 393 | | /* clang-format off */ | 394 | | /* [49/50] T.query = A.query; */ | 395 | | /* clang-format on */ | 396 | 190 | dest->query = absSource->query; | 397 | | /* clang-format off */ | 398 | | /* [50/50] T.fragment = A.fragment; */ | 399 | | /* clang-format on */ | 400 | 190 | dest->fragment = absSource->fragment; | 401 | 190 | } | 402 | 190 | } | 403 | 190 | } | 404 | 190 | return URI_SUCCESS; | 405 | 190 | } |
|
406 | | |
407 | | int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, const URI_TYPE(Uri) * absSource, |
408 | 13.5k | const URI_TYPE(Uri) * absBase, UriBool domainRootMode) { |
409 | 13.5k | return URI_FUNC(RemoveBaseUriMm)(dest, absSource, absBase, domainRootMode, NULL); |
410 | 13.5k | } Line | Count | Source | 408 | 7.01k | const URI_TYPE(Uri) * absBase, UriBool domainRootMode) { | 409 | 7.01k | return URI_FUNC(RemoveBaseUriMm)(dest, absSource, absBase, domainRootMode, NULL); | 410 | 7.01k | } |
Line | Count | Source | 408 | 6.58k | const URI_TYPE(Uri) * absBase, UriBool domainRootMode) { | 409 | 6.58k | return URI_FUNC(RemoveBaseUriMm)(dest, absSource, absBase, domainRootMode, NULL); | 410 | 6.58k | } |
|
411 | | |
412 | | int URI_FUNC(RemoveBaseUriMm)(URI_TYPE(Uri) * dest, const URI_TYPE(Uri) * absSource, |
413 | | const URI_TYPE(Uri) * absBase, UriBool domainRootMode, |
414 | 13.5k | UriMemoryManager * memory) { |
415 | 13.5k | int res; |
416 | | |
417 | 13.5k | URI_CHECK_MEMORY_MANAGER(memory); /* may return */ |
418 | | |
419 | 13.5k | res = URI_FUNC(RemoveBaseUriImpl)(dest, absSource, absBase, domainRootMode, memory); |
420 | 13.5k | if ((res != URI_SUCCESS) && (dest != NULL)) { |
421 | 13.2k | URI_FUNC(FreeUriMembersMm)(dest, memory); |
422 | 13.2k | } |
423 | 13.5k | return res; |
424 | 13.5k | } Line | Count | Source | 414 | 7.01k | UriMemoryManager * memory) { | 415 | 7.01k | int res; | 416 | | | 417 | 7.01k | URI_CHECK_MEMORY_MANAGER(memory); /* may return */ | 418 | | | 419 | 7.01k | res = URI_FUNC(RemoveBaseUriImpl)(dest, absSource, absBase, domainRootMode, memory); | 420 | 7.01k | if ((res != URI_SUCCESS) && (dest != NULL)) { | 421 | 6.81k | URI_FUNC(FreeUriMembersMm)(dest, memory); | 422 | 6.81k | } | 423 | 7.01k | return res; | 424 | 7.01k | } |
Line | Count | Source | 414 | 6.58k | UriMemoryManager * memory) { | 415 | 6.58k | int res; | 416 | | | 417 | 6.58k | URI_CHECK_MEMORY_MANAGER(memory); /* may return */ | 418 | | | 419 | 6.58k | res = URI_FUNC(RemoveBaseUriImpl)(dest, absSource, absBase, domainRootMode, memory); | 420 | 6.58k | if ((res != URI_SUCCESS) && (dest != NULL)) { | 421 | 6.39k | URI_FUNC(FreeUriMembersMm)(dest, memory); | 422 | 6.39k | } | 423 | 6.58k | return res; | 424 | 6.58k | } |
|
425 | | |
426 | | #endif |