Coverage Report

Created: 2025-11-05 06:12

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
16.0M
  _UT('0') : case _UT('1'): \
78
16.3M
  case _UT('2'): \
79
16.5M
  case _UT('3'): \
80
16.7M
  case _UT('4'): \
81
19.0M
  case _UT('5'): \
82
19.7M
  case _UT('6'): \
83
19.8M
  case _UT('7'): \
84
19.9M
  case _UT('8'): \
85
20.1M
  case _UT('9')
86
87
#  define URI_SET_HEX_LETTER_UPPER \
88
12.9M
  _UT('A') : case _UT('B'): \
89
13.0M
  case _UT('C'): \
90
13.4M
  case _UT('D'): \
91
13.5M
  case _UT('E'): \
92
13.7M
  case _UT('F')
93
94
#  define URI_SET_HEX_LETTER_LOWER \
95
17.9M
  _UT('a') : case _UT('b'): \
96
18.1M
  case _UT('c'): \
97
18.3M
  case _UT('d'): \
98
18.9M
  case _UT('e'): \
99
20.1M
  case _UT('f')
100
101
#  define URI_SET_HEXDIG \
102
162k
  URI_SET_DIGIT: \
103
192k
  case URI_SET_HEX_LETTER_UPPER: \
104
204k
  case URI_SET_HEX_LETTER_LOWER
105
106
#  define URI_SET_ALPHA \
107
13.5M
  URI_SET_HEX_LETTER_UPPER: \
108
19.8M
  case URI_SET_HEX_LETTER_LOWER: \
109
19.9M
  case _UT('g'): \
110
19.9M
  case _UT('G'): \
111
24.5M
  case _UT('h'): \
112
25.1M
  case _UT('H'): \
113
28.5M
  case _UT('i'): \
114
42.8M
  case _UT('I'): \
115
42.9M
  case _UT('j'): \
116
43.0M
  case _UT('J'): \
117
45.5M
  case _UT('k'): \
118
45.6M
  case _UT('K'): \
119
45.7M
  case _UT('l'): \
120
47.2M
  case _UT('L'): \
121
47.3M
  case _UT('m'): \
122
47.4M
  case _UT('M'): \
123
47.5M
  case _UT('n'): \
124
47.7M
  case _UT('N'): \
125
47.9M
  case _UT('o'): \
126
48.0M
  case _UT('O'): \
127
48.0M
  case _UT('p'): \
128
48.2M
  case _UT('P'): \
129
48.3M
  case _UT('q'): \
130
48.4M
  case _UT('Q'): \
131
48.7M
  case _UT('r'): \
132
48.8M
  case _UT('R'): \
133
48.9M
  case _UT('s'): \
134
48.9M
  case _UT('S'): \
135
49.2M
  case _UT('t'): \
136
49.3M
  case _UT('T'): \
137
49.3M
  case _UT('u'): \
138
49.6M
  case _UT('U'): \
139
49.7M
  case _UT('v'): \
140
49.8M
  case _UT('V'): \
141
49.9M
  case _UT('w'): \
142
50.0M
  case _UT('W'): \
143
50.2M
  case _UT('x'): \
144
54.6M
  case _UT('X'): \
145
54.6M
  case _UT('y'): \
146
54.9M
  case _UT('Y'): \
147
55.2M
  case _UT('z'): \
148
65.6M
  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.1k
                                            UriMemoryManager * memory) {
304
13.1k
    URI_FUNC(FreeUriMembersMm)(state->uri, memory);
305
13.1k
    state->errorPos = errorPos;
306
13.1k
    state->errorCode = URI_ERROR_SYNTAX;
307
13.1k
}
UriParse.c:uriStopSyntaxA
Line
Count
Source
303
5.88k
                                            UriMemoryManager * memory) {
304
5.88k
    URI_FUNC(FreeUriMembersMm)(state->uri, memory);
305
5.88k
    state->errorPos = errorPos;
306
5.88k
    state->errorCode = URI_ERROR_SYNTAX;
307
5.88k
}
UriParse.c:uriStopSyntaxW
Line
Count
Source
303
7.30k
                                            UriMemoryManager * memory) {
304
7.30k
    URI_FUNC(FreeUriMembersMm)(state->uri, memory);
305
7.30k
    state->errorPos = errorPos;
306
7.30k
    state->errorCode = URI_ERROR_SYNTAX;
307
7.30k
}
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
19.9k
                                                            UriMemoryManager * memory) {
325
19.9k
    if (first >= afterLast) {
326
        /* "" regname host */
327
45
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
328
45
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
329
45
        return afterLast;
330
45
    }
331
332
19.8k
    switch (*first) {
333
7.84k
    case _UT('['): {
334
7.84k
        const URI_CHAR * const afterIpLit2 =
335
7.84k
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
336
7.84k
        if (afterIpLit2 == NULL) {
337
6.53k
            return NULL;
338
6.53k
        }
339
1.30k
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
340
1.30k
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
341
7.84k
    }
342
343
52
    case _UT('!'):
344
114
    case _UT('$'):
345
221
    case _UT('%'):
346
282
    case _UT('&'):
347
348
    case _UT('('):
348
404
    case _UT(')'):
349
460
    case _UT('-'):
350
513
    case _UT('*'):
351
590
    case _UT(','):
352
716
    case _UT('.'):
353
4.23k
    case _UT(':'):
354
4.30k
    case _UT(';'):
355
7.36k
    case _UT('@'):
356
7.41k
    case _UT('\''):
357
7.50k
    case _UT('_'):
358
7.55k
    case _UT('~'):
359
7.61k
    case _UT('+'):
360
7.67k
    case _UT('='):
361
75.7k
    case URI_SET_DIGIT:
362
75.7k
    case URI_SET_ALPHA:
363
11.7k
        state->uri->userInfo.first = first; /* USERINFO BEGIN */
364
11.7k
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
365
366
280
    default:
367
        /* "" regname host */
368
280
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
369
280
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
370
280
        return first;
371
19.8k
    }
372
19.8k
}
UriParse.c:uriParseAuthorityA
Line
Count
Source
324
9.69k
                                                            UriMemoryManager * memory) {
325
9.69k
    if (first >= afterLast) {
326
        /* "" regname host */
327
18
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
328
18
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
329
18
        return afterLast;
330
18
    }
331
332
9.67k
    switch (*first) {
333
3.76k
    case _UT('['): {
334
3.76k
        const URI_CHAR * const afterIpLit2 =
335
3.76k
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
336
3.76k
        if (afterIpLit2 == NULL) {
337
3.13k
            return NULL;
338
3.13k
        }
339
623
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
340
623
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
341
3.76k
    }
342
343
24
    case _UT('!'):
344
59
    case _UT('$'):
345
109
    case _UT('%'):
346
140
    case _UT('&'):
347
172
    case _UT('('):
348
200
    case _UT(')'):
349
225
    case _UT('-'):
350
252
    case _UT('*'):
351
294
    case _UT(','):
352
329
    case _UT('.'):
353
2.09k
    case _UT(':'):
354
2.12k
    case _UT(';'):
355
3.55k
    case _UT('@'):
356
3.58k
    case _UT('\''):
357
3.61k
    case _UT('_'):
358
3.64k
    case _UT('~'):
359
3.67k
    case _UT('+'):
360
3.70k
    case _UT('='):
361
36.5k
    case URI_SET_DIGIT:
362
36.5k
    case URI_SET_ALPHA:
363
5.80k
        state->uri->userInfo.first = first; /* USERINFO BEGIN */
364
5.80k
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
365
366
109
    default:
367
        /* "" regname host */
368
109
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
369
109
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
370
109
        return first;
371
9.67k
    }
372
9.67k
}
UriParse.c:uriParseAuthorityW
Line
Count
Source
324
10.2k
                                                            UriMemoryManager * memory) {
325
10.2k
    if (first >= afterLast) {
326
        /* "" regname host */
327
27
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
328
27
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
329
27
        return afterLast;
330
27
    }
331
332
10.1k
    switch (*first) {
333
4.08k
    case _UT('['): {
334
4.08k
        const URI_CHAR * const afterIpLit2 =
335
4.08k
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
336
4.08k
        if (afterIpLit2 == NULL) {
337
3.40k
            return NULL;
338
3.40k
        }
339
685
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
340
685
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
341
4.08k
    }
342
343
28
    case _UT('!'):
344
55
    case _UT('$'):
345
112
    case _UT('%'):
346
142
    case _UT('&'):
347
176
    case _UT('('):
348
204
    case _UT(')'):
349
235
    case _UT('-'):
350
261
    case _UT('*'):
351
296
    case _UT(','):
352
387
    case _UT('.'):
353
2.14k
    case _UT(':'):
354
2.17k
    case _UT(';'):
355
3.80k
    case _UT('@'):
356
3.83k
    case _UT('\''):
357
3.89k
    case _UT('_'):
358
3.90k
    case _UT('~'):
359
3.94k
    case _UT('+'):
360
3.97k
    case _UT('='):
361
39.2k
    case URI_SET_DIGIT:
362
39.2k
    case URI_SET_ALPHA:
363
5.92k
        state->uri->userInfo.first = first; /* USERINFO BEGIN */
364
5.92k
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
365
366
171
    default:
367
        /* "" regname host */
368
171
        state->uri->hostText.first = URI_FUNC(SafeToPointTo);
369
171
        state->uri->hostText.afterLast = URI_FUNC(SafeToPointTo);
370
171
        return first;
371
10.1k
    }
372
10.1k
}
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.95k
                            const URI_CHAR * afterLast) {
381
1.95k
    if (first >= afterLast) {
382
940
        return afterLast;
383
940
    }
384
385
1.01k
    switch (*first) {
386
572
    case _UT(':'): {
387
572
        const URI_CHAR * const afterPort =
388
572
            URI_FUNC(ParsePort)(state, first + 1, afterLast);
389
572
        if (afterPort == NULL) {
390
0
            return NULL;
391
0
        }
392
572
        state->uri->portText.first = first + 1; /* PORT BEGIN */
393
572
        state->uri->portText.afterLast = afterPort; /* PORT END */
394
572
        return afterPort;
395
572
    }
396
397
440
    default:
398
440
        return first;
399
1.01k
    }
400
1.01k
}
UriParse.c:uriParseAuthorityTwoA
Line
Count
Source
380
862
                            const URI_CHAR * afterLast) {
381
862
    if (first >= afterLast) {
382
484
        return afterLast;
383
484
    }
384
385
378
    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
144
    default:
398
144
        return first;
399
378
    }
400
378
}
UriParse.c:uriParseAuthorityTwoW
Line
Count
Source
380
1.09k
                            const URI_CHAR * afterLast) {
381
1.09k
    if (first >= afterLast) {
382
456
        return afterLast;
383
456
    }
384
385
634
    switch (*first) {
386
338
    case _UT(':'): {
387
338
        const URI_CHAR * const afterPort =
388
338
            URI_FUNC(ParsePort)(state, first + 1, afterLast);
389
338
        if (afterPort == NULL) {
390
0
            return NULL;
391
0
        }
392
338
        state->uri->portText.first = first + 1; /* PORT BEGIN */
393
338
        state->uri->portText.afterLast = afterPort; /* PORT END */
394
338
        return afterPort;
395
338
    }
396
397
296
    default:
398
296
        return first;
399
634
    }
400
634
}
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
79.8k
                                               const URI_CHAR * afterLast) {
409
79.8k
    if (first >= afterLast) {
410
850
        return afterLast;
411
850
    }
412
413
79.0k
    switch (*first) {
414
74.7k
    case URI_SET_HEXDIG:
415
74.7k
        return URI_FUNC(ParseHexZero)(state, first + 1, afterLast);
416
417
4.21k
    default:
418
4.21k
        return first;
419
79.0k
    }
420
79.0k
}
UriParse.c:uriParseHexZeroA
Line
Count
Source
408
68.3k
                                               const URI_CHAR * afterLast) {
409
68.3k
    if (first >= afterLast) {
410
426
        return afterLast;
411
426
    }
412
413
67.9k
    switch (*first) {
414
65.8k
    case URI_SET_HEXDIG:
415
65.8k
        return URI_FUNC(ParseHexZero)(state, first + 1, afterLast);
416
417
2.05k
    default:
418
2.05k
        return first;
419
67.9k
    }
420
67.9k
}
UriParse.c:uriParseHexZeroW
Line
Count
Source
408
11.5k
                                               const URI_CHAR * afterLast) {
409
11.5k
    if (first >= afterLast) {
410
424
        return afterLast;
411
424
    }
412
413
11.1k
    switch (*first) {
414
8.94k
    case URI_SET_HEXDIG:
415
8.94k
        return URI_FUNC(ParseHexZero)(state, first + 1, afterLast);
416
417
2.15k
    default:
418
2.15k
        return first;
419
11.1k
    }
420
11.1k
}
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.02k
                                                           UriMemoryManager * memory) {
431
2.02k
    if (first >= afterLast) {
432
315
        return afterLast;
433
315
    }
434
435
1.71k
    switch (*first) {
436
19
    case _UT('!'):
437
29
    case _UT('$'):
438
38
    case _UT('%'):
439
50
    case _UT('&'):
440
65
    case _UT('('):
441
78
    case _UT(')'):
442
112
    case _UT('-'):
443
134
    case _UT('*'):
444
149
    case _UT(','):
445
220
    case _UT('.'):
446
262
    case _UT(':'):
447
273
    case _UT(';'):
448
289
    case _UT('@'):
449
299
    case _UT('\''):
450
310
    case _UT('_'):
451
322
    case _UT('~'):
452
338
    case _UT('+'):
453
351
    case _UT('='):
454
4.23k
    case URI_SET_DIGIT:
455
4.23k
    case URI_SET_ALPHA:
456
1.28k
        return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory);
457
458
384
    case _UT('/'):
459
384
        return URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
460
461
43
    default:
462
43
        return first;
463
1.71k
    }
464
1.71k
}
UriParse.c:uriParseHierPartA
Line
Count
Source
430
1.07k
                                                           UriMemoryManager * memory) {
431
1.07k
    if (first >= afterLast) {
432
171
        return afterLast;
433
171
    }
434
435
901
    switch (*first) {
436
6
    case _UT('!'):
437
11
    case _UT('$'):
438
16
    case _UT('%'):
439
22
    case _UT('&'):
440
27
    case _UT('('):
441
36
    case _UT(')'):
442
45
    case _UT('-'):
443
62
    case _UT('*'):
444
71
    case _UT(','):
445
103
    case _UT('.'):
446
123
    case _UT(':'):
447
130
    case _UT(';'):
448
139
    case _UT('@'):
449
144
    case _UT('\''):
450
150
    case _UT('_'):
451
156
    case _UT('~'):
452
166
    case _UT('+'):
453
174
    case _UT('='):
454
2.06k
    case URI_SET_DIGIT:
455
2.06k
    case URI_SET_ALPHA:
456
694
        return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory);
457
458
185
    case _UT('/'):
459
185
        return URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
460
461
22
    default:
462
22
        return first;
463
901
    }
464
901
}
UriParse.c:uriParseHierPartW
Line
Count
Source
430
953
                                                           UriMemoryManager * memory) {
431
953
    if (first >= afterLast) {
432
144
        return afterLast;
433
144
    }
434
435
809
    switch (*first) {
436
13
    case _UT('!'):
437
18
    case _UT('$'):
438
22
    case _UT('%'):
439
28
    case _UT('&'):
440
38
    case _UT('('):
441
42
    case _UT(')'):
442
67
    case _UT('-'):
443
72
    case _UT('*'):
444
78
    case _UT(','):
445
117
    case _UT('.'):
446
139
    case _UT(':'):
447
143
    case _UT(';'):
448
150
    case _UT('@'):
449
155
    case _UT('\''):
450
160
    case _UT('_'):
451
166
    case _UT('~'):
452
172
    case _UT('+'):
453
177
    case _UT('='):
454
2.16k
    case URI_SET_DIGIT:
455
2.16k
    case URI_SET_ALPHA:
456
589
        return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory);
457
458
199
    case _UT('/'):
459
199
        return URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
460
461
21
    default:
462
21
        return first;
463
809
    }
464
809
}
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
5
        URI_FUNC(StopSyntax)(state, afterLast, memory);
477
5
        return NULL;
478
5
    }
479
480
4.71M
    switch (*first) {
481
20.9k
    case _UT('!'):
482
21.9k
    case _UT('$'):
483
26.1k
    case _UT('&'):
484
28.0k
    case _UT('('):
485
29.5k
    case _UT(')'):
486
35.2k
    case _UT('-'):
487
36.6k
    case _UT('*'):
488
38.1k
    case _UT(','):
489
67.8k
    case _UT('.'):
490
69.4k
    case _UT(':'):
491
72.1k
    case _UT(';'):
492
73.9k
    case _UT('\''):
493
75.2k
    case _UT('_'):
494
76.4k
    case _UT('~'):
495
77.8k
    case _UT('+'):
496
79.6k
    case _UT('='):
497
5.71M
    case URI_SET_DIGIT:
498
5.71M
    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.77M
                                                 UriMemoryManager * memory) {
475
3.77M
    if (first >= afterLast) {
476
3
        URI_FUNC(StopSyntax)(state, afterLast, memory);
477
3
        return NULL;
478
3
    }
479
480
3.77M
    switch (*first) {
481
20.3k
    case _UT('!'):
482
20.8k
    case _UT('$'):
483
21.8k
    case _UT('&'):
484
22.9k
    case _UT('('):
485
23.9k
    case _UT(')'):
486
28.8k
    case _UT('-'):
487
29.6k
    case _UT('*'):
488
30.4k
    case _UT(','):
489
57.8k
    case _UT('.'):
490
58.7k
    case _UT(':'):
491
60.9k
    case _UT(';'):
492
61.8k
    case _UT('\''):
493
62.6k
    case _UT('_'):
494
63.3k
    case _UT('~'):
495
64.0k
    case _UT('+'):
496
65.3k
    case _UT('='):
497
4.36M
    case URI_SET_DIGIT:
498
4.36M
    case URI_SET_ALPHA:
499
3.77M
        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.77M
    }
505
3.77M
}
UriParse.c:uriParseIpFutLoopW
Line
Count
Source
474
934k
                                                 UriMemoryManager * memory) {
475
934k
    if (first >= afterLast) {
476
2
        URI_FUNC(StopSyntax)(state, afterLast, memory);
477
2
        return NULL;
478
2
    }
479
480
934k
    switch (*first) {
481
612
    case _UT('!'):
482
1.09k
    case _UT('$'):
483
4.29k
    case _UT('&'):
484
5.11k
    case _UT('('):
485
5.62k
    case _UT(')'):
486
6.46k
    case _UT('-'):
487
6.97k
    case _UT('*'):
488
7.65k
    case _UT(','):
489
9.93k
    case _UT('.'):
490
10.6k
    case _UT(':'):
491
11.2k
    case _UT(';'):
492
12.1k
    case _UT('\''):
493
12.5k
    case _UT('_'):
494
13.1k
    case _UT('~'):
495
13.7k
    case _UT('+'):
496
14.3k
    case _UT('='):
497
1.34M
    case URI_SET_DIGIT:
498
1.34M
    case URI_SET_ALPHA:
499
934k
        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
934k
    }
505
934k
}
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.57k
        return afterLast;
517
3.57k
    }
518
519
4.70M
    switch (*first) {
520
20.8k
    case _UT('!'):
521
21.8k
    case _UT('$'):
522
25.9k
    case _UT('&'):
523
27.8k
    case _UT('('):
524
29.2k
    case _UT(')'):
525
34.9k
    case _UT('-'):
526
36.2k
    case _UT('*'):
527
37.7k
    case _UT(','):
528
67.2k
    case _UT('.'):
529
68.8k
    case _UT(':'):
530
71.5k
    case _UT(';'):
531
73.2k
    case _UT('\''):
532
74.5k
    case _UT('_'):
533
75.6k
    case _UT('~'):
534
76.9k
    case _UT('+'):
535
78.7k
    case _UT('='):
536
5.70M
    case URI_SET_DIGIT:
537
5.70M
    case URI_SET_ALPHA:
538
4.70M
        return URI_FUNC(ParseIpFutLoop)(state, first, afterLast, memory);
539
540
510
    default:
541
510
        return first;
542
4.70M
    }
