/[grep]/grep/src/grep.c
ViewVC logotype

Diff of /grep/src/grep.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.103 by charles_levert, Tue Jun 21 05:18:44 2005 UTC revision 1.104 by charles_levert, Tue Jun 21 06:19:44 2005 UTC
# Line 618  print_offset_sep (uintmax_t pos, char se Line 618  print_offset_sep (uintmax_t pos, char se
618    fwrite (p, 1, buf + sizeof buf - p, stdout);    fwrite (p, 1, buf + sizeof buf - p, stdout);
619  }  }
620    
621    /* Print a whole line head (filename, line, byte).  */
622  static void  static void
623  prline (char const *beg, char const *lim, int sep)  print_line_head (char const *beg, char const *lim, int sep)
624  {  {
625    if (out_file)    if (out_file)
626      printf ("%s%c", filename, sep & filename_mask);      printf ("%s%c", filename, sep & filename_mask);
627    if (out_line)    if (out_line)
628      {      {
629        nlscan (beg);        if (lastnl < lim)
630        totalnl = add_count (totalnl, 1);          {
631              nlscan (beg);
632              totalnl = add_count (totalnl, 1);
633              lastnl = lim;
634            }
635        print_offset_sep (totalnl, sep);        print_offset_sep (totalnl, sep);
       lastnl = lim;  
636      }      }
637    if (out_byte)    if (out_byte)
638      {      {
# Line 638  prline (char const *beg, char const *lim Line 642  prline (char const *beg, char const *lim
642  #endif  #endif
643        print_offset_sep (pos, sep);        print_offset_sep (pos, sep);
644      }      }
645    if (only_matching)  }
646    
647    static void
648    prline (char const *beg, char const *lim, int sep)
649    {
650      if (!only_matching)
651        print_line_head(beg, lim, sep);
652      else
653      {      {
654        size_t match_size;        size_t match_size;
655        size_t match_offset;        size_t match_offset;
# Line 659  prline (char const *beg, char const *lim Line 670  prline (char const *beg, char const *lim
670                  break;                  break;
671                if (match_size == 0)                if (match_size == 0)
672                  break;                  break;
673                  print_line_head(b, lim, sep);
674                PR_SGR_START_IF(grep_color);                PR_SGR_START_IF(grep_color);
675                fwrite(b, sizeof (char), match_size, stdout);                fwrite(b, sizeof (char), match_size, stdout);
676                PR_SGR_END_IF(grep_color);                PR_SGR_END_IF(grep_color);
# Line 680  prline (char const *beg, char const *lim Line 692  prline (char const *beg, char const *lim
692              break;              break;
693            if (match_size == 0)            if (match_size == 0)
694              break;              break;
695              print_line_head(b, lim, sep);
696            PR_SGR_START_IF(grep_color);            PR_SGR_START_IF(grep_color);
697            fwrite(b, sizeof (char), match_size, stdout);            fwrite(b, sizeof (char), match_size, stdout);
698            PR_SGR_END_IF(grep_color);            PR_SGR_END_IF(grep_color);

Legend:
Removed from v.1.103  
changed lines
  Added in v.1.104

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26