summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2010-05-01 14:24:35 +0200
committerJim Meyering <meyering@redhat.com>2010-05-31 11:02:21 +0200
commitda7a704cd36e1d2015d14247e5139fb1999b2211 (patch)
tree8302e47cb2f6fdef10059934e06413506ba1111d /src
parent5591f19e9cbee3598d23ea728fdebb396e2df89a (diff)
downloadcoreutils-da7a704cd36e1d2015d14247e5139fb1999b2211.tar.xz
maint: replace each "for (;;)" with "while (true)"
Run this command: git ls-files | grep '\.[ch]$' \ | xargs perl -pi -e 's/for \(;;\)/while (true)/g' ...except for randint.c, which does not include stdbool.h. In that case, use "while (1)". * gl/lib/randint.c (randint_genmax): Use "while (1)" for infloops. * src/cat.c (simple_cat, cat): Use "while (true)" for infloops. * gl/lib/randread.c (readsource, readisaac): Likewise. * src/copy.c (copy_reg): Likewise. * src/csplit.c (record_line_starts, process_regexp): Likewise. * src/cut.c (set_fields): Likewise. * src/dd.c (iread, parse_symbols): Likewise. * src/df.c (find_mount_point, main): Likewise. * src/du.c (main): Likewise. * src/expand.c (expand): Likewise. * src/factor.c (factor_using_division, do_stdin): Likewise. * src/fmt.c (get_space): Likewise. * src/ls.c (decode_switches): Likewise. * src/od.c (main): Likewise. * src/pr.c (main, read_line): Likewise. * src/shred.c (dopass, genpattern): Likewise. * src/sort.c (initbuf, fillbuf, getmonth, keycompare): Likewise. * src/split.c (bytes_split, lines_split): Likewise. * src/tac.c (tac_seekable): Likewise. * src/test.c (and, or): Likewise. * src/tr.c (squeeze_filter, main): Likewise. * src/tsort.c (search_item): Likewise. * src/unexpand.c (unexpand): Likewise. * src/uniq.c (main): Likewise. * src/yes.c (main): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/cat.c8
-rw-r--r--src/copy.c2
-rw-r--r--src/csplit.c6
-rw-r--r--src/cut.c2
-rw-r--r--src/dd.c4
-rw-r--r--src/df.c4
-rw-r--r--src/du.c2
-rw-r--r--src/expand.c4
-rw-r--r--src/factor.c6
-rw-r--r--src/fmt.c2
-rw-r--r--src/ls.c2
-rw-r--r--src/od.c2
-rw-r--r--src/pr.c4
-rw-r--r--src/shred.c4
-rw-r--r--src/sort.c16
-rw-r--r--src/split.c4
-rw-r--r--src/tac.c2
-rw-r--r--src/test.c4
-rw-r--r--src/tr.c8
-rw-r--r--src/tsort.c2
-rw-r--r--src/unexpand.c4
-rw-r--r--src/uniq.c2
-rw-r--r--src/yes.c2
23 files changed, 48 insertions, 48 deletions
diff --git a/src/cat.c b/src/cat.c
index 8740e0e4f..eebfb974d 100644
--- a/src/cat.c
+++ b/src/cat.c
@@ -160,7 +160,7 @@ simple_cat (
/* Loop until the end of the file. */
- for (;;)
+ while (true)
{
/* Read a block of input. */
@@ -269,7 +269,7 @@ cat (
bpout = outbuf;
- for (;;)
+ while (true)
{
do
{
@@ -424,7 +424,7 @@ cat (
scan for chars that need conversion. */
if (show_nonprinting)
{
- for (;;)
+ while (true)
{
if (ch >= 32)
{
@@ -475,7 +475,7 @@ cat (
else
{
/* Not quoting, neither of -v, -e, or -t specified. */
- for (;;)
+ while (true)
{
if (ch == '\t' && show_tabs)
{
diff --git a/src/copy.c b/src/copy.c
index c16cef62b..78c97ccb0 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -707,7 +707,7 @@ copy_reg (char const *src_name, char const *dst_name,
buf_alloc = xmalloc (buf_size + buf_alignment_slop);
buf = ptr_align (buf_alloc, buf_alignment);
- for (;;)
+ while (true)
{
word *wp = NULL;
diff --git a/src/csplit.c b/src/csplit.c
index 8cefdf329..40baba825 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -342,7 +342,7 @@ record_line_starts (struct buffer_record *b)
line_start = b->buffer;
bytes_left = b->bytes_used;
- for (;;)
+ while (true)
{
line_end = memchr (line_start, '\n', bytes_left);
if (line_end == NULL)
@@ -773,7 +773,7 @@ process_regexp (struct control *p, uintmax_t repetition)
if (p->offset >= 0)
{
- for (;;)
+ while (true)
{
line = find_line (++current_line);
if (line == NULL)
@@ -813,7 +813,7 @@ process_regexp (struct control *p, uintmax_t repetition)
else
{
/* Buffer the lines. */
- for (;;)
+ while (true)
{
line = find_line (++current_line);
if (line == NULL)
diff --git a/src/cut.c b/src/cut.c
index 087981cdf..8c93c8965 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -358,7 +358,7 @@ set_fields (const char *fieldstr)
/* Collect and store in RP the range end points.
It also sets EOL_RANGE_START if appropriate. */
- for (;;)
+ while (true)
{
if (*fieldstr == '-')
{
diff --git a/src/dd.c b/src/dd.c
index 1d8cfe07f..30d3d287a 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -796,7 +796,7 @@ process_signals (void)
static ssize_t
iread (int fd, char *buf, size_t size)
{
- for (;;)
+ while (true)
{
ssize_t nread;
process_signals ();
@@ -926,7 +926,7 @@ parse_symbols (char const *str, struct symbol_value const *table,
{
int value = 0;
- for (;;)
+ while (true)
{
char const *strcomma = strchr (str, ',');
struct symbol_value const *entry;
diff --git a/src/df.c b/src/df.c
index b8628791e..40011f8ac 100644
--- a/src/df.c
+++ b/src/df.c
@@ -574,7 +574,7 @@ find_mount_point (const char *file, const struct stat *file_stat)
/* Now walk up FILE's parents until we find another file system or /,
chdiring as we go. LAST_STAT holds stat information for the last place
we visited. */
- for (;;)
+ while (true)
{
struct stat st;
if (stat ("..", &st) < 0)
@@ -873,7 +873,7 @@ main (int argc, char **argv)
print_grand_total = false;
grand_fsu.fsu_blocksize = 1;
- for (;;)
+ while (true)
{
int oi = -1;
int c = getopt_long (argc, argv, "aB:iF:hHklmPTt:vx:", long_options,
diff --git a/src/du.c b/src/du.c
index 5d83dc6b5..2704f0f86 100644
--- a/src/du.c
+++ b/src/du.c
@@ -690,7 +690,7 @@ main (int argc, char **argv)
human_options (getenv ("DU_BLOCK_SIZE"),
&human_output_opts, &output_block_size);
- for (;;)
+ while (true)
{
int oi = -1;
int c = getopt_long (argc, argv, "0abd:chHklmsxB:DLPSX:",
diff --git a/src/expand.c b/src/expand.c
index fa1fdfeb7..6a04d36d7 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -270,7 +270,7 @@ expand (void)
if (!fp)
return;
- for (;;)
+ while (true)
{
/* Input character, or EOF. */
int c;
@@ -306,7 +306,7 @@ expand (void)
if (tab_size)
next_tab_column = column + (tab_size - column % tab_size);
else
- for (;;)
+ while (true)
if (tab_index == first_free_tab)
{
next_tab_column = column + 1;
diff --git a/src/factor.c b/src/factor.c
index 80aa3e639..7291d2819 100644
--- a/src/factor.c
+++ b/src/factor.c
@@ -107,7 +107,7 @@ factor_using_division (mpz_t t, unsigned int limit)
--f;
}
- for (;;)
+ while (true)
{
mpz_tdiv_qr_ui (q, r, t, 3);
if (mpz_cmp_ui (r, 0) != 0)
@@ -116,7 +116,7 @@ factor_using_division (mpz_t t, unsigned int limit)
emit_ul_factor (3);
}
- for (;;)
+ while (true)
{
mpz_tdiv_qr_ui (q, r, t, 5);
if (mpz_cmp_ui (r, 0) != 0)
@@ -516,7 +516,7 @@ do_stdin (void)
init_tokenbuffer (&tokenbuffer);
- for (;;)
+ while (true)
{
size_t token_length = readtoken (stdin, DELIM, sizeof (DELIM) - 1,
&tokenbuffer);
diff --git a/src/fmt.c b/src/fmt.c
index 86b83ee7c..1a268eeb4 100644
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -728,7 +728,7 @@ get_prefix (FILE *f)
static int
get_space (FILE *f, int c)
{
- for (;;)
+ while (true)
{
if (c == ' ')
in_column++;
diff --git a/src/ls.c b/src/ls.c
index aa9fb6c1a..3c0443849 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1635,7 +1635,7 @@ decode_switches (int argc, char **argv)
}
}
- for (;;)
+ while (true)
{
int oi = -1;
int c = getopt_long (argc, argv,
diff --git a/src/od.c b/src/od.c
index 45087253d..cde3bf951 100644
--- a/src/od.c
+++ b/src/od.c
@@ -1564,7 +1564,7 @@ main (int argc, char **argv)
address_pad_len = 7;
flag_dump_strings = false;
- for (;;)
+ while (true)
{
uintmax_t tmp;
enum strtol_error s_err;
diff --git a/src/pr.c b/src/pr.c
index a36b657ca..9d4c90f96 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -876,7 +876,7 @@ main (int argc, char **argv)
? xmalloc ((argc - 1) * sizeof (char *))
: NULL);
- for (;;)
+ while (true)
{
int oi = -1;
int c = getopt_long (argc, argv, short_options, long_options, &oi);
@@ -2526,7 +2526,7 @@ read_line (COLUMN *p)
print_clump (p, chars, clump_buff);
- for (;;)
+ while (true)
{
c = getc (p->fp);
diff --git a/src/shred.c b/src/shred.c
index 93858431e..659ac5a80 100644
--- a/src/shred.c
+++ b/src/shred.c
@@ -417,7 +417,7 @@ dopass (int fd, char const *qname, off_t *sizep, int type,
}
offset = 0;
- for (;;)
+ while (true)
{
/* How much to write this time? */
lim = sizeof r;
@@ -664,7 +664,7 @@ genpattern (int *dest, size_t num, struct randint_source *s)
d = dest; /* Destination for generated pass list */
n = num; /* Passes remaining to fill */
- for (;;)
+ while (true)
{
k = *p++; /* Block descriptor word */
if (!k)
diff --git a/src/sort.c b/src/sort.c
index e6cc2c27c..41194ba22 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1453,7 +1453,7 @@ initbuf (struct buffer *buf, size_t line_bytes, size_t alloc)
size cannot be allocated, repeatedly halve it until allocation
succeeds. The smaller allocation may hurt overall performance,
but that's better than failing. */
- for (;;)
+ while (true)
{
alloc += sizeof (struct line) - alloc % sizeof (struct line);
buf->buf = malloc (alloc);
@@ -1646,7 +1646,7 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file)
buf->nlines = 0;
}
- for (;;)
+ while (true)
{
char *ptr = buf->buf + buf->used;
struct line *linelim = buffer_linelim (buf);
@@ -1918,7 +1918,7 @@ getmonth (char const *month, size_t len, char const **ea)
size_t hi = MONTHS_PER_YEAR;
char const *monthlim = month + len;
- for (;;)
+ while (true)
{
if (month == monthlim)
return 0;
@@ -2340,7 +2340,7 @@ keycompare (const struct line *a, const struct line *b, bool show_debug)
int diff;
- for (;;)
+ while (true)
{
char const *translate = key->translate;
bool const *ignore = key->ignore;
@@ -2445,7 +2445,7 @@ keycompare (const struct line *a, const struct line *b, bool show_debug)
#define CMP_WITH_IGNORE(A, B) \
do \
{ \
- for (;;) \
+ while (true) \
{ \
while (texta < lima && ignore[to_uchar (*texta)]) \
++texta; \
@@ -2960,7 +2960,7 @@ mergelines (struct line *t,
struct line const *lo, size_t nlo,
struct line const *hi, size_t nhi)
{
- for (;;)
+ while (true)
if (compare (lo - 1, hi - 1, false) <= 0)
{
*--t = *--lo;
@@ -3210,7 +3210,7 @@ merge (struct sortfile *files, size_t ntemps, size_t nfiles,
try to merge into the output, and then merge as much as we can into a
temp file if we can't. Repeat. */
- for (;;)
+ while (true)
{
/* Merge directly into the output file if possible. */
FILE **fps;
@@ -3648,7 +3648,7 @@ main (int argc, char **argv)
files = xnmalloc (argc, sizeof *files);
- for (;;)
+ while (true)
{
/* Parse an operand as a file after "--" was seen; or if
pedantic and a file was seen, unless the POSIX version
diff --git a/src/split.c b/src/split.c
index 5bd9ebb4b..5be720795 100644
--- a/src/split.c
+++ b/src/split.c
@@ -233,7 +233,7 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
error (EXIT_FAILURE, errno, "%s", infile);
bp_out = buf;
to_read = n_read;
- for (;;)
+ while (true)
{
if (to_read < to_write)
{
@@ -278,7 +278,7 @@ lines_split (uintmax_t n_lines, char *buf, size_t bufsize)
bp = bp_out = buf;
eob = bp + n_read;
*eob = '\n';
- for (;;)
+ while (true)
{
bp = memchr (bp, '\n', eob - bp + 1);
if (bp == eob)
diff --git a/src/tac.c b/src/tac.c
index c7af6c11c..cec973601 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -245,7 +245,7 @@ tac_seekable (int input_fd, const char *file)
if (sentinel_length)
match_start -= match_length1;
- for (;;)
+ while (true)
{
/* Search backward from `match_start' - 1 to `G_buffer' for a match
with `separator'; for speed, use strncmp if `separator' contains no
diff --git a/src/test.c b/src/test.c
index 59d8b4eb0..e2247d2a6 100644
--- a/src/test.c
+++ b/src/test.c
@@ -511,7 +511,7 @@ and (void)
{
bool value = true;
- for (;;)
+ while (true)
{
value &= term ();
if (! (pos < argc && STREQ (argv[pos], "-a")))
@@ -530,7 +530,7 @@ or (void)
{
bool value = false;
- for (;;)
+ while (true)
{
value |= and ();
if (! (pos < argc && STREQ (argv[pos], "-o")))
diff --git a/src/tr.c b/src/tr.c
index c7510c335..3722b4d84 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -1489,7 +1489,7 @@ squeeze_filter (char *buf, size_t size, size_t (*reader) (char *, size_t))
size_t i = 0;
size_t nr = 0;
- for (;;)
+ while (true)
{
size_t begin;
@@ -1763,7 +1763,7 @@ main (int argc, char **argv)
{
set_initialize (s1, complement, in_delete_set);
- for (;;)
+ while (true)
{
size_t nr = read_and_delete (io_buf, sizeof io_buf);
if (nr == 0)
@@ -1817,7 +1817,7 @@ main (int argc, char **argv)
xlate[i] = i;
s1->state = BEGIN_STATE;
s2->state = BEGIN_STATE;
- for (;;)
+ while (true)
{
/* When the previous pair identified case-converting classes,
advance S1 and S2 so that each points to the following
@@ -1877,7 +1877,7 @@ main (int argc, char **argv)
}
else
{
- for (;;)
+ while (true)
{
size_t bytes_read = read_and_xlate (io_buf, sizeof io_buf);
if (bytes_read == 0)
diff --git a/src/tsort.c b/src/tsort.c
index 3746f9ec0..b5c187b30 100644
--- a/src/tsort.c
+++ b/src/tsort.c
@@ -136,7 +136,7 @@ search_item (struct item *root, const char *str)
t = root;
s = p = root->right;
- for (;;)
+ while (true)
{
/* A2. Compare. */
a = strcmp (str, p->str);
diff --git a/src/unexpand.c b/src/unexpand.c
index dfe93053f..a3bb4a88e 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -299,7 +299,7 @@ unexpand (void)
allocate MAX_COLUMN_WIDTH bytes to store the blanks. */
pending_blank = xmalloc (max_column_width);
- for (;;)
+ while (true)
{
/* Input character, or EOF. */
int c;
@@ -351,7 +351,7 @@ unexpand (void)
next_tab_column =
column + (tab_size - column % tab_size);
else
- for (;;)
+ while (true)
if (tab_index == first_free_tab)
{
convert = false;
diff --git a/src/uniq.c b/src/uniq.c
index 9a72857fd..1f594697e 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -434,7 +434,7 @@ main (int argc, char **argv)
countmode = count_none;
delimit_groups = DM_NONE;
- for (;;)
+ while (true)
{
/* Parse an operand with leading "+" as a file after "--" was
seen; or if pedantic and a file was seen; or if not
diff --git a/src/yes.c b/src/yes.c
index 9c79101bc..2548018d3 100644
--- a/src/yes.c
+++ b/src/yes.c
@@ -78,7 +78,7 @@ main (int argc, char **argv)
argv[argc++] = bad_cast ("y");
}
- for (;;)
+ while (true)
{
int i;
for (i = optind; i < argc; i++)