Coverage Report

Created: 2026-01-09 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pcre2/src/pcre2_context.c
Line
Count
Source
1
/*************************************************
2
*      Perl-Compatible Regular Expressions       *
3
*************************************************/
4
5
/* PCRE is a library of functions to support regular expressions whose syntax
6
and semantics are as close as possible to those of the Perl 5 language.
7
8
                       Written by Philip Hazel
9
     Original API code Copyright (c) 1997-2012 University of Cambridge
10
          New API code Copyright (c) 2016-2024 University of Cambridge
11
12
-----------------------------------------------------------------------------
13
Redistribution and use in source and binary forms, with or without
14
modification, are permitted provided that the following conditions are met:
15
16
    * Redistributions of source code must retain the above copyright notice,
17
      this list of conditions and the following disclaimer.
18
19
    * Redistributions in binary form must reproduce the above copyright
20
      notice, this list of conditions and the following disclaimer in the
21
      documentation and/or other materials provided with the distribution.
22
23
    * Neither the name of the University of Cambridge nor the names of its
24
      contributors may be used to endorse or promote products derived from
25
      this software without specific prior written permission.
26
27
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
POSSIBILITY OF SUCH DAMAGE.
38
-----------------------------------------------------------------------------
39
*/
40
41
42
#include "pcre2_internal.h"
43
44
45
46
/*************************************************
47
*          Default malloc/free functions         *
48
*************************************************/
49
50
/* Ignore the "user data" argument in each case. */
51
52
static void *default_malloc(size_t size, void *data)
53
77.7M
{
54
77.7M
(void)data;
55
77.7M
return malloc(size);
56
77.7M
}
57
58
59
static void default_free(void *block, void *data)
60
79.7M
{
61
79.7M
(void)data;
62
79.7M
free(block);
63
79.7M
}
64
65
66
67
/*************************************************
68
*        Get a block and save memory control     *
69
*************************************************/
70
71
/* This internal function is called to get a block of memory in which the
72
memory control data is to be stored at the start for future use.
73
74
Arguments:
75
  size        amount of memory required
76
  memctl      pointer to a memctl block or NULL
77
78
Returns:      pointer to memory or NULL on failure
79
*/
80
81
extern void *
82
PRIV(memctl_malloc)(size_t size, pcre2_memctl *memctl)
83
1.40M
{
84
1.40M
pcre2_memctl *newmemctl;
85
1.40M
void *yield = (memctl == NULL)? malloc(size) :
86
1.40M
  memctl->malloc(size, memctl->memory_data);
87
1.40M
if (yield == NULL) return NULL;
88
1.40M
newmemctl = (pcre2_memctl *)yield;
89
1.40M
if (memctl == NULL)
90
1.40M
  {
91
1.40M
  newmemctl->malloc = default_malloc;
92
1.40M
  newmemctl->free = default_free;
93
1.40M
  newmemctl->memory_data = NULL;
94
1.40M
  }
95
0
else *newmemctl = *memctl;
96
1.40M
return yield;
97
1.40M
}
_pcre2_memctl_malloc_8
Line
Count
Source
83
458k
{
84
458k
pcre2_memctl *newmemctl;
85
458k
void *yield = (memctl == NULL)? malloc(size) :
86
458k
  memctl->malloc(size, memctl->memory_data);
87
458k
if (yield == NULL) return NULL;
88
458k
newmemctl = (pcre2_memctl *)yield;
89
458k
if (memctl == NULL)
90
458k
  {
91
458k
  newmemctl->malloc = default_malloc;
92
458k
  newmemctl->free = default_free;
93
458k
  newmemctl->memory_data = NULL;
94
458k
  }
95
0
else *newmemctl = *memctl;
96
458k
return yield;
97
458k
}
_pcre2_memctl_malloc_32
Line
Count
Source
83
476k
{
84
476k
pcre2_memctl *newmemctl;
85
476k
void *yield = (memctl == NULL)? malloc(size) :
86
476k
  memctl->malloc(size, memctl->memory_data);
87
476k
if (yield == NULL) return NULL;
88
476k
newmemctl = (pcre2_memctl *)yield;
89
476k
if (memctl == NULL)
90
476k
  {
91
476k
  newmemctl->malloc = default_malloc;
92
476k
  newmemctl->free = default_free;
93
476k
  newmemctl->memory_data = NULL;
94
476k
  }
95
0
else *newmemctl = *memctl;
96
476k
return yield;
97
476k
}
_pcre2_memctl_malloc_16
Line
Count
Source
83
469k
{
84
469k
pcre2_memctl *newmemctl;
85
469k
void *yield = (memctl == NULL)? malloc(size) :
86
469k
  memctl->malloc(size, memctl->memory_data);
87
469k
if (yield == NULL) return NULL;
88
469k
newmemctl = (pcre2_memctl *)yield;
89
469k
if (memctl == NULL)
90
469k
  {
91
469k
  newmemctl->malloc = default_malloc;
92
469k
  newmemctl->free = default_free;
93
469k
  newmemctl->memory_data = NULL;
94
469k
  }
95
0
else *newmemctl = *memctl;
96
469k
return yield;
97
469k
}
98
99
100
101
/*************************************************
102
*          Create and initialize contexts        *
103
*************************************************/
104
105
/* Initializing for compile and match contexts is done in separate, private
106
functions so that these can be called from functions such as pcre2_compile()
107
when an external context is not supplied. The initializing functions have an
108
option to set up default memory management. */
109
110
PCRE2_EXP_DEFN pcre2_general_context * PCRE2_CALL_CONVENTION
111
pcre2_general_context_create(void *(*private_malloc)(size_t, void *),
112
  void (*private_free)(void *, void *), void *memory_data)