543
4.70M
}
UriParse.c:uriParseIpFutStopGoA
Line
Count
Source
514
3.77M
                                                   UriMemoryManager * memory) {
515
3.77M
    if (first >= afterLast) {
516
1.80k
        return afterLast;
517
1.80k
    }
518
519
3.77M
    switch (*first) {
520
20.2k
    case _UT('!'):
521
20.8k
    case _UT('$'):
522
21.7k
    case _UT('&'):
523
22.8k
    case _UT('('):
524
23.8k
    case _UT(')'):
525
28.6k
    case _UT('-'):
526
29.4k
    case _UT('*'):
527
30.2k
    case _UT(','):
528
57.6k
    case _UT('.'):
529
58.4k
    case _UT(':'):
530
60.6k
    case _UT(';'):
531
61.5k
    case _UT('\''):
532
62.3k
    case _UT('_'):
533
62.9k
    case _UT('~'):
534
63.6k
    case _UT('+'):
535
64.9k
    case _UT('='):
536
4.36M
    case URI_SET_DIGIT:
537
4.36M
    case URI_SET_ALPHA:
538
3.77M
        return URI_FUNC(ParseIpFutLoop)(state, first, afterLast, memory);
539
540
209
    default:
541
209
        return first;
542
3.77M
    }
543
3.77M
}
UriParse.c:uriParseIpFutStopGoW
Line
Count
Source
514
934k
                                                   UriMemoryManager * memory) {
515
934k
    if (first >= afterLast) {
516
1.76k
        return afterLast;
517
1.76k
    }
518
519
932k
    switch (*first) {
520
588
    case _UT('!'):
521
1.04k
    case _UT('$'):
522
4.19k
    case _UT('&'):
523
5.00k
    case _UT('('):
524
5.49k
    case _UT(')'):
525
6.30k
    case _UT('-'):
526
6.78k
    case _UT('*'):
527
7.43k
    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
13.8k
    case _UT('='):
536
1.34M
    case URI_SET_DIGIT:
537
1.34M
    case URI_SET_ALPHA:
538
932k
        return URI_FUNC(ParseIpFutLoop)(state, first, afterLast, memory);
539
540
301
    default:
541
301
        return first;
542
932k
    }
543
932k
}
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.08k
                                                UriMemoryManager * memory) {
552
5.08k
    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.08k
    if (afterLast - first < 2) {
566
11
        URI_FUNC(StopSyntax)(state, afterLast, memory);
567
11
        return NULL;
568
11
    }
569
570
5.07k
    switch (first[1]) {
571
61.1k
    case URI_SET_HEXDIG: {
572
61.1k
        const URI_CHAR * afterIpFutLoop;
573
61.1k
        const URI_CHAR * const afterHexZero =
574
61.1k
            URI_FUNC(ParseHexZero)(state, first + 2, afterLast);
575
61.1k
        if (afterHexZero == NULL) {
576
0
            return NULL;
577
0
        }
578
5.06k
        if (afterHexZero >= afterLast) {
579
850
            URI_FUNC(StopSyntax)(state, afterLast, memory);
580
850
            return NULL;
581
850
        }
582
4.21k
        if (*afterHexZero != _UT('.')) {
583
119
            URI_FUNC(StopSyntax)(state, afterHexZero, memory);
584
119
            return NULL;
585
119
        }
586
4.09k
        state->uri->hostText.first = first; /* HOST BEGIN */
587
4.09k
        state->uri->hostData.ipFuture.first = first; /* IPFUTURE BEGIN */
588
4.09k
        afterIpFutLoop =
589
4.09k
            URI_FUNC(ParseIpFutLoop)(state, afterHexZero + 1, afterLast, memory);
590
4.09k
        if (afterIpFutLoop == NULL) {
591
9
            return NULL;
592
9
        }
593
4.08k
        state->uri->hostText.afterLast = afterIpFutLoop; /* HOST END */
594
4.08k
        state->uri->hostData.ipFuture.afterLast = afterIpFutLoop; /* IPFUTURE END */
595
4.08k
        return afterIpFutLoop;
596
4.09k
    }
597
598
17
    default:
599
17
        URI_FUNC(StopSyntax)(state, first + 1, memory);
600
17
        return NULL;
601
5.07k
    }
602
603
    /*
604
    default:
605
            URI_FUNC(StopSyntax)(state, first, memory);
606
            return NULL;
607
    }
608
    */
609
5.07k
}
UriParse.c:uriParseIpFutureA
Line
Count
Source
551
2.49k
                                                UriMemoryManager * memory) {
552
2.49k
    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.49k
    if (afterLast - first < 2) {
566
5
        URI_FUNC(StopSyntax)(state, afterLast, memory);
567
5
        return NULL;
568
5
    }
569
570
2.48k
    switch (first[1]) {
571
27.2k
    case URI_SET_HEXDIG: {
572
27.2k
        const URI_CHAR * afterIpFutLoop;
573
27.2k
        const URI_CHAR * const afterHexZero =
574
27.2k
            URI_FUNC(ParseHexZero)(state, first + 2, afterLast);
575
27.2k
        if (afterHexZero == NULL) {
576
0
            return NULL;
577
0
        }
578
2.48k
        if (afterHexZero >= afterLast) {
579
426
            URI_FUNC(StopSyntax)(state, afterLast, memory);
580
426
            return NULL;
581
426
        }
582
2.05k
        if (*afterHexZero != _UT('.')) {
583
34
            URI_FUNC(StopSyntax)(state, afterHexZero, memory);
584
34
            return NULL;
585
34
        }
586
2.02k
        state->uri->hostText.first = first; /* HOST BEGIN */
587
2.02k
        state->uri->hostData.ipFuture.first = first; /* IPFUTURE BEGIN */
588
2.02k
        afterIpFutLoop =
589
2.02k
            URI_FUNC(ParseIpFutLoop)(state, afterHexZero + 1, afterLast, memory);
590
2.02k
        if (afterIpFutLoop == NULL) {
591
5
            return NULL;
592
5
        }
593
2.01k
        state->uri->hostText.afterLast = afterIpFutLoop; /* HOST END */
594
2.01k
        state->uri->hostData.ipFuture.afterLast = afterIpFutLoop; /* IPFUTURE END */
595
2.01k
        return afterIpFutLoop;
596
2.02k
    }
597
598
5
    default:
599
5
        URI_FUNC(StopSyntax)(state, first + 1, memory);
600
5
        return NULL;
601
2.48k
    }
602
603
    /*
604
    default:
605
            URI_FUNC(StopSyntax)(state, first, memory);
606
            return NULL;
607
    }
608
    */
609
2.48k
}
UriParse.c:uriParseIpFutureW
Line
Count
Source
551
2.59k
                                                UriMemoryManager * memory) {
552
2.59k
    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.59k
    if (afterLast - first < 2) {
566
6
        URI_FUNC(StopSyntax)(state, afterLast, memory);
567
6
        return NULL;
568
6
    }
569
570
2.59k
    switch (first[1]) {
571
33.9k
    case URI_SET_HEXDIG: {
572
33.9k
        const URI_CHAR * afterIpFutLoop;
573
33.9k
        const URI_CHAR * const afterHexZero =
574
33.9k
            URI_FUNC(ParseHexZero)(state, first + 2, afterLast);
575
33.9k
        if (afterHexZero == NULL) {
576
0
            return NULL;
577
0
        }
578
2.58k
        if (afterHexZero >= afterLast) {
579
424
            URI_FUNC(StopSyntax)(state, afterLast, memory);
580
424
            return NULL;
581
424
        }
582
2.15k
        if (*afterHexZero != _UT('.')) {
583
85
            URI_FUNC(StopSyntax)(state, afterHexZero, memory);
584
85
            return NULL;
585
85
        }
586
2.07k
        state->uri->hostText.first = first; /* HOST BEGIN */
587
2.07k
        state->uri->hostData.ipFuture.first = first; /* IPFUTURE BEGIN */
588
2.07k
        afterIpFutLoop =
589
2.07k
            URI_FUNC(ParseIpFutLoop)(state, afterHexZero + 1, afterLast, memory);
590
2.07k
        if (afterIpFutLoop == NULL) {
591
4
            return NULL;
592
4
        }
593
2.06k
        state->uri->hostText.afterLast = afterIpFutLoop; /* HOST END */
594
2.06k
        state->uri->hostData.ipFuture.afterLast = afterIpFutLoop; /* IPFUTURE END */
595
2.06k
        return afterIpFutLoop;
596
2.07k
    }
597
598
12
    default:
599
12
        URI_FUNC(StopSyntax)(state, first + 1, memory);
600
12
        return NULL;
601
2.59k
    }
602
603
    /*
604
    default:
605
            URI_FUNC(StopSyntax)(state, first, memory);
606
            return NULL;
607
    }
608
    */
609
2.59k
}
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.19k
                                                         UriMemoryManager * memory) {
619
8.19k
    if (first >= afterLast) {
620
11
        URI_FUNC(StopSyntax)(state, afterLast, memory);
621
11
        return NULL;
622
11
    }
623
624
8.18k
    switch (*first) {
625
    /* The leading "v" of IPvFuture is case-insensitive. */
626
3.24k
    case _UT('v'):
627
5.08k
    case _UT('V'): {
628
5.08k
        const URI_CHAR * const afterIpFuture =
629
5.08k
            URI_FUNC(ParseIpFuture)(state, first, afterLast, memory);
630
5.08k
        if (afterIpFuture == NULL) {
631
1.00k
            return NULL;
632
1.00k
        }
633
4.08k
        if (afterIpFuture >= afterLast) {
634
3.57k
            URI_FUNC(StopSyntax)(state, afterLast, memory);
635
3.57k
            return NULL;
636
3.57k
        }
637
510
        if (*afterIpFuture != _UT(']')) {
638
186
            URI_FUNC(StopSyntax)(state, afterIpFuture, memory);
639
186
            return NULL;
640
186
        }
641
324
        return afterIpFuture + 1;
642
510
    }
643
644
1.89k
    case _UT(':'):
645
1.89k
    case _UT(']'):
646
54.8k
    case URI_SET_HEXDIG:
647
54.8k
        state->uri->hostData.ip6 = memory->malloc(
648
54.8k
            memory, 1 * sizeof(UriIp6)); /* Freed when stopping on parse error */
649
54.8k
        if (state->uri->hostData.ip6 == NULL) {
650
0
            URI_FUNC(StopMalloc)(state, memory);
651
0
            return NULL;
652
0
        }
653
3.08k
        return URI_FUNC(ParseIPv6address2)(state, first, afterLast, memory);
654
655
4
    default:
656
4
        URI_FUNC(StopSyntax)(state, first, memory);
657
4
        return NULL;
658
8.18k
    }
659
8.18k
}
UriParse.c:uriParseIpLit2A
Line
Count
Source
618
3.89k
                                                         UriMemoryManager * memory) {
619
3.89k
    if (first >= afterLast) {
620
6
        URI_FUNC(StopSyntax)(state, afterLast, memory);
621
6
        return NULL;
622
6
    }
623
624
3.88k
    switch (*first) {
625
    /* The leading "v" of IPvFuture is case-insensitive. */
626
1.51k
    case _UT('v'):
627
2.49k
    case _UT('V'): {
628
2.49k
        const URI_CHAR * const afterIpFuture =
629
2.49k
            URI_FUNC(ParseIpFuture)(state, first, afterLast, memory);
630
2.49k
        if (afterIpFuture == NULL) {
631
475
            return NULL;
632
475
        }
633
2.01k
        if (afterIpFuture >= afterLast) {
634
1.80k
            URI_FUNC(StopSyntax)(state, afterLast, memory);
635
1.80k
            return NULL;
636
1.80k
        }
637
209
        if (*afterIpFuture != _UT(']')) {
638
52
            URI_FUNC(StopSyntax)(state, afterIpFuture, memory);
639
52
            return NULL;
640
52
        }
641
157
        return afterIpFuture + 1;
642
209
    }
643
644
803
    case _UT(':'):
645
806
    case _UT(']'):
646
23.9k
    case URI_SET_HEXDIG:
647
23.9k
        state->uri->hostData.ip6 = memory->malloc(
648
23.9k
            memory, 1 * sizeof(UriIp6)); /* Freed when stopping on parse error */
649
23.9k
        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.88k
    }
659
3.88k
}
UriParse.c:uriParseIpLit2W
Line
Count
Source
618
4.29k
                                                         UriMemoryManager * memory) {
619
4.29k
    if (first >= afterLast) {
620
5
        URI_FUNC(StopSyntax)(state, afterLast, memory);
621
5
        return NULL;
622
5
    }
623
624
4.29k
    switch (*first) {
625
    /* The leading "v" of IPvFuture is case-insensitive. */
626
1.72k
    case _UT('v'):
627
2.59k
    case _UT('V'): {
628
2.59k
        const URI_CHAR * const afterIpFuture =
629
2.59k
            URI_FUNC(ParseIpFuture)(state, first, afterLast, memory);
630
2.59k
        if (afterIpFuture == NULL) {
631
531
            return NULL;
632
531
        }
633
2.06k
        if (afterIpFuture >= afterLast) {
634
1.76k
            URI_FUNC(StopSyntax)(state, afterLast, memory);
635
1.76k
            return NULL;
636
1.76k
        }
637
301
        if (*afterIpFuture != _UT(']')) {
638
134
            URI_FUNC(StopSyntax)(state, afterIpFuture, memory);
639
134
            return NULL;
640
134
        }
641
167
        return afterIpFuture + 1;
642
301
    }
643
644
1.09k
    case _UT(':'):
645
1.09k
    case _UT(']'):
646
30.9k
    case URI_SET_HEXDIG:
647
30.9k
        state->uri->hostData.ip6 = memory->malloc(
648
30.9k
            memory, 1 * sizeof(UriIp6)); /* Freed when stopping on parse error */
649
30.9k
        if (state->uri->hostData.ip6 == NULL) {
650
0
            URI_FUNC(StopMalloc)(state, memory);
651
0
            return NULL;
652
0
        }
653
1.69k
        return URI_FUNC(ParseIPv6address2)(state, first, afterLast, memory);
654
655
2
    default:
656
2
        URI_FUNC(StopSyntax)(state, first, memory);
657
        return NULL;
658
4.29k
    }
659
4.29k
}
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.08k
                                                    UriMemoryManager * memory) {
668
3.08k
    int zipperEver = 0;
669
3.08k
    int quadsDone = 0;
670
3.08k
    int digitCount = 0;
671
3.08k
    unsigned char digitHistory[4];
672
3.08k
    int ip4OctetsDone = 0;
673
674
3.08k
    unsigned char quadsAfterZipper[14];
675
3.08k
    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.74k
            for (;;) {
687
2.74k
                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.97k
                    digitHistory[digitCount++] = (unsigned char)(9 + *first - _UT('9'));
694
1.97k
                    break;
695
696
600
                case _UT('.'):
697
600
                    if ((ip4OctetsDone == 4) /* NOTE! */
698
595
                        || (digitCount == 0) || (digitCount == 4)) {
699
                        /* Invalid digit or octet count */
700
17
                        URI_FUNC(StopSyntax)(state, first, memory);
701
17
                        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
46
                        if (digitHistory[0] > 2) {
712
28
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
713
28
                        } else if (digitHistory[1] > 5) {
714
13
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
715
13
                        } else {
716
5
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
717
5
                        }
718
46
                        return NULL;
719
46
                    }
720
721
                    /* Copy IPv4 octet */
722
533
                    state->uri->hostData.ip6->data[16 - 4 + ip4OctetsDone] =
723
533
                        uriGetOctetValue(digitHistory, digitCount);
724
533
                    digitCount = 0;
725
533
                    ip4OctetsDone++;
726
533
                    break;
727
728
125
                case _UT(']'):
729
125
                    if ((ip4OctetsDone != 3) /* NOTE! */
730
114
                        || (digitCount == 0) || (digitCount == 4)) {
731
                        /* Invalid digit or octet count */
732
19
                        URI_FUNC(StopSyntax)(state, first, memory);
733
19
                        return NULL;
734
106
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
735
                        /* Leading zero */
736
5
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
737
5
                        return NULL;
738
101
                    } else if ((digitCount == 3)
739
68
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
740
68
                                       + digitHistory[2]
741
68
                                   > 255)) {
742
                        /* Octet value too large */
743
33
                        if (digitHistory[0] > 2) {
744
18
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
745
18
                        } else if (digitHistory[1] > 5) {
746
11
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
747
11
                        } else {
748
4
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
749
4
                        }
750
33
                        return NULL;
751
33
                    }
752
753
68
                    state->uri->hostText.afterLast = first; /* HOST END */
754
755
                    /* Copy missing quads right before IPv4 */
756
68
                    memcpy(state->uri->hostData.ip6->data + 16 - 4
757
68
                               - 2 * quadsAfterZipperCount,
758
68
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
759
760
                    /* Copy last IPv4 octet */
761
68
                    state->uri->hostData.ip6->data[16 - 4 + 3] =
762
68
                        uriGetOctetValue(digitHistory, digitCount);
763
764
68
                    return first + 1;
765
766
19
                default:
767
19
                    URI_FUNC(StopSyntax)(state, first, memory);
768
19
                    return NULL;
769
2.74k
                }
770
2.50k
                first++;
771
772
2.50k
                if (first >= afterLast) {
773
284
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
774
284
                    return NULL;
775
284
                }
776
2.50k
            }
777
3.08k
        } else {
778
            /* Eat while no dot in sight */
779
3.08k
            int letterAmong = 0;
780
3.08k
            int walking = 1;
781
15.7k
            do {
782
15.7k
                switch (*first) {
783
5.98k
                case URI_SET_HEX_LETTER_LOWER:
784
5.98k
                    letterAmong = 1;
785
5.98k
                    if (digitCount == 4) {
786
28
                        URI_FUNC(StopSyntax)(state, first, memory);
787
28
                        return NULL;
788
28
                    }
789
1.90k
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('f'));
790
1.90k
                    digitCount++;
791
1.90k
                    break;
792
793
7.49k
                case URI_SET_HEX_LETTER_UPPER:
794
7.49k
                    letterAmong = 1;
795
7.49k
                    if (digitCount == 4) {
796
26
                        URI_FUNC(StopSyntax)(state, first, memory);
797
26
                        return NULL;
798
26
                    }
799
2.25k
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('F'));
800
2.25k
                    digitCount++;
801
2.25k
                    break;
802
803
29.6k
                case URI_SET_DIGIT:
804
29.6k
                    if (digitCount == 4) {
805
56
                        URI_FUNC(StopSyntax)(state, first, memory);
806
56
                        return NULL;
807
56
                    }
808
5.00k
                    digitHistory[digitCount] = (unsigned char)(9 + *first - _UT('9'));
809
5.00k
                    digitCount++;
810
5.00k
                    break;
811
812
4.27k
                case _UT(':'): {
813
4.27k
                    int setZipper = 0;
814
815
4.27k
                    if (digitCount > 0) {
816
2.37k
                        if (zipperEver) {
817
328
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
818
328
                                                     quadsAfterZipper
819
328
                                                         + 2 * quadsAfterZipperCount);
820
328
                            quadsAfterZipperCount++;
821
2.04k
                        } else {
822
2.04k
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
823
2.04k
                                                     state->uri->hostData.ip6->data
824
2.04k
                                                         + 2 * quadsDone);
825
2.04k
                        }
826
2.37k
                        quadsDone++;
827
2.37k
                        digitCount = 0;
828
2.37k
                    }
829
4.27k
                    letterAmong = 0;
830
831
                    /* Too many quads? */
832
4.27k
                    if (quadsDone >= 8 - zipperEver) {
833
21
                        URI_FUNC(StopSyntax)(state, first, memory);
834
21
                        return NULL;
835
21
                    }
836
837
                    /* "::"? */
838
4.25k
                    if (afterLast - first < 2) {
839
92
                        URI_FUNC(StopSyntax)(state, afterLast, memory);
840
92
                        return NULL;
841
92
                    }
842
4.15k
                    if (first[1] == _UT(':')) {
843
2.04k
                        const int resetOffset = 2 * (quadsDone + (digitCount > 0));
844
845
2.04k
                        first++;
846
2.04k
                        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.03k
                        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
113
                        URI_FUNC(StopSyntax)(state, first, memory);
868
113
                        return NULL;
869
113
                    }
870
871
4.03k
                    if (setZipper) {
872
2.03k
                        zipperEver = 1;
873
2.03k
                    }
874
4.03k
                } break;
875
876
670
                case _UT('.'):
877
670
                    if ((quadsDone + zipperEver > 6) /* NOTE */
878
666
                        || (!zipperEver && (quadsDone < 6)) || letterAmong
879
642
                        || (digitCount == 0) || (digitCount == 4)) {
880
                        /* Invalid octet before */
881
53
                        URI_FUNC(StopSyntax)(state, first, memory);
882
53
                        return NULL;
883
617
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
884
                        /* Leading zero */
885
4
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
886
4
                        return NULL;
887
613
                    } else if ((digitCount == 3)
888
91
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
889
91
                                       + digitHistory[2]
890
91
                                   > 255)) {
891
                        /* Octet value too large */
892
35
                        if (digitHistory[0] > 2) {
893
18
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
894
18
                        } else if (digitHistory[1] > 5) {
895
12
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
896
12
                        } else {
897
5
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
898
5
                        }
899
35
                        return NULL;
900
35
                    }
901
902
                    /* Copy first IPv4 octet */
903
578
                    state->uri->hostData.ip6->data[16 - 4] =
904
578
                        uriGetOctetValue(digitHistory, digitCount);
905
578
                    digitCount = 0;
906
907
                    /* Switch over to IPv4 loop */
908
578
                    ip4OctetsDone = 1;
909
578
                    walking = 0;
910
578
                    break;
911
912
1.26k
                case _UT(']'):
913
                    /* Too little quads? */
914
1.26k
                    if (!zipperEver && !((quadsDone == 7) && (digitCount > 0))) {
915
15
                        URI_FUNC(StopSyntax)(state, first, memory);
916
15
                        return NULL;
917
15
                    }
918
919
1.25k
                    if (digitCount > 0) {
920
268
                        if (zipperEver) {
921
                            /* Too many quads? */
922
248
                            if (quadsDone >= 7) {
923
4
                                URI_FUNC(StopSyntax)(state, first, memory);
924
4
                                return NULL;
925
4
                            }
926
244
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
927
244
                                                     quadsAfterZipper
928
244
                                                         + 2 * quadsAfterZipperCount);
929
244
                            quadsAfterZipperCount++;
930
244
                        } 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
268
                    }
940
941
                    /* Copy missing quads to the end */
942
1.24k
                    memcpy(state->uri->hostData.ip6->data + 16
943
1.24k
                               - 2 * quadsAfterZipperCount,
944
1.24k
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
945
946
1.24k
                    state->uri->hostText.afterLast = first; /* HOST END */
947
1.24k
                    return first + 1; /* Fine */
948
949
236
                default:
950
236
                    URI_FUNC(StopSyntax)(state, first, memory);
951
236
                    return NULL;
952
15.7k
                }
953
13.7k
                first++;
954
955
13.7k
                if (first >= afterLast) {
956
624
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
957
624
                    return NULL; /* No ']' yet */
958
624
                }
959
13.7k
            } while (walking);
960
3.08k
        }
961
3.61k
    }
962
3.08k
}
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.42k
            for (;;) {
687
1.42k
                switch (*first) {
688
6.29k
                case URI_SET_DIGIT:
689
6.29k
                    if (digitCount == 4) {
690
17
                        URI_FUNC(StopSyntax)(state, first, memory);
691
17
                        return NULL;
692
17
                    }
693
1.02k
                    digitHistory[digitCount++] = (unsigned char)(9 + *first - _UT('9'));
694
1.02k
                    break;
695
696
310
                case _UT('.'):
697
310
                    if ((ip4OctetsDone == 4) /* NOTE! */
698
308
                        || (digitCount == 0) || (digitCount == 4)) {
699
                        /* Invalid digit or octet count */
700
8
                        URI_FUNC(StopSyntax)(state, first, memory);
701
8
                        return NULL;
702
302
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
703
                        /* Leading zero */
704
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
705
2
                        return NULL;
706
300
                    } else if ((digitCount == 3)
707
89
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
708
89
                                       + digitHistory[2]
709
89
                                   > 255)) {
710
                        /* Octet value too large */
711
27
                        if (digitHistory[0] > 2) {
712
18
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
713
18
                        } 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
27
                        return NULL;
719
27
                    }
720
721
                    /* Copy IPv4 octet */
722
273
                    state->uri->hostData.ip6->data[16 - 4 + ip4OctetsDone] =
723
273
                        uriGetOctetValue(digitHistory, digitCount);
724
273
                    digitCount = 0;
725
273
                    ip4OctetsDone++;
726
273
                    break;
727
728
66
                case _UT(']'):
729
66
                    if ((ip4OctetsDone != 3) /* NOTE! */
730
60
                        || (digitCount == 0) || (digitCount == 4)) {
731
                        /* Invalid digit or octet count */
732
10
                        URI_FUNC(StopSyntax)(state, first, memory);
733
10
                        return NULL;
734
56
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
735
                        /* Leading zero */
736
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
737
2
                        return NULL;
738
54
                    } else if ((digitCount == 3)
739
36
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
740
36
                                       + digitHistory[2]
741
36
                                   > 255)) {
742
                        /* Octet value too large */
743
17
                        if (digitHistory[0] > 2) {
744
11
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
745
11
                        } else if (digitHistory[1] > 5) {
746
4
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
747
4
                        } else {
748
2
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
749
2
                        }
750
17
                        return NULL;
751
17
                    }
752
753
37
                    state->uri->hostText.afterLast = first; /* HOST END */
754
755
                    /* Copy missing quads right before IPv4 */
756
37
                    memcpy(state->uri->hostData.ip6->data + 16 - 4
757
37
                               - 2 * quadsAfterZipperCount,
758
37
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
759
760
                    /* Copy last IPv4 octet */
761
37
                    state->uri->hostData.ip6->data[16 - 4 + 3] =
762
37
                        uriGetOctetValue(digitHistory, digitCount);
763
764
37
                    return first + 1;
765
766
10
                default:
767
10
                    URI_FUNC(StopSyntax)(state, first, memory);
768
10
                    return NULL;
769
1.42k
                }
770
1.29k
                first++;
771
772
1.29k
                if (first >= afterLast) {
773
141
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
774
141
                    return NULL;
775
141
                }
776
1.29k
            }
777
1.39k
        } else {
778
            /* Eat while no dot in sight */
779
1.39k
            int letterAmong = 0;
780
1.39k
            int walking = 1;
781
8.05k
            do {
782
8.05k
                switch (*first) {
783
3.35k
                case URI_SET_HEX_LETTER_LOWER:
784
3.35k
                    letterAmong = 1;
785
3.35k
                    if (digitCount == 4) {
786
18
                        URI_FUNC(StopSyntax)(state, first, memory);
787
18
                        return NULL;
788
18
                    }
789
1.06k
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('f'));
790
1.06k
                    digitCount++;
791
1.06k
                    break;
792
793
4.19k
                case URI_SET_HEX_LETTER_UPPER:
794
4.19k
                    letterAmong = 1;
795
4.19k
                    if (digitCount == 4) {
796
16
                        URI_FUNC(StopSyntax)(state, first, memory);
797
16
                        return NULL;
798
16
                    }
799
1.29k
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('F'));
800
1.29k
                    digitCount++;
801
1.29k
                    break;
802
803
15.2k
                case URI_SET_DIGIT:
804
15.2k
                    if (digitCount == 4) {
805
34
                        URI_FUNC(StopSyntax)(state, first, memory);
806
34
                        return NULL;
807
34
                    }
808
2.59k
                    digitHistory[digitCount] = (unsigned char)(9 + *first - _UT('9'));
809
2.59k
                    digitCount++;
810
2.59k
                    break;
811
812
2.07k
                case _UT(':'): {
813
2.07k
                    int setZipper = 0;
814
815
2.07k
                    if (digitCount > 0) {
816
1.26k
                        if (zipperEver) {
817
184
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
818
184
                                                     quadsAfterZipper
819
184
                                                         + 2 * quadsAfterZipperCount);
820
184
                            quadsAfterZipperCount++;
821
1.08k
                        } else {
822
1.08k
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
823
1.08k
                                                     state->uri->hostData.ip6->data
824
1.08k
                                                         + 2 * quadsDone);
825
1.08k
                        }
826
1.26k
                        quadsDone++;
827
1.26k
                        digitCount = 0;
828
1.26k
                    }
829
2.07k
                    letterAmong = 0;
830
831
                    /* Too many quads? */
832
2.07k
                    if (quadsDone >= 8 - zipperEver) {
833
12
                        URI_FUNC(StopSyntax)(state, first, memory);
834
12
                        return NULL;
835
12
                    }
836
837
                    /* "::"? */
