Lines Matching refs:pattern

1337  *	Place the word in the buffer if it matches the given pattern.
1345 * pattern Pattern the word must match
1359 void *pattern)
1362 fprintf(debug_file, "VarMatch [%s] [%s]\n", word, (char *)pattern);
1363 if (Str_Match(word, (char *)pattern)) {
1377 * Place the word in the buffer if it matches the given pattern.
1428 * Place the word in the buffer if it doesn't match the given pattern.
1436 * pattern Pattern the word must match
1450 void *pattern)
1452 if (!Str_Match(word, (char *)pattern)) {
1491 VarPattern *pattern = (VarPattern *)patternp;
1494 if ((pattern->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) !=
1500 if ((pattern->flags & VAR_MATCH_START) &&
1501 (strncmp(word, pattern->lhs, pattern->leftLen) == 0)) {
1503 * Anchored at start and beginning of word matches pattern
1505 if ((pattern->flags & VAR_MATCH_END) &&
1506 (wordLen == pattern->leftLen)) {
1509 * is same length as pattern) add space and rhs only
1512 if (pattern->rightLen != 0) {
1517 Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
1519 pattern->flags |= VAR_SUB_MATCHED;
1520 } else if (pattern->flags & VAR_MATCH_END) {
1529 if ((pattern->rightLen + wordLen - pattern->leftLen) != 0){
1535 Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
1536 Buf_AddBytes(buf, wordLen - pattern->leftLen,
1537 (word + pattern->leftLen));
1538 pattern->flags |= VAR_SUB_MATCHED;
1540 } else if (pattern->flags & VAR_MATCH_START) {
1545 } else if (pattern->flags & VAR_MATCH_END) {
1552 cp = word + (wordLen - pattern->leftLen);
1554 (strncmp(cp, pattern->lhs, pattern->leftLen) == 0)) {
1561 if (((cp - word) + pattern->rightLen) != 0) {
1568 Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
1569 pattern->flags |= VAR_SUB_MATCHED;
1578 * Pattern is unanchored: search for the pattern in the word using
1594 cp = Str_FindSubstring(word, pattern->lhs);
1596 if (addSpace && (((cp - word) + pattern->rightLen) != 0)){
1601 Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
1602 wordLen -= (cp - word) + pattern->leftLen;
1603 word = cp + pattern->leftLen;
1607 if ((pattern->flags & VAR_SUB_GLOBAL) == 0) {
1610 pattern->flags |= VAR_SUB_MATCHED;
1803 * We set the temp variable named in pattern.lhs to word and expand
1804 * pattern.rhs storing the result in the passed buffer.
1811 * pattern Datafor substitution
2152 * If pattern is specified, handle escaped ampersands, and replace
2153 * unescaped ampersands with the lhs of the pattern.
2158 * If flags is specified and the last character of the pattern is a
2168 int *length, VarPattern *pattern)
2182 (cp[1] == '\\') || (cp[1] == '$') || (pattern && (cp[1] == '&'))))
2200 * Unescaped $ at end of pattern => anchor
2201 * pattern at end.
2248 else if (pattern && *cp == '&')
2249 Buf_AddBytes(&buf, pattern->leftLen, pattern->lhs);
2264 fprintf(debug_file, "Modifier pattern: \"%s\"\n", rstr);
2400 * :M<pattern> words which match the given <pattern>.
2401 * <pattern> is of the standard file
2403 * :N<pattern> words which do not match the given <pattern>.
2580 VarPattern pattern;
2616 pattern.flags = 0;
2619 pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
2621 &pattern.rightLen,
2628 if (pattern.rhs == NULL)
2637 Var_Append(v->name, pattern.rhs, v_ctxt);
2640 newStr = Cmd_Exec(pattern.rhs, &emsg);
2652 Var_Set(v->name, pattern.rhs, v_ctxt, 0);
2656 free(UNCONST(pattern.rhs));
2792 VarPattern pattern;
2793 pattern.flags = 0;
2798 if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
2800 NULL, &pattern.rightLen,
2804 newStr = Cmd_Exec(pattern.rhs, &emsg);
2807 free(UNCONST(pattern.rhs));
2995 VarPattern pattern;
3061 pattern.flags = VAR_SUB_ONE;
3062 pattern.lhs = pattern.rhs = "\032";
3063 pattern.leftLen = pattern.rightLen = 1;
3067 &pattern);
3117 char *pattern;
3118 const char *endpat; /* points just after end of pattern */
3120 Boolean copy; /* pattern should be, or has been, copied */
3161 * Need to compress the \:'s out of the pattern, so
3163 * pattern (note that cp started at tstr+1, so
3165 * compress the pattern into the space.
3167 pattern = bmake_malloc(cp - tstr);
3168 for (cp2 = pattern, cp = tstr + 1;
3185 pattern = bmake_strndup(tstr+1, endpat - (tstr + 1));
3189 * pattern contains embedded '$', so use Var_Subst to
3192 cp2 = pattern;
3193 pattern = Var_Subst(NULL, cp2, ctxt, flags | VARF_WANTRES);
3198 v->name, nstr, pattern);
3201 pattern);
3204 pattern);
3206 free(pattern);
3211 VarPattern pattern;
3214 pattern.flags = 0;
3220 * If pattern begins with '^', it is anchored to the
3221 * start of the word -- skip over it and flag pattern.
3224 pattern.flags |= VAR_MATCH_START;
3229 if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, flags,
3231 &pattern.flags,
3232 &pattern.leftLen,
3236 if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
3238 &pattern.rightLen,
3239 &pattern)) == NULL)
3250 pattern.flags |= VAR_SUB_GLOBAL;
3253 pattern.flags |= VAR_SUB_ONE;
3265 &pattern);
3270 free(UNCONST(pattern.lhs));
3271 free(UNCONST(pattern.rhs));
3277 VarPattern pattern;
3299 pattern.flags = 0;
3303 if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, flags,
3305 &pattern.leftLen,
3311 if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
3313 &pattern.rightLen,
3321 v->name, v->name, pattern.lhs, pattern.rhs);
3326 newStr = UNCONST(pattern.lhs);
3327 free(UNCONST(pattern.rhs));
3329 newStr = UNCONST(pattern.rhs);
3330 free(UNCONST(pattern.lhs));
3340 VarREPattern pattern;
3345 pattern.flags = 0;
3356 if ((pattern.replace = VarGetPattern(ctxt, &parsestate,
3366 pattern.flags |= VAR_SUB_GLOBAL;
3369 pattern.flags |= VAR_SUB_ONE;
3380 error = regcomp(&pattern.re, re, REG_EXTENDED);
3384 VarREError(error, &pattern.re, "RE substitution error");
3385 free(pattern.replace);
3389 pattern.nsub = pattern.re.re_nsub + 1;
3390 if (pattern.nsub < 1)
3391 pattern.nsub = 1;
3392 if (pattern.nsub > 10)
3393 pattern.nsub = 10;
3394 pattern.matches = bmake_malloc(pattern.nsub *
3398 &pattern);
3399 regfree(&pattern.re);
3400 free(pattern.replace);
3401 free(pattern.matches);
3501 VarPattern pattern;
3504 pattern.flags = 0;
3533 if ((pattern.lhs = VarGetPattern(ctxt, &parsestate,
3534 flags, &cp, delim, &pattern.flags,
3535 &pattern.leftLen, NULL)) == NULL)
3538 if ((pattern.rhs = VarGetPattern(ctxt, &parsestate,
3539 flags, &cp, delim, NULL, &pattern.rightLen,
3540 &pattern)) == NULL)
3545 * string. Note the pattern is anchored at the end.
3549 if (pattern.leftLen == 0 && *nstr == '\0') {
3554 &pattern);
3556 free(UNCONST(pattern.lhs));
3557 free(UNCONST(pattern.rhs));