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

Function regmatch

src/engine/regexp.cpp:902–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

900 */
901
902static int32_t /* 0 failure, 1 success */
903regmatch( char * prog )
904{
905 char * scan; /* Current node. */
906 char * next; /* Next node. */
907
908 scan = prog;
909#ifdef DEBUG
910 if (scan != NULL && regnarrate)
911 err_printf("%s(\n", regprop(scan));
912#endif
913 while (scan != NULL) {
914#ifdef DEBUG
915 if (regnarrate)
916 err_printf("%s...\n", regprop(scan));
917#endif
918 next = regnext(scan);
919
920 switch (OP(scan)) {
921 case BOL:
922 if (reginput != regbol)
923 return(0);
924 break;
925 case EOL:
926 if (*reginput != '\0')
927 return(0);
928 break;
929 case WORDA:
930 /* Must be looking at a letter, digit, or _ */
931 if ((!isalnum(*reginput)) && *reginput != '_')
932 return(0);
933 /* Prev must be BOL or nonword */
934 if (reginput > regbol &&
935 (isalnum(reginput[-1]) || reginput[-1] == '_'))
936 return(0);
937 break;
938 case WORDZ:
939 /* Must be looking at non letter, digit, or _ */
940 if (isalnum(*reginput) || *reginput == '_')
941 return(0);
942 /* We don't care what the previous char was */
943 break;
944 case ANY:
945 if (*reginput == '\0')
946 return(0);
947 reginput++;
948 break;
949 case EXACTLY: {
950 size_t len;
951 char *opnd;
952
953 opnd = OPERAND(scan);
954 /* Inline the first character, for speed. */
955 if (*opnd != *reginput)
956 return(0);
957 len = strlen(opnd);
958 if (len > 1 && strncmp(opnd, reginput, len) != 0)
959 return(0);

Callers 1

regtryFunction · 0.85

Calls 5

err_printfFunction · 0.85
regpropFunction · 0.85
regnextFunction · 0.85
regrepeatFunction · 0.85
regerrorFunction · 0.85

Tested by

no test coverage detected