1

I'm created a SVN patch to port from a Linux server to AIX server.

The SVN generated patch is as below:

Index: cas/cm/cmsee.c
===================================================================
--- cas/cm/cmsee.c      (revision 19)
+++ cas/cm/cmsee.c      (working copy)
@@ -769,14 +769,23 @@

 CE_CEXPFCT CE_VOID cm_seet(CE_VOID)
 {
+#ifndef TRACE
+   TT_OWNTYPE  *phh;
+   TT_OWNTYPE  *phhe;
+#elif FINAL_CHECKS
    TT_OWNTYPE  *phh;
    TT_OWNTYPE  *phhe;
+#endif

    TRACE(I,"cm_seet");

+#ifndef TRACE
    phh  = cm_fp->fp_hh_ptr;
    phhe = phh + cm_fp->cp_hh_cnt;
-
+#elif FINAL_CHECKS
+   phh  = bm_fp->fp_hh_ptr;
+   phhe = pht + bm_fp->fp_hh_cnt; 
+#endif
    TRACE(I, fstr("init: phh %x phhe %x\n", phh, phhe););

 #ifdef FINAL_CHECKS

When I run the command

patch -p0 -i Modified.patch 

I get the follow error:

Hmm...  Looks like a unified context diff to me...
The text leading up to this was:
--------------------------
|Index: cas/cm/cmsee.c
|===================================================================
|--- cas/cm/cmsee.c     (revision 19)
|+++ cas/cm/cmsee.c     (working copy)
--------------------------
Patching file cas/cm/cmsee.c using Plan A...
Malformed patch at line 7:  CE_CEXPFCT CE_VOID cm_seet(CE_VOID)

I tried Google and checked on StackExchange, but no solutions which could solve my problem. Can anyone help me here?

3
  • Which version of AIX? It seems the versions of patch provided in 5.3 and below do not support unified diffs, but later versions should. If you have an earlier version, you could build another patch, such as GNU's, or generate non-unified diffs Commented Mar 6, 2018 at 9:42
  • Does it help if you explicitly tell patch that it's a unified diff, with the -u flag? Commented Mar 7, 2018 at 15:10
  • It's been a while, but the combination of -p0 and the two-level directory structure confuses me; are you in the cas/cm/ directory? Or should you use -p2? Commented Mar 7, 2018 at 15:12

1 Answer 1

3

The issue you are encountering is a bug in the AIX implementation of patch. Specifically, at least some versions of the AIX implementation of patch expect unified context diff files to be in the erroneous form produced by (at least some versions of) the AIX diff utility. Said erroneous form does not conform to POSIX and contains a space in the second column of each line of context and of each added or deleted line.

To use a unified context diff (in the form described by POSIX) with affected versions of the AIX patch utility, a space needs to be inserted into the second column of each of the lines that represent context, additions, or deletions.

For the Modified.patch file that you described, an adjusted patch file can be produced using:

( head -n 4 Modified.patch; tail -n +5 Modified.patch |
  sed 's/^$/ /; s/^\([ +-]\)/\1 /;' ) > Adjusted.patch

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.