ivaneeo's blog

          自由的力量,自由的生活。

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            669 Posts :: 0 Stories :: 64 Comments :: 0 Trackbacks
          以前曾提到過,在發布軟件補丁時很少(可能從不)使用正規和并排的塊格式.但diff產生的上下文(context)或統一(unified)的塊格式是創建補丁所采用的格式.為了產生上下文的差異文件(它們稱為context diff的原因是它們顯示出了有差別的行的上下文內容),可使用diff的-c或-C[num]選項.
            提示:和大多數GNU程序一樣,diff也支持長選項,也就是以兩個兩字符"--"開頭,后面跟著更容易記憶的名字的選項,例如,創建一個上下文diff文件的長選項是"--context=[num]".


          上下文輸出舉例
          $diff -c hello.c howdy.c
          *** hello.c Web Aug 9 21:02:42 2000
          --- howdy.c Web Aug 9 21:04:30 2000
          *************
          *** 1,12 ****
            #include <stdio.h>
            
            int main(void)
            {
          !    char msg[ ] = "Hello, Linux programmer!";
            
               puts(msg);
          !    printf("Here you are, using diff.\n");

          !    return 0;
            }
          ---  1,13 ---
            #include <stdio.h>
          + #include <stdlib.h>

            int main(void)
            {
          !   char msg[] = "Hello, Linux programmer, from howdy.c!");
            
              puts(msg);
          !   printf("howdy.c says, `Here you are, using diff.`\n");
          !   exit(EXIT_SUCCESS);
            }
          $

          上下文塊的格式采用以下一般形式:
            *** srcfile srcfile_timestamp
            --- dstfile dstfile_timestamp
            ****************
            *** srcfile_line_range ***
              srcfile line
            --- dstfile line_line_range
            dstfile line
            dstfile line...

          . + -----向srcfile添加一行以創建dstfile
          . - -----從srcfile刪除一行以創建dstfile
          . ! -----在srcfile改變一行以創建dstfile.srcfile中標記"!"的每一行或一段,在dstfile中相應的每一行或一段也標記"!".

          每一塊(hunk)都用一長串最多15個星號和下一塊(hunk)分隔開來.
          posted on 2005-08-04 17:21 ivaneeo 閱讀(243) 評論(0)  編輯  收藏 所屬分類: GNU牛力
          主站蜘蛛池模板: 温州市| 博爱县| 靖远县| 长岭县| 高安市| 平谷区| 区。| 江阴市| 南岸区| 苗栗市| 滨海县| 株洲县| 元谋县| 日喀则市| 航空| 石景山区| 农安县| 廊坊市| 南开区| 陕西省| 都江堰市| 石棉县| 阜阳市| 时尚| 仙桃市| 白山市| 盈江县| 抚顺县| 岗巴县| 南昌市| 嘉黎县| 宝坻区| 柘荣县| 巴东县| 余庆县| 宕昌县| 榆社县| 万安县| 屏南县| 瑞金市| 虎林市|