From 7aa651a6a4496d848f86de9b1e6b3a003256a01f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 13 Nov 2012 17:14:08 -0600 Subject: Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring. --- toys/posix/cmp.c | 110 +++++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 57 deletions(-) (limited to 'toys/posix/cmp.c') diff --git a/toys/posix/cmp.c b/toys/posix/cmp.c index 4bbd3f30..13990d45 100644 --- a/toys/posix/cmp.c +++ b/toys/posix/cmp.c @@ -1,6 +1,4 @@ -/* vi: set sw=4 ts=4: - * - * cmp.c - Compare two files. +/* cmp.c - Compare two files. * * Copyright 2012 Timothy Elliott * @@ -9,80 +7,78 @@ USE_CMP(NEWTOY(cmp, "<2>2ls", TOYFLAG_USR|TOYFLAG_BIN)) config CMP - bool "cmp" - default y - help - usage: cmp [-l] [-s] FILE1 FILE2 + bool "cmp" + default y + help + usage: cmp [-l] [-s] FILE1 FILE2 - Compare the contents of two files. + Compare the contents of two files. - -l show all differing bytes - -s silent + -l show all differing bytes + -s silent */ #define FOR_cmp #include "toys.h" GLOBALS( - int fd; - char *name; + int fd; + char *name; ) -// This handles opening the file and +// This handles opening the file and void do_cmp(int fd, char *name) { - int i, len1, len2, min_len, size = sizeof(toybuf)/2; - long byte_no = 1, line_no = 1; - char *buf2 = toybuf+size; + int i, len1, len2, min_len, size = sizeof(toybuf)/2; + long byte_no = 1, line_no = 1; + char *buf2 = toybuf+size; - // First time through, cache the data and return. - if (!TT.fd) { - TT.name = name; - // On return the old filehandle is closed, and this assures that even - // if we were called with stdin closed, the new filehandle != 0. - TT.fd = dup(fd); - return; - } + // First time through, cache the data and return. + if (!TT.fd) { + TT.name = name; + // On return the old filehandle is closed, and this assures that even + // if we were called with stdin closed, the new filehandle != 0. + TT.fd = dup(fd); + return; + } - for (;;) { - len1 = readall(TT.fd, toybuf, size); - len2 = readall(fd, buf2, size); + for (;;) { + len1 = readall(TT.fd, toybuf, size); + len2 = readall(fd, buf2, size); - min_len = len1 < len2 ? len1 : len2; - for (i=0; i