838
2.05k
                    if (afterLast - first < 2) {
839
46
                        URI_FUNC(StopSyntax)(state, afterLast, memory);
840
46
                        return NULL;
841
46
                    }
842
2.01k
                    if (first[1] == _UT(':')) {
843
925
                        const int resetOffset = 2 * (quadsDone + (digitCount > 0));
844
845
925
                        first++;
846
925
                        if (zipperEver) {
847
2
                            URI_FUNC(StopSyntax)(state, first, memory);
848
2
                            return NULL; /* "::.+::" */
849
2
                        }
850
851
                        /* Zero everything after zipper */
852
923
                        memset(state->uri->hostData.ip6->data + resetOffset, 0,
853
923
                               16 - resetOffset);
854
923
                        setZipper = 1;
855
856
                        /* ":::+"? */
857
923
                        if (afterLast - first < 2) {
858
2
                            URI_FUNC(StopSyntax)(state, afterLast, memory);
859
2
                            return NULL; /* No ']' yet */
860
2
                        }
861
921
                        if (first[1] == _UT(':')) {
862
2
                            URI_FUNC(StopSyntax)(state, first + 1, memory);
863
2
                            return NULL; /* ":::+ "*/
864
2
                        }
865
1.08k
                    } else if (quadsDone == 0 || first[1] == _UT(']')) {
866
                        /* Single leading or trailing ":" */
867
24
                        URI_FUNC(StopSyntax)(state, first, memory);
868
24
                        return NULL;
869
24
                    }
870
871
1.98k
                    if (setZipper) {
872
919
                        zipperEver = 1;
873
919
                    }
874
1.98k
                } break;
875
876
348
                case _UT('.'):
877
348
                    if ((quadsDone + zipperEver > 6) /* NOTE */
878
346
                        || (!zipperEver && (quadsDone < 6)) || letterAmong
879
332
                        || (digitCount == 0) || (digitCount == 4)) {
880
                        /* Invalid octet before */
881
30
                        URI_FUNC(StopSyntax)(state, first, memory);
882
30
                        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
11
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
894
11
                        } else if (digitHistory[1] > 5) {
895
6
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
896
6
                        } else {
897
2
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
898
2
                        }
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
568
                case _UT(']'):
913
                    /* Too little quads? */
914
568
                    if (!zipperEver && !((quadsDone == 7) && (digitCount > 0))) {
915
7
                        URI_FUNC(StopSyntax)(state, first, memory);
916
7
                        return NULL;
917
7
                    }
918
919
561
                    if (digitCount > 0) {
920
164
                        if (zipperEver) {
921
                            /* Too many quads? */
922
152
                            if (quadsDone >= 7) {
923
2
                                URI_FUNC(StopSyntax)(state, first, memory);
924
2
                                return NULL;
925
2
                            }
926
150
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
927
150
                                                     quadsAfterZipper
928
150
                                                         + 2 * quadsAfterZipperCount);
929
150
                            quadsAfterZipperCount++;
930
150
                        } 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
164
                    }
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
46
                default:
950
46
                    URI_FUNC(StopSyntax)(state, first, memory);
951
46
                    return NULL;
952
8.05k
                }
953
7.23k
                first++;
954
955
7.23k
                if (first >= afterLast) {
956
304
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
957
304
                    return NULL; /* No ']' yet */
958
304
                }
959
7.23k
            } while (walking);
960
1.39k
        }
961
1.66k
    }
962
1.39k
}
UriParse.c:uriParseIPv6address2W
Line
Count
Source
667
1.69k
                                                    UriMemoryManager * memory) {
668
1.69k
    int zipperEver = 0;
669
1.69k
    int quadsDone = 0;
670
1.69k
    int digitCount = 0;
671
1.69k
    unsigned char digitHistory[4];
672
1.69k
    int ip4OctetsDone = 0;
673
674
1.69k
    unsigned char quadsAfterZipper[14];
675
1.69k
    int quadsAfterZipperCount = 0;
676
677
1.94k
    for (;;) {
678
1.94k
        if (first >= afterLast) {
679
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
680
0
            return NULL;
681
0
        }
682
683
        /* Inside IPv4 part? */
684
1.94k
        if (ip4OctetsDone > 0) {
685
            /* Eat rest of IPv4 address */
686
1.32k
            for (;;) {
687
1.32k
                switch (*first) {
688
5.70k
                case URI_SET_DIGIT:
689
5.70k
                    if (digitCount == 4) {
690
12
                        URI_FUNC(StopSyntax)(state, first, memory);
691
12
                        return NULL;
692
12
                    }
693
954
                    digitHistory[digitCount++] = (unsigned char)(9 + *first - _UT('9'));
694
954
                    break;
695
696
290
                case _UT('.'):
697
290
                    if ((ip4OctetsDone == 4) /* NOTE! */
698
287
                        || (digitCount == 0) || (digitCount == 4)) {
699
                        /* Invalid digit or octet count */
700
9
                        URI_FUNC(StopSyntax)(state, first, memory);
701
9
                        return NULL;
702
281
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
703
                        /* Leading zero */
704
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
705
2
                        return NULL;
706
279
                    } else if ((digitCount == 3)
707
78
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
708
78
                                       + digitHistory[2]
709
78
                                   > 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
6
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
715
6
                        } else {
716
3
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
717
3
                        }
718
19
                        return NULL;
719
19
                    }
720
721
                    /* Copy IPv4 octet */
722
260
                    state->uri->hostData.ip6->data[16 - 4 + ip4OctetsDone] =
723
260
                        uriGetOctetValue(digitHistory, digitCount);
724
260
                    digitCount = 0;
725
260
                    ip4OctetsDone++;
726
260
                    break;
727
728
59
                case _UT(']'):
729
59
                    if ((ip4OctetsDone != 3) /* NOTE! */
730
54
                        || (digitCount == 0) || (digitCount == 4)) {
731
                        /* Invalid digit or octet count */
732
9
                        URI_FUNC(StopSyntax)(state, first, memory);
733
9
                        return NULL;
734
50
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
735
                        /* Leading zero */
736
3
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
737
3
                        return NULL;
738
47
                    } else if ((digitCount == 3)
739
32
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
740
32
                                       + digitHistory[2]
741
32
                                   > 255)) {
742
                        /* Octet value too large */
743
16
                        if (digitHistory[0] > 2) {
744
7
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
745
9
                        } else if (digitHistory[1] > 5) {
746
7
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
747
7
                        } else {
748
2
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
749
2
                        }
750
16
                        return NULL;
751
16
                    }
752
753
31
                    state->uri->hostText.afterLast = first; /* HOST END */
754
755
                    /* Copy missing quads right before IPv4 */
756
31
                    memcpy(state->uri->hostData.ip6->data + 16 - 4
757
31
                               - 2 * quadsAfterZipperCount,
758
31
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
759
760
                    /* Copy last IPv4 octet */
761
31
                    state->uri->hostData.ip6->data[16 - 4 + 3] =
762
31
                        uriGetOctetValue(digitHistory, digitCount);
763
764
31
                    return first + 1;
765
766
9
                default:
767
9
                    URI_FUNC(StopSyntax)(state, first, memory);
768
9
                    return NULL;
769
1.32k
                }
770
1.21k
                first++;
771
772
1.21k
                if (first >= afterLast) {
773
143
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
774
143
                    return NULL;
775
143
                }
776
1.21k
            }
777
1.69k
        } else {
778
            /* Eat while no dot in sight */
779
1.69k
            int letterAmong = 0;
780
1.69k
            int walking = 1;
781
7.65k
            do {
782
7.65k
                switch (*first) {
783
2.63k
                case URI_SET_HEX_LETTER_LOWER:
784
2.63k
                    letterAmong = 1;
785
2.63k
                    if (digitCount == 4) {
786
10
                        URI_FUNC(StopSyntax)(state, first, memory);
787
10
                        return NULL;
788
10
                    }
789
843
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('f'));
790
843
                    digitCount++;
791
843
                    break;
792
793
3.30k
                case URI_SET_HEX_LETTER_UPPER:
794
3.30k
                    letterAmong = 1;
795
3.30k
                    if (digitCount == 4) {
796
10
                        URI_FUNC(StopSyntax)(state, first, memory);
797
10
                        return NULL;
798
10
                    }
799
959
                    digitHistory[digitCount] = (unsigned char)(15 + *first - _UT('F'));
800
959
                    digitCount++;
801
959
                    break;
802
803
14.3k
                case URI_SET_DIGIT:
804
14.3k
                    if (digitCount == 4) {
805
22
                        URI_FUNC(StopSyntax)(state, first, memory);
806
22
                        return NULL;
807
22
                    }
808
2.40k
                    digitHistory[digitCount] = (unsigned char)(9 + *first - _UT('9'));
809
2.40k
                    digitCount++;
810
2.40k
                    break;
811
812
2.20k
                case _UT(':'): {
813
2.20k
                    int setZipper = 0;
814
815
2.20k
                    if (digitCount > 0) {
816
1.10k
                        if (zipperEver) {
817
144
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
818
144
                                                     quadsAfterZipper
819
144
                                                         + 2 * quadsAfterZipperCount);
820
144
                            quadsAfterZipperCount++;
821
965
                        } else {
822
965
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
823
965
                                                     state->uri->hostData.ip6->data
824
965
                                                         + 2 * quadsDone);
825
965
                        }
826
1.10k
                        quadsDone++;
827
1.10k
                        digitCount = 0;
828
1.10k
                    }
829
2.20k
                    letterAmong = 0;
830
831
                    /* Too many quads? */
832
2.20k
                    if (quadsDone >= 8 - zipperEver) {
833
9
                        URI_FUNC(StopSyntax)(state, first, memory);
834
9
                        return NULL;
835
9
                    }
836
837
                    /* "::"? */
838
2.19k
                    if (afterLast - first < 2) {
839
46
                        URI_FUNC(StopSyntax)(state, afterLast, memory);
840
46
                        return NULL;
841
46
                    }
842
2.14k
                    if (first[1] == _UT(':')) {
843
1.11k
                        const int resetOffset = 2 * (quadsDone + (digitCount > 0));
844
845
1.11k
                        first++;
846
1.11k
                        if (zipperEver) {
847
2
                            URI_FUNC(StopSyntax)(state, first, memory);
848
2
                            return NULL; /* "::.+::" */
849
2
                        }
850
851
                        /* Zero everything after zipper */
852
1.11k
                        memset(state->uri->hostData.ip6->data + resetOffset, 0,
853
1.11k
                               16 - resetOffset);
854
1.11k
                        setZipper = 1;
855
856
                        /* ":::+"? */
857
1.11k
                        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
89
                        URI_FUNC(StopSyntax)(state, first, memory);
868
89
                        return NULL;
869
89
                    }
870
871
2.05k
                    if (setZipper) {
872
1.11k
                        zipperEver = 1;
873
1.11k
                    }
874
2.05k
                } break;
875
876
322
                case _UT('.'):
877
322
                    if ((quadsDone + zipperEver > 6) /* NOTE */
878
320
                        || (!zipperEver && (quadsDone < 6)) || letterAmong
879
310
                        || (digitCount == 0) || (digitCount == 4)) {
880
                        /* Invalid octet before */
881
23
                        URI_FUNC(StopSyntax)(state, first, memory);
882
23
                        return NULL;
883
299
                    } else if ((digitCount > 1) && (digitHistory[0] == 0)) {
884
                        /* Leading zero */
885
2
                        URI_FUNC(StopSyntax)(state, first - digitCount, memory);
886
2
                        return NULL;
887
297
                    } else if ((digitCount == 3)
888
43
                               && (100 * digitHistory[0] + 10 * digitHistory[1]
889
43
                                       + digitHistory[2]
890
43
                                   > 255)) {
891
                        /* Octet value too large */
892
16
                        if (digitHistory[0] > 2) {
893
7
                            URI_FUNC(StopSyntax)(state, first - 3, memory);
894
9
                        } else if (digitHistory[1] > 5) {
895
6
                            URI_FUNC(StopSyntax)(state, first - 2, memory);
896
6
                        } else {
897
3
                            URI_FUNC(StopSyntax)(state, first - 1, memory);
898
3
                        }
899
16
                        return NULL;
900
16
                    }
901
902
                    /* Copy first IPv4 octet */
903
281
                    state->uri->hostData.ip6->data[16 - 4] =
904
281
                        uriGetOctetValue(digitHistory, digitCount);
905
281
                    digitCount = 0;
906
907
                    /* Switch over to IPv4 loop */
908
281
                    ip4OctetsDone = 1;
909
281
                    walking = 0;
910
281
                    break;
911
912
697
                case _UT(']'):
913
                    /* Too little quads? */
914
697
                    if (!zipperEver && !((quadsDone == 7) && (digitCount > 0))) {
915
8
                        URI_FUNC(StopSyntax)(state, first, memory);
916
8
                        return NULL;
917
8
                    }
918
919
689
                    if (digitCount > 0) {
920
104
                        if (zipperEver) {
921
                            /* Too many quads? */
922
96
                            if (quadsDone >= 7) {
923
2
                                URI_FUNC(StopSyntax)(state, first, memory);
924
2
                                return NULL;
925
2
                            }
926
94
                            uriWriteQuadToDoubleByte(digitHistory, digitCount,
927
94
                                                     quadsAfterZipper
928
94
                                                         + 2 * quadsAfterZipperCount);
929
94
                            quadsAfterZipperCount++;
930
94
                        } 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
104
                    }
940
941
                    /* Copy missing quads to the end */
942
687
                    memcpy(state->uri->hostData.ip6->data + 16
943
687
                               - 2 * quadsAfterZipperCount,
944
687
                           quadsAfterZipper, 2 * quadsAfterZipperCount);
945
946
687
                    state->uri->hostText.afterLast = first; /* HOST END */
947
687
                    return first + 1; /* Fine */
948
949
190
                default:
950
190
                    URI_FUNC(StopSyntax)(state, first, memory);
951
190
                    return NULL;
952
7.65k
                }
953
6.53k
                first++;
954
955
6.53k
                if (first >= afterLast) {
956
320
                    URI_FUNC(StopSyntax)(state, afterLast, memory);
957
320
                    return NULL; /* No ']' yet */
958
320
                }
959
6.53k
            } while (walking);
960
1.69k
        }
961
1.94k
    }
962
1.69k
}
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
9.99M
                                                         UriMemoryManager * memory) {
976
9.99M
    if (first >= afterLast) {
977
4.81k
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
978
4.81k
                                       memory)) { /* SEGMENT BOTH */
979
0
            URI_FUNC(StopMalloc)(state, memory);
980
0
            return NULL;
981
0
        }
982
4.81k
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
983
4.81k
        return afterLast;
984
4.81k
    }
985
986
9.98M
    switch (*first) {
987
31.7k
    case _UT('%'): {
988
31.7k
        const URI_CHAR * const afterPctEncoded =
989
31.7k
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
990
31.7k
        if (afterPctEncoded == NULL) {
991
597
            return NULL;
992
597
        }
993
31.1k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
994
31.1k
                                                memory);
995
31.7k
    }
996
997
942
    case _UT('@'):
998
2.07k
    case _UT('!'):
999
3.24k
    case _UT('$'):
1000
4.43k
    case _UT('&'):
1001
5.65k
    case _UT('('):
1002
7.59k
    case _UT(')'):
1003
8.88k
    case _UT('*'):
1004
9.89k
    case _UT(','):
1005
10.9k
    case _UT(';'):
1006
13.4k
    case _UT('\''):
1007
19.4k
    case _UT('+'):
1008
21.4k
    case _UT('='):
1009
35.0k
    case _UT('-'):
1010
89.7k
    case _UT('.'):
1011
91.2k
    case _UT('_'):
1012
92.6k
    case _UT('~'):
1013
29.8M
    case URI_SET_DIGIT:
1014
29.8M
    case URI_SET_ALPHA:
1015
9.95M
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1016
1017
824
    case _UT('/'): {
1018
824
        const URI_CHAR * afterZeroMoreSlashSegs;
1019
824
        const URI_CHAR * afterSegment;
1020
824
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1021
824
                                       memory)) { /* SEGMENT BOTH */
1022
0
            URI_FUNC(StopMalloc)(state, memory);
1023
0
            return NULL;
1024
0
        }
1025
824
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1026
824
        afterSegment = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1027
824
        if (afterSegment == NULL) {
1028
12
            return NULL;
1029
12
        }
1030
812
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1031
812
                                       memory)) { /* SEGMENT BOTH */
1032
0
            URI_FUNC(StopMalloc)(state, memory);
1033
0
            return NULL;
1034
0
        }
1035
812
        afterZeroMoreSlashSegs =
1036
812
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1037
812
        if (afterZeroMoreSlashSegs == NULL) {
1038
8
            return NULL;
1039
8
        }
1040
804
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1041
812
    }
1042
1043
475
    default:
1044
475
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1045
475
                                       memory)) { /* SEGMENT BOTH */
1046
0
            URI_FUNC(StopMalloc)(state, memory);
1047
0
            return NULL;
1048
0
        }
1049
475
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1050
475
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1051
9.98M
    }
1052
9.98M
}
UriParse.c:uriParseMustBeSegmentNzNcA
Line
Count
Source
975
9.66M
                                                         UriMemoryManager * memory) {
976
9.66M
    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
9.65M
    switch (*first) {
987
18.1k
    case _UT('%'): {
988
18.1k
        const URI_CHAR * const afterPctEncoded =
989
18.1k
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
990
18.1k
        if (afterPctEncoded == NULL) {
991
294
            return NULL;
992
294
        }
993
17.8k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
994
17.8k
                                                memory);
995
18.1k
    }
996
997
551
    case _UT('@'):
998
1.18k
    case _UT('!'):
999
1.93k
    case _UT('$'):
1000
2.61k
    case _UT('&'):
1001
3.42k
    case _UT('('):
1002
4.00k
    case _UT(')'):
1003
4.49k
    case _UT('*'):
1004
5.05k
    case _UT(','):
1005
5.65k
    case _UT(';'):
1006
6.55k
    case _UT('\''):
1007
11.8k
    case _UT('+'):
1008
13.4k
    case _UT('='):
1009
26.4k
    case _UT('-'):
1010
79.9k
    case _UT('.'):
1011
80.7k
    case _UT('_'):
1012
81.4k
    case _UT('~'):
1013
29.3M
    case URI_SET_DIGIT:
1014
29.3M
    case URI_SET_ALPHA:
1015
9.64M
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1016
1017
452
    case _UT('/'): {
1018
452
        const URI_CHAR * afterZeroMoreSlashSegs;
1019
452
        const URI_CHAR * afterSegment;
1020
452
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1021
452
                                       memory)) { /* SEGMENT BOTH */
1022
0
            URI_FUNC(StopMalloc)(state, memory);
1023
0
            return NULL;
1024
0
        }
1025
452
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1026
452
        afterSegment = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1027
452
        if (afterSegment == NULL) {
1028
7
            return NULL;
1029
7
        }
1030
445
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1031
445
                                       memory)) { /* SEGMENT BOTH */
1032
0
            URI_FUNC(StopMalloc)(state, memory);
1033
0
            return NULL;
1034
0
        }
1035
445
        afterZeroMoreSlashSegs =
1036
445
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1037
445
        if (afterZeroMoreSlashSegs == NULL) {
1038
4
            return NULL;
1039
4
        }
1040
441
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1041
445
    }
1042
1043
97
    default:
1044
97
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1045
97
                                       memory)) { /* SEGMENT BOTH */
1046
0
            URI_FUNC(StopMalloc)(state, memory);
1047
0
            return NULL;
1048
0
        }
1049
97
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1050
97
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1051
9.65M
    }
1052
9.65M
}
UriParse.c:uriParseMustBeSegmentNzNcW
Line
Count
Source
975
328k
                                                         UriMemoryManager * memory) {
976
328k
    if (first >= afterLast) {
977
2.20k
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
978
2.20k
                                       memory)) { /* SEGMENT BOTH */
979
0
            URI_FUNC(StopMalloc)(state, memory);
980
0
            return NULL;
981
0
        }
982
2.20k
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
983
2.20k
        return afterLast;
984
2.20k
    }
985
986
326k
    switch (*first) {
987
13.5k
    case _UT('%'): {
988
13.5k
        const URI_CHAR * const afterPctEncoded =
989
13.5k
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
990
13.5k
        if (afterPctEncoded == NULL) {
991
303
            return NULL;
992
303
        }
993
13.2k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
994
13.2k
                                                memory);
995
13.5k
    }
996
997
391
    case _UT('@'):
998
899
    case _UT('!'):
999
1.31k
    case _UT('$'):
1000
1.82k
    case _UT('&'):
1001
2.23k
    case _UT('('):
1002
3.59k
    case _UT(')'):
1003
4.39k
    case _UT('*'):
1004
4.83k
    case _UT(','):
1005
5.29k
    case _UT(';'):
1006
6.88k
    case _UT('\''):
1007
7.59k
    case _UT('+'):
1008
7.99k
    case _UT('='):
1009
8.55k
    case _UT('-'):
1010
9.83k
    case _UT('.'):
1011
10.4k
    case _UT('_'):
1012
11.1k
    case _UT('~'):
1013
511k
    case URI_SET_DIGIT:
1014
511k
    case URI_SET_ALPHA:
1015
312k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1016
1017
372
    case _UT('/'): {
1018
372
        const URI_CHAR * afterZeroMoreSlashSegs;
1019
372
        const URI_CHAR * afterSegment;
1020
372
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1021
372
                                       memory)) { /* SEGMENT BOTH */
1022
0
            URI_FUNC(StopMalloc)(state, memory);
1023
0
            return NULL;
1024
0
        }
1025
372
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1026
372
        afterSegment = URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1027
372
        if (afterSegment == NULL) {
1028
5
            return NULL;
1029
5
        }
1030
367
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1031
367
                                       memory)) { /* SEGMENT BOTH */
1032
0
            URI_FUNC(StopMalloc)(state, memory);
1033
0
            return NULL;
1034
0
        }
1035
367
        afterZeroMoreSlashSegs =
1036
367
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1037
367
        if (afterZeroMoreSlashSegs == NULL) {
1038
4
            return NULL;
1039
4
        }
1040
363
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1041
367
    }
1042
1043
378
    default:
1044
378
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1045
378
                                       memory)) { /* SEGMENT BOTH */
1046
0
            URI_FUNC(StopMalloc)(state, memory);
1047
0
            return NULL;
1048
0
        }
1049
378
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1050
378
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1051
326k
    }
1052
326k
}
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
246
        state->uri->hostText.afterLast = afterLast; /* HOST END */
1064
246
        return afterLast;
1065
246
    }
1066
1067
3.23k
    switch (*first) {
1068
347
    case _UT('['): {
1069
347
        const URI_CHAR * const afterIpLit2 =
1070
347
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
1071
347
        if (afterIpLit2 == NULL) {
1072
17
            return NULL;
1073
17
        }
1074
330
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1075
330
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
1076
347
    }
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
124
        state->uri->hostText.afterLast = afterLast; /* HOST END */
1064
124
        return afterLast;
1065
124
    }
1066
1067
1.53k
    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
4
            return NULL;
1073
4
        }
1074
130
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1075
130
        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.53k
    }
1081
1.53k
}
UriParse.c:uriParseOwnHostW
Line
Count
Source
1061
1.81k
                                                          UriMemoryManager * memory) {
1062
1.81k
    if (first >= afterLast) {
1063
122
        state->uri->hostText.afterLast = afterLast; /* HOST END */
1064
122
        return afterLast;
1065
122
    }
1066
1067
1.69k
    switch (*first) {
1068
213
    case _UT('['): {
1069
213
        const URI_CHAR * const afterIpLit2 =
1070
213
            URI_FUNC(ParseIpLit2)(state, first + 1, afterLast, memory);
1071
213
        if (afterIpLit2 == NULL) {
1072
13
            return NULL;
1073
13
        }
1074
200
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1075
200
        return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast);
1076
213
    }
1077
1078
1.48k
    default:
1079
1.48k
        return URI_FUNC(ParseOwnHost2)(state, first, afterLast, memory);
1080
1.69k
    }
