- publishing free software manuals
Comparing and Merging Files with GNU diff and patch
by David MacKenzie, Paul Eggert, and Richard Stallman
Paperback (6"x9"), 120 pages
ISBN 0954161750
RRP £12.95 ($19.95)

"Well packaged... the quality of information is excellent" --- Linux User and Developer Magazine (Issue 36, Feb 2004) Get a printed copy>>>

3 Incomplete Lines

When an input file ends in a non-newline character, its last line is called an incomplete line because its last character is not a newline. All other lines are called full lines and end in a newline character. Incomplete lines do not match full lines unless differences in white space are ignored (see section 1.2 Suppressing Differences in Blank and Tab Spacing).

An incomplete line is normally distinguished on output from a full line by a following line that starts with ‘\’. However, the RCS format (see section 2.5.3 RCS Scripts) outputs the incomplete line as-is, without any trailing newline or following line. The side by side format normally represents incomplete lines as-is, but in some cases uses a ‘\’ or ‘/’ gutter marker; See section 2.4 Showing Differences Side by Side. The if-then-else line format preserves a line's incompleteness with ‘%L’, and discards the newline with ‘%l’; See section 2.6.2 Line Formats. Finally, with the ed and forward ed output formats (see section 2 diff Output Formats) diff cannot represent an incomplete line, so it pretends there was a newline and reports an error.

For example, suppose ‘F’ and ‘G’ are one-byte files that contain just ‘f’ and ‘g’, respectively. Then ‘diff F G’ outputs

< f
\ No newline at end of file
> g
\ No newline at end of file

(The exact message may differ in non-English locales.) ‘diff -n F G’ outputs the following without a trailing newline:

d1 1
a1 1

‘diff -e F G’ reports two errors and outputs the following:

ISBN 0954161750Comparing and Merging Files with GNU diff and patchSee the print edition