MCPcopy Create free account
hub / github.com/boostorg/build / regexec

Function regexec

src/engine/regexp.cpp:796–854  ·  view source on GitHub ↗

- regexec - match a regexp against a string */

Source from the content-addressed store, hash-verified

794 - regexec - match a regexp against a string
795 */
796int32_t
797regexec(
798 regexp *prog,
799 const char *string )
800{
801 char *s;
802
803 /* Be paranoid... */
804 if (prog == NULL || string == NULL) {
805 regerror("NULL parameter");
806 return(0);
807 }
808
809 /* Check validity of program. */
810 if (UCHARAT(prog->program) != MAGIC) {
811 regerror("corrupted program");
812 return(0);
813 }
814
815 /* If there is a "must appear" string, look for it. */
816 if ( prog->regmust != NULL )
817 {
818 s = (char *)string;
819 while ( ( s = strchr( s, prog->regmust[ 0 ] ) ) != NULL )
820 {
821 if ( !strncmp( s, prog->regmust, prog->regmlen ) )
822 break; /* Found it. */
823 ++s;
824 }
825 if ( s == NULL ) /* Not present. */
826 return 0;
827 }
828
829 /* Mark beginning of line for ^ . */
830 regbol = (char *)string;
831
832 /* Simplest case: anchored match need be tried only once. */
833 if ( prog->reganch )
834 return regtry( prog, string );
835
836 /* Messy cases: unanchored match. */
837 s = (char *)string;
838 if (prog->regstart != '\0')
839 /* We know what char it must start with. */
840 while ((s = strchr(s, prog->regstart)) != NULL) {
841 if (regtry(prog, s))
842 return(1);
843 s++;
844 }
845 else
846 /* We do not -- general case. */
847 do {
848 if ( regtry( prog, s ) )
849 return( 1 );
850 } while ( *s++ != '\0' );
851
852 /* Failure. */
853 return 0;

Callers 7

headers1Function · 0.85
builtin_substFunction · 0.85
builtin_matchFunction · 0.85
macro_headersFunction · 0.85
regex_splitFunction · 0.85
regex_replaceFunction · 0.85
regex_transformFunction · 0.85

Calls 2

regerrorFunction · 0.85
regtryFunction · 0.85

Tested by

no test coverage detected