diff options
Diffstat (limited to 'editors/diff.c')
-rw-r--r-- | editors/diff.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/editors/diff.c b/editors/diff.c index 03c13908e..62f558944 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -711,6 +711,10 @@ static int diffreg(char *file[2]) | |||
711 | FILE *fp[2]; | 711 | FILE *fp[2]; |
712 | bool binary = false, differ = false; | 712 | bool binary = false, differ = false; |
713 | int status = STATUS_SAME, i; | 713 | int status = STATUS_SAME, i; |
714 | #if ENABLE_PLATFORM_MINGW32 | ||
715 | char *tmpfile[2] = { NULL, NULL }; | ||
716 | char *tmpdir; | ||
717 | #endif | ||
714 | 718 | ||
715 | fp[0] = stdin; | 719 | fp[0] = stdin; |
716 | fp[1] = stdin; | 720 | fp[1] = stdin; |
@@ -732,10 +736,19 @@ static int diffreg(char *file[2]) | |||
732 | * When we meet non-seekable file, we must make a temp copy. | 736 | * When we meet non-seekable file, we must make a temp copy. |
733 | */ | 737 | */ |
734 | if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) { | 738 | if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) { |
739 | #if !ENABLE_PLATFORM_MINGW32 | ||
735 | char name[] = "/tmp/difXXXXXX"; | 740 | char name[] = "/tmp/difXXXXXX"; |
736 | int fd_tmp = xmkstemp(name); | 741 | int fd_tmp = xmkstemp(name); |
737 | 742 | ||
738 | unlink(name); | 743 | unlink(name); |
744 | #else | ||
745 | int fd_tmp; | ||
746 | |||
747 | if (!(tmpdir=getenv("TMPDIR"))) | ||
748 | goto out; | ||
749 | tmpfile[i] = xasprintf("%s/difXXXXXX", tmpdir); | ||
750 | fd_tmp = xmkstemp(tmpfile[i]); | ||
751 | #endif | ||
739 | if (bb_copyfd_eof(fd, fd_tmp) < 0) | 752 | if (bb_copyfd_eof(fd, fd_tmp) < 0) |
740 | xfunc_die(); | 753 | xfunc_die(); |
741 | if (fd != STDIN_FILENO) | 754 | if (fd != STDIN_FILENO) |
@@ -778,6 +791,14 @@ static int diffreg(char *file[2]) | |||
778 | out: | 791 | out: |
779 | fclose_if_not_stdin(fp[0]); | 792 | fclose_if_not_stdin(fp[0]); |
780 | fclose_if_not_stdin(fp[1]); | 793 | fclose_if_not_stdin(fp[1]); |
794 | #if ENABLE_PLATFORM_MINGW32 | ||
795 | for (i = 0; i < 2; i++) { | ||
796 | if (tmpfile[i]) { | ||
797 | unlink(tmpfile[i]); | ||
798 | free(tmpfile[i]); | ||
799 | } | ||
800 | } | ||
801 | #endif | ||
781 | 802 | ||
782 | return status; | 803 | return status; |
783 | } | 804 | } |