diff options
author | Jim Meyering <meyering@redhat.com> | 2009-08-22 18:56:06 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-08-25 09:21:00 +0200 |
commit | 5e778f7c8d1ecf3d8f11385db013af2ba026e2a5 (patch) | |
tree | e460d471f37f0dce1ba06f60f88114d1a65326c4 /gl/lib | |
parent | 2bc0f3caaafeb240cdcfd050b7ad1fe0ad14addf (diff) | |
download | coreutils-5e778f7c8d1ecf3d8f11385db013af2ba026e2a5.tar.xz |
global: convert indentation-TABs to spaces
Transformed via this shell code:
t=$'\t'
git ls-files \
| grep -vE '(^|/)((GNU)?[Mm]akefile|ChangeLog)|\.(am|mk)$' \
| grep -vE 'tests/pr/|help2man' \
| xargs grep -lE "^ *$t" \
| xargs perl -MText::Tabs -ni -le \
'$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
Diffstat (limited to 'gl/lib')
-rw-r--r-- | gl/lib/mgetgroups.c | 68 | ||||
-rw-r--r-- | gl/lib/rand-isaac.c | 18 | ||||
-rw-r--r-- | gl/lib/randint.c | 132 | ||||
-rw-r--r-- | gl/lib/randperm.c | 24 | ||||
-rw-r--r-- | gl/lib/randread.c | 66 | ||||
-rw-r--r-- | gl/lib/root-dev-ino.h | 10 | ||||
-rw-r--r-- | gl/lib/tempname.c | 126 | ||||
-rw-r--r-- | gl/lib/tempname.h | 4 | ||||
-rw-r--r-- | gl/lib/xfreopen.c | 10 |
9 files changed, 229 insertions, 229 deletions
diff --git a/gl/lib/mgetgroups.c b/gl/lib/mgetgroups.c index 736dd87f3..0ebc2be15 100644 --- a/gl/lib/mgetgroups.c +++ b/gl/lib/mgetgroups.c @@ -76,45 +76,45 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups) g = realloc_groupbuf (NULL, max_n_groups); if (g == NULL) - return -1; + return -1; while (1) - { - GETGROUPS_T *h; - int last_n_groups = max_n_groups; - - /* getgrouplist updates max_n_groups to num required. */ - ng = getgrouplist (username, gid, g, &max_n_groups); - - /* Some systems (like Darwin) have a bug where they - never increase max_n_groups. */ - if (ng < 0 && last_n_groups == max_n_groups) - max_n_groups *= 2; - - if ((h = realloc_groupbuf (g, max_n_groups)) == NULL) - { - int saved_errno = errno; - free (g); - errno = saved_errno; - return -1; - } - g = h; - - if (0 <= ng) - { - *groups = g; - /* On success some systems just return 0 from getgrouplist, - so return max_n_groups rather than ng. */ - return max_n_groups; - } - } + { + GETGROUPS_T *h; + int last_n_groups = max_n_groups; + + /* getgrouplist updates max_n_groups to num required. */ + ng = getgrouplist (username, gid, g, &max_n_groups); + + /* Some systems (like Darwin) have a bug where they + never increase max_n_groups. */ + if (ng < 0 && last_n_groups == max_n_groups) + max_n_groups *= 2; + + if ((h = realloc_groupbuf (g, max_n_groups)) == NULL) + { + int saved_errno = errno; + free (g); + errno = saved_errno; + return -1; + } + g = h; + + if (0 <= ng) + { + *groups = g; + /* On success some systems just return 0 from getgrouplist, + so return max_n_groups rather than ng. */ + return max_n_groups; + } + } } /* else no username, so fall through and use getgroups. */ #endif max_n_groups = (username - ? getugroups (0, NULL, username, gid) - : getgroups (0, NULL)); + ? getugroups (0, NULL, username, gid) + : getgroups (0, NULL)); /* If we failed to count groups with NULL for a buffer, try again with a non-NULL one, just in case. */ @@ -126,8 +126,8 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups) return -1; ng = (username - ? getugroups (max_n_groups, g, username, gid) - : getgroups (max_n_groups, g)); + ? getugroups (max_n_groups, g, username, gid) + : getgroups (max_n_groups, g)); if (ng < 0) { diff --git a/gl/lib/rand-isaac.c b/gl/lib/rand-isaac.c index 5b6171478..a1edf4785 100644 --- a/gl/lib/rand-isaac.c +++ b/gl/lib/rand-isaac.c @@ -43,7 +43,7 @@ /* This index operation is more efficient on many processors */ #define ind(mm, x) \ (* (uint32_t *) ((char *) (mm) \ - + ((x) & (ISAAC_WORDS - 1) * sizeof (uint32_t)))) + + ((x) & (ISAAC_WORDS - 1) * sizeof (uint32_t)))) /* * The central step. This uses two temporaries, x and y. mm is the @@ -191,18 +191,18 @@ isaac_init (struct isaac_state *s, uint32_t const *seed, size_t seedsize) isaac_mix (s, seed); /* Second and subsequent passes (extension to ISAAC) */ while (seedsize -= ISAAC_BYTES) - { - seed += ISAAC_WORDS; - for (i = 0; i < ISAAC_WORDS; i++) - s->mm[i] += seed[i]; - isaac_mix (s, s->mm); - } + { + seed += ISAAC_WORDS; + for (i = 0; i < ISAAC_WORDS; i++) + s->mm[i] += seed[i]; + isaac_mix (s, s->mm); + } } else { /* The no seed case (as in reference ISAAC code) */ for (i = 0; i < ISAAC_WORDS; i++) - s->mm[i] = 0; + s->mm[i] = 0; } /* Final pass */ @@ -252,7 +252,7 @@ isaac_seed_data (struct isaac_state *s, void const *buffer, size_t size) { p = (unsigned char *) s->mm + s->c; for (i = 0; i < avail; i++) - p[i] ^= buf[i]; + p[i] ^= buf[i]; buf += avail; size -= avail; isaac_mix (s, s->mm); diff --git a/gl/lib/randint.c b/gl/lib/randint.c index 0edda0aa0..cfa6e232b 100644 --- a/gl/lib/randint.c +++ b/gl/lib/randint.c @@ -128,75 +128,75 @@ randint_genmax (struct randint_source *s, randint genmax) for (;;) { if (randmax < genmax) - { - /* Calculate how many input bytes will be needed, and read - the bytes. */ - - size_t i = 0; - randint rmax = randmax; - unsigned char buf[sizeof randnum]; - - do - { - rmax = shift_left (rmax) + UCHAR_MAX; - i++; - } - while (rmax < genmax); - - randread (source, buf, i); - - /* Increase RANDMAX by appending random bytes to RANDNUM and - UCHAR_MAX to RANDMAX until RANDMAX is no less than - GENMAX. This may lose up to CHAR_BIT bits of information - if shift_right (RANDINT_MAX) < GENMAX, but it is not - worth the programming hassle of saving these bits since - GENMAX is rarely that large in practice. */ - - i = 0; - - do - { - randnum = shift_left (randnum) + buf[i]; - randmax = shift_left (randmax) + UCHAR_MAX; - i++; - } - while (randmax < genmax); - } + { + /* Calculate how many input bytes will be needed, and read + the bytes. */ + + size_t i = 0; + randint rmax = randmax; + unsigned char buf[sizeof randnum]; + + do + { + rmax = shift_left (rmax) + UCHAR_MAX; + i++; + } + while (rmax < genmax); + + randread (source, buf, i); + + /* Increase RANDMAX by appending random bytes to RANDNUM and + UCHAR_MAX to RANDMAX until RANDMAX is no less than + GENMAX. This may lose up to CHAR_BIT bits of information + if shift_right (RANDINT_MAX) < GENMAX, but it is not + worth the programming hassle of saving these bits since + GENMAX is rarely that large in practice. */ + + i = 0; + + do + { + randnum = shift_left (randnum) + buf[i]; + randmax = shift_left (randmax) + UCHAR_MAX; + i++; + } + while (randmax < genmax); + } if (randmax == genmax) - { - s->randnum = s->randmax = 0; - return randnum; - } + { + s->randnum = s->randmax = 0; + return randnum; + } else - { - /* GENMAX < RANDMAX, so attempt to generate a random number - by taking RANDNUM modulo GENMAX+1. This will choose - fairly so long as RANDNUM falls within an integral - multiple of GENMAX+1; otherwise, LAST_USABLE_CHOICE < RANDNUM, - so discard this attempt and try again. - - Since GENMAX cannot be RANDINT_MAX, CHOICES cannot be - zero and there is no need to worry about dividing by - zero. */ - - randint excess_choices = randmax - genmax; - randint unusable_choices = excess_choices % choices; - randint last_usable_choice = randmax - unusable_choices; - randint reduced_randnum = randnum % choices; - - if (randnum <= last_usable_choice) - { - s->randnum = randnum / choices; - s->randmax = excess_choices / choices; - return reduced_randnum; - } - - /* Retry, but retain the randomness from the fact that RANDNUM fell - into the range LAST_USABLE_CHOICE+1 .. RANDMAX. */ - randnum = reduced_randnum; - randmax = unusable_choices - 1; - } + { + /* GENMAX < RANDMAX, so attempt to generate a random number + by taking RANDNUM modulo GENMAX+1. This will choose + fairly so long as RANDNUM falls within an integral + multiple of GENMAX+1; otherwise, LAST_USABLE_CHOICE < RANDNUM, + so discard this attempt and try again. + + Since GENMAX cannot be RANDINT_MAX, CHOICES cannot be + zero and there is no need to worry about dividing by + zero. */ + + randint excess_choices = randmax - genmax; + randint unusable_choices = excess_choices % choices; + randint last_usable_choice = randmax - unusable_choices; + randint reduced_randnum = randnum % choices; + + if (randnum <= last_usable_choice) + { + s->randnum = randnum / choices; + s->randmax = excess_choices / choices; + return reduced_randnum; + } + + /* Retry, but retain the randomness from the fact that RANDNUM fell + into the range LAST_USABLE_CHOICE+1 .. RANDMAX. */ + randnum = reduced_randnum; + randmax = unusable_choices - 1; + } } } diff --git a/gl/lib/randperm.c b/gl/lib/randperm.c index 507e21460..a03c5b87f 100644 --- a/gl/lib/randperm.c +++ b/gl/lib/randperm.c @@ -79,21 +79,21 @@ randperm_new (struct randint_source *r, size_t h, size_t n) default: { - size_t i; + size_t i; - v = xnmalloc (n, sizeof *v); - for (i = 0; i < n; i++) - v[i] = i; + v = xnmalloc (n, sizeof *v); + for (i = 0; i < n; i++) + v[i] = i; - for (i = 0; i < h; i++) - { - size_t j = i + randint_choose (r, n - i); - size_t t = v[i]; - v[i] = v[j]; - v[j] = t; - } + for (i = 0; i < h; i++) + { + size_t j = i + randint_choose (r, n - i); + size_t t = v[i]; + v[i] = v[j]; + v[j] = t; + } - v = xnrealloc (v, h, sizeof *v); + v = xnrealloc (v, h, sizeof *v); } break; } diff --git a/gl/lib/randread.c b/gl/lib/randread.c index 48ce92e9a..72475017e 100644 --- a/gl/lib/randread.c +++ b/gl/lib/randread.c @@ -100,8 +100,8 @@ struct randread_source /* Up to a buffer's worth of pseudorandom data. */ union { - uint32_t w[ISAAC_WORDS]; - unsigned char b[ISAAC_BYTES]; + uint32_t w[ISAAC_WORDS]; + unsigned char b[ISAAC_BYTES]; } data; } isaac; } buf; @@ -115,8 +115,8 @@ randread_error (void const *file_name) { if (file_name) error (exit_failure, errno, - _(errno == 0 ? "%s: end of file" : "%s: read error"), - quotearg_colon (file_name)); + _(errno == 0 ? "%s: end of file" : "%s: read error"), + quotearg_colon (file_name)); abort (); } @@ -155,18 +155,18 @@ randread_new (char const *name, size_t bytes_bound) struct randread_source *s; if (name) - if (! (source = fopen_safer (name, "rb"))) - return NULL; + if (! (source = fopen_safer (name, "rb"))) + return NULL; s = simple_new (source, name); if (source) - setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound)); + setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound)); else - { - s->buf.isaac.buffered = 0; - isaac_seed (&s->buf.isaac.state); - } + { + s->buf.isaac.buffered = 0; + isaac_seed (&s->buf.isaac.state); + } return s; } @@ -206,7 +206,7 @@ readsource (struct randread_source *s, unsigned char *p, size_t size) p += inbytes; size -= inbytes; if (size == 0) - break; + break; errno = (ferror (s->source) ? fread_errno : 0); s->handler (s->handler_arg); } @@ -224,34 +224,34 @@ readisaac (struct isaac *isaac, unsigned char *p, size_t size) for (;;) { if (size <= inbytes) - { - memcpy (p, isaac->data.b + ISAAC_BYTES - inbytes, size); - isaac->buffered = inbytes - size; - return; - } + { + memcpy (p, isaac->data.b + ISAAC_BYTES - inbytes, size); + isaac->buffered = inbytes - size; + return; + } memcpy (p, isaac->data.b + ISAAC_BYTES - inbytes, inbytes); p += inbytes; size -= inbytes; /* If P is aligned, write to *P directly to avoid the overhead - of copying from the buffer. */ + of copying from the buffer. */ if (ALIGNED_POINTER (p, uint32_t)) - { - uint32_t *wp = (uint32_t *) p; - while (ISAAC_BYTES <= size) - { - isaac_refill (&isaac->state, wp); - wp += ISAAC_WORDS; - size -= ISAAC_BYTES; - if (size == 0) - { - isaac->buffered = 0; - return; - } - } - p = (unsigned char *) wp; - } + { + uint32_t *wp = (uint32_t *) p; + while (ISAAC_BYTES <= size) + { + isaac_refill (&isaac->state, wp); + wp += ISAAC_WORDS; + size -= ISAAC_BYTES; + if (size == 0) + { + isaac->buffered = 0; + return; + } + } + p = (unsigned char *) wp; + } isaac_refill (&isaac->state, isaac->data.w); inbytes = ISAAC_BYTES; diff --git a/gl/lib/root-dev-ino.h b/gl/lib/root-dev-ino.h index 2832096c1..bec27f0ae 100644 --- a/gl/lib/root-dev-ino.h +++ b/gl/lib/root-dev-ino.h @@ -34,12 +34,12 @@ get_root_dev_ino (struct dev_ino *root_d_i); do \ { \ if (STREQ (Dirname, "/")) \ - error (0, 0, _("it is dangerous to operate recursively on %s"), \ - quote (Dirname)); \ + error (0, 0, _("it is dangerous to operate recursively on %s"), \ + quote (Dirname)); \ else \ - error (0, 0, \ - _("it is dangerous to operate recursively on %s (same as %s)"), \ - quote_n (0, Dirname), quote_n (1, "/")); \ + error (0, 0, \ + _("it is dangerous to operate recursively on %s (same as %s)"), \ + quote_n (0, Dirname), quote_n (1, "/")); \ error (0, 0, _("use --no-preserve-root to override this failsafe")); \ } \ while (0) diff --git a/gl/lib/tempname.c b/gl/lib/tempname.c index e9fb60670..01715168d 100644 --- a/gl/lib/tempname.c +++ b/gl/lib/tempname.c @@ -96,7 +96,7 @@ direxists (const char *dir) enough space in TMPL. */ int __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, - int try_tmpdir) + int try_tmpdir) { const char *d; size_t dlen, plen; @@ -110,30 +110,30 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, { plen = strlen (pfx); if (plen > 5) - plen = 5; + plen = 5; } if (try_tmpdir) { d = __secure_getenv ("TMPDIR"); if (d != NULL && direxists (d)) - dir = d; + dir = d; else if (dir != NULL && direxists (dir)) - /* nothing */ ; + /* nothing */ ; else - dir = NULL; + dir = NULL; } if (dir == NULL) { if (direxists (P_tmpdir)) - dir = P_tmpdir; + dir = P_tmpdir; else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) - dir = "/tmp"; + dir = "/tmp"; else - { - __set_errno (ENOENT); - return -1; - } + { + __set_errno (ENOENT); + return -1; + } } dlen = strlen (dir); @@ -169,9 +169,9 @@ static const char letters[] = KIND may be one of: __GT_NOCREATE: simply verify that the name does not exist - at the time of the call. + at the time of the call. __GT_FILE: create the file using open(O_CREAT|O_EXCL) - and return a read-write fd. The file is mode 0600. + and return a read-write fd. The file is mode 0600. __GT_BIGFILE: same as __GT_FILE but use open64(). __GT_DIR: create a directory, which will be mode 0700. @@ -205,7 +205,7 @@ gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) len = strlen (tmpl); if (len < x_suffix_len || ! check_x_suffix (&tmpl[len - x_suffix_len], - x_suffix_len)) + x_suffix_len)) { __set_errno (EINVAL); return -1; @@ -223,60 +223,60 @@ gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) size_t i; for (i = 0; i < x_suffix_len; i++) - { - XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)]; - } + { + XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)]; + } switch (kind) - { - case __GT_FILE: - fd = small_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); - break; - - case __GT_BIGFILE: - fd = large_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); - break; - - case __GT_DIR: - fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR); - break; - - case __GT_NOCREATE: - /* This case is backward from the other three. This function - succeeds if __xstat fails because the name does not exist. - Note the continue to bypass the common logic at the bottom - of the loop. */ - if (__lxstat64 (_STAT_VER, tmpl, &st) < 0) - { - if (errno == ENOENT) - { - __set_errno (save_errno); - fd = 0; - goto done; - } - else - { - /* Give up now. */ - fd = -1; - goto done; - } - } - continue; - - default: - assert (! "invalid KIND in __gen_tempname"); - } + { + case __GT_FILE: + fd = small_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + break; + + case __GT_BIGFILE: + fd = large_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + break; + + case __GT_DIR: + fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR); + break; + + case __GT_NOCREATE: + /* This case is backward from the other three. This function + succeeds if __xstat fails because the name does not exist. + Note the continue to bypass the common logic at the bottom + of the loop. */ + if (__lxstat64 (_STAT_VER, tmpl, &st) < 0) + { + if (errno == ENOENT) + { + __set_errno (save_errno); + fd = 0; + goto done; + } + else + { + /* Give up now. */ + fd = -1; + goto done; + } + } + continue; + + default: + assert (! "invalid KIND in __gen_tempname"); + } if (fd >= 0) - { - __set_errno (save_errno); - goto done; - } + { + __set_errno (save_errno); + goto done; + } else if (errno != EEXIST) - { - fd = -1; - goto done; - } + { + fd = -1; + goto done; + } } randint_all_free (rand_src); diff --git a/gl/lib/tempname.h b/gl/lib/tempname.h index b7dd3a101..ee34aca21 100644 --- a/gl/lib/tempname.h +++ b/gl/lib/tempname.h @@ -30,9 +30,9 @@ KIND may be one of: GT_NOCREATE: simply verify that the name does not exist - at the time of the call. + at the time of the call. GT_FILE: create a large file using open(O_CREAT|O_EXCL) - and return a read-write fd. The file is mode 0600. + and return a read-write fd. The file is mode 0600. GT_DIR: create a directory, which will be mode 0700. We use a clever algorithm to get hard-to-predict names. */ diff --git a/gl/lib/xfreopen.c b/gl/lib/xfreopen.c index a20965f25..61091694b 100644 --- a/gl/lib/xfreopen.c +++ b/gl/lib/xfreopen.c @@ -31,11 +31,11 @@ xfreopen (char const *filename, char const *mode, FILE *fp) if (!freopen (filename, mode, fp)) { char const *f = (filename ? filename - : (fp == stdin ? _("stdin") - : (fp == stdout ? _("stdout") - : (fp == stderr ? _("stderr") - : _("unknown stream"))))); + : (fp == stdin ? _("stdin") + : (fp == stdout ? _("stdout") + : (fp == stderr ? _("stderr") + : _("unknown stream"))))); error (exit_failure, errno, _("failed to reopen %s with mode %s"), - quote_n (0, f), quote_n (1, mode)); + quote_n (0, f), quote_n (1, mode)); } } |