home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
rcs567s.zip
/
diff
/
patches.os2
< prev
next >
Wrap
Text File
|
1994-07-04
|
22KB
|
904 lines
diff -cb orig/cmp.c new/cmp.c
*** orig/cmp.c Sat Apr 23 11:48:54 1994
--- new/cmp.c Sun Nov 14 23:48:26 1993
***************
*** 94,99 ****
--- 94,100 ----
if (reason && *reason)
fprintf (stderr, "%s: %s\n", program_name, reason);
fflush (stderr);
+ printf ("\nGNU cmp, version %s\n\n", version_string);
printf ("\
Usage: %s [options] from-file [to-file]\n\
Options:\n\
***************
*** 156,162 ****
}
if (optind == argc)
! usage ("missing operand");
file[0] = argv[optind++];
file[1] = optind < argc ? argv[optind++] : "-";
--- 157,163 ----
}
if (optind == argc)
! usage (0);
file[0] = argv[optind++];
file[1] = optind < argc ? argv[optind++] : "-";
***************
*** 177,183 ****
file_desc[i1] = (strcmp (file[i1], "-") == 0
? STDIN_FILENO
! : open (file[i1], O_RDONLY));
if (file_desc[i1] < 0 || fstat (file_desc[i1], &stat_buf[i1]) != 0)
{
if (file_desc[i1] < 0 && comparison_type == type_status)
--- 178,184 ----
file_desc[i1] = (strcmp (file[i1], "-") == 0
? STDIN_FILENO
! : open (file[i1], O_RDONLY | O_BINARY));
if (file_desc[i1] < 0 || fstat (file_desc[i1], &stat_buf[i1]) != 0)
{
if (file_desc[i1] < 0 && comparison_type == type_status)
***************
*** 187,192 ****
--- 188,194 ----
}
}
+ #ifndef OS2
/* If the files are links to the same inode and have the same file position,
they are identical. */
***************
*** 222,227 ****
--- 224,230 ----
if (max (0, s0) != max (0, s1))
exit (1);
}
+ #endif
/* Get the optimal block size of the files. */
***************
*** 503,508 ****
--- 506,512 ----
{
register FILE *fs = stdout;
+ #ifndef OS2
if (c >= 128)
{
putc ('M', fs);
***************
*** 510,515 ****
--- 514,520 ----
c -= 128;
width -= 2;
}
+ #endif
if (c < 32)
{
putc ('^', fs);
diff -cb orig/context.c new/context.c
*** orig/context.c Sat Apr 23 11:48:54 1994
--- new/context.c Sat Nov 13 13:29:54 1993
***************
*** 45,62 ****
if (label)
fprintf (outfile, "%s %s\n", mark, label);
else
/* See Posix.2 section 4.17.6.1.4 for this format. */
fprintf (outfile, "%s %s\t%s",
! mark, inf->name, ctime (&inf->stat.st_mtime));
}
/* Print a header for a context diff, with the file names and dates. */
void
print_context_header (inf, unidiff_flag)
struct file_data inf[];
int unidiff_flag;
{
if (unidiff_flag)
{
print_context_label ("---", &inf[0], file_label[0]);
--- 45,80 ----
if (label)
fprintf (outfile, "%s %s\n", mark, label);
else
+ {
+ char *ct = ctime (&inf->stat.st_mtime);
/* See Posix.2 section 4.17.6.1.4 for this format. */
fprintf (outfile, "%s %s\t%s",
! mark, inf->name, ct ? ct : "\n");
! /* some ctime()'s return NULL on illegal times
! which may occur sometimes on a PC ... */
! }
}
/* Print a header for a context diff, with the file names and dates. */
+ #ifdef OS2
+ void unixname(char *ptr)
+ {
+ for ( ; *ptr; ptr++ )
+ if ( *ptr == '\\' )
+ *ptr = '/';
+ }
+ #endif
+
void
print_context_header (inf, unidiff_flag)
struct file_data inf[];
int unidiff_flag;
{
+ #ifdef OS2
+ unixname((char *) inf[0].name);
+ unixname((char *) inf[1].name);
+ #endif
if (unidiff_flag)
{
print_context_label ("---", &inf[0], file_label[0]);
diff -cb orig/diff.c new/diff.c
*** orig/diff.c Sat Apr 23 11:48:56 1994
--- new/diff.c Sat Apr 23 12:02:54 1994
***************
*** 538,544 ****
}
if (optind != argc - 2)
! usage (optind < argc - 2 ? "extra operand" : "missing operand");
{
--- 538,544 ----
}
if (optind != argc - 2)
! usage (optind < argc - 2 ? "extra operand" : 0);
{
***************
*** 632,637 ****
--- 632,638 ----
if (reason && *reason)
fprintf (stderr, "%s: %s\n", program, reason);
fflush (stderr);
+ printf ("\nGNU diff, version %s\n\n", version_string);
printf ("Usage: %s [options] from-file to-file\n", program);
printf ("Options:\n\
[-abBcdefhHilnNpPqrstTuvwy] [-C lines] [-D name] [-F regexp]\n\
***************
*** 736,742 ****
struct file_data inf[2];
register int i;
int val;
! int same_files;
int failed = 0;
char *free0 = 0, *free1 = 0;
--- 737,743 ----
struct file_data inf[2];
register int i;
int val;
! int same_files = 0;
int failed = 0;
char *free0 = 0, *free1 = 0;
***************
*** 835,843 ****
int dir_arg = 1 - fnm_arg;
char const *fnm = inf[fnm_arg].name;
char const *dir = inf[dir_arg].name;
! char const *p = strrchr (fnm, '/');
! char const *filename = inf[dir_arg].name
! = dir_file_pathname (dir, p ? p + 1 : fnm);
if (strcmp (fnm, "-") == 0)
fatal ("can't compare - to a directory");
--- 836,851 ----
int dir_arg = 1 - fnm_arg;
char const *fnm = inf[fnm_arg].name;
char const *dir = inf[dir_arg].name;
! char const *p, *filename;
!
! p = strrchr (fnm, '/');
! #ifdef OS2
! if (p == NULL)
! p = strrchr (fnm, '\\');
! if (p == NULL)
! p = strrchr (fnm, ':');
! #endif
! filename = inf[dir_arg].name = dir_file_pathname (dir, p ? p + 1 : fnm);
if (strcmp (fnm, "-") == 0)
fatal ("can't compare - to a directory");
***************
*** 859,864 ****
--- 867,873 ----
val = 2;
}
+ #ifndef OS2
else if ((same_files = inf[0].stat.st_ino == inf[1].stat.st_ino
&& inf[0].stat.st_dev == inf[1].stat.st_dev
&& inf[0].stat.st_size == inf[1].stat.st_size
***************
*** 871,876 ****
--- 880,886 ----
val = 0;
}
+ #endif
else if (inf[0].dir_p & inf[1].dir_p)
{
if (output_style == OUTPUT_IFDEF)
diff -cb orig/diff3.c new/diff3.c
*** orig/diff3.c Sat Apr 23 11:48:58 1994
--- new/diff3.c Sat Nov 13 13:48:02 1993
***************
*** 397,403 ****
usage (status)
int status;
{
! fflush (stderr);
printf ("\
Usage: %s [options] my-file older-file your-file\n\
Options:\n\
--- 397,404 ----
usage (status)
int status;
{
! fflush(stderr);
! printf ("\nGNU diff3, version %s\n\n", version_string);
printf ("\
Usage: %s [options] my-file older-file your-file\n\
Options:\n\
***************
*** 1096,1108 ****
{
char *diff_result;
size_t bytes, current_chunk_size, total;
char const *argv[7];
char horizon_arg[256];
char const **ap;
- int fds[2];
pid_t pid;
int wstatus;
ap = argv;
*ap++ = diff_program;
if (always_text)
--- 1097,1120 ----
{
char *diff_result;
size_t bytes, current_chunk_size, total;
+ int fds[2];
+ #ifdef OS2
+ FILE *pipe;
+ char buffer[512];
+ #else
char const *argv[7];
char horizon_arg[256];
char const **ap;
pid_t pid;
+ #endif
int wstatus;
+ #ifdef OS2
+ sprintf (buffer, "%s -a --horizon-lines=%d -- %s %s",
+ diff_program, horizon_lines, filea, fileb);
+ pipe = popen (buffer, "r");
+ fds[0] = fileno (pipe);
+ #else
ap = argv;
*ap++ = diff_program;
if (always_text)
***************
*** 1138,1143 ****
--- 1150,1157 ----
perror_with_exit ("fork failed");
close (fds[1]); /* Prevent erroneous lack of EOF */
+ #endif
+
current_chunk_size = DIFF_CHUNK_SIZE;
diff_result = xmalloc (current_chunk_size);
total = 0;
***************
*** 1163,1168 ****
--- 1177,1185 ----
*output_placement = diff_result;
+ #ifdef OS2
+ wstatus = pclose(pipe);
+ #else
#if HAVE_WAITPID
if (waitpid (pid, &wstatus, 0) < 0)
perror_with_exit ("waitpid failed");
***************
*** 1174,1179 ****
--- 1191,1197 ----
if (w == pid)
break;
}
+ #endif
#endif
if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
diff -cb orig/dir.c new/dir.c
*** orig/dir.c Sat Apr 23 11:48:58 1994
--- new/dir.c Sat Nov 13 13:29:56 1993
***************
*** 19,24 ****
--- 19,28 ----
#include "diff.h"
+ #ifdef OS2
+ #define strcmp stricmp
+ #endif /* OS2 */
+
/* Read the directory named by DIR and store into DIRDATA a sorted vector
of filenames for its contents. DIR->desc == -1 means this directory is
known to be nonexistent, so set DIRDATA to an empty vector.
diff -cb orig/ifdef.c new/ifdef.c
*** orig/ifdef.c Sat Apr 23 11:48:58 1994
--- new/ifdef.c Sat Nov 13 13:29:56 1993
***************
*** 30,36 ****
static char *format_group PARAMS((FILE *, char *, int, struct group const[]));
static char *scan_char_literal PARAMS((char *, int *));
static char *scan_printf_spec PARAMS((char *));
! static int groups_letter_value PARAMS((struct group const[], int));
static void format_ifdef PARAMS((char *, int, int, int, int));
static void print_ifdef_hunk PARAMS((struct change *));
static void print_ifdef_lines PARAMS((FILE *, char *, struct group const *));
--- 30,36 ----
static char *format_group PARAMS((FILE *, char *, int, struct group const[]));
static char *scan_char_literal PARAMS((char *, int *));
static char *scan_printf_spec PARAMS((char *));
! static int groups_letter_value PARAMS((struct group const *, int));
static void format_ifdef PARAMS((char *, int, int, int, int));
static void print_ifdef_hunk PARAMS((struct change *));
static void print_ifdef_lines PARAMS((FILE *, char *, struct group const *));
***************
*** 238,244 ****
Return -1 if LETTER is not a group format letter. */
static int
groups_letter_value (g, letter)
! struct group const g[];
int letter;
{
if (isupper (letter))
--- 238,244 ----
Return -1 if LETTER is not a group format letter. */
static int
groups_letter_value (g, letter)
! struct group const *g;
int letter;
{
if (isupper (letter))
diff -cb orig/regex.c new/regex.c
*** orig/regex.c Sat Apr 23 11:49:00 1994
--- new/regex.c Sat Nov 13 13:29:56 1993
***************
*** 218,226 ****
--- 218,230 ----
#if HAVE_ALLOCA_H
#include <alloca.h>
#else /* not __GNUC__ or HAVE_ALLOCA_H */
+ #ifdef __WATCOMC__
+ #include <malloc.h>
+ #else
#ifndef _AIX /* Already did AIX, up at the top. */
char *alloca ();
#endif /* not _AIX */
+ #endif
#endif /* not HAVE_ALLOCA_H */
#endif /* not __GNUC__ */
diff -cb orig/sdiff.c new/sdiff.c
*** orig/sdiff.c Sat Apr 23 11:49:02 1994
--- new/sdiff.c Sat Nov 13 13:47:02 1993
***************
*** 46,51 ****
--- 46,52 ----
static char *tmpname;
static int volatile tmpmade;
static pid_t volatile diffpid;
+ static char diffcmd[1024];
struct line_filter;
***************
*** 80,86 ****
--- 81,91 ----
static void usage PARAMS((int));
/* this lossage until the gnu libc conquers the universe */
+ #ifdef OS2
+ #define PVT_tmpdir ""
+ #else
#define PVT_tmpdir "/tmp"
+ #endif
static char *private_tempnam PARAMS((char const *, char const *, int, size_t *));
static int diraccess PARAMS((char const *));
static int exists PARAMS((char const *));
***************
*** 118,123 ****
--- 123,129 ----
usage (status)
int status;
{
+ printf ("\nGNU sdiff, version %s\n\n", version_string);
printf ("Usage: %s [options] from-file to-file\n", prog);
printf ("Options:\n\
[-abBdHilstv] [-I regexp] [-o outfile] [-w columns]\n\
***************
*** 254,259 ****
--- 260,266 ----
}
#endif
+ #ifndef OS2
#ifndef HAVE_WAITPID
/* Emulate waitpid well enough for sdiff, which has at most two children. */
static pid_t
***************
*** 283,288 ****
--- 290,296 ----
return pid;
}
#endif
+ #endif
static char const *
expand_name (name, isdir, other_name)
***************
*** 517,530 ****
usage (2);
if (! out_file)
/* easy case: diff does everything for us */
execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1]);
else
{
FILE *left, *right, *out, *diffout;
! int diff_fds[2];
! int interact_ok;
! pid_t pid;
struct line_filter lfilt;
struct line_filter rfilt;
struct line_filter diff_filt;
--- 525,539 ----
usage (2);
if (! out_file)
+ {
/* easy case: diff does everything for us */
execdiff (suppress_common_flag, "-y", argv[optind], argv[optind + 1]);
+ exit (system (diffcmd));
+ }
else
{
FILE *left, *right, *out, *diffout;
! int interact_ok, wstatus;
struct line_filter lfilt;
struct line_filter rfilt;
struct line_filter diff_filt;
***************
*** 539,571 ****
right = ck_fopen (expand_name (argv[optind + 1], rightdir, argv[optind]), "r");
out = ck_fopen (out_file, "w");
- if (pipe (diff_fds))
- perror_fatal ("pipe");
-
- trapsigs ();
-
- diffpid = pid = vfork ();
-
- if (pid == 0)
- {
- signal (SIGINT, SIG_IGN); /* in case user interrupts editor */
- signal (SIGPIPE, SIG_DFL);
-
- close (diff_fds[0]);
- if (diff_fds[1] != STDOUT_FILENO)
- {
- dup2 (diff_fds[1], STDOUT_FILENO);
- close (diff_fds[1]);
- }
-
execdiff (0, "--sdiff-merge-assist", argv[optind], argv[optind + 1]);
! }
!
! if (pid < 0)
! perror_fatal ("fork failed");
!
! close (diff_fds[1]);
! diffout = ck_fdopen (diff_fds[0], "r");
lf_init (&diff_filt, diffout);
lf_init (&lfilt, left);
--- 548,556 ----
right = ck_fopen (expand_name (argv[optind + 1], rightdir, argv[optind]), "r");
out = ck_fopen (out_file, "w");
execdiff (0, "--sdiff-merge-assist", argv[optind], argv[optind + 1]);
! if ( (diffout = popen(diffcmd, "r")) == NULL )
! perror_fatal ("popen failed");
lf_init (&diff_filt, diffout);
lf_init (&lfilt, left);
***************
*** 573,592 ****
interact_ok = interact (&diff_filt, &lfilt, &rfilt, out);
- ck_fclose (diffout);
ck_fclose (left);
ck_fclose (right);
ck_fclose (out);
! {
! int wstatus;
!
! while (waitpid (pid, &wstatus, 0) < 0)
! if (errno == EINTR)
! checksigs ();
! else
! perror_fatal ("wait failed");
! diffpid = 0;
if (tmpmade)
{
--- 558,568 ----
interact_ok = interact (&diff_filt, &lfilt, &rfilt, out);
ck_fclose (left);
ck_fclose (right);
ck_fclose (out);
! wstatus = pclose(diffout);
if (tmpmade)
{
***************
*** 604,635 ****
checksigs ();
exit (WEXITSTATUS (wstatus));
}
- }
return 0; /* Fool -Wall . . . */
}
- static char const **diffargv;
-
static void
diffarg (a)
char const *a;
{
! static unsigned diffargs, diffargsmax;
!
! if (diffargs == diffargsmax)
! {
! if (! diffargsmax)
! {
! diffargv = (char const **) xmalloc (sizeof (char));
! diffargsmax = 8;
! }
! diffargsmax *= 2;
! diffargv = (char const **) realloc (diffargv,
! diffargsmax * sizeof (char const *));
! if (! diffargv)
! fatal ("out of memory");
! }
! diffargv[diffargs++] = a;
}
static void
--- 580,595 ----
checksigs ();
exit (WEXITSTATUS (wstatus));
}
return 0; /* Fool -Wall . . . */
}
static void
diffarg (a)
char const *a;
{
! if (diffcmd[0] != 0)
! strcat (diffcmd, " ");
! strcat (diffcmd, a);
}
static void
***************
*** 643,654 ****
diffarg ("--");
diffarg (file1);
diffarg (file2);
- diffarg (0);
-
- execvp (diffbin, (char **) diffargv);
- write (STDERR_FILENO, diffbin, strlen (diffbin));
- write (STDERR_FILENO, ": not found\n", 12);
- _exit (2);
}
--- 603,608 ----
***************
*** 903,909 ****
case 'q':
return 0;
case 'e':
! if (! tmpname && ! (tmpname = private_tempnam (0, "sdiff", 1, 0)))
perror_fatal ("temporary file name");
tmpmade = 1;
--- 857,863 ----
case 'q':
return 0;
case 'e':
! if (! tmpname && ! (tmpname = private_tempnam (0, "sd_", 1, 0)))
perror_fatal ("temporary file name");
tmpmade = 1;
***************
*** 923,928 ****
--- 877,902 ----
ck_fflush (tmp);
+ #ifdef OS2
+ {
+ char const *argv[3];
+ int i = 0, wstatus;
+
+ argv[i++] = edbin;
+ argv[i++] = tmpname;
+ argv[i++] = 0;
+
+ if ( (wstatus = spawnvp (P_WAIT, edbin, argv)) == -1 )
+ {
+ write (fileno (stderr), edbin, strlen (edbin));
+ write (fileno (stderr), ": not found\n", 12);
+ _exit (1);
+ }
+
+ if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 1))
+ fatal ("Subsidiary editor failed");
+ }
+ #else
{
pid_t pid;
int wstatus;
***************
*** 960,965 ****
--- 934,940 ----
if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 1))
fatal ("Subsidiary editor failed");
}
+ #endif
if (fseek (tmp, 0L, SEEK_SET) != 0)
perror_fatal ("fseek");
***************
*** 1114,1119 ****
--- 1089,1099 ----
if (dir_search)
{
+ #ifdef OS2
+ char *d = getenv ("TMP");
+ if (d == NULL)
+ d = "";
+ #else
register char const *d = getenv ("TMPDIR");
if (d && !diraccess (d))
d = 0;
***************
*** 1123,1128 ****
--- 1103,1109 ----
d = tmpdir;
if (!d && diraccess ("/tmp"))
d = "/tmp";
+ #endif
if (!d)
{
errno = ENOENT;
***************
*** 1170,1176 ****
for (;;)
{
*info->s = letters[info->i];
! sprintf (buf, "%s/%.*s%.5lu%.3s", dir, (int) plen, pfx,
(unsigned long) pid % 100000, info->buf);
if (!exists (buf))
break;
--- 1151,1157 ----
for (;;)
{
*info->s = letters[info->i];
! sprintf (buf, "%s/%.*s%.5lu.%.3s", dir, (int) plen, pfx,
(unsigned long) pid % 100000, info->buf);
if (!exists (buf))
break;
diff -cb orig/system.h new/system.h
*** orig/system.h Sat Apr 23 11:49:02 1994
--- new/system.h Sat Nov 13 13:30:00 1993
***************
*** 98,111 ****
--- 98,117 ----
#if HAVE_TIME_H
#include <time.h>
#else
+ #ifdef __WATCOMC__
+ #include <time.h>
+ #else
#include <sys/time.h>
#endif
+ #endif
#if HAVE_FCNTL_H
#include <fcntl.h>
#else
+ #ifndef __WATCOMC__
#include <sys/file.h>
#endif
+ #endif
#if !HAVE_DUP2
#define dup2(f,t) (close (t), fcntl (f,F_DUPFD,t))
***************
*** 137,144 ****
--- 143,154 ----
#if HAVE_ST_BLKSIZE
#define STAT_BLOCKSIZE(s) (s).st_blksize
#else
+ #ifdef OS2
+ #define STAT_BLOCKSIZE(s) (64 * 1024)
+ #else
#define STAT_BLOCKSIZE(s) (8 * 1024)
#endif
+ #endif
#if DIRENT || defined (_POSIX_VERSION)
#include <dirent.h>
***************
*** 160,165 ****
--- 170,177 ----
#if HAVE_VFORK_H
#include <vfork.h>
+ #else
+ #define vfork fork
#endif
#if HAVE_STDLIB_H
***************
*** 211,215 ****
--- 223,242 ----
extern int errno;
#endif
+ #ifdef min
+ #undef min
+ #endif
+ #ifdef max
+ #undef max
+ #endif
#define min(a,b) ((a) <= (b) ? (a) : (b))
#define max(a,b) ((a) >= (b) ? (a) : (b))
+
+ #ifdef OS2
+ #include <process.h>
+ typedef int pid_t;
+ #define DIFF_PROGRAM "diff.exe"
+ #ifdef __EMX__
+ #define main os2main
+ #endif
+ #endif
diff -cb orig/util.c new/util.c
*** orig/util.c Sat Apr 23 11:49:02 1994
--- new/util.c Sat Nov 13 13:30:02 1993
***************
*** 177,182 ****
--- 177,197 ----
These requirements are silly and do not match historical practice. */
sprintf (name, "diff%s %s %s", switch_string, current_name0, current_name1);
+ #ifdef OS2
+ if (paginate_flag)
+ {
+ #ifdef __WATCOMC__
+ outfile = stdout;
+ #else
+ extern FILE *popen();
+ char cmd[256];
+
+ /* Fork a `pr' and make OUTFILE a pipe to it. */
+ sprintf (cmd, "pr -f -h \"%s\"", name);
+ outfile = popen(cmd, "w");
+ #endif
+ }
+ #else
if (paginate_flag)
{
int pipes[2];
***************
*** 210,215 ****
--- 225,231 ----
outfile = fdopen (pipes[1], "w");
}
}
+ #endif
else
{
***************
*** 252,259 ****
--- 268,280 ----
int wstatus;
if (ferror (outfile))
fatal ("write error");
+ #if defined(OS2) && !defined(__WATCOMC__)
+ if (pclose (outfile) != 0)
+ #else
if (fclose (outfile) != 0)
+ #endif
pfatal_with_name ("write error");
+ #ifndef OS2
#if HAVE_WAITPID
if (waitpid (pr_pid, &wstatus, 0) < 0)
pfatal_with_name ("waitpid");
***************
*** 268,273 ****
--- 289,295 ----
#endif
if (! WIFEXITED (wstatus) || WEXITSTATUS (wstatus) != 0)
fatal ("subsidiary pr failed");
+ #endif
}
outfile = 0;
diff -cb orig/version.c new/version.c
*** orig/version.c Sat Apr 23 11:49:02 1994
--- new/version.c Sat Nov 13 13:30:02 1993
***************
*** 2,5 ****
--- 2,21 ----
#include "config.h"
+
+ #ifdef __EMX__
+
+ #include <stdio.h>
+
+ int main(int argc, char **argv)
+ {
+ _response(&argc, &argv);
+ _wildcard(&argc, &argv);
+ _emxload_env("RCSLOAD");
+ setvbuf(stdout, NULL, _IOFBF, BUFSIZ);
+ return os2main(argc, argv);
+ }
+
+ #endif
+
char const version_string[] = "2.6";