diffutils: Detailed If-then-else
2.6.4 Detailed Description of If-then-else Format
-------------------------------------------------
For lines common to both files, 'diff' uses the unchanged line group
format. For each hunk of differences in the merged output format, if
the hunk contains only lines from the first file, 'diff' uses the old
line group format; if the hunk contains only lines from the second file,
'diff' uses the new group format; otherwise, 'diff' uses the changed
group format.
The old, new, and unchanged line formats specify the output format of
lines from the first file, lines from the second file, and lines common
to both files, respectively.
The option '--ifdef=NAME' is equivalent to the following sequence of
options using shell syntax:
--old-group-format='#ifndef NAME
%<#endif /* ! NAME */
' \
--new-group-format='#ifdef NAME
%>#endif /* NAME */
' \
--unchanged-group-format='%=' \
--changed-group-format='#ifndef NAME
%<#else /* NAME */
%>#endif /* NAME */
'
You should carefully check the 'diff' output for proper nesting. For
example, when using the '-D NAME' or '--ifdef=NAME' option, you should
check that if the differing lines contain any of the C preprocessor
directives '#ifdef', '#ifndef', '#else', '#elif', or '#endif', they are
nested properly and match. If they don't, you must make corrections
manually. It is a good idea to carefully check the resulting code
anyway to make sure that it really does what you want it to; depending
on how the input files were produced, the output might contain duplicate
or otherwise incorrect code.
The 'patch' '-D NAME' option behaves like the 'diff' '-D NAME'
option, except it operates on a file and a diff to produce a merged
file. ⇒patch Options.