summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/diff/side.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-03-18 09:21:42 +0000
committerpeter <peter@FreeBSD.org>1999-03-18 09:21:42 +0000
commit308b60f66831aa65a459a7b347ea6ca14b6e4799 (patch)
tree1b2cd3bad90a2dd8ccb449f73ddfb9e295c0737d /contrib/cvs/diff/side.c
parent0c111e2b51cac7eead56494b30c5977e4ec9a8ea (diff)
downloadFreeBSD-src-308b60f66831aa65a459a7b347ea6ca14b6e4799.zip
FreeBSD-src-308b60f66831aa65a459a7b347ea6ca14b6e4799.tar.gz
Import cvs-1.10 onto vendor branch. Merge to follow shortly.
Obtained from: cyclic.com
Diffstat (limited to 'contrib/cvs/diff/side.c')
-rw-r--r--contrib/cvs/diff/side.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/contrib/cvs/diff/side.c b/contrib/cvs/diff/side.c
index a150b5e..d776e77 100644
--- a/contrib/cvs/diff/side.c
+++ b/contrib/cvs/diff/side.c
@@ -1,5 +1,5 @@
/* sdiff-format output routines for GNU DIFF.
- Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1992, 1993, 1998 Free Software Foundation, Inc.
This file is part of GNU DIFF.
@@ -50,17 +50,16 @@ static unsigned
tab_from_to (from, to)
unsigned from, to;
{
- FILE *out = outfile;
unsigned tab;
if (! tab_expand_flag)
for (tab = from + TAB_WIDTH - from % TAB_WIDTH; tab <= to; tab += TAB_WIDTH)
{
- putc ('\t', out);
+ write_output ("\t", 1);
from = tab;
}
while (from++ < to)
- putc (' ', out);
+ write_output (" ", 1);
return to;
}
@@ -74,7 +73,6 @@ print_half_line (line, indent, out_bound)
char const * const *line;
unsigned indent, out_bound;
{
- FILE *out = outfile;
register unsigned in_position = 0, out_position = 0;
register char const
*text_pointer = line[0],
@@ -83,6 +81,9 @@ print_half_line (line, indent, out_bound)
while (text_pointer < text_limit)
{
register unsigned char c = *text_pointer++;
+ /* We use CC to avoid taking the address of the register
+ variable C. */
+ char cc;
switch (c)
{
@@ -97,13 +98,14 @@ print_half_line (line, indent, out_bound)
if (out_bound < tabstop)
tabstop = out_bound;
for (; out_position < tabstop; out_position++)
- putc (' ', out);
+ write_output (" ", 1);
}
else
if (tabstop < out_bound)
{
out_position = tabstop;
- putc (c, out);
+ cc = c;
+ write_output (&cc, 1);
}
}
in_position += spaces;
@@ -112,7 +114,8 @@ print_half_line (line, indent, out_bound)
case '\r':
{
- putc (c, out);
+ cc = c;
+ write_output (&cc, 1);
tab_from_to (0, indent);
in_position = out_position = 0;
}
@@ -123,11 +126,12 @@ print_half_line (line, indent, out_bound)
if (out_position <= in_position)
/* Add spaces to make up for suppressed tab past out_bound. */
for (; out_position < in_position; out_position++)
- putc (' ', out);
+ write_output (" ", 1);
else
{
out_position = in_position;
- putc (c, out);
+ cc = c;
+ write_output (&cc, 1);
}
break;
@@ -135,7 +139,10 @@ print_half_line (line, indent, out_bound)
case '\v':
control_char:
if (in_position < out_bound)
- putc (c, out);
+ {
+ cc = c;
+ write_output (&cc, 1);
+ }
break;
default:
@@ -146,7 +153,8 @@ print_half_line (line, indent, out_bound)
if (in_position++ < out_bound)
{
out_position = in_position;
- putc (c, out);
+ cc = c;
+ write_output (&cc, 1);
}
break;
@@ -170,7 +178,6 @@ print_1sdiff_line (left, sep, right)
int sep;
char const * const *right;
{
- FILE *out = outfile;
unsigned hw = sdiff_half_width, c2o = sdiff_column2_offset;
unsigned col = 0;
int put_newline = 0;
@@ -184,10 +191,13 @@ print_1sdiff_line (left, sep, right)
if (sep != ' ')
{
+ char cc;
+
col = tab_from_to (col, (hw + c2o - 1) / 2) + 1;
if (sep == '|' && put_newline != (right[1][-1] == '\n'))
sep = put_newline ? '/' : '\\';
- putc (sep, out);
+ cc = sep;
+ write_output (&cc, 1);
}
if (right)
@@ -202,7 +212,7 @@ print_1sdiff_line (left, sep, right)
}
if (put_newline)
- putc ('\n', out);
+ write_output ("\n", 1);
}
/* Print lines common to both files in side-by-side format. */
@@ -215,7 +225,7 @@ print_sdiff_common_lines (limit0, limit1)
if (! sdiff_skip_common_lines && (i0 != limit0 || i1 != limit1))
{
if (sdiff_help_sdiff)
- fprintf (outfile, "i%d,%d\n", limit0 - i0, limit1 - i1);
+ printf_output ("i%d,%d\n", limit0 - i0, limit1 - i1);
if (! sdiff_left_only)
{
@@ -252,7 +262,7 @@ print_sdiff_hunk (hunk)
print_sdiff_common_lines (first0, first1);
if (sdiff_help_sdiff)
- fprintf (outfile, "c%d,%d\n", last0 - first0 + 1, last1 - first1 + 1);
+ printf_output ("c%d,%d\n", last0 - first0 + 1, last1 - first1 + 1);
/* Print ``xxx | xxx '' lines */
if (inserts && deletes)
OpenPOWER on IntegriCloud