113
0
{
114
0
pcre2_general_context *gcontext;
115
0
if (private_malloc == NULL) private_malloc = default_malloc;
116
0
if (private_free == NULL) private_free = default_free;
117
0
gcontext = private_malloc(sizeof(pcre2_real_general_context), memory_data);
118
0
if (gcontext == NULL) return NULL;
119
0
gcontext->memctl.malloc = private_malloc;
120
0
gcontext->memctl.free = private_free;
121
0
gcontext->memctl.memory_data = memory_data;
122
0
return gcontext;
123
0
}
Unexecuted instantiation: pcre2_general_context_create_8
Unexecuted instantiation: pcre2_general_context_create_32
Unexecuted instantiation: pcre2_general_context_create_16
124
125
126
/* A default compile context is set up to save having to initialize at run time
127
when no context is supplied to the compile function. */
128
129
pcre2_compile_context PRIV(default_compile_context) = {
130
  { default_malloc, default_free, NULL },    /* Default memory handling */
131
  NULL,                                      /* Stack guard */
132
  NULL,                                      /* Stack guard data */
133
  PRIV(default_tables),                      /* Character tables */
134
  PCRE2_UNSET,                               /* Max pattern length */
135
  PCRE2_UNSET,                               /* Max pattern compiled length */
136
  BSR_DEFAULT,                               /* Backslash R default */
137
  NEWLINE_DEFAULT,                           /* Newline convention */
138
  PARENS_NEST_LIMIT,                         /* As it says */
139
  0,                                         /* Extra options */
140
  MAX_VARLOOKBEHIND,                         /* As it says */
141
  PCRE2_OPTIMIZATION_ALL                     /* All optimizations enabled */
142
  };
