#diff -u file_old file_new > file.patch
parameter of diff
[root@ecken02 temp]# ls
pnscan-1.8.tar.gz
[root@ecken02 temp]# tar zxvf pnscan-1.8.tar.gz
[root@ecken02 temp]# mv pnscan-1.8 pnscan-1.8.old
[root@ecken02 temp]# tar zxvf pnscan-1.8.tar.gz
[root@ecken02 temp]# ls
pnscan-1.8 pnscan-1.8.old pnscan-1.8.tar.gz
[root@ecken02 temp]# diff -Nur pnscan-1.8.old pnscan-1.8 > file.patch
[root@ecken02 temp]# cat file.patch
diff -Nur pnscan-1.8.old/bm.c pnscan-1.8/bm.c
--- pnscan-1.8.old/bm.c 2002-03-22 18:02:55.000000000 +0800
+++ pnscan-1.8/bm.c 2009-02-02 13:44:47.000000000 +0800
@@ -109,7 +109,7 @@
xsize = m;
saved_m = m;
- saved_x = (unsigned char *) malloc(m);
+ saved_x = (unsigned char *) malloc(m); /* I am here */
if (saved_x == NULL)
return -2;
diff -Nur pnscan-1.8.old/pnscan.c pnscan-1.8/pnscan.c
--- pnscan-1.8.old/pnscan.c 2002-03-22 21:09:52.000000000 +0800
+++ pnscan-1.8/pnscan.c 2009-02-02 13:58:05.000000000 +0800
@@ -106,7 +106,7 @@
return val & 0xFF;
}
-
+/* I am here */
int
dehex(char *str)
{
@@ -996,7 +996,9 @@
goto EndOptions;
case 'h':
- usage(stdout);
+
+ usage(stdout); /* I am here */
+
exit(0);
case 'w':
[root@ecken02 temp]#
Patch file:
#patch -p1 < file.patch
parameter of patch
[root@ecken02 temp]# cp pnscan-1.8.old pnscan-1.8.new
[root@ecken02 temp]# patch -tp1 -d pnscan-1.8.new -i /absolute path/file.patch
沒有留言:
張貼留言