Lines Matching +defs:match +defs:line

82 static void printline_metadata(struct str *line, int sep);
210 /* Print the matching line, but only if not quiet/binary */
241 * line being rotated out, then go ahead and increment
242 * last_outed to signify a gap between context/match.
258 * line-by-line basis, setting up a `struct str` as needed.
264 /* Count the matches if we have a match limit */
278 * Opens a file and processes it. Each file is processed line-by-line
335 * not going to be doing per-line statistics because of the
338 /* Reset per-line statistics */
365 /* Halt processing if we hit our match limit */
440 /* We only needed to know if we match or not */
455 * Processes a line comparing it with the specified patterns. Each pattern
457 * match, which is necessary to colorize the output and to count the
477 * Emtpy patterns trivially match every line except in the -w and -x
478 * cases. For -w (whole-word) cases, we only match if the first
479 * character isn't a word-character. For -x (whole-line) cases, we only
480 * match if the line is empty.
494 * If we don't have any other patterns, we really don't match.
508 /* Loop to process the whole line */
534 /* Check for full match */
538 /* Check for whole word match */
561 * the earliest match. This allows the pattern
562 * to match later on in the line and possibly
563 * still match a whole word.
579 * Replace previous match if the new one is earlier
608 * Advance to just past the start of the earliest match, try
609 * again just in case we still have a chance to match later in
630 /* Zero-length match -- advance one more so we don't get stuck */
695 * Print an entire line as-is, there are no inline matches to consider. This is
698 void grep_printline(struct str *line, int sep) {
699 printline_metadata(line, sep);
700 fwrite(line->dat, line->len, 1, stdout);
705 printline_metadata(struct str *line, int sep)
712 fputs(line->file, stdout);
715 printf("%s", line->file);
722 printf("%d", line->line_no);
728 printf("%lld", (long long)(line->off + line->boff));
736 * Prints a matching line according to the command line options.
743 regmatch_t match;
753 /* Only print metadata once per line if --color */
757 match = pc->matches[i];
759 if (match.rm_so == match.rm_eo)
762 * Metadata is printed on a per-line basis, so every
763 * match gets file metadata with the -o flag.
766 pc->ln.boff = match.rm_so;
769 fwrite(pc->ln.dat + a, match.rm_so - a, 1,
773 fwrite(pc->ln.dat + match.rm_so,
774 match.rm_eo - match.rm_so, 1, stdout);
777 a = match.rm_eo;