Lines Matching refs:rule
68 struct subst_rule *rule;
79 rule = malloc(sizeof(*rule));
80 if (rule == NULL)
82 rule->next = NULL;
85 subst->first_rule = rule;
87 subst->last_rule->next = rule;
88 subst->last_rule = rule;
102 if ((r = regcomp(&rule->re, pattern, REG_BASIC)) != 0) {
104 regerror(r, &rule->re, buf, sizeof(buf));
114 rule->result = malloc(end_pattern - start_subst + 1);
115 if (rule->result == NULL)
117 memcpy(rule->result, start_subst, end_pattern - start_subst);
118 rule->result[end_pattern - start_subst] = '\0';
120 rule->global = 0;
121 rule->print = 0;
122 rule->symlink = 0;
128 rule->global = 1;
132 rule->print = 1;
136 rule->symlink = 1;
191 struct subst_rule *rule;
203 for (rule = subst->first_rule; rule != NULL; rule = rule->next) {
204 if (symlink_only && !rule->symlink)
206 if (regexec(&rule->re, name, 10, matches, 0))
210 print_match |= rule->print;
213 for (i = 0, j = 0; rule->result[i] != '\0'; ++i) {
214 if (rule->result[i] == '~') {
215 realloc_strncat(result, rule->result + j, i - j);
220 if (rule->result[i] != '\\')
224 c = rule->result[i];
228 realloc_strncat(result, rule->result + j, i - j - 1);
240 realloc_strncat(result, rule->result + j, i - j - 1);
241 if ((size_t)(c - '0') > (size_t)(rule->re.re_nsub)) {
256 realloc_strcat(result, rule->result + j);
260 if (!rule->global)
276 struct subst_rule *rule;
282 while ((rule = subst->first_rule) != NULL) {
283 subst->first_rule = rule->next;
284 free(rule->result);
285 free(rule);