Coverage Report

Created: 2025-11-15 06:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/uriparser/src/UriParse.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
/**
41
 * @file UriParse.c
42
 * Holds the RFC 3986 %URI parsing implementation.
43
 * NOTE: This source file includes itself twice.
44
 */
45
46
/* What encodings are enabled? */
47
#include <uriparser/UriDefsConfig.h>
48
#if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE))
49
/* Include SELF twice */
50
#  ifdef URI_ENABLE_ANSI
51
#    define URI_PASS_ANSI 1
52
#    include "UriParse.c"
53
#    undef URI_PASS_ANSI
54
#  endif
55
#  ifdef URI_ENABLE_UNICODE
56
#    define URI_PASS_UNICODE 1
57
#    include "UriParse.c"
58
#    undef URI_PASS_UNICODE
59
#  endif
60
#else
61
#  ifdef URI_PASS_ANSI
62
#    include <uriparser/UriDefsAnsi.h>
63
#  else
64
#    include <uriparser/UriDefsUnicode.h>
65
#    include <wchar.h>
66
#  endif
67
68
#  ifndef URI_DOXYGEN
69
#    include <uriparser/Uri.h>
70
#    include <uriparser/UriIp4.h>
71
#    include "UriCommon.h"
72
#    include "UriMemory.h"
73
#    include "UriParseBase.h"
74
#  endif
75
76
#  define URI_SET_DIGIT \
77
14.8M
  _UT('0') : case _UT('1'): \
78
15.1M
  case _UT('2'): \
79
15.3M
  case _UT('3'): \
80
15.5M
  case _UT('4'): \
81
18.0M
  case _UT('5'): \
82
18.7M
  case _UT('6'): \
83
18.8M
  case _UT('7'): \
84
18.9M
  case _UT('8'): \
85
19.1M
  case _UT('9')
86
87
#  define URI_SET_HEX_LETTER_UPPER \
88
12.1M
  _UT('A') : case _UT('B'): \
89
12.2M
  case _UT('C'): \
90
12.6M
  case _UT('D'): \
91
12.7M
  case _UT('E'): \
92
12.9M
  case _UT('F')
93
94
#  define URI_SET_HEX_LETTER_LOWER \
95
16.9M
  _UT('a') : case _UT('b'): \
96
17.1M
  case _UT('c'): \
97
17.3M
  case _UT('d'): \
98
17.9M
  case _UT('e'): \
99
19.1M
  case _UT('f')
100
101
#  define URI_SET_HEXDIG \
102
114k
  URI_SET_DIGIT: \
103
145k
  case URI_SET_HEX_LETTER_UPPER: \
104
155k
  case URI_SET_HEX_LETTER_LOWER
105
106
#  define URI_SET_ALPHA \
107
12.7M
  URI_SET_HEX_LETTER_UPPER: \
108
18.9M
  case URI_SET_HEX_LETTER_LOWER: \
109
19.0M
  case _UT('g'): \
110
19.0M
  case _UT('G'): \
111
23.6M
  case _UT('h'): \
112
24.2M
  case _UT('H'): \
113
27.7M
  case _UT('i'): \
114
42.1M
  case _UT('I'): \
115
42.3M
  case _UT('j'): \
116
42.3M
  case _UT('J'): \
117
44.9M
  case _UT('k'): \
118
45.0M
  case _UT('K'): \
119
45.1M
  case _UT('l'): \
120
46.7M
  case _UT('L'): \
121
46.8M
  case _UT('m'): \
122
46.8M
  case _UT('M'): \
123
47.0M
  case _UT('n'): \
124
47.2M
  case _UT('N'): \
125
47.4M
  case _UT('o'): \
126
47.5M
  case _UT('O'): \
127
47.5M
  case _UT('p'): \
128
47.8M
  case _UT('P'): \
129
47.8M
  case _UT('q'): \
130
47.9M
  case _UT('Q'): \
131
48.3M
  case _UT('r'): \
132
48.3M
  case _UT('R'): \
133
48.4M
  case _UT('s'): \
134
48.5M
  case _UT('S'): \
135
48.8M
  case _UT('t'): \
136
48.8M
  case _UT('T'): \
137
48.9M
  case _UT('u'): \
138
49.2M
  case _UT('U'): \
139
49.3M
  case _UT('v'): \
140
49.4M
  case _UT('V'): \
141
49.5M
  case _UT('w'): \
142
49.6M
  case _UT('W'): \
143
49.8M
  case _UT('x'): \
144
54.4M
  case _UT('X'): \
145
54.5M
  case _UT('y'): \
146
54.8M
  case _UT('Y'): \
147
55.1M
  case _UT('z'): \
148
65.5M
  case _UT('Z')
149
150
static const URI_CHAR * URI_FUNC(ParseAuthority)(URI_TYPE(ParserState) * state,
151
                                                 const URI_CHAR * first,
152
                                                 const URI_CHAR * afterLast,
153
                                                 UriMemoryManager * memory);
154
static const URI_CHAR * URI_FUNC(ParseAuthorityTwo)(URI_TYPE(ParserState) * state,
155
                                                    const URI_CHAR * first,
156
                                                    const URI_CHAR * afterLast);
157
static const URI_CHAR * URI_FUNC(ParseHexZero)(URI_TYPE(ParserState) * state,
158
                                               const URI_CHAR * first,
159
                                               const URI_CHAR * afterLast);
160
static const URI_CHAR * URI_FUNC(ParseHierPart)(URI_TYPE(ParserState) * state,
161
                                                const URI_CHAR * first,
162
                                                const URI_CHAR * afterLast,
163
                                                UriMemoryManager * memory);
164
static const URI_CHAR * URI_FUNC(ParseIpFutLoop)(URI_TYPE(ParserState) * state,
165
                                                 const URI_CHAR * first,
166
                                                 const URI_CHAR * afterLast,
167
                                                 UriMemoryManager * memory);
168
static const URI_CHAR * URI_FUNC(ParseIpFutStopGo)(URI_TYPE(ParserState) * state,
169
                                                   const URI_CHAR * first,
170
                                                   const URI_CHAR * afterLast,
171
                                                   UriMemoryManager * memory);
172
static const URI_CHAR * URI_FUNC(ParseIpLit2)(URI_TYPE(ParserState) * state,
173
                                              const URI_CHAR * first,
174
                                              const URI_CHAR * afterLast,
175
                                              UriMemoryManager * memory);
176
static const URI_CHAR * URI_FUNC(ParseIPv6address2)(URI_TYPE(ParserState) * state,
177
                                                    const URI_CHAR * first,
178
                                                    const URI_CHAR * afterLast,
179
                                                    UriMemoryManager * memory);
180
static const URI_CHAR * URI_FUNC(ParseMustBeSegmentNzNc)(URI_TYPE(ParserState) * state,
181
                                                         const URI_CHAR * first,
182
                                                         const URI_CHAR * afterLast,
183
                                                         UriMemoryManager * memory);
184
static const URI_CHAR * URI_FUNC(ParseOwnHost)(URI_TYPE(ParserState) * state,
185
                                               const URI_CHAR * first,
186
                                               const URI_CHAR * afterLast,
187
                                               UriMemoryManager * memory);
188
static const URI_CHAR * URI_FUNC(ParseOwnHost2)(URI_TYPE(ParserState) * state,
189
                                                const URI_CHAR * first,
190
                                                const URI_CHAR * afterLast,
191
                                                UriMemoryManager * memory);
192
static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfo)(URI_TYPE(ParserState) * state,
193
                                                       const URI_CHAR * first,
194
                                                       const URI_CHAR * afterLast,
195
                                                       UriMemoryManager * memory);
196
static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfoNz)(URI_TYPE(ParserState) * state,
197
                                                         const URI_CHAR * first,
198
                                                         const URI_CHAR * afterLast,
199
                                                         UriMemoryManager * memory);
200
static const URI_CHAR * URI_FUNC(ParseOwnPortUserInfo)(URI_TYPE(ParserState) * state,
201
                                                       const URI_CHAR * first,
202
                                                       const URI_CHAR * afterLast,
203
                                                       UriMemoryManager * memory);
204
static const URI_CHAR * URI_FUNC(ParseOwnUserInfo)(URI_TYPE(ParserState) * state,
205
                                                   const URI_CHAR * first,
206
                                                   const URI_CHAR * afterLast,
207
                                                   UriMemoryManager * memory);
208
static const URI_CHAR * URI_FUNC(ParsePartHelperTwo)(URI_TYPE(ParserState) * state,
209
                                                     const URI_CHAR * first,
210
                                                     const URI_CHAR * afterLast,
211
                                                     UriMemoryManager * memory);
212
static const URI_CHAR * URI_FUNC(ParsePathAbsEmpty)(URI_TYPE(ParserState) * state,
213
                                                    const URI_CHAR * first,
214
                                                    const URI_CHAR * afterLast,
215
                                                    UriMemoryManager * memory);
216
static const URI_CHAR * URI_FUNC(ParsePathAbsNoLeadSlash)(URI_TYPE(ParserState) * state,
217
                                                          const URI_CHAR * first,
218
                                                          const URI_CHAR * afterLast,
219
                                                          UriMemoryManager * memory);
220
static const URI_CHAR * URI_FUNC(ParsePathRootless)(URI_TYPE(ParserState) * state,
221
                                                    const URI_CHAR * first,
222
                                                    const URI_CHAR * afterLast,
223
                                                    UriMemoryManager * memory);
224
static const URI_CHAR * URI_FUNC(ParsePchar)(URI_TYPE(ParserState) * state,
225
                                             const URI_CHAR * first,
226
                                             const URI_CHAR * afterLast,
227
                                             UriMemoryManager * memory);
228
static const URI_CHAR * URI_FUNC(ParsePctEncoded)(URI_TYPE(ParserState) * state,
229
                                                  const URI_CHAR * first,
230
                                                  const URI_CHAR * afterLast,
231
                                                  UriMemoryManager * memory);
232
static const URI_CHAR * URI_FUNC(ParsePctSubUnres)(URI_TYPE(ParserState) * state,
233
                                                   const URI_CHAR * first,
234
                                                   const URI_CHAR * afterLast,
235
                                                   UriMemoryManager * memory);
236
static const URI_CHAR * URI_FUNC(ParsePort)(URI_TYPE(ParserState) * state,
237
                                            const URI_CHAR * first,
238
                                            const URI_CHAR * afterLast);
239
static const URI_CHAR * URI_FUNC(ParseQueryFrag)(URI_TYPE(ParserState) * state,
240
                                                 const URI_CHAR * first,
241
                                                 const URI_CHAR * afterLast,
242
                                                 UriMemoryManager * memory);
243
static const URI_CHAR * URI_FUNC(ParseSegment)(URI_TYPE(ParserState) * state,
244
                                               const URI_CHAR * first,
245
                                               const URI_CHAR * afterLast,
246
                                               UriMemoryManager * memory);
247
static const URI_CHAR * URI_FUNC(ParseSegmentNz)(URI_TYPE(ParserState) * state,
248
                                                 const URI_CHAR * first,
249
                                                 const URI_CHAR * afterLast,
250
                                                 UriMemoryManager * memory);
251
static const URI_CHAR * URI_FUNC(ParseSegmentNzNcOrScheme2)(URI_TYPE(ParserState) * state,
252
                                                            const URI_CHAR * first,
253
                                                            const URI_CHAR * afterLast,
254
                                                            UriMemoryManager * memory);
255
static const URI_CHAR * URI_FUNC(ParseUriReference)(URI_TYPE(ParserState) * state,
256
                                                    const URI_CHAR * first,
257
                                                    const URI_CHAR * afterLast,
258
                                                    UriMemoryManager * memory);
259
static const URI_CHAR * URI_FUNC(ParseUriTail)(URI_TYPE(ParserState) * state,
260
                                               const URI_CHAR * first,
261
                                               const URI_CHAR * afterLast,
262
                                               UriMemoryManager * memory);
263
static const URI_CHAR * URI_FUNC(ParseUriTailTwo)(URI_TYPE(ParserState) * state,
264
                                                  const URI_CHAR * first,
265
                                                  const URI_CHAR * afterLast,
266
                                                  UriMemoryManager * memory);
267
static const URI_CHAR * URI_FUNC(ParseZeroMoreSlashSegs)(URI_TYPE(ParserState) * state,
268
                                                         const URI_CHAR * first,
269
                                                         const URI_CHAR * afterLast,
270
                                                         UriMemoryManager * memory);
271
272
static UriBool URI_FUNC(OnExitOwnHost2)(URI_TYPE(ParserState) * state,
273
                                        const URI_CHAR * first,
274
                                        UriMemoryManager * memory);
275
static UriBool URI_FUNC(OnExitOwnHostUserInfo)(URI_TYPE(ParserState) * state,
276
                                               const URI_CHAR * first,
277
                                               UriMemoryManager * memory);
278
static UriBool URI_FUNC(OnExitOwnPortUserInfo)(URI_TYPE(ParserState) * state,
279
                                               const URI_CHAR * first,
280
                                               UriMemoryManager * memory);
281
static UriBool URI_FUNC(OnExitSegmentNzNcOrScheme2)(URI_TYPE(ParserState) * state,
282
                                                    const URI_CHAR * first,
283
                                                    UriMemoryManager * memory);
284
static void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state);
285
286
static void URI_FUNC(ResetParserStateExceptUri)(URI_TYPE(ParserState) * state);
287
288
static UriBool URI_FUNC(PushPathSegment)(URI_TYPE(ParserState) * state,
289
                                         const URI_CHAR * first,
290
                                         const URI_CHAR * afterLast,
291
                                         UriMemoryManager * memory);
292
293
static void URI_FUNC(StopSyntax)(URI_TYPE(ParserState) * state, const URI_CHAR * errorPos,
294
                                 UriMemoryManager * memory);
295
static void URI_FUNC(StopMalloc)(URI_TYPE(ParserState) * state,
296
                                 UriMemoryManager * memory);
297
298
static int URI_FUNC(ParseUriExMm)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
299
                                  const URI_CHAR * afterLast, UriMemoryManager * memory);
300
301
static URI_INLINE void URI_FUNC(StopSyntax)(URI_TYPE(ParserState) * state,
302
                                            const URI_CHAR * errorPos,
303
13.3k
                                            UriMemoryManager * memory) {
304
13.3k
    URI_FUNC(FreeUriMembersMm)(state->uri, memory);
305
13.3k
    state->errorPos = errorPos;
306
13.3k
    state->errorCode = URI_ERROR_SYNTAX;
307
13.3k
}
UriParse.c:uriStopSyntaxA
Line
Count
Source
303
5.99k
                                            UriMemoryManager * memory) {
304
5.99k
    URI_FUNC(FreeUriMembersMm)(state->uri, memory);
305
5.99k
    state->errorPos = errorPos;
306
5.99k
    state->errorCode = URI_ERROR_SYNTAX;
307
5.99k
}
UriParse.c:uriStopSyntaxW
Line
Count
Source
303
7.32k
                                            UriMemoryManager * memory) {
304
7.32k
    URI_FUNC(FreeUriMembersMm)(state->uri, memory);
305
7.32k
    state->errorPos = errorPos;
306
7.32k
    state->errorCode = URI_ERROR_SYNTAX;
307
7.32k
}
308
309
static URI_INLINE void URI_FUNC(StopMalloc)(URI_TYPE(ParserState) * state,
310
0
                                            UriMemoryManager * memory) {
311
0
    URI_FUNC(FreeUriMembersMm)(state->uri, memory);
312
0
    state->errorPos = NULL;
313
0
    state->errorCode = URI_ERROR_MALLOC;
314
0
}
Unexecuted instantiation: UriParse.c:uriStopMallocA
Unexecuted instantiation: UriParse.c:uriStopMallocW
315
316
/*
317
 * [authority]-><[>[ipLit2][authorityTwo]
318
 * [authority]->[ownHostUserInfoNz]
319
 * [authority]-><NULL>
320
 */
321
static URI_INLINE const URI_CHAR * URI_FUNC(ParseAuthority)(URI_TYPE(ParserState) * state,
322
                                                            const URI_CHAR * first,
323
                                                            const URI_CHAR * afterLast,
324
20.1k
                                                            UriMemoryManager * memory) {
325
20.1k
    if (first >= afterLast) {
326
        /* "" regname host */
327
43
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
328
43
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
329
43
        return afterLast;
330
43
    }
331
332
20.1k
    switch (*first) {
333
7.98k
    case _UT('['): {
334
7.98k
        const URI_CHAR * const afterIpLit2 =
335
7.98k
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
336
7.98k
        if (afterIpLit2 == NULL) {
337
6.65k
            return NULL;
338
6.65k
        }
339
1.32k
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
340
1.32k
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
341
7.98k
    }
342
343
53
    case _UT('!'):
344
119
    case _UT('$'):
345
227
    case _UT('%'):
346
292
    case _UT('&'):
347
365
    case _UT('('):
348
433
    case _UT(')'):
349
494
    case _UT('-'):
350
554
    case _UT('*'):
351
626
    case _UT(','):
352
739
    case _UT('.'):
353
4.27k
    case _UT(':'):
354
4.34k
    case _UT(';'):
355
7.40k
    case _UT('@'):
356
7.47k
    case _UT('\''):
357
7.56k
    case _UT('_'):
358
7.61k
    case _UT('~'):
359
7.67k
    case _UT('+'):
360
7.73k
    case _UT('='):
361
76.2k
    case URI_SET_DIGIT:
362
76.2k
    case URI_SET_ALPHA:
363
11.8k
        state->uri->userInfo.first = first; /* USERINFO BEGIN */
364
11.8k
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
365
366
284
    default:
367
        /* "" regname host */
368
284
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
369
284
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
370
284
        return first;
371
20.1k
    }
372
20.1k
}
UriParse.c:uriParseAuthorityA
Line
Count
Source
324
9.86k
                                                            UriMemoryManager * memory) {
325
9.86k
    if (first >= afterLast) {
326
        /* "" regname host */
327
17
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
328
17
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
329
17
        return afterLast;
330
17
    }
331
332
9.84k
    switch (*first) {
333
3.85k
    case _UT('['): {
334
3.85k
        const URI_CHAR * const afterIpLit2 =
335
3.85k
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
336
3.85k
        if (afterIpLit2 == NULL) {
337
3.22k
            return NULL;
338
3.22k
        }
339
628
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
340
628
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
341
3.85k
    }
342
343
25
    case _UT('!'):
344
59
    case _UT('$'):
345
108
    case _UT('%'):
346
138
    case _UT('&'):
347
176
    case _UT('('):
348
210
    case _UT(')'):
349
240
    case _UT('-'):
350
267
    case _UT('*'):
351
301
    case _UT(','):
352
344
    case _UT('.'):
353
2.11k
    case _UT(':'):
354
2.15k
    case _UT(';'):
355
3.58k
    case _UT('@'):
356
3.61k
    case _UT('\''):
357
3.64k
    case _UT('_'):
358
3.66k
    case _UT('~'):
359
3.69k
    case _UT('+'):
360
3.72k
    case _UT('='):
361
36.7k
    case URI_SET_DIGIT:
362
36.7k
    case URI_SET_ALPHA:
363
5.88k
        state->uri->userInfo.first = first; /* USERINFO BEGIN */
364
5.88k
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
365
366
111
    default:
367
        /* "" regname host */
368
111
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
369
111
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
370
111
        return first;
371
9.84k
    }
372
9.84k
}
UriParse.c:uriParseAuthorityW
Line
Count
Source
324
10.2k
                                                            UriMemoryManager * memory) {
325
10.2k
    if (first >= afterLast) {
326
        /* "" regname host */
327
26
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
328
26
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
329
26
        return afterLast;
330
26
    }
331
332
10.2k
    switch (*first) {
333
4.12k
    case _UT('['): {
334
4.12k
        const URI_CHAR * const afterIpLit2 =
335
4.12k
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
336
4.12k
        if (afterIpLit2 == NULL) {
337
3.42k
            return NULL;
338
3.42k
        }
339
699
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
340
699
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
341
4.12k
    }
342
343
28
    case _UT('!'):
344
60
    case _UT('$'):
345
119
    case _UT('%'):
346
154
    case _UT('&'):
347
189
    case _UT('('):
348
223
    case _UT(')'):
349
254
    case _UT('-'):
350
287
    case _UT('*'):
351
325
    case _UT(','):
352
395
    case _UT('.'):
353
2.15k
    case _UT(':'):
354
2.19k
    case _UT(';'):
355
3.82k
    case _UT('@'):
356
3.85k
    case _UT('\''):
357
3.92k
    case _UT('_'):
358
3.94k
    case _UT('~'):
359
3.97k
    case _UT('+'):
360
4.00k
    case _UT('='):
361
39.4k
    case URI_SET_DIGIT:
362
39.4k
    case URI_SET_ALPHA:
363
5.95k
        state->uri->userInfo.first = first; /* USERINFO BEGIN */
364
5.95k
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
365
366
173
    default:
367
        /* "" regname host */
368
173
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
369
173
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
370
173
        return first;
371
10.2k
    }
372
10.2k
}
373
374
/*
375
 * [authorityTwo]-><:>[port]
376
 * [authorityTwo]-><NULL>
377
 */
378
static URI_INLINE const URI_CHAR *
379
URI_FUNC(ParseAuthorityTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
380
1.97k
                            const URI_CHAR * afterLast) {
381
1.97k
    if (first >= afterLast) {
382
957
        return afterLast;
383
957
    }
384
385
1.01k
    switch (*first) {
386
564
    case _UT(':'): {
387
564
        const URI_CHAR * const afterPort =
388
564
            URI_FUNC(ParsePort)(state, first + 1, afterLast);
389
564
        if (afterPort == NULL) {
390
0
            return NULL;
391
0
        }
392
564
        state->uri->portText.first = first + 1; /* PORT BEGIN */
393
564
        state->uri->portText.afterLast = afterPort; /* PORT END */
394
564
        return afterPort;
395
564
    }
396
397
452
    default:
398
452
        return first;
399
1.01k
    }
400
1.01k
}
UriParse.c:uriParseAuthorityTwoA
Line
Count
Source
380
868
                            const URI_CHAR * afterLast) {
381
868
    if (first >= afterLast) {
382
493
        return afterLast;
383
493
    }
384
385
375
    switch (*first) {
386
234
    case _UT(':'): {
387
234
        const URI_CHAR * const afterPort =
388
234
            URI_FUNC(ParsePort)(state, first + 1, afterLast);
389
234
        if (afterPort == NULL) {
390
0
            return NULL;
391
0
        }
392
234
        state->uri->portText.first = first + 1; /* PORT BEGIN */
393
234
        state->uri->portText.afterLast = afterPort; /* PORT END */
394
234
        return afterPort;
395
234
    }
396
397
141
    default:
398
141
        return first;
399
375
    }
400
375
}
UriParse.c:uriParseAuthorityTwoW
Line
Count
Source
380
1.10k
                            const URI_CHAR * afterLast) {
381
1.10k
    if (first >= afterLast) {
382
464
        return afterLast;
383
464
    }
384
385
641
    switch (*first) {
386
330
    case _UT(':'): {
387
330
        const URI_CHAR * const afterPort =
388
330
            URI_FUNC(ParsePort)(state, first + 1, afterLast);
389
330
        if (afterPort == NULL) {
390
0
            return NULL;
391
0
        }
392
330
        state->uri->portText.first = first + 1; /* PORT BEGIN */
393
330
        state->uri->portText.afterLast = afterPort; /* PORT END */
394
330
        return afterPort;
395
330
    }
396
397
311
    default:
398
311
        return first;
399
641
    }
400
641
}
401
402
/*
403
 * [hexZero]->[HEXDIG][hexZero]
404
 * [hexZero]-><NULL>
405
 */
406
static const URI_CHAR * URI_FUNC(ParseHexZero)(URI_TYPE(ParserState) * state,
407
                                               const URI_CHAR * first,
408
23.9k
                                               const URI_CHAR * afterLast) {
409
23.9k
    if (first >= afterLast) {
410
851
        return afterLast;
411
851
    }
412
413
23.0k
    switch (*first) {
414
18.7k
    case URI_SET_HEXDIG:
415
18.7k
        return URI_FUNC(ParseHexZero)(state, first + 1, afterLast);
416
417
4.33k
    default:
418
4.33k
        return first;
419
23.0k
    }
420
23.0k
}
UriParse.c:uriParseHexZeroA
Line
Count
Source
408
12.0k
                                               const URI_CHAR * afterLast) {
409
12.0k
    if (first >= afterLast) {
410
424
        return afterLast;
411
424
    }
412
413
11.5k
    switch (*first) {
414
9.45k
    case URI_SET_HEXDIG:
415
9.45k
        return URI_FUNC(ParseHexZero)(state, first + 1, afterLast);
416
417
2.14k
    default:
418
2.14k
        return first;
419
11.5k
    }
420
11.5k
}
UriParse.c:uriParseHexZeroW
Line
Count
Source
408
11.9k
                                               const URI_CHAR * afterLast) {
409
11.9k
    if (first >= afterLast) {
410
427
        return afterLast;
411
427
    }
412
413
11.4k
    switch (*first) {
414
9.31k
    case URI_SET_HEXDIG:
415
9.31k
        return URI_FUNC(ParseHexZero)(state, first + 1, afterLast);
416
417
2.18k
    default:
418
2.18k
        return first;
419
11.4k
    }
420
11.4k
}
421
422
/*
423
 * [hierPart]->[pathRootless]
424
 * [hierPart]-></>[partHelperTwo]
425
 * [hierPart]-><NULL>
426
 */
427
static URI_INLINE const URI_CHAR * URI_FUNC(ParseHierPart)(URI_TYPE(ParserState) * state,
428
                                                           const URI_CHAR * first,
429
                                                           const URI_CHAR * afterLast,
430
2.03k
                                                           UriMemoryManager * memory) {
431
2.03k
    if (first >= afterLast) {
432
334
        return afterLast;
433
334
    }
434
435
1.70k
    switch (*first) {
436
17
    case _UT('!'):
437
25
    case _UT('$'):
438
34
    case _UT('%'):
439
44
    case _UT('&'):
440
60
    case _UT('('):
441
70
    case _UT(')'):
442
105
    case _UT('-'):
443
126
    case _UT('*'):
444
143
    case _UT(','):
445
214
    case _UT('.'):
446
261
    case _UT(':'):
447
271
    case _UT(';'):
448
287
    case _UT('@'):
449
301
    case _UT('\''):
450
312
    case _UT('_'):
451
323
    case _UT('~'):
452
337
    case _UT('+'):
453
349
    case _UT('='):
454
4.15k
    case URI_SET_DIGIT:
455
4.15k
    case URI_SET_ALPHA:
456
1.26k
        return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory);
457
458
391
    case _UT('/'):
459
391
        return URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
460
461
43
    default:
462
43
        return first;
463
1.70k
    }
464
1.70k
}
UriParse.c:uriParseHierPartA
Line
Count
Source
430
1.05k
                                                           UriMemoryManager * memory) {
431
1.05k
    if (first >= afterLast) {
432
176
        return afterLast;
433
176
    }
434
435
881
    switch (*first) {
436
4
    case _UT('!'):
437
8
    case _UT('$'):
438
13
    case _UT('%'):
439
19
    case _UT('&'):
440
23
    case _UT('('):
441
29
    case _UT(')'):
442
38
    case _UT('-'):
443
55
    case _UT('*'):
444
66
    case _UT(','):
445
100
    case _UT('.'):
446
122
    case _UT(':'):
447
128
    case _UT(';'):
448
136
    case _UT('@'):
449
142
    case _UT('\''):
450
148
    case _UT('_'):
451
153
    case _UT('~'):
452
160
    case _UT('+'):
453
168
    case _UT('='):
454
2.04k
    case URI_SET_DIGIT:
455
2.04k
    case URI_SET_ALPHA:
456
676
        return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory);
457
458
181
    case _UT('/'):
459
181
        return URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
460
461
24
    default:
462
24
        return first;
463
881
    }
464
881
}
UriParse.c:uriParseHierPartW
Line
Count
Source
430
977
                                                           UriMemoryManager * memory) {
431
977
    if (first >= afterLast) {
432
158
        return afterLast;
433
158
    }
434
435
819
    switch (*first) {
436
13
    case _UT('!'):
437
17
    case _UT('$'):
438
21
    case _UT('%'):
439
25
    case _UT('&'):
440
37
    case _UT('('):
441
41
    case _UT(')'):
442
67
    case _UT('-'):
443
71
    case _UT('*'):
444
77
    case _UT(','):
445
114
    case _UT('.'):
446
139
    case _UT(':'):
447
143
    case _UT(';'):
448
151
    case _UT('@'):
449
159
    case _UT('\''):
450
164
    case _UT('_'):
451
170
    case _UT('~'):
452
177
    case _UT('+'):
453
181
    case _UT('='):
454
2.11k
    case URI_SET_DIGIT:
455
2.11k
    case URI_SET_ALPHA:
456
590
        return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory);
457
458
210
    case _UT('/'):
459
210
        return URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
460
461
19
    default:
462
19
        return first;
463
819
    }
464
819
}
465
466
/*
467
 * [ipFutLoop]->[subDelims][ipFutStopGo]
468
 * [ipFutLoop]->[unreserved][ipFutStopGo]
469
 * [ipFutLoop]-><:>[ipFutStopGo]
470
 */
