home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / DIFFPT.ZIP / PATCHES.OS2 < prev    next >
Text File  |  1991-07-01  |  60KB  |  2,090 lines

  1. Only in diff: patches.os2
  2. Only in diff: patchfmt.dif
  3. Only in diff: merged.dif
  4. Only in diff: diff.bad
  5. Only in diff: diff.cs
  6. Only in diff: diff.def
  7. Only in diff: diff.man
  8. Only in diff: diff3.bad
  9. Only in diff: diff3.cs
  10. Only in diff: diff3.def
  11. Only in diff: diff3.man
  12. Only in diff: hrealloc.c
  13. Only in diff: merged.c
  14. Only in diff: mktemp.c
  15. Only in diff: pipe.c
  16. Only in diff: proto.h
  17. diff -cbBw orig/analyze.c diff/analyze.c
  18. *** orig/analyze.c    Mon Jan 28 20:17:44 1991
  19. --- diff/analyze.c    Mon Jan 28 20:22:04 1991
  20. ***************
  21. *** 32,42 ****
  22. --- 32,47 ----
  23.   void print_normal_script ();
  24.   void print_rcs_script ();
  25.   void pr_forward_ed_script ();
  26. + void print_merged_script ();
  27.   void setup_output ();
  28.   
  29.   extern int no_discards;
  30.   
  31.   static int *xvec, *yvec;    /* Vectors being compared. */
  32. + #ifdef MSDOS
  33. + static int _huge *fdiag;
  34. + static int _huge *bdiag;
  35. + #else
  36.   static int *fdiag;        /* Vector, indexed by diagonal, containing
  37.                      the X coordinate of the point furthest
  38.                      along the given diagonal in the forward
  39. ***************
  40. *** 45,50 ****
  41. --- 50,56 ----
  42.                      the X coordinate of the point furthest
  43.                      along the given diagonal in the backward
  44.                      search of the edit matrix. */
  45. + #endif
  46.   
  47.   /* Find the midpoint of the shortest edit script for a specified
  48.      portion of the two files.
  49. ***************
  50. *** 75,84 ****
  51. --- 81,97 ----
  52.        int xoff, xlim, yoff, ylim;
  53.        int *cost;
  54.   {
  55. + #ifdef MSDOS
  56. +   int _huge *const fd = fdiag;
  57. +   int _huge *const bd = bdiag;
  58. +   int _huge *const xv = xvec;
  59. +   int _huge *const yv = yvec;
  60. + #else
  61.     int *const fd = fdiag;    /* Give the compiler a chance. */
  62.     int *const bd = bdiag;    /* Additional help for the compiler. */
  63.     int *const xv = xvec;        /* Still more help for the compiler. */
  64.     int *const yv = yvec;        /* And more and more . . . */
  65. + #endif
  66.     const int dmin = xoff - ylim;    /* Minimum valid diagonal. */
  67.     const int dmax = xlim - yoff;    /* Maximum valid diagonal. */
  68.     const int fmid = xoff - yoff;    /* Center diagonal of top-down search. */
  69. ***************
  70. *** 719,725 ****
  71.        struct file_data filevec[];
  72.        int depth;
  73.   {
  74. !   int diags;
  75.     int i;
  76.     struct change *e, *p;
  77.     struct change *script;
  78. --- 732,738 ----
  79.        struct file_data filevec[];
  80.        int depth;
  81.   {
  82. !   long diags;
  83.     int i;
  84.     struct change *e, *p;
  85.     struct change *script;
  86. ***************
  87. *** 729,738 ****
  88. --- 742,766 ----
  89.     /* See if the two named files are actually the same physical file.
  90.        If so, we know they are identical without actually reading them.  */
  91.   
  92. + #if !defined(MSDOS)
  93. +       /*
  94. +       ** since MSC always sets the inode and dev fields to zero under DOS
  95. +       ** this test will always think two files are the same.
  96. +       */
  97.     if (output_style != OUTPUT_IFDEF
  98.         && filevec[0].stat.st_ino == filevec[1].stat.st_ino
  99.         && filevec[0].stat.st_dev == filevec[1].stat.st_dev)
  100.       return 0;
  101. + #endif /* MSDOS */
  102. +   if (no_details_flag
  103. +       && (filevec[0].stat.st_mode & S_IFMT) == S_IFREG
  104. +       && (filevec[1].stat.st_mode & S_IFMT) == S_IFREG
  105. +       && filevec[0].stat.st_size != filevec[1].stat.st_size)
  106. +     {
  107. +       message ("Files %s and %s differ\n", filevec[0].name, filevec[1].name);
  108. +       return 1;
  109. +     }
  110.   
  111.     binary = read_files (filevec);
  112.   
  113. ***************
  114. *** 743,759 ****
  115.   
  116.     if (binary || no_details_flag)
  117.       {
  118.         int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
  119.                || bcmp (filevec[0].buffer, filevec[1].buffer,
  120.                     filevec[1].buffered_chars));
  121.         if (differs)
  122. !     message (binary ? "Binary files %s and %s differ\n"
  123. !          : "Files %s and %s differ\n",
  124.            filevec[0].name, filevec[1].name);
  125.   
  126.         for (i = 0; i < 2; ++i)
  127.       if (filevec[i].buffer)
  128.         free (filevec[i].buffer);
  129.         return differs;
  130.       }
  131.   
  132. --- 771,817 ----
  133.   
  134.     if (binary || no_details_flag)
  135.       {
  136. + #if !defined(MSDOS)
  137.         int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
  138.                || bcmp (filevec[0].buffer, filevec[1].buffer,
  139.                     filevec[1].buffered_chars));
  140. + #else
  141. +       int differs;
  142. +       if(filevec[0].buffered_chars != filevec[1].buffered_chars)
  143. +               differs = 1;
  144. +       else {
  145. +               /*
  146. +               ** we've got to do it in chunks because of our
  147. +               ** poor 16 bit processor
  148. +               */
  149. +               char _huge *b0 = filevec[0].buffer;
  150. +               char _huge *b1 = filevec[1].buffer;
  151. +               long int count;
  152. +               unsigned int delta;
  153. +               count = filevec[0].buffered_chars;
  154. +               while(count > 0) {
  155. +                       delta = (unsigned)(count > 65000 ? 65000 : count);
  156. +                       if(bcmp(b0,b1,delta) != 0)
  157. +                               break;
  158. +                       count -= delta;
  159. +                       b0 += delta;
  160. +                       b1 += delta;
  161. +               }
  162. +               differs = count != 0;
  163. +       }
  164. + #endif
  165.         if (differs)
  166. !     message (no_details_flag ? "Files %s and %s differ\n"
  167. !          : "Binary files %s and %s differ\n",
  168.            filevec[0].name, filevec[1].name);
  169.   
  170.         for (i = 0; i < 2; ++i)
  171.       if (filevec[i].buffer)
  172. + #ifndef MSDOS
  173.         free (filevec[i].buffer);
  174. + #else
  175. +           hfree (filevec[i].buffer);
  176. + #endif
  177.         return differs;
  178.       }
  179.   
  180. ***************
  181. *** 780,789 ****
  182.   
  183.     xvec = filevec[0].undiscarded;
  184.     yvec = filevec[1].undiscarded;
  185. !   diags = filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3;
  186.     fdiag = (int *) xmalloc (diags * sizeof (int));
  187. -   fdiag += filevec[1].nondiscarded_lines + 1;
  188.     bdiag = (int *) xmalloc (diags * sizeof (int));
  189.     bdiag += filevec[1].nondiscarded_lines + 1;
  190.   
  191.     files[0] = filevec[0];
  192. --- 838,854 ----
  193.   
  194.     xvec = filevec[0].undiscarded;
  195.     yvec = filevec[1].undiscarded;
  196. !   diags = (long) filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3;
  197. ! #ifdef MSDOS
  198. !   fdiag = halloc (diags, sizeof (int));
  199. !   bdiag = halloc (diags, sizeof (int));
  200. !   if ( fdiag == NULL || bdiag == NULL )
  201. !     fatal("virtual memory exhausted");
  202. ! #else
  203.     fdiag = (int *) xmalloc (diags * sizeof (int));
  204.     bdiag = (int *) xmalloc (diags * sizeof (int));
  205. + #endif
  206. +   fdiag += filevec[1].nondiscarded_lines + 1;
  207.     bdiag += filevec[1].nondiscarded_lines + 1;
  208.   
  209.     files[0] = filevec[0];
  210. ***************
  211. *** 793,801 ****
  212.             0, filevec[1].nondiscarded_lines);
  213.   
  214.     bdiag -= filevec[1].nondiscarded_lines + 1;
  215. -   free (bdiag);
  216.     fdiag -= filevec[1].nondiscarded_lines + 1;
  217.     free (fdiag);
  218.   
  219.     /* Modify the results slightly to make them prettier
  220.        in cases where that can validly be done.  */
  221. --- 858,871 ----
  222.             0, filevec[1].nondiscarded_lines);
  223.   
  224.     bdiag -= filevec[1].nondiscarded_lines + 1;
  225.     fdiag -= filevec[1].nondiscarded_lines + 1;
  226. + #ifdef MSDOS
  227. +   hfree (bdiag);
  228. +   hfree (fdiag);
  229. + #else
  230. +   free (bdiag);
  231.     free (fdiag);
  232. + #endif
  233.   
  234.     /* Modify the results slightly to make them prettier
  235.        in cases where that can validly be done.  */
  236. ***************
  237. *** 814,828 ****
  238.       {
  239.         setup_output (files[0].name, files[1].name, depth);
  240.   
  241.         switch (output_style)
  242.       {
  243.       case OUTPUT_CONTEXT:
  244. !       print_context_header (files, 0);
  245.         print_context_script (script, 0);
  246.         break;
  247.   
  248.       case OUTPUT_UNIFIED:
  249. !       print_context_header (files, 1);
  250.         print_context_script (script, 1);
  251.         break;
  252.   
  253. --- 884,903 ----
  254.       {
  255.         setup_output (files[0].name, files[1].name, depth);
  256.   
  257. +       if (output_style == OUTPUT_CONTEXT ||
  258. +           output_style == OUTPUT_UNIFIED ||
  259. +           output_patch_flag)
  260. +       print_context_header (files, output_style == OUTPUT_UNIFIED);
  261.         switch (output_style)
  262.       {
  263.       case OUTPUT_CONTEXT:
  264. !       /* print_context_header (files, 0); */
  265.         print_context_script (script, 0);
  266.         break;
  267.   
  268.       case OUTPUT_UNIFIED:
  269. !       /* print_context_header (files, 1); */
  270.         print_context_script (script, 1);
  271.         break;
  272.   
  273. ***************
  274. *** 845,850 ****
  275. --- 920,929 ----
  276.       case OUTPUT_IFDEF:
  277.         print_ifdef_script (script);
  278.         break;
  279. +     case OUTPUT_MERGED:
  280. +       print_merged_script (script);
  281. +       break;
  282.       }
  283.   
  284.         finish_output ();
  285. ***************
  286. *** 899,907 ****
  287. --- 978,994 ----
  288.   
  289.     for (i = 0; i < 2; ++i)
  290.       {
  291. + #if !defined(MSDOS)
  292.         if (filevec[i].buffer != 0)
  293.       free (filevec[i].buffer);
  294.         free (filevec[i].linbuf);
  295. + #else /* MSDOS */
  296. +       if (filevec[i].buffer != 0)
  297. +         hfree (filevec[i].buffer);
  298. +       hfree (filevec[i].linbuf);
  299. + #endif
  300.       }
  301.   
  302.     for (e = script; e; e = p)
  303. diff -cbBw orig/context.c diff/context.c
  304. *** orig/context.c    Mon Jan 28 20:17:46 1991
  305. --- diff/context.c    Thu Jan 17 23:07:24 1991
  306. ***************
  307. *** 43,49 ****
  308.     if (label)
  309.       fprintf (outfile, "%s %s\n", mark, label);
  310.     else if (inf->stat.st_mtime)
  311. !     fprintf (outfile, "%s %s\t%s", mark, inf->name, ctime(&inf->stat.st_mtime));
  312.     else
  313.       /* Don't pretend that standard input is ancient.  */
  314.       fprintf (outfile, "%s %s\n", mark, inf->name);
  315. --- 43,54 ----
  316.     if (label)
  317.       fprintf (outfile, "%s %s\n", mark, label);
  318.     else if (inf->stat.st_mtime)
  319. !   {
  320. !     char *ct = ctime(&inf->stat.st_mtime);
  321. !     /* some ctime()'s return NULL on illegal times
  322. !        which may occur sometimes under DOS ... */
  323. !     fprintf (outfile, "%s %s\t%s", mark, inf->name, ct ? ct : "\n");
  324. !   }
  325.     else
  326.       /* Don't pretend that standard input is ancient.  */
  327.       fprintf (outfile, "%s %s\n", mark, inf->name);
  328. ***************
  329. *** 51,61 ****
  330. --- 56,90 ----
  331.   
  332.   /* Print a header for a context diff, with the file names and dates.  */
  333.   
  334. + #ifdef MSDOS
  335. + void dosname(char *ptr)
  336. + {
  337. +   for ( ; *ptr; ptr++ )
  338. +     if ( *ptr == '\\' )
  339. +       *ptr = '/';
  340. +     /* else
  341. +       *ptr = tolower(*ptr); */
  342. + }
  343. + #endif
  344.   void
  345.   print_context_header (inf, unidiff_flag)
  346.        struct file_data *inf;
  347.        int unidiff_flag;
  348.   {
  349. + #ifdef MSDOS
  350. +   dosname(inf[0].name);
  351. +   dosname(inf[1].name);
  352. + #endif
  353. +   if (output_patch_flag)
  354. +     {
  355. +       char *cp = strlen (inf[0].name) <= strlen (inf[1].name)
  356. +         ? inf[0].name : inf[1].name;
  357. +       if (cp[0] == '.' && cp[1] == '/')
  358. +     cp += 2;
  359. +       fprintf (outfile, "Index: %s\n", cp);
  360. +       return;
  361. +     }
  362.     if (unidiff_flag)
  363.       {
  364.         print_context_label ("---", &inf[0], file_label[0]);
  365. ***************
  366. *** 397,403 ****
  367.         script->link = next;
  368.   
  369.         /* If the change is ignorable, mark it.  */
  370. !       script->ignore = (!deletes && !inserts);
  371.   
  372.         /* Advance to the following change.  */
  373.         script = next;
  374. --- 426,432 ----
  375.         script->link = next;
  376.   
  377.         /* If the change is ignorable, mark it.  */
  378. !       script->ignore = (char) (!deletes && !inserts);
  379.   
  380.         /* Advance to the following change.  */
  381.         script = next;
  382. diff -cbBw orig/diff.c diff/diff.c
  383. *** orig/diff.c    Mon Jan 28 20:19:56 1991
  384. --- diff/diff.c    Thu Jan 17 23:47:22 1991
  385. ***************
  386. *** 95,100 ****
  387. --- 95,101 ----
  388.     {"print", 0, 0, 'l'},
  389.     {"rcs", 0, 0, 'n'},
  390.     {"show-c-function", 0, 0, 'p'},
  391. +   {"patch", 0, 0, 'P'},
  392.     {"binary", 0, 0, 'q'},
  393.     {"brief", 0, 0, 'q'},
  394.     {"recursive", 0, 0, 'r'},
  395. ***************
  396. *** 139,153 ****
  397.     paginate_flag = FALSE;
  398.     ifdef_string = NULL;
  399.     heuristic = FALSE;
  400.     dir_start_file = NULL;
  401.     msg_chain = NULL;
  402.     msg_chain_end = NULL;
  403.     no_discards = 0;
  404.   
  405.     /* Decode the options.  */
  406.   
  407.     while ((c = getopt_long (argc, argv,
  408. !                "0123456789abBcC:dD:efF:hHiI:lL:nNpqrsS:tTuvw",
  409.                  longopts, &longind)) != EOF)
  410.       {
  411.         if (c == 0)        /* Long option. */
  412. --- 140,156 ----
  413.     paginate_flag = FALSE;
  414.     ifdef_string = NULL;
  415.     heuristic = FALSE;
  416. +   output_patch_flag = 0;
  417.     dir_start_file = NULL;
  418.     msg_chain = NULL;
  419.     msg_chain_end = NULL;
  420.     no_discards = 0;
  421. +   line_width = 0;
  422.   
  423.     /* Decode the options.  */
  424.   
  425.     while ((c = getopt_long (argc, argv,
  426. !                "0123456789abBcC:dD:efF:hHiI:lL:mM:nNpPqrsS:tTuvw",
  427.                  longopts, &longind)) != EOF)
  428.       {
  429.         if (c == 0)        /* Long option. */
  430. ***************
  431. *** 283,288 ****
  432. --- 286,303 ----
  433.           fatal ("too many file label options");
  434.         break;
  435.   
  436. +     case 'm':
  437. +       /* Make output merged in side-by-side display. */
  438. +       specify_style (OUTPUT_MERGED);
  439. +       line_width = 80;
  440. +       break;
  441. +     case 'M':
  442. +       /* Make output merged in side-by-side display. */
  443. +       specify_style (OUTPUT_MERGED);
  444. +       line_width = atoi(optarg);
  445. +       break;
  446.       case 'n':
  447.         /* Output RCS-style diffs, like `-f' except that each command
  448.            specifies the number of lines affected.  */
  449. ***************
  450. *** 301,306 ****
  451. --- 316,325 ----
  452.         function_regexp = "^[_a-zA-Z]";
  453.         break;
  454.   
  455. +     case 'P':
  456. +       output_patch_flag = 1;
  457. +       break;
  458.       case 'q':
  459.         no_details_flag = 1;
  460.         break;
  461. ***************
  462. *** 399,411 ****
  463.     exit (val);
  464.   }
  465.   
  466.   usage ()
  467.   {
  468.     fprintf (stderr, "\
  469. ! Usage: diff [-#] [-abBcdefhHilnNprstTuvw] [-C lines] [-F regexp] [-I regexp]\n\
  470.          [-L label [-L label]] [-S file] [-D symbol] [+ignore-blank-lines]\n\
  471.          [+context[=lines]] [+unified[=lines]] [+ifdef=symbol]\n\
  472. !        [+show-function-line=regexp]\n");
  473.     fprintf (stderr, "\
  474.          [+speed-large-files] [+ignore-matching-lines=regexp] [+new-file]\n\
  475.          [+initial-tab] [+starting-file=file] [+text] [+all-text] [+ascii]\n\
  476. --- 418,495 ----
  477.     exit (val);
  478.   }
  479.   
  480. + #ifdef MSDOS
  481. + extern char *version_string;
  482. + usage()
  483. + {
  484. +   printf("\nGNU diff, version %s\n", version_string);
  485. +   printf("\nUsage: %s [-options] file1 file2\n\n", program);
  486. +   printf(
  487. +   "  -c      Make context-style output.\n"
  488. +   "  -p      Make context-style output and show name of last C function.\n"
  489. +   "  -C n    Make context-style output and define context size to be n lines.\n"
  490. +   "  -u      Make unified-context-style output.\n"
  491. +   "  -D      Make merged #ifdef output.\n"
  492. +   "  -e      Make output that is a valid `ed' script.\n"
  493. +   "  -f      Make output that looks vaguely like an `ed' script\n"
  494. +   "          but has changes in the order they appear in the file.\n"
  495. +   "  -n      Make RCS-style output, like `-f' except that each command\n"
  496. +   "          specifies the number of lines affected.\n"
  497. +   "  -m      Make side-by-side merged output.\n"
  498. +   "  -M n    Make side-by-side merged output and specify page-width.\n\n"
  499. +   );
  500. +   printf(
  501. +   "  -[0-9]  digits combined into decimal to specify the context-size.\n"
  502. +   "  -a      Treat all files as text files; never treat as binary.\n"
  503. +   "  -b      Ignore changes in amount of whitespace.\n"
  504. +   "  -B      Ignore changes affecting only blank lines.\n"
  505. +   "  -d      Don't discard lines. This makes things slower (sometimes much\n"
  506. +   "          slower) but will find a guaranteed minimal set of changes.\n"
  507. +   );
  508. +   printf(
  509. +   "  -F re   Show, for each set of changes, the previous line that matches the\n"
  510. +   "          specified regexp. Currently affects only context-style output.\n"
  511. +   "  -h      Split the files into chunks of around 1500 lines\n"
  512. +   "          for faster processing. Usually does not change the result.\n"
  513. +   "  -H      Use heuristic.\n"
  514. +   "  -i      Ignore changes in case.\n"
  515. +   "  -I re   Ignore changes affecting only lines that match the specified regexp.\n"
  516. +   "  -l      Pass the output through `pr' to paginate it.\n"
  517. +   "  -L label [-L label]\n"
  518. +   "          Use the specified label in file header lines output by the -c option.\n"
  519. +   );
  520. +   printf(
  521. +   "  -N      When comparing directories, if a file appears only in one\n"
  522. +   "          directory, treat it as present but empty in the other.\n"
  523. +   "  -P      Create patch headers (Index: ...).\n"
  524. +   "  -q      Treat all files as binaries.\n"
  525. +   "  -r      When comparing directories, recursively compare subdir's found.\n"
  526. +   "  -s      Print a message if the files are the same.\n"
  527. +   );
  528. +   printf(
  529. +   "  -S file When comparing directories, start with the specified\n"
  530. +   "          file name. This is used for resuming an aborted comparison.\n"
  531. +   "  -t      Expand tabs to spaces in the output so that it preserves\n"
  532. +   "          the alignment of the input files.\n"
  533. +   "  -T      Use a tab in the output, rather than a space, before the\n"
  534. +   "          text of an input line, so as to keep the proper alignment\n"
  535. +   "          in the input line without changing the characters in it.\n"
  536. +   "  -v      Print version number.\n"
  537. +   "  -w      Ignore horizontal whitespace when comparing lines.\n"
  538. +   );
  539. +   exit(2);
  540. + }
  541. + #else
  542.   usage ()
  543.   {
  544.     fprintf (stderr, "\
  545. ! Usage: diff [-#] [-abBcdefhHilnNpPrstTuvw] [-C lines] [-F regexp] [-I regexp]\n\
  546.          [-L label [-L label]] [-S file] [-D symbol] [+ignore-blank-lines]\n\
  547.          [+context[=lines]] [+unified[=lines]] [+ifdef=symbol]\n\
  548. !        [+show-function-line=regexp] [+patch]\n");
  549.     fprintf (stderr, "\
  550.          [+speed-large-files] [+ignore-matching-lines=regexp] [+new-file]\n\
  551.          [+initial-tab] [+starting-file=file] [+text] [+all-text] [+ascii]\n\
  552. ***************
  553. *** 416,421 ****
  554. --- 500,506 ----
  555.          [+file-label=label [+file-label=label]] [+version] path1 path2\n");
  556.     exit (2);
  557.   }
  558. + #endif
  559.   
  560.   specify_style (style)
  561.        enum output_style style;
  562. ***************
  563. *** 455,460 ****
  564. --- 540,546 ----
  565.       {
  566.         char *name = name0 == 0 ? name1 : name0;
  567.         char *dir = name0 == 0 ? dir1 : dir0;
  568. +       if (!output_patch_flag)
  569.       message ("Only in %s: %s\n", dir, name);
  570.         /* Return 1 so that diff_dirs will return 1 ("some files differ").  */
  571.         return 1;
  572. ***************
  573. *** 506,511 ****
  574. --- 592,604 ----
  575.       }
  576.       }
  577.   
  578. + #if !defined(MSDOS)
  579. +       /*
  580. +       ** this stuff is real bad idea under MSDOS, at least for MSC 5.1
  581. +       ** because the st_ino and st_dev fields are not supported by
  582. +       ** MSDOS, and so stat sets them to zero; therefore
  583. +       ** this test always succeeds.
  584. +       */
  585.     /* See if the two named files are actually the same physical file.
  586.        If so, we know they are identical without actually reading them.  */
  587.   
  588. ***************
  589. *** 518,523 ****
  590. --- 611,617 ----
  591.         val = 0;
  592.         goto done;
  593.       }
  594. + #endif        /* MSDOS */
  595.   
  596.     if (name0 == 0)
  597.       inf[0].dir_p = inf[1].dir_p;
  598. ***************
  599. *** 536,545 ****
  600.         inf[i].name = Standard_Input;
  601.       }
  602.         /* Don't bother opening if stat already failed.  */
  603. !       else if (stat_result[i] == 0 && ! inf[i].dir_p)
  604.       {
  605.         char *filename = inf[i].name;
  606.         inf[i].desc = open (filename, O_RDONLY, 0);
  607.         if (0 > inf[i].desc)
  608.           {
  609. --- 630,648 ----
  610.         inf[i].name = Standard_Input;
  611.       }
  612.         /* Don't bother opening if stat already failed.  */
  613. !       else if (stat_result[i] == 0)
  614.       {
  615.         char *filename = inf[i].name;
  616. ! #if !defined(MSDOS)
  617. !       inf[i].desc = open (filename, O_RDONLY, 0);
  618. !       if (0 > inf[i].desc)
  619. !         {
  620. !           perror_with_name (filename);
  621. !           errorcount = 1;
  622. !         }
  623. ! #else
  624. !           if(inf[i].dir_p == 0)
  625. !           {
  626.         inf[i].desc = open (filename, O_RDONLY, 0);
  627.         if (0 > inf[i].desc)
  628.           {
  629. ***************
  630. *** 546,554 ****
  631. --- 649,665 ----
  632.             perror_with_name (filename);
  633.             errorcount = 1;
  634.           }
  635. +           } else
  636. +                 inf[i].desc = 0;
  637. + #endif    /* MSDOS */
  638.       }
  639.       }
  640.   
  641. +   if (name0 == 0)
  642. +     inf[0].dir_p = inf[1].dir_p;
  643. +   if (name1 == 0)
  644. +     inf[1].dir_p = inf[0].dir_p;
  645.     if (errorcount)
  646.       {
  647.   
  648. ***************
  649. *** 568,573 ****
  650. --- 679,685 ----
  651.       {
  652.         /* But don't compare dir contents one level down
  653.            unless -r was specified.  */
  654. +       if (!output_patch_flag)
  655.           message ("Common subdirectories: %s and %s\n",
  656.              inf[0].name, inf[1].name);
  657.         val = 0;
  658. ***************
  659. *** 637,642 ****
  660. --- 749,755 ----
  661.         else
  662.           {
  663.             char *dir = (inf[0].desc == -1) ? dir1 : dir0;
  664. +           if (!output_patch_flag)
  665.           message ("Only in %s: %s\n", dir, name0);
  666.             val = 1;
  667.           }
  668. diff -cbBw orig/diff.h diff/diff.h
  669. *** orig/diff.h    Mon Jan 28 20:17:56 1991
  670. --- diff/diff.h    Thu Jan 17 23:26:02 1991
  671. ***************
  672. *** 23,28 ****
  673. --- 23,30 ----
  674.   #include <sys/types.h>
  675.   #include <sys/stat.h>
  676.   
  677. + #include <string.h>
  678.   #ifdef USG
  679.   #include <time.h>
  680.   #ifdef HAVE_NDIR
  681. ***************
  682. *** 32,38 ****
  683. --- 34,42 ----
  684.   #include <ndir.h>
  685.   #endif /* not NDIR_IN_SYS */
  686.   #else
  687. + #ifndef MSDOS
  688.   #include <dirent.h>
  689. + #endif
  690.   #endif /* not HAVE_NDIR */
  691.   #include <fcntl.h>
  692.   #ifndef HAVE_DIRECT
  693. ***************
  694. *** 47,59 ****
  695. --- 51,69 ----
  696.   #ifdef USG
  697.   /* Define needed BSD functions in terms of sysV library.  */
  698.   
  699. + #ifdef MSDOS
  700. + #define bcopy(s,d,n)    memmove((d),(s),(n))
  701. + #else
  702.   #define bcopy(s,d,n)    memcpy((d),(s),(n))
  703. + #endif
  704.   #define bcmp(s1,s2,n)    memcmp((s1),(s2),(n))
  705.   #define bzero(s,n)    memset((s),0,(n))
  706.   
  707.   #ifndef XENIX
  708. + #ifndef MSDOS
  709.   #define dup2(f,t)    (close(t),fcntl((f),F_DUPFD,(t)))
  710.   #endif
  711. + #endif
  712.   
  713.   #define vfork    fork
  714.   #define index    strchr
  715. ***************
  716. *** 65,81 ****
  717. --- 75,100 ----
  718.   #define vfork fork
  719.   #endif
  720.   
  721. + #ifdef MSDOS
  722. + #include <process.h>
  723. + #include <stdlib.h>
  724. + #endif /* MSDOS */
  725.   #include <errno.h>
  726. + #if !defined(MSDOS)
  727.   extern int      errno;
  728.   extern int      sys_nerr;
  729.   extern char    *sys_errlist[];
  730. + #endif
  731.   
  732.   #define    EOS        (0)
  733.   #define    FALSE        (0)
  734.   #define TRUE        1
  735.   
  736. + #if !defined(min)
  737.   #define min(a,b) ((a) <= (b) ? (a) : (b))
  738.   #define max(a,b) ((a) >= (b) ? (a) : (b))
  739. + #endif /* MSDOS */
  740.   
  741.   #ifndef PR_FILE_NAME
  742.   #define PR_FILE_NAME "/bin/pr"
  743. ***************
  744. *** 83,96 ****
  745.   
  746.   /* Support old-fashioned C compilers.  */
  747.   #if defined (__STDC__) || defined (__GNUC__)
  748.   #include "limits.h"
  749.   #else
  750.   #define INT_MAX 2147483647
  751.   #define CHAR_BIT 8
  752.   #endif
  753.   
  754.   /* Support old-fashioned C compilers.  */
  755. ! #if !defined (__STDC__) && !defined (__GNUC__)
  756.   #define const
  757.   #endif
  758.   
  759. --- 102,130 ----
  760.   
  761.   /* Support old-fashioned C compilers.  */
  762.   #if defined (__STDC__) || defined (__GNUC__)
  763. + #if !defined(MSDOS)
  764.   #include "limits.h"
  765.   #else
  766. + #include <limits.h>
  767. + #endif        /* MSDOS */
  768. + #else
  769.   #define INT_MAX 2147483647
  770.   #define CHAR_BIT 8
  771.   #endif
  772.   
  773. + #if defined(MSDOS)
  774. + #ifdef INT_MAX
  775. + #undef INT_MAX
  776. + #include <limits.h>
  777. + #endif
  778. + #include <malloc.h>
  779. + #include <io.h>
  780. + #include <memory.h>
  781. + extern int getopt(int nargc,char **nargv,char *ostr);
  782. + #endif
  783.   /* Support old-fashioned C compilers.  */
  784. ! #if !defined (__STDC__) && !defined (__GNUC__) || defined(MSDOS)
  785.   #define const
  786.   #endif
  787.   
  788. ***************
  789. *** 120,126 ****
  790.     /* Like -f, but output a count of changed lines in each "command" (-n). */
  791.     OUTPUT_RCS,
  792.     /* Output merged #ifdef'd file (-D).  */
  793. !   OUTPUT_IFDEF };
  794.   
  795.   /* True for output styles that are robust,
  796.      i.e. can handle a file that ends in a non-newline.  */
  797. --- 154,163 ----
  798.     /* Like -f, but output a count of changed lines in each "command" (-n). */
  799.     OUTPUT_RCS,
  800.     /* Output merged #ifdef'd file (-D).  */
  801. !   OUTPUT_IFDEF,
  802. !   /* Output merged in side-by-side display (-m). */
  803. !   OUTPUT_MERGED
  804. ! };
  805.   
  806.   /* True for output styles that are robust,
  807.      i.e. can handle a file that ends in a non-newline.  */
  808. ***************
  809. *** 199,204 ****
  810. --- 236,244 ----
  811.   /* Pipe each file's output through pr (-l).  */
  812.   EXTERN int    paginate_flag;
  813.   
  814. + /* Line width for the merged display (-m,-M).  */
  815. + EXTERN int    line_width;
  816.   /* String to use for #ifdef (-D).  */
  817.   EXTERN char *    ifdef_string;
  818.   
  819. ***************
  820. *** 210,215 ****
  821. --- 250,258 ----
  822.   /* Nonzero means use heuristics for better speed.  */
  823.   EXTERN int    heuristic;
  824.   
  825. + /* Reduce extraneous output when they're outputting a patch. */
  826. + EXTERN int    output_patch_flag;
  827.   /* Name of program the user invoked (for error messages).  */
  828.   EXTERN char *    program;
  829.   
  830. ***************
  831. *** 239,245 ****
  832. --- 282,292 ----
  833.   /* Data on one line of text.  */
  834.   
  835.   struct line_def {
  836. + #ifdef MSDOS
  837. +     char _huge  *text;
  838. + #else
  839.       char        *text;
  840. + #endif
  841.       int         length;
  842.       unsigned    hash;
  843.   };
  844. ***************
  845. *** 252,257 ****
  846. --- 299,305 ----
  847.       struct stat     stat;    /* File status from fstat()  */
  848.       int             dir_p;    /* 1 if file is a directory  */
  849.   
  850. + #if !defined(MSDOS)
  851.       /* Buffer in which text of file is read.  */
  852.       char *        buffer;
  853.       /* Allocated size of buffer.  */
  854. ***************
  855. *** 279,284 ****
  856. --- 327,361 ----
  857.   
  858.       /* Count of lines in the suffix. */
  859.       int suffix_lines;
  860. + #else /* MSDOS */
  861. +     /* Buffer in which text of file is read.  */
  862. +     char _huge *buffer;
  863. +     /* Allocated size of buffer.  */
  864. +     long int        bufsize;
  865. +     /* Number of valid characters now in the buffer. */
  866. +     long int        buffered_chars;
  867. +     /* Array of data on analyzed lines of this chunk of this file.  */
  868. +     struct line_def _huge *linbuf;
  869. +     /* Allocated size of linbuf array (# of elements).  */
  870. +     int            linbufsize;
  871. +     /* Number of elements of linbuf containing valid data. */
  872. +     int            buffered_lines;
  873. +     /* Pointer to end of prefix of this file to ignore when hashing. */
  874. +     char _huge *prefix_end;
  875. +     /* Count of lines in the prefix. */
  876. +     int prefix_lines;
  877. +     /* Pointer to start of suffix of this file to ignore when hashing. */
  878. +     char _huge *suffix_begin;
  879. +     /* Count of lines in the suffix. */
  880. +     int suffix_lines;
  881. + #endif        /* MSDOS */
  882.   
  883.       /* Vector, indexed by line number, containing an equivalence code for
  884.          each line.  It is this vector that is actually compared with that
  885. ***************
  886. *** 366,370 ****
  887. --- 443,456 ----
  888.   void print_1_line ();
  889.   void print_message_queue ();
  890.   void print_number_range ();
  891. + #ifdef MSDOS
  892. + void _huge *hrealloc(void _huge *, long, long);
  893. + #endif
  894.   void print_script ();
  895.   void translate_range ();
  896. + #ifdef PROTO
  897. + #include "proto.h"
  898. + #endif
  899. diff -cbBw orig/diff3.c diff/diff3.c
  900. *** orig/diff3.c    Mon Jan 28 20:18:04 1991
  901. --- diff/diff3.c    Thu Jan 17 23:07:26 1991
  902. ***************
  903. *** 32,37 ****
  904. --- 32,61 ----
  905.   #include <sys/types.h>
  906.   #include <sys/stat.h>
  907.   
  908. + #include <getopt.h>
  909. + #ifdef OS2
  910. + #include <stdlib.h>
  911. + extern FILE *popen(char *, char *);
  912. + extern int pclose(FILE *);
  913. + #define WEXITSTATUS(stat_val)  (stat_val & 255)
  914. + #define WIFEXITED(stat_val)    (((unsigned)stat_val >> 8) == 0)
  915. + /* pclose() returns status in inverse byte order than wait() does */
  916. + #define bcopy(s,d,n)    memmove((d),(s),(n))
  917. + #define bcmp(s1,s2,n)    memcmp((s1),(s2),(n))
  918. + #define bzero(s,n)    memset((s),0,(n))
  919. + #define index    strchr
  920. + #define rindex    strrchr
  921. + #else  /* OS2 */
  922. + extern char **environ;
  923.   #ifdef USG
  924.   #include <fcntl.h>
  925.   
  926. ***************
  927. *** 58,63 ****
  928. --- 82,89 ----
  929.   #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
  930.   #endif
  931.   
  932. + #endif /* OS2 */
  933.   #ifdef sparc
  934.   /* vfork clobbers registers on the Sparc, so don't use it.  */
  935.   #define vfork fork
  936. ***************
  937. *** 390,398 ****
  938.   void
  939.   usage ()
  940.   {
  941. !   fprintf (stderr, "Usage:\t%s [-exEX3 [-i | -m] [-L label1 -L label3]] file1 file2 file3\n",
  942.          argv0);
  943. !   fprintf (stderr, "\tOnly one of [exEX3] allowed\n");
  944.     exit (2);
  945.   }
  946.   
  947. --- 416,438 ----
  948.   void
  949.   usage ()
  950.   {
  951. !   extern char *version_string;
  952. !   printf ("\nGNU diff3, version %s\n", version_string);
  953. !   printf ("\nUsage:\t%s [-exEX3 [-a] [-i | -m] [-L label1 -L label3]] file1 file2 file3\n",
  954.          argv0);
  955. !   printf ("\n  -e   Create ed script."
  956. !           "\n  -x   ED script, write only overlapping diffs."
  957. !           "\n  -E   ED script, flag overlapping diffs."
  958. !           "\n  -X   ED script, write and flag only overlapping diffs."
  959. !           "\n  -3   ED script, write only non-overlapping diffs."
  960. !           "\n  -a   Treat all files as text, never as binary."
  961. !           "\n  -i   Like -e, but append final :wq commands."
  962. !           "\n  -m   Output a merged file."
  963. !           "\n  -L label   use the specified label for lines output by the -E and -X options.\n");
  964. !   printf ("\nOnly one of [exEX3] is allowed.\n");
  965.     exit (2);
  966.   }
  967.   
  968. ***************
  969. *** 960,967 ****
  970.    * Routines to input and parse two way diffs.
  971.    */
  972.   
  973. - extern char **environ;
  974.   #define    DIFF_CHUNK_SIZE    10000
  975.   
  976.   struct diff_block *
  977. --- 1000,1005 ----
  978. ***************
  979. *** 1170,1182 ****
  980. --- 1208,1227 ----
  981.        char *filea, *fileb;
  982.        char **output_placement;
  983.   {
  984. + #ifndef OS2
  985.     char *argv[6];
  986.     char **ap;
  987. + #endif
  988.     int fds[2];
  989.     char *diff_result;
  990.     int current_chunk_size;
  991.     int bytes;
  992.     int total;
  993. + #ifdef OS2
  994. +   FILE *pipe;
  995. +   char buffer[256];
  996. +   int wstatus;
  997. + #else
  998.     int pid, w;
  999.     int wstatus;
  1000.   
  1001. ***************
  1002. *** 1188,1194 ****
  1003. --- 1233,1245 ----
  1004.     *ap++ = filea;
  1005.     *ap++ = fileb;
  1006.     *ap = (char *) 0;
  1007. + #endif
  1008.   
  1009. + #ifdef OS2
  1010. +   sprintf(buffer, "%s -a -- %s %s", diff_program, filea, fileb);
  1011. +   pipe = popen(buffer, "r");
  1012. +   fds[0] = fileno(pipe);
  1013. + #else
  1014.     if (pipe (fds) < 0)
  1015.       perror_with_exit ("Pipe failed");
  1016.   
  1017. ***************
  1018. *** 1213,1218 ****
  1019. --- 1264,1270 ----
  1020.       perror_with_exit ("Fork failed");
  1021.   
  1022.     close (fds[1]);        /* Prevent erroneous lack of EOF */
  1023. + #endif
  1024.     current_chunk_size = DIFF_CHUNK_SIZE;
  1025.     diff_result = (char *) xmalloc (current_chunk_size);
  1026.     total = 0;
  1027. ***************
  1028. *** 1222,1228 ****
  1029. --- 1274,1285 ----
  1030.               current_chunk_size - total);
  1031.       total += bytes;
  1032.       if (total == current_chunk_size)
  1033. + #ifdef OS2
  1034. +       diff_result = (char *) xrealloc (diff_result,
  1035. +         (current_chunk_size += DIFF_CHUNK_SIZE));
  1036. + #else
  1037.         diff_result = (char *) xrealloc (diff_result, (current_chunk_size *= 2));
  1038. + #endif
  1039.     } while (bytes);
  1040.   
  1041.     if (total != 0 && diff_result[total-1] != '\n')
  1042. ***************
  1043. *** 1230,1239 ****
  1044. --- 1287,1300 ----
  1045.   
  1046.     *output_placement = diff_result;
  1047.   
  1048. + #ifdef OS2
  1049. +   wstatus = pclose(pipe);
  1050. + #else
  1051.     do
  1052.       if ((w = wait (&wstatus)) == -1)
  1053.         perror_with_exit ("Wait failed");
  1054.     while (w != pid);
  1055. + #endif
  1056.   
  1057.     if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
  1058.       fatal ("Subsidiary diff failed");
  1059. ***************
  1060. *** 1332,1338 ****
  1061.       case DIFF_3RD:
  1062.         oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
  1063.   
  1064. !       x[0] = oddoneout + '1';
  1065.         x[1] = '\0';
  1066.         dontprint = oddoneout==0;
  1067.         break;
  1068. --- 1393,1399 ----
  1069.       case DIFF_3RD:
  1070.         oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
  1071.   
  1072. !       x[0] = (char) (oddoneout + '1');
  1073.         x[1] = '\0';
  1074.         dontprint = oddoneout==0;
  1075.         break;
  1076. diff -cbBw orig/dir.c diff/dir.c
  1077. *** orig/dir.c    Mon Jan 28 20:18:06 1991
  1078. --- diff/dir.c    Thu Jan 17 23:07:26 1991
  1079. ***************
  1080. *** 31,36 ****
  1081. --- 31,176 ----
  1082.     char **files;            /* Sorted names of files in the dir */
  1083.   };
  1084.   
  1085. + #if defined(MSDOS)
  1086. + /*
  1087. + ** due to difference of opinion btw gnu and microsoft about what
  1088. + ** const means, const is defined away in diff.h, which causes warnings
  1089. + ** when compiling the headers.  This ugliness is avoided here.
  1090. + */
  1091. + #ifdef const
  1092. + #undef const
  1093. + #endif
  1094. + #include <string.h>
  1095. + #include <ctype.h>
  1096. + #ifdef OS2
  1097. + #define strcmp stricmp
  1098. +   /* stricmp() this is important for the HPFS because it is
  1099. +   /* case-preserving but NOT case-sensitive */
  1100. + #include <stdlib.h>
  1101. + #define INCL_NOPM
  1102. + #include <os2.h>
  1103. + #define _A_NORMAL        0x00
  1104. + #define _A_SUBDIR        0x10
  1105. + #define _MAX_NAME        256
  1106. + #else
  1107. + #include <dos.h>
  1108. + #define _MAX_NAME        13
  1109. + #endif
  1110. + struct direct {
  1111. +     char d_name[_MAX_NAME];
  1112. + };
  1113. + typedef struct _dir {
  1114. +         int first;
  1115. + #ifdef OS2
  1116. +         FILEFINDBUF find;
  1117. + #else
  1118. +         struct find_t dta;
  1119. + #endif
  1120. +     struct direct current;
  1121. + } DIR;
  1122. + #ifdef OS2
  1123. + static HDIR hdir;
  1124. + static USHORT count;
  1125. + static BOOL lower;
  1126. + #endif
  1127. + #ifdef OS2
  1128. + int IsFileSystemFAT(char *dir)
  1129. + {
  1130. +   USHORT nDrive;
  1131. +   ULONG lMap;
  1132. +   BYTE bData[64], bName[3];
  1133. +   USHORT cbData;
  1134. +   if ( _osmode == DOS_MODE )
  1135. +     return TRUE;
  1136. +   else
  1137. +   {
  1138. +     /* We separate FAT and HPFS file systems here.
  1139. +      * Filenames read from a FAT system are converted to lower case
  1140. +      * while the case of filenames read from a HPFS (and other future
  1141. +      * file systems, like Unix-compatibles) is preserved.
  1142. +      */
  1143. +     if ( isalpha(dir[0]) && (dir[1] == ':') )
  1144. +       nDrive = toupper(dir[0]) - '@';
  1145. +     else
  1146. +       DosQCurDisk(&nDrive, &lMap);
  1147. +     bName[0] = (char) (nDrive + '@');
  1148. +     bName[1] = ':';
  1149. +     bName[2] = 0;
  1150. +     cbData = sizeof(bData);
  1151. +     if ( !DosQFSAttach(bName, 0U, 1U, bData, &cbData, 0L) )
  1152. +       return !strcmp(bData + (*(USHORT *) (bData + 2) + 7), "FAT");
  1153. +     else
  1154. +       return FALSE;
  1155. +     /* End of this ugly code */
  1156. +   }
  1157. + }
  1158. + #endif
  1159. + DIR *
  1160. + opendir(char *name) {
  1161. +     char localname[_MAX_NAME];
  1162. +     DIR *rval = malloc(sizeof(DIR));
  1163. +     strcpy(localname,name);
  1164. +         strcat(localname,"/*.*");
  1165. + #ifdef OS2
  1166. +         lower = IsFileSystemFAT(name);
  1167. +         hdir = count = 1;
  1168. + #endif
  1169. +     if(rval == NULL ||
  1170. + #ifdef OS2
  1171. +            DosFindFirst(localname, &hdir, _A_NORMAL|_A_SUBDIR, &rval->find,
  1172. +                         sizeof(FILEFINDBUF), &count, 0L) != 0)
  1173. + #else
  1174. +           _dos_findfirst(localname,_A_NORMAL|_A_SUBDIR,&rval->dta) != 0)
  1175. + #endif
  1176. +                 return NULL;
  1177. +     rval->first = 1;
  1178. +     return rval;
  1179. + }
  1180. + void
  1181. + closedir(DIR *x) {
  1182. +     free(x);
  1183. + }
  1184. + struct direct *
  1185. + readdir(DIR *thisdir) {
  1186. +     /*
  1187. +     ** first time through, we don't need to look for a file
  1188. +     */
  1189. +         if(!thisdir->first) {
  1190. + #ifdef OS2
  1191. +                 if(DosFindNext(hdir, &thisdir->find, sizeof(FILEFINDBUF),
  1192. +                                &count) != 0)
  1193. + #else
  1194. +                 if(_dos_findnext(&thisdir->dta) != 0)
  1195. + #endif
  1196. +             return NULL;
  1197. +     } else
  1198. +                 thisdir->first = 0;
  1199. + #ifdef OS2
  1200. +         strcpy(thisdir->current.d_name,thisdir->find.achName);
  1201. + #else
  1202. +         strcpy(thisdir->current.d_name,thisdir->dta.name);
  1203. + #endif
  1204. +     /* thisdir->current.d_name[13] = '\0'; */
  1205. +         if ( lower )
  1206. +       strlwr(thisdir->current.d_name);
  1207. +     return &thisdir->current;
  1208. + }
  1209. + #endif /* MSDOS */
  1210.   static struct dirdata
  1211.   dir_sort (dirname, nonex)
  1212.        char *dirname;
  1213. ***************
  1214. *** 135,142 ****
  1215.   int
  1216.   diff_dirs (name1, name2, handle_file, depth, nonex1, nonex2)
  1217.        char *name1, *name2;
  1218.        int (*handle_file) ();
  1219. !      int nonex1, nonex2;
  1220.   {
  1221.     struct dirdata data1, data2;
  1222.     register int i1, i2;
  1223. --- 275,290 ----
  1224.   int
  1225.   diff_dirs (name1, name2, handle_file, depth, nonex1, nonex2)
  1226.        char *name1, *name2;
  1227. + #if !defined(MSDOS)
  1228.        int (*handle_file) ();
  1229. ! #else
  1230. !       /* sorry, rms, I can't live with the assumption that
  1231. !       ** sizeof(char *) == sizeof(int)
  1232. !       */
  1233. !       int (*handle_file)(char *dir0,char *name0,
  1234. !               char *dir1,char *name1,int depth);
  1235. ! #endif
  1236. !      int depth, nonex1, nonex2;
  1237.   {
  1238.     struct dirdata data1, data2;
  1239.     register int i1, i2;
  1240. diff -cbBw orig/getopt.c diff/getopt.c
  1241. *** orig/getopt.c    Mon Jan 28 20:18:10 1991
  1242. --- diff/getopt.c    Thu Jan 17 23:07:26 1991
  1243. ***************
  1244. *** 15,25 ****
  1245.      along with this program; if not, write to the Free Software
  1246.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  1247.   
  1248. ! #ifdef __STDC__
  1249.   #define CONST const
  1250.   #else
  1251.   #define CONST
  1252.   #endif
  1253.   
  1254.   /* This version of `getopt' appears to the caller like standard Unix `getopt'
  1255.      but it behaves differently for the user, since it allows the user
  1256. --- 15,28 ----
  1257.      along with this program; if not, write to the Free Software
  1258.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  1259.   
  1260. ! #if defined(__STDC__) || defined(MSDOS)
  1261.   #define CONST const
  1262.   #else
  1263.   #define CONST
  1264.   #endif
  1265. + #ifdef MSDOS
  1266. + #define STDC_HEADERS
  1267. + #endif
  1268.   
  1269.   /* This version of `getopt' appears to the caller like standard Unix `getopt'
  1270.      but it behaves differently for the user, since it allows the user
  1271. ***************
  1272. *** 44,51 ****
  1273. --- 47,58 ----
  1274.   #ifdef sparc
  1275.   #include <alloca.h>
  1276.   #else
  1277. + #ifdef MSDOS
  1278. + #include <malloc.h>
  1279. + #else
  1280.   char *alloca ();
  1281.   #endif
  1282. + #endif
  1283.   #endif /* not __GNUC__ */
  1284.   
  1285.   #if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
  1286. ***************
  1287. *** 72,77 ****
  1288. --- 79,86 ----
  1289.   char *malloc ();
  1290.   #endif
  1291.   
  1292. + static void exchange (char **);
  1293.   /* For communication from `getopt' to the caller.
  1294.      When `getopt' finds an option that takes an argument,
  1295.      the argument value is returned here.
  1296. ***************
  1297. *** 376,382 ****
  1298.          p++, option_index++)
  1299.       if (!strncmp (p->name, nextchar, s - nextchar))
  1300.         {
  1301. !         if (s - nextchar == strlen (p->name))
  1302.             {
  1303.           /* Exact match found.  */
  1304.           pfound = p;
  1305. --- 385,391 ----
  1306.          p++, option_index++)
  1307.       if (!strncmp (p->name, nextchar, s - nextchar))
  1308.         {
  1309. !         if (s - nextchar == (int) strlen (p->name))
  1310.             {
  1311.           /* Exact match found.  */
  1312.           pfound = p;
  1313. diff -cbBw orig/getopt.h diff/getopt.h
  1314. *** orig/getopt.h    Mon Jan 28 20:18:12 1991
  1315. --- diff/getopt.h    Thu Jan 17 23:07:26 1991
  1316. ***************
  1317. *** 70,76 ****
  1318.     int val;
  1319.   };
  1320.   
  1321. ! #ifdef __STDC__
  1322.   extern const struct option *_getopt_long_options;
  1323.   #else
  1324.   extern struct option *_getopt_long_options;
  1325. --- 70,76 ----
  1326.     int val;
  1327.   };
  1328.   
  1329. ! #if defined(__STDC__) || defined(MSDOS)
  1330.   extern const struct option *_getopt_long_options;
  1331.   #else
  1332.   extern struct option *_getopt_long_options;
  1333. ***************
  1334. *** 87,93 ****
  1335.   
  1336.   extern int option_index;
  1337.   
  1338. ! #ifdef __STDC__
  1339.   int getopt (int argc, char **argv, const char *shortopts);
  1340.   int getopt_long (int argc, char **argv, const char *shortopts,
  1341.            const struct option *longopts, int *longind);
  1342. --- 87,93 ----
  1343.   
  1344.   extern int option_index;
  1345.   
  1346. ! #if defined(__STDC__) || defined(MSDOS)
  1347.   int getopt (int argc, char **argv, const char *shortopts);
  1348.   int getopt_long (int argc, char **argv, const char *shortopts,
  1349.            const struct option *longopts, int *longind);
  1350. diff -cbBw orig/getopt1.c diff/getopt1.c
  1351. *** orig/getopt1.c    Mon Jan 28 20:18:14 1991
  1352. --- diff/getopt1.c    Thu Jan 17 23:07:26 1991
  1353. ***************
  1354. *** 17,23 ****
  1355.   
  1356.   #include "getopt.h"
  1357.   
  1358. ! #ifdef __STDC__
  1359.   #define CONST const
  1360.   #else
  1361.   #define CONST
  1362. --- 17,23 ----
  1363.   
  1364.   #include "getopt.h"
  1365.   
  1366. ! #if defined(__STDC__) || defined(MSDOS)
  1367.   #define CONST const
  1368.   #else
  1369.   #define CONST
  1370. ***************
  1371. *** 38,43 ****
  1372. --- 38,44 ----
  1373.     int val;
  1374.   
  1375.     _getopt_long_options = long_options;
  1376. +   _getopt_long_only = 0;
  1377.     val = getopt (argc, argv, options);
  1378.     if (val == 0 && opt_index != NULL)
  1379.       *opt_index = option_index;
  1380. diff -cbBw orig/io.c diff/io.c
  1381. *** orig/io.c    Mon Jan 28 20:18:20 1991
  1382. --- diff/io.c    Thu Jan 17 23:07:26 1991
  1383. ***************
  1384. *** 20,27 ****
  1385. --- 20,31 ----
  1386.   #include "diff.h"
  1387.   
  1388.   /* Rotate a value n bits to the left. */
  1389. + #if !defined(MSDOS)
  1390.   #define UINT_BIT (sizeof (unsigned) * CHAR_BIT)
  1391.   #define ROL(v, n) ((v) << (n) | (v) >> UINT_BIT - (n))
  1392. + #else
  1393. + #define ROL(v,n)  ((v) << (n) | (v) >> (sizeof(v) * CHAR_BIT) - (n))
  1394. + #endif
  1395.   
  1396.   /* Given a hash value and a new character, return a new hash value. */
  1397.   #define HASH(h, c) ((c) + ROL (h, 7))
  1398. ***************
  1399. *** 57,66 ****
  1400. --- 61,77 ----
  1401.       1, 1, 1, 1, 1, 1, 1, 1,
  1402.       1, 1, 1, 1, 1, 1, 1, 1,
  1403.       1, 1, 1, 1, 1, 1, 1, 0,
  1404. + #ifdef MSDOS
  1405. +     1, 1, 1, 1, 1, 1, 1, 1,
  1406. +     1, 1, 1, 1, 1, 1, 1, 1,
  1407. +     1, 1, 1, 1, 1, 1, 1, 1,
  1408. +     1, 1, 1, 1, 1, 1, 1, 1,
  1409. + #else
  1410.       0, 0, 0, 0, 0, 0, 0, 0,
  1411.       0, 0, 0, 0, 0, 0, 0, 0,
  1412.       0, 0, 0, 0, 0, 0, 0, 0,
  1413.       0, 0, 0, 0, 0, 0, 0, 0,
  1414. + #endif
  1415.       1, 1, 1, 1, 1, 1, 1, 1,
  1416.       1, 1, 1, 1, 1, 1, 1, 1,
  1417.       1, 1, 1, 1, 1, 1, 1, 1,
  1418. ***************
  1419. *** 101,106 ****
  1420. --- 112,118 ----
  1421.        beyond those that current->bufsize describes:
  1422.        one for a newline (in case the text does not end with one)
  1423.        and one for a sentinel in find_identical_ends.  */
  1424. + #if !defined(MSDOS)
  1425.     else if ((current->stat.st_mode & S_IFMT) == S_IFREG)
  1426.       {
  1427.         current->bufsize = current->stat.st_size;
  1428. ***************
  1429. *** 136,146 ****
  1430.         if (cc < 0)
  1431.       pfatal_with_name (current->name);
  1432.       }
  1433.   
  1434.     /* Check first part of file to see if it's a binary file.  */
  1435.     if (! always_text_flag
  1436.         && binary_file_p (current->buffer,
  1437. !             min (current->buffered_chars, binary_file_threshold)))
  1438.       return 1;
  1439.   
  1440.     /* If not binary, make sure text ends in a newline,
  1441. --- 148,191 ----
  1442.         if (cc < 0)
  1443.       pfatal_with_name (current->name);
  1444.       }
  1445. + #else /* MSDOS */
  1446. +   else {
  1447. +       int count;
  1448. +       char _huge *ptr;
  1449. +       char *buf;
  1450. +       current->bufsize = current->stat.st_size + 1;
  1451. +       if((current->buffer = halloc(current->bufsize + 2,sizeof(char))) == NULL)
  1452. +              fatal("virtual memory exhausted");
  1453. +       current->buffered_chars = 0;
  1454. +       ptr = current->buffer;
  1455. +      /* this kludge is the only way to prevent read() from segment
  1456. +       * wraparounds in real mode in a OS/2 family mode application  :-( :-(
  1457. +       */
  1458. +       if((buf = malloc(16384)) == NULL)
  1459. +              fatal("virtual memory exhausted");
  1460. +       while((count = read(current->desc, buf, 16384)) > 0)
  1461. +       {
  1462. +              memcpy(ptr, buf, count); /* memcpy is aware of huge pointers */
  1463. +              current->buffered_chars += count;
  1464. +              ptr += count;
  1465. +       }
  1466. +       free(buf);
  1467. +       if (count < 0)
  1468. +     pfatal_with_name (current->name);
  1469. +     }
  1470. + #endif        /* MSDOS */
  1471.   
  1472.     /* Check first part of file to see if it's a binary file.  */
  1473.     if (! always_text_flag
  1474.         && binary_file_p (current->buffer,
  1475. !             (int) min (current->buffered_chars, binary_file_threshold)))
  1476.       return 1;
  1477.   
  1478.     /* If not binary, make sure text ends in a newline,
  1479. ***************
  1480. *** 169,180 ****
  1481.   {
  1482.     unsigned h;
  1483.     int i;
  1484. !   unsigned char *p = (unsigned char *) current->prefix_end, *ip, c;
  1485.   
  1486.     /* Attempt to get a good initial guess as to the number of lines. */
  1487.     current->linbufsize = current->buffered_chars / 50 + 5;
  1488.     current->linbuf
  1489.       = (struct line_def *) xmalloc (current->linbufsize * sizeof (struct line_def));
  1490.   
  1491.     if (function_regexp || output_style == OUTPUT_IFDEF)
  1492.       {
  1493. --- 214,238 ----
  1494.   {
  1495.     unsigned h;
  1496.     int i;
  1497. ! #if !defined(MSDOS)
  1498. !   char *p = current->prefix_end, *ip, c;
  1499. ! #else
  1500. !   char _huge *p = (char _huge *) current->prefix_end;
  1501. !   char _huge *ip, c;
  1502. !   int old;
  1503. ! #endif
  1504.   
  1505.     /* Attempt to get a good initial guess as to the number of lines. */
  1506.     current->linbufsize = current->buffered_chars / 50 + 5;
  1507. + #if !defined(MSDOS)
  1508.     current->linbuf
  1509.       = (struct line_def *) xmalloc (current->linbufsize * sizeof (struct line_def));
  1510. + #else
  1511. +   current->linbuf
  1512. +     = halloc(current->linbufsize, sizeof(struct line_def));
  1513. +   if ( current->linbuf == NULL )
  1514. +     fatal("virtual memory exhausted");
  1515. + #endif
  1516.   
  1517.     if (function_regexp || output_style == OUTPUT_IFDEF)
  1518.       {
  1519. ***************
  1520. *** 183,189 ****
  1521.        but since we don't know how many, it's easiest to find them all.
  1522.        If -D is specified, we need all the lines of the first file.  */
  1523.         current->buffered_lines = 0;
  1524. !       p = (unsigned char *) current->buffer;
  1525.       }
  1526.     else
  1527.       {
  1528. --- 241,247 ----
  1529.        but since we don't know how many, it's easiest to find them all.
  1530.        If -D is specified, we need all the lines of the first file.  */
  1531.         current->buffered_lines = 0;
  1532. !       p = current->buffer;
  1533.       }
  1534.     else
  1535.       {
  1536. ***************
  1537. *** 195,212 ****
  1538.       current->buffered_lines = 0;
  1539.         for (i = 0; i < context + 1; ++i)
  1540.       /* Unless we are at the beginning, */
  1541. !     if ((char *) p != current->buffer)
  1542.         /* Back up at least 1 char until at the start of a line.  */
  1543. !       while ((char *) --p != current->buffer && p[-1] != '\n')
  1544.           ;
  1545.       }
  1546.   
  1547. !   while ((char *) p < current->suffix_begin)
  1548.       {
  1549.         h = 0;
  1550.         ip = p;
  1551.   
  1552. !       if (current->prefix_end <= (char *) p)
  1553.       {
  1554.         /* Hash this line until we find a newline. */
  1555.         if (ignore_case_flag)
  1556. --- 253,270 ----
  1557.       current->buffered_lines = 0;
  1558.         for (i = 0; i < context + 1; ++i)
  1559.       /* Unless we are at the beginning, */
  1560. !     if (p != current->buffer)
  1561.         /* Back up at least 1 char until at the start of a line.  */
  1562. !       while ( --p != current->buffer && p[-1] != '\n')
  1563.           ;
  1564.       }
  1565.   
  1566. !   while (p < current->suffix_begin)
  1567.       {
  1568.         h = 0;
  1569.         ip = p;
  1570.   
  1571. !       if (current->prefix_end <= p)
  1572.       {
  1573.         /* Hash this line until we find a newline. */
  1574.         if (ignore_case_flag)
  1575. ***************
  1576. *** 291,298 ****
  1577. --- 349,358 ----
  1578.         /* Maybe increase the size of the line table. */
  1579.         if (current->buffered_lines >= current->linbufsize)
  1580.       {
  1581. + #ifndef MSDOS
  1582.         while (current->buffered_lines >= current->linbufsize)
  1583.           current->linbufsize *= 2;
  1584.         current->linbuf
  1585.           = (struct line_def *) xrealloc (current->linbuf,
  1586.                           current->linbufsize
  1587. ***************
  1588. *** 297,304 ****
  1589.           = (struct line_def *) xrealloc (current->linbuf,
  1590.                           current->linbufsize
  1591.                           * sizeof (struct line_def));
  1592.       }
  1593. !       current->linbuf[current->buffered_lines].text = (char *) ip;
  1594.         current->linbuf[current->buffered_lines].length = p - ip + 1;
  1595.         current->linbuf[current->buffered_lines].hash = h;
  1596.         ++current->buffered_lines;
  1597. --- 357,377 ----
  1598.           = (struct line_def *) xrealloc (current->linbuf,
  1599.                           current->linbufsize
  1600.                           * sizeof (struct line_def));
  1601. + #else
  1602. +           old = current->linbufsize;
  1603. +       while (current->buffered_lines >= current->linbufsize)
  1604. +         current->linbufsize += 2048;
  1605. +       current->linbuf = hrealloc(current->linbuf,
  1606. +             (long) current->linbufsize * sizeof (struct line_def),
  1607. +             (long) old * sizeof (struct line_def));
  1608. +           if ( current->linbuf == NULL )
  1609. +              fatal("too many lines");
  1610. + #endif
  1611.       }
  1612. !       current->linbuf[current->buffered_lines].text = ip;
  1613.         current->linbuf[current->buffered_lines].length = p - ip + 1;
  1614.         current->linbuf[current->buffered_lines].hash = h;
  1615.         ++current->buffered_lines;
  1616. ***************
  1617. *** 307,313 ****
  1618. --- 380,390 ----
  1619.   
  1620.     i = 0;
  1621.     while ((i < context || output_style == OUTPUT_IFDEF)
  1622. + #ifndef MSDOS
  1623.        && (char *) p < current->buffer + current->buffered_chars)
  1624. + #else
  1625. +      && p < (char _huge *) current->buffer + current->buffered_chars)
  1626. + #endif
  1627.       {
  1628.         ip = p;
  1629.         while (*p++ != '\n')
  1630. ***************
  1631. *** 315,322 ****
  1632. --- 392,401 ----
  1633.         /* Maybe increase the size of the line table. */
  1634.         if (current->buffered_lines >= current->linbufsize)
  1635.       {
  1636. + #ifndef MSDOS
  1637.         while (current->buffered_lines >= current->linbufsize)
  1638.           current->linbufsize *= 2;
  1639.         current->linbuf
  1640.           = (struct line_def *) xrealloc (current->linbuf,
  1641.                           current->linbufsize
  1642. ***************
  1643. *** 321,328 ****
  1644.           = (struct line_def *) xrealloc (current->linbuf,
  1645.                           current->linbufsize
  1646.                           * sizeof (struct line_def));
  1647.       }
  1648. !       current->linbuf[current->buffered_lines].text = (char *) ip;
  1649.         current->linbuf[current->buffered_lines].length = p - ip;
  1650.         current->linbuf[current->buffered_lines].hash = 0;
  1651.         ++current->buffered_lines;
  1652. --- 400,420 ----
  1653.           = (struct line_def *) xrealloc (current->linbuf,
  1654.                           current->linbufsize
  1655.                           * sizeof (struct line_def));
  1656. + #else
  1657. +           old = current->linbufsize;
  1658. +       while (current->buffered_lines >= current->linbufsize)
  1659. +         current->linbufsize += 2048;
  1660. +       current->linbuf = hrealloc(current->linbuf,
  1661. +             (long) current->linbufsize * sizeof (struct line_def),
  1662. +             (long) old * sizeof (struct line_def));
  1663. +           if ( current->linbuf == NULL )
  1664. +              fatal("too many lines");
  1665. + #endif
  1666.       }
  1667. !       current->linbuf[current->buffered_lines].text = ip;
  1668.         current->linbuf[current->buffered_lines].length = p - ip;
  1669.         current->linbuf[current->buffered_lines].hash = 0;
  1670.         ++current->buffered_lines;
  1671. ***************
  1672. *** 342,348 ****
  1673. --- 434,444 ----
  1674.   find_identical_ends (filevec)
  1675.        struct file_data filevec[];
  1676.   {
  1677. + #ifndef MSDOS
  1678.     char *p0, *p1, *end0, *beg0;
  1679. + #else
  1680. +   char _huge *p0, _huge *p1, _huge *end0, _huge *beg0;
  1681. + #endif
  1682.     int lines;
  1683.   
  1684.     if (filevec[0].buffered_chars == 0 || filevec[1].buffered_chars == 0)
  1685. ***************
  1686. *** 383,397 ****
  1687.     /* Don't count missing newline as part of prefix in RCS mode. */
  1688.     if (ROBUST_OUTPUT_STYLE (output_style)
  1689.         && ((filevec[0].missing_newline
  1690. !        && p0 - filevec[0].buffer > filevec[0].buffered_chars)
  1691.         ||
  1692.         (filevec[1].missing_newline
  1693. !        && p1 - filevec[1].buffer > filevec[1].buffered_chars)))
  1694.       --p0, --p1, --lines;
  1695.   
  1696.     /* If the sentinel was passed, and lengths are equal, the
  1697.        files are identical.  */
  1698. !   if (p0 - filevec[0].buffer > filevec[0].buffered_chars
  1699.         && filevec[0].buffered_chars == filevec[1].buffered_chars)
  1700.       {
  1701.         filevec[0].prefix_end = p0 - 1;
  1702. --- 479,493 ----
  1703.     /* Don't count missing newline as part of prefix in RCS mode. */
  1704.     if (ROBUST_OUTPUT_STYLE (output_style)
  1705.         && ((filevec[0].missing_newline
  1706. !        && (p0 - filevec[0].buffer) > filevec[0].buffered_chars)
  1707.         ||
  1708.         (filevec[1].missing_newline
  1709. !        && (p1 - filevec[1].buffer) > filevec[1].buffered_chars)))
  1710.       --p0, --p1, --lines;
  1711.   
  1712.     /* If the sentinel was passed, and lengths are equal, the
  1713.        files are identical.  */
  1714. !   if ((p0 - filevec[0].buffer) > filevec[0].buffered_chars
  1715.         && filevec[0].buffered_chars == filevec[1].buffered_chars)
  1716.       {
  1717.         filevec[0].prefix_end = p0 - 1;
  1718. ***************
  1719. *** 435,445 ****
  1720.         else
  1721.       /* Figure out where P0 will be when P1 is at the end of the prefix.
  1722.          Thus we only need to test P0.  */
  1723. !     beg0 = (filevec[0].prefix_end
  1724. !         + filevec[0].buffered_chars - filevec[1].buffered_chars);
  1725.   
  1726.         /* Scan back until chars don't match or we reach that point.  */
  1727. !       while (p0 != beg0)
  1728.       {
  1729.         char c = *--p0;
  1730.         if (c != *--p1)
  1731. --- 531,541 ----
  1732.         else
  1733.       /* Figure out where P0 will be when P1 is at the end of the prefix.
  1734.          Thus we only need to test P0.  */
  1735. !     beg0 = filevec[0].prefix_end
  1736. !         + (filevec[0].buffered_chars - filevec[1].buffered_chars);
  1737.   
  1738.         /* Scan back until chars don't match or we reach that point.  */
  1739. !       while (p0 > beg0)
  1740.       {
  1741.         char c = *--p0;
  1742.         if (c != *--p1)
  1743. ***************
  1744. *** 483,488 ****
  1745. --- 579,587 ----
  1746.   {
  1747.     struct equivclass *next;    /* Next item in this bucket. */
  1748.     struct line_def line;    /* A line that fits this class. */
  1749. + #ifdef MSDOS
  1750. +   long dummy; /* to pad struct size to a power of two, 16 */
  1751. + #endif
  1752.   };
  1753.   
  1754.   /* Hash-table: array of buckets, each being a chain of equivalence classes.  */
  1755. ***************
  1756. *** 494,511 ****
  1757.   /* Array in which the equivalence classes are allocated.
  1758.      The bucket-chains go through the elements in this array.
  1759.      The number of an equivalence class is its index in this array.  */
  1760. ! static struct equivclass *equivs;
  1761.   
  1762.   /* Index of first free element in the array `equivs'.  */
  1763. ! static int equivs_index;
  1764.   
  1765.   /* Size allocated to the array `equivs'.  */
  1766. ! static int equivs_alloc;
  1767.   
  1768.   /* Largest primes less than some power of two, for nbuckets.  Values range
  1769.      from useful to preposterous.  If one of these numbers isn't prime
  1770.      after all, don't blame it on me, blame it on primes (6) . . . */
  1771. ! static int primes[] =
  1772.   {
  1773.     509,
  1774.     1021,
  1775. --- 593,610 ----
  1776.   /* Array in which the equivalence classes are allocated.
  1777.      The bucket-chains go through the elements in this array.
  1778.      The number of an equivalence class is its index in this array.  */
  1779. ! static struct equivclass _huge *equivs;
  1780.   
  1781.   /* Index of first free element in the array `equivs'.  */
  1782. ! static long equivs_index;
  1783.   
  1784.   /* Size allocated to the array `equivs'.  */
  1785. ! static long equivs_alloc;
  1786.   
  1787.   /* Largest primes less than some power of two, for nbuckets.  Values range
  1788.      from useful to preposterous.  If one of these numbers isn't prime
  1789.      after all, don't blame it on me, blame it on primes (6) . . . */
  1790. ! static long primes[] =
  1791.   {
  1792.     509,
  1793.     1021,
  1794. ***************
  1795. *** 538,544 ****
  1796.        int n;
  1797.   {
  1798.     int bucket;
  1799. !   struct equivclass *b, *p = NULL;
  1800.   
  1801.     /* Equivalence class 0 is permanently allocated to lines that were
  1802.        not hashed because they were parts of identical prefixes or
  1803. --- 637,643 ----
  1804.        int n;
  1805.   {
  1806.     int bucket;
  1807. !   struct equivclass _huge *b, _huge *p = NULL;
  1808.   
  1809.     /* Equivalence class 0 is permanently allocated to lines that were
  1810.        not hashed because they were parts of identical prefixes or
  1811. ***************
  1812. *** 564,569 ****
  1813. --- 663,671 ----
  1814.   
  1815.     /* Create a new equivalence class in this bucket. */
  1816.   
  1817. +   if (equivs_index >= equivs_alloc)
  1818. +     fatal ("too many differences, hash table overflow");
  1819.     p = &equivs[equivs_index++];
  1820.     p->next = buckets[bucket];
  1821.     buckets[bucket] = p;
  1822. ***************
  1823. *** 601,608 ****
  1824.       }
  1825.   
  1826.     /* This is guaranteed to be enough space.  */
  1827. !   equivs_alloc = filevec[0].buffered_lines + filevec[1].buffered_lines + 1;
  1828.     equivs = (struct equivclass *) xmalloc (equivs_alloc * sizeof (struct equivclass));
  1829.     /* Equivalence class 0 is permanently safe for lines that were not
  1830.        hashed.  Real equivalence classes start at 1. */
  1831.     equivs_index = 1;
  1832. --- 703,716 ----
  1833.       }
  1834.   
  1835.     /* This is guaranteed to be enough space.  */
  1836. !   equivs_alloc = (long) filevec[0].buffered_lines + filevec[1].buffered_lines + 1L;
  1837. ! #ifndef MSDOS
  1838.     equivs = (struct equivclass *) xmalloc (equivs_alloc * sizeof (struct equivclass));
  1839. + #else
  1840. +   equivs = halloc (equivs_alloc, sizeof (struct equivclass));
  1841. +   if ( equivs == NULL )
  1842. +     fatal("virtual memory exhausted");
  1843. + #endif
  1844.     /* Equivalence class 0 is permanently safe for lines that were not
  1845.        hashed.  Real equivalence classes start at 1. */
  1846.     equivs_index = 1;
  1847. ***************
  1848. *** 611,618 ****
  1849. --- 719,730 ----
  1850.     while (primes[primes_index] < equivs_alloc / 3)
  1851.       primes_index++;
  1852.   
  1853. + #ifndef MSDOS
  1854.     buckets = (struct equivclass **) xmalloc (primes[primes_index] * sizeof (struct equivclass *));
  1855.     bzero (buckets, primes[primes_index] * sizeof (struct equivclass *));
  1856. + #else
  1857. +   buckets = halloc (primes[primes_index], sizeof (struct equivclass *));
  1858. + #endif
  1859.     nbuckets = primes[primes_index];
  1860.   
  1861.     for (i = 0; i < 2; ++i)
  1862. ***************
  1863. *** 626,633 ****
  1864. --- 738,750 ----
  1865.   
  1866.     filevec[0].equiv_max = filevec[1].equiv_max = equivs_index;
  1867.   
  1868. + #ifndef MSDOS
  1869.     free (equivs);
  1870.     free (buckets);
  1871. + #else
  1872. +   hfree (equivs);
  1873. +   hfree (buckets);
  1874. + #endif
  1875.   
  1876.     return 0;
  1877.   }
  1878. diff -cbBw orig/limits.h diff/limits.h
  1879. *** orig/limits.h    Mon Jan 28 20:18:22 1991
  1880. --- diff/limits.h    Thu Jan 17 23:07:26 1991
  1881. ***************
  1882. *** 28,38 ****
  1883. --- 28,46 ----
  1884.   #define USHRT_MAX 65535U
  1885.   
  1886.   /* Minimum and maximum values a `signed int' can hold.  */
  1887. + #ifdef MSDOS
  1888. + #define INT_MIN (-32768)
  1889. + #define INT_MAX 32767
  1890. + /* Maximum value an `unsigned int' can hold.  (Minimum is 0).  */
  1891. + #define UINT_MAX 65535U
  1892. + #else
  1893.   #define INT_MIN (-INT_MAX-1)
  1894.   #define INT_MAX 2147483647
  1895.   
  1896.   /* Maximum value an `unsigned int' can hold.  (Minimum is 0).  */
  1897.   #define UINT_MAX 4294967295U
  1898. + #endif
  1899.   
  1900.   /* Minimum and maximum values a `signed long int' can hold.
  1901.      (Same as `int').  */
  1902. diff -cbBw orig/util.c diff/util.c
  1903. *** orig/util.c    Mon Jan 28 20:18:26 1991
  1904. --- diff/util.c    Thu Jan 17 23:07:28 1991
  1905. ***************
  1906. *** 51,57 ****
  1907.        char *arg;
  1908.        char *arg1;
  1909.   {
  1910. !   fprintf (stderr, "%s: ", program);
  1911.     fprintf (stderr, format, arg, arg1);
  1912.     fprintf (stderr, "\n");
  1913.   }
  1914. --- 51,57 ----
  1915.        char *arg;
  1916.        char *arg1;
  1917.   {
  1918. !   fprintf (stderr, "\n%s: ", program);
  1919.     fprintf (stderr, format, arg, arg1);
  1920.     fprintf (stderr, "\n");
  1921.   }
  1922. ***************
  1923. *** 129,136 ****
  1924. --- 129,147 ----
  1925.     strcat (name, " ");
  1926.     strcat (name, name1);
  1927.   
  1928. + #if defined(MSDOS)
  1929.     if (paginate_flag)
  1930.       {
  1931. +       extern FILE *popen();
  1932. +       /* Fork a `pr' and make OUTFILE a pipe to it.  */
  1933. +       outfile = popen("pr -o -", "w");
  1934. +       fprintf (outfile, "%s\n", name);
  1935. +     }
  1936. +   else
  1937. + #else
  1938. +   if (paginate_flag)
  1939. +     {
  1940.         int pipes[2];
  1941.         int desc;
  1942.   
  1943. ***************
  1944. *** 164,169 ****
  1945. --- 175,181 ----
  1946.       }
  1947.       }
  1948.     else
  1949. + #endif
  1950.       {
  1951.   
  1952.         /* If -l was not specified, output the diff straight to `stdout'.  */
  1953. ***************
  1954. *** 172,178 ****
  1955.   
  1956.         /* If handling multiple files (because scanning a directory),
  1957.        print which files the following output is about.  */
  1958. !       if (depth > 0)
  1959.       printf ("%s\n", name);
  1960.       }
  1961.   
  1962. --- 184,190 ----
  1963.   
  1964.         /* If handling multiple files (because scanning a directory),
  1965.        print which files the following output is about.  */
  1966. !       if (depth > 0 && !output_patch_flag)
  1967.       printf ("%s\n", name);
  1968.       }
  1969.   
  1970. ***************
  1971. *** 187,194 ****
  1972. --- 199,210 ----
  1973.   {
  1974.     if (outfile != stdout)
  1975.       {
  1976. + #if defined(MSDOS)
  1977. +       pclose (outfile);
  1978. + #else
  1979.         fclose (outfile);
  1980.         wait (0);
  1981. + #endif
  1982.       }
  1983.   }
  1984.   
  1985. ***************
  1986. *** 201,207 ****
  1987. --- 217,227 ----
  1988.   line_cmp (s1, s2)
  1989.        struct line_def *s1, *s2;
  1990.   {
  1991. + #ifdef MSDOS
  1992. +   char _huge *t1, _huge *t2;
  1993. + #else
  1994.     register char *t1, *t2;
  1995. + #endif
  1996.     register char end_char = line_end_char;
  1997.     int savechar;
  1998.   
  1999. ***************
  2000. *** 382,388 ****
  2001. --- 402,412 ----
  2002.        struct line_def *line;
  2003.   {
  2004.     int length = line->length; /* must be nonzero */
  2005. + #ifdef MSDOS
  2006. +   const char _huge *text = line->text; /* Help the compiler.  */
  2007. + #else
  2008.     const char *text = line->text; /* Help the compiler.  */
  2009. + #endif
  2010.     FILE *out = outfile; /* Help the compiler some more.  */
  2011.   
  2012.     /* If -T was specified, use a Tab between the line-flag and the text.
  2013.