diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-23 14:40:00 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-23 14:40:00 +0000 |
commit | 4c83025ea6fd8ccc450f822e87da0e1187d62aca (patch) | |
tree | e165e7352507a8205b8086fddfe9596482604ede | |
parent | 9a280fa7e65a8b9412acb15fd049219d30a90a2c (diff) | |
download | busybox-w32-4c83025ea6fd8ccc450f822e87da0e1187d62aca.tar.gz busybox-w32-4c83025ea6fd8ccc450f822e87da0e1187d62aca.tar.bz2 busybox-w32-4c83025ea6fd8ccc450f822e87da0e1187d62aca.zip |
diff: emit /dev/null if diff -rN diffs a file against /dev/null
function old new delta
diffreg 1782 1786 +4
-rw-r--r-- | editors/diff.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/editors/diff.c b/editors/diff.c index 0e96c8496..7fce70d08 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -858,7 +858,7 @@ static void print_header(const char *file1, const char *file2) | |||
858 | * lines appended (beginning at b). If c is greater than d then there are | 858 | * lines appended (beginning at b). If c is greater than d then there are |
859 | * lines missing from the to file. | 859 | * lines missing from the to file. |
860 | */ | 860 | */ |
861 | static void change(char *file1, FILE *f1, char *file2, FILE *f2, | 861 | static void change(const char *file1, FILE *f1, const char *file2, FILE *f2, |
862 | int a, int b, int c, int d) | 862 | int a, int b, int c, int d) |
863 | { | 863 | { |
864 | if ((a > b && c > d) || (option_mask32 & FLAG_q)) { | 864 | if ((a > b && c > d) || (option_mask32 & FLAG_q)) { |
@@ -902,7 +902,7 @@ static void change(char *file1, FILE *f1, char *file2, FILE *f2, | |||
902 | } | 902 | } |
903 | 903 | ||
904 | 904 | ||
905 | static void output(char *file1, FILE *f1, char *file2, FILE *f2) | 905 | static void output(const char *file1, FILE *f1, const char *file2, FILE *f2) |
906 | { | 906 | { |
907 | /* Note that j0 and j1 can't be used as they are defined in math.h. | 907 | /* Note that j0 and j1 can't be used as they are defined in math.h. |
908 | * This also allows the rather amusing variable 'j00'... */ | 908 | * This also allows the rather amusing variable 'j00'... */ |
@@ -999,7 +999,7 @@ static void output(char *file1, FILE *f1, char *file2, FILE *f2) | |||
999 | */ | 999 | */ |
1000 | /* NB: files can be not REGular. The only sure thing that they | 1000 | /* NB: files can be not REGular. The only sure thing that they |
1001 | * are not both DIRectories. */ | 1001 | * are not both DIRectories. */ |
1002 | static unsigned diffreg(char *file1, char *file2, int flags) | 1002 | static unsigned diffreg(const char *file1, const char *file2, int flags) |
1003 | { | 1003 | { |
1004 | int *member; /* will be overlaid on nfile[1] */ | 1004 | int *member; /* will be overlaid on nfile[1] */ |
1005 | int *class; /* will be overlaid on nfile[0] */ | 1005 | int *class; /* will be overlaid on nfile[0] */ |
@@ -1022,13 +1022,11 @@ static unsigned diffreg(char *file1, char *file2, int flags) | |||
1022 | 1022 | ||
1023 | if (flags & D_EMPTY1) | 1023 | if (flags & D_EMPTY1) |
1024 | /* can't be stdin, but xfopen_stdin() is smaller code */ | 1024 | /* can't be stdin, but xfopen_stdin() is smaller code */ |
1025 | f1 = xfopen_stdin(bb_dev_null); | 1025 | file1 = bb_dev_null; |
1026 | else | 1026 | f1 = xfopen_stdin(file1); |
1027 | f1 = xfopen_stdin(file1); | ||
1028 | if (flags & D_EMPTY2) | 1027 | if (flags & D_EMPTY2) |
1029 | f2 = xfopen_stdin(bb_dev_null); | 1028 | file2 = bb_dev_null; |
1030 | else | 1029 | f2 = xfopen_stdin(file2); |
1031 | f2 = xfopen_stdin(file2); | ||
1032 | 1030 | ||
1033 | /* NB: if D_EMPTY1/2 is set, other file is always a regular file, | 1031 | /* NB: if D_EMPTY1/2 is set, other file is always a regular file, |
1034 | * not pipe/fifo/chardev/etc - D_EMPTY is used by "diff -r" only, | 1032 | * not pipe/fifo/chardev/etc - D_EMPTY is used by "diff -r" only, |