471
static const URI_CHAR * URI_FUNC(ParseIpFutLoop)(URI_TYPE(ParserState) * state,
472
                                                 const URI_CHAR * first,
473
                                                 const URI_CHAR * afterLast,
474
4.71M
                                                 UriMemoryManager * memory) {
475
4.71M
    if (first >= afterLast) {
476
4
        URI_FUNC(StopSyntax)(state, afterLast, memory);
477
4
        return NULL;
478
4
    }
479
480
4.71M
    switch (*first) {
481
21.0k
    case _UT('!'):
482
22.3k
    case _UT('$'):
483
26.9k
    case _UT('&'):
484
29.0k
    case _UT('('):
485
31.0k
    case _UT(')'):
486
36.7k
    case _UT('-'):
487
38.2k
    case _UT('*'):
488
39.7k
    case _UT(','):
489
70.7k
    case _UT('.'):
490
72.4k
    case _UT(':'):
491
75.2k
    case _UT(';'):
492
77.1k
    case _UT('\''):
493
78.4k
    case _UT('_'):
494
79.6k
    case _UT('~'):
495
81.0k
    case _UT('+'):
496
83.2k
    case _UT('='):
497
5.74M
    case URI_SET_DIGIT:
498
5.74M
    case URI_SET_ALPHA:
499
4.71M
        return URI_FUNC(ParseIpFutStopGo)(state, first + 1, afterLast, memory);
500
501
4
    default:
502
4
        URI_FUNC(StopSyntax)(state, first, memory);
503
4
        return NULL;
504
4.71M
    }
505
4.71M
}
UriParse.c:uriParseIpFutLoopA
Line
Count
Source
474
3.92M
                                                 UriMemoryManager * memory) {
475
3.92M
    if (first >= afterLast) {
476
2
        URI_FUNC(StopSyntax)(state, afterLast, memory);
477
2
        return NULL;
478
2
    }
479
480
3.92M
    switch (*first) {
481
20.4k
    case _UT('!'):
482
21.3k
    case _UT('$'):
483
22.5k
    case _UT('&'):
484
23.6k
    case _UT('('):
485
25.1k
    case _UT(')'):
486
30.1k
    case _UT('-'):
487
31.1k
    case _UT('*'):
488
31.9k
    case _UT(','):
489
60.8k
    case _UT('.'):
490
61.7k
    case _UT(':'):
491
64.1k
    case _UT(';'):
492
64.9k
    case _UT('\''):
493
65.8k
    case _UT('_'):
494
66.5k
    case _UT('~'):
495
67.3k
    case _UT('+'):
496
68.7k
    case _UT('='):
497
4.60M
    case URI_SET_DIGIT:
498
4.60M
    case URI_SET_ALPHA:
499
3.92M
        return URI_FUNC(ParseIpFutStopGo)(state, first + 1, afterLast, memory);
500
501
2
    default:
502
2
        URI_FUNC(StopSyntax)(state, first, memory);
503
        return NULL;
504
3.92M
    }
505
3.92M
}
UriParse.c:uriParseIpFutLoopW
Line
Count
Source
474
785k
                                                 UriMemoryManager * memory) {
475
785k
    if (first >= afterLast) {
476
2
        URI_FUNC(StopSyntax)(state, afterLast, memory);
477
2
        return NULL;
478
2
    }
479
480
785k
    switch (*first) {
481
524
    case _UT('!'):
482
1.07k
    case _UT('$'):
483
4.48k
    case _UT('&'):
484
5.36k
    case _UT('('):
485
5.88k
    case _UT(')'):
486
6.60k
    case _UT('-'):
487
7.09k
    case _UT('*'):
488
7.77k
    case _UT(','):
489
9.90k
    case _UT('.'):
490
10.6k
    case _UT(':'):
491
11.1k
    case _UT(';'):
492
12.1k
    case _UT('\''):
493
12.5k
    case _UT('_'):
494
13.1k
    case _UT('~'):
495
13.7k
    case _UT('+'):
496
14.4k
    case _UT('='):
497
1.14M
    case URI_SET_DIGIT:
498
1.14M
    case URI_SET_ALPHA:
499
785k
        return URI_FUNC(ParseIpFutStopGo)(state, first + 1, afterLast, memory);
500
501
2
    default:
502
2
        URI_FUNC(StopSyntax)(state, first, memory);
503
        return NULL;
504
785k
    }
505
785k
}
506
507
/*
508
 * [ipFutStopGo]->[ipFutLoop]
509
 * [ipFutStopGo]-><NULL>
510
 */
511
static const URI_CHAR * URI_FUNC(ParseIpFutStopGo)(URI_TYPE(ParserState) * state,
512
                                                   const URI_CHAR * first,
513
                                                   const URI_CHAR * afterLast,
514
4.71M
                                                   UriMemoryManager * memory) {
515
4.71M
    if (first >= afterLast) {
516
3.68k
        return afterLast;
517
3.68k
    }
518
519
4.70M
    switch (*first) {
520
20.9k
    case _UT('!'):
521
22.2k
    case _UT('$'):
522
26.8k
    case _UT('&'):
523
28.8k
    case _UT('('):
524
30.7k
    case _UT(')'):
525
36.4k
    case _UT('-'):
526
37.8k
    case _UT('*'):
527
39.2k
    case _UT(','):
528
70.2k
    case _UT('.'):
529
71.8k
    case _UT(':'):
530
74.6k
    case _UT(';'):
531
76.4k
    case _UT('\''):
532
77.7k
    case _UT('_'):
533
78.8k
    case _UT('~'):
534
80.2k
    case _UT('+'):
535
82.3k
    case _UT('='):
536
5.73M
    case URI_SET_DIGIT:
537
5.73M
    case URI_SET_ALPHA:
538
4.70M
        return URI_FUNC(ParseIpFutLoop)(state, first, afterLast, memory);
539
540
517
    default:
541
517
        return first;
542
4.70M
    }
543
4.70M
}
UriParse.c:uriParseIpFutStopGoA
Line
Count
Source
514
3.92M
                                                   UriMemoryManager * memory) {
515
3.92M
    if (first >= afterLast) {
516
1.89k
        return afterLast;
517
1.89k
    }
518
519
3.92M
    switch (*first) {
520
20.4k
    case _UT('!'):
521
21.2k
    case _UT('$'):
522
22.4k
    case _UT('&'):
523
23.5k
    case _UT('('):
524
25.0k
    case _UT(')'):
525
29.9k
    case _UT('-'):
526
30.9k
    case _UT('*'):
527
31.7k
    case _UT(','):
528
60.5k
    case _UT('.'):
529
61.4k
    case _UT(':'):
530
63.8k
    case _UT(';'):
531
64.6k
    case _UT('\''):
532
65.4k
    case _UT('_'):
533
66.1k
    case _UT('~'):
534
66.8k
    case _UT('+'):
535
68.2k
    case _UT('='):
536
4.59M
    case URI_SET_DIGIT:
537
4.59M
    case URI_SET_ALPHA:
538
3.92M
        return URI_FUNC(ParseIpFutLoop)(state, first, afterLast, memory);
539
540
223
    default:
541
223
        return first;
542
3.92M
    }
543
3.92M
}
UriParse.c:uriParseIpFutStopGoW
Line
Count
Source
514
785k
                                                   UriMemoryManager * memory) {
515
785k
    if (first >= afterLast) {
516
1.79k
        return afterLast;
517
1.79k
    }
518
519
783k
    switch (*first) {
520
502
    case _UT('!'):
521
1.02k
    case _UT('$'):
522
4.41k
    case _UT('&'):
523
5.27k
    case _UT('('):
524
5.77k
    case _UT(')'):
525
6.46k
    case _UT('-'):
526
6.93k
    case _UT('*'):
527
7.57k
    case _UT(','):
528
9.66k
    case _UT('.'):
529
10.3k
    case _UT(':'):
530
10.8k
    case _UT(';'):
531
11.7k
    case _UT('\''):
532
12.2k
    case _UT('_'):
533
12.7k
    case _UT('~'):
534
13.3k
    case _UT('+'):
535
14.0k
    case _UT('='):
536
1.13M
    case URI_SET_DIGIT:
537
1.13M
    case URI_SET_ALPHA:
538
782k
        return URI_FUNC(ParseIpFutLoop)(state, first, afterLast, memory);
539
540
294
    default:
541
294
        return first;
542
783k
    }
543
783k
}
544
545
/*
546
 * [ipFuture]-><v>[HEXDIG][hexZero]<.>[ipFutLoop]
547
 */
548
static const URI_CHAR * URI_FUNC(ParseIpFuture)(URI_TYPE(ParserState) * state,
549
                                                const URI_CHAR * first,
550
                                                const URI_CHAR * afterLast,
551
5.21k
                                                UriMemoryManager * memory) {
552
5.21k
    if (first >= afterLast) {
553
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
554
0
        return NULL;
555
0
    }
556
557
    /*
558
    First character has already been
559
    checked before entering this rule.
560
561
    switch (*first) {
562
    case _UT('v'):
563
    case _UT('V'):
564
    */
565
5.21k
    if (afterLast - first < 2) {
566
12
        URI_FUNC(StopSyntax)(state, afterLast, memory);
567
12
        return NULL;
568
12
    }
569
570
5.20k
    switch (first[1]) {
571
62.0k
    case URI_SET_HEXDIG: {
572
62.0k
        const URI_CHAR * afterIpFutLoop;
573
62.0k
        const URI_CHAR * const afterHexZero =
574
62.0k
            URI_FUNC(ParseHexZero)(state, first + 2, afterLast);
575
62.0k
        if (afterHexZero == NULL) {
576
0
            return NULL;
577
0
        }
578
5.18k
        if (afterHexZero >= afterLast) {
579
851
            URI_FUNC(StopSyntax)(state, afterLast, memory);
580
851
            return NULL;
581
851
        }
582
4.33k
        if (*afterHexZero != _UT('.')) {
583
120
            URI_FUNC(StopSyntax)(state, afterHexZero, memory);
584
120
            return NULL;
585
120
        }
586
4.21k
        state->uri->hostText.first = first; /* HOST BEGIN */
587
4.21k
        state->uri->hostData.ipFuture.first = first; /* IPFUTURE BEGIN */
588
4.21k
        afterIpFutLoop =
589
4.21k
            URI_FUNC(ParseIpFutLoop)(state, afterHexZero + 1, afterLast, memory);
590
4.21k
        if (afterIpFutLoop == NULL) {
591
8
            return NULL;
592
8
        }
593
4.20k
        state->uri->hostText.afterLast = afterIpFutLoop; /* HOST END */
594
4.20k
        state->uri->hostData.ipFuture.afterLast = afterIpFutLoop; /* IPFUTURE END */
595
4.20k
        return afterIpFutLoop;
596
4.21k
    }
597
598
15
    default:
599
15
        URI_FUNC(StopSyntax)(state, first + 1, memory);
600
15
        return NULL;
601
5.20k
    }
602
603
    /*
604
    default:
605
            URI_FUNC(StopSyntax)(state, first, memory);
606
            return NULL;
607
    }
608
    */
609
5.20k
}
UriParse.c:uriParseIpFutureA
Line
Count
Source
551
2.58k
                                                UriMemoryManager * memory) {
552
2.58k
    if (first >= afterLast) {
553
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
554
0
        return NULL;
555
0
    }
556
557
    /*
558
    First character has already been
559
    checked before entering this rule.
560
561
    switch (*first) {
562
    case _UT('v'):
563
    case _UT('V'):
564
    */
565
2.58k
    if (afterLast - first < 2) {
566
6
        URI_FUNC(StopSyntax)(state, afterLast, memory);
567
6
        return NULL;
568
6
    }
569
570
2.57k
    switch (first[1]) {
571
27.6k
    case URI_SET_HEXDIG: {
572
27.6k
        const URI_CHAR * afterIpFutLoop;
573
27.6k
        const URI_CHAR * const afterHexZero =
574
27.6k
            URI_FUNC(ParseHexZero)(state, first + 2, afterLast);
575
27.6k
        if (afterHexZero == NULL) {
576
0
            return NULL;
577
0
        }
578
2.57k
        if (afterHexZero >= afterLast) {
579
424
            URI_FUNC(StopSyntax)(state, afterLast, memory);
580
424
            return NULL;
581
424
        }
582
2.14k
        if (*afterHexZero != _UT('.')) {
583
31
            URI_FUNC(StopSyntax)(state, afterHexZero, memory);
584
31
            return NULL;
585
31
        }
586
2.11k
        state->uri->hostText.first = first; /* HOST BEGIN */
587
2.11k
        state->uri->hostData.ipFuture.first = first; /* IPFUTURE BEGIN */
588
2.11k
        afterIpFutLoop =
589
2.11k
            URI_FUNC(ParseIpFutLoop)(state, afterHexZero + 1, afterLast, memory);
590
2.11k
        if (afterIpFutLoop == NULL) {
591
4
            return NULL;
592
4
        }
593
2.11k
        state->uri->hostText.afterLast = afterIpFutLoop; /* HOST END */
594
2.11k
        state->uri->hostData.ipFuture.afterLast = afterIpFutLoop; /* IPFUTURE END */
595
2.11k
        return afterIpFutLoop;
596
2.11k
    }
597
598
5
    default:
599
5
        URI_FUNC(StopSyntax)(state, first + 1, memory);
600
5
        return NULL;
601
2.57k
    }
602
603
    /*
604
    default:
605
            URI_FUNC(StopSyntax)(state, first, memory);
606
            return NULL;
607
    }
608
    */
609
2.57k
}
UriParse.c:uriParseIpFutureW
Line
Count
Source
551
2.62k
                                                UriMemoryManager * memory) {
552
2.62k
    if (first >= afterLast) {
553
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
554
0
        return NULL;
555
0
    }
556
557
    /*
558
    First character has already been
559
    checked before entering this rule.
560
561
    switch (*first) {
562
    case _UT('v'):
563
    case _UT('V'):
564
    */
565
2.62k
    if (afterLast - first < 2) {
566
6
        URI_FUNC(StopSyntax)(state, afterLast, memory);
567
6
        return NULL;
568
6
    }
569
570
2.62k
    switch (first[1]) {
571
34.4k
    case URI_SET_HEXDIG: {
572
34.4k
        const URI_CHAR * afterIpFutLoop;
573
34.4k
        const URI_CHAR * const afterHexZero =
574
34.4k
            URI_FUNC(ParseHexZero)(state, first + 2, afterLast);
575
34.4k
        if (afterHexZero == NULL) {
576
0
            return NULL;
577
0
        }
578
2.61k
        if (afterHexZero >= afterLast) {
579
427
            URI_FUNC(StopSyntax)(state, afterLast, memory);
580
427
            return NULL;
581
427
        }
582
2.18k
        if (*afterHexZero != _UT('.')) {
583
89
            URI_FUNC(StopSyntax)(state, afterHexZero, memory);
584
89
            return NULL;
585
89
        }
586
2.09k
        state->uri->hostText.first = first; /* HOST BEGIN */
587
2.09k
        state->uri->hostData.ipFuture.first = first; /* IPFUTURE BEGIN */
588
2.09k
        afterIpFutLoop =
589
2.09k
            URI_FUNC(ParseIpFutLoop)(state, afterHexZero + 1, afterLast, memory);
590
2.09k
        if (afterIpFutLoop == NULL) {
591
4
            return NULL;
592
4
        }
593
2.09k
        state->uri->hostText.afterLast = afterIpFutLoop; /* HOST END */
594
2.09k
        state->uri->hostData.ipFuture.afterLast = afterIpFutLoop; /* IPFUTURE END */
595
2.09k
        return afterIpFutLoop;
596
2.09k
    }
597
598
10
    default:
599
10
        URI_FUNC(StopSyntax)(state, first + 1, memory);
600
10
        return NULL;
601
2.62k
    }
602
603
    /*
604
    default:
605
            URI_FUNC(StopSyntax)(state, first, memory);
606
            return NULL;
607
    }
608
    */
609
2.62k
}
610
611
/*
612
 * [ipLit2]->[ipFuture]<]>
613
 * [ipLit2]->[IPv6address2]
614
 */
615
static URI_INLINE const URI_CHAR * URI_FUNC(ParseIpLit2)(URI_TYPE(ParserState) * state,
616
                                                         const URI_CHAR * first,
617
                                                         const URI_CHAR * afterLast,
618
8.32k
                                                         UriMemoryManager * memory) {
619
8.32k
    if (first >= afterLast) {
620
12
        URI_FUNC(StopSyntax)(state, afterLast, memory);
621
12
        return NULL;
622
12
    }
623
624
8.31k
    switch (*first) {
625
    /* The leading "v" of IPvFuture is case-insensitive. */
626
3.27k
    case _UT('v'):
627
5.21k
    case _UT('V'): {
628
5.21k
        const URI_CHAR * const afterIpFuture =
629
5.21k
            URI_FUNC(ParseIpFuture)(state, first, afterLast, memory);
630
5.21k
        if (afterIpFuture == NULL) {
631
1.00k
            return NULL;
632
1.00k
        }
633
4.20k
        if (afterIpFuture >= afterLast) {
634
3.68k
            URI_FUNC(StopSyntax)(state, afterLast, memory);
635
3.68k
            return NULL;
636
3.68k
        }
637
517
        if (*afterIpFuture != _UT(']')) {
638
181
            URI_FUNC(StopSyntax)(state, afterIpFuture, memory);
639
181
            return NULL;
640
181
        }
641
336
        return afterIpFuture + 1;
642
517
    }
643
644
1.90k
    case _UT(':'):
645
1.90k
    case _UT(']'):
646
55.1k
    case URI_SET_HEXDIG:
647
55.1k
        state->uri->hostData.ip6 = memory->malloc(
648
55.1k
            memory, 1 * sizeof(UriIp6)); /* Freed when stopping on parse error */
649
55.1k
        if (state->uri->hostData.ip6 == NULL) {
650
0
            URI_FUNC(StopMalloc)(state, memory);
651
0
            return NULL;
652
0
        }
653
3.09k
        return URI_FUNC(ParseIPv6address2)(state, first, afterLast, memory);
654
655
5
    default:
656
5
        URI_FUNC(StopSyntax)(state, first, memory);
657
5
        return NULL;
658
8.31k
    }
659
8.31k
}
UriParse.c:uriParseIpLit2A
Line
Count
Source
618
3.98k
                                                         UriMemoryManager * memory) {
619
3.98k
    if (first >= afterLast) {
620
7
        URI_FUNC(StopSyntax)(state, afterLast, memory);
621
7
        return NULL;
622
7
    }
623
624
3.98k
    switch (*first) {
625
    /* The leading "v" of IPvFuture is case-insensitive. */
626
1.52k
    case _UT('v'):
627
2.58k
    case _UT('V'): {
628
2.58k
        const URI_CHAR * const afterIpFuture =
629
2.58k
            URI_FUNC(ParseIpFuture)(state, first, afterLast, memory);
630
2.58k
        if (afterIpFuture == NULL) {
631
470
            return NULL;
632
470
        }
633
2.11k
        if (afterIpFuture >= afterLast) {
634
1.89k
            URI_FUNC(StopSyntax)(state, afterLast, memory);
635
1.89k
            return NULL;
636
1.89k
        }
637
223
        if (*afterIpFuture != _UT(']')) {
638
61
            URI_FUNC(StopSyntax)(state, afterIpFuture, memory);
639
61
            return NULL;
640
61
        }
641
162
        return afterIpFuture + 1;
642
223
    }
643
644
808
    case _UT(':'):
645
810
    case _UT(']'):
646
24.0k
    case URI_SET_HEXDIG:
647
24.0k
        state->uri->hostData.ip6 = memory->malloc(
648
24.0k
            memory, 1 * sizeof(UriIp6)); /* Freed when stopping on parse error */
649
24.0k
        if (state->uri->hostData.ip6 == NULL) {
650
0
            URI_FUNC(StopMalloc)(state, memory);
651
0
            return NULL;
652
0
        }
653
1.39k
        return URI_FUNC(ParseIPv6address2)(state, first, afterLast, memory);
654
655
2
    default:
656
2
        URI_FUNC(StopSyntax)(state, first, memory);
657
        return NULL;
658
3.98k
    }
659
3.98k
}
UriParse.c:uriParseIpLit2W
Line
Count
Source
618
4.33k
                                                         UriMemoryManager * memory) {
619
4.33k
    if (first >= afterLast) {
620
5
        URI_FUNC(StopSyntax)(state, afterLast, memory);
621
5
        return NULL;
622
5
    }
623
624
4.33k
    switch (*first) {
625
    /* The leading "v" of IPvFuture is case-insensitive. */
626
1.74k
    case _UT('v'):
627
2.62k
    case _UT('V'): {
628
2.62k
        const URI_CHAR * const afterIpFuture =
629
2.62k
            URI_FUNC(ParseIpFuture)(state, first, afterLast, memory);
630
2.62k
        if (afterIpFuture == NULL) {
631
536
            return NULL;
632
536
        }
633
2.09k
        if (afterIpFuture >= afterLast) {
634
1.79k
            URI_FUNC(StopSyntax)(state, afterLast, memory);
635
1.79k
            return NULL;
636
1.79k
        }
637
294
        if (*afterIpFuture != _UT(']')) {
638
120
            URI_FUNC(StopSyntax)(state, afterIpFuture, memory);
639
120
            return NULL;
640
120
        }
641
174
        return afterIpFuture + 1;
642
294
    }
643
644
1.09k
    case _UT(':'):
645
1.09k
    case _UT(']'):
646
31.0k
    case URI_SET_HEXDIG:
647
31.0k
        state->uri->hostData.ip6 = memory->malloc(
648
31.0k
            memory, 1 * sizeof(UriIp6)); /* Freed when stopping on parse error */
649
31.0k
        if (state->uri->hostData.ip6 == NULL) {
650
0
            URI_FUNC(StopMalloc)(state, memory);
651
0
            return NULL;
652
0
        }
653
1.70k
        return URI_FUNC(ParseIPv6address2)(state, first, afterLast, memory);
654
655
3
    default:
656
3
        URI_FUNC(StopSyntax)(state, first, memory);
657
        return NULL;
658
4.33k
    }
659
4.33k
}
660
661
/*
662
 * [IPv6address2]->..<]>
663
 */
664
static const URI_CHAR * URI_FUNC(ParseIPv6address2)(URI_TYPE(ParserState) * state,
665
                                                    const URI_CHAR * first,
666
                                                    const URI_CHAR * afterLast,
667
3.09k
                                                    UriMemoryManager * memory) {
668
3.09k
    int zipperEver = 0;
669
3.09k
    int quadsDone = 0;
670
3.09k
    int digitCount = 0;
671
3.09k
    unsigned char digitHistory[4];
672
3.09k
    int ip4OctetsDone = 0;
673
674
3.09k
    unsigned char quadsAfterZipper[14];
675
3.09k
    int quadsAfterZipperCount = 0;
676
677
3.61k
    for (;;) {
678
3.61k
        if (first >= afterLast) {
679
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
680
0
            return NULL;
681
0
        }
682
683
        /* Inside IPv4 part? */
684
3.61k
        if (ip4OctetsDone > 0) {
685
            /* Eat rest of IPv4 address */
686
2.75k
            for (;;) {
687
2.75k
                switch (*first) {
688
11.9k
                case URI_SET_DIGIT:
689
11.9k
                    if (digitCount == 4) {
690
29
                        URI_FUNC(StopSyntax)(state, first, memory);
691
29
                        return NULL;
692
29
                    }
693
1.98k
                    digitHistory[digitCount++] = (unsigned char)(9 + *first - _UT('9'));
694
1.98k
                    break;
695
696
601
                case _UT('.'):
697
601
                    if ((ip4OctetsDone == 4) /* NOTE! */
698
594
                        || (digitCount == 0) || (digitCount == 4)) {
699
                        /* Invalid digit or octet count */
700
18
                        URI_FUNC(StopSyntax)(state, first, memory);
701
18
                        return NULL;
702
583
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
703
                        /* Leading zero */
704
4
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
705
4
                        return NULL;
706
579
                    } else if ((digitCount == 3)
707
167
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
708
167
                                       + digitHistory[2]
709
167
                                   > 255)) {
710
                        /* Octet value too large */
711
43
                        if (digitHistory[0] > 2) {
712
26
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
713
26
                        } else if (digitHistory[1] > 5) {
714
13
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
715
13
                        } else {
716
4
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
717
4
                        }
718
43
                        return NULL;
719
43
                    }
720
721
                    /* Copy IPv4 octet */
722
536
                    state->uri->hostData.ip6->data[16 - 4 + ip4OctetsDone] =
723
536
                        uriGetOctetValue(digitHistory, digitCount);
724
536
                    digitCount = 0;
725
536
                    ip4OctetsDone++;
726
536
                    break;
727
728
123
                case _UT(']'):
729
123
                    if ((ip4OctetsDone != 3) /* NOTE! */
730
112
                        || (digitCount == 0) || (digitCount == 4)) {
731
                        /* Invalid digit or octet count */
732
19
                        URI_FUNC(StopSyntax)(state, first, memory);
733
19
                        return NULL;
734
104
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
735
                        /* Leading zero */
736
4
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
737
4
                        return NULL;
738
100
                    } else if ((digitCount == 3)
739
66
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
740
66
                                       + digitHistory[2]
741
66
                                   > 255)) {
742
                        /* Octet value too large */
743
31
                        if (digitHistory[0] > 2) {
744
13
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
745
18
                        } else if (digitHistory[1] > 5) {
746
10
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
747
10
                        } else {
748
8
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
749
8
                        }
750
31
                        return NULL;
751
31
                    }
752
753
69
                    state->uri->hostText.afterLast = first; /* HOST END */
754
755
                    /* Copy missing quads right before IPv4 */
756
69
                    memcpy(state->uri->hostData.ip6->data + 16 - 4
757
69
                               - 2 * quadsAfterZipperCount,
758
69
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
759
760
                    /* Copy last IPv4 octet */
761
69
                    state->uri->hostData.ip6->data[16 - 4 + 3] =
762
69
                        uriGetOctetValue(digitHistory, digitCount);
763
764
69
                    return first + 1;
765
766
17
                default:
767
17
                    URI_FUNC(StopSyntax)(state, first, memory);
768
17
                    return NULL;
769
2.75k
                }
770
2.52k
                first++;
771
772
2.52k
                if (first >= afterLast) {
773
284
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
774
284
                    return NULL;
775
284
                }
776
2.52k
            }
777
3.09k
        } else {
778
            /* Eat while no dot in sight */
779
3.09k
            int letterAmong = 0;
780
3.09k
            int walking = 1;
781
15.7k
            do {
782
15.7k
                switch (*first) {
783
6.38k
                case URI_SET_HEX_LETTER_LOWER:
784
6.38k
                    letterAmong = 1;
785
6.38k
                    if (digitCount == 4) {
786
31
                        URI_FUNC(StopSyntax)(state, first, memory);
787
31
                        return NULL;
788
31
                    }
789
2.00k
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('f'));
790
2.00k
                    digitCount++;
791
2.00k
                    break;
792
793
7.01k
                case URI_SET_HEX_LETTER_UPPER:
794
7.01k
                    letterAmong = 1;
795
7.01k
                    if (digitCount == 4) {
796
29
                        URI_FUNC(StopSyntax)(state, first, memory);
797
29
                        return NULL;
798
29
                    }
799
2.09k
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('F'));
800
2.09k
                    digitCount++;
801
2.09k
                    break;
802
803
29.7k
                case URI_SET_DIGIT:
804
29.7k
                    if (digitCount == 4) {
805
56
                        URI_FUNC(StopSyntax)(state, first, memory);
806
56
                        return NULL;
807
56
                    }
808
5.03k
                    digitHistory[digitCount] = (unsigned char)(9 + *first - _UT('9'));
809
5.03k
                    digitCount++;
810
5.03k
                    break;
811
812
4.28k
                case _UT(':'): {
813
4.28k
                    int setZipper = 0;
814
815
4.28k
                    if (digitCount > 0) {
816
2.37k
                        if (zipperEver) {
817
306
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
818
306
                                                     quadsAfterZipper
819
306
                                                         + 2 * quadsAfterZipperCount);
820
306
                            quadsAfterZipperCount++;
821
2.07k
                        } else {
822
2.07k
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
823
2.07k
                                                     state->uri->hostData.ip6->data
824
2.07k
                                                         + 2 * quadsDone);
825
2.07k
                        }
826
2.37k
                        quadsDone++;
827
2.37k
                        digitCount = 0;
828
2.37k
                    }
829
4.28k
                    letterAmong = 0;
830
831
                    /* Too many quads? */
832
4.28k
                    if (quadsDone >= 8 - zipperEver) {
833
22
                        URI_FUNC(StopSyntax)(state, first, memory);
834
22
                        return NULL;
835
22
                    }
836
837
                    /* "::"? */
838
4.25k
                    if (afterLast - first < 2) {
839
93
                        URI_FUNC(StopSyntax)(state, afterLast, memory);
840
93
                        return NULL;
841
93
                    }
842
4.16k
                    if (first[1] == _UT(':')) {
843
2.05k
                        const int resetOffset = 2 * (quadsDone + (digitCount > 0));
844
845
2.05k
                        first++;
846
2.05k
                        if (zipperEver) {
847
4
                            URI_FUNC(StopSyntax)(state, first, memory);
848
4
                            return NULL; /* "::.+::" */
849
4
                        }
850
851
                        /* Zero everything after zipper */
852
2.04k
                        memset(state->uri->hostData.ip6->data + resetOffset, 0,
853
2.04k
                               16 - resetOffset);
854
2.04k
                        setZipper = 1;
855
856
                        /* ":::+"? */
857
2.04k
                        if (afterLast - first < 2) {
858
4
                            URI_FUNC(StopSyntax)(state, afterLast, memory);
859
4
                            return NULL; /* No ']' yet */
860
4
                        }
861
2.04k
                        if (first[1] == _UT(':')) {
862
4
                            URI_FUNC(StopSyntax)(state, first + 1, memory);
863
4
                            return NULL; /* ":::+ "*/
864
4
                        }
865
2.11k
                    } else if (quadsDone == 0 || first[1] == _UT(']')) {
866
                        /* Single leading or trailing ":" */
867
122
                        URI_FUNC(StopSyntax)(state, first, memory);
868
122
                        return NULL;
869
122
                    }
870
871
4.03k
                    if (setZipper) {
872
2.03k
                        zipperEver = 1;
873
2.03k
                    }
874
4.03k
                } break;
875
876
666
                case _UT('.'):
877
666
                    if ((quadsDone + zipperEver > 6) /* NOTE */
878
661
                        || (!zipperEver && (quadsDone < 6)) || letterAmong
879
639
                        || (digitCount == 0) || (digitCount == 4)) {
880
                        /* Invalid octet before */
881
53
                        URI_FUNC(StopSyntax)(state, first, memory);
882
53
                        return NULL;
883
613
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
884
                        /* Leading zero */
885
4
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
886
4
                        return NULL;
887
609
                    } else if ((digitCount == 3)
888
92
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
889
92
                                       + digitHistory[2]
890
92
                                   > 255)) {
891
                        /* Octet value too large */
892
36
                        if (digitHistory[0] > 2) {
893
17
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
894
19
                        } else if (digitHistory[1] > 5) {
895
14
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
896
14
                        } else {
897
5
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
898
5
                        }
899
36
                        return NULL;
900
36
                    }
901
902
                    /* Copy first IPv4 octet */
903
573
                    state->uri->hostData.ip6->data[16 - 4] =