1081
1.69k
}
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.38k
                                                   UriMemoryManager * memory) {
1086
1.38k
    state->uri->hostText.afterLast = first; /* HOST END */
1087
1088
    /* Valid IPv4 or just a regname? */
1089
1.38k
    state->uri->hostData.ip4 = memory->malloc(
1090
1.38k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1091
1.38k
    if (state->uri->hostData.ip4 == NULL) {
1092
0
        return URI_FALSE; /* Raises malloc error */
1093
0
    }
1094
1.38k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1095
1.38k
                                     state->uri->hostText.first,
1096
1.38k
                                     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.38k
    return URI_TRUE; /* Success */
1102
1.38k
}
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.44k
        memory->free(memory, state->uri->hostData.ip4);
1099
1.44k
        state->uri->hostData.ip4 = NULL;
1100
1.44k
    }
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
2.17M
                                                UriMemoryManager * memory) {
1112
2.17M
    if (first >= afterLast) {
1113
2.53k
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1114
0
            URI_FUNC(StopMalloc)(state, memory);
1115
0
            return NULL;
1116
0
        }
1117
2.53k
        return afterLast;
1118
2.53k
    }
1119
1120
2.17M
    switch (*first) {
1121
894
    case _UT('!'):
1122
1.77k
    case _UT('$'):
1123
3.80k
    case _UT('%'):
1124
4.68k
    case _UT('&'):
1125
5.54k
    case _UT('('):
1126
6.69k
    case _UT(')'):
1127
12.6k
    case _UT('-'):
1128
13.7k
    case _UT('*'):
1129
14.8k
    case _UT(','):
1130
27.1k
    case _UT('.'):
1131
28.3k
    case _UT(';'):
1132
29.7k
    case _UT('\''):
1133
30.6k
    case _UT('_'):
1134
31.5k
    case _UT('~'):
1135
32.6k
    case _UT('+'):
1136
34.2k
    case _UT('='):
1137
3.56M
    case URI_SET_DIGIT:
1138
69.9M
    case URI_SET_ALPHA: {
1139
69.9M
        const URI_CHAR * const afterPctSubUnres =
1140
69.9M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1141
69.9M
        if (afterPctSubUnres == NULL) {
1142
35
            return NULL;
1143
35
        }
1144
2.17M
        return URI_FUNC(ParseOwnHost2)(state, afterPctSubUnres, afterLast, memory);
1145
69.9M
    }
1146
1147
314
    default:
1148
314
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1149
0
            URI_FUNC(StopMalloc)(state, memory);
1150
0
            return NULL;
1151
0
        }
1152
314
        return URI_FUNC(ParseAuthorityTwo)(state, first, afterLast);
1153
2.17M
    }
1154
2.17M
}
UriParse.c:uriParseOwnHost2A
Line
Count
Source
1111
1.82M
                                                UriMemoryManager * memory) {
1112
1.82M
    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.82M
    switch (*first) {
1121
444
    case _UT('!'):
1122
896
    case _UT('$'):
1123
1.93k
    case _UT('%'):
1124
2.32k
    case _UT('&'):
1125
2.80k
    case _UT('('):
1126
3.20k
    case _UT(')'):
1127
6.31k
    case _UT('-'):
1128
6.77k
    case _UT('*'):
1129
7.22k
    case _UT(','):
1130
18.4k
    case _UT('.'):
1131
19.1k
    case _UT(';'):
1132
19.8k
    case _UT('\''):
1133
20.2k
    case _UT('_'):
1134
20.6k
    case _UT('~'):
1135
21.0k
    case _UT('+'):
1136
21.9k
    case _UT('='):
1137
3.01M
    case URI_SET_DIGIT:
1138
60.6M
    case URI_SET_ALPHA: {
1139
60.6M
        const URI_CHAR * const afterPctSubUnres =
1140
60.6M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1141
60.6M
        if (afterPctSubUnres == NULL) {
1142
16
            return NULL;
1143
16
        }
1144
1.82M
        return URI_FUNC(ParseOwnHost2)(state, afterPctSubUnres, afterLast, memory);
1145
60.6M
    }
1146
1147
109
    default:
1148
109
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1149
0
            URI_FUNC(StopMalloc)(state, memory);
1150
0
            return NULL;
1151
0
        }
1152
109
        return URI_FUNC(ParseAuthorityTwo)(state, first, afterLast);
1153
1.82M
    }
1154
1.82M
}
UriParse.c:uriParseOwnHost2W
Line
Count
Source
1111
345k
                                                UriMemoryManager * memory) {
1112
345k
    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
344k
    switch (*first) {
1121
450
    case _UT('!'):
1122
879
    case _UT('$'):
1123
1.87k
    case _UT('%'):
1124
2.35k
    case _UT('&'):
1125
2.74k
    case _UT('('):
1126
3.49k
    case _UT(')'):
1127
6.29k
    case _UT('-'):
1128
6.97k
    case _UT('*'):
1129
7.66k
    case _UT(','):
1130
8.68k
    case _UT('.'):
1131
9.19k
    case _UT(';'):
1132
9.94k
    case _UT('\''):
1133
10.4k
    case _UT('_'):
1134
10.9k
    case _UT('~'):
1135
11.5k
    case _UT('+'):
1136
12.3k
    case _UT('='):
1137
547k
    case URI_SET_DIGIT:
1138
9.32M
    case URI_SET_ALPHA: {
1139
9.32M
        const URI_CHAR * const afterPctSubUnres =
1140
9.32M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1141
9.32M
        if (afterPctSubUnres == NULL) {
1142
19
            return NULL;
1143
19
        }
1144
343k
        return URI_FUNC(ParseOwnHost2)(state, afterPctSubUnres, afterLast, memory);
1145
9.32M
    }
1146
1147
205
    default:
1148
205
        if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) {
1149
0
            URI_FUNC(StopMalloc)(state, memory);
1150
0
            return NULL;
1151
0
        }
1152
205
        return URI_FUNC(ParseAuthorityTwo)(state, first, afterLast);
1153
344k
    }
1154
344k
}
1155
1156
static URI_INLINE UriBool URI_FUNC(OnExitOwnHostUserInfo)(URI_TYPE(ParserState) * state,
1157
                                                          const URI_CHAR * first,
1158
4.77k
                                                          UriMemoryManager * memory) {
1159
4.77k
    state->uri->hostText.first =
1160
4.77k
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1161
4.77k
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1162
4.77k
    state->uri->hostText.afterLast = first; /* HOST END */
1163
1164
    /* Valid IPv4 or just a regname? */
1165
4.77k
    state->uri->hostData.ip4 = memory->malloc(
1166
4.77k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1167
4.77k
    if (state->uri->hostData.ip4 == NULL) {
1168
0
        return URI_FALSE; /* Raises malloc error */
1169
0
    }
1170
4.77k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1171
4.77k
                                     state->uri->hostText.first,
1172
4.77k
                                     state->uri->hostText.afterLast)) {
1173
        /* Not IPv4 */
1174
4.65k
        memory->free(memory, state->uri->hostData.ip4);
1175
4.65k
        state->uri->hostData.ip4 = NULL;
1176
4.65k
    }
1177
4.77k
    return URI_TRUE; /* Success */
1178
4.77k
}
UriParse.c:uriOnExitOwnHostUserInfoA
Line
Count
Source
1158
2.39k
                                                          UriMemoryManager * memory) {
1159
2.39k
    state->uri->hostText.first =
1160
2.39k
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1161
2.39k
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1162
2.39k
    state->uri->hostText.afterLast = first; /* HOST END */
1163
1164
    /* Valid IPv4 or just a regname? */
1165
2.39k
    state->uri->hostData.ip4 = memory->malloc(
1166
2.39k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1167
2.39k
    if (state->uri->hostData.ip4 == NULL) {
1168
0
        return URI_FALSE; /* Raises malloc error */
1169
0
    }
1170
2.39k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1171
2.39k
                                     state->uri->hostText.first,
1172
2.39k
                                     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.39k
    return URI_TRUE; /* Success */
1178
2.39k
}
UriParse.c:uriOnExitOwnHostUserInfoW
Line
Count
Source
1158
2.37k
                                                          UriMemoryManager * memory) {
1159
2.37k
    state->uri->hostText.first =
1160
2.37k
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1161
2.37k
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1162
2.37k
    state->uri->hostText.afterLast = first; /* HOST END */
1163
1164
    /* Valid IPv4 or just a regname? */
1165
2.37k
    state->uri->hostData.ip4 = memory->malloc(
1166
2.37k
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1167
2.37k
    if (state->uri->hostData.ip4 == NULL) {
1168
0
        return URI_FALSE; /* Raises malloc error */
1169
0
    }
1170
2.37k
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1171
2.37k
                                     state->uri->hostText.first,
1172
2.37k
                                     state->uri->hostText.afterLast)) {
1173
        /* Not IPv4 */
1174
2.31k
        memory->free(memory, state->uri->hostData.ip4);
1175
2.31k
        state->uri->hostData.ip4 = NULL;
1176
2.31k
    }
1177
2.37k
    return URI_TRUE; /* Success */
1178
2.37k
}
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.95M
                               const URI_CHAR * afterLast, UriMemoryManager * memory) {
1187
5.95M
    if (first >= afterLast) {
1188
4.63k
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1189
0
            URI_FUNC(StopMalloc)(state, memory);
1190
0
            return NULL;
1191
0
        }
1192
4.63k
        return afterLast;
1193
4.63k
    }
1194
1195
5.95M
    switch (*first) {
1196
1.60k
    case _UT('!'):
1197
3.15k
    case _UT('$'):
1198
12.1k
    case _UT('%'):
1199
13.7k
    case _UT('&'):
1200
15.3k
    case _UT('('):
1201
19.3k
    case _UT(')'):
1202
31.2k
    case _UT('-'):
1203
33.5k
    case _UT('*'):
1204
35.3k
    case _UT(','):
1205
75.5k
    case _UT('.'):
1206
75.6k
    case _UT(':'):
1207
77.5k
    case _UT(';'):
1208
77.7k
    case _UT('@'):
1209
81.8k
    case _UT('\''):
1210
83.6k
    case _UT('_'):
1211
85.3k
    case _UT('~'):
1212
87.0k
    case _UT('+'):
1213
88.7k
    case _UT('='):
1214
4.76M
    case URI_SET_DIGIT:
1215
5.94M
    case URI_SET_ALPHA:
1216
5.94M
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
1217
1218
144
    default:
1219
144
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1220
0
            URI_FUNC(StopMalloc)(state, memory);
1221
0
            return NULL;
1222
0
        }
1223
144
        return first;
1224
5.95M
    }
1225
5.95M
}
UriParse.c:uriParseOwnHostUserInfoA
Line
Count
Source
1186
4.99M
                               const URI_CHAR * afterLast, UriMemoryManager * memory) {
1187
4.99M
    if (first >= afterLast) {
1188
2.33k
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1189
0
            URI_FUNC(StopMalloc)(state, memory);
1190
0
            return NULL;
1191
0
        }
1192
2.33k
        return afterLast;
1193
2.33k
    }
1194
1195
4.99M
    switch (*first) {
1196
1.08k
    case _UT('!'):
1197
1.97k
    case _UT('$'):
1198
4.34k
    case _UT('%'):
1199
5.28k
    case _UT('&'):
1200
6.33k
    case _UT('('):
1201
7.64k
    case _UT(')'):
1202
17.2k
    case _UT('-'):
1203
18.1k
    case _UT('*'):
1204
19.0k
    case _UT(','):
1205
57.4k
    case _UT('.'):
1206
57.5k
    case _UT(':'):
1207
58.5k
    case _UT(';'):
1208
58.6k
    case _UT('@'):
1209
59.6k
    case _UT('\''):
1210
60.4k
    case _UT('_'):
1211
61.0k
    case _UT('~'):
1212
61.9k
    case _UT('+'):
1213
63.0k
    case _UT('='):
1214
3.26M
    case URI_SET_DIGIT:
1215
4.99M
    case URI_SET_ALPHA:
1216
4.99M
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
1217
1218
63
    default:
1219
63
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1220
0
            URI_FUNC(StopMalloc)(state, memory);
1221
0
            return NULL;
1222
0
        }
1223
63
        return first;
1224
4.99M
    }
1225
4.99M
}
UriParse.c:uriParseOwnHostUserInfoW
Line
Count
Source
1186
956k
                               const URI_CHAR * afterLast, UriMemoryManager * memory) {
1187
956k
    if (first >= afterLast) {
1188
2.29k
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1189
0
            URI_FUNC(StopMalloc)(state, memory);
1190
0
            return NULL;
1191
0
        }
1192
2.29k
        return afterLast;
1193
2.29k
    }
1194
1195
954k
    switch (*first) {
1196
519
    case _UT('!'):
1197
1.18k
    case _UT('$'):
1198
7.78k
    case _UT('%'):
1199
8.45k
    case _UT('&'):
1200
9.03k
    case _UT('('):
1201
11.7k
    case _UT(')'):
1202
13.9k
    case _UT('-'):
1203
15.4k
    case _UT('*'):
1204
16.3k
    case _UT(','):
1205
18.1k
    case _UT('.'):
1206
18.1k
    case _UT(':'):
1207
19.0k
    case _UT(';'):
1208
19.1k
    case _UT('@'):
1209
22.1k
    case _UT('\''):
1210
23.2k
    case _UT('_'):
1211
24.2k
    case _UT('~'):
1212
25.1k
    case _UT('+'):
1213
25.7k
    case _UT('='):
1214
1.49M
    case URI_SET_DIGIT:
1215
1.49M
    case URI_SET_ALPHA:
1216
954k
        return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory);
1217
1218
81
    default:
1219
81
        if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) {
1220
0
            URI_FUNC(StopMalloc)(state, memory);
1221
0
            return NULL;
1222
0
        }
1223
81
        return first;
1224
954k
    }
1225
954k
}
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.96M
                                                         UriMemoryManager * memory) {
1236
5.96M
    if (first >= afterLast) {
1237
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1238
0
        return NULL;
1239
0
    }
1240
1241
5.96M
    switch (*first) {
1242
1.66k
    case _UT('!'):
1243
3.27k
    case _UT('$'):
1244
12.3k
    case _UT('%'):
1245
14.0k
    case _UT('&'):
1246
15.7k
    case _UT('('):
1247
19.7k
    case _UT(')'):
1248
31.7k
    case _UT('-'):
1249
34.0k
    case _UT('*'):
1250
35.9k
    case _UT(','):
1251
76.2k
    case _UT('.'):
1252
78.2k
    case _UT(';'):
1253
82.3k
    case _UT('\''):
1254
84.2k
    case _UT('_'):
1255
85.9k
    case _UT('~'):
1256
87.7k
    case _UT('+'):
1257
89.5k
    case _UT('='):
1258
4.77M
    case URI_SET_DIGIT:
1259
168M
    case URI_SET_ALPHA: {
1260
168M
        const URI_CHAR * const afterPctSubUnres =
1261
168M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1262
168M
        if (afterPctSubUnres == NULL) {
1263
55
            return NULL;
1264
55
        }
1265
5.95M
        return URI_FUNC(ParseOwnHostUserInfo)(state, afterPctSubUnres, afterLast, memory);
1266
168M
    }
1267
1268
3.68k
    case _UT(':'):
1269
3.68k
        state->uri->hostText.afterLast = first; /* HOST END */
1270
3.68k
        state->uri->portText.first = first + 1; /* PORT BEGIN */
1271
3.68k
        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.96M
    }
1282
5.96M
}
UriParse.c:uriParseOwnHostUserInfoNzA
Line
Count
Source
1235
5.00M
                                                         UriMemoryManager * memory) {
1236
5.00M
    if (first >= afterLast) {
1237
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1238
0
        return NULL;
1239
0
    }
1240
1241
5.00M
    switch (*first) {
1242
1.11k
    case _UT('!'):
1243
2.03k
    case _UT('$'):
1244
4.45k
    case _UT('%'):
1245
5.42k
    case _UT('&'):
1246
6.50k
    case _UT('('):
1247
7.84k
    case _UT(')'):
1248
17.5k
    case _UT('-'):
1249
18.4k
    case _UT('*'):
1250
19.3k
    case _UT(','):
1251
57.7k
    case _UT('.'):
1252
58.8k
    case _UT(';'):
1253
59.8k
    case _UT('\''):
1254
60.6k
    case _UT('_'):
1255
61.3k
    case _UT('~'):
1256
62.2k
    case _UT('+'):
1257
63.3k
    case _UT('='):
1258
3.27M
    case URI_SET_DIGIT:
1259
142M
    case URI_SET_ALPHA: {
1260
142M
        const URI_CHAR * const afterPctSubUnres =
1261
142M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1262
142M
        if (afterPctSubUnres == NULL) {
1263
28
            return NULL;
1264
28
        }
1265
4.99M
        return URI_FUNC(ParseOwnHostUserInfo)(state, afterPctSubUnres, afterLast, memory);
1266
142M
    }
1267
1268
1.86k
    case _UT(':'):
1269
1.86k
        state->uri->hostText.afterLast = first; /* HOST END */
1270
1.86k
        state->uri->portText.first = first + 1; /* PORT BEGIN */
1271
1.86k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1272
1273
1.52k
    case _UT('@'):
1274
1.52k
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1275
1.52k
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1276
1.52k
        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
5.00M
    }
1282
5.00M
}
UriParse.c:uriParseOwnHostUserInfoNzW
Line
Count
Source
1235
960k
                                                         UriMemoryManager * memory) {
1236
960k
    if (first >= afterLast) {
1237
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1238
0
        return NULL;
1239
0
    }
1240
1241
960k
    switch (*first) {
1242
547
    case _UT('!'):
1243
1.23k
    case _UT('$'):
1244
7.89k
    case _UT('%'):
1245
8.60k
    case _UT('&'):
1246
9.20k
    case _UT('('):
1247
11.9k
    case _UT(')'):
1248
14.1k
    case _UT('-'):
1249
15.6k
    case _UT('*'):
1250
16.6k
    case _UT(','):
1251
18.5k
    case _UT('.'):
1252
19.3k
    case _UT(';'):
1253
22.4k
    case _UT('\''):
1254
23.6k
    case _UT('_'):
1255
24.6k
    case _UT('~'):
1256
25.5k
    case _UT('+'):
1257
26.1k
    case _UT('='):
1258
1.50M
    case URI_SET_DIGIT:
1259
25.9M
    case URI_SET_ALPHA: {
1260
25.9M
        const URI_CHAR * const afterPctSubUnres =
1261
25.9M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1262
25.9M
        if (afterPctSubUnres == NULL) {
1263
27
            return NULL;
1264
27
        }
1265
956k
        return URI_FUNC(ParseOwnHostUserInfo)(state, afterPctSubUnres, afterLast, memory);
1266
25.9M
    }
1267
1268
1.81k
    case _UT(':'):
1269
1.81k
        state->uri->hostText.afterLast = first; /* HOST END */
1270
1.81k
        state->uri->portText.first = first + 1; /* PORT BEGIN */
1271
1.81k
        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
960k
    }
1282
960k
}
1283
1284
static URI_INLINE UriBool URI_FUNC(OnExitOwnPortUserInfo)(URI_TYPE(ParserState) * state,
1285
                                                          const URI_CHAR * first,
1286
439
                                                          UriMemoryManager * memory) {
1287
439
    state->uri->hostText.first =
1288
439
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1289
439
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1290
439
    state->uri->portText.afterLast = first; /* PORT END */
1291
1292
    /* Valid IPv4 or just a regname? */
1293
439
    state->uri->hostData.ip4 = memory->malloc(
1294
439
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1295
439
    if (state->uri->hostData.ip4 == NULL) {
1296
0
        return URI_FALSE; /* Raises malloc error */
1297
0
    }
1298
439
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1299
439
                                     state->uri->hostText.first,
1300
439
                                     state->uri->hostText.afterLast)) {
1301
        /* Not IPv4 */
1302
422
        memory->free(memory, state->uri->hostData.ip4);
1303
422
        state->uri->hostData.ip4 = NULL;
1304
422
    }
1305
439
    return URI_TRUE; /* Success */
1306
439
}
UriParse.c:uriOnExitOwnPortUserInfoA
Line
Count
Source
1286
222
                                                          UriMemoryManager * memory) {
1287
222
    state->uri->hostText.first =
1288
222
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1289
222
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1290
222
    state->uri->portText.afterLast = first; /* PORT END */
1291
1292
    /* Valid IPv4 or just a regname? */
1293
222
    state->uri->hostData.ip4 = memory->malloc(
1294
222
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1295
222
    if (state->uri->hostData.ip4 == NULL) {
1296
0
        return URI_FALSE; /* Raises malloc error */
1297
0
    }
1298
222
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1299
222
                                     state->uri->hostText.first,
1300
222
                                     state->uri->hostText.afterLast)) {
1301
        /* Not IPv4 */
1302
212
        memory->free(memory, state->uri->hostData.ip4);
1303
212
        state->uri->hostData.ip4 = NULL;
1304
212
    }
1305
222
    return URI_TRUE; /* Success */
1306
222
}
UriParse.c:uriOnExitOwnPortUserInfoW
Line
Count
Source
1286
217
                                                          UriMemoryManager * memory) {
1287
217
    state->uri->hostText.first =
1288
217
        state->uri->userInfo.first; /* Host instead of userInfo, update */
1289
217
    state->uri->userInfo.first = NULL; /* Not a userInfo, reset */
1290
217
    state->uri->portText.afterLast = first; /* PORT END */
1291
1292
    /* Valid IPv4 or just a regname? */
1293
217
    state->uri->hostData.ip4 = memory->malloc(
1294
217
        memory, 1 * sizeof(UriIp4)); /* Freed when stopping on parse error */
1295
217
    if (state->uri->hostData.ip4 == NULL) {
1296
0
        return URI_FALSE; /* Raises malloc error */
1297
0
    }
1298
217
    if (URI_FUNC(ParseIpFourAddress)(state->uri->hostData.ip4->data,
1299
217
                                     state->uri->hostText.first,
1300
217
                                     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
217
    return URI_TRUE; /* Success */
1306
217
}
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
84.5k
                                                       UriMemoryManager * memory) {
1325
84.5k
    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
84.1k
    switch (*first) {
1334
    /* begin sub-delims */
1335
55
    case _UT('!'):
1336
98
    case _UT('$'):
1337
132
    case _UT('&'):
1338
185
    case _UT('\''):
1339
233
    case _UT('('):
1340
284
    case _UT(')'):
1341
343
    case _UT('*'):
1342
389
    case _UT('+'):
1343
435
    case _UT(','):
1344
486
    case _UT(';'):
1345
528
    case _UT('='):
1346
    /* end sub-delims */
1347
    /* begin unreserved (except alpha and digit) */
1348
594
    case _UT('-'):
1349
714
    case _UT('.'):
1350
755
    case _UT('_'):
1351
799
    case _UT('~'):
1352
    /* end unreserved (except alpha and digit) */
1353
961
    case _UT(':'):
1354
3.21k
    case URI_SET_ALPHA:
1355
3.21k
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1356
3.21k
        state->uri->portText.first = NULL; /* Not a port, reset */
1357
3.21k
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1358
1359
80.8k
    case URI_SET_DIGIT:
1360
80.8k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1361
1362
17
    case _UT('%'):
1363
17
        state->uri->portText.first = NULL; /* Not a port, reset */
1364
17
        const URI_CHAR * const afterPct =
1365
17
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1366
17
        if (afterPct == NULL) {
1367
4
            return NULL;
1368
4
        }
1369
13
        return URI_FUNC(ParseOwnUserInfo)(state, afterPct, afterLast, memory);
1370
1371
11
    case _UT('@'):
1372
11
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1373
11
        state->uri->portText.first = NULL; /* Not a port, reset */
1374
11
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1375
11
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1376
11
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1377
1378
40
    default:
1379
40
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1380
0
            URI_FUNC(StopMalloc)(state, memory);
1381
0
            return NULL;
1382
0
        }
1383
40
        return first;
1384
84.1k
    }
1385
84.1k
}
UriParse.c:uriParseOwnPortUserInfoA
Line
Count
Source
1324
77.6k
                                                       UriMemoryManager * memory) {
1325
77.6k
    if (first >= afterLast) {
1326
201
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1327
0
            URI_FUNC(StopMalloc)(state, memory);
1328
0
            return NULL;
1329
0
        }
1330
201
        return afterLast;
1331
201
    }
1332
1333
77.4k
    switch (*first) {
1334
    /* begin sub-delims */
1335
33
    case _UT('!'):
1336
56
    case _UT('$'):
1337
76
    case _UT('&'):
1338
98
    case _UT('\''):
1339
110
    case _UT('('):
1340
138
    case _UT(')'):
1341
170
    case _UT('*'):
1342
195
    case _UT('+'):
1343
224
    case _UT(','):
1344
247
    case _UT(';'):
1345
265
    case _UT('='):
1346
    /* end sub-delims */
1347
    /* begin unreserved (except alpha and digit) */
1348
304
    case _UT('-'):
1349
351
    case _UT('.'):
1350
375
    case _UT('_'):
1351
397
    case _UT('~'):
1352
    /* end unreserved (except alpha and digit) */
1353
476
    case _UT(':'):
1354
1.62k
    case URI_SET_ALPHA:
1355
1.62k
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1356
1.62k
        state->uri->portText.first = NULL; /* Not a port, reset */
1357
1.62k
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1358
1359
75.8k
    case URI_SET_DIGIT:
1360
75.8k
        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
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
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
77.4k
    }
