home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-12-24 | 64.0 KB | 2,302 lines |
- diff -cbBw orig/analyze.c new/analyze.c
- *** orig/analyze.c Tue Dec 24 19:13:18 1991
- --- new/analyze.c Tue Dec 24 19:25:12 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* Analyze file differences for GNU DIFF.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This file is part of GNU DIFF.
-
- ***************
- *** 32,42 ****
- --- 34,49 ----
- void print_normal_script ();
- void print_rcs_script ();
- void pr_forward_ed_script ();
- + void print_merged_script ();
- void setup_output ();
-
- extern int no_discards;
-
- static int *xvec, *yvec; /* Vectors being compared. */
- + #ifdef MSDOS
- + static int huge *fdiag;
- + static int huge *bdiag;
- + #else
- static int *fdiag; /* Vector, indexed by diagonal, containing
- the X coordinate of the point furthest
- along the given diagonal in the forward
- ***************
- *** 45,50 ****
- --- 52,58 ----
- the X coordinate of the point furthest
- along the given diagonal in the backward
- search of the edit matrix. */
- + #endif
-
- /* Find the midpoint of the shortest edit script for a specified
- portion of the two files.
- ***************
- *** 75,84 ****
- --- 83,99 ----
- int xoff, xlim, yoff, ylim;
- int *cost;
- {
- + #ifdef MSDOS
- + int huge *const fd = fdiag;
- + int huge *const bd = bdiag;
- + int huge *const xv = xvec;
- + int huge *const yv = yvec;
- + #else
- int *const fd = fdiag; /* Give the compiler a chance. */
- int *const bd = bdiag; /* Additional help for the compiler. */
- int *const xv = xvec; /* Still more help for the compiler. */
- int *const yv = yvec; /* And more and more . . . */
- + #endif
- const int dmin = xoff - ylim; /* Minimum valid diagonal. */
- const int dmax = xlim - yoff; /* Maximum valid diagonal. */
- const int fmid = xoff - yoff; /* Center diagonal of top-down search. */
- ***************
- *** 719,725 ****
- struct file_data filevec[];
- int depth;
- {
- ! int diags;
- int i;
- struct change *e, *p;
- struct change *script;
- --- 734,740 ----
- struct file_data filevec[];
- int depth;
- {
- ! long diags;
- int i;
- struct change *e, *p;
- struct change *script;
- ***************
- *** 729,738 ****
- --- 744,768 ----
- /* See if the two named files are actually the same physical file.
- If so, we know they are identical without actually reading them. */
-
- + #if !defined(MSDOS)
- + /*
- + ** since MSC always sets the inode and dev fields to zero under DOS
- + ** this test will always think two files are the same.
- + */
- if (output_style != OUTPUT_IFDEF
- && filevec[0].stat.st_ino == filevec[1].stat.st_ino
- && filevec[0].stat.st_dev == filevec[1].stat.st_dev)
- return 0;
- + #endif /* MSDOS */
- +
- + if (no_details_flag
- + && (filevec[0].stat.st_mode & S_IFMT) == S_IFREG
- + && (filevec[1].stat.st_mode & S_IFMT) == S_IFREG
- + && filevec[0].stat.st_size != filevec[1].stat.st_size)
- + {
- + message ("Files %s and %s differ\n", filevec[0].name, filevec[1].name);
- + return 1;
- + }
-
- binary = read_files (filevec);
-
- ***************
- *** 743,759 ****
-
- if (binary || no_details_flag)
- {
- int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
- || bcmp (filevec[0].buffer, filevec[1].buffer,
- filevec[1].buffered_chars));
- if (differs)
- ! message (binary ? "Binary files %s and %s differ\n"
- ! : "Files %s and %s differ\n",
- filevec[0].name, filevec[1].name);
-
- for (i = 0; i < 2; ++i)
- if (filevec[i].buffer)
- free (filevec[i].buffer);
- return differs;
- }
-
- --- 773,819 ----
-
- if (binary || no_details_flag)
- {
- + #if !defined(MSDOS)
- int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
- || bcmp (filevec[0].buffer, filevec[1].buffer,
- filevec[1].buffered_chars));
- + #else
- + int differs;
- + if(filevec[0].buffered_chars != filevec[1].buffered_chars)
- + differs = 1;
- + else {
- + /*
- + ** we've got to do it in chunks because of our
- + ** poor 16 bit processor
- + */
- + char huge *b0 = filevec[0].buffer;
- + char huge *b1 = filevec[1].buffer;
- + long int count;
- + unsigned int delta;
- + count = filevec[0].buffered_chars;
- + while(count > 0) {
- + delta = (unsigned)(count > 65000 ? 65000 : count);
- + if(bcmp(b0,b1,delta) != 0)
- + break;
- + count -= delta;
- + b0 += delta;
- + b1 += delta;
- + }
- + differs = count != 0;
- + }
- + #endif
- if (differs)
- ! message (no_details_flag ? "Files %s and %s differ\n"
- ! : "Binary files %s and %s differ\n",
- filevec[0].name, filevec[1].name);
-
- for (i = 0; i < 2; ++i)
- if (filevec[i].buffer)
- + #ifndef MSDOS
- free (filevec[i].buffer);
- + #else
- + hfree (filevec[i].buffer);
- + #endif
- return differs;
- }
-
- ***************
- *** 780,789 ****
-
- xvec = filevec[0].undiscarded;
- yvec = filevec[1].undiscarded;
- ! diags = filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3;
- fdiag = (int *) xmalloc (diags * sizeof (int));
- - fdiag += filevec[1].nondiscarded_lines + 1;
- bdiag = (int *) xmalloc (diags * sizeof (int));
- bdiag += filevec[1].nondiscarded_lines + 1;
-
- files[0] = filevec[0];
- --- 840,856 ----
-
- xvec = filevec[0].undiscarded;
- yvec = filevec[1].undiscarded;
- ! diags = (long) filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3;
- ! #ifdef MSDOS
- ! fdiag = halloc (diags, sizeof (int));
- ! bdiag = halloc (diags, sizeof (int));
- ! if ( fdiag == NULL || bdiag == NULL )
- ! fatal("virtual memory exhausted");
- ! #else
- fdiag = (int *) xmalloc (diags * sizeof (int));
- bdiag = (int *) xmalloc (diags * sizeof (int));
- + #endif
- + fdiag += filevec[1].nondiscarded_lines + 1;
- bdiag += filevec[1].nondiscarded_lines + 1;
-
- files[0] = filevec[0];
- ***************
- *** 793,801 ****
- 0, filevec[1].nondiscarded_lines);
-
- bdiag -= filevec[1].nondiscarded_lines + 1;
- - free (bdiag);
- fdiag -= filevec[1].nondiscarded_lines + 1;
- free (fdiag);
-
- /* Modify the results slightly to make them prettier
- in cases where that can validly be done. */
- --- 860,873 ----
- 0, filevec[1].nondiscarded_lines);
-
- bdiag -= filevec[1].nondiscarded_lines + 1;
- fdiag -= filevec[1].nondiscarded_lines + 1;
- + #ifdef MSDOS
- + hfree (bdiag);
- + hfree (fdiag);
- + #else
- + free (bdiag);
- free (fdiag);
- + #endif
-
- /* Modify the results slightly to make them prettier
- in cases where that can validly be done. */
- ***************
- *** 814,828 ****
- {
- setup_output (files[0].name, files[1].name, depth);
-
- switch (output_style)
- {
- case OUTPUT_CONTEXT:
- ! print_context_header (files, 0);
- print_context_script (script, 0);
- break;
-
- case OUTPUT_UNIFIED:
- ! print_context_header (files, 1);
- print_context_script (script, 1);
- break;
-
- --- 886,905 ----
- {
- setup_output (files[0].name, files[1].name, depth);
-
- + if (output_style == OUTPUT_CONTEXT ||
- + output_style == OUTPUT_UNIFIED ||
- + output_patch_flag)
- + print_context_header (files, output_style == OUTPUT_UNIFIED);
- +
- switch (output_style)
- {
- case OUTPUT_CONTEXT:
- ! /* print_context_header (files, 0); */
- print_context_script (script, 0);
- break;
-
- case OUTPUT_UNIFIED:
- ! /* print_context_header (files, 1); */
- print_context_script (script, 1);
- break;
-
- ***************
- *** 845,850 ****
- --- 922,931 ----
- case OUTPUT_IFDEF:
- print_ifdef_script (script);
- break;
- +
- + case OUTPUT_MERGED:
- + print_merged_script (script);
- + break;
- }
-
- finish_output ();
- ***************
- *** 899,907 ****
- --- 980,996 ----
-
- for (i = 0; i < 2; ++i)
- {
- + #if !defined(MSDOS)
- if (filevec[i].buffer != 0)
- free (filevec[i].buffer);
- +
- free (filevec[i].linbuf);
- + #else /* MSDOS */
- + if (filevec[i].buffer != 0)
- + hfree (filevec[i].buffer);
- +
- + hfree (filevec[i].linbuf);
- + #endif
- }
-
- for (e = script; e; e = p)
- diff -cbBw orig/context.c new/context.c
- *** orig/context.c Tue Dec 24 19:13:18 1991
- --- new/context.c Tue Dec 24 19:19:06 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* Context-format output routines for GNU DIFF.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This file is part of GNU DIFF.
-
- ***************
- *** 43,49 ****
- if (label)
- fprintf (outfile, "%s %s\n", mark, label);
- else if (inf->stat.st_mtime)
- ! fprintf (outfile, "%s %s\t%s", mark, inf->name, ctime(&inf->stat.st_mtime));
- else
- /* Don't pretend that standard input is ancient. */
- fprintf (outfile, "%s %s\n", mark, inf->name);
- --- 45,56 ----
- if (label)
- fprintf (outfile, "%s %s\n", mark, label);
- else if (inf->stat.st_mtime)
- ! {
- ! char *ct = ctime(&inf->stat.st_mtime);
- ! /* some ctime()'s return NULL on illegal times
- ! which may occur sometimes under DOS ... */
- ! fprintf (outfile, "%s %s\t%s", mark, inf->name, ct ? ct : "\n");
- ! }
- else
- /* Don't pretend that standard input is ancient. */
- fprintf (outfile, "%s %s\n", mark, inf->name);
- ***************
- *** 51,61 ****
- --- 58,92 ----
-
- /* Print a header for a context diff, with the file names and dates. */
-
- + #ifdef MSDOS
- + void dosname(char *ptr)
- + {
- + for ( ; *ptr; ptr++ )
- + if ( *ptr == '\\' )
- + *ptr = '/';
- + /* else
- + *ptr = tolower(*ptr); */
- + }
- + #endif
- +
- void
- print_context_header (inf, unidiff_flag)
- struct file_data *inf;
- int unidiff_flag;
- {
- + #ifdef MSDOS
- + dosname(inf[0].name);
- + dosname(inf[1].name);
- + #endif
- + if (output_patch_flag)
- + {
- + char *cp = strlen (inf[0].name) <= strlen (inf[1].name)
- + ? inf[0].name : inf[1].name;
- + if (cp[0] == '.' && cp[1] == '/')
- + cp += 2;
- + fprintf (outfile, "Index: %s\n", cp);
- + return;
- + }
- if (unidiff_flag)
- {
- print_context_label ("---", &inf[0], file_label[0]);
- ***************
- *** 397,403 ****
- script->link = next;
-
- /* If the change is ignorable, mark it. */
- ! script->ignore = (!deletes && !inserts);
-
- /* Advance to the following change. */
- script = next;
- --- 428,434 ----
- script->link = next;
-
- /* If the change is ignorable, mark it. */
- ! script->ignore = (char) (!deletes && !inserts);
-
- /* Advance to the following change. */
- script = next;
- diff -cbBw orig/diff.c new/diff.c
- *** orig/diff.c Tue Dec 24 19:13:20 1991
- --- new/diff.c Tue Dec 24 19:26:04 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* GNU DIFF main routine.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This file is part of GNU DIFF.
-
- ***************
- *** 95,100 ****
- --- 97,103 ----
- {"print", 0, 0, 'l'},
- {"rcs", 0, 0, 'n'},
- {"show-c-function", 0, 0, 'p'},
- + {"patch", 0, 0, 'P'},
- {"binary", 0, 0, 'q'},
- {"brief", 0, 0, 'q'},
- {"recursive", 0, 0, 'r'},
- ***************
- *** 139,153 ****
- paginate_flag = FALSE;
- ifdef_string = NULL;
- heuristic = FALSE;
- dir_start_file = NULL;
- msg_chain = NULL;
- msg_chain_end = NULL;
- no_discards = 0;
-
- /* Decode the options. */
-
- while ((c = getopt_long (argc, argv,
- ! "0123456789abBcC:dD:efF:hHiI:lL:nNpqrsS:tTuvw",
- longopts, &longind)) != EOF)
- {
- if (c == 0) /* Long option. */
- --- 142,158 ----
- paginate_flag = FALSE;
- ifdef_string = NULL;
- heuristic = FALSE;
- + output_patch_flag = 0;
- dir_start_file = NULL;
- msg_chain = NULL;
- msg_chain_end = NULL;
- no_discards = 0;
- + line_width = 0;
-
- /* Decode the options. */
-
- while ((c = getopt_long (argc, argv,
- ! "0123456789abBcC:dD:efF:hHiI:lL:mM:nNpPqrsS:tTuvw",
- longopts, &longind)) != EOF)
- {
- if (c == 0) /* Long option. */
- ***************
- *** 283,288 ****
- --- 288,305 ----
- fatal ("too many file label options");
- break;
-
- + case 'm':
- + /* Make output merged in side-by-side display. */
- + specify_style (OUTPUT_MERGED);
- + line_width = 80;
- + break;
- +
- + case 'M':
- + /* Make output merged in side-by-side display. */
- + specify_style (OUTPUT_MERGED);
- + line_width = atoi(optarg);
- + break;
- +
- case 'n':
- /* Output RCS-style diffs, like `-f' except that each command
- specifies the number of lines affected. */
- ***************
- *** 301,306 ****
- --- 318,327 ----
- function_regexp = "^[_a-zA-Z]";
- break;
-
- + case 'P':
- + output_patch_flag = 1;
- + break;
- +
- case 'q':
- no_details_flag = 1;
- break;
- ***************
- *** 399,411 ****
- exit (val);
- }
-
- usage ()
- {
- fprintf (stderr, "\
- ! Usage: diff [-#] [-abBcdefhHilnNprstTuvw] [-C lines] [-F regexp] [-I regexp]\n\
- [-L label [-L label]] [-S file] [-D symbol] [+ignore-blank-lines]\n\
- [+context[=lines]] [+unified[=lines]] [+ifdef=symbol]\n\
- ! [+show-function-line=regexp]\n");
- fprintf (stderr, "\
- [+speed-large-files] [+ignore-matching-lines=regexp] [+new-file]\n\
- [+initial-tab] [+starting-file=file] [+text] [+all-text] [+ascii]\n\
- --- 420,497 ----
- exit (val);
- }
-
- + #ifdef MSDOS
- + extern char *version_string;
- +
- + usage()
- + {
- + printf("\nGNU diff, version %s\n", version_string);
- +
- + printf("\nUsage: %s [-options] file1 file2\n\n", program);
- + printf(
- + " -c Make context-style output.\n"
- + " -p Make context-style output and show name of last C function.\n"
- + " -C n Make context-style output and define context size to be n lines.\n"
- + " -u Make unified-context-style output.\n"
- + " -D Make merged #ifdef output.\n"
- + " -e Make output that is a valid `ed' script.\n"
- + " -f Make output that looks vaguely like an `ed' script\n"
- + " but has changes in the order they appear in the file.\n"
- + " -n Make RCS-style output, like `-f' except that each command\n"
- + " specifies the number of lines affected.\n"
- + " -m Make side-by-side merged output.\n"
- + " -M n Make side-by-side merged output and specify page-width.\n\n"
- + );
- + printf(
- + " -[0-9] digits combined into decimal to specify the context-size.\n"
- + " -a Treat all files as text files; never treat as binary.\n"
- + " -b Ignore changes in amount of whitespace.\n"
- + " -B Ignore changes affecting only blank lines.\n"
- + " -d Don't discard lines. This makes things slower (sometimes much\n"
- + " slower) but will find a guaranteed minimal set of changes.\n"
- + );
- + printf(
- + " -F re Show, for each set of changes, the previous line that matches the\n"
- + " specified regexp. Currently affects only context-style output.\n"
- + " -h Split the files into chunks of around 1500 lines\n"
- + " for faster processing. Usually does not change the result.\n"
- + " -H Use heuristic.\n"
- + " -i Ignore changes in case.\n"
- + " -I re Ignore changes affecting only lines that match the specified regexp.\n"
- + " -l Pass the output through `pr' to paginate it.\n"
- + " -L label [-L label]\n"
- + " Use the specified label in file header lines output by the -c option.\n"
- + );
- + printf(
- + " -N When comparing directories, if a file appears only in one\n"
- + " directory, treat it as present but empty in the other.\n"
- + " -P Create patch headers (Index: ...).\n"
- + " -q Treat all files as binaries.\n"
- + " -r When comparing directories, recursively compare subdir's found.\n"
- + " -s Print a message if the files are the same.\n"
- + );
- + printf(
- + " -S file When comparing directories, start with the specified\n"
- + " file name. This is used for resuming an aborted comparison.\n"
- + " -t Expand tabs to spaces in the output so that it preserves\n"
- + " the alignment of the input files.\n"
- + " -T Use a tab in the output, rather than a space, before the\n"
- + " text of an input line, so as to keep the proper alignment\n"
- + " in the input line without changing the characters in it.\n"
- + " -v Print version number.\n"
- + " -w Ignore horizontal whitespace when comparing lines.\n"
- + );
- +
- + exit(2);
- + }
- + #else
- usage ()
- {
- fprintf (stderr, "\
- ! Usage: diff [-#] [-abBcdefhHilnNpPrstTuvw] [-C lines] [-F regexp] [-I regexp]\n\
- [-L label [-L label]] [-S file] [-D symbol] [+ignore-blank-lines]\n\
- [+context[=lines]] [+unified[=lines]] [+ifdef=symbol]\n\
- ! [+show-function-line=regexp] [+patch]\n");
- fprintf (stderr, "\
- [+speed-large-files] [+ignore-matching-lines=regexp] [+new-file]\n\
- [+initial-tab] [+starting-file=file] [+text] [+all-text] [+ascii]\n\
- ***************
- *** 416,421 ****
- --- 502,508 ----
- [+file-label=label [+file-label=label]] [+version] path1 path2\n");
- exit (2);
- }
- + #endif
-
- specify_style (style)
- enum output_style style;
- ***************
- *** 455,460 ****
- --- 542,548 ----
- {
- char *name = name0 == 0 ? name1 : name0;
- char *dir = name0 == 0 ? dir1 : dir0;
- + if (!output_patch_flag)
- message ("Only in %s: %s\n", dir, name);
- /* Return 1 so that diff_dirs will return 1 ("some files differ"). */
- return 1;
- ***************
- *** 506,511 ****
- --- 594,606 ----
- }
- }
-
- + #if !defined(MSDOS)
- + /*
- + ** this stuff is real bad idea under MSDOS, at least for MSC 5.1
- + ** because the st_ino and st_dev fields are not supported by
- + ** MSDOS, and so stat sets them to zero; therefore
- + ** this test always succeeds.
- + */
- /* See if the two named files are actually the same physical file.
- If so, we know they are identical without actually reading them. */
-
- ***************
- *** 518,523 ****
- --- 613,619 ----
- val = 0;
- goto done;
- }
- + #endif /* MSDOS */
-
- if (name0 == 0)
- inf[0].dir_p = inf[1].dir_p;
- ***************
- *** 536,545 ****
- inf[i].name = Standard_Input;
- }
- /* Don't bother opening if stat already failed. */
- ! else if (stat_result[i] == 0 && ! inf[i].dir_p)
- {
- char *filename = inf[i].name;
- !
- inf[i].desc = open (filename, O_RDONLY, 0);
- if (0 > inf[i].desc)
- {
- --- 632,650 ----
- inf[i].name = Standard_Input;
- }
- /* Don't bother opening if stat already failed. */
- ! else if (stat_result[i] == 0)
- {
- char *filename = inf[i].name;
- ! #if !defined(MSDOS)
- ! inf[i].desc = open (filename, O_RDONLY, 0);
- ! if (0 > inf[i].desc)
- ! {
- ! perror_with_name (filename);
- ! errorcount = 1;
- ! }
- ! #else
- ! if(inf[i].dir_p == 0)
- ! {
- inf[i].desc = open (filename, O_RDONLY, 0);
- if (0 > inf[i].desc)
- {
- ***************
- *** 546,554 ****
- --- 651,667 ----
- perror_with_name (filename);
- errorcount = 1;
- }
- + } else
- + inf[i].desc = 0;
- + #endif /* MSDOS */
- }
- }
-
- + if (name0 == 0)
- + inf[0].dir_p = inf[1].dir_p;
- + if (name1 == 0)
- + inf[1].dir_p = inf[0].dir_p;
- +
- if (errorcount)
- {
-
- ***************
- *** 568,573 ****
- --- 681,687 ----
- {
- /* But don't compare dir contents one level down
- unless -r was specified. */
- + if (!output_patch_flag)
- message ("Common subdirectories: %s and %s\n",
- inf[0].name, inf[1].name);
- val = 0;
- ***************
- *** 637,642 ****
- --- 751,757 ----
- else
- {
- char *dir = (inf[0].desc == -1) ? dir1 : dir0;
- + if (!output_patch_flag)
- message ("Only in %s: %s\n", dir, name0);
- val = 1;
- }
- diff -cbBw orig/diff.h new/diff.h
- *** orig/diff.h Tue Dec 24 19:13:22 1991
- --- new/diff.h Tue Dec 24 19:19:10 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* Shared definitions for GNU DIFF
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This file is part of GNU DIFF.
-
- ***************
- *** 20,28 ****
- --- 22,36 ----
-
- #include <ctype.h>
- #include <stdio.h>
- + #ifdef __TURBOC__
- + #include <types.h>
- + #else
- #include <sys/types.h>
- + #endif
- #include <sys/stat.h>
-
- + #include <string.h>
- +
- #ifdef USG
- #include <time.h>
- #ifdef HAVE_NDIR
- ***************
- *** 32,38 ****
- --- 40,48 ----
- #include <ndir.h>
- #endif /* not NDIR_IN_SYS */
- #else
- + #ifndef MSDOS
- #include <dirent.h>
- + #endif
- #endif /* not HAVE_NDIR */
- #include <fcntl.h>
- #ifndef HAVE_DIRECT
- ***************
- *** 47,59 ****
- --- 57,75 ----
- #ifdef USG
- /* Define needed BSD functions in terms of sysV library. */
-
- + #ifdef MSDOS
- + #define bcopy(s,d,n) memmove((d),(s),(n))
- + #else
- #define bcopy(s,d,n) memcpy((d),(s),(n))
- + #endif
- #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- #define bzero(s,n) memset((s),0,(n))
-
- #ifndef XENIX
- + #ifndef MSDOS
- #define dup2(f,t) (close(t),fcntl((f),F_DUPFD,(t)))
- #endif
- + #endif
-
- #define vfork fork
- #define index strchr
- ***************
- *** 65,81 ****
- --- 81,106 ----
- #define vfork fork
- #endif
-
- + #ifdef MSDOS
- + #include <process.h>
- + #include <stdlib.h>
- + #endif /* MSDOS */
- +
- #include <errno.h>
- + #if !defined(MSDOS)
- extern int errno;
- extern int sys_nerr;
- extern char *sys_errlist[];
- + #endif
-
- #define EOS (0)
- #define FALSE (0)
- #define TRUE 1
-
- + #if !defined(min)
- #define min(a,b) ((a) <= (b) ? (a) : (b))
- #define max(a,b) ((a) >= (b) ? (a) : (b))
- + #endif /* MSDOS */
-
- #ifndef PR_FILE_NAME
- #define PR_FILE_NAME "/bin/pr"
- ***************
- *** 83,96 ****
-
- /* Support old-fashioned C compilers. */
- #if defined (__STDC__) || defined (__GNUC__)
- #include "limits.h"
- #else
- #define INT_MAX 2147483647
- #define CHAR_BIT 8
- #endif
-
- /* Support old-fashioned C compilers. */
- ! #if !defined (__STDC__) && !defined (__GNUC__)
- #define const
- #endif
-
- --- 108,144 ----
-
- /* Support old-fashioned C compilers. */
- #if defined (__STDC__) || defined (__GNUC__)
- + #if !defined(MSDOS)
- #include "limits.h"
- #else
- + #include <limits.h>
- + #endif /* MSDOS */
- + #else
- #define INT_MAX 2147483647
- #define CHAR_BIT 8
- #endif
-
- + #if defined(MSDOS)
- + #ifdef INT_MAX
- + #undef INT_MAX
- + #include <limits.h>
- + #endif
- + #ifdef __TURBOC__
- + #include <alloc.h>
- + #include <mem.h>
- + #define halloc(n, s) farmalloc((long) n * s)
- + #define hrealloc(x, s, o) farrealloc(x, s)
- + #define hfree(x) farfree(x)
- + #else
- + #include <malloc.h>
- + #include <memory.h>
- + #endif
- + #include <io.h>
- + extern int getopt(int nargc,char **nargv,char *ostr);
- + #endif
- +
- /* Support old-fashioned C compilers. */
- ! #if !defined (__STDC__) && !defined (__GNUC__) || defined(MSDOS)
- #define const
- #endif
-
- ***************
- *** 120,126 ****
- /* Like -f, but output a count of changed lines in each "command" (-n). */
- OUTPUT_RCS,
- /* Output merged #ifdef'd file (-D). */
- ! OUTPUT_IFDEF };
-
- /* True for output styles that are robust,
- i.e. can handle a file that ends in a non-newline. */
- --- 168,177 ----
- /* Like -f, but output a count of changed lines in each "command" (-n). */
- OUTPUT_RCS,
- /* Output merged #ifdef'd file (-D). */
- ! OUTPUT_IFDEF,
- ! /* Output merged in side-by-side display (-m). */
- ! OUTPUT_MERGED
- ! };
-
- /* True for output styles that are robust,
- i.e. can handle a file that ends in a non-newline. */
- ***************
- *** 199,204 ****
- --- 250,258 ----
- /* Pipe each file's output through pr (-l). */
- EXTERN int paginate_flag;
-
- + /* Line width for the merged display (-m,-M). */
- + EXTERN int line_width;
- +
- /* String to use for #ifdef (-D). */
- EXTERN char * ifdef_string;
-
- ***************
- *** 210,215 ****
- --- 264,272 ----
- /* Nonzero means use heuristics for better speed. */
- EXTERN int heuristic;
-
- + /* Reduce extraneous output when they're outputting a patch. */
- + EXTERN int output_patch_flag;
- +
- /* Name of program the user invoked (for error messages). */
- EXTERN char * program;
-
- ***************
- *** 239,245 ****
- --- 296,306 ----
- /* Data on one line of text. */
-
- struct line_def {
- + #ifdef MSDOS
- + char huge *text;
- + #else
- char *text;
- + #endif
- int length;
- unsigned hash;
- };
- ***************
- *** 252,257 ****
- --- 313,319 ----
- struct stat stat; /* File status from fstat() */
- int dir_p; /* 1 if file is a directory */
-
- + #if !defined(MSDOS)
- /* Buffer in which text of file is read. */
- char * buffer;
- /* Allocated size of buffer. */
- ***************
- *** 279,284 ****
- --- 341,375 ----
-
- /* Count of lines in the suffix. */
- int suffix_lines;
- + #else /* MSDOS */
- + /* Buffer in which text of file is read. */
- + char huge *buffer;
- + /* Allocated size of buffer. */
- + long int bufsize;
- + /* Number of valid characters now in the buffer. */
- + long int buffered_chars;
- +
- + /* Array of data on analyzed lines of this chunk of this file. */
- + struct line_def huge *linbuf;
- +
- + /* Allocated size of linbuf array (# of elements). */
- + int linbufsize;
- +
- + /* Number of elements of linbuf containing valid data. */
- + int buffered_lines;
- +
- + /* Pointer to end of prefix of this file to ignore when hashing. */
- + char huge *prefix_end;
- +
- + /* Count of lines in the prefix. */
- + int prefix_lines;
- +
- + /* Pointer to start of suffix of this file to ignore when hashing. */
- + char huge *suffix_begin;
- +
- + /* Count of lines in the suffix. */
- + int suffix_lines;
- + #endif /* MSDOS */
-
- /* Vector, indexed by line number, containing an equivalence code for
- each line. It is this vector that is actually compared with that
- ***************
- *** 318,324 ****
- --- 409,419 ----
-
- /* Describe the two files currently being compared. */
-
- + #if defined(__TURBOC__) && !defined(GDIFF_MAIN)
- + extern struct file_data files[2];
- + #else
- struct file_data files[2];
- + #endif
-
- /* Queue up one-line messages to be printed at the end,
- when -l is specified. Each message is recorded with a `struct msg'. */
- ***************
- *** 366,370 ****
- --- 461,476 ----
- void print_1_line ();
- void print_message_queue ();
- void print_number_range ();
- +
- + #ifdef MSDOS
- + #ifndef __TURBOC__
- + void huge *hrealloc(void huge *, long, long);
- + #endif
- + #endif
- void print_script ();
- void translate_range ();
- +
- +
- + #ifdef PROTO
- + #include "proto.h"
- + #endif
- diff -cbBw orig/diff3.c new/diff3.c
- *** orig/diff3.c Tue Dec 24 19:13:24 1991
- --- new/diff3.c Tue Dec 24 19:26:32 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* Three-way file comparison program (diff3) for Project GNU
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- ***************
- *** 29,37 ****
- --- 31,67 ----
- */
- #include <stdio.h>
- #include <ctype.h>
- + #ifdef __TURBOC__
- + #include <types.h>
- + #else
- #include <sys/types.h>
- + #endif
- #include <sys/stat.h>
-
- + #include <getopt.h>
- +
- + #ifdef MSDOS
- +
- + #include <stdlib.h>
- +
- + extern FILE *popen(char *, char *);
- + extern int pclose(FILE *);
- +
- + #define WEXITSTATUS(stat_val) (stat_val & 255)
- + #define WIFEXITED(stat_val) (((unsigned)stat_val >> 8) == 0)
- + /* pclose() returns status in inverse byte order than wait() does */
- +
- + #define bcopy(s,d,n) memmove((d),(s),(n))
- + #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- + #define bzero(s,n) memset((s),0,(n))
- +
- + #define index strchr
- + #define rindex strrchr
- +
- + #else /* MSDOS */
- +
- + extern char **environ;
- +
- #ifdef USG
- #include <fcntl.h>
-
- ***************
- *** 58,63 ****
- --- 88,95 ----
- #define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
- #endif
-
- + #endif /* MSDOS */
- +
- #ifdef sparc
- /* vfork clobbers registers on the Sparc, so don't use it. */
- #define vfork fork
- ***************
- *** 390,398 ****
- void
- usage ()
- {
- ! fprintf (stderr, "Usage:\t%s [-exEX3 [-i | -m] [-L label1 -L label3]] file1 file2 file3\n",
- argv0);
- ! fprintf (stderr, "\tOnly one of [exEX3] allowed\n");
- exit (2);
- }
-
- --- 422,444 ----
- void
- usage ()
- {
- ! extern char *version_string;
- !
- ! printf ("\nGNU diff3, version %s\n", version_string);
- ! printf ("\nUsage:\t%s [-exEX3 [-a] [-i | -m] [-L label1 -L label3]] file1 file2 file3\n",
- argv0);
- !
- ! printf ("\n -e Create ed script."
- ! "\n -x ED script, write only overlapping diffs."
- ! "\n -E ED script, flag overlapping diffs."
- ! "\n -X ED script, write and flag only overlapping diffs."
- ! "\n -3 ED script, write only non-overlapping diffs."
- ! "\n -a Treat all files as text, never as binary."
- ! "\n -i Like -e, but append final :wq commands."
- ! "\n -m Output a merged file."
- ! "\n -L label use the specified label for lines output by the -E and -X options.\n");
- !
- ! printf ("\nOnly one of [exEX3] is allowed.\n");
- exit (2);
- }
-
- ***************
- *** 960,967 ****
- * Routines to input and parse two way diffs.
- */
-
- - extern char **environ;
- -
- #define DIFF_CHUNK_SIZE 10000
-
- struct diff_block *
- --- 1006,1011 ----
- ***************
- *** 1170,1182 ****
- --- 1214,1233 ----
- char *filea, *fileb;
- char **output_placement;
- {
- + #ifndef MSDOS
- char *argv[6];
- char **ap;
- + #endif
- int fds[2];
- char *diff_result;
- int current_chunk_size;
- int bytes;
- int total;
- + #ifdef MSDOS
- + FILE *pipe;
- + char buffer[256];
- + int wstatus;
- + #else
- int pid, w;
- int wstatus;
-
- ***************
- *** 1188,1194 ****
- --- 1239,1251 ----
- *ap++ = filea;
- *ap++ = fileb;
- *ap = (char *) 0;
- + #endif
-
- + #ifdef MSDOS
- + sprintf(buffer, "%s -a -- %s %s", diff_program, filea, fileb);
- + pipe = popen(buffer, "r");
- + fds[0] = fileno(pipe);
- + #else
- if (pipe (fds) < 0)
- perror_with_exit ("Pipe failed");
-
- ***************
- *** 1213,1218 ****
- --- 1270,1276 ----
- perror_with_exit ("Fork failed");
-
- close (fds[1]); /* Prevent erroneous lack of EOF */
- + #endif
- current_chunk_size = DIFF_CHUNK_SIZE;
- diff_result = (char *) xmalloc (current_chunk_size);
- total = 0;
- ***************
- *** 1222,1228 ****
- --- 1280,1291 ----
- current_chunk_size - total);
- total += bytes;
- if (total == current_chunk_size)
- + #ifdef MSDOS
- + diff_result = (char *) xrealloc (diff_result,
- + (current_chunk_size += DIFF_CHUNK_SIZE));
- + #else
- diff_result = (char *) xrealloc (diff_result, (current_chunk_size *= 2));
- + #endif
- } while (bytes);
-
- if (total != 0 && diff_result[total-1] != '\n')
- ***************
- *** 1230,1239 ****
- --- 1293,1306 ----
-
- *output_placement = diff_result;
-
- + #ifdef MSDOS
- + wstatus = pclose(pipe);
- + #else
- do
- if ((w = wait (&wstatus)) == -1)
- perror_with_exit ("Wait failed");
- while (w != pid);
- + #endif
-
- if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
- fatal ("Subsidiary diff failed");
- ***************
- *** 1332,1338 ****
- case DIFF_3RD:
- oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
-
- ! x[0] = oddoneout + '1';
- x[1] = '\0';
- dontprint = oddoneout==0;
- break;
- --- 1399,1405 ----
- case DIFF_3RD:
- oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
-
- ! x[0] = (char) (oddoneout + '1');
- x[1] = '\0';
- dontprint = oddoneout==0;
- break;
- diff -cbBw orig/dir.c new/dir.c
- *** orig/dir.c Tue Dec 24 19:13:24 1991
- --- new/dir.c Tue Dec 24 19:37:14 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* Read, sort and compare two directories. Used for GNU DIFF.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This file is part of GNU DIFF.
-
- ***************
- *** 31,36 ****
- --- 33,201 ----
- char **files; /* Sorted names of files in the dir */
- };
-
- + #if defined(MSDOS)
- + /*
- + ** due to difference of opinion btw gnu and microsoft about what
- + ** const means, const is defined away in diff.h, which causes warnings
- + ** when compiling the headers. This ugliness is avoided here.
- + */
- + #ifdef const
- + #undef const
- + #endif
- + #include <string.h>
- + #include <ctype.h>
- + #ifdef OS2
- + #define strcmp stricmp
- + /* stricmp() this is important for the HPFS because it is
- + /* case-preserving but NOT case-sensitive */
- + #include <stdlib.h>
- + #define INCL_NOPM
- + #include <os2.h>
- + #define _A_NORMAL 0x00
- + #define _A_SUBDIR 0x10
- + #define _MAX_NAME 256
- + #else
- + #ifdef __TURBOC__
- + #include <dir.h>
- + #define _A_NORMAL 0x00
- + #define _A_SUBDIR 0x10
- + #endif
- + #include <dos.h>
- + #define _MAX_NAME 13
- + #endif
- +
- + struct direct {
- + char d_name[_MAX_NAME];
- + };
- +
- + typedef struct _dir {
- + int first;
- + #ifdef OS2
- + FILEFINDBUF find;
- + #else
- + #ifdef __TURBOC__
- + struct ffblk dta;
- + #else
- + struct find_t dta;
- + #endif
- + #endif
- + struct direct current;
- + } DIR;
- +
- + #ifdef OS2
- + static HDIR hdir;
- + static USHORT count;
- + static BOOL lower;
- + #endif
- +
- + #ifdef OS2
- + int IsFileSystemFAT(char *dir)
- + {
- + USHORT nDrive;
- + ULONG lMap;
- + BYTE bData[64], bName[3];
- + USHORT cbData;
- +
- + if ( _osmode == DOS_MODE )
- + return TRUE;
- + else
- + {
- + /* We separate FAT and HPFS file systems here.
- + * Filenames read from a FAT system are converted to lower case
- + * while the case of filenames read from a HPFS (and other future
- + * file systems, like Unix-compatibles) is preserved.
- + */
- +
- + if ( isalpha(dir[0]) && (dir[1] == ':') )
- + nDrive = toupper(dir[0]) - '@';
- + else
- + DosQCurDisk(&nDrive, &lMap);
- +
- + bName[0] = (char) (nDrive + '@');
- + bName[1] = ':';
- + bName[2] = 0;
- +
- + cbData = sizeof(bData);
- +
- + if ( !DosQFSAttach(bName, 0U, 1U, bData, &cbData, 0L) )
- + return !strcmp(bData + (*(USHORT *) (bData + 2) + 7), "FAT");
- + else
- + return FALSE;
- +
- + /* End of this ugly code */
- + }
- + }
- + #endif
- +
- + DIR *
- + opendir(char *name) {
- + char localname[_MAX_NAME];
- + DIR *rval = malloc(sizeof(DIR));
- + strcpy(localname,name);
- + strcat(localname,"/*.*");
- + #ifdef OS2
- + lower = IsFileSystemFAT(name);
- + hdir = count = 1;
- + #endif
- + if(rval == NULL ||
- + #ifdef OS2
- + DosFindFirst(localname, &hdir, _A_NORMAL|_A_SUBDIR, &rval->find,
- + sizeof(FILEFINDBUF), &count, 0L) != 0)
- + #else
- + #ifdef __TURBOC__
- + findfirst(localname,&rval->dta,_A_NORMAL|_A_SUBDIR) != 0)
- + #else
- + _dos_findfirst(localname,_A_NORMAL|_A_SUBDIR,&rval->dta) != 0)
- + #endif
- + #endif
- + return NULL;
- + rval->first = 1;
- + return rval;
- + }
- +
- + void
- + closedir(DIR *x) {
- + free(x);
- + }
- +
- + struct direct *
- + readdir(DIR *thisdir) {
- + /*
- + ** first time through, we don't need to look for a file
- + */
- + if(!thisdir->first) {
- + #ifdef OS2
- + if(DosFindNext(hdir, &thisdir->find, sizeof(FILEFINDBUF),
- + &count) != 0)
- + #else
- + #ifdef __TURBOC__
- + if(findnext(&thisdir->dta) != 0)
- + #else
- + if(_dos_findnext(&thisdir->dta) != 0)
- + #endif
- + #endif
- + return NULL;
- + } else
- + thisdir->first = 0;
- + #ifdef OS2
- + strcpy(thisdir->current.d_name,thisdir->find.achName);
- + #else
- + #ifdef __BORLANDC__
- + strcpy(thisdir->current.d_name,thisdir->dta.ff_name);
- + #else
- + strcpy(thisdir->current.d_name,thisdir->dta.name);
- + #endif
- + #endif
- + /* thisdir->current.d_name[13] = '\0'; */
- + #ifdef OS2
- + if ( lower )
- + #endif
- + strlwr(thisdir->current.d_name);
- + return &thisdir->current;
- + }
- +
- + #endif /* MSDOS */
- +
- static struct dirdata
- dir_sort (dirname, nonex)
- char *dirname;
- ***************
- *** 135,142 ****
- int
- diff_dirs (name1, name2, handle_file, depth, nonex1, nonex2)
- char *name1, *name2;
- int (*handle_file) ();
- ! int nonex1, nonex2;
- {
- struct dirdata data1, data2;
- register int i1, i2;
- --- 300,315 ----
- int
- diff_dirs (name1, name2, handle_file, depth, nonex1, nonex2)
- char *name1, *name2;
- + #if !defined(MSDOS)
- int (*handle_file) ();
- ! #else
- ! /* sorry, rms, I can't live with the assumption that
- ! ** sizeof(char *) == sizeof(int)
- ! */
- ! int (*handle_file)(char *dir0,char *name0,
- ! char *dir1,char *name1,int depth);
- ! #endif
- ! int depth, nonex1, nonex2;
- {
- struct dirdata data1, data2;
- register int i1, i2;
- diff -cbBw orig/getopt.c new/getopt.c
- *** orig/getopt.c Tue Dec 24 19:13:26 1991
- --- new/getopt.c Tue Dec 24 19:19:20 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* Getopt for GNU.
- Copyright (C) 1987, 1989, 1990 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- ***************
- *** 15,25 ****
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- ! #ifdef __STDC__
- #define CONST const
- #else
- #define CONST
- #endif
-
- /* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- --- 17,30 ----
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- ! #if defined(__STDC__) || defined(MSDOS)
- #define CONST const
- #else
- #define CONST
- #endif
- + #ifdef MSDOS
- + #define STDC_HEADERS
- + #endif
-
- /* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- ***************
- *** 44,51 ****
- --- 49,64 ----
- #ifdef sparc
- #include <alloca.h>
- #else
- + #ifdef MSDOS
- + #ifdef __TURBOC__
- + #include <alloc.h>
- + #else
- + #include <malloc.h>
- + #endif
- + #else
- char *alloca ();
- #endif
- + #endif
- #endif /* not __GNUC__ */
-
- #if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__)
- ***************
- *** 72,77 ****
- --- 85,92 ----
- char *malloc ();
- #endif
-
- + static void exchange (char **);
- +
- /* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- ***************
- *** 376,382 ****
- p++, option_index++)
- if (!strncmp (p->name, nextchar, s - nextchar))
- {
- ! if (s - nextchar == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- --- 391,397 ----
- p++, option_index++)
- if (!strncmp (p->name, nextchar, s - nextchar))
- {
- ! if (s - nextchar == (int) strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- diff -cbBw orig/getopt.h new/getopt.h
- *** orig/getopt.h Tue Dec 24 19:13:26 1991
- --- new/getopt.h Tue Dec 24 19:19:24 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* declarations for getopt
- Copyright (C) 1989, 1990 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- ***************
- *** 70,76 ****
- int val;
- };
-
- ! #ifdef __STDC__
- extern const struct option *_getopt_long_options;
- #else
- extern struct option *_getopt_long_options;
- --- 72,78 ----
- int val;
- };
-
- ! #if defined(__STDC__) || defined(MSDOS)
- extern const struct option *_getopt_long_options;
- #else
- extern struct option *_getopt_long_options;
- ***************
- *** 87,93 ****
-
- extern int option_index;
-
- ! #ifdef __STDC__
- int getopt (int argc, char **argv, const char *shortopts);
- int getopt_long (int argc, char **argv, const char *shortopts,
- const struct option *longopts, int *longind);
- --- 89,95 ----
-
- extern int option_index;
-
- ! #if defined(__STDC__) || defined(MSDOS)
- int getopt (int argc, char **argv, const char *shortopts);
- int getopt_long (int argc, char **argv, const char *shortopts,
- const struct option *longopts, int *longind);
- diff -cbBw orig/getopt1.c new/getopt1.c
- *** orig/getopt1.c Tue Dec 24 19:13:26 1991
- --- new/getopt1.c Tue Dec 24 19:19:30 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* Getopt for GNU.
- Copyright (C) 1987, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- ***************
- *** 17,23 ****
-
- #include "getopt.h"
-
- ! #ifdef __STDC__
- #define CONST const
- #else
- #define CONST
- --- 19,25 ----
-
- #include "getopt.h"
-
- ! #if defined(__STDC__) || defined(MSDOS)
- #define CONST const
- #else
- #define CONST
- ***************
- *** 38,43 ****
- --- 40,46 ----
- int val;
-
- _getopt_long_options = long_options;
- + _getopt_long_only = 0;
- val = getopt (argc, argv, options);
- if (val == 0 && opt_index != NULL)
- *opt_index = option_index;
- diff -cbBw orig/io.c new/io.c
- *** orig/io.c Tue Dec 24 19:13:30 1991
- --- new/io.c Tue Dec 24 19:45:04 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* File I/O for GNU DIFF.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This file is part of GNU DIFF.
-
- ***************
- *** 20,27 ****
- --- 22,33 ----
- #include "diff.h"
-
- /* Rotate a value n bits to the left. */
- + #if !defined(MSDOS)
- #define UINT_BIT (sizeof (unsigned) * CHAR_BIT)
- #define ROL(v, n) ((v) << (n) | (v) >> UINT_BIT - (n))
- + #else
- + #define ROL(v,n) ((v) << (n) | (v) >> (sizeof(v) * CHAR_BIT) - (n))
- + #endif
-
- /* Given a hash value and a new character, return a new hash value. */
- #define HASH(h, c) ((c) + ROL (h, 7))
- ***************
- *** 57,66 ****
- --- 63,79 ----
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 0,
- + #ifdef MSDOS
- + 1, 1, 1, 1, 1, 1, 1, 1,
- + 1, 1, 1, 1, 1, 1, 1, 1,
- + 1, 1, 1, 1, 1, 1, 1, 1,
- + 1, 1, 1, 1, 1, 1, 1, 1,
- + #else
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- + #endif
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- ***************
- *** 101,106 ****
- --- 114,120 ----
- beyond those that current->bufsize describes:
- one for a newline (in case the text does not end with one)
- and one for a sentinel in find_identical_ends. */
- + #if !defined(MSDOS)
- else if ((current->stat.st_mode & S_IFMT) == S_IFREG)
- {
- current->bufsize = current->stat.st_size;
- ***************
- *** 136,146 ****
- if (cc < 0)
- pfatal_with_name (current->name);
- }
-
- /* Check first part of file to see if it's a binary file. */
- if (! always_text_flag
- && binary_file_p (current->buffer,
- ! min (current->buffered_chars, binary_file_threshold)))
- return 1;
-
- /* If not binary, make sure text ends in a newline,
- --- 150,201 ----
- if (cc < 0)
- pfatal_with_name (current->name);
- }
- + #else /* MSDOS */
- + else {
- + int count;
- + char huge *ptr;
- + char *buf;
- + #ifdef __TURBOC__
- + int cnt;
- + #endif
- +
- + current->bufsize = current->stat.st_size + 1;
- + if((current->buffer = halloc(current->bufsize + 2,sizeof(char))) == NULL)
- + fatal("virtual memory exhausted");
- +
- + current->buffered_chars = 0;
- + ptr = current->buffer;
- +
- + /* this kludge is the only way to prevent read() from segment
- + * wraparounds in real mode in a OS/2 family mode application :-( :-(
- + */
- +
- + if((buf = malloc(16384)) == NULL)
- + fatal("virtual memory exhausted");
- +
- + while((count = read(current->desc, buf, 16384)) > 0)
- + {
- + #ifdef __TURBOC__
- + for ( cnt = 0; cnt < count; cnt++ )
- + ptr[cnt] = buf[cnt];
- + #else
- + memcpy(ptr, buf, count); /* MS C memcpy is aware of huge pointers */
- + #endif
- + current->buffered_chars += count;
- + ptr += count;
- + }
- +
- + free(buf);
- +
- + if (count < 0)
- + pfatal_with_name (current->name);
- + }
- + #endif /* MSDOS */
-
- /* Check first part of file to see if it's a binary file. */
- if (! always_text_flag
- && binary_file_p (current->buffer,
- ! (int) min (current->buffered_chars, binary_file_threshold)))
- return 1;
-
- /* If not binary, make sure text ends in a newline,
- ***************
- *** 169,180 ****
- {
- unsigned h;
- int i;
- ! unsigned char *p = (unsigned char *) current->prefix_end, *ip, c;
-
- /* Attempt to get a good initial guess as to the number of lines. */
- current->linbufsize = current->buffered_chars / 50 + 5;
- current->linbuf
- = (struct line_def *) xmalloc (current->linbufsize * sizeof (struct line_def));
-
- if (function_regexp || output_style == OUTPUT_IFDEF)
- {
- --- 224,248 ----
- {
- unsigned h;
- int i;
- ! #if !defined(MSDOS)
- ! char *p = current->prefix_end, *ip, c;
- ! #else
- ! char huge *p = (char huge *) current->prefix_end;
- ! char huge *ip, c;
- ! int old;
- ! #endif
-
- /* Attempt to get a good initial guess as to the number of lines. */
- current->linbufsize = current->buffered_chars / 50 + 5;
- + #if !defined(MSDOS)
- current->linbuf
- = (struct line_def *) xmalloc (current->linbufsize * sizeof (struct line_def));
- + #else
- + current->linbuf
- + = halloc(current->linbufsize, sizeof(struct line_def));
- + if ( current->linbuf == NULL )
- + fatal("virtual memory exhausted");
- + #endif
-
- if (function_regexp || output_style == OUTPUT_IFDEF)
- {
- ***************
- *** 183,189 ****
- but since we don't know how many, it's easiest to find them all.
- If -D is specified, we need all the lines of the first file. */
- current->buffered_lines = 0;
- ! p = (unsigned char *) current->buffer;
- }
- else
- {
- --- 251,257 ----
- but since we don't know how many, it's easiest to find them all.
- If -D is specified, we need all the lines of the first file. */
- current->buffered_lines = 0;
- ! p = current->buffer;
- }
- else
- {
- ***************
- *** 195,212 ****
- current->buffered_lines = 0;
- for (i = 0; i < context + 1; ++i)
- /* Unless we are at the beginning, */
- ! if ((char *) p != current->buffer)
- /* Back up at least 1 char until at the start of a line. */
- ! while ((char *) --p != current->buffer && p[-1] != '\n')
- ;
- }
-
- ! while ((char *) p < current->suffix_begin)
- {
- h = 0;
- ip = p;
-
- ! if (current->prefix_end <= (char *) p)
- {
- /* Hash this line until we find a newline. */
- if (ignore_case_flag)
- --- 263,280 ----
- current->buffered_lines = 0;
- for (i = 0; i < context + 1; ++i)
- /* Unless we are at the beginning, */
- ! if (p != current->buffer)
- /* Back up at least 1 char until at the start of a line. */
- ! while ( --p != current->buffer && p[-1] != '\n')
- ;
- }
-
- ! while (p < current->suffix_begin)
- {
- h = 0;
- ip = p;
-
- ! if (current->prefix_end <= p)
- {
- /* Hash this line until we find a newline. */
- if (ignore_case_flag)
- ***************
- *** 291,298 ****
- --- 359,368 ----
- /* Maybe increase the size of the line table. */
- if (current->buffered_lines >= current->linbufsize)
- {
- + #ifndef MSDOS
- while (current->buffered_lines >= current->linbufsize)
- current->linbufsize *= 2;
- +
- current->linbuf
- = (struct line_def *) xrealloc (current->linbuf,
- current->linbufsize
- ***************
- *** 297,304 ****
- = (struct line_def *) xrealloc (current->linbuf,
- current->linbufsize
- * sizeof (struct line_def));
- }
- ! current->linbuf[current->buffered_lines].text = (char *) ip;
- current->linbuf[current->buffered_lines].length = p - ip + 1;
- current->linbuf[current->buffered_lines].hash = h;
- ++current->buffered_lines;
- --- 367,387 ----
- = (struct line_def *) xrealloc (current->linbuf,
- current->linbufsize
- * sizeof (struct line_def));
- + #else
- + old = current->linbufsize;
- +
- + while (current->buffered_lines >= current->linbufsize)
- + current->linbufsize += 2048;
- +
- + current->linbuf = hrealloc(current->linbuf,
- + (long) current->linbufsize * sizeof (struct line_def),
- + (long) old * sizeof (struct line_def));
- +
- + if ( current->linbuf == NULL )
- + fatal("too many lines");
- + #endif
- }
- ! current->linbuf[current->buffered_lines].text = ip;
- current->linbuf[current->buffered_lines].length = p - ip + 1;
- current->linbuf[current->buffered_lines].hash = h;
- ++current->buffered_lines;
- ***************
- *** 307,313 ****
- --- 390,400 ----
-
- i = 0;
- while ((i < context || output_style == OUTPUT_IFDEF)
- + #ifndef MSDOS
- && (char *) p < current->buffer + current->buffered_chars)
- + #else
- + && p < (char huge *) current->buffer + current->buffered_chars)
- + #endif
- {
- ip = p;
- while (*p++ != '\n')
- ***************
- *** 315,322 ****
- --- 402,411 ----
- /* Maybe increase the size of the line table. */
- if (current->buffered_lines >= current->linbufsize)
- {
- + #ifndef MSDOS
- while (current->buffered_lines >= current->linbufsize)
- current->linbufsize *= 2;
- +
- current->linbuf
- = (struct line_def *) xrealloc (current->linbuf,
- current->linbufsize
- ***************
- *** 321,328 ****
- = (struct line_def *) xrealloc (current->linbuf,
- current->linbufsize
- * sizeof (struct line_def));
- }
- ! current->linbuf[current->buffered_lines].text = (char *) ip;
- current->linbuf[current->buffered_lines].length = p - ip;
- current->linbuf[current->buffered_lines].hash = 0;
- ++current->buffered_lines;
- --- 410,430 ----
- = (struct line_def *) xrealloc (current->linbuf,
- current->linbufsize
- * sizeof (struct line_def));
- + #else
- + old = current->linbufsize;
- +
- + while (current->buffered_lines >= current->linbufsize)
- + current->linbufsize += 2048;
- +
- + current->linbuf = hrealloc(current->linbuf,
- + (long) current->linbufsize * sizeof (struct line_def),
- + (long) old * sizeof (struct line_def));
- +
- + if ( current->linbuf == NULL )
- + fatal("too many lines");
- + #endif
- }
- ! current->linbuf[current->buffered_lines].text = ip;
- current->linbuf[current->buffered_lines].length = p - ip;
- current->linbuf[current->buffered_lines].hash = 0;
- ++current->buffered_lines;
- ***************
- *** 342,348 ****
- --- 444,454 ----
- find_identical_ends (filevec)
- struct file_data filevec[];
- {
- + #ifndef MSDOS
- char *p0, *p1, *end0, *beg0;
- + #else
- + char huge *p0, huge *p1, huge *end0, huge *beg0;
- + #endif
- int lines;
-
- if (filevec[0].buffered_chars == 0 || filevec[1].buffered_chars == 0)
- ***************
- *** 383,397 ****
- /* Don't count missing newline as part of prefix in RCS mode. */
- if (ROBUST_OUTPUT_STYLE (output_style)
- && ((filevec[0].missing_newline
- ! && p0 - filevec[0].buffer > filevec[0].buffered_chars)
- ||
- (filevec[1].missing_newline
- ! && p1 - filevec[1].buffer > filevec[1].buffered_chars)))
- --p0, --p1, --lines;
-
- /* If the sentinel was passed, and lengths are equal, the
- files are identical. */
- ! if (p0 - filevec[0].buffer > filevec[0].buffered_chars
- && filevec[0].buffered_chars == filevec[1].buffered_chars)
- {
- filevec[0].prefix_end = p0 - 1;
- --- 489,503 ----
- /* Don't count missing newline as part of prefix in RCS mode. */
- if (ROBUST_OUTPUT_STYLE (output_style)
- && ((filevec[0].missing_newline
- ! && (p0 - filevec[0].buffer) > filevec[0].buffered_chars)
- ||
- (filevec[1].missing_newline
- ! && (p1 - filevec[1].buffer) > filevec[1].buffered_chars)))
- --p0, --p1, --lines;
-
- /* If the sentinel was passed, and lengths are equal, the
- files are identical. */
- ! if ((p0 - filevec[0].buffer) > filevec[0].buffered_chars
- && filevec[0].buffered_chars == filevec[1].buffered_chars)
- {
- filevec[0].prefix_end = p0 - 1;
- ***************
- *** 435,445 ****
- else
- /* Figure out where P0 will be when P1 is at the end of the prefix.
- Thus we only need to test P0. */
- ! beg0 = (filevec[0].prefix_end
- ! + filevec[0].buffered_chars - filevec[1].buffered_chars);
-
- /* Scan back until chars don't match or we reach that point. */
- ! while (p0 != beg0)
- {
- char c = *--p0;
- if (c != *--p1)
- --- 541,551 ----
- else
- /* Figure out where P0 will be when P1 is at the end of the prefix.
- Thus we only need to test P0. */
- ! beg0 = filevec[0].prefix_end
- ! + (filevec[0].buffered_chars - filevec[1].buffered_chars);
-
- /* Scan back until chars don't match or we reach that point. */
- ! while (p0 > beg0)
- {
- char c = *--p0;
- if (c != *--p1)
- ***************
- *** 483,488 ****
- --- 589,597 ----
- {
- struct equivclass *next; /* Next item in this bucket. */
- struct line_def line; /* A line that fits this class. */
- + #ifdef MSDOS
- + long dummy; /* to pad struct size to a power of two, 16 */
- + #endif
- };
-
- /* Hash-table: array of buckets, each being a chain of equivalence classes. */
- ***************
- *** 494,511 ****
- /* Array in which the equivalence classes are allocated.
- The bucket-chains go through the elements in this array.
- The number of an equivalence class is its index in this array. */
- ! static struct equivclass *equivs;
-
- /* Index of first free element in the array `equivs'. */
- ! static int equivs_index;
-
- /* Size allocated to the array `equivs'. */
- ! static int equivs_alloc;
-
- /* Largest primes less than some power of two, for nbuckets. Values range
- from useful to preposterous. If one of these numbers isn't prime
- after all, don't blame it on me, blame it on primes (6) . . . */
- ! static int primes[] =
- {
- 509,
- 1021,
- --- 603,620 ----
- /* Array in which the equivalence classes are allocated.
- The bucket-chains go through the elements in this array.
- The number of an equivalence class is its index in this array. */
- ! static struct equivclass huge *equivs;
-
- /* Index of first free element in the array `equivs'. */
- ! static long equivs_index;
-
- /* Size allocated to the array `equivs'. */
- ! static long equivs_alloc;
-
- /* Largest primes less than some power of two, for nbuckets. Values range
- from useful to preposterous. If one of these numbers isn't prime
- after all, don't blame it on me, blame it on primes (6) . . . */
- ! static long primes[] =
- {
- 509,
- 1021,
- ***************
- *** 538,544 ****
- int n;
- {
- int bucket;
- ! struct equivclass *b, *p = NULL;
-
- /* Equivalence class 0 is permanently allocated to lines that were
- not hashed because they were parts of identical prefixes or
- --- 647,653 ----
- int n;
- {
- int bucket;
- ! struct equivclass huge *b, huge *p = NULL;
-
- /* Equivalence class 0 is permanently allocated to lines that were
- not hashed because they were parts of identical prefixes or
- ***************
- *** 564,569 ****
- --- 673,681 ----
-
- /* Create a new equivalence class in this bucket. */
-
- + if (equivs_index >= equivs_alloc)
- + fatal ("too many differences, hash table overflow");
- +
- p = &equivs[equivs_index++];
- p->next = buckets[bucket];
- buckets[bucket] = p;
- ***************
- *** 601,608 ****
- }
-
- /* This is guaranteed to be enough space. */
- ! equivs_alloc = filevec[0].buffered_lines + filevec[1].buffered_lines + 1;
- equivs = (struct equivclass *) xmalloc (equivs_alloc * sizeof (struct equivclass));
- /* Equivalence class 0 is permanently safe for lines that were not
- hashed. Real equivalence classes start at 1. */
- equivs_index = 1;
- --- 713,726 ----
- }
-
- /* This is guaranteed to be enough space. */
- ! equivs_alloc = (long) filevec[0].buffered_lines + filevec[1].buffered_lines + 1L;
- ! #ifndef MSDOS
- equivs = (struct equivclass *) xmalloc (equivs_alloc * sizeof (struct equivclass));
- + #else
- + equivs = halloc (equivs_alloc, sizeof (struct equivclass));
- + if ( equivs == NULL )
- + fatal("virtual memory exhausted");
- + #endif
- /* Equivalence class 0 is permanently safe for lines that were not
- hashed. Real equivalence classes start at 1. */
- equivs_index = 1;
- ***************
- *** 611,618 ****
- --- 729,752 ----
- while (primes[primes_index] < equivs_alloc / 3)
- primes_index++;
-
- + #ifndef MSDOS
- buckets = (struct equivclass **) xmalloc (primes[primes_index] * sizeof (struct equivclass *));
- bzero (buckets, primes[primes_index] * sizeof (struct equivclass *));
- + #else
- + buckets = halloc (primes[primes_index], sizeof (struct equivclass *));
- + #ifdef __TURBOC__
- + /* Microsoft C's halloc already zeroes out the allocated memory.
- + So this bzero call is only needed for Turbo C and Borland C.
- + But note that the block may be bigger than 64k and that the bzero
- + (actually memset) will not fill out the whole block. But this
- + situation is not very likely to occur, because with Turbo C or
- + Borland C, you can only make a MS-DOS program, who's memory
- + is too restricted to diff such big files that this situation
- + may occur.
- + */
- + bzero (buckets, primes[primes_index] * sizeof (struct equivclass *));
- + #endif
- + #endif
- nbuckets = primes[primes_index];
-
- for (i = 0; i < 2; ++i)
- ***************
- *** 626,633 ****
- --- 760,772 ----
-
- filevec[0].equiv_max = filevec[1].equiv_max = equivs_index;
-
- + #ifndef MSDOS
- free (equivs);
- free (buckets);
- + #else
- + hfree (equivs);
- + hfree (buckets);
- + #endif
-
- return 0;
- }
- diff -cbBw orig/limits.h new/limits.h
- *** orig/limits.h Tue Dec 24 19:13:30 1991
- --- new/limits.h Tue Dec 24 19:27:48 1991
- ***************
- *** 1,3 ****
- --- 1,9 ----
- + /*
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
- + */
- +
- +
- /* Number of bits in a `char'. */
- #define CHAR_BIT 8
-
- ***************
- *** 28,38 ****
- --- 34,52 ----
- #define USHRT_MAX 65535U
-
- /* Minimum and maximum values a `signed int' can hold. */
- + #ifdef MSDOS
- + #define INT_MIN (-32768)
- + #define INT_MAX 32767
- +
- + /* Maximum value an `unsigned int' can hold. (Minimum is 0). */
- + #define UINT_MAX 65535U
- + #else
- #define INT_MIN (-INT_MAX-1)
- #define INT_MAX 2147483647
-
- /* Maximum value an `unsigned int' can hold. (Minimum is 0). */
- #define UINT_MAX 4294967295U
- + #endif
-
- /* Minimum and maximum values a `signed long int' can hold.
- (Same as `int'). */
- Only in new: pc-files
- Only in orig: regex.c
- Only in orig: regex.h
- diff -cbBw orig/util.c new/util.c
- *** orig/util.c Tue Dec 24 19:13:34 1991
- --- new/util.c Tue Dec 24 19:19:38 1991
- ***************
- *** 1,5 ****
- --- 1,7 ----
- /* Support routines for GNU DIFF.
- Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
-
- This file is part of GNU DIFF.
-
- ***************
- *** 51,57 ****
- char *arg;
- char *arg1;
- {
- ! fprintf (stderr, "%s: ", program);
- fprintf (stderr, format, arg, arg1);
- fprintf (stderr, "\n");
- }
- --- 53,59 ----
- char *arg;
- char *arg1;
- {
- ! fprintf (stderr, "\n%s: ", program);
- fprintf (stderr, format, arg, arg1);
- fprintf (stderr, "\n");
- }
- ***************
- *** 129,134 ****
- --- 131,147 ----
- strcat (name, " ");
- strcat (name, name1);
-
- + #if defined(MSDOS)
- + if (paginate_flag)
- + {
- + extern FILE *popen();
- +
- + /* Fork a `pr' and make OUTFILE a pipe to it. */
- + outfile = popen("pr -o -", "w");
- + fprintf (outfile, "%s\n", name);
- + }
- + else
- + #else
- if (paginate_flag)
- {
- int pipes[2];
- ***************
- *** 164,169 ****
- --- 177,183 ----
- }
- }
- else
- + #endif
- {
-
- /* If -l was not specified, output the diff straight to `stdout'. */
- ***************
- *** 172,178 ****
-
- /* If handling multiple files (because scanning a directory),
- print which files the following output is about. */
- ! if (depth > 0)
- printf ("%s\n", name);
- }
-
- --- 186,192 ----
-
- /* If handling multiple files (because scanning a directory),
- print which files the following output is about. */
- ! if (depth > 0 && !output_patch_flag)
- printf ("%s\n", name);
- }
-
- ***************
- *** 187,194 ****
- --- 201,212 ----
- {
- if (outfile != stdout)
- {
- + #if defined(MSDOS)
- + pclose (outfile);
- + #else
- fclose (outfile);
- wait (0);
- + #endif
- }
- }
-
- ***************
- *** 201,207 ****
- --- 219,229 ----
- line_cmp (s1, s2)
- struct line_def *s1, *s2;
- {
- + #ifdef MSDOS
- + char huge *t1, huge *t2;
- + #else
- register char *t1, *t2;
- + #endif
- register char end_char = line_end_char;
- int savechar;
-
- ***************
- *** 382,388 ****
- --- 404,414 ----
- struct line_def *line;
- {
- int length = line->length; /* must be nonzero */
- + #ifdef MSDOS
- + const char huge *text = line->text; /* Help the compiler. */
- + #else
- const char *text = line->text; /* Help the compiler. */
- + #endif
- FILE *out = outfile; /* Help the compiler some more. */
-
- /* If -T was specified, use a Tab between the line-flag and the text.
- diff -cbBw orig/version.c new/version.c
- *** orig/version.c Tue Dec 24 19:13:34 1991
- --- new/version.c Tue Dec 24 19:29:16 1991
- ***************
- *** 1,3 ****
- /* Version number of GNU diff. */
-
- ! char *version_string = "1.15";
- --- 1,11 ----
- /* Version number of GNU diff. */
- + /*
- + Modified for DOS and OS/2 on 1991/09/14 by Kai Uwe Rommel
- + <rommel@informatik.tu-muenchen.de>.
- + */
-
- ! char *version_string = "1.15-ms";
- !
- ! #ifdef __TURBOC__
- ! unsigned _stklen = 0x8000;
- ! #endif
-