diff options
author | Rob Landley <rob@landley.net> | 2012-11-13 17:14:08 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-11-13 17:14:08 -0600 |
commit | 7aa651a6a4496d848f86de9b1e6b3a003256a01f (patch) | |
tree | 6995fb4b7cc2e90a6706b0239ebaf95d9dbab530 /toys/other/truncate.c | |
parent | 571b0706cce45716126776d0ad0f6ac65f4586e3 (diff) | |
download | toybox-7aa651a6a4496d848f86de9b1e6b3a003256a01f.tar.gz |
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.
Diffstat (limited to 'toys/other/truncate.c')
-rw-r--r-- | toys/other/truncate.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/toys/other/truncate.c b/toys/other/truncate.c index 47b07583..5ed9f61b 100644 --- a/toys/other/truncate.c +++ b/toys/other/truncate.c @@ -1,44 +1,43 @@ -/* vi: set sw=4 ts=4: - * - * truncate.c - set file length, extending sparsely if necessary +/* truncate.c - set file length, extending sparsely if necessary * * Copyright 2011 Rob Landley <rob@landley.net> USE_TRUNCATE(NEWTOY(truncate, "<1s#|c", TOYFLAG_BIN)) config TRUNCATE - bool "truncate" - default y - help - usage: truncate [-c] -s file... - Set length of file(s), extending sparsely if necessary. - - -c Don't create file if it doesn't exist. - -s New size + bool "truncate" + default y + help + usage: truncate [-c] -s file... + + Set length of file(s), extending sparsely if necessary. + + -c Don't create file if it doesn't exist. + -s New size */ #define FOR_truncate #include "toys.h" GLOBALS( - long size; + long size; ) static void do_truncate(int fd, char *name) { - if (fd<0) return; - if (ftruncate(fd, TT.size)) { - perror_msg("failed to set '%s' to '%ld'", name, TT.size); - toys.exitval = EXIT_FAILURE; - } + if (fd<0) return; + if (ftruncate(fd, TT.size)) { + perror_msg("failed to set '%s' to '%ld'", name, TT.size); + toys.exitval = EXIT_FAILURE; + } } void truncate_main(void) { - int cr = !(toys.optflags&1); + int cr = !(toys.optflags&1); - // Create files with mask rwrwrw. - // Nonexistent files are only an error if we're supposed to create them. - loopfiles_rw(toys.optargs, O_WRONLY|(cr ? O_CREAT : 0), 0666, cr, - do_truncate); + // Create files with mask rwrwrw. + // Nonexistent files are only an error if we're supposed to create them. + loopfiles_rw(toys.optargs, O_WRONLY|(cr ? O_CREAT : 0), 0666, cr, + do_truncate); } |