[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes to grep/src/grep.c
From: |
Charles Levert |
Subject: |
Changes to grep/src/grep.c |
Date: |
Tue, 21 Jun 2005 02:19:44 -0400 |
Index: grep/src/grep.c
diff -u grep/src/grep.c:1.103 grep/src/grep.c:1.104
--- grep/src/grep.c:1.103 Tue Jun 21 05:18:44 2005
+++ grep/src/grep.c Tue Jun 21 06:19:44 2005
@@ -618,17 +618,21 @@
fwrite (p, 1, buf + sizeof buf - p, stdout);
}
+/* Print a whole line head (filename, line, byte). */
static void
-prline (char const *beg, char const *lim, int sep)
+print_line_head (char const *beg, char const *lim, int sep)
{
if (out_file)
printf ("%s%c", filename, sep & filename_mask);
if (out_line)
{
- nlscan (beg);
- totalnl = add_count (totalnl, 1);
+ if (lastnl < lim)
+ {
+ nlscan (beg);
+ totalnl = add_count (totalnl, 1);
+ lastnl = lim;
+ }
print_offset_sep (totalnl, sep);
- lastnl = lim;
}
if (out_byte)
{
@@ -638,7 +642,14 @@
#endif
print_offset_sep (pos, sep);
}
- if (only_matching)
+}
+
+static void
+prline (char const *beg, char const *lim, int sep)
+{
+ if (!only_matching)
+ print_line_head(beg, lim, sep);
+ else
{
size_t match_size;
size_t match_offset;
@@ -659,6 +670,7 @@
break;
if (match_size == 0)
break;
+ print_line_head(b, lim, sep);
PR_SGR_START_IF(grep_color);
fwrite(b, sizeof (char), match_size, stdout);
PR_SGR_END_IF(grep_color);
@@ -680,6 +692,7 @@
break;
if (match_size == 0)
break;
+ print_line_head(b, lim, sep);
PR_SGR_START_IF(grep_color);
fwrite(b, sizeof (char), match_size, stdout);
PR_SGR_END_IF(grep_color);
- Changes to grep/src/grep.c, Charles Levert, 2005/06/14
- Changes to grep/src/grep.c, Charles Levert, 2005/06/20
- Changes to grep/src/grep.c, Charles Levert, 2005/06/20
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21
- Changes to grep/src/grep.c,
Charles Levert <=
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21
- Changes to grep/src/grep.c, Charles Levert, 2005/06/21