- new applet diff. Rob Sullivan writes:

Here's my attempt at a mini diff applet - it's adapted from the code at
http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/diff/, and only supports
unified diffs.

I've busyboxified everything to a reasonable degree, so I think the code is
suitable enough to be included, but there's still a fair bit of cleaning up
to be done.
This commit is contained in:
Bernhard Reutner-Fischer 2006-04-06 08:11:08 +00:00
parent e11a01cc34
commit 8f7d389700
5 changed files with 1331 additions and 0 deletions

View File

@ -109,6 +109,38 @@ config CONFIG_DF
df reports the amount of disk space used and available
on filesystems.
config CONFIG_DIFF
bool "diff"
default n
help
diff compares two files or directories and outputs the
differences between them in a form that can be given to
the patch command.
config CONFIG_FEATURE_DIFF_BINARY
bool " Enable checks for binary files"
default y
depends on CONFIG_DIFF
help
This option enables support for checking for binary files
before a comparison is carried out.
config CONFIG_FEATURE_DIFF_DIR
bool " Enable directory support"
default y
depends on CONFIG_DIFF
help
This option enables support for directory and subdirectory
comparison.
config CONFIG_FEATURE_DIFF_MINIMAL
bool " Enable -d option to find smaller sets of changes"
default n
depends on CONFIG_DIFF
help
Enabling this option allows the use of -d to make diff
try hard to find the smallest possible set of changes.
config CONFIG_DIRNAME
bool "dirname"
default n

View File

@ -25,6 +25,7 @@ COREUTILS-$(CONFIG_CUT) += cut.o
COREUTILS-$(CONFIG_DATE) += date.o
COREUTILS-$(CONFIG_DD) += dd.o
COREUTILS-$(CONFIG_DF) += df.o
COREUTILS-$(CONFIG_DIFF) += diff.o
COREUTILS-$(CONFIG_DIRNAME) += dirname.o
COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
COREUTILS-$(CONFIG_DU) += du.o

1277
coreutils/diff.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -86,6 +86,7 @@ USE_DELGROUP(APPLET(delgroup, delgroup_main, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_DELUSER(APPLET(deluser, deluser_main, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_DEVFSD(APPLET(devfsd, devfsd_main, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_DF(APPLET(df, df_main, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_DIFF(APPLET(diff, diff_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_DIRNAME(APPLET(dirname, dirname_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_DMESG(APPLET(dmesg, dmesg_main, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_DNSD(APPLET(dnsd, dnsd_main, _BB_DIR_USR_SBIN, _BB_SUID_ALWAYS))

View File

@ -453,6 +453,26 @@
"Filesystem 1k-blocks Used Available Use% Mounted on\n" \
"/dev/sda3 8690864 8553540 137324 98% /\n"
#define diff_trivial_usage \
"[-abdiNqrTstw] [-S FILE] [-U LINES] FILE1 FILE2"
#define diff_full_usage \
"Compare files line by line and output the differences between them.\n" \
"This diff implementation only supports unified diffs.\n\n" \
"Options:\n" \
"\t-a\tTreat all files as text\n" \
"\t-b\tIgnore changes in the amount of whitespace\n" \
"\t-d\tTry hard to find a smaller set of changes\n" \
"\t-i\tIgnore case differences\n" \
"\t-N\tTreat absent files as empty\n" \
"\t-q\tOutput only whether files differ\n" \
"\t-r\tRecursively compare any subdirectories\n" \
"\t-S\tStart with FILE when comparing directories\n" \
"\t-T\tMake tabs line up by prefixing a tab when necessary\n" \
"\t-s\tReport when two files are the same\n" \
"\t-t\tExpand tabs to spaces in output\n" \
"\t-U\tOutput LINES lines of context\n" \
"\t-w\tIgnore all whitespace\n"
#define dirname_trivial_usage \
"FILENAME"
#define dirname_full_usage \