summaryrefslogtreecommitdiffstats
path: root/toolbox
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-01-15 23:55:45 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-01-15 23:55:45 +0000
commitf5a6c6bbb5e83824161356106876baeb80d8a986 (patch)
tree0595a265039a2611e0c17819c7503a09345b770c /toolbox
parentf4f4d10950a016283a160718a6ba4b19bfbf27e4 (diff)
parent17e2f436f0da70673498482921a642c8917677aa (diff)
downloadsystem_core-f5a6c6bbb5e83824161356106876baeb80d8a986.zip
system_core-f5a6c6bbb5e83824161356106876baeb80d8a986.tar.gz
system_core-f5a6c6bbb5e83824161356106876baeb80d8a986.tar.bz2
am 17e2f436: Merge "Lose cmp to toybox."
* commit '17e2f436f0da70673498482921a642c8917677aa': Lose cmp to toybox.
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/Android.mk1
-rw-r--r--toolbox/cmp.c91
2 files changed, 0 insertions, 92 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index 5db3fce..f6f57cc 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -53,7 +53,6 @@ BSD_TOOLS := \
grep \
OUR_TOOLS := \
- cmp \
df \
getevent \
getprop \
diff --git a/toolbox/cmp.c b/toolbox/cmp.c
deleted file mode 100644
index 80635ad..0000000
--- a/toolbox/cmp.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-
-int cmp_main(int argc, char *argv[])
-{
- int c;
- int fd1, fd2;
- char buf1[4096], buf2[4096];
- int res, res1, res2;
- int rv = 0;
- int i;
- int filepos = 0;
-
- int show_byte = 0;
- int show_all = 0;
- int limit = 0;
-
- do {
- c = getopt(argc, argv, "bln:");
- if (c == EOF)
- break;
- switch (c) {
- case 'b':
- show_byte = 1;
- break;
- case 'l':
- show_all = 1;
- break;
- case 'n':
- limit = atoi(optarg);
- break;
- case '?':
- fprintf(stderr, "%s: invalid option -%c\n",
- argv[0], optopt);
- exit(1);
- }
- } while (1);
-
- if (optind + 2 != argc) {
- fprintf(stderr, "Usage: %s [-b] [-l] [-n count] file1 file2\n", argv[0]);
- exit(1);
- }
-
- fd1 = open(argv[optind], O_RDONLY);
- if(fd1 < 0) {
- fprintf(stderr, "could not open %s, %s\n", argv[optind], strerror(errno));
- return 1;
- }
-
- fd2 = open(argv[optind+1], O_RDONLY);
- if(fd2 < 0) {
- fprintf(stderr, "could not open %s, %s\n", argv[optind+1], strerror(errno));
- return 1;
- }
-
- while(1) {
- res1 = read(fd1, &buf1, sizeof(buf1));
- res2 = read(fd2, &buf2, sizeof(buf2));
- res = res1 < res2 ? res1 : res2;
- if(res1 == 0 && res2 == 0) {
- return rv;
- }
- for(i = 0; i < res; i++) {
- if(buf1[i] != buf2[i]) {
- printf("%s %s differ byte %d", argv[optind], argv[optind+1], filepos + i);
- if(show_byte)
- printf(" 0x%02x 0x%02x", buf1[i], buf2[i]);
- printf("\n");
- if(!show_all)
- return 1;
- rv = 1;
- }
- if(limit) {
- limit--;
- if(limit == 0)
- return rv;
- }
- }
- if(res1 != res2 || res < 0) {
- printf("%s on %s\n", res < 0 ? "Read error" : "EOF", res1 < res2 ? argv[optind] : argv[optind+1]);
- return 1;
- }
- filepos += res;
- }
-}