143
144
/* The create function copies the default into the new memory, but must
145
override the default memory handling functions if a gcontext was provided. */
146
147
PCRE2_EXP_DEFN pcre2_compile_context * PCRE2_CALL_CONVENTION
148
pcre2_compile_context_create(pcre2_general_context *gcontext)
149
379k
{
150
379k
pcre2_compile_context *ccontext = PRIV(memctl_malloc)(
151
379k
  sizeof(pcre2_real_compile_context), (pcre2_memctl *)gcontext);
152
379k
if (ccontext == NULL) return NULL;
153
379k
*ccontext = PRIV(default_compile_context);
154
379k
if (gcontext != NULL)
155
0
  *((pcre2_memctl *)ccontext) = *((pcre2_memctl *)gcontext);
156
379k
return ccontext;
157
379k
}
pcre2_compile_context_create_8
Line
Count
Source
149
123k
{
150
123k
pcre2_compile_context *ccontext = PRIV(memctl_malloc)(
151
123k
  sizeof(pcre2_real_compile_context), (pcre2_memctl *)gcontext);
152
123k
if (ccontext == NULL) return NULL;
153
123k
*ccontext = PRIV(default_compile_context);
154
123k
if (gcontext != NULL)
155
0
  *((pcre2_memctl *)ccontext) = *((pcre2_memctl *)gcontext);
156
123k
return ccontext;
157
123k
}
pcre2_compile_context_create_32
Line
Count
Source
149
129k
{
150
129k
pcre2_compile_context *ccontext = PRIV(memctl_malloc)(
151
129k
  sizeof(pcre2_real_compile_context), (pcre2_memctl *)gcontext);
152
129k
if (ccontext == NULL) return NULL;
153
129k
*ccontext = PRIV(default_compile_context);
154
129k
if (gcontext != NULL)
155
0
  *((pcre2_memctl *)ccontext) = *((pcre2_memctl *)gcontext);
156
129k
return ccontext;
157
129k
}
pcre2_compile_context_create_16
Line
Count
Source
149
126k
{
150
126k
pcre2_compile_context *ccontext = PRIV(memctl_malloc)(
151
126k
  sizeof(pcre2_real_compile_context), (pcre2_memctl *)gcontext);
152
126k
if (ccontext == NULL) return NULL;
153
126k
*ccontext = PRIV(default_compile_context);
154
126k
if (gcontext != NULL)
155
0
  *((pcre2_memctl *)ccontext) = *((pcre2_memctl *)gcontext);
156
126k
return ccontext;
157
126k
}
158
159
160
/* A default match context is set up to save having to initialize at run time
161
when no context is supplied to a match function. */
162
163
pcre2_match_context PRIV(default_match_context) = {
164
  { default_malloc, default_free, NULL },
165
#ifdef SUPPORT_JIT
166
  NULL,          /* JIT callback */
167
  NULL,          /* JIT callback data */
168
#endif
169
  NULL,          /* Callout function */
170
  NULL,          /* Callout data */
171
  NULL,          /* Substitute callout function */
172
  NULL,          /* Substitute callout data */
173
  NULL,          /* Substitute case callout function */
174
  NULL,          /* Substitute case callout data */
175
  PCRE2_UNSET,   /* Offset limit */
176
  HEAP_LIMIT,
177
  MATCH_LIMIT,
178
  MATCH_LIMIT_DEPTH };
179
180
/* The create function copies the default into the new memory, but must
181
override the default memory handling functions if a gcontext was provided. */
182
183
PCRE2_EXP_DEFN pcre2_match_context * PCRE2_CALL_CONVENTION
184
pcre2_match_context_create(pcre2_general_context *gcontext)
185
341k
{
186
341k
pcre2_match_context *mcontext = PRIV(memctl_malloc)(
187
341k
  sizeof(pcre2_real_match_context), (pcre2_memctl *)gcontext);
188
341k
if (mcontext == NULL) return NULL;
189
341k
*mcontext = PRIV(default_match_context);
190
341k
if (gcontext != NULL)
191
0
  *((pcre2_memctl *)mcontext) = *((pcre2_memctl *)gcontext);
192
341k
return mcontext;
193
341k
}
pcre2_match_context_create_8
Line
Count
Source
185
111k
{
186
111k
pcre2_match_context *mcontext = PRIV(memctl_malloc)(
187
111k
  sizeof(pcre2_real_match_context), (pcre2_memctl *)gcontext);
188
111k
if (mcontext == NULL) return NULL;
189
111k
*mcontext = PRIV(default_match_context);
190
111k
if (gcontext != NULL)
191
0
  *((pcre2_memctl *)mcontext) = *((pcre2_memctl *)gcontext);
192
111k
return mcontext;
193
111k
}
pcre2_match_context_create_32
Line
Count
Source
185
115k
{
186
115k
pcre2_match_context *mcontext = PRIV(memctl_malloc)(
187
115k
  sizeof(pcre2_real_match_context), (pcre2_memctl *)gcontext);
188
115k
if (mcontext == NULL) return NULL;
189
115k
*mcontext = PRIV(default_match_context);
190
115k
if (gcontext != NULL)
191
0
  *((pcre2_memctl *)mcontext) = *((pcre2_memctl *)gcontext);
192
115k
return mcontext;
193
115k
}
pcre2_match_context_create_16
Line
Count
Source
185
114k
{
186
114k
pcre2_match_context *mcontext = PRIV(memctl_malloc)(
187
114k
  sizeof(pcre2_real_match_context), (pcre2_memctl *)gcontext);
188
114k
if (mcontext == NULL) return NULL;
189
114k
*mcontext = PRIV(default_match_context);
190
114k
if (gcontext != NULL)
191
0
  *((pcre2_memctl *)mcontext) = *((pcre2_memctl *)gcontext);
192
114k
return mcontext;
193
114k
}
194
195
196
/* A default convert context is set up to save having to initialize at run time
197
when no context is supplied to the convert function. */
198
199
pcre2_convert_context PRIV(default_convert_context) = {
200
  { default_malloc, default_free, NULL },    /* Default memory handling */
201
#ifdef _WIN32
202
  CHAR_BACKSLASH,                            /* Default path separator */
203
  CHAR_GRAVE_ACCENT                          /* Default escape character */
204
#else  /* Not Windows */
205
  CHAR_SLASH,                                /* Default path separator */
206
  CHAR_BACKSLASH                             /* Default escape character */
207
#endif
208
  };
