summaryrefslogtreecommitdiff
path: root/editors/diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'editors/diff.c')
-rw-r--r--editors/diff.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/editors/diff.c b/editors/diff.c
index 1462a9b18..cf531460f 100644
--- a/editors/diff.c
+++ b/editors/diff.c
@@ -709,6 +709,10 @@ static int diffreg(char *file[2])
709 FILE *fp[2]; 709 FILE *fp[2];
710 bool binary = false, differ = false; 710 bool binary = false, differ = false;
711 int status = STATUS_SAME, i; 711 int status = STATUS_SAME, i;
712#if ENABLE_PLATFORM_MINGW32
713 char *tmpfile[2] = { NULL, NULL };
714 char *tmpdir;
715#endif
712 716
713 fp[0] = stdin; 717 fp[0] = stdin;
714 fp[1] = stdin; 718 fp[1] = stdin;
@@ -730,10 +734,19 @@ static int diffreg(char *file[2])
730 * When we meet non-seekable file, we must make a temp copy. 734 * When we meet non-seekable file, we must make a temp copy.
731 */ 735 */
732 if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) { 736 if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) {
737#if !ENABLE_PLATFORM_MINGW32
733 char name[] = "/tmp/difXXXXXX"; 738 char name[] = "/tmp/difXXXXXX";
734 int fd_tmp = xmkstemp(name); 739 int fd_tmp = xmkstemp(name);
735 740
736 unlink(name); 741 unlink(name);
742#else
743 int fd_tmp;
744
745 if (!(tmpdir=getenv("TMPDIR")))
746 goto out;
747 tmpfile[i] = xasprintf("%s/difXXXXXX", tmpdir);
748 fd_tmp = xmkstemp(tmpfile[i]);
749#endif
737 if (bb_copyfd_eof(fd, fd_tmp) < 0) 750 if (bb_copyfd_eof(fd, fd_tmp) < 0)
738 xfunc_die(); 751 xfunc_die();
739 if (fd != STDIN_FILENO) 752 if (fd != STDIN_FILENO)
@@ -776,6 +789,14 @@ static int diffreg(char *file[2])
776out: 789out:
777 fclose_if_not_stdin(fp[0]); 790 fclose_if_not_stdin(fp[0]);
778 fclose_if_not_stdin(fp[1]); 791 fclose_if_not_stdin(fp[1]);
792#if ENABLE_PLATFORM_MINGW32
793 for (i = 0; i < 2; i++) {
794 if (tmpfile[i]) {
795 unlink(tmpfile[i]);
796 free(tmpfile[i]);
797 }
798 }
799#endif
779 800
780 return status; 801 return status;
781} 802}
@@ -1019,6 +1040,11 @@ int diff_main(int argc UNUSED_PARAM, char **argv)
1019 * 255, or if a local inode number (st_ino) exceeds 16777215. 1040 * 255, or if a local inode number (st_ino) exceeds 16777215.
1020 */ 1041 */
1021 if (ENABLE_DESKTOP 1042 if (ENABLE_DESKTOP
1043 && (ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_EXTRA_FILE_DATA)
1044#if ENABLE_FEATURE_EXTRA_FILE_DATA
1045 /* ignore invalid inode numbers */
1046 && stb[0].st_ino != 0
1047#endif
1022 && stb[0].st_ino == stb[1].st_ino 1048 && stb[0].st_ino == stb[1].st_ino
1023 && stb[0].st_dev == stb[1].st_dev 1049 && stb[0].st_dev == stb[1].st_dev
1024 && stb[0].st_size == stb[1].st_size 1050 && stb[0].st_size == stb[1].st_size