904
573
                        uriGetOctetValue(digitHistory, digitCount);
905
573
                    digitCount = 0;
906
907
                    /* Switch over to IPv4 loop */
908
573
                    ip4OctetsDone = 1;
909
573
                    walking = 0;
910
573
                    break;
911
912
1.27k
                case _UT(']'):
913
                    /* Too little quads? */
914
1.27k
                    if (!zipperEver && !((quadsDone == 7) && (digitCount > 0))) {
915
15
                        URI_FUNC(StopSyntax)(state, first, memory);
916
15
                        return NULL;
917
15
                    }
918
919
1.26k
                    if (digitCount > 0) {
920
270
                        if (zipperEver) {
921
                            /* Too many quads? */
922
250
                            if (quadsDone >= 7) {
923
4
                                URI_FUNC(StopSyntax)(state, first, memory);
924
4
                                return NULL;
925
4
                            }
926
246
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
927
246
                                                     quadsAfterZipper
928
246
                                                         + 2 * quadsAfterZipperCount);
929
246
                            quadsAfterZipperCount++;
930
246
                        } else {
931
20
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
932
20
                                                     state->uri->hostData.ip6->data
933
20
                                                         + 2 * quadsDone);
934
20
                        }
935
                        /*
936
                        quadsDone++;
937
                        digitCount = 0;
938
                        */
939
270
                    }
940
941
                    /* Copy missing quads to the end */
942
1.25k
                    memcpy(state->uri->hostData.ip6->data + 16
943
1.25k
                               - 2 * quadsAfterZipperCount,
944
1.25k
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
945
946
1.25k
                    state->uri->hostText.afterLast = first; /* HOST END */
947
1.25k
                    return first + 1; /* Fine */
948
949
225
                default:
950
225
                    URI_FUNC(StopSyntax)(state, first, memory);
951
225
                    return NULL;
952
15.7k
                }
953
13.7k
                first++;
954
955
13.7k
                if (first >= afterLast) {
956
619
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
957
619
                    return NULL; /* No ']' yet */
958
619
                }
959
13.7k
            } while (walking);
960
3.09k
        }
961
3.61k
    }
962
3.09k
}
UriParse.c:uriParseIPv6address2A
Line
Count
Source
667
1.39k
                                                    UriMemoryManager * memory) {
668
1.39k
    int zipperEver = 0;
669
1.39k
    int quadsDone = 0;
670
1.39k
    int digitCount = 0;
671
1.39k
    unsigned char digitHistory[4];
672
1.39k
    int ip4OctetsDone = 0;
673
674
1.39k
    unsigned char quadsAfterZipper[14];
675
1.39k
    int quadsAfterZipperCount = 0;
676
677
1.66k
    for (;;) {
678
1.66k
        if (first >= afterLast) {
679
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
680
0
            return NULL;
681
0
        }
682
683
        /* Inside IPv4 part? */
684
1.66k
        if (ip4OctetsDone > 0) {
685
            /* Eat rest of IPv4 address */
686
1.46k
            for (;;) {
687
1.46k
                switch (*first) {
688
6.59k
                case URI_SET_DIGIT:
689
6.59k
                    if (digitCount == 4) {
690
17
                        URI_FUNC(StopSyntax)(state, first, memory);
691
17
                        return NULL;
692
17
                    }
693
1.05k
                    digitHistory[digitCount++] = (unsigned char)(9 + *first - _UT('9'));
694
1.05k
                    break;
695
696
317
                case _UT('.'):
697
317
                    if ((ip4OctetsDone == 4) /* NOTE! */
698
314
                        || (digitCount == 0) || (digitCount == 4)) {
699
                        /* Invalid digit or octet count */
700
8
                        URI_FUNC(StopSyntax)(state, first, memory);
701
8
                        return NULL;
702
309
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
703
                        /* Leading zero */
704
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
705
2
                        return NULL;
706
307
                    } else if ((digitCount == 3)
707
93
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
708
93
                                       + digitHistory[2]
709
93
                                   > 255)) {
710
                        /* Octet value too large */
711
24
                        if (digitHistory[0] > 2) {
712
16
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
713
16
                        } else if (digitHistory[1] > 5) {
714
6
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
715
6
                        } else {
716
2
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
717
2
                        }
718
24
                        return NULL;
719
24
                    }
720
721
                    /* Copy IPv4 octet */
722
283
                    state->uri->hostData.ip6->data[16 - 4 + ip4OctetsDone] =
723
283
                        uriGetOctetValue(digitHistory, digitCount);
724
283
                    digitCount = 0;
725
283
                    ip4OctetsDone++;
726
283
                    break;
727
728
68
                case _UT(']'):
729
68
                    if ((ip4OctetsDone != 3) /* NOTE! */
730
61
                        || (digitCount == 0) || (digitCount == 4)) {
731
                        /* Invalid digit or octet count */
732
11
                        URI_FUNC(StopSyntax)(state, first, memory);
733
11
                        return NULL;
734
57
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
735
                        /* Leading zero */
736
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
737
2
                        return NULL;
738
55
                    } else if ((digitCount == 3)
739
35
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
740
35
                                       + digitHistory[2]
741
35
                                   > 255)) {
742
                        /* Octet value too large */
743
16
                        if (digitHistory[0] > 2) {
744
6
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
745
10
                        } else if (digitHistory[1] > 5) {
746
4
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
747
6
                        } else {
748
6
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
749
6
                        }
750
16
                        return NULL;
751
16
                    }
752
753
39
                    state->uri->hostText.afterLast = first; /* HOST END */
754
755
                    /* Copy missing quads right before IPv4 */
756
39
                    memcpy(state->uri->hostData.ip6->data + 16 - 4
757
39
                               - 2 * quadsAfterZipperCount,
758
39
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
759
760
                    /* Copy last IPv4 octet */
761
39
                    state->uri->hostData.ip6->data[16 - 4 + 3] =
762
39
                        uriGetOctetValue(digitHistory, digitCount);
763
764
39
                    return first + 1;
765
766
9
                default:
767
9
                    URI_FUNC(StopSyntax)(state, first, memory);
768
9
                    return NULL;
769
1.46k
                }
770
1.33k
                first++;
771
772
1.33k
                if (first >= afterLast) {
773
142
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
774
142
                    return NULL;
775
142
                }
776
1.33k
            }
777
1.39k
        } else {
778
            /* Eat while no dot in sight */
779
1.39k
            int letterAmong = 0;
780
1.39k
            int walking = 1;
781
7.97k
            do {
782
7.97k
                switch (*first) {
783
3.41k
                case URI_SET_HEX_LETTER_LOWER:
784
3.41k
                    letterAmong = 1;
785
3.41k
                    if (digitCount == 4) {
786
19
                        URI_FUNC(StopSyntax)(state, first, memory);
787
19
                        return NULL;
788
19
                    }
789
1.06k
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('f'));
790
1.06k
                    digitCount++;
791
1.06k
                    break;
792
793
4.02k
                case URI_SET_HEX_LETTER_UPPER:
794
4.02k
                    letterAmong = 1;
795
4.02k
                    if (digitCount == 4) {
796
19
                        URI_FUNC(StopSyntax)(state, first, memory);
797
19
                        return NULL;
798
19
                    }
799
1.21k
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('F'));
800
1.21k
                    digitCount++;
801
1.21k
                    break;
802
803
15.4k
                case URI_SET_DIGIT:
804
15.4k
                    if (digitCount == 4) {
805
36
                        URI_FUNC(StopSyntax)(state, first, memory);
806
36
                        return NULL;
807
36
                    }
808
2.62k
                    digitHistory[digitCount] = (unsigned char)(9 + *first - _UT('9'));
809
2.62k
                    digitCount++;
810
2.62k
                    break;
811
812
2.05k
                case _UT(':'): {
813
2.05k
                    int setZipper = 0;
814
815
2.05k
                    if (digitCount > 0) {
816
1.24k
                        if (zipperEver) {
817
167
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
818
167
                                                     quadsAfterZipper
819
167
                                                         + 2 * quadsAfterZipperCount);
820
167
                            quadsAfterZipperCount++;
821
1.07k
                        } else {
822
1.07k
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
823
1.07k
                                                     state->uri->hostData.ip6->data
824
1.07k
                                                         + 2 * quadsDone);
825
1.07k
                        }
826
1.24k
                        quadsDone++;
827
1.24k
                        digitCount = 0;
828
1.24k
                    }
829
2.05k
                    letterAmong = 0;
830
831
                    /* Too many quads? */
832
2.05k
                    if (quadsDone >= 8 - zipperEver) {
833
11
                        URI_FUNC(StopSyntax)(state, first, memory);
834
11
                        return NULL;
835
11
                    }
836
837
                    /* "::"? */
838
2.04k
                    if (afterLast - first < 2) {
839
47
                        URI_FUNC(StopSyntax)(state, afterLast, memory);
840
47
                        return NULL;
841
47
                    }
842
1.99k
                    if (first[1] == _UT(':')) {
843
928
                        const int resetOffset = 2 * (quadsDone + (digitCount > 0));
844
845
928
                        first++;
846
928
                        if (zipperEver) {
847
2
                            URI_FUNC(StopSyntax)(state, first, memory);
848
2
                            return NULL; /* "::.+::" */
849
2
                        }
850
851
                        /* Zero everything after zipper */
852
926
                        memset(state->uri->hostData.ip6->data + resetOffset, 0,
853
926
                               16 - resetOffset);
854
926
                        setZipper = 1;
855
856
                        /* ":::+"? */
857
926
                        if (afterLast - first < 2) {
858
2
                            URI_FUNC(StopSyntax)(state, afterLast, memory);
859
2
                            return NULL; /* No ']' yet */
860
2
                        }
861
924
                        if (first[1] == _UT(':')) {
862
2
                            URI_FUNC(StopSyntax)(state, first + 1, memory);
863
2
                            return NULL; /* ":::+ "*/
864
2
                        }
865
1.06k
                    } else if (quadsDone == 0 || first[1] == _UT(']')) {
866
                        /* Single leading or trailing ":" */
867
27
                        URI_FUNC(StopSyntax)(state, first, memory);
868
27
                        return NULL;
869
27
                    }
870
871
1.96k
                    if (setZipper) {
872
922
                        zipperEver = 1;
873
922
                    }
874
1.96k
                } break;
875
876
347
                case _UT('.'):
877
347
                    if ((quadsDone + zipperEver > 6) /* NOTE */
878
345
                        || (!zipperEver && (quadsDone < 6)) || letterAmong
879
332
                        || (digitCount == 0) || (digitCount == 4)) {
880
                        /* Invalid octet before */
881
29
                        URI_FUNC(StopSyntax)(state, first, memory);
882
29
                        return NULL;
883
318
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
884
                        /* Leading zero */
885
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
886
2
                        return NULL;
887
316
                    } else if ((digitCount == 3)
888
48
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
889
48
                                       + digitHistory[2]
890
48
                                   > 255)) {
891
                        /* Octet value too large */
892
19
                        if (digitHistory[0] > 2) {
893
9
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
894
10
                        } else if (digitHistory[1] > 5) {
895
7
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
896
7
                        } else {
897
3
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
898
3
                        }
899
19
                        return NULL;
900
19
                    }
901
902
                    /* Copy first IPv4 octet */
903
297
                    state->uri->hostData.ip6->data[16 - 4] =
904
297
                        uriGetOctetValue(digitHistory, digitCount);
905
297
                    digitCount = 0;
906
907
                    /* Switch over to IPv4 loop */
908
297
                    ip4OctetsDone = 1;
909
297
                    walking = 0;
910
297
                    break;
911
912
567
                case _UT(']'):
913
                    /* Too little quads? */
914
567
                    if (!zipperEver && !((quadsDone == 7) && (digitCount > 0))) {
915
6
                        URI_FUNC(StopSyntax)(state, first, memory);
916
6
                        return NULL;
917
6
                    }
918
919
561
                    if (digitCount > 0) {
920
163
                        if (zipperEver) {
921
                            /* Too many quads? */
922
151
                            if (quadsDone >= 7) {
923
2
                                URI_FUNC(StopSyntax)(state, first, memory);
924
2
                                return NULL;
925
2
                            }
926
149
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
927
149
                                                     quadsAfterZipper
928
149
                                                         + 2 * quadsAfterZipperCount);
929
149
                            quadsAfterZipperCount++;
930
149
                        } else {
931
12
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
932
12
                                                     state->uri->hostData.ip6->data
933
12
                                                         + 2 * quadsDone);
934
12
                        }
935
                        /*
936
                        quadsDone++;
937
                        digitCount = 0;
938
                        */
939
163
                    }
940
941
                    /* Copy missing quads to the end */
942
559
                    memcpy(state->uri->hostData.ip6->data + 16
943
559
                               - 2 * quadsAfterZipperCount,
944
559
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
945
946
559
                    state->uri->hostText.afterLast = first; /* HOST END */
947
559
                    return first + 1; /* Fine */
948
949
43
                default:
950
43
                    URI_FUNC(StopSyntax)(state, first, memory);
951
43
                    return NULL;
952
7.97k
                }
953
7.15k
                first++;
954
955
7.15k
                if (first >= afterLast) {
956
300
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
957
300
                    return NULL; /* No ']' yet */
958
300
                }
959
7.15k
            } while (walking);
960
1.39k
        }
961
1.66k
    }
962
1.39k
}
UriParse.c:uriParseIPv6address2W
Line
Count
Source
667
1.70k
                                                    UriMemoryManager * memory) {
668
1.70k
    int zipperEver = 0;
669
1.70k
    int quadsDone = 0;
670
1.70k
    int digitCount = 0;
671
1.70k
    unsigned char digitHistory[4];
672
1.70k
    int ip4OctetsDone = 0;
673
674
1.70k
    unsigned char quadsAfterZipper[14];
675
1.70k
    int quadsAfterZipperCount = 0;
676
677
1.95k
    for (;;) {
678
1.95k
        if (first >= afterLast) {
679
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
680
0
            return NULL;
681
0
        }
682
683
        /* Inside IPv4 part? */
684
1.95k
        if (ip4OctetsDone > 0) {
685
            /* Eat rest of IPv4 address */
686
1.29k
            for (;;) {
687
1.29k
                switch (*first) {
688
5.38k
                case URI_SET_DIGIT:
689
5.38k
                    if (digitCount == 4) {
690
12
                        URI_FUNC(StopSyntax)(state, first, memory);
691
12
                        return NULL;
692
12
                    }
693
937
                    digitHistory[digitCount++] = (unsigned char)(9 + *first - _UT('9'));
694
937
                    break;
695
696
284
                case _UT('.'):
697
284
                    if ((ip4OctetsDone == 4) /* NOTE! */
698
280
                        || (digitCount == 0) || (digitCount == 4)) {
699
                        /* Invalid digit or octet count */
700
10
                        URI_FUNC(StopSyntax)(state, first, memory);
701
10
                        return NULL;
702
274
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
703
                        /* Leading zero */
704
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
705
2
                        return NULL;
706
272
                    } else if ((digitCount == 3)
707
74
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
708
74
                                       + digitHistory[2]
709
74
                                   > 255)) {
710
                        /* Octet value too large */
711
19
                        if (digitHistory[0] > 2) {
712
10
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
713
10
                        } else if (digitHistory[1] > 5) {
714
7
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
715
7
                        } else {
716
2
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
717
2
                        }
718
19
                        return NULL;
719
19
                    }
720
721
                    /* Copy IPv4 octet */
722
253
                    state->uri->hostData.ip6->data[16 - 4 + ip4OctetsDone] =
723
253
                        uriGetOctetValue(digitHistory, digitCount);
724
253
                    digitCount = 0;
725
253
                    ip4OctetsDone++;
726
253
                    break;
727
728
55
                case _UT(']'):
729
55
                    if ((ip4OctetsDone != 3) /* NOTE! */
730
51
                        || (digitCount == 0) || (digitCount == 4)) {
731
                        /* Invalid digit or octet count */
732
8
                        URI_FUNC(StopSyntax)(state, first, memory);
733
8
                        return NULL;
734
47
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
735
                        /* Leading zero */
736
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
737
2
                        return NULL;
738
45
                    } else if ((digitCount == 3)
739
31
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
740
31
                                       + digitHistory[2]
741
31
                                   > 255)) {
742
                        /* Octet value too large */
743
15
                        if (digitHistory[0] > 2) {
744
7
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
745
8
                        } else if (digitHistory[1] > 5) {
746
6
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
747
6
                        } else {
748
2
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
749
2
                        }
750
15
                        return NULL;
751
15
                    }
752
753
30
                    state->uri->hostText.afterLast = first; /* HOST END */
754
755
                    /* Copy missing quads right before IPv4 */
756
30
                    memcpy(state->uri->hostData.ip6->data + 16 - 4
757
30
                               - 2 * quadsAfterZipperCount,
758
30
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
759
760
                    /* Copy last IPv4 octet */
761
30
                    state->uri->hostData.ip6->data[16 - 4 + 3] =
762
30
                        uriGetOctetValue(digitHistory, digitCount);
763
764
30
                    return first + 1;
765
766
8
                default:
767
8
                    URI_FUNC(StopSyntax)(state, first, memory);
768
8
                    return NULL;
769
1.29k
                }
770
1.19k
                first++;
771
772
1.19k
                if (first >= afterLast) {
773
142
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
774
142
                    return NULL;
775
142
                }
776
1.19k
            }
777
1.70k
        } else {
778
            /* Eat while no dot in sight */
779
1.70k
            int letterAmong = 0;
780
1.70k
            int walking = 1;
781
7.72k
            do {
782
7.72k
                switch (*first) {
783
2.97k
                case URI_SET_HEX_LETTER_LOWER:
784
2.97k
                    letterAmong = 1;
785
2.97k
                    if (digitCount == 4) {
786
12
                        URI_FUNC(StopSyntax)(state, first, memory);
787
12
                        return NULL;
788
12
                    }
789
943
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('f'));
790
943
                    digitCount++;
791
943
                    break;
792
793
2.98k
                case URI_SET_HEX_LETTER_UPPER:
794
2.98k
                    letterAmong = 1;
795
2.98k
                    if (digitCount == 4) {
796
10
                        URI_FUNC(StopSyntax)(state, first, memory);
797
10
                        return NULL;
798
10
                    }
799
883
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('F'));
800
883
                    digitCount++;
801
883
                    break;
802
803
14.2k
                case URI_SET_DIGIT:
804
14.2k
                    if (digitCount == 4) {
805
20
                        URI_FUNC(StopSyntax)(state, first, memory);
806
20
                        return NULL;
807
20
                    }
808
2.41k
                    digitHistory[digitCount] = (unsigned char)(9 + *first - _UT('9'));
809
2.41k
                    digitCount++;
810
2.41k
                    break;
811
812
2.23k
                case _UT(':'): {
813
2.23k
                    int setZipper = 0;
814
815
2.23k
                    if (digitCount > 0) {
816
1.13k
                        if (zipperEver) {
817
139
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
818
139
                                                     quadsAfterZipper
819
139
                                                         + 2 * quadsAfterZipperCount);
820
139
                            quadsAfterZipperCount++;
821
994
                        } else {
822
994
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
823
994
                                                     state->uri->hostData.ip6->data
824
994
                                                         + 2 * quadsDone);
825
994
                        }
826
1.13k
                        quadsDone++;
827
1.13k
                        digitCount = 0;
828
1.13k
                    }
829
2.23k
                    letterAmong = 0;
830
831
                    /* Too many quads? */
832
2.23k
                    if (quadsDone >= 8 - zipperEver) {
833
11
                        URI_FUNC(StopSyntax)(state, first, memory);
834
11
                        return NULL;
835
11
                    }
836
837
                    /* "::"? */
838
2.21k
                    if (afterLast - first < 2) {
839
46
                        URI_FUNC(StopSyntax)(state, afterLast, memory);
840
46
                        return NULL;
841
46
                    }
842
2.17k
                    if (first[1] == _UT(':')) {
843
1.12k
                        const int resetOffset = 2 * (quadsDone + (digitCount > 0));
844
845
1.12k
                        first++;
846
1.12k
                        if (zipperEver) {
847
2
                            URI_FUNC(StopSyntax)(state, first, memory);
848
2
                            return NULL; /* "::.+::" */
849
2
                        }
850
851
                        /* Zero everything after zipper */
852
1.12k
                        memset(state->uri->hostData.ip6->data + resetOffset, 0,
853
1.12k
                               16 - resetOffset);
854
1.12k
                        setZipper = 1;
855
856
                        /* ":::+"? */
857
1.12k
                        if (afterLast - first < 2) {
858
2
                            URI_FUNC(StopSyntax)(state, afterLast, memory);
859
2
                            return NULL; /* No ']' yet */
860
2
                        }
861
1.11k
                        if (first[1] == _UT(':')) {
862
2
                            URI_FUNC(StopSyntax)(state, first + 1, memory);
863
2
                            return NULL; /* ":::+ "*/
864
2
                        }
865
1.11k
                    } else if (quadsDone == 0 || first[1] == _UT(']')) {
866
                        /* Single leading or trailing ":" */
867
95
                        URI_FUNC(StopSyntax)(state, first, memory);
868
95
                        return NULL;
869
95
                    }
870
871
2.07k
                    if (setZipper) {
872
1.11k
                        zipperEver = 1;
873
1.11k
                    }
874
2.07k
                } break;
875
876
319
                case _UT('.'):
877
319
                    if ((quadsDone + zipperEver > 6) /* NOTE */
878
316
                        || (!zipperEver && (quadsDone < 6)) || letterAmong
879
307
                        || (digitCount == 0) || (digitCount == 4)) {
880
                        /* Invalid octet before */
881
24
                        URI_FUNC(StopSyntax)(state, first, memory);
882
24
                        return NULL;
883
295
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
884
                        /* Leading zero */
885
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
886
2
                        return NULL;
887
293
                    } else if ((digitCount == 3)
888
44
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
889
44
                                       + digitHistory[2]
890
44
                                   > 255)) {
891
                        /* Octet value too large */
892
17
                        if (digitHistory[0] > 2) {
893
8
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
894
9
                        } else if (digitHistory[1] > 5) {
895
7
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
896
7
                        } else {
897
2
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
898
2
                        }
899
17
                        return NULL;
900
17
                    }
901
902
                    /* Copy first IPv4 octet */
903
276
                    state->uri->hostData.ip6->data[16 - 4] =
904
276
                        uriGetOctetValue(digitHistory, digitCount);
905
276
                    digitCount = 0;
906
907
                    /* Switch over to IPv4 loop */
908
276
                    ip4OctetsDone = 1;
909
276
                    walking = 0;
910
276
                    break;
911
912
710
                case _UT(']'):
913
                    /* Too little quads? */
914
710
                    if (!zipperEver && !((quadsDone == 7) && (digitCount > 0))) {
915
9
                        URI_FUNC(StopSyntax)(state, first, memory);
916
9
                        return NULL;
917
9
                    }
918
919
701
                    if (digitCount > 0) {
920
107
                        if (zipperEver) {
921
                            /* Too many quads? */
922
99
                            if (quadsDone >= 7) {
923
2
                                URI_FUNC(StopSyntax)(state, first, memory);
924
2
                                return NULL;
925
2
                            }
926
97
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
927
97
                                                     quadsAfterZipper
928
97
                                                         + 2 * quadsAfterZipperCount);
929
97
                            quadsAfterZipperCount++;
930
97
                        } else {
931
8
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
932
8
                                                     state->uri->hostData.ip6->data
933
8
                                                         + 2 * quadsDone);
934
8
                        }
935
                        /*
936
                        quadsDone++;
937
                        digitCount = 0;
938
                        */
939
107
                    }
940
941
                    /* Copy missing quads to the end */
942
699
                    memcpy(state->uri->hostData.ip6->data + 16
943
699
                               - 2 * quadsAfterZipperCount,
944
699
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
945
946
699
                    state->uri->hostText.afterLast = first; /* HOST END */
947
699
                    return first + 1; /* Fine */
948
949
182
                default:
950
182
                    URI_FUNC(StopSyntax)(state, first, memory);
951
182
                    return NULL;
952
7.72k
                }
953
6.59k
                first++;
954
955
6.59k
                if (first >= afterLast) {
956
319
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
957
319
                    return NULL; /* No ']' yet */
958
319
                }
959
6.59k
            } while (walking);
960
1.70k
        }
961
1.95k
    }
962
1.70k
}
963
964
/*
965
 * [mustBeSegmentNzNc]->[pctEncoded][mustBeSegmentNzNc]
966
 * [mustBeSegmentNzNc]->[subDelims][mustBeSegmentNzNc]
967
 * [mustBeSegmentNzNc]->[unreserved][mustBeSegmentNzNc]
968
 * [mustBeSegmentNzNc]->[uriTail] // can take <NULL>
969
 * [mustBeSegmentNzNc]-></>[segment][zeroMoreSlashSegs][uriTail]
970
 * [mustBeSegmentNzNc]-><@>[mustBeSegmentNzNc]
971
 */
972
static const URI_CHAR * URI_FUNC(ParseMustBeSegmentNzNc)(URI_TYPE(ParserState) * state,
973
                                                         const URI_CHAR * first,
974
                                                         const URI_CHAR * afterLast,
975
10.7M
                                                         UriMemoryManager * memory) {
976
10.7M
    if (first >= afterLast) {
977
4.85k
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
978
4.85k
                                       memory)) { /* SEGMENT BOTH */
979
0
            URI_FUNC(StopMalloc)(state, memory);
980
0
            return NULL;
981
0
        }
982
4.85k
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
983
4.85k
        return afterLast;
984
4.85k
    }
985
986
10.7M
    switch (*first) {
987
32.5k
    case _UT('%'): {
988
32.5k
        const URI_CHAR * const afterPctEncoded =
989
32.5k
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
990
32.5k
        if (afterPctEncoded == NULL) {
991
631
            return NULL;
992
631
        }
993
31.9k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
994
31.9k
                                                memory);
995
32.5k
    }
996
997
1.00k
    case _UT('@'):
998
2.20k
    case _UT('!'):
999
3.34k
    case _UT('$'):
1000
4.72k
    case _UT('&'):
1001
5.97k
    case _UT('('):
1002
9.29k
    case _UT(')'):
1003
10.7k
    case _UT('*'):
1004
11.9k
    case _UT(','):
1005
13.0k
    case _UT(';'):
1006
17.1k
    case _UT('\''):
1007
23.5k
    case _UT('+'):
1008
25.8k
    case _UT('='):
1009
41.3k
    case _UT('-'):
1010
105k
    case _UT('.'):
1011
107k
    case _UT('_'):
1012
108k
    case _UT('~'):
1013
27.0M
    case URI_SET_DIGIT:
1014
27.0M
    case URI_SET_ALPHA:
1015
10.7M
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1016
1017
807
    case _UT('/'): {
1018
807
        const URI_CHAR * afterZeroMoreSlashSegs;
1019
807
        const URI_CHAR * afterSegment;
1020
807
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1021
807
                                       memory)) { /* SEGMENT BOTH */
1022
0
            URI_FUNC(StopMalloc)(state, memory);
1023
0
            return NULL;
1024
0
        }
1025
807
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1026
807
        afterSegment = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1027
807
        if (afterSegment == NULL) {
1028
7
            return NULL;
1029
7
        }
1030
800
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1031
800
                                       memory)) { /* SEGMENT BOTH */
1032
0
            URI_FUNC(StopMalloc)(state, memory);
1033
0
            return NULL;
1034
0
        }
1035
800
        afterZeroMoreSlashSegs =
1036
800
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1037
800
        if (afterZeroMoreSlashSegs == NULL) {
1038
8
            return NULL;
1039
8
        }
1040
792
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1041
800
    }
1042
1043
456
    default:
1044
456
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1045
456
                                       memory)) { /* SEGMENT BOTH */
1046
0
            URI_FUNC(StopMalloc)(state, memory);
1047
0
            return NULL;
1048
0
        }
1049
456
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1050
456
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1051
10.7M
    }
1052
10.7M
}
UriParse.c:uriParseMustBeSegmentNzNcA
Line
Count
Source
975
10.3M
                                                         UriMemoryManager * memory) {
976
10.3M
    if (first >= afterLast) {
977
2.61k
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
978
2.61k
                                       memory)) { /* SEGMENT BOTH */
979
0
            URI_FUNC(StopMalloc)(state, memory);
980
0
            return NULL;
981
0
        }
982
2.61k
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
983
2.61k
        return afterLast;
984
2.61k
    }
985
986
10.3M
    switch (*first) {
987
17.3k
    case _UT('%'): {
988
17.3k
        const URI_CHAR * const afterPctEncoded =
989
17.3k
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
990
17.3k
        if (afterPctEncoded == NULL) {
991
311
            return NULL;
992
311
        }
993
17.0k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
994
17.0k
                                                memory);
995
17.3k
    }
996
997
612
    case _UT('@'):
998
1.35k
    case _UT('!'):
999
2.04k
    case _UT('$'):
1000
2.71k
    case _UT('&'):
1001
3.54k
    case _UT('('):
1002
4.17k
    case _UT(')'):
1003
4.66k
    case _UT('*'):
1004
5.23k
    case _UT(','):
1005
5.90k
    case _UT(';'):
1006
6.84k
    case _UT('\''):
1007
12.4k
    case _UT('+'):
1008
14.2k
    case _UT('='):
1009
29.3k
    case _UT('-'):
1010
92.2k
    case _UT('.'):
1011
93.0k
    case _UT('_'):
1012
93.7k
    case _UT('~'):
1013
26.4M
    case URI_SET_DIGIT:
1014
26.4M
    case URI_SET_ALPHA:
1015
10.3M
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1016
1017
429
    case _UT('/'): {
1018
429
        const URI_CHAR * afterZeroMoreSlashSegs;
1019
429
        const URI_CHAR * afterSegment;
1020
429
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1021
429
                                       memory)) { /* SEGMENT BOTH */
1022
0
            URI_FUNC(StopMalloc)(state, memory);
1023
0
            return NULL;
1024
0
        }
1025
429
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1026
429
        afterSegment = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1027
429
        if (afterSegment == NULL) {
1028
4
            return NULL;
1029
4
        }
1030
425
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1031
425
                                       memory)) { /* SEGMENT BOTH */
1032
0
            URI_FUNC(StopMalloc)(state, memory);
1033
0
            return NULL;
1034
0
        }
1035
425
        afterZeroMoreSlashSegs =
