summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/cvs/src/diff.c
diff options
context:
space:
mode:
authortholo <tholo@openbsd.org>1996-10-18 03:34:32 +0000
committertholo <tholo@openbsd.org>1996-10-18 03:34:32 +0000
commit50bf276cd1c7e20f1eda64a5e63e0fae39e12a95 (patch)
treeb3261b3bb6bd3ee497b476dbac783f5ffa519157 /gnu/usr.bin/cvs/src/diff.c
parentDo not run IP defragmentation routines unneccecarily; NetBSD PR# 2772 (diff)
downloadwireguard-openbsd-50bf276cd1c7e20f1eda64a5e63e0fae39e12a95.tar.xz
wireguard-openbsd-50bf276cd1c7e20f1eda64a5e63e0fae39e12a95.zip
New release from Cyclic Software
Diffstat (limited to 'gnu/usr.bin/cvs/src/diff.c')
-rw-r--r--gnu/usr.bin/cvs/src/diff.c508
1 files changed, 381 insertions, 127 deletions
diff --git a/gnu/usr.bin/cvs/src/diff.c b/gnu/usr.bin/cvs/src/diff.c
index 7520cec4a92..ca113323b4a 100644
--- a/gnu/usr.bin/cvs/src/diff.c
+++ b/gnu/usr.bin/cvs/src/diff.c
@@ -16,12 +16,28 @@
#include "cvs.h"
-static Dtype diff_dirproc PROTO((char *dir, char *pos_repos, char *update_dir));
-static int diff_filesdoneproc PROTO((int err, char *repos, char *update_dir));
-static int diff_dirleaveproc PROTO((char *dir, int err, char *update_dir));
-static int diff_file_nodiff PROTO((char *file, char *repository, List *entries,
- RCSNode *rcs, Vers_TS *vers));
-static int diff_fileproc PROTO((struct file_info *finfo));
+enum diff_file
+{
+ DIFF_ERROR,
+ DIFF_ADDED,
+ DIFF_REMOVED,
+ DIFF_DIFFERENT,
+ DIFF_SAME
+};
+
+static Dtype diff_dirproc PROTO ((void *callerdat, char *dir,
+ char *pos_repos, char *update_dir,
+ List *entries));
+static int diff_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repos, char *update_dir,
+ List *entries));
+static int diff_dirleaveproc PROTO ((void *callerdat, char *dir,
+ int err, char *update_dir,
+ List *entries));
+static enum diff_file diff_file_nodiff PROTO ((struct file_info *finfo,
+ Vers_TS *vers,
+ enum diff_file));
+static int diff_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static void diff_mark_errors PROTO((int err));
static char *diff_rev1, *diff_rev2;
@@ -35,18 +51,19 @@ static char *user_file_rev;
#endif
static char *options;
+/* FIXME: arbitrary limit (security hole, if the client passes us
+ data which overflows it). */
static char opts[PATH_MAX];
static int diff_errors;
static int empty_files = 0;
+/* FIXME: should be documenting all the options here. They don't
+ perfectly match rcsdiff options (for example, we always support
+ --ifdef and --context, but rcsdiff only does if diff does). */
static const char *const diff_usage[] =
{
"Usage: %s %s [-lN] [rcsdiff-options]\n",
-#ifdef CVS_DIFFDATE
" [[-r rev1 | -D date1] [-r rev2 | -D date2]] [files...] \n",
-#else
- " [-r rev1 [-r rev2]] [files...] \n",
-#endif
"\t-l\tLocal directory only, not recursive\n",
"\t-D d1\tDiff revision for date against working file.\n",
"\t-D d2\tDiff rev1/date1 against date2.\n",
@@ -56,6 +73,79 @@ static const char *const diff_usage[] =
NULL
};
+/* I copied this array directly out of diff.c in diffutils 2.7, after
+ removing the following entries, none of which seem relevant to use
+ with CVS:
+ --help
+ --version
+ --recursive
+ --unidirectional-new-file
+ --starting-file
+ --exclude
+ --exclude-from
+ --sdiff-merge-assist
+
+ I changed the options which take optional arguments (--context and
+ --unified) to return a number rather than a letter, so that the
+ optional argument could be handled more easily. I changed the
+ --paginate and --brief options to return a number, since -l and -q
+ mean something else to cvs diff.
+
+ The numbers 129- that appear in the fourth element of some entries
+ tell the big switch in `diff' how to process those options. -- Ian
+
+ The following options, which diff lists as "An alias, no longer
+ recommended" have been removed: --file-label --entire-new-file
+ --ascii --print. */
+
+static struct option const longopts[] =
+{
+ {"ignore-blank-lines", 0, 0, 'B'},
+ {"context", 2, 0, 143},
+ {"ifdef", 1, 0, 147},
+ {"show-function-line", 1, 0, 'F'},
+ {"speed-large-files", 0, 0, 'H'},
+ {"ignore-matching-lines", 1, 0, 'I'},
+ {"label", 1, 0, 'L'},
+ {"new-file", 0, 0, 'N'},
+ {"initial-tab", 0, 0, 'T'},
+ {"width", 1, 0, 'W'},
+ {"text", 0, 0, 'a'},
+ {"ignore-space-change", 0, 0, 'b'},
+ {"minimal", 0, 0, 'd'},
+ {"ed", 0, 0, 'e'},
+ {"forward-ed", 0, 0, 'f'},
+ {"ignore-case", 0, 0, 'i'},
+ {"paginate", 0, 0, 144},
+ {"rcs", 0, 0, 'n'},
+ {"show-c-function", 0, 0, 'p'},
+
+ /* This is a potentially very useful option, except the output is so
+ silly. It would be much better for it to look like "cvs rdiff -s"
+ which displays all the same info, minus quite a few lines of
+ extraneous garbage. */
+ {"brief", 0, 0, 145},
+
+ {"report-identical-files", 0, 0, 's'},
+ {"expand-tabs", 0, 0, 't'},
+ {"ignore-all-space", 0, 0, 'w'},
+ {"side-by-side", 0, 0, 'y'},
+ {"unified", 2, 0, 146},
+ {"left-column", 0, 0, 129},
+ {"suppress-common-lines", 0, 0, 130},
+ {"old-line-format", 1, 0, 132},
+ {"new-line-format", 1, 0, 133},
+ {"unchanged-line-format", 1, 0, 134},
+ {"line-format", 1, 0, 135},
+ {"old-group-format", 1, 0, 136},
+ {"new-group-format", 1, 0, 137},
+ {"unchanged-group-format", 1, 0, 138},
+ {"changed-group-format", 1, 0, 139},
+ {"horizon-lines", 1, 0, 140},
+ {"binary", 0, 0, 142},
+ {0, 0, 0, 0}
+};
+
int
diff (argc, argv)
int argc;
@@ -65,6 +155,7 @@ diff (argc, argv)
int c, err = 0;
int local = 0;
int which;
+ int option_index;
if (argc == -1)
usage (diff_usage);
@@ -80,41 +171,50 @@ diff (argc, argv)
opts[0] = '\0';
#endif
optind = 1;
- while ((c = getopt (argc, argv,
- "abcdefhilnpqtuw0123456789BHNQRTC:D:F:I:L:V:k:r:")) != -1)
+ while ((c = getopt_long (argc, argv,
+ "abcdefhilnpstuwy0123456789BHNRTC:D:F:I:L:U:V:W:k:r:",
+ longopts, &option_index)) != -1)
{
switch (c)
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- case 'h': case 'i': case 'n': case 'p': case 't': case 'u':
- case 'w': case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': case 'B':
- case 'H': case 'T': case 'Q':
+ case 'h': case 'i': case 'n': case 'p': case 's': case 't':
+ case 'u': case 'w': case 'y': case '0': case '1': case '2':
+ case '3': case '4': case '5': case '6': case '7': case '8':
+ case '9': case 'B': case 'H': case 'T':
(void) sprintf (tmp, " -%c", (char) c);
(void) strcat (opts, tmp);
- if (c == 'Q')
+ break;
+ case 'C': case 'F': case 'I': case 'L': case 'U': case 'V':
+ case 'W':
+ (void) sprintf (tmp, " -%c", (char) c);
+ strcat (opts, tmp);
+ strcat (opts, optarg);
+ break;
+ case 147:
+ /* --ifdef. */
+ strcat (opts, " -D");
+ strcat (opts, optarg);
+ break;
+ case 129: case 130: case 131: case 132: case 133: case 134:
+ case 135: case 136: case 137: case 138: case 139: case 140:
+ case 141: case 142: case 143: case 144: case 145: case 146:
+ strcat (opts, " --");
+ strcat (opts, longopts[option_index].name);
+ if (longopts[option_index].has_arg == 1
+ || (longopts[option_index].has_arg == 2
+ && optarg != NULL))
{
- quiet = 1;
- really_quiet = 1;
- c = 'q';
+ strcat (opts, "=");
+ strcat (opts, optarg);
}
break;
- case 'C': case 'F': case 'I': case 'L': case 'V':
-#ifndef CVS_DIFFDATE
- case 'D':
-#endif
- (void) sprintf (tmp, " -%c%s", (char) c, optarg);
- (void) strcat (opts, tmp);
- break;
case 'R':
local = 0;
break;
case 'l':
local = 1;
break;
- case 'q':
- quiet = 1;
- break;
case 'k':
if (options)
free (options);
@@ -129,7 +229,6 @@ diff (argc, argv)
else
diff_rev1 = optarg;
break;
-#ifdef CVS_DIFFDATE
case 'D':
if (diff_rev2 != NULL || diff_date2 != NULL)
error (1, 0,
@@ -139,7 +238,6 @@ diff (argc, argv)
else
diff_date1 = Make_Date (optarg);
break;
-#endif
case 'N':
empty_files = 1;
break;
@@ -201,15 +299,15 @@ diff (argc, argv)
tag_check_valid (diff_rev2, argc, argv, local, 0, "");
which = W_LOCAL;
- if (diff_rev2 != NULL || diff_date2 != NULL)
+ if (diff_rev1 != NULL || diff_date1 != NULL)
which |= W_REPOS | W_ATTIC;
wrap_setup ();
/* start the recursion processor */
err = start_recursion (diff_fileproc, diff_filesdoneproc, diff_dirproc,
- diff_dirleaveproc, argc, argv, local,
- which, 0, 1, (char *) NULL, 1, 0);
+ diff_dirleaveproc, NULL, argc, argv, local,
+ which, 0, 1, (char *) NULL, 1);
/* clean up */
free (options);
@@ -221,26 +319,21 @@ diff (argc, argv)
*/
/* ARGSUSED */
static int
-diff_fileproc (finfo)
+diff_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
int status, err = 2; /* 2 == trouble, like rcsdiff */
Vers_TS *vers;
- enum {
- DIFF_ERROR,
- DIFF_ADDED,
- DIFF_REMOVED,
- DIFF_NEITHER
- } empty_file = DIFF_NEITHER;
- char tmp[L_tmpnam+1];
+ enum diff_file empty_file = DIFF_DIFFERENT;
+ char *tmp;
char *tocvsPath;
char fname[PATH_MAX];
#ifdef SERVER_SUPPORT
user_file_rev = 0;
#endif
- vers = Version_TS (finfo->repository, (char *) NULL, (char *) NULL, (char *) NULL,
- finfo->file, 1, 0, finfo->entries, finfo->rcs);
+ vers = Version_TS (finfo, NULL, NULL, NULL, 1, 0);
if (diff_rev2 != NULL || diff_date2 != NULL)
{
@@ -249,10 +342,46 @@ diff_fileproc (finfo)
}
else if (vers->vn_user == NULL)
{
- error (0, 0, "I know nothing about %s", finfo->fullname);
- freevers_ts (&vers);
- diff_mark_errors (err);
- return (err);
+ /* The file does not exist in the working directory. */
+ if ((diff_rev1 != NULL || diff_date1 != NULL)
+ && vers->srcfile != NULL)
+ {
+ /* The file does exist in the repository. */
+ if (empty_files)
+ empty_file = DIFF_REMOVED;
+ else
+ {
+ int exists;
+
+ exists = 0;
+ /* special handling for TAG_HEAD */
+ if (diff_rev1 && strcmp (diff_rev1, TAG_HEAD) == 0)
+ exists = vers->vn_rcs != NULL;
+ else
+ {
+ Vers_TS *xvers;
+
+ xvers = Version_TS (finfo, NULL, diff_rev1, diff_date1,
+ 1, 0);
+ exists = xvers->vn_rcs != NULL;
+ freevers_ts (&xvers);
+ }
+ if (exists)
+ error (0, 0,
+ "%s no longer exists, no comparison available",
+ finfo->fullname);
+ freevers_ts (&vers);
+ diff_mark_errors (err);
+ return (err);
+ }
+ }
+ else
+ {
+ error (0, 0, "I know nothing about %s", finfo->fullname);
+ freevers_ts (&vers);
+ diff_mark_errors (err);
+ return (err);
+ }
}
else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0')
{
@@ -311,14 +440,64 @@ diff_fileproc (finfo)
}
}
- if (empty_file == DIFF_NEITHER && diff_file_nodiff (finfo->file, finfo->repository, finfo->entries, finfo->rcs, vers))
+ empty_file = diff_file_nodiff (finfo, vers, empty_file);
+ if (empty_file == DIFF_SAME || empty_file == DIFF_ERROR)
{
freevers_ts (&vers);
- return (0);
+ if (empty_file == DIFF_SAME)
+ return (0);
+ else
+ {
+ diff_mark_errors (err);
+ return (err);
+ }
}
- /* FIXME: Check whether use_rev1 and use_rev2 are dead and deal
- accordingly. */
+ if (empty_file == DIFF_DIFFERENT)
+ {
+ int dead1, dead2;
+
+ if (use_rev1 == NULL)
+ dead1 = 0;
+ else
+ dead1 = RCS_isdead (vers->srcfile, use_rev1);
+ if (use_rev2 == NULL)
+ dead2 = 0;
+ else
+ dead2 = RCS_isdead (vers->srcfile, use_rev2);
+
+ if (dead1 && dead2)
+ {
+ freevers_ts (&vers);
+ return (0);
+ }
+ else if (dead1)
+ {
+ if (empty_files)
+ empty_file = DIFF_ADDED;
+ else
+ {
+ error (0, 0, "%s is a new entry, no comparison available",
+ finfo->fullname);
+ freevers_ts (&vers);
+ diff_mark_errors (err);
+ return (err);
+ }
+ }
+ else if (dead2)
+ {
+ if (empty_files)
+ empty_file = DIFF_REMOVED;
+ else
+ {
+ error (0, 0, "%s was removed, no comparison available",
+ finfo->fullname);
+ freevers_ts (&vers);
+ diff_mark_errors (err);
+ return (err);
+ }
+ }
+ }
/* Output an "Index:" line for patch to use */
(void) fflush (stdout);
@@ -348,23 +527,42 @@ diff_fileproc (finfo)
if (empty_file == DIFF_ADDED)
{
- run_setup ("%s %s %s %s", DIFF, opts, DEVNULL, finfo->file);
+ if (use_rev2 == NULL)
+ run_setup ("%s %s %s %s", DIFF, opts, DEVNULL, finfo->file);
+ else
+ {
+ int retcode;
+
+ tmp = cvs_temp_name ();
+ retcode = RCS_checkout (vers->srcfile, (char *) NULL,
+ use_rev2, (char *) NULL,
+ (*options
+ ? options
+ : vers->options),
+ tmp);
+ if (retcode == -1)
+ {
+ (void) CVS_UNLINK (tmp);
+ error (1, errno, "fork failed during checkout of %s",
+ vers->srcfile->path);
+ }
+ /* FIXME: what if retcode > 0? */
+
+ run_setup ("%s %s %s %s", DIFF, opts, DEVNULL, tmp);
+ }
}
else
{
int retcode;
- /*
- * FIXME: Should be setting use_rev1 using the logic in
- * diff_file_nodiff, and using that revision. This code
- * is broken for "cvs diff -N -r foo".
- */
- retcode = RCS_checkout (vers->srcfile->path, NULL, vers->vn_rcs,
- *options ? options : vers->options, tmpnam (tmp),
- 0, 0);
+ tmp = cvs_temp_name ();
+ retcode = RCS_checkout (vers->srcfile, (char *) NULL,
+ use_rev1, (char *) NULL,
+ *options ? options : vers->options,
+ tmp);
if (retcode == -1)
{
- (void) unlink (tmp);
+ (void) CVS_UNLINK (tmp);
error (1, errno, "fork failed during checkout of %s",
vers->srcfile->path);
}
@@ -414,8 +612,12 @@ diff_fileproc (finfo)
error (1, errno, "cannot remove %s", finfo->file);
}
- if (empty_file == DIFF_REMOVED)
- (void) unlink (tmp);
+ if (empty_file == DIFF_REMOVED
+ || (empty_file == DIFF_ADDED && use_rev2 != NULL))
+ {
+ (void) CVS_UNLINK (tmp);
+ free (tmp);
+ }
(void) fflush (stdout);
freevers_ts (&vers);
@@ -441,10 +643,12 @@ diff_mark_errors (err)
*/
/* ARGSUSED */
static Dtype
-diff_dirproc (dir, pos_repos, update_dir)
+diff_dirproc (callerdat, dir, pos_repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *pos_repos;
char *update_dir;
+ List *entries;
{
/* XXX - check for dirs we don't want to process??? */
@@ -462,10 +666,12 @@ diff_dirproc (dir, pos_repos, update_dir)
*/
/* ARGSUSED */
static int
-diff_filesdoneproc (err, repos, update_dir)
+diff_filesdoneproc (callerdat, err, repos, update_dir, entries)
+ void *callerdat;
int err;
char *repos;
char *update_dir;
+ List *entries;
{
return (diff_errors);
}
@@ -475,27 +681,27 @@ diff_filesdoneproc (err, repos, update_dir)
*/
/* ARGSUSED */
static int
-diff_dirleaveproc (dir, err, update_dir)
+diff_dirleaveproc (callerdat, dir, err, update_dir, entries)
+ void *callerdat;
char *dir;
int err;
char *update_dir;
+ List *entries;
{
return (diff_errors);
}
/*
- * verify that a file is different 0=same 1=different
+ * verify that a file is different
*/
-static int
-diff_file_nodiff (file, repository, entries, rcs, vers)
- char *file;
- char *repository;
- List *entries;
- RCSNode *rcs;
+static enum diff_file
+diff_file_nodiff (finfo, vers, empty_file)
+ struct file_info *finfo;
Vers_TS *vers;
+ enum diff_file empty_file;
{
Vers_TS *xvers;
- char tmp[L_tmpnam+1];
+ char *tmp;
int retcode;
/* free up any old use_rev* variables and reset 'em */
@@ -512,23 +718,9 @@ diff_file_nodiff (file, repository, entries, rcs, vers)
use_rev1 = xstrdup (vers->vn_rcs);
else
{
- xvers = Version_TS (repository, (char *) NULL, diff_rev1,
- diff_date1, file, 1, 0, entries, rcs);
- if (xvers->vn_rcs == NULL)
- {
- /* Don't gripe if it doesn't exist, just ignore! */
- if (! isfile (file))
- /* null statement */ ;
- else if (diff_rev1)
- error (0, 0, "tag %s is not in file %s", diff_rev1, file);
- else
- error (0, 0, "no revision for date %s in file %s",
- diff_date1, file);
-
- freevers_ts (&xvers);
- return (1);
- }
- use_rev1 = xstrdup (xvers->vn_rcs);
+ xvers = Version_TS (finfo, NULL, diff_rev1, diff_date1, 1, 0);
+ if (xvers->vn_rcs != NULL)
+ use_rev1 = xstrdup (xvers->vn_rcs);
freevers_ts (&xvers);
}
}
@@ -539,36 +731,84 @@ diff_file_nodiff (file, repository, entries, rcs, vers)
use_rev2 = xstrdup (vers->vn_rcs);
else
{
- xvers = Version_TS (repository, (char *) NULL, diff_rev2,
- diff_date2, file, 1, 0, entries, rcs);
- if (xvers->vn_rcs == NULL)
- {
- /* Don't gripe if it doesn't exist, just ignore! */
- if (! isfile (file))
- /* null statement */ ;
- else if (diff_rev1)
- error (0, 0, "tag %s is not in file %s", diff_rev2, file);
- else
- error (0, 0, "no revision for date %s in file %s",
- diff_date2, file);
-
- freevers_ts (&xvers);
- return (1);
- }
- use_rev2 = xstrdup (xvers->vn_rcs);
+ xvers = Version_TS (finfo, NULL, diff_rev2, diff_date2, 1, 0);
+ if (xvers->vn_rcs != NULL)
+ use_rev2 = xstrdup (xvers->vn_rcs);
freevers_ts (&xvers);
}
+ if (use_rev1 == NULL)
+ {
+ /* The first revision does not exist. If EMPTY_FILES is
+ true, treat this as an added file. Otherwise, warn
+ about the missing tag. */
+ if (use_rev2 == NULL)
+ return DIFF_SAME;
+ else if (empty_files)
+ return DIFF_ADDED;
+ else if (diff_rev1)
+ error (0, 0, "tag %s is not in file %s", diff_rev1,
+ finfo->fullname);
+ else
+ error (0, 0, "no revision for date %s in file %s",
+ diff_date1, finfo->fullname);
+ return DIFF_ERROR;
+ }
+
+ if (use_rev2 == NULL)
+ {
+ /* The second revision does not exist. If EMPTY_FILES is
+ true, treat this as a removed file. Otherwise warn
+ about the missing tag. */
+ if (empty_files)
+ return DIFF_REMOVED;
+ else if (diff_rev2)
+ error (0, 0, "tag %s is not in file %s", diff_rev2,
+ finfo->fullname);
+ else
+ error (0, 0, "no revision for date %s in file %s",
+ diff_date2, finfo->fullname);
+ return DIFF_ERROR;
+ }
+
/* now, see if we really need to do the diff */
- if (use_rev1 && use_rev2) {
- return (strcmp (use_rev1, use_rev2) == 0);
- } else {
- error(0, 0, "No HEAD revision for file %s", file);
- return (1);
+ if (strcmp (use_rev1, use_rev2) == 0)
+ return DIFF_SAME;
+ else
+ return DIFF_DIFFERENT;
+ }
+
+ if ((diff_rev1 || diff_date1) && use_rev1 == NULL)
+ {
+ /* The first revision does not exist, and no second revision
+ was given. */
+ if (empty_files)
+ {
+ if (empty_file == DIFF_REMOVED)
+ return DIFF_SAME;
+ else
+ {
+#ifdef SERVER_SUPPORT
+ if (user_file_rev && use_rev2 == NULL)
+ use_rev2 = xstrdup (user_file_rev);
+#endif
+ return DIFF_ADDED;
+ }
+ }
+ else
+ {
+ if (diff_rev1)
+ error (0, 0, "tag %s is not in file %s", diff_rev1,
+ finfo->fullname);
+ else
+ error (0, 0, "no revision for date %s in file %s",
+ diff_date1, finfo->fullname);
+ return DIFF_ERROR;
}
}
+
#ifdef SERVER_SUPPORT
- if (user_file_rev)
+ if (user_file_rev)
{
/* drop user_file_rev into first unused use_rev */
if (!use_rev1)
@@ -582,42 +822,56 @@ diff_file_nodiff (file, repository, entries, rcs, vers)
/* now, see if we really need to do the diff */
if (use_rev1 && use_rev2)
{
- return (strcmp (use_rev1, use_rev2) == 0);
+ if (strcmp (use_rev1, use_rev2) == 0)
+ return DIFF_SAME;
+ else
+ return DIFF_DIFFERENT;
}
#endif /* SERVER_SUPPORT */
- if (use_rev1 == NULL || strcmp (use_rev1, vers->vn_user) == 0)
+ if (use_rev1 == NULL
+ || (vers->vn_user != NULL && strcmp (use_rev1, vers->vn_user) == 0))
{
if (strcmp (vers->ts_rcs, vers->ts_user) == 0 &&
(!(*options) || strcmp (options, vers->options) == 0))
{
- return (1);
+ return DIFF_SAME;
}
if (use_rev1 == NULL)
use_rev1 = xstrdup (vers->vn_user);
}
+ /* If we already know that the file is being added or removed,
+ then we don't want to do an actual file comparison here. */
+ if (empty_file != DIFF_DIFFERENT)
+ return empty_file;
+
/*
* with 0 or 1 -r option specified, run a quick diff to see if we
* should bother with it at all.
*/
- retcode = RCS_checkout (vers->srcfile->path, NULL, use_rev1,
- *options ? options : vers->options, tmpnam (tmp), 0, 0);
+ tmp = cvs_temp_name ();
+ retcode = RCS_checkout (vers->srcfile, (char *) NULL, use_rev1,
+ (char *) NULL,
+ *options ? options : vers->options,
+ tmp);
switch (retcode)
{
case 0: /* everything ok */
- if (xcmp (file, tmp) == 0)
+ if (xcmp (finfo->file, tmp) == 0)
{
- (void) unlink (tmp);
- return (1);
+ (void) CVS_UNLINK (tmp);
+ free (tmp);
+ return DIFF_SAME;
}
break;
case -1: /* fork failed */
- (void) unlink (tmp);
+ (void) CVS_UNLINK (tmp);
error (1, errno, "fork failed during checkout of %s",
vers->srcfile->path);
default:
break;
}
- (void) unlink (tmp);
- return (0);
+ (void) CVS_UNLINK (tmp);
+ free (tmp);
+ return DIFF_DIFFERENT;
}