[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.6.3 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; See section Options to patch
.