From c2882d31134116dd2ebbf41cb89c115ea6f88bb3 Mon Sep 17 00:00:00 2001 From: Lucas Trzesniewski Date: Sat, 28 Dec 2024 16:47:38 +0100 Subject: [PATCH] Update constants TODO: Add them to API --- README.md | 2 +- src/PCRE.NET/Internal/PcreConstants.cs | 39 +++++++++++++++++++++++++- src/PCRE.NET/PcreErrorCode.cs | 9 +++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 30cb237..9422190 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This is a friendly API that is very similar to .NET's `System.Text.RegularExpres - Callbacks: `Func` - Replacement strings with placeholders: ``$n ${name} $& $_ $` $' $+`` - Using `Substitute`, the PCRE2 API: - - Replacement strings with placeholders: ``$n ${n} $$ $*MARK ${*MARK}`` + - Replacement strings with placeholders: ``$n ${n} $& $_ $` $' $$ $*MARK ${*MARK}`` - Callouts for matches and substitutions - String splitting on matches: `Split` diff --git a/src/PCRE.NET/Internal/PcreConstants.cs b/src/PCRE.NET/Internal/PcreConstants.cs index ef0e916..aa11d7c 100644 --- a/src/PCRE.NET/Internal/PcreConstants.cs +++ b/src/PCRE.NET/Internal/PcreConstants.cs @@ -40,6 +40,7 @@ internal static class PcreConstants public const uint EXTENDED_MORE = 0x01000000; public const uint LITERAL = 0x02000000; public const uint MATCH_INVALID_UTF = 0x04000000; + public const uint ALT_EXTENDED_CLASS = 0x08000000; public const uint EXTRA_ALLOW_SURROGATE_ESCAPES = 0x00000001; public const uint EXTRA_BAD_ESCAPE_IS_LITERAL = 0x00000002; public const uint EXTRA_MATCH_WORD = 0x00000004; @@ -53,10 +54,15 @@ internal static class PcreConstants public const uint EXTRA_ASCII_BSW = 0x00000400; public const uint EXTRA_ASCII_POSIX = 0x00000800; public const uint EXTRA_ASCII_DIGIT = 0x00001000; + public const uint EXTRA_PYTHON_OCTAL = 0x00002000; + public const uint EXTRA_NO_BS0 = 0x00004000; + public const uint EXTRA_NEVER_CALLOUT = 0x00008000; + public const uint EXTRA_TURKISH_CASING = 0x00010000; public const uint JIT_COMPLETE = 0x00000001; public const uint JIT_PARTIAL_SOFT = 0x00000002; public const uint JIT_PARTIAL_HARD = 0x00000004; public const uint JIT_INVALID_UTF = 0x00000100; + public const uint JIT_TEST_ALLOC = 0x00000200; public const uint NOTBOL = 0x00000001; public const uint NOTEOL = 0x00000002; public const uint NOTEMPTY = 0x00000004; @@ -188,8 +194,25 @@ internal static class PcreConstants public const int ERROR_ALPHA_ASSERTION_UNKNOWN = 195; public const int ERROR_SCRIPT_RUN_NOT_AVAILABLE = 196; public const int ERROR_TOO_MANY_CAPTURES = 197; - public const int ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED = 198; + public const int ERROR_MISSING_OCTAL_DIGIT = 198; public const int ERROR_BACKSLASH_K_IN_LOOKAROUND = 199; + public const int ERROR_MAX_VAR_LOOKBEHIND_EXCEEDED = 200; + public const int ERROR_PATTERN_COMPILED_SIZE_TOO_BIG = 201; + public const int ERROR_OVERSIZE_PYTHON_OCTAL = 202; + public const int ERROR_CALLOUT_CALLER_DISABLED = 203; + public const int ERROR_EXTRA_CASING_REQUIRES_UNICODE = 204; + public const int ERROR_TURKISH_CASING_REQUIRES_UTF = 205; + public const int ERROR_EXTRA_CASING_INCOMPATIBLE = 206; + public const int ERROR_ECLASS_NEST_TOO_DEEP = 207; + public const int ERROR_ECLASS_INVALID_OPERATOR = 208; + public const int ERROR_ECLASS_UNEXPECTED_OPERATOR = 209; + public const int ERROR_ECLASS_EXPECTED_OPERAND = 210; + public const int ERROR_ECLASS_MIXED_OPERATORS = 211; + public const int ERROR_ECLASS_HINT_SQUARE_BRACKET = 212; + public const int ERROR_PERL_ECLASS_UNEXPECTED_EXPR = 213; + public const int ERROR_PERL_ECLASS_EMPTY_EXPR = 214; + public const int ERROR_PERL_ECLASS_MISSING_CLOSE = 215; + public const int ERROR_PERL_ECLASS_UNEXPECTED_CHAR = 216; public const int ERROR_NOMATCH = -1; public const int ERROR_PARTIAL = -2; public const int ERROR_UTF8_ERR1 = -3; @@ -257,6 +280,9 @@ internal static class PcreConstants public const int ERROR_INTERNAL_DUPMATCH = -65; public const int ERROR_DFA_UINVALID_UTF = -66; public const int ERROR_INVALIDOFFSET = -67; + public const int ERROR_JIT_UNSUPPORTED = -68; + public const int ERROR_REPLACECASE = -69; + public const int ERROR_TOOLARGEREPLACE = -70; public const uint INFO_ALLOPTIONS = 0; public const uint INFO_ARGOPTIONS = 1; public const uint INFO_BACKREFMAX = 2; @@ -299,6 +325,17 @@ internal static class PcreConstants public const uint CONFIG_NEVER_BACKSLASH_C = 13; public const uint CONFIG_COMPILED_WIDTHS = 14; public const uint CONFIG_TABLES_LENGTH = 15; + public const uint OPTIMIZATION_NONE = 0; + public const uint OPTIMIZATION_FULL = 1; + public const uint AUTO_POSSESS = 64; + public const uint AUTO_POSSESS_OFF = 65; + public const uint DOTSTAR_ANCHOR = 66; + public const uint DOTSTAR_ANCHOR_OFF = 67; + public const uint START_OPTIMIZE = 68; + public const uint START_OPTIMIZE_OFF = 69; + public const uint SUBSTITUTE_CASE_LOWER = 1; + public const uint SUBSTITUTE_CASE_UPPER = 2; + public const uint SUBSTITUTE_CASE_TITLE_FIRST = 3; public const uint CALLOUT_STARTMATCH = 0x00000001; public const uint CALLOUT_BACKTRACK = 0x00000002; } diff --git a/src/PCRE.NET/PcreErrorCode.cs b/src/PCRE.NET/PcreErrorCode.cs index 640b9bf..8b84e65 100644 --- a/src/PCRE.NET/PcreErrorCode.cs +++ b/src/PCRE.NET/PcreErrorCode.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics.CodeAnalysis; using PCRE.Internal; @@ -501,10 +502,16 @@ public enum PcreErrorCode /// TooManyCaptures = PcreConstants.ERROR_TOO_MANY_CAPTURES, + /// + /// PCRE2_ERROR_MISSING_OCTAL_DIGIT - Octal digit missing after \0 (PCRE2_EXTRA_NO_BS0 is set). + /// + MissingOctalDigit = PcreConstants.ERROR_MISSING_OCTAL_DIGIT, + /// /// PCRE2_ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED - Atomic assertion expected after (?( or (?(?C) /// - ConditionAtomicAssertionExpected = PcreConstants.ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED, + [Obsolete($"Not used anymore, shares the code with {nameof(MissingOctalDigit)}")] + ConditionAtomicAssertionExpected = MissingOctalDigit, /// /// PCRE2_ERROR_BACKSLASH_K_IN_LOOKAROUND - \K is not allowed in lookarounds (but see ).