1036
425
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1037
425
        if (afterZeroMoreSlashSegs == NULL) {
1038
4
            return NULL;
1039
4
        }
1040
421
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1041
425
    }
1042
1043
93
    default:
1044
93
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1045
93
                                       memory)) { /* SEGMENT BOTH */
1046
0
            URI_FUNC(StopMalloc)(state, memory);
1047
0
            return NULL;
1048
0
        }
1049
93
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1050
93
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1051
10.3M
    }
1052
10.3M
}
UriParse.c:uriParseMustBeSegmentNzNcW
Line
Count
Source
975
364k
                                                         UriMemoryManager * memory) {
976
364k
    if (first >= afterLast) {
977
2.24k
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
978
2.24k
                                       memory)) { /* SEGMENT BOTH */
979
0
            URI_FUNC(StopMalloc)(state, memory);
980
0
            return NULL;
981
0
        }
982
2.24k
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
983
2.24k
        return afterLast;
984
2.24k
    }
985
986
362k
    switch (*first) {
987
15.2k
    case _UT('%'): {
988
15.2k
        const URI_CHAR * const afterPctEncoded =
989
15.2k
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
990
15.2k
        if (afterPctEncoded == NULL) {
991
320
            return NULL;
992
320
        }
993
14.9k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
994
14.9k
                                                memory);
995
15.2k
    }
996
997
397
    case _UT('@'):
998
856
    case _UT('!'):
999
1.30k
    case _UT('$'):
1000
2.01k
    case _UT('&'):
1001
2.42k
    case _UT('('):
1002
5.11k
    case _UT(')'):
1003
6.12k
    case _UT('*'):
1004
6.69k
    case _UT(','):
1005
7.09k
    case _UT(';'):
1006
10.2k
    case _UT('\''):
1007
11.0k
    case _UT('+'):
1008
11.5k
    case _UT('='):
1009
12.0k
    case _UT('-'):
1010
13.4k
    case _UT('.'):
1011
14.2k
    case _UT('_'):
1012
15.1k
    case _UT('~'):
1013
591k
    case URI_SET_DIGIT:
1014
591k
    case URI_SET_ALPHA:
1015
346k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1016
1017
378
    case _UT('/'): {
1018
378
        const URI_CHAR * afterZeroMoreSlashSegs;
1019
378
        const URI_CHAR * afterSegment;
1020
378
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1021
378
                                       memory)) { /* SEGMENT BOTH */
1022
0
            URI_FUNC(StopMalloc)(state, memory);
1023
0
            return NULL;
1024
0
        }
1025
378
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1026
378
        afterSegment = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1027
378
        if (afterSegment == NULL) {
1028
3
            return NULL;
1029
3
        }
1030
375
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1031
375
                                       memory)) { /* SEGMENT BOTH */
1032
0
            URI_FUNC(StopMalloc)(state, memory);
1033
0
            return NULL;
1034
0
        }
1035
375
        afterZeroMoreSlashSegs =
1036
375
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1037
375
        if (afterZeroMoreSlashSegs == NULL) {
1038
4
            return NULL;
1039
4
        }
1040
371
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1041
375
    }
1042
1043
363
    default:
1044
363
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1045
363
                                       memory)) { /* SEGMENT BOTH */
1046
0
            URI_FUNC(StopMalloc)(state, memory);
1047
0
            return NULL;
1048
0
        }
1049
363
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1050
363
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1051
362k
    }
1052
362k
}
1053
1054
/*
1055
 * [ownHost]-><[>[ipLit2][authorityTwo]
1056
 * [ownHost]->[ownHost2] // can take <NULL>
1057
 */
1058
static URI_INLINE const URI_CHAR * URI_FUNC(ParseOwnHost)(URI_TYPE(ParserState) * state,
1059
                                                          const URI_CHAR * first,
1060
                                                          const URI_CHAR * afterLast,
1061
3.48k
                                                          UriMemoryManager * memory) {
1062
3.48k
    if (first >= afterLast) {
1063
250
        state->uri->hostText.afterLast = afterLast; /* HOST END */
1064
250
        return afterLast;
1065
250
    }
1066
1067
3.23k
    switch (*first) {
1068
346
    case _UT('['): {
1069
346
        const URI_CHAR * const afterIpLit2 =
1070
346
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
1071
346
        if (afterIpLit2 == NULL) {
1072
10
            return NULL;
1073
10
        }
1074
336
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1075
336
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
1076
346
    }
1077
1078
2.88k
    default:
1079
2.88k
        return URI_FUNC(ParseOwnHost2)(state, first, afterLast, memory);
1080
3.23k
    }
1081
3.23k
}
UriParse.c:uriParseOwnHostA
Line
Count
Source
1061
1.66k
                                                          UriMemoryManager * memory) {
1062
1.66k
    if (first >= afterLast) {
1063
125
        state->uri->hostText.afterLast = afterLast; /* HOST END */
1064
125
        return afterLast;
1065
125
    }
1066
1067
1.54k
    switch (*first) {
1068
134
    case _UT('['): {
1069
134
        const URI_CHAR * const afterIpLit2 =
1070
134
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
1071
134
        if (afterIpLit2 == NULL) {
1072
2
            return NULL;
1073
2
        }
1074
132
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1075
132
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
1076
134
    }
1077
1078
1.40k
    default:
1079
1.40k
        return URI_FUNC(ParseOwnHost2)(state, first, afterLast, memory);
1080
1.54k
    }
1081
1.54k
}
UriParse.c:uriParseOwnHostW
Line
Count
Source
1061
1.81k
                                                          UriMemoryManager * memory) {
1062
1.81k
    if (first >= afterLast) {
1063
125
        state->uri->hostText.afterLast = afterLast; /* HOST END */
1064
125
        return afterLast;
1065
125
    }
1066
1067
1.68k
    switch (*first) {
1068
212
    case _UT('['): {
1069
212
        const URI_CHAR * const afterIpLit2 =
1070
212
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
1071
212
        if (afterIpLit2 == NULL) {
1072
8
            return NULL;
1073
8
        }
1074
204
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1075
204
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
1076
212
    }
1077
1078
1.47k
    default:
1079
1.47k
        return URI_FUNC(ParseOwnHost2)(state, first, afterLast, memory);
1080
1.68k
    }
1081
1.68k
}
1082
1083
static URI_INLINE UriBool URI_FUNC(OnExitOwnHost2)(URI_TYPE(ParserState) * state,
1084
                                                   const URI_CHAR * first,
1085
2.85k
                                                   UriMemoryManager * memory) {
1086
2.85k
    state->uri->hostText.afterLast = first; /* HOST END */
1087
1088
    /* Valid IPv4 or just a regname? */
1089
2.85k
    state->uri->hostData.ip4 = memory->malloc(
1090
2.85k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1091
2.85k
    if (state->uri->hostData.ip4 == NULL) {
1092
0
        return URI_FALSE; /* Raises malloc error */
1093
0
    }
1094
2.85k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1095
2.85k
                                     state->uri->hostText.first,
1096
2.85k
                                     state->uri->hostText.afterLast)) {
1097
        /* Not IPv4 */
1098
2.81k
        memory->free(memory, state->uri->hostData.ip4);
1099
2.81k
        state->uri->hostData.ip4 = NULL;
1100
2.81k
    }
1101
2.85k
    return URI_TRUE; /* Success */
1102
2.85k
}
UriParse.c:uriOnExitOwnHost2A
Line
Count
Source
1085
1.39k
                                                   UriMemoryManager * memory) {
1086
1.39k
    state->uri->hostText.afterLast = first; /* HOST END */
1087
1088
    /* Valid IPv4 or just a regname? */
1089
1.39k
    state->uri->hostData.ip4 = memory->malloc(
1090
1.39k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1091
1.39k
    if (state->uri->hostData.ip4 == NULL) {
1092
0
        return URI_FALSE; /* Raises malloc error */
1093
0
    }
1094
1.39k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1095
1.39k
                                     state->uri->hostText.first,
1096
1.39k
                                     state->uri->hostText.afterLast)) {
1097
        /* Not IPv4 */
1098
1.37k
        memory->free(memory, state->uri->hostData.ip4);
1099
1.37k
        state->uri->hostData.ip4 = NULL;
1100
1.37k
    }
1101
1.39k
    return URI_TRUE; /* Success */
1102
1.39k
}
UriParse.c:uriOnExitOwnHost2W
Line
Count
Source
1085
1.46k
                                                   UriMemoryManager * memory) {
1086
1.46k
    state->uri->hostText.afterLast = first; /* HOST END */
1087
1088
    /* Valid IPv4 or just a regname? */
1089
1.46k
    state->uri->hostData.ip4 = memory->malloc(
1090
1.46k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1091
1.46k
    if (state->uri->hostData.ip4 == NULL) {
1092
0
        return URI_FALSE; /* Raises malloc error */
1093
0
    }
1094
1.46k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1095
1.46k
                                     state->uri->hostText.first,
1096
1.46k
                                     state->uri->hostText.afterLast)) {
1097
        /* Not IPv4 */
1098
1.43k
        memory->free(memory, state->uri->hostData.ip4);
1099
1.43k
        state->uri->hostData.ip4 = NULL;
1100
1.43k
    }
1101
1.46k
    return URI_TRUE; /* Success */
1102
1.46k
}
1103
1104
/*
1105
 * [ownHost2]->[authorityTwo] // can take <NULL>
1106
 * [ownHost2]->[pctSubUnres][ownHost2]
1107
 */
1108
static const URI_CHAR * URI_FUNC(ParseOwnHost2)(URI_TYPE(ParserState) * state,
1109
                                                const URI_CHAR * first,
1110
                                                const URI_CHAR * afterLast,
1111
1.53M
                                                UriMemoryManager * memory) {
1112
1.53M
    if (first >= afterLast) {
1113
2.54k
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1114
0
            URI_FUNC(StopMalloc)(state, memory);
1115
0
            return NULL;
1116
0
        }
1117
2.54k
        return afterLast;
1118
2.54k
    }
1119
1120
1.53M
    switch (*first) {
1121
870
    case _UT('!'):
1122
1.71k
    case _UT('$'):
1123
4.71k
    case _UT('%'):
1124
5.70k
    case _UT('&'):
1125
6.59k
    case _UT('('):
1126
8.56k
    case _UT(')'):
1127
11.1k
    case _UT('-'):
1128
12.7k
    case _UT('*'):
1129
13.5k
    case _UT(','):
1130
21.1k
    case _UT('.'):
1131
22.0k
    case _UT(';'):
1132
24.6k
    case _UT('\''):
1133
25.7k
    case _UT('_'):
1134
26.8k
    case _UT('~'):
1135
27.9k
    case _UT('+'):
1136
29.5k
    case _UT('='):
1137
3.37M
    case URI_SET_DIGIT:
1138
51.7M
    case URI_SET_ALPHA: {
1139
51.7M
        const URI_CHAR * const afterPctSubUnres =
1140
51.7M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1141
51.7M
        if (afterPctSubUnres == NULL) {
1142
35
            return NULL;
1143
35
        }
1144
1.53M
        return URI_FUNC(ParseOwnHost2)(state, afterPctSubUnres, afterLast, memory);
1145
51.7M
    }
1146
1147
310
    default:
1148
310
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1149
0
            URI_FUNC(StopMalloc)(state, memory);
1150
0
            return NULL;
1151
0
        }
1152
310
        return URI_FUNC(ParseAuthorityTwo)(state, first, afterLast);
1153
1.53M
    }
1154
1.53M
}
UriParse.c:uriParseOwnHost2A
Line
Count
Source
1111
1.23M
                                                UriMemoryManager * memory) {
1112
1.23M
    if (first >= afterLast) {
1113
1.28k
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1114
0
            URI_FUNC(StopMalloc)(state, memory);
1115
0
            return NULL;
1116
0
        }
1117
1.28k
        return afterLast;
1118
1.28k
    }
1119
1120
1.23M
    switch (*first) {
1121
420
    case _UT('!'):
1122
848
    case _UT('$'):
1123
2.09k
    case _UT('%'):
1124
2.49k
    case _UT('&'):
1125
2.99k
    case _UT('('):
1126
3.39k
    case _UT(')'):
1127
5.49k
    case _UT('-'):
1128
5.95k
    case _UT('*'):
1129
6.35k
    case _UT(','):
1130
13.2k
    case _UT('.'):
1131
13.7k
    case _UT(';'):
1132
14.5k
    case _UT('\''):
1133
14.9k
    case _UT('_'):
1134
15.3k
    case _UT('~'):
1135
15.7k
    case _UT('+'):
1136
16.9k
    case _UT('='):
1137
2.87M
    case URI_SET_DIGIT:
1138
43.3M
    case URI_SET_ALPHA: {
1139
43.3M
        const URI_CHAR * const afterPctSubUnres =
1140
43.3M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1141
43.3M
        if (afterPctSubUnres == NULL) {
1142
18
            return NULL;
1143
18
        }
1144
1.23M
        return URI_FUNC(ParseOwnHost2)(state, afterPctSubUnres, afterLast, memory);
1145
43.3M
    }
1146
1147
108
    default:
1148
108
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1149
0
            URI_FUNC(StopMalloc)(state, memory);
1150
0
            return NULL;
1151
0
        }
1152
108
        return URI_FUNC(ParseAuthorityTwo)(state, first, afterLast);
1153
1.23M
    }
1154
1.23M
}
UriParse.c:uriParseOwnHost2W
Line
Count
Source
1111
301k
                                                UriMemoryManager * memory) {
1112
301k
    if (first >= afterLast) {
1113
1.25k
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1114
0
            URI_FUNC(StopMalloc)(state, memory);
1115
0
            return NULL;
1116
0
        }
1117
1.25k
        return afterLast;
1118
1.25k
    }
1119
1120
300k
    switch (*first) {
1121
450
    case _UT('!'):
1122
869
    case _UT('$'):
1123
2.62k
    case _UT('%'):
1124
3.21k
    case _UT('&'):
1125
3.60k
    case _UT('('):
1126
5.17k
    case _UT(')'):
1127
5.62k
    case _UT('-'):
1128
6.81k
    case _UT('*'):
1129
7.20k
    case _UT(','):
1130
7.92k
    case _UT('.'):
1131
8.32k
    case _UT(';'):
1132
10.1k
    case _UT('\''):
1133
10.8k
    case _UT('_'):
1134
11.5k
    case _UT('~'):
1135
12.2k
    case _UT('+'):
1136
12.5k
    case _UT('='):
1137
492k
    case URI_SET_DIGIT:
1138
8.40M
    case URI_SET_ALPHA: {
1139
8.40M
        const URI_CHAR * const afterPctSubUnres =
1140
8.40M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1141
8.40M
        if (afterPctSubUnres == NULL) {
1142
17
            return NULL;
1143
17
        }
1144
299k
        return URI_FUNC(ParseOwnHost2)(state, afterPctSubUnres, afterLast, memory);
1145
8.40M
    }
1146
1147
202
    default:
1148
202
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1149
0
            URI_FUNC(StopMalloc)(state, memory);
1150
0
            return NULL;
1151
0
        }
1152
202
        return URI_FUNC(ParseAuthorityTwo)(state, first, afterLast);
1153
300k
    }
1154
300k
}
1155
1156
static URI_INLINE UriBool URI_FUNC(OnExitOwnHostUserInfo)(URI_TYPE(ParserState) * state,
1157
                                                          const URI_CHAR * first,
1158
4.86k
                                                          UriMemoryManager * memory) {
1159
4.86k
    state->uri->hostText.first =
1160
4.86k
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1161
4.86k
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1162
4.86k
    state->uri->hostText.afterLast = first; /* HOST END */
1163
1164
    /* Valid IPv4 or just a regname? */
1165
4.86k
    state->uri->hostData.ip4 = memory->malloc(
1166
4.86k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1167
4.86k
    if (state->uri->hostData.ip4 == NULL) {
1168
0
        return URI_FALSE; /* Raises malloc error */
1169
0
    }
1170
4.86k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1171
4.86k
                                     state->uri->hostText.first,
1172
4.86k
                                     state->uri->hostText.afterLast)) {
1173
        /* Not IPv4 */
1174
4.73k
        memory->free(memory, state->uri->hostData.ip4);
1175
4.73k
        state->uri->hostData.ip4 = NULL;
1176
4.73k
    }
1177
4.86k
    return URI_TRUE; /* Success */
1178
4.86k
}
UriParse.c:uriOnExitOwnHostUserInfoA
Line
Count
Source
1158
2.46k
                                                          UriMemoryManager * memory) {
1159
2.46k
    state->uri->hostText.first =
1160
2.46k
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1161
2.46k
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1162
2.46k
    state->uri->hostText.afterLast = first; /* HOST END */
1163
1164
    /* Valid IPv4 or just a regname? */
1165
2.46k
    state->uri->hostData.ip4 = memory->malloc(
1166
2.46k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1167
2.46k
    if (state->uri->hostData.ip4 == NULL) {
1168
0
        return URI_FALSE; /* Raises malloc error */
1169
0
    }
1170
2.46k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1171
2.46k
                                     state->uri->hostText.first,
1172
2.46k
                                     state->uri->hostText.afterLast)) {
1173
        /* Not IPv4 */
1174
2.40k
        memory->free(memory, state->uri->hostData.ip4);
1175
2.40k
        state->uri->hostData.ip4 = NULL;
1176
2.40k
    }
1177
2.46k
    return URI_TRUE; /* Success */
1178
2.46k
}
UriParse.c:uriOnExitOwnHostUserInfoW
Line
Count
Source
1158
2.40k
                                                          UriMemoryManager * memory) {
1159
2.40k
    state->uri->hostText.first =
1160
2.40k
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1161
2.40k
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1162
2.40k
    state->uri->hostText.afterLast = first; /* HOST END */
1163
1164
    /* Valid IPv4 or just a regname? */
1165
2.40k
    state->uri->hostData.ip4 = memory->malloc(
1166
2.40k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1167
2.40k
    if (state->uri->hostData.ip4 == NULL) {
1168
0
        return URI_FALSE; /* Raises malloc error */
1169
0
    }
1170
2.40k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1171
2.40k
                                     state->uri->hostText.first,
1172
2.40k
                                     state->uri->hostText.afterLast)) {
1173
        /* Not IPv4 */
1174
2.33k
        memory->free(memory, state->uri->hostData.ip4);
1175
2.33k
        state->uri->hostData.ip4 = NULL;
1176
2.33k
    }
1177
2.40k
    return URI_TRUE; /* Success */
1178
2.40k
}
1179
1180
/*
1181
 * [ownHostUserInfo]->[ownHostUserInfoNz]
1182
 * [ownHostUserInfo]-><NULL>
1183
 */
1184
static URI_INLINE const URI_CHAR *
1185
URI_FUNC(ParseOwnHostUserInfo)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
1186
5.71M
                               const URI_CHAR * afterLast, UriMemoryManager * memory) {
1187
5.71M
    if (first >= afterLast) {
1188
4.71k
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1189
0
            URI_FUNC(StopMalloc)(state, memory);
1190
0
            return NULL;
1191
0
        }
1192
4.71k
        return afterLast;
1193
4.71k
    }
1194
1195
5.71M
    switch (*first) {
1196
1.59k
    case _UT('!'):
1197
3.27k
    case _UT('$'):
1198
12.7k
    case _UT('%'):
1199
14.4k
    case _UT('&'):
1200
16.1k
    case _UT('('):
1201
21.3k
    case _UT(')'):
1202
32.9k
    case _UT('-'):
1203
35.8k
    case _UT('*'):
1204
37.7k
    case _UT(','):
1205
75.7k
    case _UT('.'):
1206
75.9k
    case _UT(':'):
1207
77.8k
    case _UT(';'):
1208
78.0k
    case _UT('@'):
1209
83.5k
    case _UT('\''):
1210
85.4k
    case _UT('_'):
1211
87.5k
    case _UT('~'):
1212
89.3k
    case _UT('+'):
1213
91.6k
    case _UT('='):
1214
3.62M
    case URI_SET_DIGIT:
1215
5.71M
    case URI_SET_ALPHA:
1216
5.71M
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
1217
1218
147
    default:
1219
147
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1220
0
            URI_FUNC(StopMalloc)(state, memory);
1221
0
            return NULL;
1222
0
        }
1223
147
        return first;
1224
5.71M
    }
1225
5.71M
}
UriParse.c:uriParseOwnHostUserInfoA
Line
Count
Source
1186
4.58M
                               const URI_CHAR * afterLast, UriMemoryManager * memory) {
1187
4.58M
    if (first >= afterLast) {
1188
2.39k
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1189
0
            URI_FUNC(StopMalloc)(state, memory);
1190
0
            return NULL;
1191
0
        }
1192
2.39k
        return afterLast;
1193
2.39k
    }
1194
1195
4.58M
    switch (*first) {
1196
1.10k
    case _UT('!'):
1197
2.11k
    case _UT('$'):
1198
5.40k
    case _UT('%'):
1199
6.39k
    case _UT('&'):
1200
7.49k
    case _UT('('):
1201
8.92k
    case _UT(')'):
1202
18.4k
    case _UT('-'):
1203
19.3k
    case _UT('*'):
1204
20.1k
    case _UT(','):
1205
56.2k
    case _UT('.'):
1206
56.3k
    case _UT(':'):
1207
57.4k
    case _UT(';'):
1208
57.5k
    case _UT('@'):
1209
58.8k
    case _UT('\''):
1210
59.5k
    case _UT('_'):
1211
60.1k
    case _UT('~'):
1212
61.1k
    case _UT('+'):
1213
62.8k
    case _UT('='):
1214
1.87M
    case URI_SET_DIGIT:
1215
4.58M
    case URI_SET_ALPHA:
1216
4.58M
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
1217
1218
67
    default:
1219
67
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1220
0
            URI_FUNC(StopMalloc)(state, memory);
1221
0
            return NULL;
1222
0
        }
1223
67
        return first;
1224
4.58M
    }
1225
4.58M
}
UriParse.c:uriParseOwnHostUserInfoW
Line
Count
Source
1186
1.12M
                               const URI_CHAR * afterLast, UriMemoryManager * memory) {
1187
1.12M
    if (first >= afterLast) {
1188
2.32k
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1189
0
            URI_FUNC(StopMalloc)(state, memory);
1190
0
            return NULL;
1191
0
        }
1192
2.32k
        return afterLast;
1193
2.32k
    }
1194
1195
1.12M
    switch (*first) {
1196
494
    case _UT('!'):
1197
1.16k
    case _UT('$'):
1198
7.38k
    case _UT('%'):
1199
8.04k
    case _UT('&'):
1200
8.64k
    case _UT('('):
1201
12.4k
    case _UT(')'):
1202
14.5k
    case _UT('-'):
1203
16.4k
    case _UT('*'):
1204
17.5k
    case _UT(','):
1205
19.5k
    case _UT('.'):
1206
19.5k
    case _UT(':'):
1207
20.3k
    case _UT(';'):
1208
20.4k
    case _UT('@'):
1209
24.7k
    case _UT('\''):
1210
25.9k
    case _UT('_'):
1211
27.3k
    case _UT('~'):
1212
28.2k
    case _UT('+'):
1213
28.8k
    case _UT('='):
1214
1.75M
    case URI_SET_DIGIT:
1215
1.75M
    case URI_SET_ALPHA:
1216
1.12M
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
1217
1218
80
    default:
1219
80
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1220
0
            URI_FUNC(StopMalloc)(state, memory);
1221
0
            return NULL;
1222
0
        }
1223
80
        return first;
1224
1.12M
    }
1225
1.12M
}
1226
1227
/*
1228
 * [ownHostUserInfoNz]->[pctSubUnres][ownHostUserInfo]
1229
 * [ownHostUserInfoNz]-><:>[ownPortUserInfo]
1230
 * [ownHostUserInfoNz]-><@>[ownHost]
1231
 */
1232
static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfoNz)(URI_TYPE(ParserState) * state,
1233
                                                         const URI_CHAR * first,
1234
                                                         const URI_CHAR * afterLast,
1235
5.72M
                                                         UriMemoryManager * memory) {
1236
5.72M
    if (first >= afterLast) {
1237
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1238
0
        return NULL;
1239
0
    }
1240
1241
5.72M
    switch (*first) {
1242
1.65k
    case _UT('!'):
1243
3.39k
    case _UT('$'):
1244
13.0k
    case _UT('%'):
1245
14.7k
    case _UT('&'):
1246
16.5k
    case _UT('('):
1247
21.7k
    case _UT(')'):
1248
33.4k
    case _UT('-'):
1249
36.3k
    case _UT('*'):
1250
38.3k
    case _UT(','):
1251
76.5k
    case _UT('.'):
1252
78.5k
    case _UT(';'):
1253
84.0k
    case _UT('\''):
1254
86.1k
    case _UT('_'):
1255
88.2k
    case _UT('~'):
1256
90.1k
    case _UT('+'):
1257
92.5k
    case _UT('='):
1258
3.64M
    case URI_SET_DIGIT:
1259
158M
    case URI_SET_ALPHA: {
1260
158M
        const URI_CHAR * const afterPctSubUnres =
1261
158M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1262
158M
        if (afterPctSubUnres == NULL) {
1263
59
            return NULL;
1264
59
        }
1265
5.71M
        return URI_FUNC(ParseOwnHostUserInfo)(state, afterPctSubUnres, afterLast, memory);
1266
158M
    }
1267
1268
3.69k
    case _UT(':'):
1269
3.69k
        state->uri->hostText.afterLast = first; /* HOST END */
1270
3.69k
        state->uri->portText.first = first + 1; /* PORT BEGIN */
1271
3.69k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1272
1273
3.22k
    case _UT('@'):
1274
3.22k
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1275
3.22k
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1276
3.22k
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1277
1278
0
    default:
1279
0
        URI_FUNC(StopSyntax)(state, first, memory);
1280
0
        return NULL;
1281
5.72M
    }
1282
5.72M
}
UriParse.c:uriParseOwnHostUserInfoNzA
Line
Count
Source
1235
4.59M
                                                         UriMemoryManager * memory) {
1236
4.59M
    if (first >= afterLast) {
1237
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1238
0
        return NULL;
1239
0
    }
1240
1241
4.59M
    switch (*first) {
1242
1.13k
    case _UT('!'):
1243
2.17k
    case _UT('$'):
1244
5.51k
    case _UT('%'):
1245
6.53k
    case _UT('&'):
1246
7.67k
    case _UT('('):
1247
9.13k
    case _UT(')'):
1248
18.6k
    case _UT('-'):
1249
19.6k
    case _UT('*'):
1250
20.4k
    case _UT(','):
1251
56.6k
    case _UT('.'):
1252
57.7k
    case _UT(';'):
1253
59.0k
    case _UT('\''):
1254
59.8k
    case _UT('_'):
1255
60.4k
    case _UT('~'):
1256
61.4k
    case _UT('+'):
1257
63.1k
    case _UT('='):
1258
1.87M
    case URI_SET_DIGIT:
1259
127M
    case URI_SET_ALPHA: {
1260
127M
        const URI_CHAR * const afterPctSubUnres =
1261
127M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1262
127M
        if (afterPctSubUnres == NULL) {
1263
30
            return NULL;
1264
30
        }
1265
4.58M
        return URI_FUNC(ParseOwnHostUserInfo)(state, afterPctSubUnres, afterLast, memory);
1266
127M
    }
1267
1268
1.87k
    case _UT(':'):
1269
1.87k
        state->uri->hostText.afterLast = first; /* HOST END */
1270
1.87k
        state->uri->portText.first = first + 1; /* PORT BEGIN */
1271
1.87k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1272
1273
1.51k
    case _UT('@'):
1274
1.51k
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1275
1.51k
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1276
1.51k
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1277
1278
0
    default:
1279
0
        URI_FUNC(StopSyntax)(state, first, memory);
1280
        return NULL;
1281
4.59M
    }
1282
4.59M
}
UriParse.c:uriParseOwnHostUserInfoNzW
Line
Count
Source
1235
1.13M
                                                         UriMemoryManager * memory) {
1236
1.13M
    if (first >= afterLast) {
1237
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1238
0
        return NULL;
1239
0
    }
1240
1241
1.13M
    switch (*first) {
1242
522
    case _UT('!'):
1243
1.22k
    case _UT('$'):
1244
7.50k
    case _UT('%'):
1245
8.20k
    case _UT('&'):
1246
8.83k
    case _UT('('):
1247
12.6k
    case _UT(')'):
1248
14.7k
    case _UT('-'):
1249
16.7k
    case _UT('*'):
1250
17.8k
    case _UT(','):
1251
19.9k
    case _UT('.'):
1252
20.7k
    case _UT(';'):
1253
25.0k
    case _UT('\''):
1254
26.3k
    case _UT('_'):
1255
27.7k
    case _UT('~'):
1256
28.7k
    case _UT('+'):
1257
29.3k
    case _UT('='):
1258
1.76M
    case URI_SET_DIGIT:
1259
30.7M
    case URI_SET_ALPHA: {
1260
30.7M
        const URI_CHAR * const afterPctSubUnres =
1261
30.7M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1262
30.7M
        if (afterPctSubUnres == NULL) {
1263
29
            return NULL;
1264
29
        }
1265
1.12M
        return URI_FUNC(ParseOwnHostUserInfo)(state, afterPctSubUnres, afterLast, memory);
1266
30.7M
    }
1267
1268
1.82k
    case _UT(':'):
1269
1.82k
        state->uri->hostText.afterLast = first; /* HOST END */
1270
1.82k
        state->uri->portText.first = first + 1; /* PORT BEGIN */
1271
1.82k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1272
1273
1.70k
    case _UT('@'):
1274
1.70k
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1275
1.70k
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1276
1.70k
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1277
1278
0
    default:
1279
0
        URI_FUNC(StopSyntax)(state, first, memory);
1280
        return NULL;
1281
1.13M
    }
1282
1.13M
}
1283
1284
static URI_INLINE UriBool URI_FUNC(OnExitOwnPortUserInfo)(URI_TYPE(ParserState) * state,
1285
                                                          const URI_CHAR * first,
1286
438
                                                          UriMemoryManager * memory) {
1287
438
    state->uri->hostText.first =
1288
438
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1289
438
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1290
438
    state->uri->portText.afterLast = first; /* PORT END */
1291
1292
    /* Valid IPv4 or just a regname? */
1293
438
    state->uri->hostData.ip4 = memory->malloc(
1294
438
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1295
438
    if (state->uri->hostData.ip4 == NULL) {
1296
0
        return URI_FALSE; /* Raises malloc error */
1297
0
    }
1298
438
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1299
438
                                     state->uri->hostText.first,
1300
438
                                     state->uri->hostText.afterLast)) {
1301
        /* Not IPv4 */
1302
421
        memory->free(memory, state->uri->hostData.ip4);
1303
421
        state->uri->hostData.ip4 = NULL;
1304
421
    }