1385
77.4k
}
UriParse.c:uriParseOwnPortUserInfoW
Line
Count
Source
1324
6.85k
                                                       UriMemoryManager * memory) {
1325
6.85k
    if (first >= afterLast) {
1326
198
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1327
0
            URI_FUNC(StopMalloc)(state, memory);
1328
0
            return NULL;
1329
0
        }
1330
198
        return afterLast;
1331
198
    }
1332
1333
6.65k
    switch (*first) {
1334
    /* begin sub-delims */
1335
22
    case _UT('!'):
1336
42
    case _UT('$'):
1337
56
    case _UT('&'):
1338
87
    case _UT('\''):
1339
123
    case _UT('('):
1340
146
    case _UT(')'):
1341
173
    case _UT('*'):
1342
194
    case _UT('+'):
1343
211
    case _UT(','):
1344
239
    case _UT(';'):
1345
263
    case _UT('='):
1346
    /* end sub-delims */
1347
    /* begin unreserved (except alpha and digit) */
1348
290
    case _UT('-'):
1349
363
    case _UT('.'):
1350
380
    case _UT('_'):
1351
402
    case _UT('~'):
1352
    /* end unreserved (except alpha and digit) */
1353
485
    case _UT(':'):
1354
1.58k
    case URI_SET_ALPHA:
1355
1.58k
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1356
1.58k
        state->uri->portText.first = NULL; /* Not a port, reset */
1357
1.58k
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1358
1359
5.03k
    case URI_SET_DIGIT:
1360
5.03k
        return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory);
1361
1362
9
    case _UT('%'):
1363
9
        state->uri->portText.first = NULL; /* Not a port, reset */
1364
9
        const URI_CHAR * const afterPct =
1365
9
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1366
9
        if (afterPct == NULL) {
1367
2
            return NULL;
1368
2
        }
1369
7
        return URI_FUNC(ParseOwnUserInfo)(state, afterPct, afterLast, memory);
1370
1371
4
    case _UT('@'):
1372
4
        state->uri->hostText.afterLast = NULL; /* Not a host, reset */
1373
4
        state->uri->portText.first = NULL; /* Not a port, reset */
1374
4
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1375
4
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1376
4
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1377
1378
19
    default:
1379
19
        if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) {
1380
0
            URI_FUNC(StopMalloc)(state, memory);
1381
0
            return NULL;
1382
0
        }
1383
19
        return first;
1384
6.65k
    }
1385
6.65k
}
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
707k
                                                   UriMemoryManager * memory) {
1396
707k
    if (first >= afterLast) {
1397
2.92k
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1398
2.92k
        return NULL;
1399
2.92k
    }
1400
1401
704k
    switch (*first) {
1402
956
    case _UT('!'):
1403
2.07k
    case _UT('$'):
1404
7.19k
    case _UT('%'):
1405
8.86k
    case _UT('&'):
1406
9.74k
    case _UT('('):
1407
13.4k
    case _UT(')'):
1408
17.5k
    case _UT('-'):
1409
19.7k
    case _UT('*'):
1410
20.5k
    case _UT(','):
1411
25.8k
    case _UT('.'):
1412
26.9k
    case _UT(';'):
1413
31.2k
    case _UT('\''):
1414
32.6k
    case _UT('_'):
1415
34.3k
    case _UT('~'):
1416
35.6k
    case _UT('+'):
1417
38.0k
    case _UT('='):
1418
825k
    case URI_SET_DIGIT:
1419
21.7M
    case URI_SET_ALPHA: {
1420
21.7M
        const URI_CHAR * const afterPctSubUnres =
1421
21.7M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1422
21.7M
        if (afterPctSubUnres == NULL) {
1423
33
            return NULL;
1424
33
        }
1425
703k
        return URI_FUNC(ParseOwnUserInfo)(state, afterPctSubUnres, afterLast, memory);
1426
21.7M
    }
1427
1428
1.01k
    case _UT(':'):
1429
1.01k
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1430
1431
240
    case _UT('@'):
1432
        /* SURE */
1433
240
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1434
240
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1435
240
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1436
1437
33
    default:
1438
33
        URI_FUNC(StopSyntax)(state, first, memory);
1439
33
        return NULL;
1440
704k
    }
1441
704k
}
UriParse.c:uriParseOwnUserInfoA
Line
Count
Source
1395
578k
                                                   UriMemoryManager * memory) {
1396
578k
    if (first >= afterLast) {
1397
1.46k
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1398
1.46k
        return NULL;
1399
1.46k
    }
1400
1401
577k
    switch (*first) {
1402
547
    case _UT('!'):
1403
1.26k
    case _UT('$'):
1404
3.47k
    case _UT('%'):
1405
4.59k
    case _UT('&'):
1406
5.08k
    case _UT('('):
1407
6.05k
    case _UT(')'):
1408
9.67k
    case _UT('-'):
1409
10.2k
    case _UT('*'):
1410
10.6k
    case _UT(','):
1411
15.3k
    case _UT('.'):
1412
16.0k
    case _UT(';'):
1413
17.0k
    case _UT('\''):
1414
17.5k
    case _UT('_'):
1415
17.9k
    case _UT('~'):
1416
18.4k
    case _UT('+'):
1417
20.4k
    case _UT('='):
1418
524k
    case URI_SET_DIGIT:
1419
17.2M
    case URI_SET_ALPHA: {
1420
17.2M
        const URI_CHAR * const afterPctSubUnres =
1421
17.2M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1422
17.2M
        if (afterPctSubUnres == NULL) {
1423
16
            return NULL;
1424
16
        }
1425
576k
        return URI_FUNC(ParseOwnUserInfo)(state, afterPctSubUnres, afterLast, memory);
1426
17.2M
    }
1427
1428
485
    case _UT(':'):
1429
485
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1430
1431
136
    case _UT('@'):
1432
        /* SURE */
1433
136
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1434
136
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1435
136
        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
577k
    }
1441
577k
}
UriParse.c:uriParseOwnUserInfoW
Line
Count
Source
1395
128k
                                                   UriMemoryManager * memory) {
1396
128k
    if (first >= afterLast) {
1397
1.45k
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1398
1.45k
        return NULL;
1399
1.45k
    }
1400
1401
127k
    switch (*first) {
1402
409
    case _UT('!'):
1403
802
    case _UT('$'):
1404
3.72k
    case _UT('%'):
1405
4.27k
    case _UT('&'):
1406
4.66k
    case _UT('('):
1407
7.43k
    case _UT(')'):
1408
7.88k
    case _UT('-'):
1409
9.52k
    case _UT('*'):
1410
9.91k
    case _UT(','):
1411
10.4k
    case _UT('.'):
1412
10.8k
    case _UT(';'):
1413
14.2k
    case _UT('\''):
1414
15.1k
    case _UT('_'):
1415
16.3k
    case _UT('~'):
1416
17.2k
    case _UT('+'):
1417
17.6k
    case _UT('='):
1418
300k
    case URI_SET_DIGIT:
1419
4.47M
    case URI_SET_ALPHA: {
1420
4.47M
        const URI_CHAR * const afterPctSubUnres =
1421
4.47M
            URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory);
1422
4.47M
        if (afterPctSubUnres == NULL) {
1423
17
            return NULL;
1424
17
        }
1425
126k
        return URI_FUNC(ParseOwnUserInfo)(state, afterPctSubUnres, afterLast, memory);
1426
4.47M
    }
1427
1428
532
    case _UT(':'):
1429
532
        return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory);
1430
1431
104
    case _UT('@'):
1432
        /* SURE */
1433
104
        state->uri->userInfo.afterLast = first; /* USERINFO END */
1434
104
        state->uri->hostText.first = first + 1; /* HOST BEGIN */
1435
104
        return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory);
1436
1437
19
    default:
1438
19
        URI_FUNC(StopSyntax)(state, first, memory);
1439
        return NULL;
1440
127k
    }
1441
127k
}
1442
1443
3.18k
static URI_INLINE void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state) {
1444
3.18k
    state->uri->absolutePath = URI_TRUE;
1445
3.18k
}
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.72k
static URI_INLINE void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state) {
1444
1.72k
    state->uri->absolutePath = URI_TRUE;
1445
1.72k
}
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.0k
                             const URI_CHAR * afterLast, UriMemoryManager * memory) {
1454
23.0k
    if (first >= afterLast) {
1455
63
        URI_FUNC(OnExitPartHelperTwo)(state);
1456
63
        return afterLast;
1457
63
    }
1458
1459
23.0k
    switch (*first) {
1460
19.9k
    case _UT('/'): {
1461
19.9k
        const URI_CHAR * const afterAuthority =
1462
19.9k
            URI_FUNC(ParseAuthority)(state, first + 1, afterLast, memory);
1463
19.9k
        const URI_CHAR * afterPathAbsEmpty;
1464
19.9k
        if (afterAuthority == NULL) {
1465
9.63k
            return NULL;
1466
9.63k
        }
1467
10.2k
        afterPathAbsEmpty =
1468
10.2k
            URI_FUNC(ParsePathAbsEmpty)(state, afterAuthority, afterLast, memory);
1469
1470
10.2k
        URI_FUNC(FixEmptyTrailSegment)(state->uri, memory);
1471
1472
10.2k
        return afterPathAbsEmpty;
1473
19.9k
    }
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.0k
    }
1479
23.0k
}
UriParse.c:uriParsePartHelperTwoA
Line
Count
Source
1453
11.1k
                             const URI_CHAR * afterLast, UriMemoryManager * memory) {
1454
11.1k
    if (first >= afterLast) {
1455
35
        URI_FUNC(OnExitPartHelperTwo)(state);
1456
35
        return afterLast;
1457
35
    }
1458
1459
11.1k
    switch (*first) {
1460
9.69k
    case _UT('/'): {
1461
9.69k
        const URI_CHAR * const afterAuthority =
1462
9.69k
            URI_FUNC(ParseAuthority)(state, first + 1, afterLast, memory);
1463
9.69k
        const URI_CHAR * afterPathAbsEmpty;
1464
9.69k
        if (afterAuthority == NULL) {
1465
4.68k
            return NULL;
1466
4.68k
        }
1467
5.01k
        afterPathAbsEmpty =
1468
5.01k
            URI_FUNC(ParsePathAbsEmpty)(state, afterAuthority, afterLast, memory);
1469
1470
5.01k
        URI_FUNC(FixEmptyTrailSegment)(state->uri, memory);
1471
1472
5.01k
        return afterPathAbsEmpty;
1473
9.69k
    }
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.1k
    }
1479
11.1k
}
UriParse.c:uriParsePartHelperTwoW
Line
Count
Source
1453
11.9k
                             const URI_CHAR * afterLast, UriMemoryManager * memory) {
1454
11.9k
    if (first >= afterLast) {
1455
28
        URI_FUNC(OnExitPartHelperTwo)(state);
1456
28
        return afterLast;
1457
28
    }
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.95k
            return NULL;
1466
4.95k
        }
1467
5.26k
        afterPathAbsEmpty =
1468
5.26k
            URI_FUNC(ParsePathAbsEmpty)(state, afterAuthority, afterLast, memory);
1469
1470
5.26k
        URI_FUNC(FixEmptyTrailSegment)(state->uri, memory);
1471
1472
5.26k
        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.7k
                                                    UriMemoryManager * memory) {
1489
18.7k
    if (first >= afterLast) {
1490
9.37k
        return afterLast;
1491
9.37k
    }
1492
1493
9.35k
    switch (*first) {
1494
8.46k
    case _UT('/'): {
1495
8.46k
        const URI_CHAR * const afterSegment =
1496
8.46k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1497
8.46k
        if (afterSegment == NULL) {
1498
5
            return NULL;
1499
5
        }
1500
8.46k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1501
8.46k
                                       memory)) { /* SEGMENT BOTH */
1502
0
            URI_FUNC(StopMalloc)(state, memory);
1503
0
            return NULL;
1504
0
        }
1505
8.46k
        return URI_FUNC(ParsePathAbsEmpty)(state, afterSegment, afterLast, memory);
1506
8.46k
    }
1507
1508
891
    default:
1509
891
        return first;
1510
9.35k
    }
1511
9.35k
}
UriParse.c:uriParsePathAbsEmptyA
Line
Count
Source
1488
9.42k
                                                    UriMemoryManager * memory) {
1489
9.42k
    if (first >= afterLast) {
1490
4.77k
        return afterLast;
1491
4.77k
    }
1492
1493
4.64k
    switch (*first) {
1494
4.41k
    case _UT('/'): {
1495
4.41k
        const URI_CHAR * const afterSegment =
1496
4.41k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1497
4.41k
        if (afterSegment == NULL) {
1498
2
            return NULL;
1499
2
        }
1500
4.41k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1501
4.41k
                                       memory)) { /* SEGMENT BOTH */
1502
0
            URI_FUNC(StopMalloc)(state, memory);
1503
0
            return NULL;
1504
0
        }
1505
4.41k
        return URI_FUNC(ParsePathAbsEmpty)(state, afterSegment, afterLast, memory);
1506
4.41k
    }
1507
1508
236
    default:
1509
236
        return first;
1510
4.64k
    }
1511
4.64k
}
UriParse.c:uriParsePathAbsEmptyW
Line
Count
Source
1488
9.31k
                                                    UriMemoryManager * memory) {
1489
9.31k
    if (first >= afterLast) {
1490
4.60k
        return afterLast;
1491
4.60k
    }
1492
1493
4.70k
    switch (*first) {
1494
4.05k
    case _UT('/'): {
1495
4.05k
        const URI_CHAR * const afterSegment =
1496
4.05k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1497
4.05k
        if (afterSegment == NULL) {
1498
3
            return NULL;
1499
3
        }
1500
4.05k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1501
4.05k
                                       memory)) { /* SEGMENT BOTH */
1502
0
            URI_FUNC(StopMalloc)(state, memory);
1503
0
            return NULL;
1504
0
        }
1505
4.05k
        return URI_FUNC(ParsePathAbsEmpty)(state, afterSegment, afterLast, memory);
1506
4.05k
    }
1507
1508
655
    default:
1509
655
        return first;
1510
4.70k
    }
1511
4.70k
}
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
29
    case _UT('!'):
1526
62
    case _UT('$'):
1527
94
    case _UT('%'):
1528
137
    case _UT('&'):
1529
176
    case _UT('('):
1530
220
    case _UT(')'):
1531
292
    case _UT('-'):
1532
322
    case _UT('*'):
1533
365
    case _UT(','):
1534
503
    case _UT('.'):
1535
653
    case _UT(':'):
1536
706
    case _UT(';'):
1537
814
    case _UT('@'):
1538
867
    case _UT('\''):
1539
898
    case _UT('_'):
1540
920
    case _UT('~'):
1541
972
    case _UT('+'):
1542
1.01k
    case _UT('='):
1543
11.3k
    case URI_SET_DIGIT:
1544
113k
    case URI_SET_ALPHA: {
1545
113k
        const URI_CHAR * const afterSegmentNz =
1546
113k
            URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1547
113k
        if (afterSegmentNz == NULL) {
1548
44
            return NULL;
1549
44
        }
1550
2.92k
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1551
2.92k
                                       memory)) { /* SEGMENT BOTH */
1552
0
            URI_FUNC(StopMalloc)(state, memory);
1553
0
            return NULL;
1554
0
        }
1555
2.92k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1556
2.92k
    }
1557
1558
149
    default:
1559
149
        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
16
    case _UT('!'):
1526
30
    case _UT('$'):
1527
38
    case _UT('%'):
1528
53
    case _UT('&'):
1529
62
    case _UT('('):
1530
77
    case _UT(')'):
1531
111
    case _UT('-'):
1532
130
    case _UT('*'):
1533
147
    case _UT(','):
1534
208
    case _UT('.'):
1535
262
    case _UT(':'):
1536
287
    case _UT(';'):
1537
325
    case _UT('@'):
1538
360
    case _UT('\''):
1539
376
    case _UT('_'):
1540
386
    case _UT('~'):
1541
407
    case _UT('+'):
1542
431
    case _UT('='):
1543
4.88k
    case URI_SET_DIGIT:
1544
51.4k
    case URI_SET_ALPHA: {
1545
51.4k
        const URI_CHAR * const afterSegmentNz =
1546
51.4k
            URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1547
51.4k
        if (afterSegmentNz == NULL) {
1548
20
            return NULL;
1549
20
        }
1550
1.37k
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1551
1.37k
                                       memory)) { /* SEGMENT BOTH */
1552
0
            URI_FUNC(StopMalloc)(state, memory);
1553
0
            return NULL;
1554
0
        }
1555
1.37k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1556
1.37k
    }
1557
1558
31
    default:
1559
31
        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
32
    case _UT('$'):
1527
56
    case _UT('%'):
1528
84
    case _UT('&'):
1529
114
    case _UT('('):
1530
143
    case _UT(')'):
1531
181
    case _UT('-'):
1532
192
    case _UT('*'):
1533
218
    case _UT(','):
1534
295
    case _UT('.'):
1535
391
    case _UT(':'):
1536
419
    case _UT(';'):
1537
489
    case _UT('@'):
1538
507
    case _UT('\''):
1539
522
    case _UT('_'):
1540
534
    case _UT('~'):
1541
565
    case _UT('+'):
1542
581
    case _UT('='):
1543
6.50k
    case URI_SET_DIGIT:
1544
62.1k
    case URI_SET_ALPHA: {
1545
62.1k
        const URI_CHAR * const afterSegmentNz =
1546
62.1k
            URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1547
62.1k
        if (afterSegmentNz == NULL) {
1548
24
            return NULL;
1549
24
        }
1550
1.55k
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1551
1.55k
                                       memory)) { /* SEGMENT BOTH */
1552
0
            URI_FUNC(StopMalloc)(state, memory);
1553
0
            return NULL;
1554
0
        }
1555
1.55k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1556
1.55k
    }
1557
1558
118
    default:
1559
118
        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.28k
                            const URI_CHAR * afterLast, UriMemoryManager * memory) {
1569
1.28k
    const URI_CHAR * const afterSegmentNz =
1570
1.28k
        URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1571
1.28k
    if (afterSegmentNz == NULL) {
1572
11
        return NULL;
1573
1.27k
    } else {
1574
1.27k
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1575
1.27k
                                       memory)) { /* SEGMENT BOTH */
1576
0
            URI_FUNC(StopMalloc)(state, memory);
1577
0
            return NULL;
1578
0
        }
1579
1.27k
    }
1580
1.27k
    return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1581
1.28k
}
UriParse.c:uriParsePathRootlessA
Line
Count
Source
1568
694
                            const URI_CHAR * afterLast, UriMemoryManager * memory) {
1569
694
    const URI_CHAR * const afterSegmentNz =
1570
694
        URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1571
694
    if (afterSegmentNz == NULL) {
1572
6
        return NULL;
1573
688
    } else {
1574
688
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1575
688
                                       memory)) { /* SEGMENT BOTH */
1576
0
            URI_FUNC(StopMalloc)(state, memory);
1577
0
            return NULL;
1578
0
        }
1579
688
    }
1580
688
    return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1581
694
}
UriParse.c:uriParsePathRootlessW
Line
Count
Source
1568
589
                            const URI_CHAR * afterLast, UriMemoryManager * memory) {
1569
589
    const URI_CHAR * const afterSegmentNz =
1570
589
        URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory);
1571
589
    if (afterSegmentNz == NULL) {
1572
5
        return NULL;
1573
584
    } else {
1574
584
        if (!URI_FUNC(PushPathSegment)(state, first, afterSegmentNz,
1575
584
                                       memory)) { /* SEGMENT BOTH */
1576
0
            URI_FUNC(StopMalloc)(state, memory);
1577
0
            return NULL;
1578
0
        }
1579
584
    }
1580
584
    return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegmentNz, afterLast, memory);
