diff options
author | peter <peter@FreeBSD.org> | 1995-10-28 18:51:33 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1995-10-28 18:51:33 +0000 |
commit | 27378b5694b4941bb63a62097f7ee523da0a35bb (patch) | |
tree | 9372a0168d8ef1138d4ec4ef2051198caed461de /gnu/usr.bin/diff/context.c | |
parent | 31fbfe9bebb8e48eaf39efc88875c743cf238ced (diff) | |
download | FreeBSD-src-27378b5694b4941bb63a62097f7ee523da0a35bb.zip FreeBSD-src-27378b5694b4941bb63a62097f7ee523da0a35bb.tar.gz |
Import GNU diffutils 2.7
Note, this is going to be messy.. 2.3 was vendor-branch imported, while
2.6 was done as a delta. Sigh. I'm importing this on a vendor branch so
that it will be easier to deal with next time..
(cvs-1.6 wants rcs-5.7, and rcs-5.7 suggests diffutils-2.7)
Diffstat (limited to 'gnu/usr.bin/diff/context.c')
-rw-r--r-- | gnu/usr.bin/diff/context.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/gnu/usr.bin/diff/context.c b/gnu/usr.bin/diff/context.c index 9b8fc3e..14f950c 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,1989,1991,1992,1993,1994 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,27 @@ 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); + { + char const *ct = ctime (&inf->stat.st_mtime); + if (!ct) + ct = "?\n"; + /* See Posix.2 section 4.17.6.1.4 for this format. */ + fprintf (outfile, "%s %s\t%s", mark, inf->name, ct); + } } /* 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 +106,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 +134,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 +240,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 +268,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 +323,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 +336,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 +347,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 +430,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 +443,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)) |