Index: diff/context.c =================================================================== RCS file: /cvs/ccvs/diff/context.c,v retrieving revision 1.3 diff -u -r1.3 context.c --- diff/context.c 12 Jan 1999 20:36:09 -0000 1.3 +++ diff/context.c 9 Jul 2003 02:39:13 -0000 @@ -193,7 +193,7 @@ Otherwise it is "deleted". */ prefix = (next->inserted > 0 ? "!" : "-"); - print_1_line (prefix, &files[0].linbuf[i]); + print_1_line (prefix, &files[0], i); } } @@ -222,7 +222,7 @@ Otherwise it is "inserted". */ prefix = (next->deleted > 0 ? "!" : "+"); - print_1_line (prefix, &files[1].linbuf[i]); + print_1_line (prefix, &files[1], i); } } } @@ -317,7 +317,7 @@ if (!next || i < next->line0) { write_output (tab_align_flag ? "\t" : " ", 1); - print_1_line (0, &files[0].linbuf[i++]); + print_1_line (0, &files[0], i++); j++; } else @@ -330,7 +330,7 @@ write_output ("-", 1); if (tab_align_flag) write_output ("\t", 1); - print_1_line (0, &files[0].linbuf[i++]); + print_1_line (0, &files[0], i++); } /* Then output the inserted part. */ @@ -341,7 +341,7 @@ write_output ("+", 1); if (tab_align_flag) write_output ("\t", 1); - print_1_line (0, &files[1].linbuf[j++]); + print_1_line (0, &files[1], j++); } /* We're done with this hunk, so on to the next! */ Index: diff/diff.h =================================================================== RCS file: /cvs/ccvs/diff/diff.h,v retrieving revision 1.4 diff -u -r1.4 diff.h --- diff/diff.h 12 Jan 1999 20:36:09 -0000 1.4 +++ diff/diff.h 9 Jul 2003 02:39:13 -0000 @@ -343,7 +343,7 @@ void output_1_line PARAMS((char const *, char const *, char const *, char const *)); void perror_with_name PARAMS((char const *)); void pfatal_with_name PARAMS((char const *)); -void print_1_line PARAMS((char const *, char const * const *)); +void print_1_line PARAMS((char const *, struct file_data *, int)); void print_message_queue PARAMS((void)); void print_number_range PARAMS((int, struct file_data *, int, int)); void print_script PARAMS((struct change *, struct change * (*) PARAMS((struct change *)), void (*) PARAMS((struct change *)))); Index: diff/ed.c =================================================================== RCS file: /cvs/ccvs/diff/ed.c,v retrieving revision 1.3 diff -u -r1.3 ed.c --- diff/ed.c 12 Jan 1999 20:36:09 -0000 1.3 +++ diff/ed.c 9 Jul 2003 02:39:13 -0000 @@ -87,7 +87,7 @@ } else /* Line is not `.', so output it unmodified. */ - print_1_line ("", &files[1].linbuf[i]); + print_1_line ("", &files[1], i); } /* End insert mode, if we are still in it. */ @@ -135,7 +135,7 @@ and the lines from file 2. */ for (i = f1; i <= l1; i++) - print_1_line ("", &files[1].linbuf[i]); + print_1_line ("", &files[1], i); printf_output (".\n"); } @@ -193,6 +193,6 @@ /* Print the inserted lines. */ for (i = f1; i <= l1; i++) - print_1_line ("", &files[1].linbuf[i]); + print_1_line ("", &files[1], i); } } Index: diff/normal.c =================================================================== RCS file: /cvs/ccvs/diff/normal.c,v retrieving revision 1.3 diff -u -r1.3 normal.c --- diff/normal.c 12 Jan 1999 20:36:09 -0000 1.3 +++ diff/normal.c 9 Jul 2003 02:39:13 -0000 @@ -57,7 +57,7 @@ /* Print the lines that the first file has. */ if (deletes) for (i = first0; i <= last0; i++) - print_1_line ("<", &files[0].linbuf[i]); + print_1_line ("<", &files[0], i); if (inserts && deletes) printf_output ("---\n"); @@ -65,5 +65,5 @@ /* Print the lines that the second file has. */ if (inserts) for (i = first1; i <= last1; i++) - print_1_line (">", &files[1].linbuf[i]); + print_1_line (">", &files[1], i); } Index: diff/util.c =================================================================== RCS file: /cvs/ccvs/diff/util.c,v retrieving revision 1.13 diff -u -r1.13 util.c --- diff/util.c 2 Feb 2003 19:52:38 -0000 1.13 +++ diff/util.c 9 Jul 2003 02:39:13 -0000 @@ -589,10 +589,12 @@ the line is inserted, deleted, changed, etc.). */ void -print_1_line (line_flag, line) +print_1_line (line_flag, file, line_num) char const *line_flag; - char const * const *line; + struct file_data *file; + int line_num; { + char const * const *line = &file->linbuf[line_num]; char const *text = line[0], *limit = line[1]; /* Help the compiler. */ char const *flag_format = 0; @@ -608,8 +610,14 @@ output_1_line (text, limit, flag_format, line_flag); - if ((!line_flag || line_flag[0]) && limit[-1] != '\n') - printf_output ("\n\\ No newline at end of file\n"); + if (!line_flag || line_flag[0]) + { + if (limit[-1] != '\n') + printf_output ("\n\\ No newline at end of file\n"); + else if (file->missing_newline && + limit == file->buffer + file->buffered_chars) + printf_output ("\\ No newline at end of file\n"); + } } /* Output a line from TEXT up to LIMIT. Without -t, output verbatim.