diff options
Diffstat (limited to 'contrib/cvs/src/patch.c')
-rw-r--r-- | contrib/cvs/src/patch.c | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/contrib/cvs/src/patch.c b/contrib/cvs/src/patch.c index 9d091c3..9f56b62 100644 --- a/contrib/cvs/src/patch.c +++ b/contrib/cvs/src/patch.c @@ -499,23 +499,43 @@ patch_fileproc (callerdat, finfo) ret = 0; goto out2; } + + /* Create 3 empty files. I'm not really sure there is any advantage + to doing so now rather than just waiting until later. */ tmpfile1 = cvs_temp_name (); - if ((fp1 = CVS_FOPEN (tmpfile1, "w+")) != NULL) - (void) fclose (fp1); + fp1 = CVS_FOPEN (tmpfile1, "w+"); + if (fp1 == NULL) + { + error (0, errno, "cannot create temporary file %s", tmpfile1); + ret = 1; + goto out; + } + else + if (fclose (fp1) < 0) + error (0, errno, "warning: cannot close %s", tmpfile1); tmpfile2 = cvs_temp_name (); - if ((fp2 = CVS_FOPEN (tmpfile2, "w+")) != NULL) - (void) fclose (fp2); + fp2 = CVS_FOPEN (tmpfile2, "w+"); + if (fp2 == NULL) + { + error (0, errno, "cannot create temporary file %s", tmpfile2); + ret = 1; + goto out; + } + else + if (fclose (fp2) < 0) + error (0, errno, "warning: cannot close %s", tmpfile2); tmpfile3 = cvs_temp_name (); - if ((fp3 = CVS_FOPEN (tmpfile3, "w+")) != NULL) - (void) fclose (fp3); - if (fp1 == NULL || fp2 == NULL || fp3 == NULL) + fp3 = CVS_FOPEN (tmpfile3, "w+"); + if (fp3 == NULL) { - /* FIXME: should be printing a proper error message, with errno-based - message, and the filename which we could not create. */ - error (0, 0, "cannot create temporary files"); + error (0, errno, "cannot create temporary file %s", tmpfile3); ret = 1; goto out; } + else + if (fclose (fp3) < 0) + error (0, errno, "warning: cannot close %s", tmpfile3); + if (vers_tag != NULL) { retcode = RCS_checkout (rcsfile, (char *) NULL, vers_tag, @@ -523,9 +543,8 @@ patch_fileproc (callerdat, finfo) (RCSCHECKOUTPROC) NULL, (void *) NULL); if (retcode != 0) { - if (!really_quiet) - error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0, - "co of revision %s in %s failed", vers_tag, rcs); + error (0, 0, + "cannot check out revision %s of %s", vers_tag, rcs); ret = 1; goto out; } @@ -548,9 +567,8 @@ patch_fileproc (callerdat, finfo) (RCSCHECKOUTPROC) NULL, (void *) NULL); if (retcode != 0) { - if (!really_quiet) - error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0, - "co of revision %s in %s failed", vers_head, rcs); + error (0, 0, + "cannot check out revision %s of %s", vers_head, rcs); ret = 1; goto out; } @@ -584,10 +602,16 @@ patch_fileproc (callerdat, finfo) if (getline (&line1, &line1_chars_allocated, fp) < 0 || getline (&line2, &line2_chars_allocated, fp) < 0) { - error (0, errno, "failed to read diff file header %s for %s", - tmpfile3, rcs); + if (feof (fp)) + error (0, 0, "\ +failed to read diff file header %s for %s: end of file", tmpfile3, rcs); + else + error (0, errno, + "failed to read diff file header %s for %s", + tmpfile3, rcs); ret = 1; - (void) fclose (fp); + if (fclose (fp) < 0) + error (0, errno, "error closing %s", tmpfile3); goto out; } if (!unidiff) @@ -599,7 +623,8 @@ patch_fileproc (callerdat, finfo) { error (0, 0, "invalid diff header for %s", rcs); ret = 1; - (void) fclose (fp); + if (fclose (fp) < 0) + error (0, errno, "error closing %s", tmpfile3); goto out; } } @@ -612,7 +637,8 @@ patch_fileproc (callerdat, finfo) { error (0, 0, "invalid unidiff header for %s", rcs); ret = 1; - (void) fclose (fp); + if (fclose (fp) < 0) + error (0, errno, "error closing %s", tmpfile3); goto out; } } |