Deleted Added
full compact
patch.c (32785) patch.c (34461)
1/*
2 * Copyright (c) 1992, Brian Berliner and Jeff Polk
3 * Copyright (c) 1989-1992, Brian Berliner
4 *
5 * You may distribute under the terms of the GNU General Public License as
6 * specified in the README file that comes with the CVS source distribution.
7 *
8 * Patch

--- 485 unchanged lines hidden (view full) ---

494 cvs_output (vers_tag, 0);
495 cvs_output (" to ", 0);
496 cvs_output (vers_head, 0);
497 cvs_output ("\n", 1);
498 }
499 ret = 0;
500 goto out2;
501 }
1/*
2 * Copyright (c) 1992, Brian Berliner and Jeff Polk
3 * Copyright (c) 1989-1992, Brian Berliner
4 *
5 * You may distribute under the terms of the GNU General Public License as
6 * specified in the README file that comes with the CVS source distribution.
7 *
8 * Patch

--- 485 unchanged lines hidden (view full) ---

494 cvs_output (vers_tag, 0);
495 cvs_output (" to ", 0);
496 cvs_output (vers_head, 0);
497 cvs_output ("\n", 1);
498 }
499 ret = 0;
500 goto out2;
501 }
502
503 /* Create 3 empty files. I'm not really sure there is any advantage
504 to doing so now rather than just waiting until later. */
502 tmpfile1 = cvs_temp_name ();
505 tmpfile1 = cvs_temp_name ();
503 if ((fp1 = CVS_FOPEN (tmpfile1, "w+")) != NULL)
504 (void) fclose (fp1);
506 fp1 = CVS_FOPEN (tmpfile1, "w+");
507 if (fp1 == NULL)
508 {
509 error (0, errno, "cannot create temporary file %s", tmpfile1);
510 ret = 1;
511 goto out;
512 }
513 else
514 if (fclose (fp1) < 0)
515 error (0, errno, "warning: cannot close %s", tmpfile1);
505 tmpfile2 = cvs_temp_name ();
516 tmpfile2 = cvs_temp_name ();
506 if ((fp2 = CVS_FOPEN (tmpfile2, "w+")) != NULL)
507 (void) fclose (fp2);
517 fp2 = CVS_FOPEN (tmpfile2, "w+");
518 if (fp2 == NULL)
519 {
520 error (0, errno, "cannot create temporary file %s", tmpfile2);
521 ret = 1;
522 goto out;
523 }
524 else
525 if (fclose (fp2) < 0)
526 error (0, errno, "warning: cannot close %s", tmpfile2);
508 tmpfile3 = cvs_temp_name ();
527 tmpfile3 = cvs_temp_name ();
509 if ((fp3 = CVS_FOPEN (tmpfile3, "w+")) != NULL)
510 (void) fclose (fp3);
511 if (fp1 == NULL || fp2 == NULL || fp3 == NULL)
528 fp3 = CVS_FOPEN (tmpfile3, "w+");
529 if (fp3 == NULL)
512 {
530 {
513 /* FIXME: should be printing a proper error message, with errno-based
514 message, and the filename which we could not create. */
515 error (0, 0, "cannot create temporary files");
531 error (0, errno, "cannot create temporary file %s", tmpfile3);
516 ret = 1;
517 goto out;
518 }
532 ret = 1;
533 goto out;
534 }
535 else
536 if (fclose (fp3) < 0)
537 error (0, errno, "warning: cannot close %s", tmpfile3);
538
519 if (vers_tag != NULL)
520 {
521 retcode = RCS_checkout (rcsfile, (char *) NULL, vers_tag,
522 rev1, options, tmpfile1,
523 (RCSCHECKOUTPROC) NULL, (void *) NULL);
524 if (retcode != 0)
525 {
539 if (vers_tag != NULL)
540 {
541 retcode = RCS_checkout (rcsfile, (char *) NULL, vers_tag,
542 rev1, options, tmpfile1,
543 (RCSCHECKOUTPROC) NULL, (void *) NULL);
544 if (retcode != 0)
545 {
526 if (!really_quiet)
527 error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
528 "co of revision %s in %s failed", vers_tag, rcs);
546 error (0, 0,
547 "cannot check out revision %s of %s", vers_tag, rcs);
529 ret = 1;
530 goto out;
531 }
532 memset ((char *) &t, 0, sizeof (t));
533 if ((t.actime = t.modtime = RCS_getrevtime (rcsfile, vers_tag,
534 (char *) 0, 0)) != -1)
535 /* I believe this timestamp only affects the dates in our diffs,
536 and therefore should be on the server, not the client. */

--- 6 unchanged lines hidden (view full) ---

543 }
544 if (vers_head != NULL)
545 {
546 retcode = RCS_checkout (rcsfile, (char *) NULL, vers_head,
547 rev2, options, tmpfile2,
548 (RCSCHECKOUTPROC) NULL, (void *) NULL);
549 if (retcode != 0)
550 {
548 ret = 1;
549 goto out;
550 }
551 memset ((char *) &t, 0, sizeof (t));
552 if ((t.actime = t.modtime = RCS_getrevtime (rcsfile, vers_tag,
553 (char *) 0, 0)) != -1)
554 /* I believe this timestamp only affects the dates in our diffs,
555 and therefore should be on the server, not the client. */

--- 6 unchanged lines hidden (view full) ---

562 }
563 if (vers_head != NULL)
564 {
565 retcode = RCS_checkout (rcsfile, (char *) NULL, vers_head,
566 rev2, options, tmpfile2,
567 (RCSCHECKOUTPROC) NULL, (void *) NULL);
568 if (retcode != 0)
569 {
551 if (!really_quiet)
552 error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
553 "co of revision %s in %s failed", vers_head, rcs);
570 error (0, 0,
571 "cannot check out revision %s of %s", vers_head, rcs);
554 ret = 1;
555 goto out;
556 }
557 if ((t.actime = t.modtime = RCS_getrevtime (rcsfile, vers_head,
558 (char *) 0, 0)) != -1)
559 /* I believe this timestamp only affects the dates in our diffs,
560 and therefore should be on the server, not the client. */
561 (void) utime (tmpfile2, &t);

--- 17 unchanged lines hidden (view full) ---

579 cvs_output ("Index: ", 0);
580 cvs_output (finfo->fullname, 0);
581 cvs_output ("\n", 1);
582
583 fp = open_file (tmpfile3, "r");
584 if (getline (&line1, &line1_chars_allocated, fp) < 0 ||
585 getline (&line2, &line2_chars_allocated, fp) < 0)
586 {
572 ret = 1;
573 goto out;
574 }
575 if ((t.actime = t.modtime = RCS_getrevtime (rcsfile, vers_head,
576 (char *) 0, 0)) != -1)
577 /* I believe this timestamp only affects the dates in our diffs,
578 and therefore should be on the server, not the client. */
579 (void) utime (tmpfile2, &t);

--- 17 unchanged lines hidden (view full) ---

597 cvs_output ("Index: ", 0);
598 cvs_output (finfo->fullname, 0);
599 cvs_output ("\n", 1);
600
601 fp = open_file (tmpfile3, "r");
602 if (getline (&line1, &line1_chars_allocated, fp) < 0 ||
603 getline (&line2, &line2_chars_allocated, fp) < 0)
604 {
587 error (0, errno, "failed to read diff file header %s for %s",
588 tmpfile3, rcs);
605 if (feof (fp))
606 error (0, 0, "\
607failed to read diff file header %s for %s: end of file", tmpfile3, rcs);
608 else
609 error (0, errno,
610 "failed to read diff file header %s for %s",
611 tmpfile3, rcs);
589 ret = 1;
612 ret = 1;
590 (void) fclose (fp);
613 if (fclose (fp) < 0)
614 error (0, errno, "error closing %s", tmpfile3);
591 goto out;
592 }
593 if (!unidiff)
594 {
595 if (strncmp (line1, "*** ", 4) != 0 ||
596 strncmp (line2, "--- ", 4) != 0 ||
597 (cp1 = strchr (line1, '\t')) == NULL ||
598 (cp2 = strchr (line2, '\t')) == NULL)
599 {
600 error (0, 0, "invalid diff header for %s", rcs);
601 ret = 1;
615 goto out;
616 }
617 if (!unidiff)
618 {
619 if (strncmp (line1, "*** ", 4) != 0 ||
620 strncmp (line2, "--- ", 4) != 0 ||
621 (cp1 = strchr (line1, '\t')) == NULL ||
622 (cp2 = strchr (line2, '\t')) == NULL)
623 {
624 error (0, 0, "invalid diff header for %s", rcs);
625 ret = 1;
602 (void) fclose (fp);
626 if (fclose (fp) < 0)
627 error (0, errno, "error closing %s", tmpfile3);
603 goto out;
604 }
605 }
606 else
607 {
608 if (strncmp (line1, "--- ", 4) != 0 ||
609 strncmp (line2, "+++ ", 4) != 0 ||
610 (cp1 = strchr (line1, '\t')) == NULL ||
611 (cp2 = strchr (line2, '\t')) == NULL)
612 {
613 error (0, 0, "invalid unidiff header for %s", rcs);
614 ret = 1;
628 goto out;
629 }
630 }
631 else
632 {
633 if (strncmp (line1, "--- ", 4) != 0 ||
634 strncmp (line2, "+++ ", 4) != 0 ||
635 (cp1 = strchr (line1, '\t')) == NULL ||
636 (cp2 = strchr (line2, '\t')) == NULL)
637 {
638 error (0, 0, "invalid unidiff header for %s", rcs);
639 ret = 1;
615 (void) fclose (fp);
640 if (fclose (fp) < 0)
641 error (0, errno, "error closing %s", tmpfile3);
616 goto out;
617 }
618 }
619 if (CVSroot_directory != NULL)
620 {
621 strippath = xmalloc (strlen (CVSroot_directory) + 10);
622 (void) sprintf (strippath, "%s/", CVSroot_directory);
623 }

--- 133 unchanged lines hidden ---
642 goto out;
643 }
644 }
645 if (CVSroot_directory != NULL)
646 {
647 strippath = xmalloc (strlen (CVSroot_directory) + 10);
648 (void) sprintf (strippath, "%s/", CVSroot_directory);
649 }

--- 133 unchanged lines hidden ---