Beispiel #1
0
        public PcreMatch Match(string subject, PcreMatchSettings settings, int startIndex, uint additionalOptions)
        {
            var input = new Native.match_input();

            settings.FillMatchInput(ref input);

            var oVector = new uint[OutputVectorSize];

            Native.match_result result;
            CalloutInterop.CalloutInteropInfo calloutInterop;

            fixed(char *pSubject = subject)
            fixed(uint *pOVec = &oVector[0])
            {
                input.code               = _code;
                input.subject            = pSubject;
                input.subject_length     = (uint)subject.Length;
                input.output_vector      = pOVec;
                input.start_index        = (uint)startIndex;
                input.additional_options = additionalOptions;

                CalloutInterop.Prepare(subject, this, ref input, out calloutInterop, settings.Callout);

                Native.match(ref input, out result);
            }

            AfterMatch(result, ref calloutInterop);

            return(new PcreMatch(subject, this, ref result, oVector));
        }
Beispiel #2
0
        public void Match(ref PcreRefMatch match, ReadOnlySpan <char> subject, PcreMatchSettings settings, int startIndex, uint additionalOptions)
        {
            var input = new Native.match_input();

            settings.FillMatchInput(ref input);

            Native.match_result result;
            CalloutInterop.CalloutInteropInfo calloutInterop;

            fixed(char *pSubject = subject)
            fixed(uint *pOVec = match.OutputVector)
            {
                input.code               = _code;
                input.subject            = pSubject;
                input.subject_length     = (uint)subject.Length;
                input.output_vector      = pOVec;
                input.start_index        = (uint)startIndex;
                input.additional_options = additionalOptions;

                if (input.subject == (char *)0 && input.subject_length == 0)
                {
                    input.subject = (char *)1; // PCRE doesn't like null subjects, even if the length is zero
                }
                CalloutInterop.Prepare(subject, this, ref input, out calloutInterop, settings.RefCallout);

                Native.match(ref input, out result);
            }

            AfterMatch(result, ref calloutInterop);

            match.Update(subject, result);
        }
Beispiel #3
0
        public PcreMatch Match(string subject, PcreMatchSettings settings)
        {
            var input = new Native.match_input();

            settings.FillMatchInput(ref input);
            return(Match(subject, settings, ref input));
        }
Beispiel #4
0
        public PcreMatch Match(string subject, PcreMatchSettings settings, int startIndex, uint additionalOptions)
        {
            var input = new Native.match_input();

            settings.FillMatchInput(ref input);
            input.start_index        = (uint)startIndex;
            input.additional_options = additionalOptions;
            return(Match(subject, settings, ref input));
        }
Beispiel #5
0
        public static void Prepare(ReadOnlySpan <char> subject, InternalRegex regex, ref Native.match_input input, out CalloutInteropInfo interopInfo, PcreRefCalloutFunc callout)
        {
            if (callout != null)
            {
                interopInfo = new CalloutInteropInfo(subject, regex, callout);

                input.callout      = _calloutHandlerFnPtr;
                input.callout_data = interopInfo.ToPointer();
            }
            else
            {
                interopInfo   = default;
                input.callout = null;
            }
        }
Beispiel #6
0
        public static void Prepare(string subject, InternalRegex regex, ref Native.match_input input, out CalloutInteropInfo interopInfo, Func <PcreCallout, PcreCalloutResult> callout)
        {
            if (callout != null)
            {
                interopInfo = new CalloutInteropInfo(subject, regex, callout);

                input.callout      = _calloutHandlerFnPtr;
                input.callout_data = interopInfo.ToPointer();
            }
            else
            {
                interopInfo   = default;
                input.callout = null;
            }
        }
Beispiel #7
0
        private PcreMatch Match(string subject, PcreMatchSettings settings, ref Native.match_input input)
        {
            var oVector = new uint[2 * (CaptureCount + 1)];

            Native.match_result result;
            CalloutInterop.CalloutInteropInfo calloutInterop;

            fixed(char *pSubject = subject)
            fixed(uint *pOVec = &oVector[0])
            {
                input.code           = _code;
                input.subject        = pSubject;
                input.subject_length = (uint)subject.Length;
                input.output_vector  = pOVec;

                CalloutInterop.Prepare(subject, this, ref input, out calloutInterop, settings.Callout);

                Native.match(ref input, out result);
            }

            AfterMatch(result, ref calloutInterop);

            return(new PcreMatch(subject, this, ref result, oVector));
        }