diff options
author | Kevin McCarthy <kevin@8t8.us> | 2019-01-03 19:58:18 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2019-01-04 13:59:27 -0800 |
commit | 248c2ee8ed7c0ff333ae076041107210c5acd641 (patch) | |
tree | f51f10f1f486e08c76e187c095e536620bebbbd0 /mkdtemp.c | |
parent | 085a6f74b3b7cebabb75f4c99ea9d59649c7b03a (diff) |
Clean up code indentation.
These are mostly automated changes corresponding to the emacs
settings:
(c-set-style "linux")
(setq c-basic-offset 2)
(c-set-offset 'case-label '+)
Most of the code follows the convention:
(add-to-list 'c-cleanup-list 'space-before-funcall)
but this is not enforced by this indentation cleanup.
Also, I personally dislike tabs, so I have:
(setq-default indent-tabs-mode nil)
in my own configuration. However I have no desire to change every line
just for that effect. So this cleanup does nothing about the mix issue.
Some of the secondary files (e.g. regex.c) have been skipped.
I've also skipped crypt-gpgme.c, because I need to think about that
file. Werner Koch and the GnuPG team contributed most it, and it
follows the Gnu indentation settings. It should probably be made
uniform with Mutt, but I don't want to discourage future GnuPG
contribution to the file.
I manually reverted a few unsightly cleanups, and added a few tweeks
when I saw things that could be improved.
Diffstat (limited to 'mkdtemp.c')
-rw-r--r-- | mkdtemp.c | 54 |
1 files changed, 27 insertions, 27 deletions
@@ -9,37 +9,37 @@ /* mkdtemp function for systems which don't have one */ char *mkdtemp (char *tmpl) { - static const char LETTERS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - static long value = 0; - long v; - int len; - int i, j; + static const char LETTERS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + static long value = 0; + long v; + int len; + int i, j; - len = strlen (tmpl); - if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX") != 0) - { - errno = EINVAL; - return NULL; - } + len = strlen (tmpl); + if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX") != 0) + { + errno = EINVAL; + return NULL; + } - value += ((long) time (NULL)) ^ getpid (); + value += ((long) time (NULL)) ^ getpid (); - for (i = 0; i < 7 ; ++i, value += 7777) + for (i = 0; i < 7 ; ++i, value += 7777) + { + /* fill in the random bits */ + for (j = 0, v = value; j < 6; ++j) { - /* fill in the random bits */ - for (j = 0, v = value; j < 6; ++j) - { - tmpl[(len - 6) + j] = LETTERS[v % 62]; - v /= 62; - } - - /* try to create the directory */ - if (mkdir (tmpl, 0700) == 0) - return tmpl; - else if (errno != EEXIST) - return NULL; + tmpl[(len - 6) + j] = LETTERS[v % 62]; + v /= 62; } - errno = EEXIST; - return NULL; + /* try to create the directory */ + if (mkdir (tmpl, 0700) == 0) + return tmpl; + else if (errno != EEXIST) + return NULL; + } + + errno = EEXIST; + return NULL; } |