GNU Info

Info Node: (diff.info)If-then-else

(diff.info)If-then-else


Prev: Scripts Up: Output Formats
Enter node , (file) or (file)node

Merging Files with If-then-else
===============================

   You can use `diff' to merge two files of C source code.  The output
of `diff' in this format contains all the lines of both files.  Lines
common to both files are output just once; the differing parts are
separated by the C preprocessor directives `#ifdef NAME' or `#ifndef
NAME', `#else', and `#endif'.  When compiling the output, you select
which version to use by either defining or leaving undefined the macro
NAME.

   To merge two files, use `diff' with the `-D NAME' or `--ifdef=NAME'
option.  The argument NAME is the C preprocessor identifier to use in
the `#ifdef' and `#ifndef' directives.

   For example, if you change an instance of `wait (&s)' to `waitpid
(-1, &s, 0)' and then merge the old and new files with the
`--ifdef=HAVE_WAITPID' option, then the affected part of your code
might look like this:

         do {
     #ifndef HAVE_WAITPID
             if ((w = wait (&s)) < 0  &&  errno != EINTR)
     #else /* HAVE_WAITPID */
             if ((w = waitpid (-1, &s, 0)) < 0  &&  errno != EINTR)
     #endif /* HAVE_WAITPID */
                 return w;
         } while (w != child);

   You can specify formats for languages other than C by using line
group formats and line formats, as described in the next sections.

Line Group Formats
Formats for general if-then-else line groups.
Line Formats
Formats for each line in a line group.
Detailed If-then-else
A detailed description of if-then-else format.
Example If-then-else
Sample if-then-else format output.

automatically generated by info2www version 1.2.2.9