209
210
/* The create function copies the default into the new memory, but must
211
override the default memory handling functions if a gcontext was provided. */
212
213
PCRE2_EXP_DEFN pcre2_convert_context * PCRE2_CALL_CONVENTION
214
pcre2_convert_context_create(pcre2_general_context *gcontext)
215
0
{
216
0
pcre2_convert_context *ccontext = PRIV(memctl_malloc)(
217
0
  sizeof(pcre2_real_convert_context), (pcre2_memctl *)gcontext);
218
0
if (ccontext == NULL) return NULL;
219
0
*ccontext = PRIV(default_convert_context);
220
0
if (gcontext != NULL)
221
0
  *((pcre2_memctl *)ccontext) = *((pcre2_memctl *)gcontext);
222
0
return ccontext;
223
0
}
Unexecuted instantiation: pcre2_convert_context_create_8
Unexecuted instantiation: pcre2_convert_context_create_32
Unexecuted instantiation: pcre2_convert_context_create_16
224
225
226
/*************************************************
227
*              Context copy functions            *
228
*************************************************/
229
230
PCRE2_EXP_DEFN pcre2_general_context * PCRE2_CALL_CONVENTION
231
pcre2_general_context_copy(pcre2_general_context *gcontext)
232
0
{
233
0
pcre2_general_context *newcontext =
234
0
  gcontext->memctl.malloc(sizeof(pcre2_real_general_context),
235
0
  gcontext->memctl.memory_data);
236
0
if (newcontext == NULL) return NULL;
237
0
memcpy(newcontext, gcontext, sizeof(pcre2_real_general_context));
238
0
return newcontext;
239
0
}
Unexecuted instantiation: pcre2_general_context_copy_8
Unexecuted instantiation: pcre2_general_context_copy_32
Unexecuted instantiation: pcre2_general_context_copy_16
240
241
242
PCRE2_EXP_DEFN pcre2_compile_context * PCRE2_CALL_CONVENTION
243
pcre2_compile_context_copy(pcre2_compile_context *ccontext)
244
0
{
245
0
pcre2_compile_context *newcontext =
246
0
  ccontext->memctl.malloc(sizeof(pcre2_real_compile_context),
247
0
  ccontext->memctl.memory_data);
248
0
if (newcontext == NULL) return NULL;
249
0
memcpy(newcontext, ccontext, sizeof(pcre2_real_compile_context));
250
0
return newcontext;
251
0
}
Unexecuted instantiation: pcre2_compile_context_copy_8
Unexecuted instantiation: pcre2_compile_context_copy_32
Unexecuted instantiation: pcre2_compile_context_copy_16
252
253
254
PCRE2_EXP_DEFN pcre2_match_context * PCRE2_CALL_CONVENTION
255
pcre2_match_context_copy(pcre2_match_context *mcontext)
256
0
{
257
0
pcre2_match_context *newcontext =
258
0
  mcontext->memctl.malloc(sizeof(pcre2_real_match_context),
259
0
  mcontext->memctl.memory_data);
260
0
if (newcontext == NULL) return NULL;
261
0
memcpy(newcontext, mcontext, sizeof(pcre2_real_match_context));
262
0
return newcontext;
263
0
}
Unexecuted instantiation: pcre2_match_context_copy_8
Unexecuted instantiation: pcre2_match_context_copy_32
Unexecuted instantiation: pcre2_match_context_copy_16
264
265
266
PCRE2_EXP_DEFN pcre2_convert_context * PCRE2_CALL_CONVENTION
267
pcre2_convert_context_copy(pcre2_convert_context *ccontext)
268
0
{
269
0
pcre2_convert_context *newcontext =
270
0
  ccontext->memctl.malloc(sizeof(pcre2_real_convert_context),
271
0
  ccontext->memctl.memory_data);
272
0
if (newcontext == NULL) return NULL;
273
0
memcpy(newcontext, ccontext, sizeof(pcre2_real_convert_context));
274
0
return newcontext;
275
0
}
Unexecuted instantiation: pcre2_convert_context_copy_8
Unexecuted instantiation: pcre2_convert_context_copy_32
Unexecuted instantiation: pcre2_convert_context_copy_16
276
277
278
/*************************************************
279
*              Context free functions            *
280
*************************************************/
281
282
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
283
pcre2_general_context_free(pcre2_general_context *gcontext)
284
0
{
285
0
if (gcontext != NULL)
286
0
  gcontext->memctl.free(gcontext, gcontext->memctl.memory_data);
287
0
}
Unexecuted instantiation: pcre2_general_context_free_8
Unexecuted instantiation: pcre2_general_context_free_32
Unexecuted instantiation: pcre2_general_context_free_16
288
289
290
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
291
pcre2_compile_context_free(pcre2_compile_context *ccontext)
292
379k
{
293
379k
if (ccontext != NULL)
294
379k
  ccontext->memctl.free(ccontext, ccontext->memctl.memory_data);
295
379k
}
pcre2_compile_context_free_8
Line
Count
Source
292
123k
{
293
123k
if (ccontext != NULL)
294
123k
  ccontext->memctl.free(ccontext, ccontext->memctl.memory_data);
295
123k
}
pcre2_compile_context_free_32
Line
Count
Source
292
129k
{
293
129k
if (ccontext != NULL)
294
129k
  ccontext->memctl.free(ccontext, ccontext->memctl.memory_data);
295
129k
}
pcre2_compile_context_free_16
Line
Count
Source
292
126k
{
293
126k
if (ccontext != NULL)
294
126k
  ccontext->memctl.free(ccontext, ccontext->memctl.memory_data);
295
126k
}
296
297
298
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
299
pcre2_match_context_free(pcre2_match_context *mcontext)
300
341k
{
301
341k
if (mcontext != NULL)
302
341k
  mcontext->memctl.free(mcontext, mcontext->memctl.memory_data);
303
341k
}
pcre2_match_context_free_8
Line
Count
Source
300
111k
{
301
111k
if (mcontext != NULL)
302
111k
  mcontext->memctl.free(mcontext, mcontext->memctl.memory_data);
303
111k
}
pcre2_match_context_free_32
Line
Count
Source
300
115k
{
301
115k
if (mcontext != NULL)
302
115k
  mcontext->memctl.free(mcontext, mcontext->memctl.memory_data);
303
115k
}
pcre2_match_context_free_16
Line
Count
Source
300
114k
{
301
114k
if (mcontext != NULL)
302
114k
  mcontext->memctl.free(mcontext, mcontext->memctl.memory_data);
303
114k
}
304
305
306
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
307
pcre2_convert_context_free(pcre2_convert_context *ccontext)
308
0
{
309
0
if (ccontext != NULL)
310
0
  ccontext->memctl.free(ccontext, ccontext->memctl.memory_data);
311
0
}
Unexecuted instantiation: pcre2_convert_context_free_8
Unexecuted instantiation: pcre2_convert_context_free_32
Unexecuted instantiation: pcre2_convert_context_free_16
312
313
314
/*************************************************
315
*             Set values in contexts             *
316
*************************************************/
317
318
/* All these functions return 0 for success or PCRE2_ERROR_BADDATA if invalid
319
data is given. Only some of the functions are able to test the validity of the
320
data. */
321
322
323
/* ------------ Compile context ------------ */
324
325
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
326
pcre2_set_character_tables(pcre2_compile_context *ccontext,
327
  const uint8_t *tables)
