home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs567s.zip / diff / patches.os2 < prev    next >
Text File  |  1995-03-03  |  23KB  |  919 lines

  1. diff -cb orig/cmp.c new/cmp.c
  2. *** orig/cmp.c    Sat Apr 23 11:48:54 1994
  3. --- new/cmp.c    Sun Nov 14 23:48:26 1993
  4. ***************
  5. *** 94,99 ****
  6. --- 94,100 ----
  7.     if (reason && *reason)
  8.       fprintf (stderr, "%s: %s\n", program_name, reason);
  9.     fflush (stderr);
  10. +   printf ("\nGNU cmp, version %s\n\n", version_string);
  11.     printf ("\
  12.   Usage: %s [options] from-file [to-file]\n\
  13.   Options:\n\
  14. ***************
  15. *** 156,162 ****
  16.         }
  17.   
  18.     if (optind == argc)
  19. !     usage ("missing operand");
  20.   
  21.     file[0] = argv[optind++];
  22.     file[1] = optind < argc ? argv[optind++] : "-";
  23. --- 157,163 ----
  24.         }
  25.   
  26.     if (optind == argc)
  27. !     usage (0);
  28.   
  29.     file[0] = argv[optind++];
  30.     file[1] = optind < argc ? argv[optind++] : "-";
  31. ***************
  32. *** 177,183 ****
  33.   
  34.         file_desc[i1] = (strcmp (file[i1], "-") == 0
  35.                  ? STDIN_FILENO
  36. !                : open (file[i1], O_RDONLY));
  37.         if (file_desc[i1] < 0 || fstat (file_desc[i1], &stat_buf[i1]) != 0)
  38.       {
  39.         if (file_desc[i1] < 0 && comparison_type == type_status)
  40. --- 178,184 ----
  41.   
  42.         file_desc[i1] = (strcmp (file[i1], "-") == 0
  43.                  ? STDIN_FILENO
  44. !                : open (file[i1], O_RDONLY | O_BINARY));
  45.         if (file_desc[i1] < 0 || fstat (file_desc[i1], &stat_buf[i1]) != 0)
  46.       {
  47.         if (file_desc[i1] < 0 && comparison_type == type_status)
  48. ***************
  49. *** 187,192 ****
  50. --- 188,194 ----
  51.       }
  52.       }
  53.   
  54. + #ifndef OS2
  55.     /* If the files are links to the same inode and have the same file position,
  56.        they are identical.  */
  57.   
  58. ***************
  59. *** 222,227 ****
  60. --- 224,230 ----
  61.         if (max (0, s0) != max (0, s1))
  62.       exit (1);
  63.       }
  64. + #endif
  65.   
  66.     /* Get the optimal block size of the files.  */
  67.   
  68. ***************
  69. *** 503,508 ****
  70. --- 506,512 ----
  71.   {
  72.     register FILE *fs = stdout;
  73.   
  74. + #ifndef OS2
  75.     if (c >= 128)
  76.       {
  77.         putc ('M', fs);
  78. ***************
  79. *** 510,515 ****
  80. --- 514,520 ----
  81.         c -= 128;
  82.         width -= 2;
  83.       }
  84. + #endif
  85.     if (c < 32)
  86.       {
  87.         putc ('^', fs);
  88. diff -cb orig/context.c new/context.c
  89. *** orig/context.c    Sat Apr 23 11:48:54 1994
  90. --- new/context.c    Sat Nov 13 13:29:54 1993
  91. ***************
  92. *** 45,62 ****
  93.     if (label)
  94.       fprintf (outfile, "%s %s\n", mark, label);
  95.     else
  96.       /* See Posix.2 section 4.17.6.1.4 for this format.  */
  97.       fprintf (outfile, "%s %s\t%s",
  98. !          mark, inf->name, ctime (&inf->stat.st_mtime));
  99.   }
  100.   
  101.   /* Print a header for a context diff, with the file names and dates.  */
  102.   
  103.   void
  104.   print_context_header (inf, unidiff_flag)
  105.        struct file_data inf[];
  106.        int unidiff_flag;
  107.   {
  108.     if (unidiff_flag)
  109.       {
  110.         print_context_label ("---", &inf[0], file_label[0]);
  111. --- 45,80 ----
  112.     if (label)
  113.       fprintf (outfile, "%s %s\n", mark, label);
  114.     else
  115. +   {
  116. +     char *ct = ctime (&inf->stat.st_mtime);
  117.       /* See Posix.2 section 4.17.6.1.4 for this format.  */
  118.       fprintf (outfile, "%s %s\t%s",
  119. !          mark, inf->name, ct ? ct : "\n");
  120. !     /* some ctime()'s return NULL on illegal times
  121. !        which may occur sometimes on a PC ... */
  122. !   }
  123.   }
  124.   
  125.   /* Print a header for a context diff, with the file names and dates.  */
  126.   
  127. + #ifdef OS2
  128. + void unixname(char *ptr)
  129. + {
  130. +   for ( ; *ptr; ptr++ )
  131. +     if ( *ptr == '\\' )
  132. +       *ptr = '/';
  133. + }
  134. + #endif
  135.   void
  136.   print_context_header (inf, unidiff_flag)
  137.        struct file_data inf[];
  138.        int unidiff_flag;
  139.   {
  140. + #ifdef OS2
  141. +   unixname((char *) inf[0].name);
  142. +   unixname((char *) inf[1].name);
  143. + #endif
  144.     if (unidiff_flag)
  145.       {
  146.         print_context_label ("---", &inf[0], file_label[0]);
  147. diff -cb orig/diff.c new/diff.c
  148. *** orig/diff.c    Sat Apr 23 11:48:56 1994
  149. --- new/diff.c    Sat Apr 23 12:02:54 1994
  150. ***************
  151. *** 538,544 ****
  152.       }
  153.   
  154.     if (optind != argc - 2)
  155. !     usage (optind < argc - 2 ? "extra operand" : "missing operand");
  156.   
  157.   
  158.     {
  159. --- 538,544 ----
  160.       }
  161.   
  162.     if (optind != argc - 2)
  163. !     usage (optind < argc - 2 ? "extra operand" : 0);
  164.   
  165.   
  166.     {
  167. ***************
  168. *** 632,637 ****
  169. --- 632,638 ----
  170.     if (reason && *reason)
  171.       fprintf (stderr, "%s: %s\n", program, reason);
  172.     fflush (stderr);
  173. +   printf ("\nGNU diff, version %s\n\n", version_string);
  174.     printf ("Usage: %s [options] from-file to-file\n", program);
  175.     printf ("Options:\n\
  176.       [-abBcdefhHilnNpPqrstTuvwy] [-C lines] [-D name] [-F regexp]\n\
  177. ***************
  178. *** 736,742 ****
  179.     struct file_data inf[2];
  180.     register int i;
  181.     int val;
  182. !   int same_files;
  183.     int failed = 0;
  184.     char *free0 = 0, *free1 = 0;
  185.   
  186. --- 737,743 ----
  187.     struct file_data inf[2];
  188.     register int i;
  189.     int val;
  190. !   int same_files = 0;
  191.     int failed = 0;
  192.     char *free0 = 0, *free1 = 0;
  193.   
  194. ***************
  195. *** 835,843 ****
  196.         int dir_arg = 1 - fnm_arg;
  197.         char const *fnm = inf[fnm_arg].name;
  198.         char const *dir = inf[dir_arg].name;
  199. !       char const *p = strrchr (fnm, '/');
  200. !       char const *filename = inf[dir_arg].name
  201. !     = dir_file_pathname (dir, p ? p + 1 : fnm);
  202.   
  203.         if (strcmp (fnm, "-") == 0)
  204.       fatal ("can't compare - to a directory");
  205. --- 836,851 ----
  206.         int dir_arg = 1 - fnm_arg;
  207.         char const *fnm = inf[fnm_arg].name;
  208.         char const *dir = inf[dir_arg].name;
  209. !       char const *p, *filename;
  210. !       p = strrchr (fnm, '/');
  211. ! #ifdef OS2
  212. !       if (p == NULL)
  213. !     p = strrchr (fnm, '\\');
  214. !       if (p == NULL)
  215. !     p = strrchr (fnm, ':');
  216. ! #endif
  217. !       filename = inf[dir_arg].name = dir_file_pathname (dir, p ? p + 1 : fnm);
  218.   
  219.         if (strcmp (fnm, "-") == 0)
  220.       fatal ("can't compare - to a directory");
  221. ***************
  222. *** 859,864 ****
  223. --- 867,873 ----
  224.         val = 2;
  225.   
  226.       }
  227. + #ifndef OS2
  228.     else if ((same_files =    inf[0].stat.st_ino == inf[1].stat.st_ino
  229.                && inf[0].stat.st_dev == inf[1].stat.st_dev
  230.                && inf[0].stat.st_size == inf[1].stat.st_size
  231. ***************
  232. *** 871,876 ****
  233. --- 880,886 ----
  234.   
  235.         val = 0;
  236.       }
  237. + #endif
  238.     else if (inf[0].dir_p & inf[1].dir_p)
  239.       {
  240.         if (output_style == OUTPUT_IFDEF)
  241. diff -cb orig/diff3.c new/diff3.c
  242. *** orig/diff3.c    Sat Apr 23 11:48:58 1994
  243. --- new/diff3.c    Sat Nov 13 13:48:02 1993
  244. ***************
  245. *** 397,403 ****
  246.   usage (status)
  247.        int status;
  248.   {
  249. !   fflush (stderr);
  250.     printf ("\
  251.   Usage: %s [options] my-file older-file your-file\n\
  252.   Options:\n\
  253. --- 397,404 ----
  254.   usage (status)
  255.        int status;
  256.   {
  257. !   fflush(stderr);
  258. !   printf ("\nGNU diff3, version %s\n\n", version_string);
  259.     printf ("\
  260.   Usage: %s [options] my-file older-file your-file\n\
  261.   Options:\n\
  262. ***************
  263. *** 1096,1108 ****
  264.   {
  265.     char *diff_result;
  266.     size_t bytes, current_chunk_size, total;
  267.     char const *argv[7];
  268.     char horizon_arg[256];
  269.     char const **ap;
  270. -   int fds[2];
  271.     pid_t pid;
  272.     int wstatus;
  273.   
  274.     ap = argv;
  275.     *ap++ = diff_program;
  276.     if (always_text)
  277. --- 1097,1120 ----
  278.   {
  279.     char *diff_result;
  280.     size_t bytes, current_chunk_size, total;
  281. +   int fds[2];
  282. + #ifdef OS2
  283. +   FILE *pipe;
  284. +   char buffer[512];
  285. + #else
  286.     char const *argv[7];
  287.     char horizon_arg[256];
  288.     char const **ap;
  289.     pid_t pid;
  290. + #endif
  291.     int wstatus;
  292.   
  293. + #ifdef OS2
  294. +   sprintf (buffer, "%s -a --horizon-lines=%d -- %s %s",
  295. +            diff_program, horizon_lines, filea, fileb);
  296. +   pipe = popen (buffer, "r");
  297. +   fds[0] = fileno (pipe);
  298. + #else
  299.     ap = argv;
  300.     *ap++ = diff_program;
  301.     if (always_text)
  302. ***************
  303. *** 1138,1143 ****
  304. --- 1150,1157 ----
  305.       perror_with_exit ("fork failed");
  306.   
  307.     close (fds[1]);        /* Prevent erroneous lack of EOF */
  308. + #endif
  309.     current_chunk_size = DIFF_CHUNK_SIZE;
  310.     diff_result = xmalloc (current_chunk_size);
  311.     total = 0;
  312. ***************
  313. *** 1163,1168 ****
  314. --- 1177,1185 ----
  315.   
  316.     *output_placement = diff_result;
  317.   
  318. + #ifdef OS2
  319. +   wstatus = pclose(pipe);
  320. + #else
  321.   #if HAVE_WAITPID
  322.     if (waitpid (pid, &wstatus, 0) < 0)
  323.       perror_with_exit ("waitpid failed");
  324. ***************
  325. *** 1174,1179 ****
  326. --- 1191,1197 ----
  327.       if (w == pid)
  328.         break;
  329.     }
  330. + #endif
  331.   #endif
  332.   
  333.     if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
  334. diff -cb orig/dir.c new/dir.c
  335. *** orig/dir.c    Sat Apr 23 11:48:58 1994
  336. --- new/dir.c    Sat Nov 13 13:29:56 1993
  337. ***************
  338. *** 19,24 ****
  339. --- 19,28 ----
  340.   
  341.   #include "diff.h"
  342.   
  343. + #ifdef OS2
  344. + #define strcmp stricmp
  345. + #endif /* OS2 */
  346.   /* Read the directory named by DIR and store into DIRDATA a sorted vector
  347.      of filenames for its contents.  DIR->desc == -1 means this directory is
  348.      known to be nonexistent, so set DIRDATA to an empty vector.
  349. diff -cb orig/ifdef.c new/ifdef.c
  350. *** orig/ifdef.c    Sat Apr 23 11:48:58 1994
  351. --- new/ifdef.c    Sat Nov 13 13:29:56 1993
  352. ***************
  353. *** 30,36 ****
  354.   static char *format_group PARAMS((FILE *, char *, int, struct group const[]));
  355.   static char *scan_char_literal PARAMS((char *, int *));
  356.   static char *scan_printf_spec PARAMS((char *));
  357. ! static int groups_letter_value PARAMS((struct group const[], int));
  358.   static void format_ifdef PARAMS((char *, int, int, int, int));
  359.   static void print_ifdef_hunk PARAMS((struct change *));
  360.   static void print_ifdef_lines PARAMS((FILE *, char *, struct group const *));
  361. --- 30,36 ----
  362.   static char *format_group PARAMS((FILE *, char *, int, struct group const[]));
  363.   static char *scan_char_literal PARAMS((char *, int *));
  364.   static char *scan_printf_spec PARAMS((char *));
  365. ! static int groups_letter_value PARAMS((struct group const *, int));
  366.   static void format_ifdef PARAMS((char *, int, int, int, int));
  367.   static void print_ifdef_hunk PARAMS((struct change *));
  368.   static void print_ifdef_lines PARAMS((FILE *, char *, struct group const *));
  369. ***************
  370. *** 238,244 ****
  371.      Return -1 if LETTER is not a group format letter.  */
  372.   static int
  373.   groups_letter_value (g, letter)
  374. !      struct group const g[];
  375.        int letter;
  376.   {
  377.     if (isupper (letter))
  378. --- 238,244 ----
  379.      Return -1 if LETTER is not a group format letter.  */
  380.   static int
  381.   groups_letter_value (g, letter)
  382. !      struct group const *g;
  383.        int letter;
  384.   {
  385.     if (isupper (letter))
  386. diff -cb orig/regex.c new/regex.c
  387. *** orig/regex.c    Sat Apr 23 11:49:00 1994
  388. --- new/regex.c    Sat Nov 13 13:29:56 1993
  389. ***************
  390. *** 218,226 ****
  391. --- 218,230 ----
  392.   #if HAVE_ALLOCA_H
  393.   #include <alloca.h>
  394.   #else /* not __GNUC__ or HAVE_ALLOCA_H */
  395. + #ifdef __WATCOMC__
  396. + #include <malloc.h>
  397. + #else
  398.   #ifndef _AIX /* Already did AIX, up at the top.  */
  399.   char *alloca ();
  400.   #endif /* not _AIX */
  401. + #endif
  402.   #endif /* not HAVE_ALLOCA_H */ 
  403.   #endif /* not __GNUC__ */
  404.   
  405. diff -cb orig/sdiff.c new/sdiff.c
  406. *** orig/sdiff.c    Sat Apr 23 11:49:02 1994
  407. --- new/sdiff.c    Sat Nov 13 13:47:02 1993
  408. ***************
  409. *** 46,51 ****
  410. --- 46,52 ----
  411.   static char *tmpname;
  412.   static int volatile tmpmade;
  413.   static pid_t volatile diffpid;
  414. + static char diffcmd[1024];
  415.   
  416.   struct line_filter;
  417.   
  418. ***************
  419. *** 80,86 ****
  420. --- 81,91 ----
  421.   static void usage PARAMS((int));
  422.   
  423.   /* this lossage until the gnu libc conquers the universe */
  424. + #ifdef OS2
  425. + #define PVT_tmpdir ""
  426. + #else
  427.   #define PVT_tmpdir "/tmp"
  428. + #endif
  429.   static char *private_tempnam PARAMS((char const *, char const *, int, size_t *));
  430.   static int diraccess PARAMS((char const *));
  431.   static int exists PARAMS((char const *));
  432. ***************
  433. *** 118,123 ****
  434. --- 123,129 ----
  435.   usage (status)
  436.        int status;
  437.   {
  438. +   printf ("\nGNU sdiff, version %s\n\n", version_string);
  439.     printf ("Usage: %s [options] from-file to-file\n", prog);
  440.     printf ("Options:\n\
  441.       [-abBdHilstv] [-I regexp] [-o outfile] [-w columns]\n\
  442. ***************
  443. *** 254,259 ****
  444. --- 260,266 ----
  445.   }
  446.   #endif
  447.   
  448. + #ifndef OS2
  449.   #ifndef HAVE_WAITPID
  450.   /* Emulate waitpid well enough for sdiff, which has at most two children.  */
  451.   static pid_t
  452. ***************
  453. *** 283,288 ****
  454. --- 290,296 ----
  455.     return pid;
  456.   }
  457.   #endif
  458. + #endif
  459.   
  460.   static char const *
  461.   expand_name (name, isdir, other_name)
  462. ***************
  463. *** 517,530 ****
  464.       usage (2);
  465.   
  466.     if (! out_file)
  467.       /* easy case: diff does everything for us */
  468.       execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1]);
  469.     else
  470.       {
  471.         FILE *left, *right, *out, *diffout;
  472. !       int diff_fds[2];
  473. !       int interact_ok;
  474. !       pid_t pid;
  475.         struct line_filter lfilt;
  476.         struct line_filter rfilt;
  477.         struct line_filter diff_filt;
  478. --- 525,539 ----
  479.       usage (2);
  480.   
  481.     if (! out_file)
  482. +   {
  483.       /* easy case: diff does everything for us */
  484.       execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1]);
  485. +     exit (system (diffcmd));
  486. +   }
  487.     else
  488.       {
  489.         FILE *left, *right, *out, *diffout;
  490. !       int interact_ok, wstatus;
  491.         struct line_filter lfilt;
  492.         struct line_filter rfilt;
  493.         struct line_filter diff_filt;
  494. ***************
  495. *** 539,571 ****
  496.         right = ck_fopen (expand_name (argv[optind + 1], rightdir, argv[optind]), "r");
  497.         out = ck_fopen (out_file, "w");
  498.   
  499. -       if (pipe (diff_fds))
  500. -     perror_fatal ("pipe");
  501. -       trapsigs ();
  502. -       diffpid = pid = vfork ();
  503. -       if (pid == 0)
  504. -     {
  505. -       signal (SIGINT, SIG_IGN);  /* in case user interrupts editor */
  506. -       signal (SIGPIPE, SIG_DFL);
  507. -       close (diff_fds[0]);
  508. -       if (diff_fds[1] != STDOUT_FILENO)
  509. -         {
  510. -           dup2 (diff_fds[1], STDOUT_FILENO);
  511. -           close (diff_fds[1]);
  512. -         }
  513.         execdiff (0, "--sdiff-merge-assist", argv[optind], argv[optind + 1]);
  514. !     }
  515. !       if (pid < 0)
  516. !     perror_fatal ("fork failed");
  517. !       close (diff_fds[1]);
  518. !       diffout = ck_fdopen (diff_fds[0], "r");
  519.   
  520.         lf_init (&diff_filt, diffout);
  521.         lf_init (&lfilt, left);
  522. --- 548,556 ----
  523.         right = ck_fopen (expand_name (argv[optind + 1], rightdir, argv[optind]), "r");
  524.         out = ck_fopen (out_file, "w");
  525.   
  526.         execdiff (0, "--sdiff-merge-assist", argv[optind], argv[optind + 1]);
  527. !       if ( (diffout = popen(diffcmd, "r")) == NULL )
  528. !     perror_fatal ("popen failed");
  529.   
  530.         lf_init (&diff_filt, diffout);
  531.         lf_init (&lfilt, left);
  532. ***************
  533. *** 573,592 ****
  534.   
  535.         interact_ok = interact (&diff_filt, &lfilt, &rfilt, out);
  536.   
  537. -       ck_fclose (diffout);
  538.         ck_fclose (left);
  539.         ck_fclose (right);
  540.         ck_fclose (out);
  541.   
  542. !       {
  543. !     int wstatus;
  544. !     while (waitpid (pid, &wstatus, 0) < 0)
  545. !       if (errno == EINTR)
  546. !         checksigs ();
  547. !       else
  548. !         perror_fatal ("wait failed");
  549. !     diffpid = 0;
  550.   
  551.       if (tmpmade)
  552.         {
  553. --- 558,568 ----
  554.   
  555.         interact_ok = interact (&diff_filt, &lfilt, &rfilt, out);
  556.   
  557.         ck_fclose (left);
  558.         ck_fclose (right);
  559.         ck_fclose (out);
  560.   
  561. !       wstatus = pclose(diffout);
  562.   
  563.       if (tmpmade)
  564.         {
  565. ***************
  566. *** 604,635 ****
  567.       checksigs ();
  568.       exit (WEXITSTATUS (wstatus));
  569.         }
  570. -     }
  571.     return 0;            /* Fool -Wall . . . */
  572.   }
  573.   
  574. - static char const **diffargv;
  575.   static void
  576.   diffarg (a)
  577.        char const *a;
  578.   {
  579. !   static unsigned diffargs, diffargsmax;
  580. !   if (diffargs == diffargsmax)
  581. !     {
  582. !       if (! diffargsmax)
  583. !     {
  584. !       diffargv = (char const **) xmalloc (sizeof (char));
  585. !       diffargsmax = 8;
  586. !     }
  587. !       diffargsmax *= 2;
  588. !       diffargv = (char const **) realloc (diffargv,
  589. !                       diffargsmax * sizeof (char const *));
  590. !       if (! diffargv)
  591. !     fatal ("out of memory");
  592. !     }
  593. !   diffargv[diffargs++] = a;
  594.   }
  595.   
  596.   static void
  597. --- 580,595 ----
  598.       checksigs ();
  599.       exit (WEXITSTATUS (wstatus));
  600.         }
  601.     return 0;            /* Fool -Wall . . . */
  602.   }
  603.   
  604.   static void
  605.   diffarg (a)
  606.        char const *a;
  607.   {
  608. !   if (diffcmd[0] != 0)
  609. !     strcat (diffcmd, " ");
  610. !   strcat (diffcmd, a);
  611.   }
  612.   
  613.   static void
  614. ***************
  615. *** 643,654 ****
  616.     diffarg ("--");
  617.     diffarg (file1);
  618.     diffarg (file2);
  619. -   diffarg (0);
  620. -   execvp (diffbin, (char **) diffargv);
  621. -   write (STDERR_FILENO, diffbin, strlen (diffbin));
  622. -   write (STDERR_FILENO, ": not found\n", 12);
  623. -   _exit (2);
  624.   }
  625.   
  626.   
  627. --- 603,608 ----
  628. ***************
  629. *** 903,909 ****
  630.       case 'q':
  631.         return 0;
  632.       case 'e':
  633. !       if (! tmpname && ! (tmpname = private_tempnam (0, "sdiff", 1, 0)))
  634.           perror_fatal ("temporary file name");
  635.   
  636.         tmpmade = 1;
  637. --- 857,863 ----
  638.       case 'q':
  639.         return 0;
  640.       case 'e':
  641. !       if (! tmpname && ! (tmpname = private_tempnam (0, "sd_", 1, 0)))
  642.           perror_fatal ("temporary file name");
  643.   
  644.         tmpmade = 1;
  645. ***************
  646. *** 923,928 ****
  647. --- 877,902 ----
  648.   
  649.           ck_fflush (tmp);
  650.   
  651. + #ifdef OS2
  652. +         {
  653. +           char const *argv[3];
  654. +           int i = 0, wstatus;
  655. +           argv[i++] = edbin;
  656. +           argv[i++] = tmpname;
  657. +           argv[i++] = 0;
  658. +           if ( (wstatus = spawnvp (P_WAIT, edbin, argv)) == -1 )
  659. +           {
  660. +         write (fileno (stderr), edbin, strlen (edbin));
  661. +         write (fileno (stderr), ": not found\n", 12);
  662. +         _exit (1);
  663. +           }
  664. +           if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 1))
  665. +         fatal ("Subsidiary editor failed");
  666. +         }
  667. + #else
  668.           {
  669.             pid_t pid;
  670.             int wstatus;
  671. ***************
  672. *** 960,965 ****
  673. --- 934,940 ----
  674.             if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 1))
  675.           fatal ("Subsidiary editor failed");
  676.           }
  677. + #endif
  678.   
  679.           if (fseek (tmp, 0L, SEEK_SET) != 0)
  680.             perror_fatal ("fseek");
  681. ***************
  682. *** 1114,1119 ****
  683. --- 1089,1099 ----
  684.   
  685.     if (dir_search)
  686.       {
  687. + #ifdef OS2
  688. +       char *d = getenv ("TMP");
  689. +       if (d == NULL)
  690. +     d = "";
  691. + #else
  692.         register char const *d = getenv ("TMPDIR");
  693.         if (d && !diraccess (d))
  694.       d = 0;
  695. ***************
  696. *** 1123,1128 ****
  697. --- 1103,1109 ----
  698.       d = tmpdir;
  699.         if (!d && diraccess ("/tmp"))
  700.       d = "/tmp";
  701. + #endif
  702.         if (!d)
  703.       {
  704.         errno = ENOENT;
  705. ***************
  706. *** 1170,1176 ****
  707.     for (;;)
  708.       {
  709.         *info->s = letters[info->i];
  710. !       sprintf (buf, "%s/%.*s%.5lu%.3s", dir, (int) plen, pfx,
  711.              (unsigned long) pid % 100000, info->buf);
  712.         if (!exists (buf))
  713.       break;
  714. --- 1151,1157 ----
  715.     for (;;)
  716.       {
  717.         *info->s = letters[info->i];
  718. !       sprintf (buf, "%s/%.*s%.5lu.%.3s", dir, (int) plen, pfx,
  719.              (unsigned long) pid % 100000, info->buf);
  720.         if (!exists (buf))
  721.       break;
  722. diff -cb orig/system.h new/system.h
  723. *** orig/system.h    Sat Apr 23 11:49:02 1994
  724. --- new/system.h    Sat Nov 13 13:30:00 1993
  725. ***************
  726. *** 98,111 ****
  727. --- 98,117 ----
  728.   #if HAVE_TIME_H
  729.   #include <time.h>
  730.   #else
  731. + #ifdef __WATCOMC__
  732. + #include <time.h>
  733. + #else
  734.   #include <sys/time.h>
  735.   #endif
  736. + #endif
  737.   
  738.   #if HAVE_FCNTL_H
  739.   #include <fcntl.h>
  740.   #else
  741. + #ifndef __WATCOMC__
  742.   #include <sys/file.h>
  743.   #endif
  744. + #endif
  745.   
  746.   #if !HAVE_DUP2
  747.   #define dup2(f,t)    (close (t),  fcntl (f,F_DUPFD,t))
  748. ***************
  749. *** 137,144 ****
  750. --- 143,154 ----
  751.   #if HAVE_ST_BLKSIZE
  752.   #define STAT_BLOCKSIZE(s) (s).st_blksize
  753.   #else
  754. + #ifdef OS2
  755. + #define STAT_BLOCKSIZE(s) (64 * 1024)
  756. + #else
  757.   #define STAT_BLOCKSIZE(s) (8 * 1024)
  758.   #endif
  759. + #endif
  760.   
  761.   #if DIRENT || defined (_POSIX_VERSION)
  762.   #include <dirent.h>
  763. ***************
  764. *** 151,157 ****
  765. --- 151,162 ----
  766.   #endif
  767.   
  768.   #if DIRENT || defined (_POSIX_VERSION)
  769. + #ifdef __WATCOMC__
  770. + typedef int pid_t;
  771. + #include <direct.h>
  772. + #else
  773.   #include <dirent.h>
  774. + #endif
  775.   #else /* ! (DIRENT || defined (_POSIX_VERSION)) */
  776.   #if SYSNDIR
  777.   #include <sys/ndir.h>
  778. ***************
  779. *** 160,165 ****
  780. --- 170,177 ----
  781.   
  782.   #if HAVE_VFORK_H
  783.   #include <vfork.h>
  784. + #else
  785. + #define vfork fork
  786.   #endif
  787.   
  788.   #if HAVE_STDLIB_H
  789. ***************
  790. *** 211,215 ****
  791. --- 223,242 ----
  792.   extern int errno;
  793.   #endif
  794.   
  795. + #ifdef min
  796. + #undef min
  797. + #endif
  798. + #ifdef max
  799. + #undef max
  800. + #endif
  801.   #define min(a,b) ((a) <= (b) ? (a) : (b))
  802.   #define max(a,b) ((a) >= (b) ? (a) : (b))
  803. + #ifdef OS2
  804. + #include <process.h>
  805. + typedef int pid_t;
  806. + #define DIFF_PROGRAM "diff.exe"
  807. + #ifdef __EMX__
  808. + #define main os2main
  809. + #endif
  810. + #endif
  811. diff -cb orig/util.c new/util.c
  812. *** orig/util.c    Sat Apr 23 11:49:02 1994
  813. --- new/util.c    Sat Nov 13 13:30:02 1993
  814. ***************
  815. *** 177,182 ****
  816. --- 177,197 ----
  817.        These requirements are silly and do not match historical practice.  */
  818.     sprintf (name, "diff%s %s %s", switch_string, current_name0, current_name1);
  819.   
  820. + #ifdef OS2
  821. +   if (paginate_flag)
  822. +     {
  823. + #ifdef __WATCOMC__
  824. +       outfile = stdout;
  825. + #else
  826. +       extern FILE *popen();
  827. +       char cmd[256];
  828. +       /* Fork a `pr' and make OUTFILE a pipe to it.  */
  829. +       sprintf (cmd, "pr -f -h \"%s\"", name);
  830. +       outfile = popen(cmd, "w");
  831. + #endif
  832. +     }
  833. + #else
  834.     if (paginate_flag)
  835.       {
  836.         int pipes[2];
  837. ***************
  838. *** 210,215 ****
  839. --- 225,231 ----
  840.         outfile = fdopen (pipes[1], "w");
  841.       }
  842.       }
  843. + #endif
  844.     else
  845.       {
  846.   
  847. ***************
  848. *** 252,259 ****
  849. --- 268,280 ----
  850.         int wstatus;
  851.         if (ferror (outfile))
  852.       fatal ("write error");
  853. + #if defined(OS2) && !defined(__WATCOMC__)
  854. +       if (pclose (outfile) != 0)
  855. + #else
  856.         if (fclose (outfile) != 0)
  857. + #endif
  858.       pfatal_with_name ("write error");
  859. + #ifndef OS2
  860.   #if HAVE_WAITPID
  861.         if (waitpid (pr_pid, &wstatus, 0) < 0)
  862.       pfatal_with_name ("waitpid");
  863. ***************
  864. *** 268,273 ****
  865. --- 289,295 ----
  866.   #endif
  867.         if (! WIFEXITED (wstatus) || WEXITSTATUS (wstatus) != 0)
  868.       fatal ("subsidiary pr failed");
  869. + #endif
  870.       }
  871.   
  872.     outfile = 0;
  873. diff -cb orig/version.c new/version.c
  874. *** orig/version.c    Sat Apr 23 11:49:02 1994
  875. --- new/version.c    Sat Nov 13 13:30:02 1993
  876. ***************
  877. *** 2,5 ****
  878. --- 2,21 ----
  879.   
  880.   #include "config.h"
  881.   
  882. + #ifdef __EMX__
  883. + #include <stdio.h>
  884. + int main(int argc, char **argv)
  885. + {
  886. +   _response(&argc, &argv);
  887. +   _wildcard(&argc, &argv);
  888. +   _emxload_env("RCSLOAD");
  889. +   setvbuf(stdout, NULL, _IOFBF, BUFSIZ);
  890. +   return os2main(argc, argv);
  891. + }
  892. + #endif
  893.   char const version_string[] = "2.6";
  894.