Skip to content

Commit 88fabd8

Browse files
committed
Minor code adjustments to avoid using C++ reserved names "new" and "typename" as variables
1 parent f5cfe2a commit 88fabd8

File tree

2 files changed

+19
-32
lines changed

2 files changed

+19
-32
lines changed

src/pcre2_context.c

+17-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
77
88
Written by Philip Hazel
99
Original API code Copyright (c) 1997-2012 University of Cambridge
10-
New API code Copyright (c) 2016-2022 University of Cambridge
10+
New API code Copyright (c) 2016-2023 University of Cambridge
1111
1212
-----------------------------------------------------------------------------
1313
Redistribution and use in source and binary forms, with or without
@@ -228,49 +228,48 @@ return ccontext;
228228
PCRE2_EXP_DEFN pcre2_general_context * PCRE2_CALL_CONVENTION
229229
pcre2_general_context_copy(pcre2_general_context *gcontext)
230230
{
231-
pcre2_general_context *new =
231+
pcre2_general_context *newcontext =
232232
gcontext->memctl.malloc(sizeof(pcre2_real_general_context),
233233
gcontext->memctl.memory_data);
234-
if (new == NULL) return NULL;
235-
memcpy(new, gcontext, sizeof(pcre2_real_general_context));
236-
return new;
234+
if (newcontext == NULL) return NULL;
235+
memcpy(newcontext, gcontext, sizeof(pcre2_real_general_context));
236+
return newcontext;
237237
}
238238

239239

240240
PCRE2_EXP_DEFN pcre2_compile_context * PCRE2_CALL_CONVENTION
241241
pcre2_compile_context_copy(pcre2_compile_context *ccontext)
242242
{
243-
pcre2_compile_context *new =
243+
pcre2_compile_context *newcontext =
244244
ccontext->memctl.malloc(sizeof(pcre2_real_compile_context),
245245
ccontext->memctl.memory_data);
246-
if (new == NULL) return NULL;
247-
memcpy(new, ccontext, sizeof(pcre2_real_compile_context));
248-
return new;
246+
if (newcontext == NULL) return NULL;
247+
memcpy(newcontext, ccontext, sizeof(pcre2_real_compile_context));
248+
return newcontext;
249249
}
250250

251251

252252
PCRE2_EXP_DEFN pcre2_match_context * PCRE2_CALL_CONVENTION
253253
pcre2_match_context_copy(pcre2_match_context *mcontext)
254254
{
255-
pcre2_match_context *new =
255+
pcre2_match_context *newcontext =
256256
mcontext->memctl.malloc(sizeof(pcre2_real_match_context),
257257
mcontext->memctl.memory_data);
258-
if (new == NULL) return NULL;
259-
memcpy(new, mcontext, sizeof(pcre2_real_match_context));
260-
return new;
258+
if (newcontext == NULL) return NULL;
259+
memcpy(newcontext, mcontext, sizeof(pcre2_real_match_context));
260+
return newcontext;
261261
}
262262

263263

264-
265264
PCRE2_EXP_DEFN pcre2_convert_context * PCRE2_CALL_CONVENTION
266265
pcre2_convert_context_copy(pcre2_convert_context *ccontext)
267266
{
268-
pcre2_convert_context *new =
267+
pcre2_convert_context *newcontext =
269268
ccontext->memctl.malloc(sizeof(pcre2_real_convert_context),
270269
ccontext->memctl.memory_data);
271-
if (new == NULL) return NULL;
272-
memcpy(new, ccontext, sizeof(pcre2_real_convert_context));
273-
return new;
270+
if (newcontext == NULL) return NULL;
271+
memcpy(newcontext, ccontext, sizeof(pcre2_real_convert_context));
272+
return newcontext;
274273
}
275274

276275

src/pcre2test.c

+2-14
Original file line numberDiff line numberDiff line change
@@ -8661,25 +8661,13 @@ display_properties(BOOL wantscripts)
86618661
printf("** This version of PCRE2 was compiled without Unicode support.\n");
86628662
#else
86638663

8664-
const char *typename;
86658664
uint16_t seentypes[1024];
86668665
uint16_t seenvalues[1024];
86678666
int seencount = 0;
86688667
int16_t found[256][MAX_SYNONYMS + 1];
86698668
int fc = 0;
86708669
int colwidth = 40;
8671-
int n;
8672-
8673-
if (wantscripts)
8674-
{
8675-
n = ucp_Script_Count;
8676-
typename = "SCRIPTS";
8677-
}
8678-
else
8679-
{
8680-
n = ucp_Bprop_Count;
8681-
typename = "PROPERTIES";
8682-
}
8670+
int n = wantscripts? ucp_Script_Count : ucp_Bprop_Count;
86838671

86848672
for (size_t i = 0; i < PRIV(utt_size); i++)
86858673
{
@@ -8724,7 +8712,7 @@ for (size_t i = 0; i < PRIV(utt_size); i++)
87248712
}
87258713

87268714
printf("-------------------------- SUPPORTED %s --------------------------\n\n",
8727-
typename);
8715+
wantscripts? "SCRIPTS" : "PROPERTIES");
87288716

87298717
if (!wantscripts) printf(
87308718
"This release of PCRE2 supports Unicode's general category properties such\n"

0 commit comments

Comments
 (0)