328
0
{
329
0
ccontext->tables = tables;
330
0
return 0;
331
0
}
Unexecuted instantiation: pcre2_set_character_tables_8
Unexecuted instantiation: pcre2_set_character_tables_32
Unexecuted instantiation: pcre2_set_character_tables_16
332
333
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
334
pcre2_set_bsr(pcre2_compile_context *ccontext, uint32_t value)
335
0
{
336
0
switch(value)
337
0
  {
338
0
  case PCRE2_BSR_ANYCRLF:
339
0
  case PCRE2_BSR_UNICODE:
340
0
  ccontext->bsr_convention = value;
341
0
  return 0;
342
343
0
  default:
344
0
  return PCRE2_ERROR_BADDATA;
345
0
  }
346
0
}
Unexecuted instantiation: pcre2_set_bsr_8
Unexecuted instantiation: pcre2_set_bsr_32
Unexecuted instantiation: pcre2_set_bsr_16
347
348
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
349
pcre2_set_max_pattern_length(pcre2_compile_context *ccontext, PCRE2_SIZE length)
350
0
{
351
0
ccontext->max_pattern_length = length;
352
0
return 0;
353
0
}
Unexecuted instantiation: pcre2_set_max_pattern_length_8
Unexecuted instantiation: pcre2_set_max_pattern_length_32
Unexecuted instantiation: pcre2_set_max_pattern_length_16
354
355
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
356
pcre2_set_max_pattern_compiled_length(pcre2_compile_context *ccontext, PCRE2_SIZE length)
357
379k
{
358
379k
ccontext->max_pattern_compiled_length = length;
359
379k
return 0;
360
379k
}
pcre2_set_max_pattern_compiled_length_8
Line
Count
Source
357
123k
{
358
123k
ccontext->max_pattern_compiled_length = length;
359
123k
return 0;
360
123k
}
pcre2_set_max_pattern_compiled_length_32
Line
Count
Source
357
129k
{
358
129k
ccontext->max_pattern_compiled_length = length;
359
129k
return 0;
360
129k
}
pcre2_set_max_pattern_compiled_length_16
Line
Count
Source
357
126k
{
358
126k
ccontext->max_pattern_compiled_length = length;
359
126k
return 0;
360
126k
}
361
362
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
363
pcre2_set_newline(pcre2_compile_context *ccontext, uint32_t newline)
364
0
{
365
0
switch(newline)
366
0
  {
367
0
  case PCRE2_NEWLINE_CR:
368
0
  case PCRE2_NEWLINE_LF:
369
0
  case PCRE2_NEWLINE_CRLF:
370
0
  case PCRE2_NEWLINE_ANY:
371
0
  case PCRE2_NEWLINE_ANYCRLF:
372
0
  case PCRE2_NEWLINE_NUL:
373
0
  ccontext->newline_convention = newline;
374
0
  return 0;
375
376
0
  default:
377
0
  return PCRE2_ERROR_BADDATA;
378
0
  }
379
0
}
Unexecuted instantiation: pcre2_set_newline_8
Unexecuted instantiation: pcre2_set_newline_32
Unexecuted instantiation: pcre2_set_newline_16
380
381
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
382
pcre2_set_max_varlookbehind(pcre2_compile_context *ccontext, uint32_t limit)
383
0
{
384
0
ccontext->max_varlookbehind = limit;
385
0
return 0;
386
0
}
Unexecuted instantiation: pcre2_set_max_varlookbehind_8
Unexecuted instantiation: pcre2_set_max_varlookbehind_32
Unexecuted instantiation: pcre2_set_max_varlookbehind_16
387
388
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
389
pcre2_set_parens_nest_limit(pcre2_compile_context *ccontext, uint32_t limit)
390
0
{
391
0
ccontext->parens_nest_limit = limit;
392
0
return 0;
393
0
}
Unexecuted instantiation: pcre2_set_parens_nest_limit_8
Unexecuted instantiation: pcre2_set_parens_nest_limit_32
Unexecuted instantiation: pcre2_set_parens_nest_limit_16
394
395
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
396
pcre2_set_compile_extra_options(pcre2_compile_context *ccontext, uint32_t options)
397
0
{
398
0
ccontext->extra_options = options;
399
0
return 0;
400
0
}
Unexecuted instantiation: pcre2_set_compile_extra_options_8
Unexecuted instantiation: pcre2_set_compile_extra_options_32
Unexecuted instantiation: pcre2_set_compile_extra_options_16
401
402
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
403
pcre2_set_compile_recursion_guard(pcre2_compile_context *ccontext,
404
  int (*guard)(uint32_t, void *), void *user_data)