1305
438
    return URI_TRUE; /* Success */
1306
438
}
UriParse.c:uriOnExitOwnPortUserInfoA
Line
Count
Source
1286
220
                                                          UriMemoryManager * memory) {
1287
220
    state->uri->hostText.first =
1288
220
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1289
220
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1290
220
    state->uri->portText.afterLast = first; /* PORT END */
1291
1292
    /* Valid IPv4 or just a regname? */
1293
220
    state->uri->hostData.ip4 = memory->malloc(
1294
220
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1295
220
    if (state->uri->hostData.ip4 == NULL) {
1296
0
        return URI_FALSE; /* Raises malloc error */
1297
0
    }
1298
220
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1299
220
                                     state->uri->hostText.first,
1300
220
                                     state->uri->hostText.afterLast)) {
1301
        /* Not IPv4 */
1302
210
        memory->free(memory, state->uri->hostData.ip4);
1303
210
        state->uri->hostData.ip4 = NULL;
1304
210
    }
1305
220
    return URI_TRUE; /* Success */
1306
220
}
UriParse.c:uriOnExitOwnPortUserInfoW
Line
Count
Source
1286
218
                                                          UriMemoryManager * memory) {
1287
218
    state->uri->hostText.first =
1288
218
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1289
218
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1290
218
    state->uri->portText.afterLast = first; /* PORT END */
1291
1292
    /* Valid IPv4 or just a regname? */
1293
218
    state->uri->hostData.ip4 = memory->malloc(
1294
218
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1295
218
    if (state->uri->hostData.ip4 == NULL) {
1296
0
        return URI_FALSE; /* Raises malloc error */
1297
0
    }
1298
218
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1299
218
                                     state->uri->hostText.first,
1300
218
                                     state->uri->hostText.afterLast)) {
1301
        /* Not IPv4 */
1302
211
        memory->free(memory, state->uri->hostData.ip4);
1303
211
        state->uri->hostData.ip4 = NULL;
1304
211
    }
1305
218
    return URI_TRUE; /* Success */
1306
218
}
1307
1308
/*
1309
 * [ownPortUserInfo]->[ALPHA][ownUserInfo]
1310
 * [ownPortUserInfo]->[DIGIT][ownPortUserInfo]
1311
 * [ownPortUserInfo]-><.>[ownUserInfo]
1312
 * [ownPortUserInfo]-><_>[ownUserInfo]
1313
 * [ownPortUserInfo]-><~>[ownUserInfo]
1314
 * [ownPortUserInfo]-><->[ownUserInfo]
1315
 * [ownPortUserInfo]->[subDelims][ownUserInfo]
1316
 * [ownPortUserInfo]->[pctEncoded][ownUserInfo]
1317
 * [ownPortUserInfo]-><:>[ownUserInfo]
1318
 * [ownPortUserInfo]-><@>[ownHost]
1319
 * [ownPortUserInfo]-><NULL>
1320
 */
1321
static const URI_CHAR * URI_FUNC(ParseOwnPortUserInfo)(URI_TYPE(ParserState) * state,
1322
                                                       const URI_CHAR * first,
1323
                                                       const URI_CHAR * afterLast,
1324
59.4k
                                                       UriMemoryManager * memory) {
1325
59.4k
    if (first >= afterLast) {
1326
399
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1327
0
            URI_FUNC(StopMalloc)(state, memory);
1328
0
            return NULL;
1329
0
        }
1330
399
        return afterLast;
1331
399
    }
1332
1333
59.0k
    switch (*first) {
1334
    /* begin sub-delims */
1335
42
    case _UT('!'):
1336
98
    case _UT('$'):
1337
126
    case _UT('&'):
1338
172
    case _UT('\''):
1339
218
    case _UT('('):
1340
280
    case _UT(')'):
1341
332
    case _UT('*'):
1342
378
    case _UT('+'):
1343
422
    case _UT(','):
1344
476
    case _UT(';'):
1345
514
    case _UT('='):
1346
    /* end sub-delims */
1347
    /* begin unreserved (except alpha and digit) */
1348
588
    case _UT('-'):
1349
697
    case _UT('.'):
1350
742
    case _UT('_'):
1351
792
    case _UT('~'):
1352
    /* end unreserved (except alpha and digit) */
1353
937
    case _UT(':'):
1354
3.22k
    case URI_SET_ALPHA:
1355
3.22k
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1356
3.22k
        state->uri->portText.first = NULL; /* Not a port, reset */
1357
3.22k
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1358
1359
55.7k
    case URI_SET_DIGIT:
1360
55.7k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1361
1362
15
    case _UT('%'):
1363
15
        state->uri->portText.first = NULL; /* Not a port, reset */
1364
15
        const URI_CHAR * const afterPct =
1365
15
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1366
15
        if (afterPct == NULL) {
1367
4
            return NULL;
1368
4
        }
1369
11
        return URI_FUNC(ParseOwnUserInfo)(state, afterPct, afterLast, memory);
1370
1371
16
    case _UT('@'):
1372
16
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1373
16
        state->uri->portText.first = NULL; /* Not a port, reset */
1374
16
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1375
16
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1376
16
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1377
1378
39
    default:
1379
39
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1380
0
            URI_FUNC(StopMalloc)(state, memory);
1381
0
            return NULL;
1382
0
        }
1383
39
        return first;
1384
59.0k
    }
1385
59.0k
}
UriParse.c:uriParseOwnPortUserInfoA
Line
Count
Source
1324
52.3k
                                                       UriMemoryManager * memory) {
1325
52.3k
    if (first >= afterLast) {
1326
199
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1327
0
            URI_FUNC(StopMalloc)(state, memory);
1328
0
            return NULL;
1329
0
        }
1330
199
        return afterLast;
1331
199
    }
1332
1333
52.1k
    switch (*first) {
1334
    /* begin sub-delims */
1335
22
    case _UT('!'):
1336
46
    case _UT('$'):
1337
65
    case _UT('&'):
1338
87
    case _UT('\''):
1339
101
    case _UT('('):
1340
134
    case _UT(')'):
1341
163
    case _UT('*'):
1342
188
    case _UT('+'):
1343
217
    case _UT(','):
1344
244
    case _UT(';'):
1345
261
    case _UT('='):
1346
    /* end sub-delims */
1347
    /* begin unreserved (except alpha and digit) */
1348
306
    case _UT('-'):
1349
354
    case _UT('.'):
1350
371
    case _UT('_'):
1351
400
    case _UT('~'):
1352
    /* end unreserved (except alpha and digit) */
1353
474
    case _UT(':'):
1354
1.63k
    case URI_SET_ALPHA:
1355
1.63k
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1356
1.63k
        state->uri->portText.first = NULL; /* Not a port, reset */
1357
1.63k
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1358
1359
50.4k
    case URI_SET_DIGIT:
1360
50.4k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1361
1362
8
    case _UT('%'):
1363
8
        state->uri->portText.first = NULL; /* Not a port, reset */
1364
8
        const URI_CHAR * const afterPct =
1365
8
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1366
8
        if (afterPct == NULL) {
1367
2
            return NULL;
1368
2
        }
1369
6
        return URI_FUNC(ParseOwnUserInfo)(state, afterPct, afterLast, memory);
1370
1371
9
    case _UT('@'):
1372
9
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1373
9
        state->uri->portText.first = NULL; /* Not a port, reset */
1374
9
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1375
9
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1376
9
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1377
1378
21
    default:
1379
21
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1380
0
            URI_FUNC(StopMalloc)(state, memory);
1381
0
            return NULL;
1382
0
        }
1383
21
        return first;
1384
52.1k
    }
1385
52.1k
}
UriParse.c:uriParseOwnPortUserInfoW
Line
Count
Source
1324
7.06k
                                                       UriMemoryManager * memory) {
1325
7.06k
    if (first >= afterLast) {
1326
200
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1327
0
            URI_FUNC(StopMalloc)(state, memory);
1328
0
            return NULL;
1329
0
        }
1330
200
        return afterLast;
1331
200
    }
1332
1333
6.86k
    switch (*first) {
1334
    /* begin sub-delims */
1335
20
    case _UT('!'):
1336
52
    case _UT('$'):
1337
61
    case _UT('&'):
1338
85
    case _UT('\''):
1339
117
    case _UT('('):
1340
146
    case _UT(')'):
1341
169
    case _UT('*'):
1342
190
    case _UT('+'):
1343
205
    case _UT(','):
1344
232
    case _UT(';'):
1345
253
    case _UT('='):
1346
    /* end sub-delims */
1347
    /* begin unreserved (except alpha and digit) */
1348
282
    case _UT('-'):
1349
343
    case _UT('.'):
1350
371
    case _UT('_'):
1351
392
    case _UT('~'):
1352
    /* end unreserved (except alpha and digit) */
1353
463
    case _UT(':'):
1354
1.59k
    case URI_SET_ALPHA:
1355
1.59k
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1356
1.59k
        state->uri->portText.first = NULL; /* Not a port, reset */
1357
1.59k
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1358
1359
5.24k
    case URI_SET_DIGIT:
1360
5.24k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1361
1362
7
    case _UT('%'):
1363
7
        state->uri->portText.first = NULL; /* Not a port, reset */
1364
7
        const URI_CHAR * const afterPct =
1365
7
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1366
7
        if (afterPct == NULL) {
1367
2
            return NULL;
1368
2
        }
1369
5
        return URI_FUNC(ParseOwnUserInfo)(state, afterPct, afterLast, memory);
1370
1371
7
    case _UT('@'):
1372
7
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1373
7
        state->uri->portText.first = NULL; /* Not a port, reset */
1374
7
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1375
7
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1376
7
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1377
1378
18
    default:
1379
18
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1380
0
            URI_FUNC(StopMalloc)(state, memory);
1381
0
            return NULL;
1382
0
        }
1383
18
        return first;
1384
6.86k
    }
1385
6.86k
}
1386
1387
/*
1388
 * [ownUserInfo]->[pctSubUnres][ownUserInfo]
1389
 * [ownUserInfo]-><:>[ownUserInfo]
1390
 * [ownUserInfo]-><@>[ownHost]
1391
 */
1392
static const URI_CHAR * URI_FUNC(ParseOwnUserInfo)(URI_TYPE(ParserState) * state,
1393
                                                   const URI_CHAR * first,
1394
                                                   const URI_CHAR * afterLast,
1395
998k
                                                   UriMemoryManager * memory) {
1396
998k
    if (first >= afterLast) {
1397
2.92k
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1398
2.92k
        return NULL;
1399
2.92k
    }
1400
1401
995k
    switch (*first) {
1402
954
    case _UT('!'):
1403
1.95k
    case _UT('$'):
1404
7.88k
    case _UT('%'):
1405
9.56k
    case _UT('&'):
1406
10.4k
    case _UT('('):
1407
14.0k
    case _UT(')'):
1408
19.2k
    case _UT('-'):
1409
21.6k
    case _UT('*'):
1410
22.4k
    case _UT(','):
1411
30.3k
    case _UT('.'):
1412
31.4k
    case _UT(';'):
1413
36.4k
    case _UT('\''):
1414
37.8k
    case _UT('_'):
1415
39.8k
    case _UT('~'):
1416
41.1k
    case _UT('+'):
1417
45.1k
    case _UT('='):
1418
923k
    case URI_SET_DIGIT:
1419
30.1M
    case URI_SET_ALPHA: {
1420
30.1M
        const URI_CHAR * const afterPctSubUnres =
1421
30.1M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1422
30.1M
        if (afterPctSubUnres == NULL) {
1423
32
            return NULL;
1424
32
        }
1425
993k
        return URI_FUNC(ParseOwnUserInfo)(state, afterPctSubUnres, afterLast, memory);
1426
30.1M
    }
1427
1428
1.10k
    case _UT(':'):
1429
1.10k
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1430
1431
245
    case _UT('@'):
1432
        /* SURE */
1433
245
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1434
245
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1435
245
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1436
1437
32
    default:
1438
32
        URI_FUNC(StopSyntax)(state, first, memory);
1439
32
        return NULL;
1440
995k
    }
1441
995k
}
UriParse.c:uriParseOwnUserInfoA
Line
Count
Source
1395
861k
                                                   UriMemoryManager * memory) {
1396
861k
    if (first >= afterLast) {
1397
1.47k
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1398
1.47k
        return NULL;
1399
1.47k
    }
1400
1401
859k
    switch (*first) {
1402
554
    case _UT('!'):
1403
1.15k
    case _UT('$'):
1404
3.59k
    case _UT('%'):
1405
4.70k
    case _UT('&'):
1406
5.17k
    case _UT('('):
1407
5.61k
    case _UT(')'):
1408
10.4k
    case _UT('-'):
1409
11.0k
    case _UT('*'):
1410
11.4k
    case _UT(','):
1411
18.7k
    case _UT('.'):
1412
19.4k
    case _UT(';'):
1413
20.7k
    case _UT('\''):
1414
21.2k
    case _UT('_'):
1415
21.7k
    case _UT('~'):
1416
22.2k
    case _UT('+'):
1417
25.8k
    case _UT('='):
1418
596k
    case URI_SET_DIGIT:
1419
25.3M
    case URI_SET_ALPHA: {
1420
25.3M
        const URI_CHAR * const afterPctSubUnres =
1421
25.3M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1422
25.3M
        if (afterPctSubUnres == NULL) {
1423
16
            return NULL;
1424
16
        }
1425
858k
        return URI_FUNC(ParseOwnUserInfo)(state, afterPctSubUnres, afterLast, memory);
1426
25.3M
    }
1427
1428
529
    case _UT(':'):
1429
529
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1430
1431
142
    case _UT('@'):
1432
        /* SURE */
1433
142
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1434
142
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1435
142
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1436
1437
14
    default:
1438
14
        URI_FUNC(StopSyntax)(state, first, memory);
1439
        return NULL;
1440
859k
    }
1441
859k
}
UriParse.c:uriParseOwnUserInfoW
Line
Count
Source
1395
136k
                                                   UriMemoryManager * memory) {
1396
136k
    if (first >= afterLast) {
1397
1.45k
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1398
1.45k
        return NULL;
1399
1.45k
    }
1400
1401
135k
    switch (*first) {
1402
400
    case _UT('!'):
1403
795
    case _UT('$'):
1404
4.29k
    case _UT('%'):
1405
4.86k
    case _UT('&'):
1406
5.25k
    case _UT('('):
1407
8.38k
    case _UT(')'):
1408
8.81k
    case _UT('-'):
1409
10.6k
    case _UT('*'):
1410
11.0k
    case _UT(','):
1411
11.6k
    case _UT('.'):
1412
12.0k
    case _UT(';'):
1413
15.6k
    case _UT('\''):
1414
16.6k
    case _UT('_'):
1415
18.0k
    case _UT('~'):
1416
18.8k
    case _UT('+'):
1417
19.2k
    case _UT('='):
1418
327k
    case URI_SET_DIGIT:
1419
4.81M
    case URI_SET_ALPHA: {
1420
4.81M
        const URI_CHAR * const afterPctSubUnres =
1421
4.81M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1422
4.81M
        if (afterPctSubUnres == NULL) {
1423
16
            return NULL;
1424
16
        }
1425
134k
        return URI_FUNC(ParseOwnUserInfo)(state, afterPctSubUnres, afterLast, memory);
1426
4.81M
    }
1427
1428
580
    case _UT(':'):
1429
580
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1430
1431
103
    case _UT('@'):
1432
        /* SURE */
1433
103
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1434
103
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1435
103
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1436
1437
18
    default:
1438
18
        URI_FUNC(StopSyntax)(state, first, memory);
1439
        return NULL;
1440
135k
    }
1441
135k
}
1442
1443
3.17k
static URI_INLINE void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state) {
1444
3.17k
    state->uri->absolutePath = URI_TRUE;
1445
3.17k
}
UriParse.c:uriOnExitPartHelperTwoA
Line
Count
Source
1443
1.45k
static URI_INLINE void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state) {
1444
1.45k
    state->uri->absolutePath = URI_TRUE;
1445
1.45k
}
UriParse.c:uriOnExitPartHelperTwoW
Line
Count
Source
1443
1.71k
static URI_INLINE void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state) {
1444
1.71k
    state->uri->absolutePath = URI_TRUE;
1445
1.71k
}
1446
1447
/*
1448
 * [partHelperTwo]->[pathAbsNoLeadSlash] // can take <NULL>
1449
 * [partHelperTwo]-></>[authority][pathAbsEmpty]
1450
 */
1451
static URI_INLINE const URI_CHAR *
1452
URI_FUNC(ParsePartHelperTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
1453
23.3k
                             const URI_CHAR * afterLast, UriMemoryManager * memory) {
1454
23.3k
    if (first >= afterLast) {
1455
49
        URI_FUNC(OnExitPartHelperTwo)(state);
1456
49
        return afterLast;
1457
49
    }
1458
1459
23.2k
    switch (*first) {
1460
20.1k
    case _UT('/'): {
1461
20.1k
        const URI_CHAR * const afterAuthority =
1462
20.1k
            URI_FUNC(ParseAuthority)(state, first + 1, afterLast, memory);
1463
20.1k
        const URI_CHAR * afterPathAbsEmpty;
1464
20.1k
        if (afterAuthority == NULL) {
1465
9.75k
            return NULL;
1466
9.75k
        }
1467
10.3k
        afterPathAbsEmpty =
1468
10.3k
            URI_FUNC(ParsePathAbsEmpty)(state, afterAuthority, afterLast, memory);
1469
1470
10.3k
        URI_FUNC(FixEmptyTrailSegment)(state->uri, memory);
1471
1472
10.3k
        return afterPathAbsEmpty;
1473
20.1k
    }
1474
1475
3.12k
    default:
1476
3.12k
        URI_FUNC(OnExitPartHelperTwo)(state);
1477
3.12k
        return URI_FUNC(ParsePathAbsNoLeadSlash)(state, first, afterLast, memory);
1478
23.2k
    }
1479
23.2k
}
UriParse.c:uriParsePartHelperTwoA
Line
Count
Source
1453
11.3k
                             const URI_CHAR * afterLast, UriMemoryManager * memory) {
1454
11.3k
    if (first >= afterLast) {
1455
28
        URI_FUNC(OnExitPartHelperTwo)(state);
1456
28
        return afterLast;
1457
28
    }
1458
1459
11.2k
    switch (*first) {
1460
9.86k
    case _UT('/'): {
1461
9.86k
        const URI_CHAR * const afterAuthority =
1462
9.86k
            URI_FUNC(ParseAuthority)(state, first + 1, afterLast, memory);
1463
9.86k
        const URI_CHAR * afterPathAbsEmpty;
1464
9.86k
        if (afterAuthority == NULL) {
1465
4.77k
            return NULL;
1466
4.77k
        }
1467
5.08k
        afterPathAbsEmpty =
1468
5.08k
            URI_FUNC(ParsePathAbsEmpty)(state, afterAuthority, afterLast, memory);
1469
1470
5.08k
        URI_FUNC(FixEmptyTrailSegment)(state->uri, memory);
1471
1472
5.08k
        return afterPathAbsEmpty;
1473
9.86k
    }
1474
1475
1.42k
    default:
1476
1.42k
        URI_FUNC(OnExitPartHelperTwo)(state);
1477
1.42k
        return URI_FUNC(ParsePathAbsNoLeadSlash)(state, first, afterLast, memory);
1478
11.2k
    }
1479
11.2k
}
UriParse.c:uriParsePartHelperTwoW
Line
Count
Source
1453
11.9k
                             const URI_CHAR * afterLast, UriMemoryManager * memory) {
1454
11.9k
    if (first >= afterLast) {
1455
21
        URI_FUNC(OnExitPartHelperTwo)(state);
1456
21
        return afterLast;
1457
21
    }
1458
1459
11.9k
    switch (*first) {
1460
10.2k
    case _UT('/'): {
1461
10.2k
        const URI_CHAR * const afterAuthority =
1462
10.2k
            URI_FUNC(ParseAuthority)(state, first + 1, afterLast, memory);
1463
10.2k
        const URI_CHAR * afterPathAbsEmpty;
1464
10.2k
        if (afterAuthority == NULL) {
1465
4.97k
            return NULL;
1466
4.97k
        }
1467
5.30k
        afterPathAbsEmpty =
1468
5.30k
            URI_FUNC(ParsePathAbsEmpty)(state, afterAuthority, afterLast, memory);
1469
1470
5.30k
        URI_FUNC(FixEmptyTrailSegment)(state->uri, memory);
1471
1472
5.30k
        return afterPathAbsEmpty;
1473
10.2k
    }
1474
1475
1.69k
    default:
1476
1.69k
        URI_FUNC(OnExitPartHelperTwo)(state);
1477
1.69k
        return URI_FUNC(ParsePathAbsNoLeadSlash)(state, first, afterLast, memory);
1478
11.9k
    }
1479
11.9k
}
1480
1481
/*
1482
 * [pathAbsEmpty]-></>[segment][pathAbsEmpty]
1483
 * [pathAbsEmpty]-><NULL>
1484
 */
1485
static const URI_CHAR * URI_FUNC(ParsePathAbsEmpty)(URI_TYPE(ParserState) * state,
1486
                                                    const URI_CHAR * first,
1487
                                                    const URI_CHAR * afterLast,
1488
18.0k
                                                    UriMemoryManager * memory) {
1489
18.0k
    if (first >= afterLast) {
1490
9.47k
        return afterLast;
1491
9.47k
    }
1492
1493
8.61k
    switch (*first) {
1494
7.70k
    case _UT('/'): {
1495
7.70k
        const URI_CHAR * const afterSegment =
1496
7.70k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1497
7.70k
        if (afterSegment == NULL) {
1498
7
            return NULL;
1499
7
        }
1500
7.69k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1501
7.69k
                                       memory)) { /* SEGMENT BOTH */
1502
0
            URI_FUNC(StopMalloc)(state, memory);
1503
0
            return NULL;
1504
0
        }
1505
7.69k
        return URI_FUNC(ParsePathAbsEmpty)(state, afterSegment, afterLast, memory);
1506
7.69k
    }
1507
1508
912
    default:
1509
912
        return first;
1510
8.61k
    }
1511
8.61k
}
UriParse.c:uriParsePathAbsEmptyA
Line
Count
Source
1488
9.28k
                                                    UriMemoryManager * memory) {
1489
9.28k
    if (first >= afterLast) {
1490
4.83k
        return afterLast;
1491
4.83k
    }
1492
1493
4.44k
    switch (*first) {
1494
4.20k
    case _UT('/'): {
1495
4.20k
        const URI_CHAR * const afterSegment =
1496
4.20k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1497
4.20k
        if (afterSegment == NULL) {
1498
3
            return NULL;
1499
3
        }
1500
4.19k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1501
4.19k
                                       memory)) { /* SEGMENT BOTH */
1502
0
            URI_FUNC(StopMalloc)(state, memory);
1503
0
            return NULL;
1504
0
        }
1505
4.19k
        return URI_FUNC(ParsePathAbsEmpty)(state, afterSegment, afterLast, memory);
1506
4.19k
    }
1507
1508
247
    default:
1509
247
        return first;
1510
4.44k
    }
1511
4.44k
}
UriParse.c:uriParsePathAbsEmptyW
Line
Count
Source
1488
8.80k
                                                    UriMemoryManager * memory) {
1489
8.80k
    if (first >= afterLast) {
1490
4.63k
        return afterLast;
1491
4.63k
    }
1492
1493
4.16k
    switch (*first) {
1494
3.50k
    case _UT('/'): {
1495
3.50k
        const URI_CHAR * const afterSegment =
1496
3.50k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1497
3.50k
        if (afterSegment == NULL) {
1498
4
            return NULL;
1499
4
        }
1500
3.49k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1501
3.49k
                                       memory)) { /* SEGMENT BOTH */
1502
0
            URI_FUNC(StopMalloc)(state, memory);
1503
0
            return NULL;
1504
0
        }
1505
3.49k
        return URI_FUNC(ParsePathAbsEmpty)(state, afterSegment, afterLast, memory);
1506
3.49k
    }
1507
1508
665
    default:
1509
665
        return first;
1510
4.16k
    }
1511
4.16k
}
1512
1513
/*
1514
 * [pathAbsNoLeadSlash]->[segmentNz][zeroMoreSlashSegs]
1515
 * [pathAbsNoLeadSlash]-><NULL>
1516
 */
1517
static URI_INLINE const URI_CHAR *
1518
URI_FUNC(ParsePathAbsNoLeadSlash)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
1519
3.12k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
1520
3.12k
    if (first >= afterLast) {
1521
0
        return afterLast;
1522
0
    }
1523
1524
3.12k
    switch (*first) {
1525
28
    case _UT('!'):
1526
67
    case _UT('$'):
1527
96
    case _UT('%'):
1528
131
    case _UT('&'):
1529
168
    case _UT('('):
1530
208
    case _UT(')'):
1531
264
    case _UT('-'):
1532
299
    case _UT('*'):
1533
328
    case _UT(','):
1534
473
    case _UT('.'):
1535
622
    case _UT(':'):
1536
674
    case _UT(';'):
1537
802
    case _UT('@'):
1538
853
    case _UT('\''):
1539
881
    case _UT('_'):
1540
911
    case _UT('~'):
1541
961
    case _UT('+'):
1542
1.00k
    case _UT('='):
1543
11.4k
    case URI_SET_DIGIT:
1544
114k
    case URI_SET_ALPHA: {
1545
114k
        const URI_CHAR * const afterSegmentNz =
1546
114k
            URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1547
114k
        if (afterSegmentNz == NULL) {
1548
41
            return NULL;
1549
41
        }
1550
2.95k
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1551
2.95k
                                       memory)) { /* SEGMENT BOTH */
1552
0
            URI_FUNC(StopMalloc)(state, memory);
1553
0
            return NULL;
1554
0
        }
1555
2.95k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1556
2.95k
    }
1557
1558
128
    default:
1559
128
        return first;
1560
3.12k
    }
1561
3.12k
}
UriParse.c:uriParsePathAbsNoLeadSlashA
Line
Count
Source
1519
1.42k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
1520
1.42k
    if (first >= afterLast) {
1521
0
        return afterLast;
1522
0
    }
1523
1524
1.42k
    switch (*first) {
1525
15
    case _UT('!'):
1526
33
    case _UT('$'):
1527
41
    case _UT('%'):
1528
57
    case _UT('&'):
1529
74
    case _UT('('):
1530
87
    case _UT(')'):
1531
111
    case _UT('-'):
1532
130
    case _UT('*'):
1533
139
    case _UT(','):
1534
205
    case _UT('.'):
1535
265
    case _UT(':'):
1536
291
    case _UT(';'):
1537
337
    case _UT('@'):
1538
367
    case _UT('\''):
1539
385
    case _UT('_'):
1540
404
    case _UT('~'):
1541
427
    case _UT('+'):
1542
453
    case _UT('='):
1543
5.10k
    case URI_SET_DIGIT:
1544
53.0k
    case URI_SET_ALPHA: {
1545
53.0k
        const URI_CHAR * const afterSegmentNz =
1546
53.0k
            URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1547
53.0k
        if (afterSegmentNz == NULL) {
1548
18
            return NULL;
1549
18
        }
1550
1.38k
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1551
1.38k
                                       memory)) { /* SEGMENT BOTH */
1552
0
            URI_FUNC(StopMalloc)(state, memory);
1553
0
            return NULL;
1554
0
        }
1555
1.38k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1556
1.38k
    }
1557
1558
26
    default:
1559
26
        return first;
1560
1.42k
    }
1561
1.42k
}
UriParse.c:uriParsePathAbsNoLeadSlashW
Line
Count
Source
1519
1.69k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
1520
1.69k
    if (first >= afterLast) {
1521
0
        return afterLast;
1522
0
    }
1523
1524
1.69k
    switch (*first) {
1525
13
    case _UT('!'):
1526
34
    case _UT('$'):
1527
55
    case _UT('%'):
1528
74
    case _UT('&'):
1529
94
    case _UT('('):
1530
121
    case _UT(')'):
1531
153
    case _UT('-'):
1532
169
    case _UT('*'):
1533
189
    case _UT(','):
1534
268
    case _UT('.'):
1535
357
    case _UT(':'):
1536
383
    case _UT(';'):
1537
465
    case _UT('@'):
1538
486
    case _UT('\''):
1539
496
    case _UT('_'):
1540
507
    case _UT('~'):
1541
534
    case _UT('+'):
1542
556
    case _UT('='):
1543
6.34k
    case URI_SET_DIGIT:
1544
61.7k
    case URI_SET_ALPHA: {
1545
61.7k
        const URI_CHAR * const afterSegmentNz =
1546
61.7k
            URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1547
61.7k
        if (afterSegmentNz == NULL) {
1548
23
            return NULL;
1549
23
        }
1550
1.56k
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1551
1.56k
                                       memory)) { /* SEGMENT BOTH */
1552
0
            URI_FUNC(StopMalloc)(state, memory);
1553
0
            return NULL;
1554
0
        }
1555
1.56k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1556
1.56k
    }
1557
1558
102
    default:
1559
102
        return first;
1560
1.69k
    }
1561
1.69k
}
1562
1563
/*
1564
 * [pathRootless]->[segmentNz][zeroMoreSlashSegs]
1565
 */
1566
static URI_INLINE const URI_CHAR *
1567
URI_FUNC(ParsePathRootless)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
1568
1.26k
                            const URI_CHAR * afterLast, UriMemoryManager * memory) {
1569
1.26k
    const URI_CHAR * const afterSegmentNz =
1570
1.26k
        URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1571
1.26k
    if (afterSegmentNz == NULL) {
1572
11
        return NULL;
1573
1.25k
    } else {
1574
1.25k
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1575
1.25k
                                       memory)) { /* SEGMENT BOTH */
1576
0
            URI_FUNC(StopMalloc)(state, memory);
1577
0
            return NULL;
1578
0
        }
1579
1.25k
    }
1580
1.25k
    return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1581
