Skip to content

Commit b56349c

Browse files
committed
Use full names in PcreConstants
1 parent 0711d79 commit b56349c

27 files changed

Lines changed: 724 additions & 725 deletions

src/PCRE.NET/Conversion/PcreConvert.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public static unsafe class PcreConvert
1313
/// </summary>
1414
/// <param name="pattern">The pattern to convert.</param>
1515
public static string FromPosixBasic(string pattern)
16-
=> BasicConvert(pattern, PcreConstants.CONVERT_POSIX_BASIC);
16+
=> BasicConvert(pattern, PcreConstants.PCRE2_CONVERT_POSIX_BASIC);
1717

1818
/// <summary>
1919
/// Converts a POSIX extended pattern to a PCRE pattern.
2020
/// </summary>
2121
/// <param name="pattern">The pattern to convert.</param>
2222
public static string FromPosixExtended(string pattern)
23-
=> BasicConvert(pattern, PcreConstants.CONVERT_POSIX_EXTENDED);
23+
=> BasicConvert(pattern, PcreConstants.PCRE2_CONVERT_POSIX_EXTENDED);
2424

2525
/// <summary>
2626
/// Converts a glob pattern to a PCRE pattern.
@@ -60,7 +60,7 @@ private static string Convert(string pattern, Native.convert_input* input)
6060
{
6161
input->pattern = pPattern;
6262
input->pattern_length = (uint)pattern.Length;
63-
input->options |= PcreConstants.CONVERT_UTF;
63+
input->options |= PcreConstants.PCRE2_CONVERT_UTF;
6464

6565
Native.convert_result result;
6666
var errorCode = Native.convert(input, &result);

src/PCRE.NET/Conversion/PcreGlobConversionOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ internal void FillConvertInput(ref Native.convert_input input)
6161

6262
private uint GetConvertOptions()
6363
{
64-
var options = PcreConstants.CONVERT_GLOB;
64+
var options = PcreConstants.PCRE2_CONVERT_GLOB;
6565

6666
if (NoWildcardSeparator)
67-
options |= PcreConstants.CONVERT_GLOB_NO_WILD_SEPARATOR;
67+
options |= PcreConstants.PCRE2_CONVERT_GLOB_NO_WILD_SEPARATOR;
6868

6969
if (NoStarStar)
70-
options |= PcreConstants.CONVERT_GLOB_NO_STARSTAR;
70+
options |= PcreConstants.PCRE2_CONVERT_GLOB_NO_STARSTAR;
7171

7272
return options;
7373
}

src/PCRE.NET/Dfa/PcreDfaMatchOptions.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ public enum PcreDfaMatchOptions : long
1515
None = 0,
1616

1717
/// <inheritdoc cref="PcreMatchOptions.Anchored"/>
18-
Anchored = PcreConstants.ANCHORED,
18+
Anchored = PcreConstants.PCRE2_ANCHORED,
1919

2020
/// <inheritdoc cref="PcreMatchOptions.EndAnchored"/>
21-
EndAnchored = PcreConstants.ENDANCHORED,
21+
EndAnchored = PcreConstants.PCRE2_ENDANCHORED,
2222

2323
/// <inheritdoc cref="PcreMatchOptions.NotBol"/>
24-
NotBol = PcreConstants.NOTBOL,
24+
NotBol = PcreConstants.PCRE2_NOTBOL,
2525

2626
/// <inheritdoc cref="PcreMatchOptions.NotEol"/>
27-
NotEol = PcreConstants.NOTEOL,
27+
NotEol = PcreConstants.PCRE2_NOTEOL,
2828

2929
/// <inheritdoc cref="PcreMatchOptions.NotEmpty"/>
30-
NotEmpty = PcreConstants.NOTEMPTY,
30+
NotEmpty = PcreConstants.PCRE2_NOTEMPTY,
3131

3232
/// <inheritdoc cref="PcreMatchOptions.NotEmptyAtStart"/>
33-
NotEmptyAtStart = PcreConstants.NOTEMPTY_ATSTART,
33+
NotEmptyAtStart = PcreConstants.PCRE2_NOTEMPTY_ATSTART,
3434

3535
/// <inheritdoc cref="PcreMatchOptions.NoUtfCheck"/>
36-
NoUtfCheck = PcreConstants.NO_UTF_CHECK,
36+
NoUtfCheck = PcreConstants.PCRE2_NO_UTF_CHECK,
3737

3838
/// <summary>
3939
/// <c>PCRE2_PARTIAL_SOFT</c> - Enable partial matching mode. Still try to find a complete match if a partial match is found first.
@@ -57,7 +57,7 @@ public enum PcreDfaMatchOptions : long
5757
/// </para>
5858
/// </remarks>
5959
/// <see cref="PcreMatchOptions.PartialSoft"/>
60-
PartialSoft = PcreConstants.PARTIAL_SOFT,
60+
PartialSoft = PcreConstants.PCRE2_PARTIAL_SOFT,
6161

6262
/// <summary>
6363
/// <c>PCRE2_PARTIAL_HARD</c> - Enable partial matching mode. Stop looking for a complete match if a partial match is found first.
@@ -81,7 +81,7 @@ public enum PcreDfaMatchOptions : long
8181
/// </para>
8282
/// </remarks>
8383
/// <see cref="PcreMatchOptions.PartialHard"/>
84-
PartialHard = PcreConstants.PARTIAL_HARD,
84+
PartialHard = PcreConstants.PCRE2_PARTIAL_HARD,
8585

8686
/// <summary>
8787
/// <c>PCRE2_DFA_SHORTEST</c> - Stop at the first (and therefore shortest) match.
@@ -90,5 +90,5 @@ public enum PcreDfaMatchOptions : long
9090
/// Setting the <see cref="DfaShortest"/> option causes the matching algorithm to stop as soon as it has found one match.
9191
/// Because of the way the alternative algorithm works, this is necessarily the shortest possible match at the first possible matching point in the subject string.
9292
/// </remarks>
93-
DfaShortest = PcreConstants.DFA_SHORTEST
93+
DfaShortest = PcreConstants.PCRE2_DFA_SHORTEST
9494
}