405
0
{
406
0
ccontext->stack_guard = guard;
407
0
ccontext->stack_guard_data = user_data;
408
0
return 0;
409
0
}
Unexecuted instantiation: pcre2_set_compile_recursion_guard_8
Unexecuted instantiation: pcre2_set_compile_recursion_guard_32
Unexecuted instantiation: pcre2_set_compile_recursion_guard_16
410
411
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
412
pcre2_set_optimize(pcre2_compile_context *ccontext, uint32_t directive)
413
0
{
414
0
if (ccontext == NULL)
415
0
  return PCRE2_ERROR_NULL;
416
417
0
switch (directive)
418
0
  {
419
0
  case PCRE2_OPTIMIZATION_NONE:
420
0
  ccontext->optimization_flags = 0;
421
0
  break;
422
423
0
  case PCRE2_OPTIMIZATION_FULL:
424
0
  ccontext->optimization_flags = PCRE2_OPTIMIZATION_ALL;
425
0
  break;
426
427
0
  default:
428
0
  if (directive >= PCRE2_AUTO_POSSESS && directive <= PCRE2_START_OPTIMIZE_OFF)
429
0
    {
430
    /* Even directive numbers starting from 64 switch a bit on;
431
     * Odd directive numbers starting from 65 switch a bit off */
432
0
    if ((directive & 1) != 0)
433
0
      ccontext->optimization_flags &= ~(1u << ((directive >> 1) - 32));
434
0
    else
435
0
      ccontext->optimization_flags |= 1u << ((directive >> 1) - 32);
436
0
    return 0;
437
0
    }
438
0
  return PCRE2_ERROR_BADOPTION;
439
0
  }
440
441
0
return 0;
442
0
}
Unexecuted instantiation: pcre2_set_optimize_8
Unexecuted instantiation: pcre2_set_optimize_32
Unexecuted instantiation: pcre2_set_optimize_16
443
444
/* ------------ Match context ------------ */
445
446
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
447
pcre2_set_callout(pcre2_match_context *mcontext,
448
  int (*callout)(pcre2_callout_block *, void *), void *callout_data)