1.26k
}
UriParse.c:uriParsePathRootlessA
Line
Count
Source
1568
676
                            const URI_CHAR * afterLast, UriMemoryManager * memory) {
1569
676
    const URI_CHAR * const afterSegmentNz =
1570
676
        URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1571
676
    if (afterSegmentNz == NULL) {
1572
6
        return NULL;
1573
670
    } else {
1574
670
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1575
670
                                       memory)) { /* SEGMENT BOTH */
1576
0
            URI_FUNC(StopMalloc)(state, memory);
1577
0
            return NULL;
1578
0
        }
1579
670
    }
1580
670
    return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1581
676
}
UriParse.c:uriParsePathRootlessW
Line
Count
Source
1568
590
                            const URI_CHAR * afterLast, UriMemoryManager * memory) {
1569
590
    const URI_CHAR * const afterSegmentNz =
1570
590
        URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1571
590
    if (afterSegmentNz == NULL) {
1572
5
        return NULL;
1573
585
    } else {
1574
585
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1575
585
                                       memory)) { /* SEGMENT BOTH */
1576
0
            URI_FUNC(StopMalloc)(state, memory);
1577
0
            return NULL;
1578
0
        }
1579
585
    }
1580
585
    return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1581
590
}
1582
1583
/*
1584
 * [pchar]->[pctEncoded]
1585
 * [pchar]->[subDelims]
1586
 * [pchar]->[unreserved]
1587
 * [pchar]-><:>
1588
 * [pchar]-><@>
1589
 */
1590
static const URI_CHAR * URI_FUNC(ParsePchar)(URI_TYPE(ParserState) * state,
1591
                                             const URI_CHAR * first,
1592
                                             const URI_CHAR * afterLast,
1593
10.6M
                                             UriMemoryManager * memory) {
1594
10.6M
    if (first >= afterLast) {
1595
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1596
0
        return NULL;
1597
0
    }
1598
1599
10.6M
    switch (*first) {
1600
26.2k
    case _UT('%'):
1601
26.2k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1602
1603
6.39k
    case _UT(':'):
1604
9.40k
    case _UT('@'):
1605
15.1k
    case _UT('!'):
1606
18.6k
    case _UT('$'):
1607
21.1k
    case _UT('&'):
1608
24.0k
    case _UT('('):
1609
31.2k
    case _UT(')'):
1610
35.9k
    case _UT('*'):
1611
39.3k
    case _UT(','):
1612
43.4k
    case _UT(';'):
1613
49.5k
    case _UT('\''):
1614
57.6k
    case _UT('+'):
1615
64.6k
    case _UT('='):
1616
81.8k
    case _UT('-'):
1617
184k
    case _UT('.'):
1618
189k
    case _UT('_'):
1619
192k
    case _UT('~'):
1620
14.2M
    case URI_SET_DIGIT:
1621
14.2M
    case URI_SET_ALPHA:
1622
10.6M
        return first + 1;
1623
1624
0
    default:
1625
0
        URI_FUNC(StopSyntax)(state, first, memory);
1626
0
        return NULL;
1627
10.6M
    }
1628
10.6M
}
UriParse.c:uriParsePcharA
Line
Count
Source
1593
8.41M
                                             UriMemoryManager * memory) {
1594
8.41M
    if (first >= afterLast) {
1595
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1596
0
        return NULL;
1597
0
    }
1598
1599
8.41M
    switch (*first) {
1600
16.1k
    case _UT('%'):
1601
16.1k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1602
1603
3.08k
    case _UT(':'):
1604
4.89k
    case _UT('@'):
1605
9.66k
    case _UT('!'):
1606
12.2k
    case _UT('$'):
1607
13.4k
    case _UT('&'):
1608
15.4k
    case _UT('('):
1609
19.3k
    case _UT(')'):
1610
21.2k
    case _UT('*'):
1611
23.2k
    case _UT(','):
1612
26.2k
    case _UT(';'):
1613
28.4k
    case _UT('\''):
1614
34.9k
    case _UT('+'):
1615
40.9k
    case _UT('='):
1616
56.5k
    case _UT('-'):
1617
136k
    case _UT('.'):
1618
139k
    case _UT('_'):
1619
140k
    case _UT('~'):
1620
10.8M
    case URI_SET_DIGIT:
1621
10.8M
    case URI_SET_ALPHA:
1622
8.40M
        return first + 1;
1623
1624
0
    default:
1625
0
        URI_FUNC(StopSyntax)(state, first, memory);
1626
        return NULL;
1627
8.41M
    }
1628
8.41M
}
UriParse.c:uriParsePcharW
Line
Count
Source
1593
2.22M
                                             UriMemoryManager * memory) {
1594
2.22M
    if (first >= afterLast) {
1595
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1596
0
        return NULL;
1597
0
    }
1598
1599
2.22M
    switch (*first) {
1600
10.1k
    case _UT('%'):
1601
10.1k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1602
1603
3.31k
    case _UT(':'):
1604
4.50k
    case _UT('@'):
1605
5.50k
    case _UT('!'):
1606
6.43k
    case _UT('$'):
1607
7.74k
    case _UT('&'):
1608
8.60k
    case _UT('('):
1609
11.8k
    case _UT(')'):
1610
14.7k
    case _UT('*'):
1611
16.0k
    case _UT(','):
1612
17.1k
    case _UT(';'):
1613
21.1k
    case _UT('\''):
1614
22.6k
    case _UT('+'):
1615
23.6k
    case _UT('='):
1616
25.2k
    case _UT('-'):
1617
48.2k
    case _UT('.'):
1618
50.0k
    case _UT('_'):
1619
52.1k
    case _UT('~'):
1620
3.37M
    case URI_SET_DIGIT:
1621
3.37M
    case URI_SET_ALPHA:
1622
2.21M
        return first + 1;
1623
1624
0
    default:
1625
0
        URI_FUNC(StopSyntax)(state, first, memory);
1626
        return NULL;
1627
2.22M
    }
1628
2.22M
}
1629
1630
/*
1631
 * [pctEncoded]-><%>[HEXDIG][HEXDIG]
1632
 */
1633
static const URI_CHAR * URI_FUNC(ParsePctEncoded)(URI_TYPE(ParserState) * state,
1634
                                                  const URI_CHAR * first,
1635
                                                  const URI_CHAR * afterLast,
1636
79.1k
                                                  UriMemoryManager * memory) {
1637
79.1k
    if (first >= afterLast) {
1638
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1639
0
        return NULL;
1640
0
    }
1641
1642
    /*
1643
    First character has already been
1644
    checked before entering this rule.
1645
1646
    switch (*first) {
1647
    case _UT('%'):
1648
    */
1649
79.1k
    if (afterLast - first < 2) {
1650
280
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1651
280
        return NULL;
1652
280
    }
1653
1654
78.8k
    switch (first[1]) {
1655
1.08M
    case URI_SET_HEXDIG:
1656
1.08M
        if (afterLast - first < 3) {
1657
663
            URI_FUNC(StopSyntax)(state, afterLast, memory);
1658
663
            return NULL;
1659
663
        }
1660
1661
78.1k
        switch (first[2]) {
1662
78.0k
        case URI_SET_HEXDIG:
1663
78.0k
            return first + 3;
1664
1665
102
        default:
1666
102
            URI_FUNC(StopSyntax)(state, first + 2, memory);
1667
102
            return NULL;
1668
78.1k
        }
1669
1670
60
    default:
1671
60
        URI_FUNC(StopSyntax)(state, first + 1, memory);
1672
60
        return NULL;
1673
78.8k
    }
1674
1675
    /*
1676
    default:
1677
            URI_FUNC(StopSyntax)(state, first, memory);
1678
            return NULL;
1679
    }
1680
    */
1681
78.8k
}
UriParse.c:uriParsePctEncodedA
Line
Count
Source
1636
41.4k
                                                  UriMemoryManager * memory) {
1637
41.4k
    if (first >= afterLast) {
1638
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1639
0
        return NULL;
1640
0
    }
1641
1642
    /*
1643
    First character has already been
1644
    checked before entering this rule.
1645
1646
    switch (*first) {
1647
    case _UT('%'):
1648
    */
1649
41.4k
    if (afterLast - first < 2) {
1650
144
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1651
144
        return NULL;
1652
144
    }
1653
1654
41.3k
    switch (first[1]) {
1655
554k
    case URI_SET_HEXDIG:
1656
554k
        if (afterLast - first < 3) {
1657
326
            URI_FUNC(StopSyntax)(state, afterLast, memory);
1658
326
            return NULL;
1659
326
        }
1660
1661
40.9k
        switch (first[2]) {
1662
40.9k
        case URI_SET_HEXDIG:
1663
40.9k
            return first + 3;
1664
1665
48
        default:
1666
48
            URI_FUNC(StopSyntax)(state, first + 2, memory);
1667
48
            return NULL;
1668
40.9k
        }
1669
1670
33
    default:
1671
33
        URI_FUNC(StopSyntax)(state, first + 1, memory);
1672
33
        return NULL;
1673
41.3k
    }
1674
1675
    /*
1676
    default:
1677
            URI_FUNC(StopSyntax)(state, first, memory);
1678
            return NULL;
1679
    }
1680
    */
1681
41.3k
}
UriParse.c:uriParsePctEncodedW
Line
Count
Source
1636
37.7k
                                                  UriMemoryManager * memory) {
1637
37.7k
    if (first >= afterLast) {
1638
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1639
0
        return NULL;
1640
0
    }
1641
1642
    /*
1643
    First character has already been
1644
    checked before entering this rule.
1645
1646
    switch (*first) {
1647
    case _UT('%'):
1648
    */
1649
37.7k
    if (afterLast - first < 2) {
1650
136
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1651
136
        return NULL;
1652
136
    }
1653
1654
37.5k
    switch (first[1]) {
1655
528k
    case URI_SET_HEXDIG:
1656
528k
        if (afterLast - first < 3) {
1657
337
            URI_FUNC(StopSyntax)(state, afterLast, memory);
1658
337
            return NULL;
1659
337
        }
1660
1661
37.2k
        switch (first[2]) {
1662
37.1k
        case URI_SET_HEXDIG:
1663
37.1k
            return first + 3;
1664
1665
54
        default:
1666
54
            URI_FUNC(StopSyntax)(state, first + 2, memory);
1667
54
            return NULL;
1668
37.2k
        }
1669
1670
27
    default:
1671
27
        URI_FUNC(StopSyntax)(state, first + 1, memory);
1672
27
        return NULL;
1673
37.5k
    }
1674
1675
    /*
1676
    default:
1677
            URI_FUNC(StopSyntax)(state, first, memory);
1678
            return NULL;
1679
    }
1680
    */
1681
37.5k
}
1682
1683
/*
1684
 * [pctSubUnres]->[pctEncoded]
1685
 * [pctSubUnres]->[subDelims]
1686
 * [pctSubUnres]->[unreserved]
1687
 */
1688
static const URI_CHAR * URI_FUNC(ParsePctSubUnres)(URI_TYPE(ParserState) * state,
1689
                                                   const URI_CHAR * first,
1690
                                                   const URI_CHAR * afterLast,
1691
8.24M
                                                   UriMemoryManager * memory) {
1692
8.24M
    if (first >= afterLast) {
1693
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1694
0
        return NULL;
1695
0
    }
1696
1697
8.24M
    switch (*first) {
1698
18.5k
    case _UT('%'):
1699
18.5k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1700
1701
3.47k
    case _UT('!'):
1702
7.06k
    case _UT('$'):
1703
11.4k
    case _UT('&'):
1704
14.9k
    case _UT('('):
1705
25.7k
    case _UT(')'):
1706
32.7k
    case _UT('*'):
1707
36.3k
    case _UT(','):
1708
40.4k
    case _UT(';'):
1709
53.5k
    case _UT('\''):
1710
57.8k
    case _UT('+'):
1711
65.8k
    case _UT('='):
1712
85.3k
    case _UT('-'):
1713
138k
    case _UT('.'):
1714
143k
    case _UT('_'):
1715
148k
    case _UT('~'):
1716
7.77M
    case URI_SET_DIGIT:
1717
8.22M
    case URI_SET_ALPHA:
1718
8.22M
        return first + 1;
1719
1720
0
    default:
1721
0
        URI_FUNC(StopSyntax)(state, first, memory);
1722
0
        return NULL;
1723
8.24M
    }
1724
8.24M
}
UriParse.c:uriParsePctSubUnresA
Line
Count
Source
1691
6.67M
                                                   UriMemoryManager * memory) {
1692
6.67M
    if (first >= afterLast) {
1693
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1694
0
        return NULL;
1695
0
    }
1696
1697
6.67M
    switch (*first) {
1698
7.02k
    case _UT('%'):
1699
7.02k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1700
1701
2.10k
    case _UT('!'):
1702
4.18k
    case _UT('$'):
1703
6.70k
    case _UT('&'):
1704
8.81k
    case _UT('('):
1705
11.1k
    case _UT(')'):
1706
13.0k
    case _UT('*'):
1707
14.7k
    case _UT(','):
1708
17.1k
    case _UT(';'):
1709
20.5k
    case _UT('\''):
1710
22.4k
    case _UT('+'):
1711
29.0k
    case _UT('='):
1712
45.4k
    case _UT('-'):
1713
95.7k
    case _UT('.'):
1714
97.3k
    case _UT('_'):
1715
98.9k
    case _UT('~'):
1716
5.29M
    case URI_SET_DIGIT:
1717
6.66M
    case URI_SET_ALPHA:
1718
6.66M
        return first + 1;
1719
1720
0
    default:
1721
0
        URI_FUNC(StopSyntax)(state, first, memory);
1722
        return NULL;
1723
6.67M
    }
1724
6.67M
}
UriParse.c:uriParsePctSubUnresW
Line
Count
Source
1691
1.56M
                                                   UriMemoryManager * memory) {
1692
1.56M
    if (first >= afterLast) {
1693
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1694
0
        return NULL;
1695
0
    }
1696
1697
1.56M
    switch (*first) {
1698
11.5k
    case _UT('%'):
1699
11.5k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1700
1701
1.37k
    case _UT('!'):
1702
2.88k
    case _UT('$'):
1703
4.75k
    case _UT('&'):
1704
6.17k
    case _UT('('):
1705
14.6k
    case _UT(')'):
1706
19.6k
    case _UT('*'):
1707
21.5k
    case _UT(','):
1708
23.2k
    case _UT(';'):
1709
32.9k
    case _UT('\''):
1710
35.4k
    case _UT('+'):
1711
36.8k
    case _UT('='):
1712
39.8k
    case _UT('-'):
1713
43.1k
    case _UT('.'):
1714
46.1k
    case _UT('_'):
1715
49.6k
    case _UT('~'):
1716
2.48M
    case URI_SET_DIGIT:
1717
2.48M
    case URI_SET_ALPHA:
1718
1.55M
        return first + 1;
1719
1720
0
    default:
1721
0
        URI_FUNC(StopSyntax)(state, first, memory);
1722
        return NULL;
1723
1.56M
    }
1724
1.56M
}
1725
1726
/*
1727
 * [port]->[DIGIT][port]
1728
 * [port]-><NULL>
1729
 */
1730
static const URI_CHAR * URI_FUNC(ParsePort)(URI_TYPE(ParserState) * state,
1731
                                            const URI_CHAR * first,
1732
4.17M
                                            const URI_CHAR * afterLast) {
1733
4.17M
    if (first >= afterLast) {
1734
193
        return afterLast;
1735
193
    }
1736
1737
4.17M
    switch (*first) {
1738
4.17M
    case URI_SET_DIGIT:
1739
4.17M
        return URI_FUNC(ParsePort)(state, first + 1, afterLast);
1740
1741
371
    default:
1742
371
        return first;
1743
4.17M
    }
1744
4.17M
}
UriParse.c:uriParsePortA
Line
Count
Source
1732
4.17M
                                            const URI_CHAR * afterLast) {
1733
4.17M
    if (first >= afterLast) {
1734
114
        return afterLast;
1735
114
    }
1736
1737
4.17M
    switch (*first) {
1738
4.17M
    case URI_SET_DIGIT:
1739
4.17M
        return URI_FUNC(ParsePort)(state, first + 1, afterLast);
1740
1741
120
    default:
1742
120
        return first;
1743
4.17M
    }
1744
4.17M
}
UriParse.c:uriParsePortW
Line
Count
Source
1732
1.56k
                                            const URI_CHAR * afterLast) {
1733
1.56k
    if (first >= afterLast) {
1734
79
        return afterLast;
1735
79
    }
1736
1737
1.48k
    switch (*first) {
1738
1.23k
    case URI_SET_DIGIT:
1739
1.23k
        return URI_FUNC(ParsePort)(state, first + 1, afterLast);
1740
1741
251
    default:
1742
251
        return first;
1743
1.48k
    }
1744
1.48k
}
1745
1746
/*
1747
 * [queryFrag]->[pchar][queryFrag]
1748
 * [queryFrag]-></>[queryFrag]
1749
 * [queryFrag]-><?>[queryFrag]
1750
 * [queryFrag]-><NULL>
1751
 */
1752
static const URI_CHAR * URI_FUNC(ParseQueryFrag)(URI_TYPE(ParserState) * state,
1753
                                                 const URI_CHAR * first,
1754
                                                 const URI_CHAR * afterLast,
1755
8.19M
                                                 UriMemoryManager * memory) {
1756
8.19M
    if (first >= afterLast) {
1757
3.08k
        return afterLast;
1758
3.08k
    }
1759
1760
8.19M
    switch (*first) {
1761
4.51k
    case _UT('!'):
1762
6.64k
    case _UT('$'):
1763
19.3k
    case _UT('%'):
1764
20.6k
    case _UT('&'):
1765
22.0k
    case _UT('('):
1766
25.7k
    case _UT(')'):
1767
39.4k
    case _UT('-'):
1768
41.7k
    case _UT('*'):
1769
43.4k
    case _UT(','):
1770
98.1k
    case _UT('.'):
1771
99.2k
    case _UT(':'):
1772
101k
    case _UT(';'):
1773
102k
    case _UT('@'):
1774
105k
    case _UT('\''):
1775
108k
    case _UT('_'):
1776
110k
    case _UT('~'):
1777
114k
    case _UT('+'):
1778
116k
    case _UT('='):
1779
11.3M
    case URI_SET_DIGIT:
1780
245M
    case URI_SET_ALPHA: {
1781
245M
        const URI_CHAR * const afterPchar =
1782
245M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1783
245M
        if (afterPchar == NULL) {
1784
43
            return NULL;
1785
43
        }
1786
8.18M
        return URI_FUNC(ParseQueryFrag)(state, afterPchar, afterLast, memory);
1787
245M
    }
1788
1789
3.92k
    case _UT('/'):
1790
6.03k
    case _UT('?'):
1791
6.03k
        return URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
1792
1793
202
    default:
1794
202
        return first;
1795
8.19M
    }
1796
8.19M
}
UriParse.c:uriParseQueryFragA
Line
Count
Source
1755
6.93M
                                                 UriMemoryManager * memory) {
1756
6.93M
    if (first >= afterLast) {
1757
1.56k
        return afterLast;
1758
1.56k
    }
1759
1760
6.93M
    switch (*first) {
1761
4.08k
    case _UT('!'):
1762
5.77k
    case _UT('$'):
1763
13.5k
    case _UT('%'):
1764
14.2k
    case _UT('&'):
1765
15.2k
    case _UT('('):
1766
16.5k
    case _UT(')'):
1767
29.5k
    case _UT('-'):
1768
30.2k
    case _UT('*'):
1769
31.2k
    case _UT(','):
1770
84.3k
    case _UT('.'):
1771
84.9k
    case _UT(':'):
1772
86.4k
    case _UT(';'):
1773
87.1k
    case _UT('@'):
1774
88.1k
    case _UT('\''):
1775
89.9k
    case _UT('_'):
1776
90.6k
    case _UT('~'):
1777
93.7k
    case _UT('+'):
1778
95.7k
    case _UT('='):
1779
9.44M
    case URI_SET_DIGIT:
1780
212M
    case URI_SET_ALPHA: {
1781
212M
        const URI_CHAR * const afterPchar =
1782
212M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1783
212M
        if (afterPchar == NULL) {
1784
20
            return NULL;
1785
20
        }
1786
6.92M
        return URI_FUNC(ParseQueryFrag)(state, afterPchar, afterLast, memory);
1787
212M
    }
1788
1789
3.37k
    case _UT('/'):
1790
5.08k
    case _UT('?'):
1791
5.08k
        return URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
1792
1793
71
    default:
1794
71
        return first;
1795
6.93M
    }
1796
6.93M
}
UriParse.c:uriParseQueryFragW
Line
Count
Source
1755
1.26M
                                                 UriMemoryManager * memory) {
1756
1.26M
    if (first >= afterLast) {
1757
1.52k
        return afterLast;
1758
1.52k
    }
1759
1760
1.26M
    switch (*first) {
1761
432
    case _UT('!'):
1762
871
    case _UT('$'):
1763
5.73k
    case _UT('%'):
1764
6.41k
    case _UT('&'):
1765
6.82k
    case _UT('('):
1766
9.15k
    case _UT(')'):
1767
9.91k
    case _UT('-'):
1768
11.4k
    case _UT('*'):
1769
12.2k
    case _UT(','):
1770
13.7k
    case _UT('.'):
1771
14.2k
    case _UT(':'):
1772
14.6k
    case _UT(';'):
1773
15.0k
    case _UT('@'):
1774
17.8k
    case _UT('\''):
1775
18.8k
    case _UT('_'):
1776
19.9k
    case _UT('~'):
1777
20.6k
    case _UT('+'):
1778
21.1k
    case _UT('='):
1779
1.86M
    case URI_SET_DIGIT:
1780
33.3M
    case URI_SET_ALPHA: {
1781
33.3M
        const URI_CHAR * const afterPchar =
1782
33.3M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1783
33.3M
        if (afterPchar == NULL) {
1784
23
            return NULL;
1785
23
        }
1786
1.25M
        return URI_FUNC(ParseQueryFrag)(state, afterPchar, afterLast, memory);
1787
33.3M
    }
1788
1789
544
    case _UT('/'):
1790
958
    case _UT('?'):
1791
958
        return URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
1792
1793
131
    default:
1794
131
        return first;
1795
1.26M
    }
1796
1.26M
}
1797
1798
/*
1799
 * [segment]->[pchar][segment]
1800
 * [segment]-><NULL>
1801
 */
1802
static const URI_CHAR * URI_FUNC(ParseSegment)(URI_TYPE(ParserState) * state,
1803
                                               const URI_CHAR * first,
1804
                                               const URI_CHAR * afterLast,
1805
2.50M
                                               UriMemoryManager * memory) {
1806
2.50M
    if (first >= afterLast) {
1807
5.51k
        return afterLast;
1808
5.51k
    }
1809
1810
2.50M
    switch (*first) {
1811
1.20k
    case _UT('!'):
1812
2.52k
    case _UT('$'):
1813
16.0k
    case _UT('%'):
1814
17.1k
    case _UT('&'):
1815
18.6k
    case _UT('('):
1816
22.0k
    case _UT(')'):
1817
25.4k
    case _UT('-'):
1818
27.8k
    case _UT('*'):
1819
29.4k
    case _UT(','):
1820
77.4k
    case _UT('.'):
1821
82.5k
    case _UT(':'):
1822
84.6k
    case _UT(';'):
1823
86.4k
    case _UT('@'):
1824
88.7k
    case _UT('\''):
1825
90.3k
    case _UT('_'):
1826
91.9k
    case _UT('~'):
1827
96.0k
    case _UT('+'):
1828
100k
    case _UT('='):
1829
3.11M
    case URI_SET_DIGIT:
1830
73.6M
    case URI_SET_ALPHA: {
1831
73.6M
        const URI_CHAR * const afterPchar =
1832
73.6M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1833
73.6M
        if (afterPchar == NULL) {
1834
84
            return NULL;
1835
84
        }
1836
2.44M
        return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1837
73.6M
    }
1838
1839
51.5k
    default:
1840
51.5k
        return first;
1841
2.50M
    }
1842
2.50M
}
UriParse.c:uriParseSegmentA
Line
Count
Source
1805
1.51M
                                               UriMemoryManager * memory) {
1806
1.51M
    if (first >= afterLast) {
1807
2.80k
        return afterLast;
1808
2.80k
    }
1809
1810
1.51M
    switch (*first) {
1811
665
    case _UT('!'):
1812
1.52k
    case _UT('$'):
1813
9.82k
    case _UT('%'):
1814
10.3k
    case _UT('&'):
1815
11.4k
    case _UT('('):
1816
13.8k
    case _UT(')'):
1817
16.5k
    case _UT('-'):
1818
17.6k
    case _UT('*'):
1819
18.6k
    case _UT(','):
1820
45.3k
    case _UT('.'):
1821
47.7k
    case _UT(':'):
1822
49.1k
    case _UT(';'):
1823
50.2k
    case _UT('@'):
1824
51.4k
    case _UT('\''):
1825
52.2k
    case _UT('_'):
1826
52.7k
    case _UT('~'):
1827
56.1k
    case _UT('+'):
1828
60.0k
    case _UT('='):
1829
1.51M
    case URI_SET_DIGIT:
1830
47.7M
    case URI_SET_ALPHA: {
1831
47.7M
        const URI_CHAR * const afterPchar =
1832
47.7M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1833
47.7M
        if (afterPchar == NULL) {
1834
38
            return NULL;
1835
38
        }
1836
1.48M
        return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1837
47.7M
    }
1838
1839
26.1k
    default:
1840
26.1k
        return first;
1841
1.51M
    }
1842
1.51M
}
UriParse.c:uriParseSegmentW
Line
Count
Source
1805
989k
                                               UriMemoryManager * memory) {
1806
989k
    if (first >= afterLast) {
1807
2.71k
        return afterLast;
1808
2.71k
    }
1809
1810
986k
    switch (*first) {
1811
542
    case _UT('!'):
1812
1.00k
    case _UT('$'):
1813
6.22k
    case _UT('%'):
1814
6.82k
    case _UT('&'):
1815
7.24k
    case _UT('('):
1816
8.17k
    case _UT(')'):
1817
8.94k
    case _UT('-'):
1818
10.1k
    case _UT('*'):
1819
10.7k
    case _UT(','):
1820
32.1k
    case _UT('.'):
1821
34.8k
    case _UT(':'):
1822
35.5k
    case _UT(';'):
1823
36.2k
    case _UT('@'):
1824
37.3k
    case _UT('\''):
1825
38.1k
    case _UT('_'):
1826
39.1k
    case _UT('~'):
1827
39.9k
    case _UT('+'):
1828
40.3k
    case _UT('='):
1829
1.59M
    case URI_SET_DIGIT:
1830
25.8M
    case URI_SET_ALPHA: {
1831
25.8M
        const URI_CHAR * const afterPchar =
1832
25.8M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1833
25.8M
        if (afterPchar == NULL) {
1834
46
            return NULL;
1835
46
        }
1836
961k
        return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1837
25.8M
    }
1838
1839
25.4k
    default:
1840
25.4k
        return first;
1841
986k
    }
1842
986k
}
1843
1844
/*
1845
 * [segmentNz]->[pchar][segment]
1846
 */
1847
static URI_INLINE const URI_CHAR * URI_FUNC(ParseSegmentNz)(URI_TYPE(ParserState) * state,
1848
                                                            const URI_CHAR * first,
1849
                                                            const URI_CHAR * afterLast,
1850
4.26k
                                                            UriMemoryManager * memory) {
1851
4.26k
    const URI_CHAR * const afterPchar =
1852
4.26k
        URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1853
4.26k
    if (afterPchar == NULL) {
1854
14
        return NULL;
1855
14
    }
1856
4.24k
    return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1857
4.26k
}
UriParse.c:uriParseSegmentNzA
Line
Count
Source
1850
2.07k
                                                            UriMemoryManager * memory) {
1851
2.07k
    const URI_CHAR * const afterPchar =
1852
2.07k
        URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1853
2.07k
    if (afterPchar == NULL) {
1854
8
        return NULL;
1855
8
    }
1856
2.07k
    return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1857
2.07k
}
UriParse.c:uriParseSegmentNzW
Line
Count
Source
1850
2.18k
                                                            UriMemoryManager * memory) {
1851
2.18k
    const URI_CHAR * const afterPchar =
1852
2.18k
        URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1853
2.18k
    if (afterPchar == NULL) {
1854
6
        return NULL;
1855
6
    }
1856
2.17k
    return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1857
2.18k
}
1858
1859
static URI_INLINE UriBool URI_FUNC(OnExitSegmentNzNcOrScheme2)(
1860
3.65k
    URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory) {
1861
3.65k
    if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1862
3.65k
                                   memory)) { /* SEGMENT BOTH */
1863
0
        return URI_FALSE; /* Raises malloc error*/
1864
0
    }
1865
3.65k
    state->uri->scheme.first = NULL; /* Not a scheme, reset */
1866
3.65k
    return URI_TRUE; /* Success */
1867
3.65k
}
UriParse.c:uriOnExitSegmentNzNcOrScheme2A
Line
Count
Source
1860
1.99k
    URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory) {
1861
1.99k
    if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1862
1.99k
                                   memory)) { /* SEGMENT BOTH */
1863
0
        return URI_FALSE; /* Raises malloc error*/
1864
0
    }
1865
1.99k
    state->uri->scheme.first = NULL; /* Not a scheme, reset */
1866
1.99k
    return URI_TRUE; /* Success */
1867
1.99k
}
UriParse.c:uriOnExitSegmentNzNcOrScheme2W
Line
Count
Source
1860
1.66k
    URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory) {
1861
1.66k
    if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1862
1.66k
                                   memory)) { /* SEGMENT BOTH */
1863
0
        return URI_FALSE; /* Raises malloc error*/
1864
0
    }
1865
1.66k
    state->uri->scheme.first = NULL; /* Not a scheme, reset */
1866
1.66k
    return URI_TRUE; /* Success */
