home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / rcs567s.zip / diff16 / patches.diff3 < prev    next >
Text File  |  1994-06-25  |  6KB  |  226 lines

  1. diff -cbBw orig/diff3.c new/diff3.c
  2. *** orig/diff3.c    Sat Jun 25 13:25:06 1994
  3. --- new/diff3.c    Sat Jun 25 13:23:38 1994
  4. ***************
  5. *** 1,5 ****
  6. --- 1,7 ----
  7.   /* Three way file comparison program (diff3) for Project GNU.
  8.      Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  9. +    Modified for DOS and OS/2 on 1994/06/25 by Kai Uwe Rommel
  10. +     <rommel@ars.muc.de>.
  11.   
  12.      This program is free software; you can redistribute it and/or modify
  13.      it under the terms of the GNU General Public License as published by
  14. ***************
  15. *** 17,28 ****
  16.   
  17.   /* Written by Randy Smith */
  18.   
  19. ! #include "system.h"
  20.   #include <stdio.h>
  21.   #include <ctype.h>
  22.   #include "getopt.h"
  23.   
  24. ! extern char const version_string[];
  25.   
  26.   /*
  27.    * Internal data structures and macros for the diff3 program; includes
  28. --- 19,46 ----
  29.   
  30.   /* Written by Randy Smith */
  31.   
  32. ! #include <stdlib.h>
  33.   #include <stdio.h>
  34.   #include <ctype.h>
  35. + #include <sys/types.h>
  36. + #include <sys/stat.h>
  37. + #define PARAMS(args) args
  38. + #ifdef MSDOS
  39. + extern FILE *popen(char *, char *);
  40. + extern int pclose(FILE *);
  41. + #define WEXITSTATUS(stat_val)  (stat_val & 255)
  42. + #define WIFEXITED(stat_val)    (((unsigned)stat_val >> 8) == 0)
  43. + /* pclose() returns status in inverse byte order than wait() does */
  44. + #define bzero(s,n)    memset((s),0,(n))
  45. + #define VOID        void
  46. + #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  47. + #endif
  48.   #include "getopt.h"
  49.   
  50. ! extern char *version_string;
  51.   
  52.   /*
  53.    * Internal data structures and macros for the diff3 program; includes
  54. ***************
  55. *** 179,185 ****
  56.   static VOID *xrealloc PARAMS((VOID *, size_t));
  57.   
  58.   static char *read_diff PARAMS((char const *, char const *, char **));
  59. ! static char *scan_diff_line PARAMS((char *, char **, size_t *, char *, int));
  60.   static enum diff_type process_diff_control PARAMS((char **, struct diff_block *));
  61.   static int compare_line_list PARAMS((char * const[], size_t const[], char * const[], size_t const[], int));
  62.   static int copy_stringlist PARAMS((char * const[], size_t const[], char *[], size_t[], int));
  63. --- 197,203 ----
  64.   static VOID *xrealloc PARAMS((VOID *, size_t));
  65.   
  66.   static char *read_diff PARAMS((char const *, char const *, char **));
  67. ! static char *scan_diff_line PARAMS((char *, char **, size_t *, char *, char));
  68.   static enum diff_type process_diff_control PARAMS((char **, struct diff_block *));
  69.   static int compare_line_list PARAMS((char * const[], size_t const[], char * const[], size_t const[], int));
  70.   static int copy_stringlist PARAMS((char * const[], size_t const[], char *[], size_t[], int));
  71. ***************
  72. *** 397,403 ****
  73.   usage (status)
  74.        int status;
  75.   {
  76. !   fflush (stderr);
  77.     printf ("\
  78.   Usage: %s [options] my-file older-file your-file\n\
  79.   Options:\n\
  80. --- 415,422 ----
  81.   usage (status)
  82.        int status;
  83.   {
  84. !   fflush(stderr);
  85. !   printf ("\nGNU diff3, version %s\n\n", version_string);
  86.     printf ("\
  87.   Usage: %s [options] my-file older-file your-file\n\
  88.   Options:\n\
  89. ***************
  90. *** 877,884 ****
  91.        int nl;
  92.   {
  93.     char
  94. !     * const *l1 = list1,
  95. !     * const *l2 = list2;
  96.     size_t const
  97.       *lgths1 = lengths1,
  98.       *lgths2 = lengths2;
  99. --- 896,903 ----
  100.        int nl;
  101.   {
  102.     char
  103. !     **l1 = list1,
  104. !     **l2 = list2;
  105.     size_t const
  106.       *lgths1 = lengths1,
  107.       *lgths2 = lengths2;
  108. ***************
  109. *** 894,901 ****
  110.    * Routines to input and parse two way diffs.
  111.    */
  112.   
  113. - extern char **environ;
  114.   #define    DIFF_CHUNK_SIZE    10000
  115.   
  116.   static struct diff_block *
  117. --- 913,918 ----
  118. ***************
  119. *** 1096,1108 ****
  120.   {
  121.     char *diff_result;
  122.     size_t bytes, current_chunk_size, total;
  123.     char const *argv[7];
  124.     char horizon_arg[256];
  125.     char const **ap;
  126. -   int fds[2];
  127.     pid_t pid;
  128.     int wstatus;
  129.   
  130.     ap = argv;
  131.     *ap++ = diff_program;
  132.     if (always_text)
  133. --- 1113,1135 ----
  134.   {
  135.     char *diff_result;
  136.     size_t bytes, current_chunk_size, total;
  137. +   int fds[2];
  138. + #ifdef MSDOS
  139. +   FILE *pipe;
  140. +   char buffer[512];
  141. + #else
  142.     char const *argv[7];
  143.     char horizon_arg[256];
  144.     char const **ap;
  145.     pid_t pid;
  146. + #endif
  147.     int wstatus;
  148.   
  149. + #ifdef MSDOS
  150. +   sprintf (buffer, "%s -a -- %s %s", diff_program, filea, fileb);
  151. +   pipe = popen (buffer, "r");
  152. +   fds[0] = fileno (pipe);
  153. + #else
  154.     ap = argv;
  155.     *ap++ = diff_program;
  156.     if (always_text)
  157. ***************
  158. *** 1138,1143 ****
  159. --- 1165,1172 ----
  160.       perror_with_exit ("fork failed");
  161.   
  162.     close (fds[1]);        /* Prevent erroneous lack of EOF */
  163. + #endif
  164.     current_chunk_size = DIFF_CHUNK_SIZE;
  165.     diff_result = xmalloc (current_chunk_size);
  166.     total = 0;
  167. ***************
  168. *** 1154,1160 ****
  169. --- 1183,1194 ----
  170.         current_chunk_size = (size_t) -1;
  171.       else
  172.         fatal ("files are too large to fit into memory");
  173. + #ifdef MSDOS
  174. +     diff_result = (char *) xrealloc (diff_result,
  175. +                       (current_chunk_size += DIFF_CHUNK_SIZE));
  176. + #else
  177.       diff_result = xrealloc (diff_result, (current_chunk_size *= 2));
  178. + #endif
  179.         }
  180.     } while (bytes);
  181.   
  182. ***************
  183. *** 1163,1168 ****
  184. --- 1197,1205 ----
  185.   
  186.     *output_placement = diff_result;
  187.   
  188. + #ifdef MSDOS
  189. +   wstatus = pclose(pipe);
  190. + #else
  191.   #if HAVE_WAITPID
  192.     if (waitpid (pid, &wstatus, 0) < 0)
  193.       perror_with_exit ("waitpid failed");
  194. ***************
  195. *** 1175,1180 ****
  196. --- 1212,1218 ----
  197.         break;
  198.     }
  199.   #endif
  200. + #endif
  201.   
  202.     if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
  203.       fatal ("subsidiary diff failed");
  204. ***************
  205. *** 1274,1280 ****
  206.       case DIFF_3RD:
  207.         oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
  208.   
  209. !       x[0] = oddoneout + '1';
  210.         x[1] = '\0';
  211.         dontprint = oddoneout==0;
  212.         break;
  213. --- 1312,1318 ----
  214.       case DIFF_3RD:
  215.         oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
  216.   
  217. !       x[0] = (char) (oddoneout + '1');
  218.         x[1] = '\0';
  219.         dontprint = oddoneout==0;
  220.         break;
  221.