449
341k
{
450
341k
mcontext->callout = callout;
451
341k
mcontext->callout_data = callout_data;
452
341k
return 0;
453
341k
}
pcre2_set_callout_8
Line
Count
Source
449
111k
{
450
111k
mcontext->callout = callout;
451
111k
mcontext->callout_data = callout_data;
452
111k
return 0;
453
111k
}
pcre2_set_callout_32
Line
Count
Source
449
115k
{
450
115k
mcontext->callout = callout;
451
115k
mcontext->callout_data = callout_data;
452
115k
return 0;
453
115k
}
pcre2_set_callout_16
Line
Count
Source
449
114k
{
450
114k
mcontext->callout = callout;
451
114k
mcontext->callout_data = callout_data;
452
114k
return 0;
453
114k
}
454
455
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
456
pcre2_set_substitute_callout(pcre2_match_context *mcontext,
457
  int (*substitute_callout)(pcre2_substitute_callout_block *, void *),
458
  void *substitute_callout_data)
459
0
{
460
0
mcontext->substitute_callout = substitute_callout;
461
0
mcontext->substitute_callout_data = substitute_callout_data;
462
0
return 0;
463
0
}
Unexecuted instantiation: pcre2_set_substitute_callout_8
Unexecuted instantiation: pcre2_set_substitute_callout_32
Unexecuted instantiation: pcre2_set_substitute_callout_16
464
465
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
466
pcre2_set_substitute_case_callout(pcre2_match_context *mcontext,
467
  PCRE2_SIZE (*substitute_case_callout)(PCRE2_SPTR, PCRE2_SIZE, PCRE2_UCHAR *,
468
                                        PCRE2_SIZE, int, void *),
469
  void *substitute_case_callout_data)
470
0
{
471
0
mcontext->substitute_case_callout = substitute_case_callout;
472
0
mcontext->substitute_case_callout_data = substitute_case_callout_data;
473
0
return 0;
474
0
}
Unexecuted instantiation: pcre2_set_substitute_case_callout_8
Unexecuted instantiation: pcre2_set_substitute_case_callout_32
Unexecuted instantiation: pcre2_set_substitute_case_callout_16
475
476
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
477
pcre2_set_heap_limit(pcre2_match_context *mcontext, uint32_t limit)
478
0
{
479
0
mcontext->heap_limit = limit;
480
0
return 0;
481
0
}
Unexecuted instantiation: pcre2_set_heap_limit_8
Unexecuted instantiation: pcre2_set_heap_limit_32
Unexecuted instantiation: pcre2_set_heap_limit_16
482
483
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
484
pcre2_set_match_limit(pcre2_match_context *mcontext, uint32_t limit)
485
341k
{
486
341k
mcontext->match_limit = limit;
487
341k
return 0;
488
341k
}
pcre2_set_match_limit_8
Line
Count
Source
485
111k
{
486
111k
mcontext->match_limit = limit;
487
111k
return 0;
488
111k
}
pcre2_set_match_limit_32
Line
Count
Source
485
115k
{
486
115k
mcontext->match_limit = limit;
487
115k
return 0;
488
115k
}
pcre2_set_match_limit_16
Line
Count
Source
485
114k
{
486
114k
mcontext->match_limit = limit;
487
114k
return 0;
488
114k
}
489
490
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
491
pcre2_set_depth_limit(pcre2_match_context *mcontext, uint32_t limit)
492
341k
{
493
341k
mcontext->depth_limit = limit;
494
341k
return 0;
495
341k
}
pcre2_set_depth_limit_8
Line
Count
Source
492
111k
{
493
111k
mcontext->depth_limit = limit;
494
111k
return 0;
495
111k
}
pcre2_set_depth_limit_32
Line
Count
Source
492
115k
{
493
115k
mcontext->depth_limit = limit;
494
115k
return 0;
495
115k
}
pcre2_set_depth_limit_16
Line
Count
Source
492
114k
{
493
114k
mcontext->depth_limit = limit;
494
114k
return 0;
495
114k
}
496
497
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
498
pcre2_set_offset_limit(pcre2_match_context *mcontext, PCRE2_SIZE limit)
499
0
{
500
0
mcontext->offset_limit = limit;
501
0
return 0;
502
0
}
Unexecuted instantiation: pcre2_set_offset_limit_8
Unexecuted instantiation: pcre2_set_offset_limit_32
Unexecuted instantiation: pcre2_set_offset_limit_16
503
504
/* These functions became obsolete at release 10.30. The first is kept as a
505
synonym for backwards compatibility. The second now does nothing. */
506
507
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
508
pcre2_set_recursion_limit(pcre2_match_context *mcontext, uint32_t limit)
509
0
{
510
0
return pcre2_set_depth_limit(mcontext, limit);
511
0
}
Unexecuted instantiation: pcre2_set_recursion_limit_8
Unexecuted instantiation: pcre2_set_recursion_limit_32
Unexecuted instantiation: pcre2_set_recursion_limit_16
512
513
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
514
pcre2_set_recursion_memory_management(pcre2_match_context *mcontext,
515
  void *(*mymalloc)(size_t, void *), void (*myfree)(void *, void *),
516
  void *mydata)