src/PCRE.NET/Dfa/PcreDfaRegex.Match.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private IEnumerable<PcreDfaMatchResult> MatchesIterator(string subject, PcreDfaM
124124

125125
yield return match;
126126

127-
additionalOptions |= PcreConstants.NO_UTF_CHECK;
127+
additionalOptions |= PcreConstants.PCRE2_NO_UTF_CHECK;
128128

129129
while (true)
130130
{

src/PCRE.NET/Internal/CalloutInterop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public int Call(Native.pcre2_callout_block* callout)
291291
catch (Exception ex)
292292
{
293293
Exception = ex;
294-
return PcreConstants.ERROR_CALLOUT;
294+
return PcreConstants.PCRE2_ERROR_CALLOUT;
295295
}
296296
}
297297
}

src/PCRE.NET/Internal/InternalRegex.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ public PcreMatch Match(string subject,
160160
GC.KeepAlive(jitStack);
161161
}
162162

163-
if (result.result_code == PcreConstants.ERROR_NOMATCH)
163+
if (result.result_code == PcreConstants.PCRE2_ERROR_NOMATCH)
164164
return _noMatch ??= new PcreMatch(this);
165165

166-
if (result.result_code < PcreConstants.ERROR_PARTIAL)
166+
if (result.result_code < PcreConstants.PCRE2_ERROR_PARTIAL)
167167
HandleError(result, ref calloutInterop);
168168

169169
oVectorArray ??= oVector.ToArray();
@@ -212,10 +212,10 @@ public void Match(ref PcreRefMatch match,
212212
GC.KeepAlive(jitStack);
213213
}
214214

215-
if (result.result_code < PcreConstants.ERROR_PARTIAL)
215+
if (result.result_code < PcreConstants.PCRE2_ERROR_PARTIAL)
216216
HandleError(result, ref calloutInterop);
217217

218-
if (result.result_code != PcreConstants.ERROR_NOMATCH && oVector != match.OutputVector)
218+
if (result.result_code != PcreConstants.PCRE2_ERROR_NOMATCH && oVector != match.OutputVector)
219219
oVectorArray ??= oVector.ToArray();
220220

221221
match.Update(subject, result, oVectorArray);
@@ -253,7 +253,7 @@ public void BufferMatch(ref PcreRefMatch match,
253253
GC.KeepAlive(buffer); // The buffer keeps alive all the other required stuff
254254
}
255255

256-
if (result.result_code < PcreConstants.ERROR_PARTIAL)
256+
if (result.result_code < PcreConstants.PCRE2_ERROR_PARTIAL)
257257
HandleError(result, ref calloutInterop);
258258

259259
match.Update(subject, result, null);
@@ -287,7 +287,7 @@ public PcreDfaMatchResult DfaMatch(string subject, PcreDfaMatchSettings settings
287287
GC.KeepAlive(this);
288288
}
289289

290-
if (result.result_code < PcreConstants.ERROR_PARTIAL)
290+
if (result.result_code < PcreConstants.PCRE2_ERROR_PARTIAL)
291291
HandleError(result, ref calloutInterop);
292292

293293
return new PcreDfaMatchResult(subject, ref result, oVector);
@@ -343,7 +343,7 @@ public string Substitute(ReadOnlySpan<char> subject,
343343
{
344344
if (calloutInterop.Exception is { } ex)
345345
{
346-
if (result.result_code == PcreConstants.ERROR_REPLACECASE)
346+
if (result.result_code == PcreConstants.PCRE2_ERROR_REPLACECASE)
347347
throw new PcreCalloutException(PcreErrorCode.ReplaceCase, "An exception was thrown by the case-transformation callout: " + ex.Message, ex);
348348

349349
throw new PcreCalloutException("An exception was thrown by the callout: " + ex.Message, ex);
@@ -355,7 +355,7 @@ public string Substitute(ReadOnlySpan<char> subject,
355355
throw new PcreSubstituteException((PcreErrorCode)result.result_code);
356356

357357
case 0: // No substitution was made, avoid allocating a new string if possible
358-
if ((additionalOptions & PcreConstants.SUBSTITUTE_REPLACEMENT_ONLY) != 0)
358+
if ((additionalOptions & PcreConstants.PCRE2_SUBSTITUTE_REPLACEMENT_ONLY) != 0)
359359
return string.Empty;
360360

361361
return subjectAsString ?? subject.ToString();
@@ -378,11 +378,11 @@ private static void HandleError(in Native.match_result result, ref CalloutIntero
378378
{
379379
switch (result.result_code)
380380
{
381-
case PcreConstants.ERROR_NOMATCH:
382-
case PcreConstants.ERROR_PARTIAL:
381+
case PcreConstants.PCRE2_ERROR_NOMATCH:
382+
case PcreConstants.PCRE2_ERROR_PARTIAL:
383383
break;
384384

385-
case PcreConstants.ERROR_CALLOUT:
385+
case PcreConstants.PCRE2_ERROR_CALLOUT:
386386
throw new PcreCalloutException("An exception was thrown by the callout: " + calloutInterop.Exception?.Message, calloutInterop.Exception);
387387

388388
default:

0 commit comments

Comments
 (0)