1581
589
}
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.2M
                                             UriMemoryManager * memory) {
1594
10.2M
    if (first >= afterLast) {
1595
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1596
0
        return NULL;
1597
0
    }
1598
1599
10.2M
    switch (*first) {
1600
25.8k
    case _UT('%'):
1601
25.8k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1602
1603
8.10k
    case _UT(':'):
1604
11.0k
    case _UT('@'):
1605
13.5k
    case _UT('!'):
1606
18.6k
    case _UT('$'):
1607
20.7k
    case _UT('&'):
1608
23.3k
    case _UT('('):
1609
28.4k
    case _UT(')'):
1610
31.9k
    case _UT('*'):
1611
35.4k
    case _UT(','):
1612
40.0k
    case _UT(';'):
1613
44.0k
    case _UT('\''):
1614
51.6k
    case _UT('+'):
1615
59.0k
    case _UT('='):
1616
75.7k
    case _UT('-'):
1617
182k
    case _UT('.'):
1618
185k
    case _UT('_'):
1619
188k
    case _UT('~'):
1620
14.8M
    case URI_SET_DIGIT:
1621
14.8M
    case URI_SET_ALPHA:
1622
10.2M
        return first + 1;
1623
1624
0
    default:
1625
0
        URI_FUNC(StopSyntax)(state, first, memory);
1626
0
        return NULL;
1627
10.2M
    }
1628
10.2M
}
UriParse.c:uriParsePcharA
Line
Count
Source
1593
8.37M
                                             UriMemoryManager * memory) {
1594
8.37M
    if (first >= afterLast) {
1595
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1596
0
        return NULL;
1597
0
    }
1598
1599
8.37M
    switch (*first) {
1600
16.2k
    case _UT('%'):
1601
16.2k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1602
1603
3.48k
    case _UT(':'):
1604
5.15k
    case _UT('@'):
1605
6.73k
    case _UT('!'):
1606
10.7k
    case _UT('$'):
1607
11.9k
    case _UT('&'):
1608
13.6k
    case _UT('('):
1609
17.3k
    case _UT(')'):
1610
18.9k
    case _UT('*'):
1611
21.1k
    case _UT(','):
1612
24.7k
    case _UT(';'):
1613
26.9k
    case _UT('\''):
1614
33.3k
    case _UT('+'):
1615
39.8k
    case _UT('='):
1616
54.9k
    case _UT('-'):
1617
136k
    case _UT('.'):
1618
138k
    case _UT('_'):
1619
140k
    case _UT('~'):
1620
12.0M
    case URI_SET_DIGIT:
1621
12.0M
    case URI_SET_ALPHA:
1622
8.36M
        return first + 1;
1623
1624
0
    default:
1625
0
        URI_FUNC(StopSyntax)(state, first, memory);
1626
        return NULL;
1627
8.37M
    }
1628
8.37M
}
UriParse.c:uriParsePcharW
Line
Count
Source
1593
1.86M
                                             UriMemoryManager * memory) {
1594
1.86M
    if (first >= afterLast) {
1595
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1596
0
        return NULL;
1597
0
    }
1598
1599
1.86M
    switch (*first) {
1600
9.51k
    case _UT('%'):
1601
9.51k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1602
1603
4.62k
    case _UT(':'):
1604
5.86k
    case _UT('@'):
1605
6.83k
    case _UT('!'):
1606
7.84k
    case _UT('$'):
1607
8.78k
    case _UT('&'):
1608
9.66k
    case _UT('('):
1609
11.1k
    case _UT(')'):
1610
12.9k
    case _UT('*'):
1611
14.2k
    case _UT(','):
1612
15.3k
    case _UT(';'):
1613
17.0k
    case _UT('\''):
1614
18.3k
    case _UT('+'):
1615
19.2k
    case _UT('='):
1616
20.7k
    case _UT('-'):
1617
45.8k
    case _UT('.'):
1618
47.0k
    case _UT('_'):
1619
48.6k
    case _UT('~'):
1620
2.84M
    case URI_SET_DIGIT:
1621
2.84M
    case URI_SET_ALPHA:
1622
1.85M
        return first + 1;
1623
1624
0
    default:
1625
0
        URI_FUNC(StopSyntax)(state, first, memory);
1626
        return NULL;
1627
1.86M
    }
1628
1.86M
}
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
75.5k
                                                  UriMemoryManager * memory) {
1637
75.5k
    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
75.5k
    if (afterLast - first < 2) {
1650
274
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1651
274
        return NULL;
1652
274
    }
1653
1654
75.3k
    switch (first[1]) {
1655
1.03M
    case URI_SET_HEXDIG:
1656
1.03M
        if (afterLast - first < 3) {
1657
641
            URI_FUNC(StopSyntax)(state, afterLast, memory);
1658
641
            return NULL;
1659
641
        }
1660
1661
74.6k
        switch (first[2]) {
1662
74.5k
        case URI_SET_HEXDIG:
1663
74.5k
            return first + 3;
1664
1665
107
        default:
1666
107
            URI_FUNC(StopSyntax)(state, first + 2, memory);
1667
107
            return NULL;
1668
74.6k
        }
1669
1670
52
    default:
1671
52
        URI_FUNC(StopSyntax)(state, first + 1, memory);
1672
52
        return NULL;
1673
75.3k
    }
1674
1675
    /*
1676
    default:
1677
            URI_FUNC(StopSyntax)(state, first, memory);
1678
            return NULL;
1679
    }
1680
    */
1681
75.3k
}
UriParse.c:uriParsePctEncodedA
Line
Count
Source
1636
41.1k
                                                  UriMemoryManager * memory) {
1637
41.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
41.1k
    if (afterLast - first < 2) {
1650
139
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1651
139
        return NULL;
1652
139
    }
1653
1654
40.9k
    switch (first[1]) {
1655
549k
    case URI_SET_HEXDIG:
1656
549k
        if (afterLast - first < 3) {
1657
316
            URI_FUNC(StopSyntax)(state, afterLast, memory);
1658
316
            return NULL;
1659
316
        }
1660
1661
40.6k
        switch (first[2]) {
1662
40.5k
        case URI_SET_HEXDIG:
1663
40.5k
            return first + 3;
1664
1665
54
        default:
1666
54
            URI_FUNC(StopSyntax)(state, first + 2, memory);
1667
54
            return NULL;
1668
40.6k
        }
1669
1670
28
    default:
1671
28
        URI_FUNC(StopSyntax)(state, first + 1, memory);
1672
28
        return NULL;
1673
40.9k
    }
1674
1675
    /*
1676
    default:
1677
            URI_FUNC(StopSyntax)(state, first, memory);
1678
            return NULL;
1679
    }
1680
    */
1681
40.9k
}
UriParse.c:uriParsePctEncodedW
Line
Count
Source
1636
34.4k
                                                  UriMemoryManager * memory) {
1637
34.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
34.4k
    if (afterLast - first < 2) {
1650
135
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1651
135
        return NULL;
1652
135
    }
1653
1654
34.3k
    switch (first[1]) {
1655
482k
    case URI_SET_HEXDIG:
1656
482k
        if (afterLast - first < 3) {
1657
325
            URI_FUNC(StopSyntax)(state, afterLast, memory);
1658
325
            return NULL;
1659
325
        }
1660
1661
34.0k
        switch (first[2]) {
1662
33.9k
        case URI_SET_HEXDIG:
1663
33.9k
            return first + 3;
1664
1665
53
        default:
1666
53
            URI_FUNC(StopSyntax)(state, first + 2, memory);
1667
53
            return NULL;
1668
34.0k
        }
1669
1670
24
    default:
1671
24
        URI_FUNC(StopSyntax)(state, first + 1, memory);
1672
24
        return NULL;
1673
34.3k
    }
1674
1675
    /*
1676
    default:
1677
            URI_FUNC(StopSyntax)(state, first, memory);
1678
            return NULL;
1679
    }
1680
    */
1681
34.3k
}
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.82M
                                                   UriMemoryManager * memory) {
1692
8.82M
    if (first >= afterLast) {
1693
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1694
0
        return NULL;
1695
0
    }
1696
1697
8.82M
    switch (*first) {
1698
16.2k
    case _UT('%'):
1699
16.2k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1700
1701
3.51k
    case _UT('!'):
1702
7.11k
    case _UT('$'):
1703
11.3k
    case _UT('&'):
1704
14.7k
    case _UT('('):
1705
23.7k
    case _UT(')'):
1706
29.4k
    case _UT('*'):
1707
33.3k
    case _UT(','):
1708
37.5k
    case _UT(';'):
1709
47.5k
    case _UT('\''):
1710
51.6k
    case _UT('+'):
1711
57.4k
    case _UT('='):
1712
79.3k
    case _UT('-'):
1713
137k
    case _UT('.'):
1714
141k
    case _UT('_'):
1715
145k
    case _UT('~'):
1716
9.01M
    case URI_SET_DIGIT:
1717
9.01M
    case URI_SET_ALPHA:
1718
8.81M
        return first + 1;
1719
1720
0
    default:
1721
0
        URI_FUNC(StopSyntax)(state, first, memory);
1722
0
        return NULL;
1723
8.82M
    }
1724
8.82M
}
UriParse.c:uriParsePctSubUnresA
Line
Count
Source
1691
7.40M
                                                   UriMemoryManager * memory) {
1692
7.40M
    if (first >= afterLast) {
1693
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1694
0
        return NULL;
1695
0
    }
1696
1697
7.40M
    switch (*first) {
1698
5.65k
    case _UT('%'):
1699
5.65k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1700
1701
2.10k
    case _UT('!'):
1702
4.19k
    case _UT('$'):
1703
6.68k
    case _UT('&'):
1704
8.73k
    case _UT('('):
1705
11.4k
    case _UT(')'):
1706
13.3k
    case _UT('*'):
1707
15.1k
    case _UT(','):
1708
17.5k
    case _UT(';'):
1709
20.4k
    case _UT('\''):
1710
22.1k
    case _UT('+'):
1711
26.1k
    case _UT('='):
1712
42.5k
    case _UT('-'):
1713
96.9k
    case _UT('.'):
1714
98.5k
    case _UT('_'):
1715
100k
    case _UT('~'):
1716
6.76M
    case URI_SET_DIGIT:
1717
7.39M
    case URI_SET_ALPHA:
1718
7.39M
        return first + 1;
1719
1720
0
    default:
1721
0
        URI_FUNC(StopSyntax)(state, first, memory);
1722
        return NULL;
1723
7.40M
    }
1724
7.40M
}
UriParse.c:uriParsePctSubUnresW
Line
Count
Source
1691
1.42M
                                                   UriMemoryManager * memory) {
1692
1.42M
    if (first >= afterLast) {
1693
0
        URI_FUNC(StopSyntax)(state, afterLast, memory);
1694
0
        return NULL;
1695
0
    }
1696
1697
1.42M
    switch (*first) {
1698
10.5k
    case _UT('%'):
1699
10.5k
        return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1700
1701
1.40k
    case _UT('!'):
1702
2.91k
    case _UT('$'):
1703
4.64k
    case _UT('&'):
1704
6.03k
    case _UT('('):
1705
12.2k
    case _UT(')'):
1706
16.1k
    case _UT('*'):
1707
18.1k
    case _UT(','):
1708
19.9k
    case _UT(';'):
1709
27.1k
    case _UT('\''):
1710
29.4k
    case _UT('+'):
1711
31.2k
    case _UT('='):
1712
36.7k
    case _UT('-'):
1713
40.2k
    case _UT('.'):
1714
42.7k
    case _UT('_'):
1715
45.5k
    case _UT('~'):
1716
2.25M
    case URI_SET_DIGIT:
1717
2.25M
    case URI_SET_ALPHA:
1718
1.41M
        return first + 1;
1719
1720
0
    default:
1721
0
        URI_FUNC(StopSyntax)(state, first, memory);
1722
        return NULL;
1723
1.42M
    }
1724
1.42M
}
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.00M
                                            const URI_CHAR * afterLast) {
1733
4.00M
    if (first >= afterLast) {
1734
198
        return afterLast;
1735
198
    }
1736
1737
4.00M
    switch (*first) {
1738
4.00M
    case URI_SET_DIGIT:
1739
4.00M
        return URI_FUNC(ParsePort)(state, first + 1, afterLast);
1740
1741
374
    default:
1742
374
        return first;
1743
4.00M
    }
1744
4.00M
}
UriParse.c:uriParsePortA
Line
Count
Source
1732
4.00M
                                            const URI_CHAR * afterLast) {
1733
4.00M
    if (first >= afterLast) {
1734
119
        return afterLast;
1735
119
    }
1736
1737
4.00M
    switch (*first) {
1738
4.00M
    case URI_SET_DIGIT:
1739
4.00M
        return URI_FUNC(ParsePort)(state, first + 1, afterLast);
1740
1741
115
    default:
1742
115
        return first;
1743
4.00M
    }
1744
4.00M
}
UriParse.c:uriParsePortW
Line
Count
Source
1732
1.57k
                                            const URI_CHAR * afterLast) {
1733
1.57k
    if (first >= afterLast) {
1734
79
        return afterLast;
1735
79
    }
1736
1737
1.49k
    switch (*first) {
1738
1.23k
    case URI_SET_DIGIT:
1739
1.23k
        return URI_FUNC(ParsePort)(state, first + 1, afterLast);
1740
1741
259
    default:
1742
259
        return first;
1743
1.49k
    }
1744
1.49k
}
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.04M
                                                 UriMemoryManager * memory) {
1756
8.04M
    if (first >= afterLast) {
1757
3.07k
        return afterLast;
1758
3.07k
    }
1759
1760
8.04M
    switch (*first) {
1761
1.25k
    case _UT('!'):
1762
4.97k
    case _UT('$'):
1763
18.1k
    case _UT('%'):
1764
19.1k
    case _UT('&'):
1765
20.6k
    case _UT('('):
1766
22.7k
    case _UT(')'):
1767
35.8k
    case _UT('-'):
1768
37.1k
    case _UT('*'):
1769
38.9k
    case _UT(','):
1770
94.3k
    case _UT('.'):
1771
96.5k
    case _UT(':'):
1772
98.7k
    case _UT(';'):
1773
99.7k
    case _UT('@'):
1774
101k
    case _UT('\''):
1775
103k
    case _UT('_'):
1776
105k
    case _UT('~'):
1777
108k
    case _UT('+'):
1778
111k
    case _UT('='):
1779
12.1M
    case URI_SET_DIGIT:
1780
244M
    case URI_SET_ALPHA: {
1781
244M
        const URI_CHAR * const afterPchar =
1782
244M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1783
244M
        if (afterPchar == NULL) {
1784
53
            return NULL;
1785
53
        }
1786
8.03M
        return URI_FUNC(ParseQueryFrag)(state, afterPchar, afterLast, memory);
1787
244M
    }
1788
1789
6.56k
    case _UT('/'):
1790
8.10k
    case _UT('?'):
1791
8.10k
        return URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
1792
1793
207
    default:
1794
207
        return first;
1795
8.04M
    }
1796
8.04M
}
UriParse.c:uriParseQueryFragA
Line
Count
Source
1755
6.87M
                                                 UriMemoryManager * memory) {
1756
6.87M
    if (first >= afterLast) {
1757
1.56k
        return afterLast;
1758
1.56k
    }
1759
1760
6.87M
    switch (*first) {
1761
852
    case _UT('!'):
1762
4.05k
    case _UT('$'):
1763
13.6k
    case _UT('%'):
1764
14.2k
    case _UT('&'):
1765
15.3k
    case _UT('('):
1766
16.8k
    case _UT(')'):
1767
29.2k
    case _UT('-'):
1768
30.0k
    case _UT('*'):
1769
31.1k
    case _UT(','):
1770
83.2k
    case _UT('.'):
1771
83.8k
    case _UT(':'):
1772
85.5k
    case _UT(';'):
1773
86.2k
    case _UT('@'):
1774
87.3k
    case _UT('\''):
1775
89.1k
    case _UT('_'):
1776
89.8k
    case _UT('~'):
1777
93.1k
    case _UT('+'):
1778
95.6k
    case _UT('='):
1779
10.4M
    case URI_SET_DIGIT:
1780
214M
    case URI_SET_ALPHA: {
1781
214M
        const URI_CHAR * const afterPchar =
1782
214M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1783
214M
        if (afterPchar == NULL) {
1784
26
            return NULL;
1785
26
        }
1786
6.86M
        return URI_FUNC(ParseQueryFrag)(state, afterPchar, afterLast, memory);
1787
214M
    }
1788
1789
4.14k
    case _UT('/'):
1790
5.25k
    case _UT('?'):
1791
5.25k
        return URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
1792
1793
68
    default:
1794
68
        return first;
1795
6.87M
    }
1796
6.87M
}
UriParse.c:uriParseQueryFragW
Line
Count
Source
1755
1.17M
                                                 UriMemoryManager * memory) {
1756
1.17M
    if (first >= afterLast) {
1757
1.50k
        return afterLast;
1758
1.50k
    }
1759
1760
1.16M
    switch (*first) {
1761
399
    case _UT('!'):
1762
916
    case _UT('$'):
1763
4.48k
    case _UT('%'):
1764
4.90k
    case _UT('&'):
1765
5.31k
    case _UT('('):
1766
5.86k
    case _UT(')'):
1767
6.61k
    case _UT('-'):
1768
7.12k
    case _UT('*'):
1769
7.79k
    case _UT(','):
1770
11.1k
    case _UT('.'):
1771
12.7k
    case _UT(':'):
1772
13.1k
    case _UT(';'):
1773
13.5k
    case _UT('@'):
1774
14.1k
    case _UT('\''):
1775
14.6k
    case _UT('_'):
1776
15.1k
    case _UT('~'):
1777
15.6k
    case _UT('+'):
1778
16.0k
    case _UT('='):
1779
1.66M
    case URI_SET_DIGIT:
1780
30.4M
    case URI_SET_ALPHA: {
1781
30.4M
        const URI_CHAR * const afterPchar =
1782
30.4M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1783
30.4M
        if (afterPchar == NULL) {
1784
27
            return NULL;
1785
27
        }
1786
1.16M
        return URI_FUNC(ParseQueryFrag)(state, afterPchar, afterLast, memory);
1787
30.4M
    }
1788
1789
2.42k
    case _UT('/'):
1790
2.84k
    case _UT('?'):
1791
2.84k
        return URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
1792
1793
139
    default:
1794
139
        return first;
1795
1.16M
    }
1796
1.16M
}
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.26M
                                               UriMemoryManager * memory) {
1806
2.26M
    if (first >= afterLast) {
1807
5.50k
        return afterLast;
1808
5.50k
    }
1809
1810
2.26M
    switch (*first) {
1811
1.26k
    case _UT('!'):
1812
2.55k
    case _UT('$'):
1813
15.1k
    case _UT('%'):
1814
16.1k
    case _UT('&'):
1815
17.1k
    case _UT('('):
1816
20.2k
    case _UT(')'):
1817
23.6k
    case _UT('-'):
1818
25.7k
    case _UT('*'):
1819
27.4k
    case _UT(','):
1820
78.3k
    case _UT('.'):
1821
83.9k
    case _UT(':'):
1822
86.3k
    case _UT(';'):
1823
88.0k
    case _UT('@'):
1824
90.3k
    case _UT('\''):
1825
91.7k
    case _UT('_'):
1826
93.4k
    case _UT('~'):
1827
97.2k
    case _UT('+'):
1828
101k
    case _UT('='):
1829
2.93M
    case URI_SET_DIGIT:
1830
68.2M
    case URI_SET_ALPHA: {
1831
68.2M
        const URI_CHAR * const afterPchar =
1832
68.2M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1833
68.2M
        if (afterPchar == NULL) {
1834
85
            return NULL;
1835
85
        }
1836
2.20M
        return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1837
68.2M
    }
1838
1839
53.4k
    default:
1840
53.4k
        return first;
1841
2.26M
    }
1842
2.26M
}
UriParse.c:uriParseSegmentA
Line
Count
Source
1805
1.54M
                                               UriMemoryManager * memory) {
1806
1.54M
    if (first >= afterLast) {
1807
2.81k
        return afterLast;
1808
2.81k
    }
1809
1810
1.53M
    switch (*first) {
1811
714
    case _UT('!'):
1812
1.53k
    case _UT('$'):
1813
8.23k
    case _UT('%'):
1814
8.72k
    case _UT('&'):
1815
9.33k
    case _UT('('):
1816
11.4k
    case _UT(')'):
1817
14.1k
    case _UT('-'):
1818
15.0k
    case _UT('*'):
1819
16.0k
    case _UT(','):
1820
45.2k
    case _UT('.'):
1821
48.0k
    case _UT(':'):
1822
49.8k
    case _UT(';'):
1823
50.8k
    case _UT('@'):
1824
51.9k
    case _UT('\''):
1825
52.6k
    case _UT('_'):
1826
53.3k
    case _UT('~'):
1827
56.3k
    case _UT('+'):
1828
60.3k
    case _UT('='):
1829
1.68M
    case URI_SET_DIGIT:
1830
49.1M
    case URI_SET_ALPHA: {
1831
49.1M
        const URI_CHAR * const afterPchar =
1832
49.1M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1833
49.1M
        if (afterPchar == NULL) {
1834
40
            return NULL;
1835
40
        }
1836
1.51M
        return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1837
49.1M
    }
1838
1839
27.3k
    default:
1840
27.3k
        return first;
1841
1.53M
    }
1842
1.53M
}
UriParse.c:uriParseSegmentW
Line
Count
Source
1805
723k
                                               UriMemoryManager * memory) {
1806
723k
    if (first >= afterLast) {
1807
2.69k
        return afterLast;
1808
2.69k
    }
1809
1810
721k
    switch (*first) {
1811
552
    case _UT('!'):
1812
1.01k
    case _UT('$'):
1813
6.93k
    case _UT('%'):
1814
7.42k
    case _UT('&'):
1815
7.85k
    case _UT('('):
1816
8.78k
    case _UT(')'):
1817
9.49k
    case _UT('-'):
1818
10.7k
    case _UT('*'):
1819
11.3k
    case _UT(','):
1820
33.0k
    case _UT('.'):
1821
35.8k
    case _UT(':'):
1822
36.4k
    case _UT(';'):
1823
37.2k
    case _UT('@'):
1824
38.4k
    case _UT('\''):
1825
39.1k
    case _UT('_'):
1826
40.1k
    case _UT('~'):
1827
40.9k
    case _UT('+'):
1828
41.3k
    case _UT('='):
1829
1.25M
    case URI_SET_DIGIT:
1830
19.1M
    case URI_SET_ALPHA: {
1831
19.1M
        const URI_CHAR * const afterPchar =
1832
19.1M
            URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1833
19.1M
        if (afterPchar == NULL) {
1834
45
            return NULL;
1835
45
        }
1836
694k
        return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1837
19.1M
    }
1838
1839
26.0k
    default:
1840
26.0k
        return first;
1841
721k
    }
1842
721k
}
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.25k
                                                            UriMemoryManager * memory) {
1851
4.25k
    const URI_CHAR * const afterPchar =
1852
4.25k
        URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1853
4.25k
    if (afterPchar == NULL) {
1854
15
        return NULL;
1855
15
    }
1856
4.24k
    return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1857
4.25k
}
UriParse.c:uriParseSegmentNzA
Line
Count
Source
1850
2.08k
                                                            UriMemoryManager * memory) {
1851
2.08k
    const URI_CHAR * const afterPchar =
1852
2.08k
        URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1853
2.08k
    if (afterPchar == NULL) {
1854
8
        return NULL;
1855
8
    }
1856
2.07k
    return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1857
2.08k
}
UriParse.c:uriParseSegmentNzW
Line
Count
Source
1850
2.16k
                                                            UriMemoryManager * memory) {
1851
2.16k
    const URI_CHAR * const afterPchar =
1852
2.16k
        URI_FUNC(ParsePchar)(state, first, afterLast, memory);
1853
2.16k
    if (afterPchar == NULL) {
1854
7
        return NULL;
1855
7
    }
1856
2.16k
    return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory);
1857
2.16k
}
1858
1859
static URI_INLINE UriBool URI_FUNC(OnExitSegmentNzNcOrScheme2)(
1860
3.67k
    URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory) {
1861
3.67k
    if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1862
3.67k
                                   memory)) { /* SEGMENT BOTH */
1863
0
        return URI_FALSE; /* Raises malloc error*/
1864
0
    }
1865
3.67k
    state->uri->scheme.first = NULL; /* Not a scheme, reset */
1866
3.67k
    return URI_TRUE; /* Success */
1867
3.67k
}
UriParse.c:uriOnExitSegmentNzNcOrScheme2A
Line
Count
Source
1860
2.00k
    URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory) {
1861
2.00k
    if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1862
2.00k
                                   memory)) { /* SEGMENT BOTH */
1863
0
        return URI_FALSE; /* Raises malloc error*/
1864
0
    }
1865
2.00k
    state->uri->scheme.first = NULL; /* Not a scheme, reset */
1866
2.00k
    return URI_TRUE; /* Success */
1867
2.00k
}
UriParse.c:uriOnExitSegmentNzNcOrScheme2W
Line
Count
Source
1860
1.67k
    URI_TYPE(ParserState) * state, const URI_CHAR * first, UriMemoryManager * memory) {
1861
1.67k
    if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1862
1.67k
                                   memory)) { /* SEGMENT BOTH */
1863
0
        return URI_FALSE; /* Raises malloc error*/
1864
0
    }
1865
1.67k
    state->uri->scheme.first = NULL; /* Not a scheme, reset */
1866
1.67k
    return URI_TRUE; /* Success */
1867
1.67k
}
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.79M
                                                            UriMemoryManager * memory) {
1897
3.79M
    if (first >= afterLast) {
1898
3.49k
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1899
0
            URI_FUNC(StopMalloc)(state, memory);
1900
0
            return NULL;
1901
0
        }
1902
3.49k
        return afterLast;
1903
3.49k
    }
1904
1905
3.78M
    switch (*first) {
1906
8.99k
    case _UT('.'):
1907
10.3k
    case _UT('+'):
1908
13.1k
    case _UT('-'):
1909
54.7M
    case URI_SET_ALPHA:
1910
54.7M
    case URI_SET_DIGIT:
1911
3.78M
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
1912
1913
100
    case _UT('%'): {
1914
100
        const URI_CHAR * const afterPctEncoded =
1915
100
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1916
100
        if (afterPctEncoded == NULL) {
1917
6
            return NULL;
1918
6
        }
1919
94
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
1920
94
                                                memory);
1921
100
    }
1922
1923
32
    case _UT('!'):
1924
53
    case _UT('$'):
1925
68
    case _UT('&'):
1926
83
    case _UT('('):
1927
99
    case _UT(')'):
1928
121
    case _UT('*'):
1929
140
    case _UT(','):
1930
157
    case _UT(';'):
1931
180
    case _UT('@'):
1932
200
    case _UT('_'):
1933
213
    case _UT('~'):
1934
239
    case _UT('='):
1935
260
    case _UT('\''):
1936
260
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1937
1938
562
    case _UT('/'): {
1939
562
        const URI_CHAR * afterZeroMoreSlashSegs;
1940
562
        const URI_CHAR * const afterSegment =
1941
562
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1942
562
        if (afterSegment == NULL) {
1943
5
            return NULL;
1944
5
        }
1945
557
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1946
557
                                       memory)) { /* SEGMENT BOTH */
1947
0
            URI_FUNC(StopMalloc)(state, memory);
1948
0
            return NULL;
1949
0
        }
1950
557
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1951
557
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1952
557
                                       memory)) { /* SEGMENT BOTH */
1953
0
            URI_FUNC(StopMalloc)(state, memory);
1954
0
            return NULL;
1955
0
        }
1956
557
        afterZeroMoreSlashSegs =
1957
557
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1958
557
        if (afterZeroMoreSlashSegs == NULL) {
1959
6
            return NULL;
1960
6
        }
1961
551
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1962
557
    }
1963
1964
2.02k
    case _UT(':'): {
1965
2.02k
        const URI_CHAR * const afterHierPart =
1966
2.02k
            URI_FUNC(ParseHierPart)(state, first + 1, afterLast, memory);
1967
2.02k
        state->uri->scheme.afterLast = first; /* SCHEME END */
1968
2.02k
        if (afterHierPart == NULL) {
1969
25
            return NULL;
1970
25
        }
1971
2.00k
        return URI_FUNC(ParseUriTail)(state, afterHierPart, afterLast, memory);
1972
2.02k
    }
1973
1974
174
    default:
1975
174
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1976
0
            URI_FUNC(StopMalloc)(state, memory);
1977
0
            return NULL;
1978
0
        }
1979
174
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1980
3.78M
    }
