home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-16 | 54.4 KB | 1,911 lines |
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:19:54 1991
- --- analyze.c Tue Mar 12 17:18:32 1991
- ***************
- *** 17,22 ****
- --- 17,31 ----
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/analyze.c 1.15.0.2 91/03/12 17:05:59 tho Exp $ */
- +
- /* The basic algorithm is described in:
- "An O(ND) Difference Algorithm and its Variations", Eugene Myers,
- Algorithmica Vol. 1 No. 2, 1986, p 251. */
- ***************
- *** 34,39 ****
- --- 43,58 ----
- void pr_forward_ed_script ();
- void setup_output ();
-
- + #ifdef __STDC__
- + static int diag(int, int, int, int, int *);
- + static void compareseq(int, int, int, int);
- + static void shift_boundaries(struct file_data *);
- + static void discard_confusing_lines(struct file_data *);
- + static struct change *add_change(int, int, int, int, struct change *);
- + static struct change *build_reverse_script(struct file_data *);
- + static struct change *build_script(struct file_data *);
- + #endif /* __STDC__ */
- +
- extern int no_discards;
-
- static int *xvec, *yvec; /* Vectors being compared. */
- ***************
- *** 729,738 ****
- --- 748,759 ----
- /* See if the two named files are actually the same physical file.
- If so, we know they are identical without actually reading them. */
-
- + #ifndef MSDOS
- 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 */
-
- binary = read_files (filevec);
-
- ***************
- *** 743,751 ****
- --- 764,781 ----
-
- if (binary || no_details_flag)
- {
- + #ifdef MSDOS
- + /***********************************************************/
- + /* FIXME: this looses when FILEVEC[1].BUFFERED_CHARS > 64k */
- + /***********************************************************/
- int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
- || bcmp (filevec[0].buffer, filevec[1].buffer,
- + (size_t) filevec[1].buffered_chars));
- + #else /* not MSDOS */
- + int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
- + || bcmp (filevec[0].buffer, filevec[1].buffer,
- filevec[1].buffered_chars));
- + #endif /* not MSDOS */
- if (differs)
- message (binary ? "Binary files %s and %s differ\n"
- : "Files %s and %s differ\n",
- ***************
- *** 753,759 ****
- --- 783,794 ----
-
- for (i = 0; i < 2; ++i)
- if (filevec[i].buffer)
- + #ifdef MSDOS
- + hfree (filevec[i].buffer);
- + #else /* not MSDOS */
- free (filevec[i].buffer);
- + #endif /* not MSDOS */
- +
- return differs;
- }
-
- ***************
- *** 900,906 ****
- --- 935,945 ----
- for (i = 0; i < 2; ++i)
- {
- if (filevec[i].buffer != 0)
- + #ifdef MSDOS
- + hfree (filevec[i].buffer);
- + #else /* not MSDOS */
- free (filevec[i].buffer);
- + #endif /* not MSDOS */
- free (filevec[i].linbuf);
- }
-
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:19:56 1991
- --- context.c Tue Mar 12 17:18:34 1991
- ***************
- *** 17,30 ****
- --- 17,52 ----
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/context.c 1.15.0.2 91/03/12 17:06:06 tho Exp $ */
- +
- #include "diff.h"
- #include "regex.h"
-
- + #ifdef __STDC__
- + static void print_context_number_range (struct file_data *file, int a, int b);
- + static void pr_context_hunk (struct change *hunk);
- + static void pr_unidiff_hunk (struct change *hunk);
- + static struct change *find_hunk (struct change *start);
- + static void mark_ignorable (struct change *script);
- + static void find_function (struct file_data *file, int linenum,
- + char **linep, int *lenp);
- + static void print_context_label (const char *mark, struct file_data *inf,
- + const char *label);
- + static void print_unidiff_number_range (struct file_data *file, int a, int b);
- + #else /* not __STDC__ */
- static void pr_context_hunk ();
- static void pr_unidiff_hunk ();
- static struct change *find_hunk ();
- static void mark_ignorable ();
- static void find_function ();
- + #endif /* not __STDC__ */
-
- /* Last place find_function started searching from. */
- static int find_function_last_search;
- ***************
- *** 56,61 ****
- --- 78,94 ----
- struct file_data *inf;
- int unidiff_flag;
- {
- + #ifdef MSDOS
- + /* If we're dealing with empty files or the standard input,
- + the current time seems to be a reasonable approximation ....
- + MSC's ctime() returns NULL for invalid times, this breaks
- + the context diff format! */
- + if (!inf[0].stat.st_mtime)
- + time (&inf[0].stat.st_mtime);
- + if (!inf[1].stat.st_mtime)
- + time (&inf[1].stat.st_mtime);
- + #endif /* MSDOS */
- +
- if (unidiff_flag)
- {
- print_context_label ("---", &inf[0], file_label[0]);
- ***************
- *** 397,403 ****
- --- 430,440 ----
- script->link = next;
-
- /* If the change is ignorable, mark it. */
- + #ifdef MSDOS
- + script->ignore = (char) (!deletes && !inserts);
- + #else /* not MSDOS */
- script->ignore = (!deletes && !inserts);
- + #endif /* not MSDOS */
-
- /* Advance to the following change. */
- script = next;
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:19:58 1991
- --- diff.c Tue Mar 12 17:18:38 1991
- ***************
- *** 20,30 ****
- --- 20,53 ----
- /* GNU DIFF was written by Mike Haertel, David Hayes,
- Richard Stallman and Len Tower. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/diff.c 1.15.0.2 91/03/12 17:06:09 tho Exp $ */
- +
- #define GDIFF_MAIN
- #include "regex.h"
- #include "diff.h"
- #include "getopt.h"
-
- + #ifdef __STDC__
- + extern void main (int argc, char **argv);
- + static void usage(void);
- + static char *option_list(char * *, int);
- + static void specify_style(enum output_style);
- + static int compare_files(char *, char *, char *, char *, int);
- + extern int getopt(int, char * *, char *);
- + #else
- + static void usage();
- + static char *option_list();
- + static void specify_style();
- + static int compare_files();
- + extern int getopt();
- + #endif /* __STDC__ */
-
- /* Nonzero for -r: if comparing two directories,
- compare their common subdirectories recursively. */
- ***************
- *** 106,111 ****
- --- 129,137 ----
- {0, 0, 0, 0}
- };
-
- + #ifdef __STDC__
- + void
- + #endif /* __STDC__ */
- main (argc, argv)
- int argc;
- char *argv[];
- ***************
- *** 399,404 ****
- --- 425,431 ----
- exit (val);
- }
-
- + void
- usage ()
- {
- fprintf (stderr, "\
- ***************
- *** 417,422 ****
- --- 444,450 ----
- exit (2);
- }
-
- + void
- specify_style (style)
- enum output_style style;
- {
- ***************
- *** 509,514 ****
- --- 537,543 ----
- /* See if the two named files are actually the same physical file.
- If so, we know they are identical without actually reading them. */
-
- + #ifndef MSDOS
- if (output_style != OUTPUT_IFDEF
- && inf[0].stat.st_ino == inf[1].stat.st_ino
- && inf[0].stat.st_dev == inf[1].stat.st_dev
- ***************
- *** 518,523 ****
- --- 547,553 ----
- val = 0;
- goto done;
- }
- + #endif /* MSDOS */
-
- if (name0 == 0)
- inf[0].dir_p = inf[1].dir_p;
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:00 1991
- --- diff.h Tue Mar 12 17:19:06 1991
- ***************
- *** 17,23 ****
- --- 17,32 ----
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
-
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/diff.h 1.15.0.2 91/03/12 17:06:56 tho Exp $ */
- +
- +
- #include <ctype.h>
- #include <stdio.h>
- #include <sys/types.h>
- ***************
- *** 25,30 ****
- --- 34,46 ----
-
- #ifdef USG
- #include <time.h>
- + #ifdef MSDOS
- + #include <stdlib.h>
- + #include <malloc.h>
- + #include <string.h>
- + #include <process.h>
- + #include <io.h>
- + #endif /* MSDOS */
- #ifdef HAVE_NDIR
- #ifdef NDIR_IN_SYS
- #include <sys/ndir.h>
- ***************
- *** 47,57 ****
- #ifdef USG
- /* Define needed BSD functions in terms of sysV library. */
-
- #define bcopy(s,d,n) memcpy((d),(s),(n))
- #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- #define bzero(s,n) memset((s),0,(n))
-
- ! #ifndef XENIX
- #define dup2(f,t) (close(t),fcntl((f),F_DUPFD,(t)))
- #endif
-
- --- 63,77 ----
- #ifdef USG
- /* Define needed BSD functions in terms of sysV library. */
-
- + #ifdef MSDOS
- + #define bcopy(s,d,n) memmove((d),(s),(n)) /* more save! */
- + #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))
-
- ! #if !defined (XENIX) && !defined (MSDOS)
- #define dup2(f,t) (close(t),fcntl((f),F_DUPFD,(t)))
- #endif
-
- ***************
- *** 66,81 ****
- --- 86,105 ----
- #endif
-
- #include <errno.h>
- + #ifndef MSDOS /* have it VOLATILE in <stdlib.h> */
- extern int errno;
- extern int sys_nerr;
- extern char *sys_errlist[];
- + #endif /* not MSDOS */
-
- #define EOS (0)
- #define FALSE (0)
- #define TRUE 1
-
- + #ifndef MSDOS /* have it in <stdlib.h> */
- #define min(a,b) ((a) <= (b) ? (a) : (b))
- #define max(a,b) ((a) >= (b) ? (a) : (b))
- + #endif
-
- #ifndef PR_FILE_NAME
- #define PR_FILE_NAME "/bin/pr"
- ***************
- *** 90,96 ****
- #endif
-
- /* Support old-fashioned C compilers. */
- ! #if !defined (__STDC__) && !defined (__GNUC__)
- #define const
- #endif
-
- --- 114,120 ----
- #endif
-
- /* Support old-fashioned C compilers. */
- ! #if !defined (__STDC__) && !defined (__GNUC__) || defined (MSDOS)
- #define const
- #endif
-
- ***************
- *** 97,102 ****
- --- 121,134 ----
- #ifndef O_RDONLY
- #define O_RDONLY 0
- #endif
- +
- + #ifdef MSDOS
- + #if !defined (_MSC_VER) || (_MSC_VER < 600)
- + #define _huge huge
- + #endif /* MSC 5.1 */
- + #else /* not MSDOS */
- + #define _huge
- + #endif /* not MSDOS */
-
- /* Variables for command line options */
-
- ***************
- *** 239,245 ****
- /* Data on one line of text. */
-
- struct line_def {
- ! char *text;
- int length;
- unsigned hash;
- };
- --- 271,277 ----
- /* Data on one line of text. */
-
- struct line_def {
- ! char _huge *text;
- int length;
- unsigned hash;
- };
- ***************
- *** 253,263 ****
- int dir_p; /* 1 if file is a directory */
-
- /* Buffer in which text of file is read. */
- ! char * buffer;
- /* Allocated size of buffer. */
- int bufsize;
- /* Number of valid characters now in the buffer. */
- int buffered_chars;
-
- /* Array of data on analyzed lines of this chunk of this file. */
- struct line_def *linbuf;
- --- 285,302 ----
- int dir_p; /* 1 if file is a directory */
-
- /* Buffer in which text of file is read. */
- ! char _huge * buffer; /* Allocated size of buffer. */
- ! #ifdef MSDOS
- /* Allocated size of buffer. */
- + long bufsize;
- + /* Number of valid characters now in the buffer. */
- + long buffered_chars;
- + #else /* not MSDOS */
- + /* Allocated size of buffer. */
- int bufsize;
- /* Number of valid characters now in the buffer. */
- int buffered_chars;
- + #endif /* not MSDOS */
-
- /* Array of data on analyzed lines of this chunk of this file. */
- struct line_def *linbuf;
- ***************
- *** 269,281 ****
- int buffered_lines;
-
- /* Pointer to end of prefix of this file to ignore when hashing. */
- ! char *prefix_end;
-
- /* Count of lines in the prefix. */
- int prefix_lines;
-
- /* Pointer to start of suffix of this file to ignore when hashing. */
- ! char *suffix_begin;
-
- /* Count of lines in the suffix. */
- int suffix_lines;
- --- 308,320 ----
- 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;
- ***************
- *** 347,370 ****
-
- #ifdef __STDC__
- #define VOID void
- #else
- #define VOID char
- ! #endif
- ! VOID *xmalloc ();
- ! VOID *xrealloc ();
- char *concat ();
- void free ();
- char *rindex ();
- char *index ();
-
- - void analyze_hunk ();
- - void error ();
- - void fatal ();
- void message ();
- - void perror_with_name ();
- - void pfatal_with_name ();
- - void print_1_line ();
- void print_message_queue ();
- ! void print_number_range ();
- void print_script ();
- void translate_range ();
- --- 386,447 ----
-
- #ifdef __STDC__
- #define VOID void
- +
- + extern int diff_2_files(struct file_data *, int);
- + extern void print_context_header (struct file_data *inf, int unidiff_flag);
- + extern void print_context_script (struct change *script, int unidiff_flag);
- + extern int diff_dirs (char *name1, char *name2,
- + int (*handle_file) (char *, char *, char *, char *, int),
- + int depth, int nonex1, int nonex2);
- + extern void print_rcs_script (struct change *);
- + extern void print_ed_script (struct change *);
- + extern void pr_forward_ed_script (struct change *);
- + extern void print_ifdef_script (struct change *);
- + extern int read_files (struct file_data *);
- + extern void print_normal_script (struct change *);
- + extern int line_cmp (struct line_def *, struct line_def *);
- + extern void pfatal_with_name (char *);
- + extern void *xcalloc (int, int);
- + extern void print_1_line (char *, struct line_def *);
- + extern void message (char *,...);
- + extern void print_message_queue (void);
- + extern struct change *find_change (struct change *);
- + extern void error (char *,...);
- + extern char *concat (char *, char *, char *);
- + extern int change_letter (int, int);
- + extern void setup_output (char *, char *, int);
- + extern void *xmalloc (unsigned int);
- + extern struct change *find_reverse_change (struct change *);
- + extern void fatal (char *);
- + extern void debug_script (struct change *sp);
- + extern int translate_line_number (struct file_data *, int);
- + extern void finish_output (void);
- + extern void perror_with_name (char *);
- + extern void *xrealloc (void *, unsigned int);
- + extern void fatal_with_name (char *, char *);
- + extern void translate_range (struct file_data *, int, int, int *, int *);
- + extern void print_number_range (char, struct file_data *, int, int);
- + extern void print_script (struct change *,
- + struct change *(*)(struct change *),
- + void (*)(struct change *));
- + extern void analyze_hunk (struct change *, int *, int *, int *, int *, int *, int *);
- + extern long hread (int fd, void _huge *buffer, long bytes);
- + extern void _huge *xhalloc (long);
- + extern void _huge *xhrealloc (void _huge *ptr, long new_size, long old_size);
- +
- #else
- #define VOID char
- !
- ! char *xmalloc ();
- ! char *xrealloc ();
- char *concat ();
- void free ();
- char *rindex ();
- char *index ();
-
- void message ();
- void print_message_queue ();
- !
- ! #endif /* __STDC__ */
- void print_script ();
- void translate_range ();
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:04 1991
- --- diff3.c Tue Mar 12 17:18:46 1991
- ***************
- *** 15,23 ****
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- -
- /* Written by Randy Smith */
-
- #ifdef __STDC__
- #define VOID void
- #else
- --- 15,31 ----
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- /* Written by Randy Smith */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/diff3.c 1.15.0.2 91/03/12 17:06:13 tho Exp $ */
- +
- #ifdef __STDC__
- #define VOID void
- #else
- ***************
- *** 35,46 ****
- #ifdef USG
- #include <fcntl.h>
-
- /* Define needed BSD functions in terms of sysV library. */
-
- #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- #define bzero(s,n) memset((s),0,(n))
-
- ! #ifndef XENIX
- #define dup2(f,t) (close(t),fcntl((f),F_DUPFD,(t)))
- #endif
-
- --- 43,64 ----
- #ifdef USG
- #include <fcntl.h>
-
- + #ifdef MSDOS
- + #include <stdlib.h>
- + #include <sys/types.h>
- + #include <sys/stat.h>
- + #include <io.h>
- + #include <process.h>
- + #include <string.h>
- + static char *tmpfilename (char *template);
- + #endif /* MSDOS */
- +
- /* Define needed BSD functions in terms of sysV library. */
-
- #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- #define bzero(s,n) memset((s),0,(n))
-
- ! #if !defined (XENIX) && !defined (MSDOS)
- #define dup2(f,t) (close(t),fcntl((f),F_DUPFD,(t)))
- #endif
-
- ***************
- *** 209,214 ****
- --- 227,267 ----
- /*
- * Forward function declarations.
- */
- + #ifdef __STDC__
- +
- + extern void main (int argc, char **argv);
- + static int myread (int, char *, int);
- + static struct diff_block *process_diff (char *, char *);
- + static void perror_with_exit (char *string);
- + static void fatal (char *string);
- + static void usage (void);
- + static void *xmalloc (size_t n);
- + static void *xrealloc (void *ptr, size_t n);
- + static char *tmpfilename (char *);
- + static char *read_diff (char *filea, char *fileb, char **output_placement);
- + static enum diff_type process_diff_control (char **, struct diff_block *);
- + static int copy_stringlist (char **, int *, char **, int *, int);
- + static struct diff3_block *create_diff3_block (int, int, int, int, int, int);
- + static struct diff3_block *make_3way_diff (struct diff_block *,
- + struct diff_block *);
- + static int compare_line_list (char **, int *, char **, int *, int);
- + static int output_diff3_edscript (FILE *outputfile, struct diff3_block *diff,
- + int mapping[3], int rev_mapping[3],
- + char *file0, char *file1, char *file2);
- + static int output_diff3_merge (FILE *commonfile, FILE *outputfile,
- + struct diff3_block *diff,
- + int mapping[3], int rev_mapping[3],
- + char *file0, char *file1, char *file2);
- + static void output_diff3 (FILE *outputfile, struct diff3_block *diff,
- + int mapping[3], int rev_mapping[3]);
- + static char *scan_diff_line (char *, char * *, int *, char *, char);
- + static struct diff3_block *reverse_diff3_blocklist (struct diff3_block *);
- + static struct diff3_block *using_to_diff3_block (struct diff_block **, struct diff_block * *, int, int, struct diff3_block *);
- +
- + extern int getopt (int, char * *, char *);
- +
- + #else
- +
- struct diff_block *process_diff ();
- struct diff3_block *make_3way_diff ();
- void output_diff3 ();
- ***************
- *** 230,235 ****
- --- 283,290 ----
- VOID *xmalloc ();
- VOID *xrealloc ();
-
- + #endif /* __STDC__ */
- +
- char diff_program[] = DIFF_PROGRAM;
-
- /*
- ***************
- *** 236,241 ****
- --- 291,299 ----
- * Main program. Calls diff twice on two pairs of input files,
- * combines the two diffs, and outputs them.
- */
- + #ifdef __STDC__
- + void
- + #endif /* __STDC__ */
- main (argc, argv)
- int argc;
- char **argv;
- ***************
- *** 960,966 ****
- --- 1018,1026 ----
- * Routines to input and parse two way diffs.
- */
-
- + #ifndef MSDOS
- extern char **environ;
- + #endif /* MSDOS */
-
- #define DIFF_CHUNK_SIZE 10000
-
- ***************
- *** 1180,1185 ****
- --- 1240,1250 ----
- int pid, w;
- int wstatus;
-
- + #ifdef MSDOS
- + int save_stdout;
- + char *pipe_file = tmpfilename ("diXXXXXX");
- + #endif /* MSDOS */
- +
- ap = argv;
- *ap++ = diff_program;
- if (always_text)
- ***************
- *** 1189,1194 ****
- --- 1254,1274 ----
- *ap++ = fileb;
- *ap = (char *) 0;
-
- +
- + #ifdef MSDOS
- +
- + save_stdout = dup (1);
- + fds[0] = open (pipe_file, O_CREAT|O_RDWR|O_TEXT,S_IREAD|S_IWRITE);
- + dup2 (fds[0], 1);
- +
- + if ((spawnvp (P_WAIT, diff_program, argv)) == -1)
- + perror_with_exit ("can't spawn diff");
- +
- + dup2 (save_stdout, 1);
- + lseek (fds[0], 0L, SEEK_SET);
- +
- + #else
- +
- if (pipe (fds) < 0)
- perror_with_exit ("Pipe failed");
-
- ***************
- *** 1213,1218 ****
- --- 1293,1301 ----
- perror_with_exit ("Fork failed");
-
- close (fds[1]); /* Prevent erroneous lack of EOF */
- +
- + #endif /* MSDOS */
- +
- current_chunk_size = DIFF_CHUNK_SIZE;
- diff_result = (char *) xmalloc (current_chunk_size);
- total = 0;
- ***************
- *** 1230,1235 ****
- --- 1313,1321 ----
-
- *output_placement = diff_result;
-
- + #ifdef MSDOS
- + unlink (pipe_file);
- + #else /* not MSDOS */
- do
- if ((w = wait (&wstatus)) == -1)
- perror_with_exit ("Wait failed");
- ***************
- *** 1237,1242 ****
- --- 1323,1329 ----
-
- if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
- fatal ("Subsidiary diff failed");
- + #endif /* not MSDOS */
-
- return diff_result + total;
- }
- ***************
- *** 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;
- --- 1419,1425 ----
- case DIFF_3RD:
- oddoneout = rev_mapping[(int) ptr->correspond - (int) DIFF_1ST];
-
- ! x[0] = (char) oddoneout + '1';
- x[1] = '\0';
- dontprint = oddoneout==0;
- break;
- ***************
- *** 1400,1406 ****
- *
- * Returns 1 if overlaps were found.
- */
- -
- int
- output_diff3_edscript (outputfile, diff, mapping, rev_mapping,
- file0, file1, file2)
- --- 1487,1492 ----
- ***************
- *** 1655,1661 ****
- --- 1741,1751 ----
-
- VOID *
- xmalloc (size)
- + #ifdef __STDC__
- + size_t size;
- + #else /* not __STDC__ */
- int size;
- + #endif /* not __STDC__ */
- {
- VOID *result = (VOID *) malloc (size ? size : 1);
- if (!result)
- ***************
- *** 1666,1672 ****
- --- 1756,1766 ----
- VOID *
- xrealloc (ptr, size)
- VOID *ptr;
- + #ifdef __STDC__
- + size_t size;
- + #else /* not __STDC__ */
- int size;
- + #endif /* not __STDC__ */
- {
- VOID *result = (VOID *) realloc (ptr, size ? size : 1);
- if (!result)
- ***************
- *** 1674,1679 ****
- --- 1768,1776 ----
- return result;
- }
-
- + #ifdef __STDC__
- + void
- + #endif /* __STDC__ */
- fatal (string)
- char *string;
- {
- ***************
- *** 1681,1686 ****
- --- 1778,1786 ----
- exit (2);
- }
-
- + #ifdef __STDC__
- + void
- + #endif /* __STDC__ */
- perror_with_exit (string)
- char *string;
- {
- ***************
- *** 1687,1689 ****
- --- 1787,1826 ----
- perror (string);
- exit (2);
- }
- +
- + #ifdef MSDOS
- + /*
- + * Get name of temporary directory from environment entry TMP or TEMP.
- + * if this fails, use current directory.
- + */
- + static char *
- + tmpfilename (char *template)
- + {
- + register int l;
- + register char *p;
- + register char *tmpfile;
- +
- + int lt = strlen (template);
- +
- + if ((p = getenv ("TMP")) || (p = getenv ("TEMP")))
- + {
- + l = strlen(p);
- + tmpfile = xmalloc (l + lt + 2);
- + strcpy (tmpfile, p);
- + if ((tmpfile[l-1] != '/') && (tmpfile[l-1] != '\\'))
- + {
- + tmpfile[l] = '/'; /* append slash */
- + tmpfile[l+1] = '\0';
- + }
- + }
- + else
- + {
- + tmpfile = xmalloc (lt + 3); /* use current directory */
- + strcpy (tmpfile, "./");
- + }
- +
- + return mktemp (strcat (tmpfile, template));
- + }
- +
- + #endif /* MSDOS */
- +
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:08 1991
- --- dir.c Tue Mar 12 17:18:50 1991
- ***************
- *** 17,25 ****
- --- 17,36 ----
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/dir.c 1.15.0.2 91/03/12 17:06:27 tho Exp $ */
- +
- #include "diff.h"
-
- + #ifndef __STDC__
- static int compare_names ();
- + #endif /* !__STDC__ */
-
- /* Read the directory named DIRNAME and return a sorted vector
- of filenames for its contents. NONEX nonzero means this directory is
- ***************
- *** 31,36 ****
- --- 42,52 ----
- char **files; /* Sorted names of files in the dir */
- };
-
- + #ifdef __STDC__
- + static struct dirdata dir_sort(char *, int);
- + static int compare_names(char * *, char * *);
- + #endif /* __STDC__ */
- +
- static struct dirdata
- dir_sort (dirname, nonex)
- char *dirname;
- ***************
- *** 132,142 ****
- --- 148,166 ----
- Returns the maximum of all the values returned by HANDLE_FILE,
- or 2 if trouble is encountered in opening files. */
-
- + #ifdef MSDOS
- + int
- + diff_dirs (name1, name2, handle_file, depth, nonex1, nonex2)
- + char *name1, *name2;
- + int (*handle_file) (char *, char *, char *, char *, int);
- + int depth, nonex1, nonex2;
- + #else
- int
- diff_dirs (name1, name2, handle_file, depth, nonex1, nonex2)
- char *name1, *name2;
- int (*handle_file) ();
- int nonex1, nonex2;
- + #endif
- {
- struct dirdata data1, data2;
- register int i1, i2;
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:12 1991
- --- ed.c Tue Mar 12 17:18:52 1991
- ***************
- *** 17,24 ****
- --- 17,38 ----
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/ed.c 1.15.0.1 91/03/11 22:11:02 tho Exp $ */
- +
- #include "diff.h"
-
- + #ifdef __STDC__
- + static void print_ed_hunk(struct change *);
- + static void pr_forward_ed_hunk(struct change *);
- + static void print_rcs_hunk(struct change *);
- + #else
- static void print_rcs_hunk ();
- static void print_ed_hunk ();
- static void pr_forward_ed_hunk ();
- ***************
- *** 25,30 ****
- --- 39,45 ----
- void translate_range ();
- struct change *find_change ();
- struct change *find_reverse_change ();
- + #endif /* __STDC__ */
-
- /* Print our script as ed commands. */
-
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:12 1991
- --- ifdef.c Tue Mar 12 17:18:54 1991
- ***************
- *** 17,28 ****
- --- 17,39 ----
- can know your rights and responsibilities. It should be in a
- file named COPYING. Among other things, the copyright notice
- and this notice must be preserved on all copies. */
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
-
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
-
- + $Header: e:/gnu/diff/RCS/ifdef.c 1.15.0.1 91/03/11 22:12:20 tho Exp $ */
- +
- #include "diff.h"
-
- + #ifdef __STDC__
- + static void print_ifdef_hunk(struct change *);
- + #else
- static void print_ifdef_hunk ();
- struct change *find_change ();
- + #endif /* __STDC__ */
-
- static int next_line;
-
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:14 1991
- --- io.c Tue Mar 12 17:18:56 1991
- ***************
- *** 17,24 ****
- --- 17,41 ----
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/io.c 1.15.0.2 91/03/12 17:06:38 tho Exp $ */
- +
- #include "diff.h"
-
- + #ifdef __STDC__
- + static int binary_file_p(char *, int);
- + static int slurp(void);
- + static void find_identical_ends(struct file_data *);
- + static void find_and_hash_each_line(void);
- + static int find_equiv_class(int);
- + #endif /* __STDC__ */
- +
- /* Rotate a value n bits to the left. */
- #define UINT_BIT (sizeof (unsigned) * CHAR_BIT)
- #define ROL(v, n) ((v) << (n) | (v) >> UINT_BIT - (n))
- ***************
- *** 104,123 ****
- else if ((current->stat.st_mode & S_IFMT) == S_IFREG)
- {
- current->bufsize = current->stat.st_size;
- current->buffer = (char *) xmalloc (current->bufsize + 2);
- current->buffered_chars
- = read (current->desc, current->buffer, current->bufsize);
- if (current->buffered_chars < 0)
- pfatal_with_name (current->name);
- }
- else
- {
- int cc;
-
- current->bufsize = 4096;
- current->buffer = (char *) xmalloc (current->bufsize + 2);
- current->buffered_chars = 0;
- !
- /* Not a regular file; read it in a little at a time, growing the
- buffer as necessary. */
- while ((cc = read (current->desc,
- --- 121,181 ----
- else if ((current->stat.st_mode & S_IFMT) == S_IFREG)
- {
- current->bufsize = current->stat.st_size;
- +
- + #ifdef MSDOS
- + current->buffer = (char _huge *) xhalloc (current->bufsize + 2L);
- + current->buffered_chars
- + = hread (current->desc, current->buffer, current->bufsize);
- + #else /* not MSDOS */
- current->buffer = (char *) xmalloc (current->bufsize + 2);
- current->buffered_chars
- = read (current->desc, current->buffer, current->bufsize);
- + #endif /* not MSDOS */
- if (current->buffered_chars < 0)
- pfatal_with_name (current->name);
- }
- else
- {
- + #ifdef MSDOS
- + long cc;
- +
- + current->bufsize = 0x2000L;
- + current->buffer = (char _huge *) xhalloc (current->bufsize + 2L);
- + current->buffered_chars = 0L;
- +
- + /* Not a regular file; read it in a little at a time, growing the
- + buffer as necessary.
- + MS-DOS: This is really slow size we do not double
- + the BUFSIZE on each step, we rather increase it linearly.
- + I think this greatly inproves the changes of managing a
- + tight fit. */
- + while ((cc = hread (current->desc,
- + current->buffer + current->buffered_chars,
- + current->bufsize - current->buffered_chars))
- + > 0L)
- + {
- + current->buffered_chars += cc;
- + if (current->buffered_chars == current->bufsize)
- + {
- + current->buffer
- + = (char _huge *) xhrealloc (current->buffer,
- + current->bufsize + 0x2002L,
- + current->bufsize);
- + current->bufsize = current->bufsize + 0x2000L;
- + }
- + }
- +
- + if (cc < 0L)
- + pfatal_with_name (current->name);
- +
- + #else /* not MSDOS */
- +
- int cc;
-
- current->bufsize = 4096;
- current->buffer = (char *) xmalloc (current->bufsize + 2);
- current->buffered_chars = 0;
- !
- /* Not a regular file; read it in a little at a time, growing the
- buffer as necessary. */
- while ((cc = read (current->desc,
- ***************
- *** 133,146 ****
- current->bufsize + 2);
- }
- }
- 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,
- --- 191,211 ----
- current->bufsize + 2);
- }
- }
- +
- if (cc < 0)
- pfatal_with_name (current->name);
- +
- + #endif /* not MSDOS */
- }
- !
- /* Check first part of file to see if it's a binary file. */
- if (! always_text_flag
- && binary_file_p (current->buffer,
- + #ifdef MSDOS
- + min ((int) current->buffered_chars, binary_file_threshold)))
- + #else
- min (current->buffered_chars, binary_file_threshold)))
- + #endif
- return 1;
-
- /* If not binary, make sure text ends in a newline,
- ***************
- *** 169,178 ****
- {
- 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));
-
- --- 234,248 ----
- {
- unsigned h;
- int i;
- ! unsigned char _huge *p = (unsigned char _huge *) current->prefix_end;
- ! unsigned char _huge *ip, c;
-
- /* Attempt to get a good initial guess as to the number of lines. */
- + #ifdef MSDOS
- + current->linbufsize = (int) (current->buffered_chars / 50) + 5;
- + #else
- current->linbufsize = current->buffered_chars / 50 + 5;
- + #endif
- current->linbuf
- = (struct line_def *) xmalloc (current->linbufsize * sizeof (struct line_def));
-
- ***************
- *** 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
- {
- --- 253,259 ----
- 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 _huge *) 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)
- --- 265,282 ----
- current->buffered_lines = 0;
- for (i = 0; i < context + 1; ++i)
- /* Unless we are at the beginning, */
- ! if ((char _huge *) p != current->buffer)
- /* Back up at least 1 char until at the start of a line. */
- ! while ((char _huge *) --p != current->buffer && p[-1] != '\n')
- ;
- }
-
- ! while ((char _huge *) p < current->suffix_begin)
- {
- h = 0;
- ip = p;
-
- ! if (current->prefix_end <= (char _huge *) p)
- {
- /* Hash this line until we find a newline. */
- if (ignore_case_flag)
- ***************
- *** 292,305 ****
- if (current->buffered_lines >= current->linbufsize)
- {
- while (current->buffered_lines >= current->linbufsize)
- current->linbufsize *= 2;
- current->linbuf
- = (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;
- ++p;
- --- 362,388 ----
- if (current->buffered_lines >= current->linbufsize)
- {
- while (current->buffered_lines >= current->linbufsize)
- + #ifdef MSDOS /* don't be to generous! */
- + {
- + current->linbufsize += 0x0100;
- + if (current->linbufsize >= 0xffe0 / sizeof (struct line_def))
- + fatal ("to many lines in input");
- + }
- + #else /* not MSDOS */
- current->linbufsize *= 2;
- + #endif /* not MSDOS */
- current->linbuf
- = (struct line_def *) xrealloc (current->linbuf,
- current->linbufsize
- * sizeof (struct line_def));
- }
- ! current->linbuf[current->buffered_lines].text = (char _huge *) ip;
- ! #ifdef MSDOS /* Be explicit to the compiler! */
- ! current->linbuf[current->buffered_lines].length
- ! = (int) ((long) (p - ip) + 1);
- ! #else /* not MSDOS */
- current->linbuf[current->buffered_lines].length = p - ip + 1;
- + #endif /* not MSDOS */
- current->linbuf[current->buffered_lines].hash = h;
- ++current->buffered_lines;
- ++p;
- ***************
- *** 307,313 ****
-
- i = 0;
- while ((i < context || output_style == OUTPUT_IFDEF)
- ! && (char *) p < current->buffer + current->buffered_chars)
- {
- ip = p;
- while (*p++ != '\n')
- --- 390,396 ----
-
- i = 0;
- while ((i < context || output_style == OUTPUT_IFDEF)
- ! && (char _huge *) p < current->buffer + current->buffered_chars)
- {
- ip = p;
- while (*p++ != '\n')
- ***************
- *** 316,329 ****
- if (current->buffered_lines >= current->linbufsize)
- {
- while (current->buffered_lines >= current->linbufsize)
- current->linbufsize *= 2;
- current->linbuf
- = (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;
- ++i;
- --- 399,425 ----
- if (current->buffered_lines >= current->linbufsize)
- {
- while (current->buffered_lines >= current->linbufsize)
- + #ifdef MSDOS /* don't be to generous! */
- + {
- + current->linbufsize += 0x0100;
- + if (current->linbufsize >= 0xffe0 / sizeof (struct line_def))
- + fatal ("to many lines in input");
- + }
- + #else /* not MSDOS */
- current->linbufsize *= 2;
- + #endif /* not MSDOS */
- current->linbuf
- = (struct line_def *) xrealloc (current->linbuf,
- current->linbufsize
- * sizeof (struct line_def));
- }
- ! current->linbuf[current->buffered_lines].text = (char _huge *) ip;
- ! #ifdef MSDOS /* Be explicit to the compiler! */
- ! current->linbuf[current->buffered_lines].length
- ! = (int) ((long) (p - ip));
- ! #else /* not MSDOS */
- current->linbuf[current->buffered_lines].length = p - ip;
- + #endif /* not MSDOS */
- current->linbuf[current->buffered_lines].hash = 0;
- ++current->buffered_lines;
- ++i;
- ***************
- *** 342,348 ****
- find_identical_ends (filevec)
- struct file_data filevec[];
- {
- ! char *p0, *p1, *end0, *beg0;
- int lines;
-
- if (filevec[0].buffered_chars == 0 || filevec[1].buffered_chars == 0)
- --- 438,444 ----
- find_identical_ends (filevec)
- struct file_data filevec[];
- {
- ! char _huge *p0, _huge *p1, _huge *end0, _huge *beg0;
- int lines;
-
- if (filevec[0].buffered_chars == 0 || filevec[1].buffered_chars == 0)
- ***************
- *** 382,397 ****
- --- 478,507 ----
-
- /* Don't count missing newline as part of prefix in RCS mode. */
- if (ROBUST_OUTPUT_STYLE (output_style)
- + #ifdef MSDOS
- + && ((filevec[0].missing_newline
- + && (long) (p0 - filevec[0].buffer)
- + > (long) filevec[0].buffered_chars)
- + ||
- + (filevec[1].missing_newline
- + && (long) (p1 - filevec[1].buffer)
- + > (long) filevec[1].buffered_chars)))
- + #else /* not MSDOS */
- && ((filevec[0].missing_newline
- && p0 - filevec[0].buffer > filevec[0].buffered_chars)
- ||
- (filevec[1].missing_newline
- && p1 - filevec[1].buffer > filevec[1].buffered_chars)))
- + #endif /* not MSDOS */
- --p0, --p1, --lines;
-
- /* If the sentinel was passed, and lengths are equal, the
- files are identical. */
- + #ifdef MSDOS
- + if ((long) (p0 - filevec[0].buffer) > (long) filevec[0].buffered_chars
- + #else /* not MSDOS */
- if (p0 - filevec[0].buffer > filevec[0].buffered_chars
- + #endif /* not MSDOS */
- && filevec[0].buffered_chars == filevec[1].buffered_chars)
- {
- filevec[0].prefix_end = p0 - 1;
- ***************
- *** 515,520 ****
- --- 625,631 ----
- 16381,
- 32749,
- 65521,
- + #ifndef MSDOS
- 131071,
- 262139,
- 524287,
- ***************
- *** 525,530 ****
- --- 636,642 ----
- 16777213,
- 33554393,
- 67108859, /* Preposterously large . . . */
- + #endif /* not MSDOS */
- -1
- };
-
- ***************
- *** 564,569 ****
- --- 676,686 ----
-
- /* Create a new equivalence class in this bucket. */
-
- + #ifdef MSDOS
- + if (equivs_index >= equivs_alloc)
- + fatal ("too many differences, hash table overflow");
- + #endif /* MSDOS */
- +
- p = &equivs[equivs_index++];
- p->next = buckets[bucket];
- buckets[bucket] = p;
- ***************
- *** 600,607 ****
- --- 717,735 ----
- find_and_hash_each_line ();
- }
-
- + #ifdef MSDOS
- + /* This is NOT guaranteed to be enough space, but we will try anyway and
- + abort iff the hash table really overflows. The strategy will help
- + us A LOT iff there are long matching pre- and suffixes (but the
- + user will have to wait longer for the bad news if we have to
- + abort ...). */
- + equivs_alloc = min ((int) (0xffe0 / sizeof (struct equivclass)),
- + filevec[0].buffered_lines + filevec[1].buffered_lines + 1);
- + #else /* not MSDOS */
- /* This is guaranteed to be enough space. */
- equivs_alloc = filevec[0].buffered_lines + filevec[1].buffered_lines + 1;
- + #endif /* not MSDOS */
- +
- 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. */
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:18 1991
- --- limits.h Tue Mar 12 17:19:06 1991
- ***************
- *** 1,3 ****
- --- 1,31 ----
- + /* limits.h - implementation dependent limits
- + Copyright (C) 1988, 1989 Free Software Foundation, Inc.
- +
- + This file is part of GNU DIFF.
- +
- + GNU DIFF is free software; you can redistribute it and/or modify
- + it under the terms of the GNU General Public License as published by
- + the Free Software Foundation; either version 1, or (at your option)
- + any later version.
- +
- + GNU DIFF is distributed in the hope that it will be useful,
- + but WITHOUT ANY WARRANTY; without even the implied warranty of
- + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + GNU General Public License for more details.
- +
- + You should have received a copy of the GNU General Public License
- + along with GNU DIFF; see the file COPYING. If not, write to
- + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- +
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/limits.h 1.15.0.1 91/03/12 10:58:28 tho Exp $ */
- +
- /* Number of bits in a `char'. */
- #define CHAR_BIT 8
-
- ***************
- *** 29,38 ****
- --- 57,75 ----
-
- /* Minimum and maximum values a `signed int' can hold. */
- #define INT_MIN (-INT_MAX-1)
- + #ifdef MSDOS
- + #define INT_MAX 32767
- + #else
- #define INT_MAX 2147483647
- + #endif
-
- /* Maximum value an `unsigned int' can hold. (Minimum is 0). */
- + #ifdef MSDOS
- + #define UINT_MAX 65535U
- + #else
- #define UINT_MAX 4294967295U
- + #endif
- +
-
- /* Minimum and maximum values a `signed long int' can hold.
- (Same as `int'). */
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:18 1991
- --- normal.c Tue Mar 12 17:18:58 1991
- ***************
- *** 17,28 ****
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
- #include "diff.h"
-
- ! void print_normal_hunk ();
- void print_number_range ();
- struct change *find_change ();
-
- /* Print the edit-script SCRIPT as a normal diff.
- INF points to an array of descriptions of the two files. */
- --- 17,41 ----
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
-
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/normal.c 1.15.0.1 91/03/12 10:45:17 tho Exp $ */
- +
- #include "diff.h"
-
- ! #ifdef __STDC__
- ! static void print_normal_hunk(struct change *);
- ! #else
- ! static void print_normal_hunk ();
- void print_number_range ();
- struct change *find_change ();
- + #endif /* __STDC__ */
- +
-
- /* Print the edit-script SCRIPT as a normal diff.
- INF points to an array of descriptions of the two files. */
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:20 1991
- --- util.c Tue Mar 12 17:19:02 1991
- ***************
- *** 17,24 ****
- --- 17,40 ----
- along with GNU DIFF; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- + /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
- + This port is also distributed under the terms of the GNU General
- + Public License as published by the Free Software Foundation.
- +
- + Please note that this file is not identical to the original GNU release,
- + you should have received this code as patch to the official release.
- +
- + $Header: e:/gnu/diff/RCS/util.c 1.15.0.2 91/03/12 17:06:46 tho Exp $ */
- +
- #include "diff.h"
- + #include "regex.h" /* was missing [tho] */
-
- + #ifdef MSDOS
- + #include <conio.h>
- + static char *_pipe_file (void);
- + static void cleanup_pipe (void);
- + #endif /* MSDOS */
- +
- /* Use when a system call returns non-zero status.
- TEXT should normally be the file name. */
-
- ***************
- *** 66,71 ****
- --- 82,97 ----
- error (message, "");
- exit (2);
- }
- +
- + #ifdef MSDOS
- + void
- + fatal_with_name (char *message,char *name)
- + {
- + print_message_queue ();
- + error ("%s: %s", name, message);
- + exit (2);
- + }
- + #endif
-
- /* Like printf, except if -l in effect then save the message and print later.
- This is used for things like "binary files differ" and "Only in ...". */
- ***************
- *** 131,136 ****
- --- 157,173 ----
-
- if (paginate_flag)
- {
- +
- + #ifdef MSDOS
- +
- + if ( !(outfile = fopen(_pipe_file (), "w")) )
- + {
- + error ("can't pipe to more, using stdout instead.");
- + outfile = stdout;
- + }
- +
- + #else
- +
- int pipes[2];
- int desc;
-
- ***************
- *** 162,167 ****
- --- 199,207 ----
- close (pipes[0]);
- outfile = fdopen (pipes[1], "w");
- }
- +
- + #endif /* MSDOS */
- +
- }
- else
- {
- ***************
- *** 187,194 ****
- --- 227,268 ----
- {
- if (outfile != stdout)
- {
- + #ifdef MSDOS
- +
- + #ifndef PAGER
- + #define PAGER "more"
- + #endif
- + #ifndef PAGER_ARGS
- + #define PAGER_ARGS NULL
- + #endif
- +
- + int diff_stdin;
- + int pager_stdin;
- +
- + fclose (outfile);
- +
- + diff_stdin = dup (0);
- + pager_stdin = open (_pipe_file (), O_RDONLY|O_TEXT);
- + dup2 (pager_stdin, 0);
- +
- + spawnlp (P_WAIT, PAGER, PAGER, PAGER_ARGS, NULL);
- +
- + dup2 (diff_stdin, 0);
- + close (diff_stdin);
- + close (pager_stdin);
- +
- + printf ("hit any key to continue...");
- + while (!kbhit ())
- + ;
- +
- + printf ("\n");
- +
- + #else /* not MSDOS */
- +
- fclose (outfile);
- wait (0);
- +
- + #endif /* not MSDOS */
- }
- }
-
- ***************
- *** 201,209 ****
- line_cmp (s1, s2)
- struct line_def *s1, *s2;
- {
- ! register char *t1, *t2;
- register char end_char = line_end_char;
- int savechar;
-
- /* Check first for exact identity.
- If that is true, return 0 immediately.
- --- 275,287 ----
- line_cmp (s1, s2)
- struct line_def *s1, *s2;
- {
- ! register char _huge *t1, _huge *t2;
- register char end_char = line_end_char;
- + #ifdef MSDOS
- + char savechar;
- + #else /* not MSDOS */
- int savechar;
- + #endif /* not MSDOS */
-
- /* Check first for exact identity.
- If that is true, return 0 immediately.
- ***************
- *** 340,350 ****
- --- 418,435 ----
- PRINTFUN takes a subscript which belongs together (with a null
- link at the end) and prints it. */
-
- + #ifdef MSDOS
- + void
- + print_script ( struct change *script,
- + struct change * (*hunkfun) (struct change *),
- + void (*printfun) (struct change *) )
- + #else
- void
- print_script (script, hunkfun, printfun)
- struct change *script;
- struct change * (*hunkfun) ();
- void (*printfun) ();
- + #endif /* MSDOS */
- {
- struct change *next = script;
-
- ***************
- *** 566,571 ****
- --- 651,728 ----
-
- /* malloc a block of memory, with fatal error message if we can't do it. */
-
- + #ifdef MSDOS
- + #include <malloc.h>
- + #include <dos.h>
- +
- + void _huge *
- + xhalloc (long size)
- + {
- + void _huge *value = (void _huge *) halloc (size, (size_t)1 );
- +
- + if (!value)
- + fatal ("virtual memory exhausted");
- + return value;
- + }
- +
- + /* Here we do a huge "realloc" by allocating a new block and
- + moving the old block afterwards. This is *slow*, but should
- + be reliable. */
- +
- + void _huge *
- + xhrealloc (void _huge *ptr, long new_size, long old_size)
- + {
- + void _huge *value = (void _huge *) halloc (new_size, (size_t)1 );
- +
- + if (!value)
- + fatal ("virtual memory exhausted");
- + else
- + {
- + char _huge *dest = value;
- + char _huge *src = ptr;
- +
- + while (old_size > 0L)
- + {
- + unsigned int bytes = (unsigned int) min (0x8000L, old_size);
- + memcpy (dest, src, bytes);
- + old_size -= (long) bytes;
- + dest += (long) bytes;
- + src += (long) bytes;
- + }
- + }
- + hfree (ptr);
- + return value;
- + }
- +
- + long /* doesn't belong here, but is also a 'huge' pointer kludge */
- + hread (int fd, void _huge *buffer, long bytes)
- + {
- + long bytes_read = 0L;
- +
- + while (1)
- + {
- + int n = read (fd, buffer, (unsigned int) min (0x4000L, bytes));
- +
- + if (n > 0)
- + {
- + bytes_read += (long) n;
- + bytes -= (long) n;
- + /* we can't say buffer += n here, because we have to make
- + sure that the offset of BUFFER doesn't overflow during
- + the read() system call. Therefore we add what we read
- + to the segment of BUFFER. */
- + FP_SEG(buffer) += (n >> 4);
- + FP_OFF(buffer) += (n & 0x0F);
- + }
- + else if (n == 0)
- + return bytes_read; /* done */
- + else
- + pfatal_with_name ("error while reading input");
- + }
- + }
- +
- + #endif /* MSDOS */
- +
- VOID *
- xmalloc (size)
- unsigned size;
- ***************
- *** 615,620 ****
- --- 772,780 ----
- return new;
- }
-
- + #ifdef MSDOS
- + void
- + #endif /* MSDOS */
- debug_script (sp)
- struct change *sp;
- {
- ***************
- *** 624,626 ****
- --- 784,839 ----
- sp->line0, sp->line1, sp->deleted, sp->inserted);
- fflush (stderr);
- }
- +
- + #ifdef MSDOS
- +
- + static char *pipe_file = NULL;
- + static char *tmpdir = NULL;
- + static int tmpdirlen;
- +
- + /* Return the name of a temporary file. */
- + char *
- + _pipe_file (void)
- + {
- + if (!pipe_file)
- + {
- + if (!tmpdir)
- + {
- + /* Initialize. */
- +
- + atexit (cleanup_pipe);
- +
- + tmpdir = getenv ("TMP");
- +
- + if (tmpdir)
- + {
- + tmpdirlen = strlen (tmpdir);
- + if (tmpdir[tmpdirlen - 1] == '/'
- + || tmpdir[tmpdirlen - 1] == '\\')
- + tmpdir[tmpdirlen - 1] = '\0';
- + }
- + else
- + {
- + tmpdir = ".";
- + tmpdirlen = 1;
- + }
- + }
- +
- + pipe_file = (char *) xmalloc (tmpdirlen + 14);
- + sprintf (pipe_file, "%s/diff%04x", tmpdir, getpid ());
- + }
- +
- + return pipe_file;
- + }
- +
- +
- + /* Clean up after we are done. */
- +
- + void
- + cleanup_pipe (void)
- + {
- + unlink (pipe_file);
- + }
- +
- + #endif /* MSDOS */
- +
- *** e:\tmp/RCSt1005321 Tue Mar 12 17:20:22 1991
- --- version.c Tue Mar 12 17:19:02 1991
- ***************
- *** 1,3 ****
- --- 1,8 ----
- /* Version number of GNU diff. */
-
- + #ifdef MSDOS
- + char *version_string
- + = "1.15 (compiled " __DATE__ " " __TIME__ " for MS-DOS)";
- + #else /* not MSDOS */
- char *version_string = "1.15";
- + #endif /* not MSDOS */
-