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/lsb/mktemp.c | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'toys/lsb/mktemp.c') diff --git a/toys/lsb/mktemp.c b/toys/lsb/mktemp.c index 1b2222c0..86c2033e 100644 --- a/toys/lsb/mktemp.c +++ b/toys/lsb/mktemp.c @@ -1,6 +1,4 @@ -/* vi: set sw=4 ts=4: - * - * mktemp.c - Create a temporary file or directory. +/* mktemp.c - Create a temporary file or directory. * * Copyright 2012 Elie De Brauwer * @@ -9,46 +7,46 @@ USE_MKTEMP(NEWTOY(mktemp, ">1q(directory)d(tmpdir)p:", TOYFLAG_BIN)) config MKTEMP - bool "mktemp" - default y - help - usage: mktemp [-dq] [-p DIR] [TEMPLATE] + bool "mktemp" + default y + help + usage: mktemp [-dq] [-p DIR] [TEMPLATE] - Safely create new file and print its name. Default TEMPLATE is - /tmp/tmp.XXXXXX and each trailing X is replaced with random char. + Safely create new file and print its name. Default TEMPLATE is + /tmp/tmp.XXXXXX and each trailing X is replaced with random char. - -d, --directory Create directory instead of file - -p DIR, --tmpdir=DIR Put new file in DIR - -q Quiet + -d, --directory Create directory instead of file + -p DIR, --tmpdir=DIR Put new file in DIR + -q Quiet */ #define FOR_mktemp #include "toys.h" GLOBALS( - char * tmpdir; + char * tmpdir; ) void mktemp_main(void) { - int d_flag = toys.optflags & FLAG_d; - char *tmp; + int d_flag = toys.optflags & FLAG_d; + char *tmp; - tmp = *toys.optargs; + tmp = *toys.optargs; - if (!tmp) { - if (!TT.tmpdir) TT.tmpdir = "/tmp"; - tmp = "tmp.xxxxxx"; - } - if (TT.tmpdir) tmp = xmsprintf("%s/%s", TT.tmpdir ? TT.tmpdir : "/tmp", - *toys.optargs ? *toys.optargs : "tmp.XXXXXX"); + if (!tmp) { + if (!TT.tmpdir) TT.tmpdir = "/tmp"; + tmp = "tmp.xxxxxx"; + } + if (TT.tmpdir) tmp = xmsprintf("%s/%s", TT.tmpdir ? TT.tmpdir : "/tmp", + *toys.optargs ? *toys.optargs : "tmp.XXXXXX"); - if (d_flag ? mkdtemp(tmp) == NULL : mkstemp(tmp) == -1) - if (toys.optflags & FLAG_q) - perror_exit("Failed to create temporary %s", - d_flag ? "directory" : "file"); + if (d_flag ? mkdtemp(tmp) == NULL : mkstemp(tmp) == -1) + if (toys.optflags & FLAG_q) + perror_exit("Failed to create temporary %s", + d_flag ? "directory" : "file"); - xputs(tmp); + xputs(tmp); - if (CFG_TOYBOX_FREE && TT.tmpdir) free(tmp); + if (CFG_TOYBOX_FREE && TT.tmpdir) free(tmp); } -- cgit v1.2.3