1981
3.78M
}
UriParse.c:uriParseSegmentNzNcOrScheme2A
Line
Count
Source
1896
2.38M
                                                            UriMemoryManager * memory) {
1897
2.38M
    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.38M
    switch (*first) {
1906
7.25k
    case _UT('.'):
1907
8.15k
    case _UT('+'):
1908
10.0k
    case _UT('-'):
1909
38.0M
    case URI_SET_ALPHA:
1910
38.0M
    case URI_SET_DIGIT:
1911
2.38M
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
1912
1913
56
    case _UT('%'): {
1914
56
        const URI_CHAR * const afterPctEncoded =
1915
56
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1916
56
        if (afterPctEncoded == NULL) {
1917
4
            return NULL;
1918
4
        }
1919
52
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
1920
52
                                                memory);
1921
56
    }
1922
1923
24
    case _UT('!'):
1924
36
    case _UT('$'):
1925
42
    case _UT('&'):
1926
52
    case _UT('('):
1927
59
    case _UT(')'):
1928
74
    case _UT('*'):
1929
85
    case _UT(','):
1930
96
    case _UT(';'):
1931
110
    case _UT('@'):
1932
118
    case _UT('_'):
1933
125
    case _UT('~'):
1934
146
    case _UT('='):
1935
160
    case _UT('\''):
1936
160
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1937
1938
294
    case _UT('/'): {
1939
294
        const URI_CHAR * afterZeroMoreSlashSegs;
1940
294
        const URI_CHAR * const afterSegment =
1941
294
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1942
294
        if (afterSegment == NULL) {
1943
2
            return NULL;
1944
2
        }
1945
292
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1946
292
                                       memory)) { /* SEGMENT BOTH */
1947
0
            URI_FUNC(StopMalloc)(state, memory);
1948
0
            return NULL;
1949
0
        }
1950
292
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1951
292
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1952
292
                                       memory)) { /* SEGMENT BOTH */
1953
0
            URI_FUNC(StopMalloc)(state, memory);
1954
0
            return NULL;
1955
0
        }
1956
292
        afterZeroMoreSlashSegs =
1957
292
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1958
292
        if (afterZeroMoreSlashSegs == NULL) {
1959
2
            return NULL;
1960
2
        }
1961
290
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1962
292
    }
1963
1964
1.07k
    case _UT(':'): {
1965
1.07k
        const URI_CHAR * const afterHierPart =
1966
1.07k
            URI_FUNC(ParseHierPart)(state, first + 1, afterLast, memory);
1967
1.07k
        state->uri->scheme.afterLast = first; /* SCHEME END */
1968
1.07k
        if (afterHierPart == NULL) {
1969
14
            return NULL;
1970
14
        }
1971
1.05k
        return URI_FUNC(ParseUriTail)(state, afterHierPart, afterLast, memory);
1972
1.07k
    }
1973
1974
88
    default:
1975
88
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1976
0
            URI_FUNC(StopMalloc)(state, memory);
1977
0
            return NULL;
1978
0
        }
1979
88
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1980
2.38M
    }
1981
2.38M
}
UriParse.c:uriParseSegmentNzNcOrScheme2W
Line
Count
Source
1896
1.40M
                                                            UriMemoryManager * memory) {
1897
1.40M
    if (first >= afterLast) {
1898
1.58k
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1899
0
            URI_FUNC(StopMalloc)(state, memory);
1900
0
            return NULL;
1901
0
        }
1902
1.58k
        return afterLast;
1903
1.58k
    }
1904
1905
1.40M
    switch (*first) {
1906
1.74k
    case _UT('.'):
1907
2.20k
    case _UT('+'):
1908
3.05k
    case _UT('-'):
1909
16.7M
    case URI_SET_ALPHA:
1910
16.7M
    case URI_SET_DIGIT:
1911
1.39M
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
1912
1913
44
    case _UT('%'): {
1914
44
        const URI_CHAR * const afterPctEncoded =
1915
44
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
1916
44
        if (afterPctEncoded == NULL) {
1917
2
            return NULL;
1918
2
        }
1919
42
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
1920
42
                                                memory);
1921
44
    }
1922
1923
8
    case _UT('!'):
1924
17
    case _UT('$'):
1925
26
    case _UT('&'):
1926
31
    case _UT('('):
1927
40
    case _UT(')'):
1928
47
    case _UT('*'):
1929
55
    case _UT(','):
1930
61
    case _UT(';'):
1931
70
    case _UT('@'):
1932
82
    case _UT('_'):
1933
88
    case _UT('~'):
1934
93
    case _UT('='):
1935
100
    case _UT('\''):
1936
100
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
1937
1938
268
    case _UT('/'): {
1939
268
        const URI_CHAR * afterZeroMoreSlashSegs;
1940
268
        const URI_CHAR * const afterSegment =
1941
268
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
1942
268
        if (afterSegment == NULL) {
1943
3
            return NULL;
1944
3
        }
1945
265
        if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first,
1946
265
                                       memory)) { /* SEGMENT BOTH */
1947
0
            URI_FUNC(StopMalloc)(state, memory);
1948
0
            return NULL;
1949
0
        }
1950
265
        state->uri->scheme.first = NULL; /* Not a scheme, reset */
1951
265
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
1952
265
                                       memory)) { /* SEGMENT BOTH */
1953
0
            URI_FUNC(StopMalloc)(state, memory);
1954
0
            return NULL;
1955
0
        }
1956
265
        afterZeroMoreSlashSegs =
1957
265
            URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
1958
265
        if (afterZeroMoreSlashSegs == NULL) {
1959
4
            return NULL;
1960
4
        }
1961
261
        return URI_FUNC(ParseUriTail)(state, afterZeroMoreSlashSegs, afterLast, memory);
1962
265
    }
1963
1964
953
    case _UT(':'): {
1965
953
        const URI_CHAR * const afterHierPart =
1966
953
            URI_FUNC(ParseHierPart)(state, first + 1, afterLast, memory);
1967
953
        state->uri->scheme.afterLast = first; /* SCHEME END */
1968
953
        if (afterHierPart == NULL) {
1969
11
            return NULL;
1970
11
        }
1971
942
        return URI_FUNC(ParseUriTail)(state, afterHierPart, afterLast, memory);
1972
953
    }
1973
1974
86
    default:
1975
86
        if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) {
1976
0
            URI_FUNC(StopMalloc)(state, memory);
1977
0
            return NULL;
1978
0
        }
1979
86
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
1980
1.40M
    }
1981
1.40M
}
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.1k
                                                    UriMemoryManager * memory) {
2000
55.1k
    if (first >= afterLast) {
2001
15.6k
        return afterLast;
2002
15.6k
    }
2003
2004
39.4k
    switch (*first) {
2005
6.61k
    case URI_SET_ALPHA:
2006
6.61k
        state->uri->scheme.first = first; /* SCHEME BEGIN */
2007
6.61k
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
2008
2009
13.8k
    case URI_SET_DIGIT:
2010
13.8k
    case _UT('!'):
2011
2.39k
    case _UT('$'):
2012
2.54k
    case _UT('&'):
2013
2.64k
    case _UT('('):
2014
2.78k
    case _UT(')'):
2015
2.91k
    case _UT('*'):
2016
3.03k
    case _UT(','):
2017
3.18k
    case _UT(';'):
2018
3.37k
    case _UT('\''):
2019
3.55k
    case _UT('+'):
2020
3.70k
    case _UT('='):
2021
4.22k
    case _UT('.'):
2022
4.32k
    case _UT('_'):
2023
4.45k
    case _UT('~'):
2024
4.61k
    case _UT('-'):
2025
4.83k
    case _UT('@'):
2026
4.83k
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2027
4.83k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
2028
2029
1.71k
    case _UT('%'): {
2030
1.71k
        const URI_CHAR * const afterPctEncoded =
2031
1.71k
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
2032
1.71k
        if (afterPctEncoded == NULL) {
2033
191
            return NULL;
2034
191
        }
2035
1.51k
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2036
1.51k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
2037
1.51k
                                                memory);
2038
1.71k
    }
2039
2040
22.7k
    case _UT('/'): {
2041
22.7k
        const URI_CHAR * const afterPartHelperTwo =
2042
22.7k
            URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
2043
22.7k
        if (afterPartHelperTwo == NULL) {
2044
9.67k
            return NULL;
2045
9.67k
        }
2046
13.0k
        return URI_FUNC(ParseUriTail)(state, afterPartHelperTwo, afterLast, memory);
2047
22.7k
    }
2048
2049
3.58k
    default:
2050
3.58k
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
2051
39.4k
    }
2052
39.4k
}
UriParse.c:uriParseUriReferenceA
Line
Count
Source
1999
26.8k
                                                    UriMemoryManager * memory) {
2000
26.8k
    if (first >= afterLast) {
2001
7.27k
        return afterLast;
2002
7.27k
    }
2003
2004
19.5k
    switch (*first) {
2005
3.58k
    case URI_SET_ALPHA:
2006
3.58k
        state->uri->scheme.first = first; /* SCHEME BEGIN */
2007
3.58k
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
2008
2009
6.67k
    case URI_SET_DIGIT:
2010
6.67k
    case _UT('!'):
2011
1.17k
    case _UT('$'):
2012
1.25k
    case _UT('&'):
2013
1.31k
    case _UT('('):
2014
1.39k
    case _UT(')'):
2015
1.45k
    case _UT('*'):
2016
1.51k
    case _UT(','):
2017
1.58k
    case _UT(';'):
2018
1.66k
    case _UT('\''):
2019
1.75k
    case _UT('+'):
2020
1.84k
    case _UT('='):
2021
2.10k
    case _UT('.'):
2022
2.16k
    case _UT('_'):
2023
2.24k
    case _UT('~'):
2024
2.32k
    case _UT('-'):
2025
2.43k
    case _UT('@'):
2026
2.43k
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2027
2.43k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
2028
2029
914
    case _UT('%'): {
2030
914
        const URI_CHAR * const afterPctEncoded =
2031
914
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
2032
914
        if (afterPctEncoded == NULL) {
2033
103
            return NULL;
2034
103
        }
2035
811
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2036
811
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
2037
811
                                                memory);
2038
914
    }
2039
2040
10.9k
    case _UT('/'): {
2041
10.9k
        const URI_CHAR * const afterPartHelperTwo =
2042
10.9k
            URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory);
2043
10.9k
        if (afterPartHelperTwo == NULL) {
2044
4.70k
            return NULL;
2045
4.70k
        }
2046
6.26k
        return URI_FUNC(ParseUriTail)(state, afterPartHelperTwo, afterLast, memory);
2047
10.9k
    }
2048
2049
1.65k
    default:
2050
1.65k
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
2051
19.5k
    }
2052
19.5k
}
UriParse.c:uriParseUriReferenceW
Line
Count
Source
1999
28.3k
                                                    UriMemoryManager * memory) {
2000
28.3k
    if (first >= afterLast) {
2001
8.42k
        return afterLast;
2002
8.42k
    }
2003
2004
19.8k
    switch (*first) {
2005
3.03k
    case URI_SET_ALPHA:
2006
3.03k
        state->uri->scheme.first = first; /* SCHEME BEGIN */
2007
3.03k
        return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory);
2008
2009
7.17k
    case URI_SET_DIGIT:
2010
7.17k
    case _UT('!'):
2011
1.22k
    case _UT('$'):
2012
1.29k
    case _UT('&'):
2013
1.33k
    case _UT('('):
2014
1.39k
    case _UT(')'):
2015
1.46k
    case _UT('*'):
2016
1.51k
    case _UT(','):
2017
1.59k
    case _UT(';'):
2018
1.71k
    case _UT('\''):
2019
1.80k
    case _UT('+'):
2020
1.85k
    case _UT('='):
2021
2.12k
    case _UT('.'):
2022
2.16k
    case _UT('_'):
2023
2.21k
    case _UT('~'):
2024
2.29k
    case _UT('-'):
2025
2.40k
    case _UT('@'):
2026
2.40k
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2027
2.40k
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory);
2028
2029
796
    case _UT('%'): {
2030
796
        const URI_CHAR * const afterPctEncoded =
2031
796
            URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory);
2032
796
        if (afterPctEncoded == NULL) {
2033
88
            return NULL;
2034
88
        }
2035
708
        state->uri->scheme.first = first; /* SEGMENT BEGIN, ABUSE SCHEME POINTER */
2036
708
        return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast,
2037
708
                                                memory);
2038
796
    }
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.97k
            return NULL;
2045
4.97k
        }
2046
6.76k
        return URI_FUNC(ParseUriTail)(state, afterPartHelperTwo, afterLast, memory);
2047
11.7k
    }
2048
2049
1.92k
    default:
2050
1.92k
        return URI_FUNC(ParseUriTail)(state, first, afterLast, memory);
2051
19.8k
    }
2052
19.8k
}
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.6k
                                                          UriMemoryManager * memory) {
2063
20.6k
    if (first >= afterLast) {
2064
14.8k
        return afterLast;
2065
14.8k
    }
2066
2067
5.73k
    switch (*first) {
2068
1.23k
    case _UT('#'): {
2069
1.23k
        const URI_CHAR * const afterQueryFrag =
2070
1.23k
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2071
1.23k
        if (afterQueryFrag == NULL) {
2072
8
            return NULL;
2073
8
        }
2074
1.22k
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2075
1.22k
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2076
1.22k
        return afterQueryFrag;
2077
1.23k
    }
2078
2079
2.06k
    case _UT('?'): {
2080
2.06k
        const URI_CHAR * const afterQueryFrag =
2081
2.06k
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2082
2.06k
        if (afterQueryFrag == NULL) {
2083
41
            return NULL;
2084
41
        }
2085
2.02k
        state->uri->query.first = first + 1; /* QUERY BEGIN */
2086
2.02k
        state->uri->query.afterLast = afterQueryFrag; /* QUERY END */
2087
2.02k
        return URI_FUNC(ParseUriTailTwo)(state, afterQueryFrag, afterLast, memory);
2088
2.06k
    }
2089
2090
2.43k
    default:
2091
2.43k
        return first;
2092
5.73k
    }
2093
5.73k
}
UriParse.c:uriParseUriTailA
Line
Count
Source
2062
9.90k
                                                          UriMemoryManager * memory) {
2063
9.90k
    if (first >= afterLast) {
2064
7.58k
        return afterLast;
2065
7.58k
    }
2066
2067
2.31k
    switch (*first) {
2068
650
    case _UT('#'): {
2069
650
        const URI_CHAR * const afterQueryFrag =
2070
650
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2071
650
        if (afterQueryFrag == NULL) {
2072
4
            return NULL;
2073
4
        }
2074
646
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2075
646
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2076
646
        return afterQueryFrag;
2077
650
    }
2078
2079
990
    case _UT('?'): {
2080
990
        const URI_CHAR * const afterQueryFrag =
2081
990
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2082
990
        if (afterQueryFrag == NULL) {
2083
20
            return NULL;
2084
20
        }
2085
970
        state->uri->query.first = first + 1; /* QUERY BEGIN */
2086
970
        state->uri->query.afterLast = afterQueryFrag; /* QUERY END */
2087
970
        return URI_FUNC(ParseUriTailTwo)(state, afterQueryFrag, afterLast, memory);
2088
990
    }
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.29k
        return afterLast;
2065
7.29k
    }
2066
2067
3.41k
    switch (*first) {
2068
584
    case _UT('#'): {
2069
584
        const URI_CHAR * const afterQueryFrag =
2070
584
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2071
584
        if (afterQueryFrag == NULL) {
2072
4
            return NULL;
2073
4
        }
2074
580
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2075
580
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2076
580
        return afterQueryFrag;
2077
584
    }
2078
2079
1.07k
    case _UT('?'): {
2080
1.07k
        const URI_CHAR * const afterQueryFrag =
2081
1.07k
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2082
1.07k
        if (afterQueryFrag == NULL) {
2083
21
            return NULL;
2084
21
        }
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.07k
    }
2089
2090
1.76k
    default:
2091
1.76k
        return first;
2092
3.41k
    }
2093
3.41k
}
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.02k
                          const URI_CHAR * afterLast, UriMemoryManager * memory) {
2102
2.02k
    if (first >= afterLast) {
2103
1.83k
        return afterLast;
2104
1.83k
    }
2105
2106
183
    switch (*first) {
2107
39
    case _UT('#'): {
2108
39
        const URI_CHAR * const afterQueryFrag =
2109
39
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2110
39
        if (afterQueryFrag == NULL) {
2111
4
            return NULL;
2112
4
        }
2113
35
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2114
35
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2115
35
        return afterQueryFrag;
2116
39
    }
2117
2118
144
    default:
2119
144
        return first;
2120
183
    }
2121
183
}
UriParse.c:uriParseUriTailTwoA
Line
Count
Source
2101
970
                          const URI_CHAR * afterLast, UriMemoryManager * memory) {
2102
970
    if (first >= afterLast) {
2103
914
        return afterLast;
2104
914
    }
2105
2106
56
    switch (*first) {
2107
19
    case _UT('#'): {
2108
19
        const URI_CHAR * const afterQueryFrag =
2109
19
            URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory);
2110
19
        if (afterQueryFrag == NULL) {
2111
2
            return NULL;
2112
2
        }
2113
17
        state->uri->fragment.first = first + 1; /* FRAGMENT BEGIN */
2114
17
        state->uri->fragment.afterLast = afterQueryFrag; /* FRAGMENT END */
2115
17
        return afterQueryFrag;
2116
19
    }
2117
2118
37
    default:
2119
37
        return first;
2120
56
    }
2121
56
}
UriParse.c:uriParseUriTailTwoW
Line
Count
Source
2101
1.05k
                          const URI_CHAR * afterLast, UriMemoryManager * memory) {
2102
1.05k
    if (first >= afterLast) {
2103
923
        return afterLast;
2104
923
    }
2105
2106
127
    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
107
    default:
2119
107
        return first;
2120
127
    }
2121
127
}
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
50.4k
                                                         UriMemoryManager * memory) {
2131
50.4k
    if (first >= afterLast) {
2132
5.12k
        return afterLast;
2133
5.12k
    }
2134
2135
45.3k
    switch (*first) {
2136
44.9k
    case _UT('/'): {
2137
44.9k
        const URI_CHAR * const afterSegment =
2138
44.9k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
2139
44.9k
        if (afterSegment == NULL) {
2140
23
            return NULL;
2141
23
        }
2142
44.9k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
2143
44.9k
                                       memory)) { /* SEGMENT BOTH */
2144
0
            URI_FUNC(StopMalloc)(state, memory);
2145
0
            return NULL;
2146
0
        }
2147
44.9k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
2148
44.9k
    }
2149
2150
421
    default:
2151
421
        return first;
2152
45.3k
    }
2153
45.3k
}
UriParse.c:uriParseZeroMoreSlashSegsA
Line
Count
Source
2130
25.8k
                                                         UriMemoryManager * memory) {
2131
25.8k
    if (first >= afterLast) {
2132
2.60k
        return afterLast;
2133
2.60k
    }
2134
2135
23.1k
    switch (*first) {
2136
23.0k
    case _UT('/'): {
2137
23.0k
        const URI_CHAR * const afterSegment =
2138
23.0k
            URI_FUNC(ParseSegment)(state, first + 1, afterLast, memory);
2139
23.0k
        if (afterSegment == NULL) {
2140
11
            return NULL;
2141
11
        }
2142
23.0k
        if (!URI_FUNC(PushPathSegment)(state, first + 1, afterSegment,
2143
23.0k
                                       memory)) { /* SEGMENT BOTH */
2144
0
            URI_FUNC(StopMalloc)(state, memory);
2145
0
            return NULL;
2146
0
        }
2147
23.0k
        return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory);
2148
23.0k
    }
2149
2150
184
    default:
2151
184
        return first;
2152
23.1k
    }
2153
23.1k
}
UriParse.c:uriParseZeroMoreSlashSegsW
Line
Count
Source
2130
24.6k
                                                         UriMemoryManager * memory) {
2131
24.6k
    if (first >= afterLast) {
2132
2.52k
        return afterLast;
2133
2.52k
    }
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
12
            return NULL;
2141
12
        }
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
237
    default:
2151
237
        return first;
2152
22.1k
    }
2153
22.1k
}
2154
2155
static URI_INLINE void URI_FUNC(ResetParserStateExceptUri)(URI_TYPE(ParserState)
2156
55.1k
                                                           * state) {
2157
55.1k
    URI_TYPE(Uri) * const uriBackup = state->uri;
2158
55.1k
    memset(state, 0, sizeof(URI_TYPE(ParserState)));
2159
55.1k
    state->uri = uriBackup;
2160
55.1k
}
UriParse.c:uriResetParserStateExceptUriA
Line
Count
Source
2156
26.8k
                                                           * state) {
2157
26.8k
    URI_TYPE(Uri) * const uriBackup = state->uri;
2158
26.8k
    memset(state, 0, sizeof(URI_TYPE(ParserState)));
2159
26.8k
    state->uri = uriBackup;
2160
26.8k
}
UriParse.c:uriResetParserStateExceptUriW
Line
Count
Source
2156
28.3k
                                                           * state) {
2157
28.3k
    URI_TYPE(Uri) * const uriBackup = state->uri;
2158
28.3k
    memset(state, 0, sizeof(URI_TYPE(ParserState)));
2159
28.3k
    state->uri = uriBackup;
2160
28.3k
}
2161
2162
static URI_INLINE UriBool URI_FUNC(PushPathSegment)(URI_TYPE(ParserState) * state,
2163
                                                    const URI_CHAR * first,
2164
                                                    const URI_CHAR * afterLast,
2165
69.2k
                                                    UriMemoryManager * memory) {
2166
69.2k
    URI_TYPE(PathSegment) * segment =
2167
69.2k
        memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment)));
2168
69.2k
    if (segment == NULL) {
2169
0
        return URI_FALSE; /* Raises malloc error */
2170
0
    }
2171
69.2k
    if (first == afterLast) {
2172
19.6k
        segment->text.first = URI_FUNC(SafeToPointTo);
2173
19.6k
        segment->text.afterLast = URI_FUNC(SafeToPointTo);
2174
49.5k
    } else {
2175
49.5k
        segment->text.first = first;
2176
49.5k
        segment->text.afterLast = afterLast;
2177
49.5k
    }
2178
2179
    /* First segment ever? */
2180
69.2k
    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
54.3k
    } else {
2185
        /* Append, update tail */
2186
54.3k
        state->uri->pathTail->next = segment;
2187
54.3k
        state->uri->pathTail = segment;
2188
54.3k
    }
2189
2190
69.2k
    return URI_TRUE; /* Success */
2191
69.2k
}
UriParse.c:uriPushPathSegmentA
Line
Count
Source
2165
35.6k
                                                    UriMemoryManager * memory) {
2166
35.6k
    URI_TYPE(PathSegment) * segment =
2167
35.6k
        memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment)));
2168
35.6k
    if (segment == NULL) {
2169
0
        return URI_FALSE; /* Raises malloc error */
2170
0
    }
2171
35.6k
    if (first == afterLast) {
2172
10.6k
        segment->text.first = URI_FUNC(SafeToPointTo);
2173
10.6k
        segment->text.afterLast = URI_FUNC(SafeToPointTo);
2174
24.9k
    } else {
2175
24.9k
        segment->text.first = first;
2176
24.9k
        segment->text.afterLast = afterLast;
2177
24.9k
    }
2178
2179
    /* First segment ever? */
2180
35.6k
    if (state->uri->pathHead == NULL) {
2181
        /* First segment ever, set head and tail */
2182
7.76k
        state->uri->pathHead = segment;
2183
7.76k
        state->uri->pathTail = segment;
2184
27.9k
    } else {
2185
        /* Append, update tail */
2186
27.9k
        state->uri->pathTail->next = segment;
2187
27.9k
        state->uri->pathTail = segment;
2188
27.9k
    }
2189
2190
35.6k
    return URI_TRUE; /* Success */
2191
35.6k
}
UriParse.c:uriPushPathSegmentW
Line
Count
Source
2165
33.6k
                                                    UriMemoryManager * memory) {
2166
33.6k
    URI_TYPE(PathSegment) * segment =
2167
33.6k
        memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment)));
2168
33.6k
    if (segment == NULL) {
2169
0
        return URI_FALSE; /* Raises malloc error */
2170
0
    }
2171
33.6k
    if (first == afterLast) {
2172
9.00k
        segment->text.first = URI_FUNC(SafeToPointTo);
2173
9.00k
        segment->text.afterLast = URI_FUNC(SafeToPointTo);
2174
24.6k
    } else {
2175
24.6k
        segment->text.first = first;
2176
24.6k
        segment->text.afterLast = afterLast;
2177
24.6k
    }
2178
2179
    /* First segment ever? */
