Using 'diff' and 'patch' with QNX 6.3

Hello,

I tried to use the GNU diff utilities ‘diff’ and ‘patch’ to update my
project files and keep track of some changes. But, while doing so I run
into some difficulties. The situation is as follows.

I’ve got two directories ‘old’ and ‘new’ with a C+±file called
‘main.cpp’. They only differ in one line. By applying the command

diff --unified=3 --text --recursive old new > patchfile

the patchfile looks like this:

=== patchfile ===

— old/main.cpp 2006-08-23 09:55:24.000000000 +0200
+++ new/main.cpp 2006-08-23 09:55:24.000000000 +0200
@@ -6,6 +6,6 @@

int main( void )
{

  • cout << “Hello old world!” << endl;
  • cout << “Hello new world!” << endl;
    return( EXIT_SUCCESS );
    }

=== end =========

After patching the old file with

cd old

patch --verbose --backup --unified --strip=1 < …/patchfile

the old file should be updated with the new line. This procedure works
perfect with LINUX (Fedora distribution) but under QNX 6.3 it fails. Is
there any specific parameter for the two programs I have to use or does
anybody spot another error?

Thanks in advance, Thomas


Thomas Reisinger Tel: 0531/391-3826
Dipl.-Ing. (FH) Fax: 0531/391-5194
Institut fuer Regelungstechnik mailto:T.Reisinger@TU-Bs.de
TU Braunschweig http://www.ifr.ing.tu-bs.de

On 2006-08-31, Thomas Reisinger <t.reisinger@tu-bs.de> wrote:

Hello,

I tried to use the GNU diff utilities ‘diff’ and ‘patch’ to update my
project files and keep track of some changes. But, while doing so I run
into some difficulties. The situation is as follows.

I’ve got two directories ‘old’ and ‘new’ with a C+±file called
‘main.cpp’. They only differ in one line. By applying the command

diff --unified=3 --text --recursive old new > patchfile

the patchfile looks like this:

=== patchfile ===

— old/main.cpp 2006-08-23 09:55:24.000000000 +0200
+++ new/main.cpp 2006-08-23 09:55:24.000000000 +0200
@@ -6,6 +6,6 @@

int main( void )
{

  • cout << “Hello old world!” << endl;
  • cout << “Hello new world!” << endl;
    return( EXIT_SUCCESS );
    }

=== end =========

After patching the old file with

cd old

patch --verbose --backup --unified --strip=1 < …/patchfile

the old file should be updated with the new line. This procedure works
perfect with LINUX (Fedora distribution) but under QNX 6.3 it fails. Is
there any specific parameter for the two programs I have to use or does
anybody spot another error?

I have the same problem … I tought I did something wrong but I
did exactly the same procedure on OpenBSD for test… and it’s
work… I’d really like to be able to use diff/patch tools in QNX…


Martin

On 2006-08-31, Thomas Reisinger <t.reisinger@tu-bs.de> wrote:

Hello,

I tried to use the GNU diff utilities ‘diff’ and ‘patch’ to update my
project files and keep track of some changes. But, while doing so I run
into some difficulties. The situation is as follows.

I’ve got two directories ‘old’ and ‘new’ with a C+±file called
‘main.cpp’. They only differ in one line. By applying the command

diff --unified=3 --text --recursive old new > patchfile

the patchfile looks like this:

=== patchfile ===

— old/main.cpp 2006-08-23 09:55:24.000000000 +0200
+++ new/main.cpp 2006-08-23 09:55:24.000000000 +0200
@@ -6,6 +6,6 @@

int main( void )
{

  • cout << “Hello old world!” << endl;
  • cout << “Hello new world!” << endl;
    return( EXIT_SUCCESS );
    }

=== end =========

After patching the old file with

cd old

patch --verbose --backup --unified --strip=1 < …/patchfile

the old file should be updated with the new line. This procedure works
perfect with LINUX (Fedora distribution) but under QNX 6.3 it fails. Is
there any specific parameter for the two programs I have to use or does
anybody spot another error?

Hi, I’ve found a solution to that problem… It’s seems that the version
of gnu-patch that come with QNX is buggy… I’ve download the sources
from the GNU website and compile it myself… and it’s work …

You can get the source from there:
ftp://ftp.cs.ubc.ca/pub/gnu/patch/patch-2.5.4.tar.gz

carefull… during configure… there’s an error telling you it cannot
detect the host… you just have to do the configure that way:

./configure --host=QNX

after that… you do the usual:
make
make install // (you must be root)

by default… it’s install it on /usr/local, so it’s don’t replace the
original one… you can rename the original one in /usr/bin (if you want
to keep a backup of it) and do a symlink from /usr/local/bin/patch to
/usr/bin/patch, or simply put /usr/local/bin before /usr/bin in your
PATH environement variable…

\

Martin