aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb/mktemp.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-11-13 17:14:08 -0600
committerRob Landley <rob@landley.net>2012-11-13 17:14:08 -0600
commit7aa651a6a4496d848f86de9b1e6b3a003256a01f (patch)
tree6995fb4b7cc2e90a6706b0239ebaf95d9dbab530 /toys/lsb/mktemp.c
parent571b0706cce45716126776d0ad0f6ac65f4586e3 (diff)
downloadtoybox-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/lsb/mktemp.c')
-rw-r--r--toys/lsb/mktemp.c54
1 files changed, 26 insertions, 28 deletions
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 <eliedebrauwer@gmail.com>
*
@@ -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);
}