aboutsummaryrefslogtreecommitdiff
path: root/gnu/usr.bin/diff/context.c
diff options
context:
space:
mode:
authorNate Williams <nate@FreeBSD.org>1993-11-12 07:05:54 +0000
committerNate Williams <nate@FreeBSD.org>1993-11-12 07:05:54 +0000
commitc7ed70b75dcb9d5603c7a7efacc974d0e29d9a6f (patch)
treeccdf94118f89667bc5481656e35a277126890ddc /gnu/usr.bin/diff/context.c
parent2839c0afd947ea73005c48e263152695efb2a586 (diff)
Notes
Diffstat (limited to 'gnu/usr.bin/diff/context.c')
-rw-r--r--gnu/usr.bin/diff/context.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/gnu/usr.bin/diff/context.c b/gnu/usr.bin/diff/context.c
index 9b8fc3ec171f5..5b4b73f94561f 100644
--- a/gnu/usr.bin/diff/context.c
+++ b/gnu/usr.bin/diff/context.c
@@ -1,5 +1,5 @@
/* Context-format output routines for GNU DIFF.
- Copyright (C) 1988, 89, 91, 92 Free Software Foundation, Inc.
+ Copyright (C) 1988, 89, 91, 92, 93 Free Software Foundation, Inc.
This file is part of GNU DIFF.
@@ -19,11 +19,14 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "diff.h"
-static void pr_context_hunk ();
-static void pr_unidiff_hunk ();
-static struct change *find_hunk ();
-static void mark_ignorable ();
-static void find_function ();
+static struct change *find_hunk PARAMS((struct change *));
+static void find_function PARAMS((struct file_data const *, int, char const **, size_t *));
+static void mark_ignorable PARAMS((struct change *));
+static void pr_context_hunk PARAMS((struct change *));
+static void pr_unidiff_hunk PARAMS((struct change *));
+static void print_context_label PARAMS ((char const *, struct file_data *, char const *));
+static void print_context_number_range PARAMS((struct file_data const *, int, int));
+static void print_unidiff_number_range PARAMS((struct file_data const *, int, int));
/* Last place find_function started searching from. */
static int find_function_last_search;
@@ -35,24 +38,23 @@ static int find_function_last_match;
static void
print_context_label (mark, inf, label)
- const char *mark;
+ char const *mark;
struct file_data *inf;
- const char *label;
+ char const *label;
{
if (label)
fprintf (outfile, "%s %s\n", mark, label);
- else if (inf->stat.st_mtime)
- fprintf (outfile, "%s %s\t%s", mark, inf->name, ctime(&inf->stat.st_mtime));
else
- /* Don't pretend that standard input is ancient. */
- fprintf (outfile, "%s %s\n", mark, inf->name);
+ /* See Posix.2 section 4.17.6.1.4 for this format. */
+ fprintf (outfile, "%s %s\t%s",
+ mark, inf->name, ctime (&inf->stat.st_mtime));
}
/* Print a header for a context diff, with the file names and dates. */
void
print_context_header (inf, unidiff_flag)
- struct file_data *inf;
+ struct file_data inf[];
int unidiff_flag;
{
if (unidiff_flag)
@@ -100,7 +102,7 @@ print_context_script (script, unidiff_flag)
static void
print_context_number_range (file, a, b)
- struct file_data *file;
+ struct file_data const *file;
int a, b;
{
int trans_a, trans_b;
@@ -128,9 +130,9 @@ pr_context_hunk (hunk)
{
int first0, last0, first1, last1, show_from, show_to, i;
struct change *next;
- char *prefix;
- const char *function;
- int function_length;
+ char const *prefix;
+ char const *function;
+ size_t function_length;
FILE *out;
/* Determine range of line numbers involved in each file. */
@@ -234,7 +236,7 @@ pr_context_hunk (hunk)
static void
print_unidiff_number_range (file, a, b)
- struct file_data *file;
+ struct file_data const *file;
int a, b;
{
int trans_a, trans_b;
@@ -262,8 +264,8 @@ pr_unidiff_hunk (hunk)
{
int first0, last0, first1, last1, show_from, show_to, i, j, k;
struct change *next;
- char *function;
- int function_length;
+ char const *function;
+ size_t function_length;
FILE *out;
/* Determine range of line numbers involved in each file. */
@@ -317,7 +319,7 @@ pr_unidiff_hunk (hunk)
if (!next || i < next->line0)
{
putc (tab_align_flag ? '\t' : ' ', out);
- print_1_line ((char *)0, &files[0].linbuf[i++]);
+ print_1_line (0, &files[0].linbuf[i++]);
j++;
}
else
@@ -330,7 +332,7 @@ pr_unidiff_hunk (hunk)
putc ('-', out);
if (tab_align_flag)
putc ('\t', out);
- print_1_line ((char *)0, &files[0].linbuf[i++]);
+ print_1_line (0, &files[0].linbuf[i++]);
}
/* Then output the inserted part. */
@@ -341,7 +343,7 @@ pr_unidiff_hunk (hunk)
putc ('+', out);
if (tab_align_flag)
putc ('\t', out);
- print_1_line ((char *)0, &files[1].linbuf[j++]);
+ print_1_line (0, &files[1].linbuf[j++]);
}
/* We're done with this hunk, so on to the next! */
@@ -424,10 +426,10 @@ mark_ignorable (script)
static void
find_function (file, linenum, linep, lenp)
- struct file_data *file;
+ struct file_data const *file;
int linenum;
- const char **linep;
- int *lenp;
+ char const **linep;
+ size_t *lenp;
{
int i = linenum;
int last = find_function_last_search;
@@ -437,8 +439,8 @@ find_function (file, linenum, linep, lenp)
{
/* See if this line is what we want. */
struct regexp_list *r;
- const char *line = file->linbuf[i];
- int len = file->linbuf[i + 1] - line;
+ char const *line = file->linbuf[i];
+ size_t len = file->linbuf[i + 1] - line;
for (r = function_regexp_list; r; r = r->next)
if (0 <= re_search (&r->buf, line, len, 0, len, 0))