From 145707949f9479f00dce41f479549f7629d7d0c9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 26 Jun 2021 18:23:52 -0700 Subject: [PATCH 1/3] =?UTF-8?q?maint:=20while=20(1)=20=E2=86=92=20while=20?= =?UTF-8?q?(true)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/basenc.c | 2 +- src/chcon.c | 2 +- src/chmod.c | 2 +- src/chown-core.c | 2 +- src/csplit.c | 2 +- src/cut.c | 2 +- src/date.c | 2 +- src/dd.c | 2 +- src/dircolors.c | 2 +- src/du.c | 2 +- src/expr.c | 12 ++++++------ src/head.c | 4 ++-- src/join.c | 2 +- src/ls.c | 4 ++-- src/nproc.c | 2 +- src/od.c | 6 +++--- src/ptx.c | 2 +- src/pwd.c | 6 +++--- src/realpath.c | 2 +- src/remove.c | 2 +- src/rmdir.c | 2 +- src/runcon.c | 2 +- src/sort.c | 2 +- src/sum.c | 2 +- src/system.h | 2 +- src/tac-pipe.c | 6 +++--- src/tac.c | 2 +- src/tail.c | 12 ++++++------ src/tsort.c | 2 +- 29 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/basenc.c b/src/basenc.c index 7e22363bf..5c97a3652 100644 --- a/src/basenc.c +++ b/src/basenc.c @@ -605,7 +605,7 @@ z85_encode (char const *restrict in, size_t inlen, unsigned int val; size_t outidx = 0; - while (1) + while (true) { if (inlen == 0) { diff --git a/src/chcon.c b/src/chcon.c index dc2258de0..88010848e 100644 --- a/src/chcon.c +++ b/src/chcon.c @@ -315,7 +315,7 @@ process_files (char **files, int bit_flags) FTS *fts = xfts_open (files, bit_flags, NULL); - while (1) + while (true) { FTSENT *ent; diff --git a/src/chmod.c b/src/chmod.c index 78d9c9cba..160a0c537 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -335,7 +335,7 @@ process_files (char **files, int bit_flags) FTS *fts = xfts_open (files, bit_flags, NULL); - while (1) + while (true) { FTSENT *ent; diff --git a/src/chown-core.c b/src/chown-core.c index a0b2f670f..4d816de4a 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -524,7 +524,7 @@ chown_files (char **files, int bit_flags, FTS *fts = xfts_open (files, bit_flags | stat_flags, NULL); - while (1) + while (true) { FTSENT *ent; diff --git a/src/csplit.c b/src/csplit.c index f188e8894..e1fb66ed2 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -496,7 +496,7 @@ load_buffer (void) if (bytes_wanted < hold_count) bytes_wanted = hold_count; - while (1) + while (true) { b = get_new_buffer (bytes_wanted); bytes_avail = b->bytes_alloc; /* Size of buffer returned. */ diff --git a/src/cut.c b/src/cut.c index 78b82c80e..f4d44c211 100644 --- a/src/cut.c +++ b/src/cut.c @@ -306,7 +306,7 @@ cut_fields (FILE *stream) That is because a non-delimited line has exactly one field. */ buffer_first_field = (suppress_non_delimited ^ !print_kth (1)); - while (1) + while (true) { if (field_idx == 1 && buffer_first_field) { diff --git a/src/date.c b/src/date.c index d5eebaf25..4a7a4e243 100644 --- a/src/date.c +++ b/src/date.c @@ -313,7 +313,7 @@ batch_convert (char const *input_filename, char const *format, line = NULL; buflen = 0; ok = true; - while (1) + while (true) { ssize_t line_length = getline (&line, &buflen, in_stream); if (line_length < 0) diff --git a/src/dd.c b/src/dd.c index d284357a4..fc5108f8b 100644 --- a/src/dd.c +++ b/src/dd.c @@ -2179,7 +2179,7 @@ dd_copy (void) alloc_ibuf (); alloc_obuf (); - while (1) + while (true) { if (status_level == STATUS_PROGRESS) { diff --git a/src/dircolors.c b/src/dircolors.c index fea0cdf01..b765ded9f 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -253,7 +253,7 @@ dc_parse_stream (FILE *fp, char const *filename) if (term == NULL || *term == '\0') term = "none"; - while (1) + while (true) { char *keywd, *arg; bool unrecognized; diff --git a/src/du.c b/src/du.c index d4760a36c..efd519706 100644 --- a/src/du.c +++ b/src/du.c @@ -684,7 +684,7 @@ du_files (char **files, int bit_flags) { FTS *fts = xfts_open (files, bit_flags, NULL); - while (1) + while (true) { FTSENT *ent; diff --git a/src/expr.c b/src/expr.c index ec76f7607..41185a8f8 100644 --- a/src/expr.c +++ b/src/expr.c @@ -781,7 +781,7 @@ eval5 (bool evaluate) trace ("eval5"); #endif l = eval6 (evaluate); - while (1) + while (true) { if (nextarg (":")) { @@ -812,7 +812,7 @@ eval4 (bool evaluate) trace ("eval4"); #endif l = eval5 (evaluate); - while (1) + while (true) { if (nextarg ("*")) fxn = multiply; @@ -851,7 +851,7 @@ eval3 (bool evaluate) trace ("eval3"); #endif l = eval4 (evaluate); - while (1) + while (true) { if (nextarg ("+")) fxn = plus; @@ -881,7 +881,7 @@ eval2 (bool evaluate) trace ("eval2"); #endif l = eval3 (evaluate); - while (1) + while (true) { VALUE *r; enum @@ -960,7 +960,7 @@ eval1 (bool evaluate) trace ("eval1"); #endif l = eval2 (evaluate); - while (1) + while (true) { if (nextarg ("&")) { @@ -991,7 +991,7 @@ eval (bool evaluate) trace ("eval"); #endif l = eval1 (evaluate); - while (1) + while (true) { if (nextarg ("|")) { diff --git a/src/head.c b/src/head.c index 844c5636a..7b2a44041 100644 --- a/src/head.c +++ b/src/head.c @@ -520,7 +520,7 @@ elide_tail_lines_pipe (char const *filename, int fd, uintmax_t n_elide, /* Always read into a fresh buffer. Read, (producing no output) until we've accumulated at least n_elide newlines, or until EOF, whichever comes first. */ - while (1) + while (true) { n_read = safe_read (fd, tmp->buffer, BUFSIZ); if (n_read == 0 || n_read == SAFE_READ_ERROR) @@ -676,7 +676,7 @@ elide_tail_lines_seekable (char const *pretty_filename, int fd, if (n_lines && bytes_read && buffer[bytes_read - 1] != line_end) --n_lines; - while (1) + while (true) { /* Scan backward, counting the newlines in this bufferfull. */ diff --git a/src/join.c b/src/join.c index 57f4665bc..f22ffda53 100644 --- a/src/join.c +++ b/src/join.c @@ -598,7 +598,7 @@ prjoin (struct line const *line1, struct line const *line2) const struct outlist *o; o = outlist; - while (1) + while (true) { if (o->file == 0) { diff --git a/src/ls.c b/src/ls.c index 4586b5ecc..1b20f17fe 100644 --- a/src/ls.c +++ b/src/ls.c @@ -2980,7 +2980,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg) /* Read the directory entries, and insert the subfiles into the 'cwd_file' table. */ - while (1) + while (true) { /* Set errno to zero so we can distinguish between a readdir failure and when readdir simply finds that there are no more entries. */ @@ -5112,7 +5112,7 @@ print_many_per_line (void) size_t pos = 0; /* Print the next row. */ - while (1) + while (true) { struct fileinfo const *f = sorted_file[filesno]; size_t name_length = length_of_file_name_and_frills (f); diff --git a/src/nproc.c b/src/nproc.c index e06b7a431..55a51bfbe 100644 --- a/src/nproc.c +++ b/src/nproc.c @@ -86,7 +86,7 @@ main (int argc, char **argv) enum nproc_query mode = NPROC_CURRENT_OVERRIDABLE; - while (1) + while (true) { int c = getopt_long (argc, argv, "", longopts, NULL); if (c == -1) diff --git a/src/od.c b/src/od.c index 5b2d507a1..f04e0ccb7 100644 --- a/src/od.c +++ b/src/od.c @@ -1387,7 +1387,7 @@ dump (void) if (limit_bytes_to_format) { - while (1) + while (true) { size_t n_needed; if (current_offset >= end_offset) @@ -1409,7 +1409,7 @@ dump (void) } else { - while (1) + while (true) { ok &= read_block (bytes_per_block, block[idx], &n_bytes_read); if (n_bytes_read < bytes_per_block) @@ -1462,7 +1462,7 @@ dump_strings (void) uintmax_t address = n_bytes_to_skip; bool ok = true; - while (1) + while (true) { size_t i; int c; diff --git a/src/ptx.c b/src/ptx.c index fc4d0912f..c488b1192 100644 --- a/src/ptx.c +++ b/src/ptx.c @@ -837,7 +837,7 @@ find_occurs_in_text (int file_index) /* Read and process a single input line or sentence, one word at a time. */ - while (1) + while (true) { if (word_regex.string) diff --git a/src/pwd.c b/src/pwd.c index 3a18c3d81..5dfda31bd 100644 --- a/src/pwd.c +++ b/src/pwd.c @@ -178,7 +178,7 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name, use_lstat = (parent_sb.st_dev != dot_sb->st_dev); found = false; - while (1) + while (true) { struct dirent const *dp; struct stat ent_sb; @@ -279,7 +279,7 @@ robust_getcwd (struct file_name *file_name) if (stat (".", &dot_sb) < 0) die (EXIT_FAILURE, errno, _("failed to stat %s"), quoteaf (".")); - while (1) + while (true) { /* If we've reached the root, we're done. */ if (SAME_INODE (dot_sb, *root_dev_ino)) @@ -340,7 +340,7 @@ main (int argc, char **argv) atexit (close_stdout); - while (1) + while (true) { int c = getopt_long (argc, argv, "LP", longopts, NULL); if (c == -1) diff --git a/src/realpath.c b/src/realpath.c index 4c9ffbcb4..8e4aabfdf 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -185,7 +185,7 @@ main (int argc, char **argv) atexit (close_stdout); - while (1) + while (true) { int c = getopt_long (argc, argv, "eLmPqsz", longopts, NULL); if (c == -1) diff --git a/src/remove.c b/src/remove.c index da380e0a7..5dd0479e6 100644 --- a/src/remove.c +++ b/src/remove.c @@ -590,7 +590,7 @@ rm (char *const *file, struct rm_options const *x) FTS *fts = xfts_open (file, bit_flags, NULL); - while (1) + while (true) { FTSENT *ent; diff --git a/src/rmdir.c b/src/rmdir.c index 3a9911ff0..149d4659a 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -117,7 +117,7 @@ remove_parents (char *dir) bool ok = true; strip_trailing_slashes (dir); - while (1) + while (true) { slash = strrchr (dir, '/'); if (slash == NULL) diff --git a/src/runcon.c b/src/runcon.c index fda8bb398..716170092 100644 --- a/src/runcon.c +++ b/src/runcon.c @@ -124,7 +124,7 @@ main (int argc, char **argv) atexit (close_stdout); - while (1) + while (true) { int option_index = 0; int c = getopt_long (argc, argv, "+r:t:u:l:c", long_options, diff --git a/src/sort.c b/src/sort.c index d98796b96..451bfe08a 100644 --- a/src/sort.c +++ b/src/sort.c @@ -3552,7 +3552,7 @@ static void merge_loop (struct merge_node_queue *queue, size_t total_lines, FILE *tfp, char const *temp_output) { - while (1) + while (true) { struct merge_node *node = queue_pop (queue); diff --git a/src/sum.c b/src/sum.c index 218db808d..f9641dbb1 100644 --- a/src/sum.c +++ b/src/sum.c @@ -179,7 +179,7 @@ sysv_sum_file (char const *file, int print_name) } } - while (1) + while (true) { size_t bytes_read = safe_read (fd, buf, sizeof buf); diff --git a/src/system.h b/src/system.h index 676f5f562..ce264b121 100644 --- a/src/system.h +++ b/src/system.h @@ -277,7 +277,7 @@ dot_or_dotdot (char const *file_name) static inline struct dirent const * readdir_ignoring_dot_and_dotdot (DIR *dirp) { - while (1) + while (true) { struct dirent const *dp = readdir (dirp); if (dp == NULL || ! dot_or_dotdot (dp->d_name)) diff --git a/src/tac-pipe.c b/src/tac-pipe.c index 5fefd631b..5192607d9 100644 --- a/src/tac-pipe.c +++ b/src/tac-pipe.c @@ -58,7 +58,7 @@ buf_init_from_stdin (Buf *x, char eol_byte) #define OBS (&(x->obs)) obstack_init (OBS); - while (1) + while (true) { char *buf = (char *) malloc (BUFFER_SIZE); size_t bytes_read; @@ -185,7 +185,7 @@ find_bol (const Buf *x, tmp = line_ptr_decrement (x, last_bol); last_bol_ptr = tmp.ptr; i = tmp.i; - while (1) + while (true) { char *nl = memrchr (x->p[i].start, last_bol_ptr, eol_byte); if (nl) @@ -250,7 +250,7 @@ tac_mem () bol.i = x.n_bufs - 1; bol.ptr = ONE_PAST_END (&x, bol.i); - while (1) + while (true) { Line_ptr new_bol; if (! find_bol (&x, &bol, &new_bol, eol_byte)) diff --git a/src/tac.c b/src/tac.c index 1a01c005e..cbc3deac9 100644 --- a/src/tac.c +++ b/src/tac.c @@ -505,7 +505,7 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) if (!temp_stream (&fp, &file_name)) return -1; - while (1) + while (true) { size_t bytes_read = safe_read (input_fd, G_buffer, read_size); if (bytes_read == 0) diff --git a/src/tail.c b/src/tail.c index b91fcfd82..7c3ae22d9 100644 --- a/src/tail.c +++ b/src/tail.c @@ -453,7 +453,7 @@ dump_remainder (bool want_header, char const *pretty_filename, int fd, uintmax_t n_remaining = n_bytes; n_written = 0; - while (1) + while (true) { char buffer[BUFSIZ]; size_t n = MIN (n_remaining, BUFSIZ); @@ -641,7 +641,7 @@ pipe_lines (char const *pretty_filename, int fd, uintmax_t n_lines, tmp = xmalloc (sizeof (LBUFFER)); /* Input is always read into a fresh buffer. */ - while (1) + while (true) { n_read = safe_read (fd, tmp->buffer, BUFSIZ); if (n_read == 0 || n_read == SAFE_READ_ERROR) @@ -780,7 +780,7 @@ pipe_bytes (char const *pretty_filename, int fd, uintmax_t n_bytes, tmp = xmalloc (sizeof (CBUFFER)); /* Input is always read into a fresh buffer. */ - while (1) + while (true) { n_read = safe_read (fd, tmp->buffer, BUFSIZ); if (n_read == 0 || n_read == SAFE_READ_ERROR) @@ -900,7 +900,7 @@ start_lines (char const *pretty_filename, int fd, uintmax_t n_lines, if (n_lines == 0) return 0; - while (1) + while (true) { char buffer[BUFSIZ]; size_t bytes_read = safe_read (fd, buffer, BUFSIZ); @@ -1160,7 +1160,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval) last = n_files - 1; - while (1) + while (true) { size_t i; bool any_input = false; @@ -1617,7 +1617,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, ensure that watched files can be re-added when following by name. This loop blocks on the 'safe_read' call until a new event is notified. But when --pid=P is specified, tail usually waits via the select. */ - while (1) + while (true) { struct File_spec *fspec; struct inotify_event *ev; diff --git a/src/tsort.c b/src/tsort.c index 92bd1b2af..33b3419c0 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -452,7 +452,7 @@ tsort (char const *file) init_tokenbuffer (&tokenbuffer); - while (1) + while (true) { /* T2. Next Relation. */ size_t len = readtoken (stdin, DELIM, sizeof (DELIM) - 1, &tokenbuffer); -- 2.30.2