1867
1.66k
}
1868
1869
/*
1870
 * [segmentNzNcOrScheme2]->[ALPHA][segmentNzNcOrScheme2]
1871
 * [segmentNzNcOrScheme2]->[DIGIT][segmentNzNcOrScheme2]
1872
 * [segmentNzNcOrScheme2]->[pctEncoded][mustBeSegmentNzNc]
1873
 * [segmentNzNcOrScheme2]->[uriTail] // can take <NULL>
1874
 * [segmentNzNcOrScheme2]-><!>[mustBeSegmentNzNc]
1875
 * [segmentNzNcOrScheme2]-><$>[mustBeSegmentNzNc]
1876
 * [segmentNzNcOrScheme2]-><&>[mustBeSegmentNzNc]
1877
 * [segmentNzNcOrScheme2]-><(>[mustBeSegmentNzNc]
1878
 * [segmentNzNcOrScheme2]-><)>[mustBeSegmentNzNc]
1879
 * [segmentNzNcOrScheme2]-><*>[mustBeSegmentNzNc]
1880
 * [segmentNzNcOrScheme2]-><,>[mustBeSegmentNzNc]
1881
 * [segmentNzNcOrScheme2]-><.>[segmentNzNcOrScheme2]
1882
 * [segmentNzNcOrScheme2]-></>[segment][zeroMoreSlashSegs][uriTail]
1883
 * [segmentNzNcOrScheme2]-><:>[hierPart][uriTail]
1884
 * [segmentNzNcOrScheme2]-><;>[mustBeSegmentNzNc]
1885
 * [segmentNzNcOrScheme2]-><@>[mustBeSegmentNzNc]
1886
 * [segmentNzNcOrScheme2]-><_>[mustBeSegmentNzNc]
1887
 * [segmentNzNcOrScheme2]-><~>[mustBeSegmentNzNc]
1888
 * [segmentNzNcOrScheme2]-><+>[segmentNzNcOrScheme2]
1889
 * [segmentNzNcOrScheme2]-><=>[mustBeSegmentNzNc]
1890
 * [segmentNzNcOrScheme2]-><'>[mustBeSegmentNzNc]
1891
 * [segmentNzNcOrScheme2]-><->[segmentNzNcOrScheme2]
1892
 */
1893
static const URI_CHAR * URI_FUNC(ParseSegmentNzNcOrScheme2)(URI_TYPE(ParserState) * state,
1894
                                                            const URI_CHAR * first,
1895
                                                            const URI_CHAR * afterLast,
1896
3.45M
                                                            UriMemoryManager * memory) {
1897
3.45M
    if (first >= afterLast) {
1898
3.52k
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1899
0
            URI_FUNC(StopMalloc)(state, memory);
1900
0
            return NULL;
1901
0
        }
1902
3.52k
        return afterLast;
1903
3.52k
    }
1904
1905
3.44M
    switch (*first) {
1906
7.49k
    case _UT('.'):
1907
8.67k
    case _UT('+'):
1908
11.1k
    case _UT('-'):
1909
49.1M
    case URI_SET_ALPHA:
1910
49.1M
    case URI_SET_DIGIT:
1911
3.44M
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
1912
1913
97
    case _UT('%'): {
1914
97
        const URI_CHAR * const afterPctEncoded =
1915
97
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1916
97
        if (afterPctEncoded == NULL) {
1917
9
            return NULL;
1918
9
        }
1919
88
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
1920
88
                                                memory);
1921
97
    }
1922
1923
29
    case _UT('!'):
1924
46
    case _UT('$'):
1925
63
    case _UT('&'):
1926
77
    case _UT('('):
1927
95
    case _UT(')'):
1928
116
    case _UT('*'):
1929
134
    case _UT(','):
1930
155
    case _UT(';'):
1931
182
    case _UT('@'):
1932
200
    case _UT('_'):
1933
217
    case _UT('~'):
1934
248
    case _UT('='):
1935
263
    case _UT('\''):
1936
263
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1937
1938
571
    case _UT('/'): {
1939
571
        const URI_CHAR * afterZeroMoreSlashSegs;
1940
571
        const URI_CHAR * const afterSegment =
1941
571
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1942
571
        if (afterSegment == NULL) {
1943
7
            return NULL;
1944
7
        }
1945
564
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1946
564
                                       memory)) { /* SEGMENT BOTH */
1947
0
            URI_FUNC(StopMalloc)(state, memory);
1948
0
            return NULL;
1949
0
        }
1950
564
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1951
564
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1952
564
                                       memory)) { /* SEGMENT BOTH */
1953
0
            URI_FUNC(StopMalloc)(state, memory);
1954
0
            return NULL;
1955
0
        }
1956
564
        afterZeroMoreSlashSegs =
1957
564
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1958
564
        if (afterZeroMoreSlashSegs == NULL) {
1959
9
            return NULL;
1960
9
        }
1961
555
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1962
564
    }
1963
1964
2.03k
    case _UT(':'): {
1965
2.03k
        const URI_CHAR * const afterHierPart =
1966
2.03k
            URI_FUNC(ParseHierPart)(state, first + 1, afterLast, memory);
1967
2.03k
        state->uri->scheme.afterLast = first; /* SCHEME END */
1968
2.03k
        if (afterHierPart == NULL) {
1969
23
            return NULL;
1970
23
        }
1971
2.01k
        return URI_FUNC(ParseUriTail)(state, afterHierPart, afterLast, memory);
1972
2.03k
    }
1973
1974
136
    default:
1975
136
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1976
0
            URI_FUNC(StopMalloc)(state, memory);
1977
0
            return NULL;
1978
0
        }
1979
136
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1980
3.44M
    }
1981
3.44M
}
UriParse.c:uriParseSegmentNzNcOrScheme2A
Line
Count
Source
1896
2.11M
                                                            UriMemoryManager * memory) {
1897
2.11M
    if (first >= afterLast) {
1898
1.91k
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1899
0
            URI_FUNC(StopMalloc)(state, memory);
1900
0
            return NULL;
1901
0
        }
1902
1.91k
        return afterLast;
1903
1.91k
    }
1904
1905
2.11M
    switch (*first) {
1906
5.77k
    case _UT('.'):
1907
6.42k
    case _UT('+'):
1908
8.05k
    case _UT('-'):
1909
33.1M
    case URI_SET_ALPHA:
1910
33.1M
    case URI_SET_DIGIT:
1911
2.11M
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
1912
1913
52
    case _UT('%'): {
1914
52
        const URI_CHAR * const afterPctEncoded =
1915
52
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1916
52
        if (afterPctEncoded == NULL) {
1917
7
            return NULL;
1918
7
        }
1919
45
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
1920
45
                                                memory);
1921
52
    }
1922
1923
22
    case _UT('!'):
1924
31
    case _UT('$'):
1925
40
    case _UT('&'):
1926
49
    case _UT('('):
1927
58
    case _UT(')'):
1928
71
    case _UT('*'):
1929
81
    case _UT(','):
1930
95
    case _UT(';'):
1931
114
    case _UT('@'):
1932
122
    case _UT('_'):
1933
134
    case _UT('~'):
1934
160
    case _UT('='):
1935
169
    case _UT('\''):
1936
169
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1937
1938
301
    case _UT('/'): {
1939
301
        const URI_CHAR * afterZeroMoreSlashSegs;
1940
301
        const URI_CHAR * const afterSegment =
1941
301
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1942
301
        if (afterSegment == NULL) {
1943
4
            return NULL;
1944
4
        }
1945
297
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1946
297
                                       memory)) { /* SEGMENT BOTH */
1947
0
            URI_FUNC(StopMalloc)(state, memory);
1948
0
            return NULL;
1949
0
        }
1950
297
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1951
297
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1952
297
                                       memory)) { /* SEGMENT BOTH */
1953
0
            URI_FUNC(StopMalloc)(state, memory);
1954
0
            return NULL;
1955
0
        }
1956
297
        afterZeroMoreSlashSegs =
1957
297
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1958
297
        if (afterZeroMoreSlashSegs == NULL) {
1959
3
            return NULL;
1960
3
        }
1961
294
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1962
297
    }
1963
1964
1.05k
    case _UT(':'): {
1965
1.05k
        const URI_CHAR * const afterHierPart =
1966
1.05k
            URI_FUNC(ParseHierPart)(state, first + 1, afterLast, memory);
1967
1.05k
        state->uri->scheme.afterLast = first; /* SCHEME END */
1968
1.05k
        if (afterHierPart == NULL) {
1969
11
            return NULL;
1970
11
        }
1971
1.04k
        return URI_FUNC(ParseUriTail)(state, afterHierPart, afterLast, memory);
1972
1.05k
    }
1973
1974
78
    default:
1975
78
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1976
0
            URI_FUNC(StopMalloc)(state, memory);
1977
0
            return NULL;
1978
0
        }
1979
78
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1980
2.11M
    }
1981
2.11M
}
UriParse.c:uriParseSegmentNzNcOrScheme2W
Line
Count
Source
1896
1.33M
                                                            UriMemoryManager * memory) {
1897
1.33M
    if (first >= afterLast) {
1898
1.61k
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1899
0
            URI_FUNC(StopMalloc)(state, memory);
1900
0
            return NULL;
1901
0
        }
1902
1.61k
        return afterLast;
1903
1.61k
    }
1904
1905
1.33M
    switch (*first) {
1906
1.71k
    case _UT('.'):
1907
2.24k
    case _UT('+'):
1908
3.04k
    case _UT('-'):
1909
16.0M
    case URI_SET_ALPHA:
1910
16.0M
    case URI_SET_DIGIT:
1911
1.32M
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
1912
1913
45
    case _UT('%'): {
1914
45
        const URI_CHAR * const afterPctEncoded =
1915
45
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1916
45
        if (afterPctEncoded == NULL) {
1917
2
            return NULL;
1918
2
        }
1919
43
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
1920
43
                                                memory);
1921
45
    }
1922
1923
7
    case _UT('!'):
1924
15
    case _UT('$'):
1925
23
    case _UT('&'):
1926
28
    case _UT('('):
1927
37
    case _UT(')'):
1928
45
    case _UT('*'):
1929
53
    case _UT(','):
1930
60
    case _UT(';'):
1931
68
    case _UT('@'):
1932
78
    case _UT('_'):
1933
83
    case _UT('~'):
1934
88
    case _UT('='):
1935
94
    case _UT('\''):
1936
94
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1937
1938
270
    case _UT('/'): {
1939
270
        const URI_CHAR * afterZeroMoreSlashSegs;
1940
270
        const URI_CHAR * const afterSegment =
1941
270
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1942
270
        if (afterSegment == NULL) {
1943
3
            return NULL;
1944
3
        }
1945
267
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1946
267
                                       memory)) { /* SEGMENT BOTH */
1947
0
            URI_FUNC(StopMalloc)(state, memory);
1948
0
            return NULL;
1949
0
        }
1950
267
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1951
267
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1952
267
                                       memory)) { /* SEGMENT BOTH */
1953
0
            URI_FUNC(StopMalloc)(state, memory);
1954
0
            return NULL;
1955
0
        }
1956
267
        afterZeroMoreSlashSegs =
1957
267
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1958
267
        if (afterZeroMoreSlashSegs == NULL) {
1959
6
            return NULL;
1960
6
        }
1961
261
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1962
267
    }
1963
1964
977
    case _UT(':'): {
1965
977
        const URI_CHAR * const afterHierPart =
1966
977
            URI_FUNC(ParseHierPart)(state, first + 1, afterLast, memory);
1967
977
        state->uri->scheme.afterLast = first; /* SCHEME END */
1968
977
        if (afterHierPart == NULL) {
1969
12
            return NULL;
1970
12
        }
1971
965
        return URI_FUNC(ParseUriTail)(state, afterHierPart, afterLast, memory);
1972
977
    }
1973
1974
58
    default:
1975
58
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1976
0
            URI_FUNC(StopMalloc)(state, memory);
1977
0
            return NULL;
1978
0
        }
1979
58
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1980
1.33M
    }
1981
1.33M
}
1982
1983
/*
1984
 * [uriReference]->[ALPHA][segmentNzNcOrScheme2]
1985
 * [uriReference]->[DIGIT][mustBeSegmentNzNc]
1986
 * [uriReference]->[pctEncoded][mustBeSegmentNzNc]
1987
 * [uriReference]->[subDelims][mustBeSegmentNzNc]
1988
 * [uriReference]->[uriTail] // can take <NULL>
1989
 * [uriReference]-><.>[mustBeSegmentNzNc]
1990
 * [uriReference]-></>[partHelperTwo][uriTail]
1991
 * [uriReference]-><@>[mustBeSegmentNzNc]
1992
 * [uriReference]-><_>[mustBeSegmentNzNc]
1993
 * [uriReference]-><~>[mustBeSegmentNzNc]
1994
 * [uriReference]-><->[mustBeSegmentNzNc]
1995
 */
1996
static const URI_CHAR * URI_FUNC(ParseUriReference)(URI_TYPE(ParserState) * state,
1997
                                                    const URI_CHAR * first,
1998
                                                    const URI_CHAR * afterLast,
1999
55.9k
                                                    UriMemoryManager * memory) {
2000
55.9k
    if (first >= afterLast) {
2001
16.1k
        return afterLast;
2002
16.1k
    }
2003
2004
39.7k
    switch (*first) {
2005
6.62k
    case URI_SET_ALPHA:
2006
6.62k
        state->uri->scheme.first = first; /* SCHEME BEGIN */
2007
6.62k
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
2008
2009
13.7k
    case URI_SET_DIGIT:
2010
13.7k
    case _UT('!'):
2011
2.37k
    case _UT('$'):
2012
2.51k
    case _UT('&'):
2013
2.65k
    case _UT('('):
2014
2.79k
    case _UT(')'):
2015
2.91k
    case _UT('*'):
2016
3.04k
    case _UT(','):
2017
3.20k
    case _UT(';'):
2018
3.39k
    case _UT('\''):
2019
3.57k
    case _UT('+'):
2020
3.70k
    case _UT('='):
2021
4.22k
    case _UT('.'):
2022
4.30k
    case _UT('_'):
2023
4.45k
    case _UT('~'):
2024
4.62k
    case _UT('-'):
2025
4.85k
    case _UT('@'):
2026
4.85k
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2027
4.85k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
2028
2029
1.73k
    case _UT('%'): {
2030
1.73k
        const URI_CHAR * const afterPctEncoded =
2031
1.73k
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
2032
1.73k
        if (afterPctEncoded == NULL) {
2033
194
            return NULL;
2034
194
        }
2035
1.54k
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2036
1.54k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
2037
1.54k
                                                memory);
2038
1.73k
    }
2039
2040
22.9k
    case _UT('/'): {
2041
22.9k
        const URI_CHAR * const afterPartHelperTwo =
2042
22.9k
            URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
2043
22.9k
        if (afterPartHelperTwo == NULL) {
2044
9.79k
            return NULL;
2045
9.79k
        }
2046
13.1k
        return URI_FUNC(ParseUriTail)(state, afterPartHelperTwo, afterLast, memory);
2047
22.9k
    }
2048
2049
3.64k
    default:
2050
3.64k
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
2051
39.7k
    }
2052
39.7k
}
UriParse.c:uriParseUriReferenceA
Line
Count
Source
1999
27.1k
                                                    UriMemoryManager * memory) {
2000
27.1k
    if (first >= afterLast) {
2001
7.44k
        return afterLast;
2002
7.44k
    }
2003
2004
19.7k
    switch (*first) {
2005
3.56k
    case URI_SET_ALPHA:
2006
3.56k
        state->uri->scheme.first = first; /* SCHEME BEGIN */
2007
3.56k
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
2008
2009
6.45k
    case URI_SET_DIGIT:
2010
6.45k
    case _UT('!'):
2011
1.14k
    case _UT('$'):
2012
1.21k
    case _UT('&'):
2013
1.28k
    case _UT('('):
2014
1.36k
    case _UT(')'):
2015
1.42k
    case _UT('*'):
2016
1.49k
    case _UT(','):
2017
1.57k
    case _UT(';'):
2018
1.65k
    case _UT('\''):
2019
1.74k
    case _UT('+'):
2020
1.81k
    case _UT('='):
2021
2.04k
    case _UT('.'):
2022
2.09k
    case _UT('_'):
2023
2.19k
    case _UT('~'):
2024
2.28k
    case _UT('-'):
2025
2.41k
    case _UT('@'):
2026
2.41k
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2027
2.41k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
2028
2029
925
    case _UT('%'): {
2030
925
        const URI_CHAR * const afterPctEncoded =
2031
925
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
2032
925
        if (afterPctEncoded == NULL) {
2033
101
            return NULL;
2034
101
        }
2035
824
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2036
824
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
2037
824
                                                memory);
2038
925
    }
2039
2040
11.1k
    case _UT('/'): {
2041
11.1k
        const URI_CHAR * const afterPartHelperTwo =
2042
11.1k
            URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
2043
11.1k
        if (afterPartHelperTwo == NULL) {
2044
4.79k
            return NULL;
2045
4.79k
        }
2046
6.34k
        return URI_FUNC(ParseUriTail)(state, afterPartHelperTwo, afterLast, memory);
2047
11.1k
    }
2048
2049
1.67k
    default:
2050
1.67k
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
2051
19.7k
    }
2052
19.7k
}
UriParse.c:uriParseUriReferenceW
Line
Count
Source
1999
28.7k
                                                    UriMemoryManager * memory) {
2000
28.7k
    if (first >= afterLast) {
2001
8.67k
        return afterLast;
2002
8.67k
    }
2003
2004
20.0k
    switch (*first) {
2005
3.05k
    case URI_SET_ALPHA:
2006
3.05k
        state->uri->scheme.first = first; /* SCHEME BEGIN */
2007
3.05k
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
2008
2009
7.31k
    case URI_SET_DIGIT:
2010
7.31k
    case _UT('!'):
2011
1.23k
    case _UT('$'):
2012
1.29k
    case _UT('&'):
2013
1.36k
    case _UT('('):
2014
1.42k
    case _UT(')'):
2015
1.49k
    case _UT('*'):
2016
1.55k
    case _UT(','):
2017
1.63k
    case _UT(';'):
2018
1.73k
    case _UT('\''):
2019
1.83k
    case _UT('+'):
2020
1.89k
    case _UT('='):
2021
2.17k
    case _UT('.'):
2022
2.21k
    case _UT('_'):
2023
2.25k
    case _UT('~'):
2024
2.34k
    case _UT('-'):
2025
2.44k
    case _UT('@'):
2026
2.44k
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2027
2.44k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
2028
2029
813
    case _UT('%'): {
2030
813
        const URI_CHAR * const afterPctEncoded =
2031
813
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
2032
813
        if (afterPctEncoded == NULL) {
2033
93
            return NULL;
2034
93
        }
2035
720
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2036
720
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
2037
720
                                                memory);
2038
813
    }
2039
2040
11.7k
    case _UT('/'): {
2041
11.7k
        const URI_CHAR * const afterPartHelperTwo =
2042
11.7k
            URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
2043
11.7k
        if (afterPartHelperTwo == NULL) {
2044
4.99k
            return NULL;
2045
4.99k
        }
2046
6.78k
        return URI_FUNC(ParseUriTail)(state, afterPartHelperTwo, afterLast, memory);
2047
11.7k
    }
2048
2049
1.96k
    default:
2050
1.96k
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
2051
20.0k
    }
2052
20.0k
}
2053
2054
/*
2055
 * [uriTail]-><#>[queryFrag]
2056
 * [uriTail]-><?>[queryFrag][uriTailTwo]
2057
 * [uriTail]-><NULL>
2058
 */
2059
static URI_INLINE const URI_CHAR * URI_FUNC(ParseUriTail)(URI_TYPE(ParserState) * state,
2060
                                                          const URI_CHAR * first,
2061
                                                          const URI_CHAR * afterLast,
2062
20.7k
                                                          UriMemoryManager * memory) {
2063
20.7k
    if (first >= afterLast) {
2064
15.0k
        return afterLast;
2065
15.0k
    }
2066
2067
5.71k
    switch (*first) {
2068
1.24k
    case _UT('#'): {
2069
1.24k
        const URI_CHAR * const afterQueryFrag =
2070
1.24k
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2071
1.24k
        if (afterQueryFrag == NULL) {
2072
10
            return NULL;
2073
10
        }
2074
1.23k
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2075
1.23k
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2076
1.23k
        return afterQueryFrag;
2077
1.24k
    }
2078
2079
2.04k
    case _UT('?'): {
2080
2.04k
        const URI_CHAR * const afterQueryFrag =
2081
2.04k
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2082
2.04k
        if (afterQueryFrag == NULL) {
2083
29
            return NULL;
2084
29
        }
2085
2.01k
        state->uri->query.first = first + 1; /* QUERY BEGIN */
2086
2.01k
        state->uri->query.afterLast = afterQueryFrag; /* QUERY END */
2087
2.01k
        return URI_FUNC(ParseUriTailTwo)(state, afterQueryFrag, afterLast, memory);
2088
2.04k
    }
2089
2090
2.42k
    default:
2091
2.42k
        return first;
2092
5.71k
    }
2093
5.71k
}
UriParse.c:uriParseUriTailA
Line
Count
Source
2062
9.94k
                                                          UriMemoryManager * memory) {
2063
9.94k
    if (first >= afterLast) {
2064
7.63k
        return afterLast;
2065
7.63k
    }
2066
2067
2.31k
    switch (*first) {
2068
659
    case _UT('#'): {
2069
659
        const URI_CHAR * const afterQueryFrag =
2070
659
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2071
659
        if (afterQueryFrag == NULL) {
2072
6
            return NULL;
2073
6
        }
2074
653
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2075
653
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2076
653
        return afterQueryFrag;
2077
659
    }
2078
2079
975
    case _UT('?'): {
2080
975
        const URI_CHAR * const afterQueryFrag =
2081
975
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2082
975
        if (afterQueryFrag == NULL) {
2083
12
            return NULL;
2084
12
        }
2085
963
        state->uri->query.first = first + 1; /* QUERY BEGIN */
2086
963
        state->uri->query.afterLast = afterQueryFrag; /* QUERY END */
2087
963
        return URI_FUNC(ParseUriTailTwo)(state, afterQueryFrag, afterLast, memory);
2088
975
    }
2089
2090
676
    default:
2091
676
        return first;
2092
2.31k
    }
2093
2.31k
}
UriParse.c:uriParseUriTailW
Line
Count
Source
2062
10.7k
                                                          UriMemoryManager * memory) {
2063
10.7k
    if (first >= afterLast) {
2064
7.36k
        return afterLast;
2065
7.36k
    }
2066
2067
3.40k
    switch (*first) {
2068
588
    case _UT('#'): {
2069
588
        const URI_CHAR * const afterQueryFrag =
2070
588
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2071
588
        if (afterQueryFrag == NULL) {
2072
4
            return NULL;
2073
4
        }
2074
584
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2075
584
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2076
584
        return afterQueryFrag;
2077
588
    }
2078
2079
1.06k
    case _UT('?'): {
2080
1.06k
        const URI_CHAR * const afterQueryFrag =
2081
1.06k
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2082
1.06k
        if (afterQueryFrag == NULL) {
2083
17
            return NULL;
2084
17
        }
2085
1.05k
        state->uri->query.first = first + 1; /* QUERY BEGIN */
2086
1.05k
        state->uri->query.afterLast = afterQueryFrag; /* QUERY END */
2087
1.05k
        return URI_FUNC(ParseUriTailTwo)(state, afterQueryFrag, afterLast, memory);
2088
1.06k
    }
2089
2090
1.75k
    default:
2091
1.75k
        return first;
2092
3.40k
    }
2093
3.40k
}
2094
2095
/*
2096
 * [uriTailTwo]-><#>[queryFrag]
2097
 * [uriTailTwo]-><NULL>
2098
 */
2099
static URI_INLINE const URI_CHAR *
2100
URI_FUNC(ParseUriTailTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
2101
2.01k
                          const URI_CHAR * afterLast, UriMemoryManager * memory) {
2102
2.01k
    if (first >= afterLast) {
2103
1.84k
        return afterLast;
2104
1.84k
    }
2105
2106
173
    switch (*first) {
2107
38
    case _UT('#'): {
2108
38
        const URI_CHAR * const afterQueryFrag =
2109
38
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2110
38
        if (afterQueryFrag == NULL) {
2111
4
            return NULL;
2112
4
        }
2113
34
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2114
34
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2115
34
        return afterQueryFrag;
2116
38
    }
2117
2118
135
    default:
2119
135
        return first;
2120
173
    }
2121
173
}
UriParse.c:uriParseUriTailTwoA
Line
Count
Source
2101
963
                          const URI_CHAR * afterLast, UriMemoryManager * memory) {
2102
963
    if (first >= afterLast) {
2103
910
        return afterLast;
2104
910
    }
2105
2106
53
    switch (*first) {
2107
20
    case _UT('#'): {
2108
20
        const URI_CHAR * const afterQueryFrag =
2109
20
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2110
20
        if (afterQueryFrag == NULL) {
2111
2
            return NULL;
2112
2
        }
2113
18
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2114
18
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2115
18
        return afterQueryFrag;
2116
20
    }
2117
2118
33
    default:
2119
33
        return first;
2120
53
    }
2121
53
}
UriParse.c:uriParseUriTailTwoW
Line
Count
Source
2101
1.05k
                          const URI_CHAR * afterLast, UriMemoryManager * memory) {
2102
1.05k
    if (first >= afterLast) {
2103
932
        return afterLast;
2104
932
    }
2105
2106
120
    switch (*first) {
2107
18
    case _UT('#'): {
2108
18
        const URI_CHAR * const afterQueryFrag =
2109
18
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2110
18
        if (afterQueryFrag == NULL) {
2111
2
            return NULL;
2112
2
        }
2113
16
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2114
16
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2115
16
        return afterQueryFrag;
2116
18
    }
2117
2118
102
    default:
2119
102
        return first;
2120
120
    }
2121
120
}
2122
2123
/*
2124
 * [zeroMoreSlashSegs]-></>[segment][zeroMoreSlashSegs]
2125
 * [zeroMoreSlashSegs]-><NULL>
2126
 */
2127
static const URI_CHAR * URI_FUNC(ParseZeroMoreSlashSegs)(URI_TYPE(ParserState) * state,
2128
                                                         const URI_CHAR * first,
2129
                                                         const URI_CHAR * afterLast,
2130
49.4k
                                                         UriMemoryManager * memory) {
2131
49.4k
    if (first >= afterLast) {
2132
5.14k
        return afterLast;
2133
5.14k
    }
2134
2135
44.2k
    switch (*first) {
2136
43.8k
    case _UT('/'): {
2137
43.8k
        const URI_CHAR * const afterSegment =
2138
43.8k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
2139
43.8k
        if (afterSegment == NULL) {
2140
25
            return NULL;
2141
25
        }
2142
43.8k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
2143
43.8k
                                       memory)) { /* SEGMENT BOTH */
2144
0
            URI_FUNC(StopMalloc)(state, memory);
2145
0
            return NULL;
2146
0
        }
2147
43.8k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
2148
43.8k
    }
2149
2150
402
    default:
2151
402
        return first;
2152
44.2k
    }
2153
44.2k
}
UriParse.c:uriParseZeroMoreSlashSegsA
Line
Count
Source
2130
24.7k
                                                         UriMemoryManager * memory) {
2131
24.7k
    if (first >= afterLast) {
2132
2.59k
        return afterLast;
2133
2.59k
    }
2134
2135
22.1k
    switch (*first) {
2136
21.9k
    case _UT('/'): {
2137
21.9k
        const URI_CHAR * const afterSegment =
2138
21.9k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
2139
21.9k
        if (afterSegment == NULL) {
2140
11
            return NULL;
2141
11
        }
2142
21.9k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
2143
21.9k
                                       memory)) { /* SEGMENT BOTH */
2144
0
            URI_FUNC(StopMalloc)(state, memory);
2145
0
            return NULL;
2146
0
        }
2147
21.9k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
2148
21.9k
    }
2149
2150
170
    default:
2151
170
        return first;
2152
22.1k
    }
2153
22.1k
}
UriParse.c:uriParseZeroMoreSlashSegsW
Line
Count
Source
2130
24.6k
                                                         UriMemoryManager * memory) {
2131
24.6k
    if (first >= afterLast) {
2132
2.54k
        return afterLast;
2133
2.54k
    }
2134
2135
22.1k
    switch (*first) {
2136
21.8k
    case _UT('/'): {
2137
21.8k
        const URI_CHAR * const afterSegment =
2138
21.8k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
2139
21.8k
        if (afterSegment == NULL) {
2140
14
            return NULL;
2141
14
        }
2142
21.8k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
2143
21.8k
                                       memory)) { /* SEGMENT BOTH */
2144
0
            URI_FUNC(StopMalloc)(state, memory);
2145
0
            return NULL;
2146
0
        }
2147
21.8k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
2148
21.8k
    }
2149
2150
232
    default:
2151
232
        return first;
2152
22.1k
    }
2153
22.1k
}
2154
2155
static URI_INLINE void URI_FUNC(ResetParserStateExceptUri)(URI_TYPE(ParserState)
2156
55.9k
                                                           * state) {
2157
55.9k
    URI_TYPE(Uri) * const uriBackup = state->uri;
2158
55.9k
    memset(state, 0, sizeof(URI_TYPE(ParserState)));
2159
55.9k
    state->uri = uriBackup;
2160
55.9k
}
UriParse.c:uriResetParserStateExceptUriA
Line
Count
Source
2156
27.1k
                                                           * state) {
2157
27.1k
    URI_TYPE(Uri) * const uriBackup = state->uri;
2158
27.1k
    memset(state, 0, sizeof(URI_TYPE(ParserState)));
2159
27.1k
    state->uri = uriBackup;
2160
27.1k
}
UriParse.c:uriResetParserStateExceptUriW
Line
Count
Source
2156
28.7k
                                                           * state) {
2157
28.7k
    URI_TYPE(Uri) * const uriBackup = state->uri;
2158
28.7k
    memset(state, 0, sizeof(URI_TYPE(ParserState)));
2159
28.7k
    state->uri = uriBackup;
2160
28.7k
}
2161
2162
static URI_INLINE UriBool URI_FUNC(PushPathSegment)(URI_TYPE(ParserState) * state,
2163
                                                    const URI_CHAR * first,
2164
                                                    const URI_CHAR * afterLast,
2165
67.4k
                                                    UriMemoryManager * memory) {
2166
67.4k
    URI_TYPE(PathSegment) * segment =
2167
67.4k
        memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment)));
2168
67.4k
    if (segment == NULL) {
2169
0
        return URI_FALSE; /* Raises malloc error */
2170
0
    }
