When any file is read, it will be piped through this external command. If
a preprocessor-command (see above) is also specified, then the output of the
preprocessor is the input of the line-matching preprocessor.
The output will only be used during the line matching phase of the analysis.
You can write your own preprocessor that fulfills your specific needs.
Each input line must have a corresponding output line.
</p></dd></dl></div>
</p><p>
The idea is to allow the user greater flexibility while configuring the diff-result.
But this requires an external program, and many users don't want to write one themselves.
The good news is that very often <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span> or <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">perl</strong></span></span>
This section only introduces some very basic features of <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span>. For more
information see <ahref="info:/sed"target="_top">info:/sed</a> or
A precompiled version for Windows can be found at <ahref="http://unxutils.sourceforge.net"target="_top">
http://unxutils.sourceforge.net</a>.
Note that the following examples assume that the <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span>-command is in some
directory in the PATH-environment variable. If this is not the case, you have to specify the full absolute
path for the command.
</p><divclass="note"style="margin-left: 0.5in; margin-right: 0.5in;"><h3class="title">Note</h3><p>Also note that the following examples use the single quotation mark (') which won't work for Windows.
On Windows you should use the double quotation marks (") instead.</p></div><p>
In this context only the <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span>-substitute-command is used:
Before you use a new command within <spanclass="application">KDiff3</span>, you should first test it in a console.
Here the <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">echo</strong></span></span>-command is useful. Example:
The "|"-symbol is the pipe-command that transfers the output of the previous
command to the input of the following command. If you want to test with a longer file
then you can use <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">cat</strong></span></span> on Unix-like systems or <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">type</strong></span></span>
on Windows-like systems. <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span> will do the substitution for each line.
</p></div><divclass="sect2"lang="en"><divclass="titlepage"><div><div><h3class="title"><aname="sedforkdiff3"></a>Examples For <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span>-Use In <spanclass="application">KDiff3</span></h3></div></div></div><divclass="sect3"lang="en"><divclass="titlepage"><div><div><h4class="title"><aname="id2567628"></a>Ignoring Other Types Of Comments</h4></div></div></div><p>
Currently <spanclass="application">KDiff3</span> understands only C/C++ comments. Using the
Line-Matching-Preprocessor-Command you can also ignore
other types of comments, by converting them into C/C++-comments.
Example: To ignore comments starting with "#", you would like to convert them
to "//". Note that you also must enable the "Ignore C/C++-Comments" option to get
an effect. An appropriate Line-Matching-Preprocessor-Command would be:
Since for <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span> the "/"-character has a special meaning, it is necessary to place the
"\"-character before each "/" in the replacement-string. Sometimes the "\" is required
to add or remove a special meaning of certain characters. The single quotation marks (') before
and after the substitution-command are important now, because otherwise the shell will
try to interpret some special characters like '#', '$' or '\' before passing them to
<spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span>. <spanclass="emphasis"><em>Note that on Windows you will need the double quotation marks (") here. Windows
substitutes other characters like '%', so you might have to experiment a little bit.</em></span>
Here the ".*" is a regular expression that matches any string and in this context matches
all characters in the line.
The "\1" in the replacement string refers to the matched text within the first pair of "\(" and "\)".
The "\U" converts the inserted text to uppercase.
</p></div><divclass="sect3"lang="en"><divclass="titlepage"><div><div><h4class="title"><aname="id2567704"></a>Ignoring Version Control Keywords</h4></div></div></div><p>
CVS and other version control systems use several keywords to insert automatically
The "\|" separates the possible keywords. You might want to modify this list
according to your needs.
The "\" before the "$" is necessary because otherwise the "$" matches the end of the line.
</p><p>
While experimenting with <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span> you might come to understand and even like
these regular expressions. They are useful because there are many other programs that also
Any character within '[' and ']' is a match and will be replaced with nothing.
</p></div><divclass="sect3"lang="en"><divclass="titlepage"><div><div><h4class="title"><aname="id2567772"></a>Ignoring Certain Columns</h4></div></div></div><p>
Sometimes a text is very strictly formatted, and contains columns that you always want to ignore, while there are
other columns you want to preserve for analysis. In the following example the first five columns (characters) are
ignored, the next ten columns are preserved, then again five columns are ignored and the rest of the line is preserved.
Each dot '.' matches any single character. The "\1" and "\2" in the replacement string refer to the matched text within the first
and second pair of "\(" and "\)" denoting the text to be preserved.
</p></div><divclass="sect3"lang="en"><divclass="titlepage"><div><div><h4class="title"><aname="id2567800"></a>Combining Several Substitutions</h4></div></div></div><p>
Sometimes you want to apply several substitutions at once. You can then use the
semicolon ';' to separate these from each other. Example:
</p></div><divclass="sect3"lang="en"><divclass="titlepage"><div><div><h4class="title"><aname="id2567827"></a>Using <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">perl</strong></span></span> instead of <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span></h4></div></div></div><p>
Instead of <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span> you might want to use something else like
But some details are different in <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">perl</strong></span></span>. Note that where
<spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">sed</strong></span></span> needed "\(" and "\)" <spanxmlns:doc="http://nwalsh.com/xsl/documentation/1.0"class="command"><span><strongclass="command">perl</strong></span></span>
requires the simpler "(" and ")" without preceding '\'. Example:
</p></div></div><divclass="sect2"lang="en"><divclass="titlepage"><div><div><h3class="title"><aname="id2567900"></a>Order Of Preprocessor Execution</h3></div></div></div><p>
The data is piped through all internal and external preprocessors in the
following order:
</p><divclass="itemizedlist"><ultype="disc"><li><p>Normal preprocessor,</p></li><li><p>Line-Matching-Preprocessor,</p></li><li><p>Ignore case (conversion to uppercase),</p></li><li><p>Detection of C/C++ comments,</p></li><li><p>Ignore numbers,</p></li><li><p>Ignore white space</p></li></ul></div><p>
The data after the normal preprocessor will be preserved for display and merging. The
other operations only modify the data that the line-matching-diff-algorithm sees.
</p><p>
In the rare cases where you use a normal preprocessor note that
the line-matching-preprocessor sees the output of the normal preprocessor as input.
The preprocessor-commands are often very useful, but as with any option that modifies
your texts or hides away certain differences automatically, you might accidentally overlook
certain differences and in the worst case destroy important data.
</p><p>
For this reason during a merge if a normal preprocessor-command is being used <spanclass="application">KDiff3</span>
will tell you so and ask you if it should be disabled or not.
But it won't warn you if a Line-Matching-Preprocessor-command is active. The merge will not complete until
all conflicts are solved. If you disabled "Show White Space" then the differences that
were removed with the Line-Matching-Preprocessor-command will also be invisible. If the
Save-button remains disabled during a merge (because of remaining conflicts), make sure to enable
"Show White Space". If you don't wan't to merge these less important differences manually
you can select "Choose [A|B|C] For All Unsolved White space Conflicts" in the Merge-menu.
</p></div></div><divstyle="background-color: #white; color: black; margin-top: 20px; margin-left: 20px; margin-right: 20px;"><divstyle="position: absolute; left: 20px;"><aaccesskey="p"href="options.html">Prev</a></div><divstyle="position: absolute; right: 20px;"><aaccesskey="n"href="dirmerge.html">Next</a></div><divalign="center"><aaccesskey="h"href="index.html">Home</a></div></div><divstyle="background-color: #white; color: black; margin-left: 20px; margin-right: 20px;"><divclass="navLeft">Options</div><divclass="navRight">Directory Comparison and Merge with <spanclass="application">KDiff3</span></div><divclass="navCenter"><aaccesskey="u"href="documentation.html">Up</a></div></div><br><br><divclass="bannerBottom"style="background-image: url(help:/common/bottom-middle.png); background-repeat: x-repeat; width: 100%; height: 100px; bottom:0px;"><divclass="BannerBottomRight"><imgsrc="help:/common/bottom-right.png"style="margin: 0px"alt=""></div><divclass="bannerBottomLeft"><imgsrc="help:/common/bottom-left.png"style="margin: 0px;"alt=""></div><divid="comments"style="position:relative; top: 5px; left: 1em; height:85px; width: 50%; color: #cfe1f6"><p>Would you like to make a comment or contribute an update to this page?<br>
Send feedback to the <ahref="mailto:kde-docs@kdemail.net"style="background:transparent; color:#cfe1f6; text-decoration: underline;">KDE Docs Team</a></p></div></div></body></html>