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

Function regexec

v2/engine/regexp.c:795–853  ·  view source on GitHub ↗

- regexec - match a regexp against a string */

Source from the content-addressed store, hash-verified

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

Callers 7

builtin_substFunction · 0.85
macro_headersFunction · 0.85
builtin_matchFunction · 0.85
headers1Function · 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