517
0
{
518
0
(void)mcontext;
519
0
(void)mymalloc;
520
0
(void)myfree;
521
0
(void)mydata;
522
0
return 0;
523
0
}
Unexecuted instantiation: pcre2_set_recursion_memory_management_8
Unexecuted instantiation: pcre2_set_recursion_memory_management_32
Unexecuted instantiation: pcre2_set_recursion_memory_management_16
524
525
526
/* ------------ Convert context ------------ */
527
528
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
529
pcre2_set_glob_separator(pcre2_convert_context *ccontext, uint32_t separator)
530
0
{
531
0
if (separator != CHAR_SLASH && separator != CHAR_BACKSLASH &&
532
0
    separator != CHAR_DOT) return PCRE2_ERROR_BADDATA;
533
0
ccontext->glob_separator = separator;
534
0
return 0;
535
0
}
Unexecuted instantiation: pcre2_set_glob_separator_8
Unexecuted instantiation: pcre2_set_glob_separator_32
Unexecuted instantiation: pcre2_set_glob_separator_16
536
537
static const char *globpunct =
538
  STR_EXCLAMATION_MARK STR_QUOTATION_MARK STR_NUMBER_SIGN STR_DOLLAR_SIGN
539
  STR_PERCENT_SIGN STR_AMPERSAND STR_APOSTROPHE STR_LEFT_PARENTHESIS
540
  STR_RIGHT_PARENTHESIS STR_ASTERISK STR_PLUS STR_COMMA STR_MINUS STR_DOT
541
  STR_SLASH STR_COLON STR_SEMICOLON STR_LESS_THAN_SIGN STR_EQUALS_SIGN
542
  STR_GREATER_THAN_SIGN STR_QUESTION_MARK STR_COMMERCIAL_AT
543
  STR_LEFT_SQUARE_BRACKET STR_BACKSLASH STR_RIGHT_SQUARE_BRACKET
544
  STR_CIRCUMFLEX_ACCENT STR_UNDERSCORE STR_GRAVE_ACCENT STR_LEFT_CURLY_BRACKET
545
  STR_VERTICAL_LINE STR_RIGHT_CURLY_BRACKET STR_TILDE;
546
547
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
548
pcre2_set_glob_escape(pcre2_convert_context *ccontext, uint32_t escape)
549
0
{
550
0
if (escape > 255 || (escape != 0 && strchr(globpunct, escape) == NULL))
551
0
  return PCRE2_ERROR_BADDATA;
552
0
ccontext->glob_escape = escape;
553
0
return 0;
554
0
}
Unexecuted instantiation: pcre2_set_glob_escape_8
Unexecuted instantiation: pcre2_set_glob_escape_32
Unexecuted instantiation: pcre2_set_glob_escape_16
555
556
/* End of pcre2_context.c */
557