2171
67.4k
    if (first == afterLast) {
2172
20.6k
        segment->text.first = URI_FUNC(SafeToPointTo);
2173
20.6k
        segment->text.afterLast = URI_FUNC(SafeToPointTo);
2174
46.7k
    } else {
2175
46.7k
        segment->text.first = first;
2176
46.7k
        segment->text.afterLast = afterLast;
2177
46.7k
    }
2178
2179
    /* First segment ever? */
2180
67.4k
    if (state->uri->pathHead == NULL) {
2181
        /* First segment ever, set head and tail */
2182
14.9k
        state->uri->pathHead = segment;
2183
14.9k
        state->uri->pathTail = segment;
2184
52.4k
    } else {
2185
        /* Append, update tail */
2186
52.4k
        state->uri->pathTail->next = segment;
2187
52.4k
        state->uri->pathTail = segment;
2188
52.4k
    }
2189
2190
67.4k
    return URI_TRUE; /* Success */
2191
67.4k
}
UriParse.c:uriPushPathSegmentA
Line
Count
Source
2165
34.3k
                                                    UriMemoryManager * memory) {
2166
34.3k
    URI_TYPE(PathSegment) * segment =
2167
34.3k
        memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment)));
2168
34.3k
    if (segment == NULL) {
2169
0
        return URI_FALSE; /* Raises malloc error */
2170
0
    }
2171
34.3k
    if (first == afterLast) {
2172
11.4k
        segment->text.first = URI_FUNC(SafeToPointTo);
2173
11.4k
        segment->text.afterLast = URI_FUNC(SafeToPointTo);
2174
22.9k
    } else {
2175
22.9k
        segment->text.first = first;
2176
22.9k
        segment->text.afterLast = afterLast;
2177
22.9k
    }
2178
2179
    /* First segment ever? */
2180
34.3k
    if (state->uri->pathHead == NULL) {
2181
        /* First segment ever, set head and tail */
2182
7.73k
        state->uri->pathHead = segment;
2183
7.73k
        state->uri->pathTail = segment;
2184
26.6k
    } else {
2185
        /* Append, update tail */
2186
26.6k
        state->uri->pathTail->next = segment;
2187
26.6k
        state->uri->pathTail = segment;
2188
26.6k
    }
2189
2190
34.3k
    return URI_TRUE; /* Success */
2191
34.3k
}
UriParse.c:uriPushPathSegmentW
Line
Count
Source
2165
33.0k
                                                    UriMemoryManager * memory) {
2166
33.0k
    URI_TYPE(PathSegment) * segment =
2167
33.0k
        memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment)));
2168
33.0k
    if (segment == NULL) {
2169
0
        return URI_FALSE; /* Raises malloc error */
2170
0
    }
2171
33.0k
    if (first == afterLast) {
2172
9.22k
        segment->text.first = URI_FUNC(SafeToPointTo);
2173
9.22k
        segment->text.afterLast = URI_FUNC(SafeToPointTo);
2174
23.8k
    } else {
2175
23.8k
        segment->text.first = first;
2176
23.8k
        segment->text.afterLast = afterLast;
2177
23.8k
    }
2178
2179
    /* First segment ever? */
2180
33.0k
    if (state->uri->pathHead == NULL) {
2181
        /* First segment ever, set head and tail */
2182
7.26k
        state->uri->pathHead = segment;
2183
7.26k
        state->uri->pathTail = segment;
2184
25.8k
    } else {
2185
        /* Append, update tail */
2186
25.8k
        state->uri->pathTail->next = segment;
2187
25.8k
        state->uri->pathTail = segment;
2188
25.8k
    }
2189
2190
33.0k
    return URI_TRUE; /* Success */
2191
33.0k
}
2192
2193
int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
2194
36.6k
                         const URI_CHAR * afterLast) {
2195
36.6k
    return URI_FUNC(ParseUriExMm)(state, first, afterLast, NULL);
2196
36.6k
}
uriParseUriExA
Line
Count
Source
2194
17.9k
                         const URI_CHAR * afterLast) {
2195
17.9k
    return URI_FUNC(ParseUriExMm)(state, first, afterLast, NULL);
2196
17.9k
}
uriParseUriExW
Line
Count
Source
2194
18.7k
                         const URI_CHAR * afterLast) {
2195
18.7k
    return URI_FUNC(ParseUriExMm)(state, first, afterLast, NULL);
2196
18.7k
}
2197
2198
static int URI_FUNC(ParseUriExMm)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
2199
55.9k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
2200
55.9k
    const URI_CHAR * afterUriReference;
2201
55.9k
    URI_TYPE(Uri) * uri;
2202
2203
    /* Check params */
2204
55.9k
    if ((state == NULL) || (first == NULL) || (afterLast == NULL)) {
2205
0
        return URI_ERROR_NULL;
2206
0
    }
2207
55.9k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2208
2209
55.9k
    uri = state->uri;
2210
2211
    /* Init parser */
2212
55.9k
    URI_FUNC(ResetParserStateExceptUri)(state);
2213
55.9k
    URI_FUNC(ResetUri)(uri);
2214
2215
    /* Parse */
2216
55.9k
    afterUriReference = URI_FUNC(ParseUriReference)(state, first, afterLast, memory);
2217
55.9k
    if (afterUriReference == NULL) {
2218
        /* Waterproof errorPos <= afterLast */
2219
10.7k
        if (state->errorPos && (state->errorPos > afterLast)) {
2220
0
            state->errorPos = afterLast;
2221
0
        }
2222
10.7k
        return state->errorCode;
2223
10.7k
    }
2224
45.1k
    if (afterUriReference != afterLast) {
2225
2.59k
        if (afterUriReference < afterLast) {
2226
2.59k
            URI_FUNC(StopSyntax)(state, afterUriReference, memory);
2227
2.59k
        } else {
2228
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
2229
0
        }
2230
2.59k
        return state->errorCode;
2231
2.59k
    }
2232
42.5k
    return URI_SUCCESS;
2233
45.1k
}
UriParse.c:uriParseUriExMmA
Line
Count
Source
2199
27.1k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
2200
27.1k
    const URI_CHAR * afterUriReference;
2201
27.1k
    URI_TYPE(Uri) * uri;
2202
2203
    /* Check params */
2204
27.1k
    if ((state == NULL) || (first == NULL) || (afterLast == NULL)) {
2205
0
        return URI_ERROR_NULL;
2206
0
    }
2207
27.1k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2208
2209
27.1k
    uri = state->uri;
2210
2211
    /* Init parser */
2212
27.1k
    URI_FUNC(ResetParserStateExceptUri)(state);
2213
27.1k
    URI_FUNC(ResetUri)(uri);
2214
2215
    /* Parse */
2216
27.1k
    afterUriReference = URI_FUNC(ParseUriReference)(state, first, afterLast, memory);
2217
27.1k
    if (afterUriReference == NULL) {
2218
        /* Waterproof errorPos <= afterLast */
2219
5.26k
        if (state->errorPos && (state->errorPos > afterLast)) {
2220
0
            state->errorPos = afterLast;
2221
0
        }
2222
5.26k
        return state->errorCode;
2223
5.26k
    }
2224
21.8k
    if (afterUriReference != afterLast) {
2225
727
        if (afterUriReference < afterLast) {
2226
727
            URI_FUNC(StopSyntax)(state, afterUriReference, memory);
2227
727
        } else {
2228
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
2229
0
        }
2230
727
        return state->errorCode;
2231
727
    }
2232
21.1k
    return URI_SUCCESS;
2233
21.8k
}
UriParse.c:uriParseUriExMmW
Line
Count
Source
2199
28.7k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
2200
28.7k
    const URI_CHAR * afterUriReference;
2201
28.7k
    URI_TYPE(Uri) * uri;
2202
2203
    /* Check params */
2204
28.7k
    if ((state == NULL) || (first == NULL) || (afterLast == NULL)) {
2205
0
        return URI_ERROR_NULL;
2206
0
    }
2207
28.7k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2208
2209
28.7k
    uri = state->uri;
2210
2211
    /* Init parser */
2212
28.7k
    URI_FUNC(ResetParserStateExceptUri)(state);
2213
28.7k
    URI_FUNC(ResetUri)(uri);
2214
2215
    /* Parse */
2216
28.7k
    afterUriReference = URI_FUNC(ParseUriReference)(state, first, afterLast, memory);
2217
28.7k
    if (afterUriReference == NULL) {
2218
        /* Waterproof errorPos <= afterLast */
2219
5.46k
        if (state->errorPos && (state->errorPos > afterLast)) {
2220
0
            state->errorPos = afterLast;
2221
0
        }
2222
5.46k
        return state->errorCode;
2223
5.46k
    }
2224
23.2k
    if (afterUriReference != afterLast) {
2225
1.86k
        if (afterUriReference < afterLast) {
2226
1.86k
            URI_FUNC(StopSyntax)(state, afterUriReference, memory);
2227
1.86k
        } else {
2228
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
2229
0
        }
2230
1.86k
        return state->errorCode;
2231
1.86k
    }
2232
21.4k
    return URI_SUCCESS;
2233
23.2k
}
2234
2235
36.6k
int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text) {
2236
36.6k
    if ((state == NULL) || (text == NULL)) {
2237
0
        return URI_ERROR_NULL;
2238
0
    }
2239
36.6k
    return URI_FUNC(ParseUriEx)(state, text, text + URI_STRLEN(text));
2240
36.6k
}
uriParseUriA
Line
Count
Source
2235
17.9k
int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text) {
2236
17.9k
    if ((state == NULL) || (text == NULL)) {
2237
0
        return URI_ERROR_NULL;
2238
0
    }
2239
17.9k
    return URI_FUNC(ParseUriEx)(state, text, text + URI_STRLEN(text));
2240
17.9k
}
uriParseUriW
Line
Count
Source
2235
18.7k
int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text) {
2236
18.7k
    if ((state == NULL) || (text == NULL)) {
2237
0
        return URI_ERROR_NULL;
2238
0
    }
2239
18.7k
    return URI_FUNC(ParseUriEx)(state, text, text + URI_STRLEN(text));
2240
18.7k
}
2241
2242
int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, const URI_CHAR * text,
2243
19.2k
                             const URI_CHAR ** errorPos) {
2244
19.2k
    return URI_FUNC(ParseSingleUriEx)(uri, text, NULL, errorPos);
2245
19.2k
}
uriParseSingleUriA
Line
Count
Source
2243
9.24k
                             const URI_CHAR ** errorPos) {
2244
9.24k
    return URI_FUNC(ParseSingleUriEx)(uri, text, NULL, errorPos);
2245
9.24k
}
uriParseSingleUriW
Line
Count
Source
2243
10.0k
                             const URI_CHAR ** errorPos) {
2244
10.0k
    return URI_FUNC(ParseSingleUriEx)(uri, text, NULL, errorPos);
2245
10.0k
}
2246
2247
int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, const URI_CHAR * first,
2248
19.2k
                               const URI_CHAR * afterLast, const URI_CHAR ** errorPos) {
2249
19.2k
    if ((afterLast == NULL) && (first != NULL)) {
2250
19.2k
        afterLast = first + URI_STRLEN(first);
2251
19.2k
    }
2252
19.2k
    return URI_FUNC(ParseSingleUriExMm)(uri, first, afterLast, errorPos, NULL);
2253
19.2k
}
uriParseSingleUriExA
Line
Count
Source
2248
9.24k
                               const URI_CHAR * afterLast, const URI_CHAR ** errorPos) {
2249
9.24k
    if ((afterLast == NULL) && (first != NULL)) {
2250
9.24k
        afterLast = first + URI_STRLEN(first);
2251
9.24k
    }
2252
9.24k
    return URI_FUNC(ParseSingleUriExMm)(uri, first, afterLast, errorPos, NULL);
2253
9.24k
}
uriParseSingleUriExW
Line
Count
Source
2248
10.0k
                               const URI_CHAR * afterLast, const URI_CHAR ** errorPos) {
2249
10.0k
    if ((afterLast == NULL) && (first != NULL)) {
2250
10.0k
        afterLast = first + URI_STRLEN(first);
2251
10.0k
    }
2252
10.0k
    return URI_FUNC(ParseSingleUriExMm)(uri, first, afterLast, errorPos, NULL);
2253
10.0k
}
2254
2255
int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first,
2256
                                 const URI_CHAR * afterLast, const URI_CHAR ** errorPos,
2257
19.2k
                                 UriMemoryManager * memory) {
2258
19.2k
    URI_TYPE(ParserState) state;
2259
19.2k
    int res;
2260
2261
    /* Check params */
2262
19.2k
    if ((uri == NULL) || (first == NULL) || (afterLast == NULL)) {
2263
0
        return URI_ERROR_NULL;
2264
0
    }
2265
19.2k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2266
2267
19.2k
    state.uri = uri;
2268
2269
19.2k
    res = URI_FUNC(ParseUriExMm)(&state, first, afterLast, memory);
2270
2271
19.2k
    if (res != URI_SUCCESS) {
2272
5.78k
        if (errorPos != NULL) {
2273
0
            *errorPos = state.errorPos;
2274
0
        }
2275
5.78k
        URI_FUNC(FreeUriMembersMm)(uri, memory);
2276
5.78k
    }
2277
2278
19.2k
    return res;
2279
19.2k
}
uriParseSingleUriExMmA
Line
Count
Source
2257
9.24k
                                 UriMemoryManager * memory) {
2258
9.24k
    URI_TYPE(ParserState) state;
2259
9.24k
    int res;
2260
2261
    /* Check params */
2262
9.24k
    if ((uri == NULL) || (first == NULL) || (afterLast == NULL)) {
2263
0
        return URI_ERROR_NULL;
2264
0
    }
2265
9.24k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2266
2267
9.24k
    state.uri = uri;
2268
2269
9.24k
    res = URI_FUNC(ParseUriExMm)(&state, first, afterLast, memory);
2270
2271
9.24k
    if (res != URI_SUCCESS) {
2272
2.26k
        if (errorPos != NULL) {
2273
0
            *errorPos = state.errorPos;
2274
0
        }
2275
2.26k
        URI_FUNC(FreeUriMembersMm)(uri, memory);
2276
2.26k
    }
2277
2278
9.24k
    return res;
2279
9.24k
}
uriParseSingleUriExMmW
Line
Count
Source
2257
10.0k
                                 UriMemoryManager * memory) {
2258
10.0k
    URI_TYPE(ParserState) state;
2259
10.0k
    int res;
2260
2261
    /* Check params */
2262
10.0k
    if ((uri == NULL) || (first == NULL) || (afterLast == NULL)) {
2263
0
        return URI_ERROR_NULL;
2264
0
    }
2265
10.0k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2266
2267
10.0k
    state.uri = uri;
2268
2269
10.0k
    res = URI_FUNC(ParseUriExMm)(&state, first, afterLast, memory);
2270
2271
10.0k
    if (res != URI_SUCCESS) {
2272
3.51k
        if (errorPos != NULL) {
2273
0
            *errorPos = state.errorPos;
2274
0
        }
2275
3.51k
        URI_FUNC(FreeUriMembersMm)(uri, memory);
2276
3.51k
    }
2277
2278
10.0k
    return res;
2279
10.0k
}
2280
2281
82.8k
void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri) {
2282
82.8k
    URI_FUNC(FreeUriMembersMm)(uri, NULL);
2283
82.8k
}
uriFreeUriMembersA
Line
Count
Source
2281
41.1k
void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri) {
2282
41.1k
    URI_FUNC(FreeUriMembersMm)(uri, NULL);
2283
41.1k
}
uriFreeUriMembersW
Line
Count
Source
2281
41.7k
void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri) {
2282
41.7k
    URI_FUNC(FreeUriMembersMm)(uri, NULL);
2283
41.7k
}
2284
2285
127k
int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) {
2286
127k
    if (uri == NULL) {
2287
0
        return URI_ERROR_NULL;
2288
0
    }
2289
2290
127k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2291
2292
127k
    if (uri->owner) {
2293
        /* Scheme */
2294
13.4k
        if (uri->scheme.first != NULL) {
2295
890
            if (uri->scheme.first != uri->scheme.afterLast) {
2296
890
                memory->free(memory, (URI_CHAR *)uri->scheme.first);
2297
890
            }
2298
890
            uri->scheme.first = NULL;
2299
890
            uri->scheme.afterLast = NULL;
2300
890
        }
2301
2302
        /* User info */
2303
13.4k
        if (uri->userInfo.first != NULL) {
2304
479
            if (uri->userInfo.first != uri->userInfo.afterLast) {
2305
201
                memory->free(memory, (URI_CHAR *)uri->userInfo.first);
2306
201
            }
2307
479
            uri->userInfo.first = NULL;
2308
479
            uri->userInfo.afterLast = NULL;
2309
479
        }
2310
2311
        /* Host data - IPvFuture (may affect host text) */
2312
13.4k
        if (uri->hostData.ipFuture.first != NULL) {
2313
            /* NOTE: .hostData.ipFuture holds the very same range pointers
2314
             *       as .hostText; we must not free memory twice. */
2315
255
            uri->hostText.first = NULL;
2316
255
            uri->hostText.afterLast = NULL;
2317
2318
255
            if (uri->hostData.ipFuture.first != uri->hostData.ipFuture.afterLast) {
2319
255
                memory->free(memory, (URI_CHAR *)uri->hostData.ipFuture.first);
2320
255
            }
2321
255
            uri->hostData.ipFuture.first = NULL;
2322
255
            uri->hostData.ipFuture.afterLast = NULL;
2323
255
        }
2324
2325
        /* Host text (after IPvFuture, see above) */
2326
13.4k
        if (uri->hostText.first != NULL) {
2327
1.76k
            if (uri->hostText.first != uri->hostText.afterLast) {
2328
1.50k
                memory->free(memory, (URI_CHAR *)uri->hostText.first);
2329
1.50k
            }
2330
1.76k
            uri->hostText.first = NULL;
2331
1.76k
            uri->hostText.afterLast = NULL;
2332
1.76k
        }
2333
13.4k
    }
2334
2335
    /* Host data - IPv4 */
2336
127k
    if (uri->hostData.ip4 != NULL) {
2337
197
        memory->free(memory, uri->hostData.ip4);
2338
197
        uri->hostData.ip4 = NULL;
2339
197
    }
2340
2341
    /* Host data - IPv6 */
2342
127k
    if (uri->hostData.ip6 != NULL) {
2343
3.17k
        memory->free(memory, uri->hostData.ip6);
2344
3.17k
        uri->hostData.ip6 = NULL;
2345
3.17k
    }
2346
2347
    /* Port text */
2348
127k
    if (uri->owner && (uri->portText.first != NULL)) {
2349
248
        if (uri->portText.first != uri->portText.afterLast) {
2350
184
            memory->free(memory, (URI_CHAR *)uri->portText.first);
2351
184
        }
2352
248
        uri->portText.first = NULL;
2353
248
        uri->portText.afterLast = NULL;
2354
248
    }
2355
2356
    /* Path */
2357
127k
    URI_FUNC(FreeUriPath)(uri, memory);
2358
2359
127k
    if (uri->owner) {
2360
        /* Query */
2361
13.4k
        if (uri->query.first != NULL) {
2362
348
            if (uri->query.first != uri->query.afterLast) {
2363
317
                memory->free(memory, (URI_CHAR *)uri->query.first);
2364
317
            }
2365
348
            uri->query.first = NULL;
2366
348
            uri->query.afterLast = NULL;
2367
348
        }
2368
2369
        /* Fragment */
2370
13.4k
        if (uri->fragment.first != NULL) {
2371
266
            if (uri->fragment.first != uri->fragment.afterLast) {
2372
240
                memory->free(memory, (URI_CHAR *)uri->fragment.first);
2373
240
            }
2374
266
            uri->fragment.first = NULL;
2375
266
            uri->fragment.afterLast = NULL;
2376
266
        }
2377
13.4k
    }
2378
2379
127k
    return URI_SUCCESS;
2380
127k
}
uriFreeUriMembersMmA
Line
Count
Source
2285
62.7k
int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) {
2286
62.7k
    if (uri == NULL) {
2287
0
        return URI_ERROR_NULL;
2288
0
    }
2289
2290
62.7k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2291
2292
62.7k
    if (uri->owner) {
2293
        /* Scheme */
2294
6.97k
        if (uri->scheme.first != NULL) {
2295
483
            if (uri->scheme.first != uri->scheme.afterLast) {
2296
483
                memory->free(memory, (URI_CHAR *)uri->scheme.first);
2297
483
            }
2298
483
            uri->scheme.first = NULL;
2299
483
            uri->scheme.afterLast = NULL;
2300
483
        }
2301
2302
        /* User info */
2303
6.97k
        if (uri->userInfo.first != NULL) {
2304
332
            if (uri->userInfo.first != uri->userInfo.afterLast) {
2305
131
                memory->free(memory, (URI_CHAR *)uri->userInfo.first);
2306
131
            }
2307
332
            uri->userInfo.first = NULL;
2308
332
            uri->userInfo.afterLast = NULL;
2309
332
        }
2310
2311
        /* Host data - IPvFuture (may affect host text) */
2312
6.97k
        if (uri->hostData.ipFuture.first != NULL) {
2313
            /* NOTE: .hostData.ipFuture holds the very same range pointers
2314
             *       as .hostText; we must not free memory twice. */
2315
127
            uri->hostText.first = NULL;
2316
127
            uri->hostText.afterLast = NULL;
2317
2318
127
            if (uri->hostData.ipFuture.first != uri->hostData.ipFuture.afterLast) {
2319
127
                memory->free(memory, (URI_CHAR *)uri->hostData.ipFuture.first);
2320
127
            }
2321
127
            uri->hostData.ipFuture.first = NULL;
2322
127
            uri->hostData.ipFuture.afterLast = NULL;
2323
127
        }
2324
2325
        /* Host text (after IPvFuture, see above) */
2326
6.97k
        if (uri->hostText.first != NULL) {
2327
1.09k
            if (uri->hostText.first != uri->hostText.afterLast) {
2328
956
                memory->free(memory, (URI_CHAR *)uri->hostText.first);
2329
956
            }
2330
1.09k
            uri->hostText.first = NULL;
2331
1.09k
            uri->hostText.afterLast = NULL;
2332
1.09k
        }
2333
6.97k
    }
2334
2335
    /* Host data - IPv4 */
2336
62.7k
    if (uri->hostData.ip4 != NULL) {
2337
89
        memory->free(memory, uri->hostData.ip4);
2338
89
        uri->hostData.ip4 = NULL;
2339
89
    }
2340
2341
    /* Host data - IPv6 */
2342
62.7k
    if (uri->hostData.ip6 != NULL) {
2343
1.43k
        memory->free(memory, uri->hostData.ip6);
2344
1.43k
        uri->hostData.ip6 = NULL;
2345
1.43k
    }
2346
2347
    /* Port text */
2348
62.7k
    if (uri->owner && (uri->portText.first != NULL)) {
2349
166
        if (uri->portText.first != uri->portText.afterLast) {
2350
129
            memory->free(memory, (URI_CHAR *)uri->portText.first);
2351
129
        }
2352
166
        uri->portText.first = NULL;
2353
166
        uri->portText.afterLast = NULL;
2354
166
    }
2355
2356
    /* Path */
2357
62.7k
    URI_FUNC(FreeUriPath)(uri, memory);
2358
2359
62.7k
    if (uri->owner) {
2360
        /* Query */
2361
6.97k
        if (uri->query.first != NULL) {
2362
225
            if (uri->query.first != uri->query.afterLast) {
2363
206
                memory->free(memory, (URI_CHAR *)uri->query.first);
2364
206
            }
2365
225
            uri->query.first = NULL;
2366
225
            uri->query.afterLast = NULL;
2367
225
        }
2368
2369
        /* Fragment */
2370
6.97k
        if (uri->fragment.first != NULL) {
2371
161
            if (uri->fragment.first != uri->fragment.afterLast) {
2372
152
                memory->free(memory, (URI_CHAR *)uri->fragment.first);
2373
152
            }
2374
161
            uri->fragment.first = NULL;
2375
161
            uri->fragment.afterLast = NULL;
2376
161
        }
2377
6.97k
    }
2378
2379
62.7k
    return URI_SUCCESS;
2380
62.7k
}
uriFreeUriMembersMmW
Line
Count
Source
2285
65.1k
int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) {
2286
65.1k
    if (uri == NULL) {
2287
0
        return URI_ERROR_NULL;
2288
0
    }
2289
2290
65.1k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2291
2292
65.1k
    if (uri->owner) {
2293
        /* Scheme */
2294
6.51k
        if (uri->scheme.first != NULL) {
2295
407
            if (uri->scheme.first != uri->scheme.afterLast) {
2296
407
                memory->free(memory, (URI_CHAR *)uri->scheme.first);
2297
407
            }
2298
407
            uri->scheme.first = NULL;
2299
407
            uri->scheme.afterLast = NULL;
2300
407
        }
2301
2302
        /* User info */
2303
6.51k
        if (uri->userInfo.first != NULL) {
2304
147
            if (uri->userInfo.first != uri->userInfo.afterLast) {
2305
70
                memory->free(memory, (URI_CHAR *)uri->userInfo.first);
2306
70
            }
2307
147
            uri->userInfo.first = NULL;
2308
147
            uri->userInfo.afterLast = NULL;
2309
147
        }
2310
2311
        /* Host data - IPvFuture (may affect host text) */
2312
6.51k
        if (uri->hostData.ipFuture.first != NULL) {
2313
            /* NOTE: .hostData.ipFuture holds the very same range pointers
2314
             *       as .hostText; we must not free memory twice. */
2315
128
            uri->hostText.first = NULL;
2316
128
            uri->hostText.afterLast = NULL;
2317
2318
128
            if (uri->hostData.ipFuture.first != uri->hostData.ipFuture.afterLast) {
2319
128
                memory->free(memory, (URI_CHAR *)uri->hostData.ipFuture.first);
2320
128
            }
2321
128
            uri->hostData.ipFuture.first = NULL;
2322
128
            uri->hostData.ipFuture.afterLast = NULL;
2323
128
        }
2324
2325
        /* Host text (after IPvFuture, see above) */
2326
6.51k
        if (uri->hostText.first != NULL) {
2327
671
            if (uri->hostText.first != uri->hostText.afterLast) {
2328
553
                memory->free(memory, (URI_CHAR *)uri->hostText.first);
2329
553
            }
2330
671
            uri->hostText.first = NULL;
2331
671
            uri->hostText.afterLast = NULL;
2332
671
        }
2333
6.51k
    }
2334
2335
    /* Host data - IPv4 */
2336
65.1k
    if (uri->hostData.ip4 != NULL) {
2337
108
        memory->free(memory, uri->hostData.ip4);
2338
108
        uri->hostData.ip4 = NULL;
2339
108
    }
2340
2341
    /* Host data - IPv6 */
2342
65.1k
    if (uri->hostData.ip6 != NULL) {
2343
1.73k
        memory->free(memory, uri->hostData.ip6);
2344
1.73k
        uri->hostData.ip6 = NULL;
2345
1.73k
    }
2346
2347
    /* Port text */
2348
65.1k
    if (uri->owner && (uri->portText.first != NULL)) {
2349
82
        if (uri->portText.first != uri->portText.afterLast) {
2350
55
            memory->free(memory, (URI_CHAR *)uri->portText.first);
2351
55
        }
2352
82
        uri->portText.first = NULL;
2353
82
        uri->portText.afterLast = NULL;
2354
82
    }
2355
2356
    /* Path */
2357
65.1k
    URI_FUNC(FreeUriPath)(uri, memory);
2358
2359
65.1k
    if (uri->owner) {
2360
        /* Query */
2361
6.51k
        if (uri->query.first != NULL) {
2362
123
            if (uri->query.first != uri->query.afterLast) {
2363
111
                memory->free(memory, (URI_CHAR *)uri->query.first);
2364
111
            }
2365
123
            uri->query.first = NULL;
2366
123
            uri->query.afterLast = NULL;
2367
123
        }
2368
2369
        /* Fragment */
2370
6.51k
        if (uri->fragment.first != NULL) {
2371
105
            if (uri->fragment.first != uri->fragment.afterLast) {
2372
88
                memory->free(memory, (URI_CHAR *)uri->fragment.first);
2373
88
            }
2374
105
            uri->fragment.first = NULL;
2375
105
            uri->fragment.afterLast = NULL;
2376
105
        }
2377
6.51k
    }
2378
2379
65.1k
    return URI_SUCCESS;
2380
65.1k
}
2381
2382
0
UriBool URI_FUNC(_TESTING_ONLY_ParseIpSix)(const URI_CHAR * text) {
2383
0
    UriMemoryManager * const memory = &defaultMemoryManager;
2384
0
    URI_TYPE(Uri) uri;
2385
0
    URI_TYPE(ParserState) parser;
2386
0
    const URI_CHAR * const afterIpSix = text + URI_STRLEN(text);
2387
0
    const URI_CHAR * res;
2388
2389
0
    URI_FUNC(ResetUri)(&uri);
2390
0
    parser.uri = &uri;
2391
0
    URI_FUNC(ResetParserStateExceptUri)(&parser);
2392
0
    parser.uri->hostData.ip6 = memory->malloc(memory, 1 * sizeof(UriIp6));
2393
0
    res = URI_FUNC(ParseIPv6address2)(&parser, text, afterIpSix, memory);
2394
0
    URI_FUNC(FreeUriMembersMm)(&uri, memory);
2395
0
    return res == afterIpSix ? URI_TRUE : URI_FALSE;
2396
0
}
Unexecuted instantiation: uri_TESTING_ONLY_ParseIpSixA
Unexecuted instantiation: uri_TESTING_ONLY_ParseIpSixW
2397
2398
0
UriBool URI_FUNC(_TESTING_ONLY_ParseIpFour)(const URI_CHAR * text) {
2399
0
    unsigned char octets[4];
2400
0
    int res = URI_FUNC(ParseIpFourAddress)(octets, text, text + URI_STRLEN(text));
2401
0
    return (res == URI_SUCCESS) ? URI_TRUE : URI_FALSE;
2402
0
}
Unexecuted instantiation: uri_TESTING_ONLY_ParseIpFourA
Unexecuted instantiation: uri_TESTING_ONLY_ParseIpFourW
2403
2404
#  undef URI_SET_DIGIT
2405
#  undef URI_SET_HEX_LETTER_UPPER
2406
#  undef URI_SET_HEX_LETTER_LOWER
2407
#  undef URI_SET_HEXDIG
2408
#  undef URI_SET_ALPHA
2409
2410
#endif