2180
33.6k
    if (state->uri->pathHead == NULL) {
2181
        /* First segment ever, set head and tail */
2182
7.21k
        state->uri->pathHead = segment;
2183
7.21k
        state->uri->pathTail = segment;
2184
26.3k
    } else {
2185
        /* Append, update tail */
2186
26.3k
        state->uri->pathTail->next = segment;
2187
26.3k
        state->uri->pathTail = segment;
2188
26.3k
    }
2189
2190
33.6k
    return URI_TRUE; /* Success */
2191
33.6k
}
2192
2193
int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
2194
36.2k
                         const URI_CHAR * afterLast) {
2195
36.2k
    return URI_FUNC(ParseUriExMm)(state, first, afterLast, NULL);
2196
36.2k
}
uriParseUriExA
Line
Count
Source
2194
17.6k
                         const URI_CHAR * afterLast) {
2195
17.6k
    return URI_FUNC(ParseUriExMm)(state, first, afterLast, NULL);
2196
17.6k
}
uriParseUriExW
Line
Count
Source
2194
18.5k
                         const URI_CHAR * afterLast) {
2195
18.5k
    return URI_FUNC(ParseUriExMm)(state, first, afterLast, NULL);
2196
18.5k
}
2197
2198
static int URI_FUNC(ParseUriExMm)(URI_TYPE(ParserState) * state, const URI_CHAR * first,
2199
55.1k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
2200
55.1k
    const URI_CHAR * afterUriReference;
2201
55.1k
    URI_TYPE(Uri) * uri;
2202
2203
    /* Check params */
2204
55.1k
    if ((state == NULL) || (first == NULL) || (afterLast == NULL)) {
2205
0
        return URI_ERROR_NULL;
2206
0
    }
2207
55.1k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2208
2209
55.1k
    uri = state->uri;
2210
2211
    /* Init parser */
2212
55.1k
    URI_FUNC(ResetParserStateExceptUri)(state);
2213
55.1k
    URI_FUNC(ResetUri)(uri);
2214
2215
    /* Parse */
2216
55.1k
    afterUriReference = URI_FUNC(ParseUriReference)(state, first, afterLast, memory);
2217
55.1k
    if (afterUriReference == NULL) {
2218
        /* Waterproof errorPos <= afterLast */
2219
10.5k
        if (state->errorPos && (state->errorPos > afterLast)) {
2220
0
            state->errorPos = afterLast;
2221
0
        }
2222
10.5k
        return state->errorCode;
2223
10.5k
    }
2224
44.5k
    if (afterUriReference != afterLast) {
2225
2.60k
        if (afterUriReference < afterLast) {
2226
2.60k
            URI_FUNC(StopSyntax)(state, afterUriReference, memory);
2227
2.60k
        } else {
2228
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
2229
0
        }
2230
2.60k
        return state->errorCode;
2231
2.60k
    }
2232
41.9k
    return URI_SUCCESS;
2233
44.5k
}
UriParse.c:uriParseUriExMmA
Line
Count
Source
2199
26.8k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
2200
26.8k
    const URI_CHAR * afterUriReference;
2201
26.8k
    URI_TYPE(Uri) * uri;
2202
2203
    /* Check params */
2204
26.8k
    if ((state == NULL) || (first == NULL) || (afterLast == NULL)) {
2205
0
        return URI_ERROR_NULL;
2206
0
    }
2207
26.8k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2208
2209
26.8k
    uri = state->uri;
2210
2211
    /* Init parser */
2212
26.8k
    URI_FUNC(ResetParserStateExceptUri)(state);
2213
26.8k
    URI_FUNC(ResetUri)(uri);
2214
2215
    /* Parse */
2216
26.8k
    afterUriReference = URI_FUNC(ParseUriReference)(state, first, afterLast, memory);
2217
26.8k
    if (afterUriReference == NULL) {
2218
        /* Waterproof errorPos <= afterLast */
2219
5.15k
        if (state->errorPos && (state->errorPos > afterLast)) {
2220
0
            state->errorPos = afterLast;
2221
0
        }
2222
5.15k
        return state->errorCode;
2223
5.15k
    }
2224
21.6k
    if (afterUriReference != afterLast) {
2225
725
        if (afterUriReference < afterLast) {
2226
725
            URI_FUNC(StopSyntax)(state, afterUriReference, memory);
2227
725
        } else {
2228
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
2229
0
        }
2230
725
        return state->errorCode;
2231
725
    }
2232
20.9k
    return URI_SUCCESS;
2233
21.6k
}
UriParse.c:uriParseUriExMmW
Line
Count
Source
2199
28.3k
                                  const URI_CHAR * afterLast, UriMemoryManager * memory) {
2200
28.3k
    const URI_CHAR * afterUriReference;
2201
28.3k
    URI_TYPE(Uri) * uri;
2202
2203
    /* Check params */
2204
28.3k
    if ((state == NULL) || (first == NULL) || (afterLast == NULL)) {
2205
0
        return URI_ERROR_NULL;
2206
0
    }
2207
28.3k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2208
2209
28.3k
    uri = state->uri;
2210
2211
    /* Init parser */
2212
28.3k
    URI_FUNC(ResetParserStateExceptUri)(state);
2213
28.3k
    URI_FUNC(ResetUri)(uri);
2214
2215
    /* Parse */
2216
28.3k
    afterUriReference = URI_FUNC(ParseUriReference)(state, first, afterLast, memory);
2217
28.3k
    if (afterUriReference == NULL) {
2218
        /* Waterproof errorPos <= afterLast */
2219
5.42k
        if (state->errorPos && (state->errorPos > afterLast)) {
2220
0
            state->errorPos = afterLast;
2221
0
        }
2222
5.42k
        return state->errorCode;
2223
5.42k
    }
2224
22.8k
    if (afterUriReference != afterLast) {
2225
1.88k
        if (afterUriReference < afterLast) {
2226
1.88k
            URI_FUNC(StopSyntax)(state, afterUriReference, memory);
2227
1.88k
        } else {
2228
0
            URI_FUNC(StopSyntax)(state, afterLast, memory);
2229
0
        }
2230
1.88k
        return state->errorCode;
2231
1.88k
    }
2232
21.0k
    return URI_SUCCESS;
2233
22.8k
}
2234
2235
36.2k
int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text) {
2236
36.2k
    if ((state == NULL) || (text == NULL)) {
2237
0
        return URI_ERROR_NULL;
2238
0
    }
2239
36.2k
    return URI_FUNC(ParseUriEx)(state, text, text + URI_STRLEN(text));
2240
36.2k
}
uriParseUriA
Line
Count
Source
2235
17.6k
int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text) {
2236
17.6k
    if ((state == NULL) || (text == NULL)) {
2237
0
        return URI_ERROR_NULL;
2238
0
    }
2239
17.6k
    return URI_FUNC(ParseUriEx)(state, text, text + URI_STRLEN(text));
2240
17.6k
}
uriParseUriW
Line
Count
Source
2235
18.5k
int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text) {
2236
18.5k
    if ((state == NULL) || (text == NULL)) {
2237
0
        return URI_ERROR_NULL;
2238
0
    }
2239
18.5k
    return URI_FUNC(ParseUriEx)(state, text, text + URI_STRLEN(text));
2240
18.5k
}
2241
2242
int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, const URI_CHAR * text,
2243
18.9k
                             const URI_CHAR ** errorPos) {
2244
18.9k
    return URI_FUNC(ParseSingleUriEx)(uri, text, NULL, errorPos);
2245
18.9k
}
uriParseSingleUriA
Line
Count
Source
2243
9.15k
                             const URI_CHAR ** errorPos) {
2244
9.15k
    return URI_FUNC(ParseSingleUriEx)(uri, text, NULL, errorPos);
2245
9.15k
}
uriParseSingleUriW
Line
Count
Source
2243
9.79k
                             const URI_CHAR ** errorPos) {
2244
9.79k
    return URI_FUNC(ParseSingleUriEx)(uri, text, NULL, errorPos);
2245
9.79k
}
2246
2247
int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, const URI_CHAR * first,
2248
18.9k
                               const URI_CHAR * afterLast, const URI_CHAR ** errorPos) {
2249
18.9k
    if ((afterLast == NULL) && (first != NULL)) {
2250
18.9k
        afterLast = first + URI_STRLEN(first);
2251
18.9k
    }
2252
18.9k
    return URI_FUNC(ParseSingleUriExMm)(uri, first, afterLast, errorPos, NULL);
2253
18.9k
}
uriParseSingleUriExA
Line
Count
Source
2248
9.15k
                               const URI_CHAR * afterLast, const URI_CHAR ** errorPos) {
2249
9.15k
    if ((afterLast == NULL) && (first != NULL)) {
2250
9.15k
        afterLast = first + URI_STRLEN(first);
2251
9.15k
    }
2252
9.15k
    return URI_FUNC(ParseSingleUriExMm)(uri, first, afterLast, errorPos, NULL);
2253
9.15k
}
uriParseSingleUriExW
Line
Count
Source
2248
9.79k
                               const URI_CHAR * afterLast, const URI_CHAR ** errorPos) {
2249
9.79k
    if ((afterLast == NULL) && (first != NULL)) {
2250
9.79k
        afterLast = first + URI_STRLEN(first);
2251
9.79k
    }
2252
9.79k
    return URI_FUNC(ParseSingleUriExMm)(uri, first, afterLast, errorPos, NULL);
2253
9.79k
}
2254
2255
int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first,
2256
                                 const URI_CHAR * afterLast, const URI_CHAR ** errorPos,
2257
18.9k
                                 UriMemoryManager * memory) {
2258
18.9k
    URI_TYPE(ParserState) state;
2259
18.9k
    int res;
2260
2261
    /* Check params */
2262
18.9k
    if ((uri == NULL) || (first == NULL) || (afterLast == NULL)) {
2263
0
        return URI_ERROR_NULL;
2264
0
    }
2265
18.9k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2266
2267
18.9k
    state.uri = uri;
2268
2269
18.9k
    res = URI_FUNC(ParseUriExMm)(&state, first, afterLast, memory);
2270
2271
18.9k
    if (res != URI_SUCCESS) {
2272
5.72k
        if (errorPos != NULL) {
2273
0
            *errorPos = state.errorPos;
2274
0
        }
2275
5.72k
        URI_FUNC(FreeUriMembersMm)(uri, memory);
2276
5.72k
    }
2277
2278
18.9k
    return res;
2279
18.9k
}
uriParseSingleUriExMmA
Line
Count
Source
2257
9.15k
                                 UriMemoryManager * memory) {
2258
9.15k
    URI_TYPE(ParserState) state;
2259
9.15k
    int res;
2260
2261
    /* Check params */
2262
9.15k
    if ((uri == NULL) || (first == NULL) || (afterLast == NULL)) {
2263
0
        return URI_ERROR_NULL;
2264
0
    }
2265
9.15k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2266
2267
9.15k
    state.uri = uri;
2268
2269
9.15k
    res = URI_FUNC(ParseUriExMm)(&state, first, afterLast, memory);
2270
2271
9.15k
    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.15k
    return res;
2279
9.15k
}
uriParseSingleUriExMmW
Line
Count
Source
2257
9.79k
                                 UriMemoryManager * memory) {
2258
9.79k
    URI_TYPE(ParserState) state;
2259
9.79k
    int res;
2260
2261
    /* Check params */
2262
9.79k
    if ((uri == NULL) || (first == NULL) || (afterLast == NULL)) {
2263
0
        return URI_ERROR_NULL;
2264
0
    }
2265
9.79k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2266
2267
9.79k
    state.uri = uri;
2268
2269
9.79k
    res = URI_FUNC(ParseUriExMm)(&state, first, afterLast, memory);
2270
2271
9.79k
    if (res != URI_SUCCESS) {
2272
3.45k
        if (errorPos != NULL) {
2273
0
            *errorPos = state.errorPos;
2274
0
        }
2275
3.45k
        URI_FUNC(FreeUriMembersMm)(uri, memory);
2276
3.45k
    }
2277
2278
9.79k
    return res;
2279
9.79k
}
2280
2281
81.5k
void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri) {
2282
81.5k
    URI_FUNC(FreeUriMembersMm)(uri, NULL);
2283
81.5k
}
uriFreeUriMembersA
Line
Count
Source
2281
40.6k
void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri) {
2282
40.6k
    URI_FUNC(FreeUriMembersMm)(uri, NULL);
2283
40.6k
}
uriFreeUriMembersW
Line
Count
Source
2281
40.9k
void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri) {
2282
40.9k
    URI_FUNC(FreeUriMembersMm)(uri, NULL);
2283
40.9k
}
2284
2285
125k
int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) {
2286
125k
    if (uri == NULL) {
2287
0
        return URI_ERROR_NULL;
2288
0
    }
2289
2290
125k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2291
2292
125k
    if (uri->owner) {
2293
        /* Scheme */
2294
13.2k
        if (uri->scheme.first != NULL) {
2295
850
            if (uri->scheme.first != uri->scheme.afterLast) {
2296
850
                memory->free(memory, (URI_CHAR *)uri->scheme.first);
2297
850
            }
2298
850
            uri->scheme.first = NULL;
2299
850
            uri->scheme.afterLast = NULL;
2300
850
        }
2301
2302
        /* User info */
2303
13.2k
        if (uri->userInfo.first != NULL) {
2304
487
            if (uri->userInfo.first != uri->userInfo.afterLast) {
2305
195
                memory->free(memory, (URI_CHAR *)uri->userInfo.first);
2306
195
            }
2307
487
            uri->userInfo.first = NULL;
2308
487
            uri->userInfo.afterLast = NULL;
2309
487
        }
2310
2311
        /* Host data - IPvFuture (may affect host text) */
2312
13.2k
        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
237
            uri->hostText.first = NULL;
2316
237
            uri->hostText.afterLast = NULL;
2317
2318
237
            if (uri->hostData.ipFuture.first != uri->hostData.ipFuture.afterLast) {
2319
237
                memory->free(memory, (URI_CHAR *)uri->hostData.ipFuture.first);
2320
237
            }
2321
237
            uri->hostData.ipFuture.first = NULL;
2322
237
            uri->hostData.ipFuture.afterLast = NULL;
2323
237
        }
2324
2325
        /* Host text (after IPvFuture, see above) */
2326
13.2k
        if (uri->hostText.first != NULL) {
2327
1.78k
            if (uri->hostText.first != uri->hostText.afterLast) {
2328
1.52k
                memory->free(memory, (URI_CHAR *)uri->hostText.first);
2329
1.52k
            }
2330
1.78k
            uri->hostText.first = NULL;
2331
1.78k
            uri->hostText.afterLast = NULL;
2332
1.78k
        }
2333
13.2k
    }
2334
2335
    /* Host data - IPv4 */
2336
125k
    if (uri->hostData.ip4 != NULL) {
2337
192
        memory->free(memory, uri->hostData.ip4);
2338
192
        uri->hostData.ip4 = NULL;
2339
192
    }
2340
2341
    /* Host data - IPv6 */
2342
125k
    if (uri->hostData.ip6 != NULL) {
2343
3.16k
        memory->free(memory, uri->hostData.ip6);
2344
3.16k
        uri->hostData.ip6 = NULL;
2345
3.16k
    }
2346
2347
    /* Port text */
2348
125k
    if (uri->owner && (uri->portText.first != NULL)) {
2349
240
        if (uri->portText.first != uri->portText.afterLast) {
2350
176
            memory->free(memory, (URI_CHAR *)uri->portText.first);
2351
176
        }
2352
240
        uri->portText.first = NULL;
2353
240
        uri->portText.afterLast = NULL;
2354
240
    }
2355
2356
    /* Path */
2357
125k
    URI_FUNC(FreeUriPath)(uri, memory);
2358
2359
125k
    if (uri->owner) {
2360
        /* Query */
2361
13.2k
        if (uri->query.first != NULL) {
2362
373
            if (uri->query.first != uri->query.afterLast) {
2363
341
                memory->free(memory, (URI_CHAR *)uri->query.first);
2364
341
            }
2365
373
            uri->query.first = NULL;
2366
373
            uri->query.afterLast = NULL;
2367
373
        }
2368
2369
        /* Fragment */
2370
13.2k
        if (uri->fragment.first != NULL) {
2371
252
            if (uri->fragment.first != uri->fragment.afterLast) {
2372
231
                memory->free(memory, (URI_CHAR *)uri->fragment.first);
2373
231
            }
2374
252
            uri->fragment.first = NULL;
2375
252
            uri->fragment.afterLast = NULL;
2376
252
        }
2377
13.2k
    }
2378
2379
125k
    return URI_SUCCESS;
2380
125k
}
uriFreeUriMembersMmA
Line
Count
Source
2285
61.9k
int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) {
2286
61.9k
    if (uri == NULL) {
2287
0
        return URI_ERROR_NULL;
2288
0
    }
2289
2290
61.9k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2291
2292
61.9k
    if (uri->owner) {
2293
        /* Scheme */
2294
6.88k
        if (uri->scheme.first != NULL) {
2295
482
            if (uri->scheme.first != uri->scheme.afterLast) {
2296
482
                memory->free(memory, (URI_CHAR *)uri->scheme.first);
2297
482
            }
2298
482
            uri->scheme.first = NULL;
2299
482
            uri->scheme.afterLast = NULL;
2300
482
        }
2301
2302
        /* User info */
2303
6.88k
        if (uri->userInfo.first != NULL) {
2304
345
            if (uri->userInfo.first != uri->userInfo.afterLast) {
2305
128
                memory->free(memory, (URI_CHAR *)uri->userInfo.first);
2306
128
            }
2307
345
            uri->userInfo.first = NULL;
2308
345
            uri->userInfo.afterLast = NULL;
2309
345
        }
2310
2311
        /* Host data - IPvFuture (may affect host text) */
2312
6.88k
        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
120
            uri->hostText.first = NULL;
2316
120
            uri->hostText.afterLast = NULL;
2317
2318
120
            if (uri->hostData.ipFuture.first != uri->hostData.ipFuture.afterLast) {
2319
120
                memory->free(memory, (URI_CHAR *)uri->hostData.ipFuture.first);
2320
120
            }
2321
120
            uri->hostData.ipFuture.first = NULL;
2322
120
            uri->hostData.ipFuture.afterLast = NULL;
2323
120
        }
2324
2325
        /* Host text (after IPvFuture, see above) */
2326
6.88k
        if (uri->hostText.first != NULL) {
2327
1.11k
            if (uri->hostText.first != uri->hostText.afterLast) {
2328
975
                memory->free(memory, (URI_CHAR *)uri->hostText.first);
2329
975
            }
2330
1.11k
            uri->hostText.first = NULL;
2331
1.11k
            uri->hostText.afterLast = NULL;
2332
1.11k
        }
2333
6.88k
    }
2334
2335
    /* Host data - IPv4 */
2336
61.9k
    if (uri->hostData.ip4 != NULL) {
2337
92
        memory->free(memory, uri->hostData.ip4);
2338
92
        uri->hostData.ip4 = NULL;
2339
92
    }
2340
2341
    /* Host data - IPv6 */
2342
61.9k
    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
61.9k
    if (uri->owner && (uri->portText.first != NULL)) {
2349
164
        if (uri->portText.first != uri->portText.afterLast) {
2350
123
            memory->free(memory, (URI_CHAR *)uri->portText.first);
2351
123
        }
2352
164
        uri->portText.first = NULL;
2353
164
        uri->portText.afterLast = NULL;
2354
164
    }
2355
2356
    /* Path */
2357
61.9k
    URI_FUNC(FreeUriPath)(uri, memory);
2358
2359
61.9k
    if (uri->owner) {
2360
        /* Query */
2361
6.88k
        if (uri->query.first != NULL) {
2362
246
            if (uri->query.first != uri->query.afterLast) {
2363
227
                memory->free(memory, (URI_CHAR *)uri->query.first);
2364
227
            }
2365
246
            uri->query.first = NULL;
2366
246
            uri->query.afterLast = NULL;
2367
246
        }
2368
2369
        /* Fragment */
2370
6.88k
        if (uri->fragment.first != NULL) {
2371
164
            if (uri->fragment.first != uri->fragment.afterLast) {
2372
155
                memory->free(memory, (URI_CHAR *)uri->fragment.first);
2373
155
            }
2374
164
            uri->fragment.first = NULL;
2375
164
            uri->fragment.afterLast = NULL;
2376
164
        }
2377
6.88k
    }
2378
2379
61.9k
    return URI_SUCCESS;
2380
61.9k
}
uriFreeUriMembersMmW
Line
Count
Source
2285
63.8k
int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) {
2286
63.8k
    if (uri == NULL) {
2287
0
        return URI_ERROR_NULL;
2288
0
    }
2289
2290
63.8k
    URI_CHECK_MEMORY_MANAGER(memory); /* may return */
2291
2292
63.8k
    if (uri->owner) {
2293
        /* Scheme */
2294
6.33k
        if (uri->scheme.first != NULL) {
2295
368
            if (uri->scheme.first != uri->scheme.afterLast) {
2296
368
                memory->free(memory, (URI_CHAR *)uri->scheme.first);
2297
368
            }
2298
368
            uri->scheme.first = NULL;
2299
368
            uri->scheme.afterLast = NULL;
2300
368
        }
2301
2302
        /* User info */
2303
6.33k
        if (uri->userInfo.first != NULL) {
2304
142
            if (uri->userInfo.first != uri->userInfo.afterLast) {
2305
67
                memory->free(memory, (URI_CHAR *)uri->userInfo.first);
2306
67
            }
2307
142
            uri->userInfo.first = NULL;
2308
142
            uri->userInfo.afterLast = NULL;
2309
142
        }
2310
2311
        /* Host data - IPvFuture (may affect host text) */
2312
6.33k
        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
117
            uri->hostText.first = NULL;
2316
117
            uri->hostText.afterLast = NULL;
2317
2318
117
            if (uri->hostData.ipFuture.first != uri->hostData.ipFuture.afterLast) {
2319
117
                memory->free(memory, (URI_CHAR *)uri->hostData.ipFuture.first);
2320
117
            }
2321
117
            uri->hostData.ipFuture.first = NULL;
2322
117
            uri->hostData.ipFuture.afterLast = NULL;
2323
117
        }
2324
2325
        /* Host text (after IPvFuture, see above) */
2326
6.33k
        if (uri->hostText.first != NULL) {
2327
665
            if (uri->hostText.first != uri->hostText.afterLast) {
2328
547
                memory->free(memory, (URI_CHAR *)uri->hostText.first);
2329
547
            }
2330
665
            uri->hostText.first = NULL;
2331
665
            uri->hostText.afterLast = NULL;
2332
665
        }
2333
6.33k
    }
2334
2335
    /* Host data - IPv4 */
2336
63.8k
    if (uri->hostData.ip4 != NULL) {
2337
100
        memory->free(memory, uri->hostData.ip4);
2338
100
        uri->hostData.ip4 = NULL;
2339
100
    }
2340
2341
    /* Host data - IPv6 */
2342
63.8k
    if (uri->hostData.ip6 != NULL) {
2343
1.72k
        memory->free(memory, uri->hostData.ip6);
2344
1.72k
        uri->hostData.ip6 = NULL;
2345
1.72k
    }
2346
2347
    /* Port text */
2348
63.8k
    if (uri->owner && (uri->portText.first != NULL)) {
2349
76
        if (uri->portText.first != uri->portText.afterLast) {
2350
53
            memory->free(memory, (URI_CHAR *)uri->portText.first);
2351
53
        }
2352
76
        uri->portText.first = NULL;
2353
76
        uri->portText.afterLast = NULL;
2354
76
    }
2355
2356
    /* Path */
2357
63.8k
    URI_FUNC(FreeUriPath)(uri, memory);
2358
2359
63.8k
    if (uri->owner) {
2360
        /* Query */
2361
6.33k
        if (uri->query.first != NULL) {
2362
127
            if (uri->query.first != uri->query.afterLast) {
2363
114
                memory->free(memory, (URI_CHAR *)uri->query.first);
2364
114
            }
2365
127
            uri->query.first = NULL;
2366
127
            uri->query.afterLast = NULL;
2367
127
        }
2368
2369
        /* Fragment */
2370
6.33k
        if (uri->fragment.first != NULL) {
2371
88
            if (uri->fragment.first != uri->fragment.afterLast) {
2372
76
                memory->free(memory, (URI_CHAR *)uri->fragment.first);
2373
76
            }
2374
88
            uri->fragment.first = NULL;
2375
88
            uri->fragment.afterLast = NULL;
2376
88
        }
2377
6.33k
    }
2378
2379
63.8k
    return URI_SUCCESS;
2380
63.8k
}
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