From eed5352e46df93f8921d2e6dfdc95b027bad6e1e Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 29 Oct 2006 22:46:37 +0100 Subject: [PATCH] FOREVER is of very bad taste, use for (;;) --- browser.c | 2 +- color.c | 2 +- curs_lib.c | 4 ++-- curs_main.c | 2 +- flags.c | 2 +- keymap.c | 4 ++-- lib.c | 2 +- lib.h | 2 -- mbox.c | 2 +- menu.c | 2 +- mh.c | 8 ++++---- nntp/nntp.c | 4 ++-- parse.c | 2 +- pgpkey.c | 2 +- pop/pop.c | 6 +++--- pop/pop_auth.c | 6 +++--- pop/pop_lib.c | 4 ++-- recvattach.c | 2 +- smime.c | 2 +- thread.c | 12 ++++++------ 20 files changed, 35 insertions(+), 37 deletions(-) diff --git a/browser.c b/browser.c index 3477f9a..12506b3 100644 --- a/browser.c +++ b/browser.c @@ -851,7 +851,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_menu (&state, menu, title, sizeof (title), buffy); - FOREVER { + for (;;) { switch (i = mutt_menuLoop (menu)) { case OP_GENERIC_SELECT_ENTRY: diff --git a/color.c b/color.c index dd29b7f..d3b4be5 100644 --- a/color.c +++ b/color.c @@ -214,7 +214,7 @@ int mutt_alloc_color (int fg, int bg) /* find the smallest available index (object) */ i = 1; - FOREVER { + for (;;) { p = ColorList; while (p) { if (p->index == i) diff --git a/curs_lib.c b/curs_lib.c index 4203b0e..002c063 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -209,7 +209,7 @@ int mutt_yesorno (const char *msg, int def) printw ("%.*s%s", COLS - answer_string_len, msg, answer_string); p_delete(&answer_string); - FOREVER { + for (;;) { mutt_refresh (); ch = mutt_getch (); if (CI_is_return (ch.ch)) @@ -530,7 +530,7 @@ int mutt_multi_choice (char *prompt, char *letters) mvaddstr (LINES - 1, 0, prompt); clrtoeol (); - FOREVER { + for (;;) { mutt_refresh (); ch = mutt_getch (); if (ch.ch == -1 || CI_is_return (ch.ch)) { diff --git a/curs_main.c b/curs_main.c index fe65287..03315f2 100644 --- a/curs_main.c +++ b/curs_main.c @@ -445,7 +445,7 @@ int mutt_index_menu (void) sidebar_set_current (Context->path); } - FOREVER { + for (;;) { tag = 0; /* clear the tag-prefix */ menu->max = Context ? Context->vcount : 0; diff --git a/flags.c b/flags.c index 37dca38..6bbe781 100644 --- a/flags.c +++ b/flags.c @@ -307,7 +307,7 @@ int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread) if ((cur = cur->child) == NULL) return (0); - FOREVER { + for (;;) { if (cur->message) mutt_set_flag (Context, cur->message, flag, bf); diff --git a/keymap.c b/keymap.c index 76ac63c..29e0dcd 100644 --- a/keymap.c +++ b/keymap.c @@ -359,7 +359,7 @@ int km_dokey (int menu) if (!map) return (retry_generic (menu, NULL, 0, 0)); - FOREVER { + for (;;) { /* ncurses doesn't return on resized screen when timeout is set to zero */ if (menu != MENU_EDITOR) timeout ((Timeout > 0 ? Timeout : 60) * 1000); @@ -491,7 +491,7 @@ int km_expand_key (char *s, size_t len, struct keymap_t *map) if (!map) return (0); - FOREVER { + for (;;) { strfcpy (s, km_keyname (map->keys[p]), len); len -= (l = m_strlen(s)); diff --git a/lib.c b/lib.c index 3212015..974f5ba 100644 --- a/lib.c +++ b/lib.c @@ -402,7 +402,7 @@ char *mutt_read_line(char *s, size_t * size, FILE * fp, int *line) *size = STRING; } - FOREVER { + for (;;) { if (fgets (s + offset, *size - offset, fp) == NULL) { p_delete(&s); return NULL; diff --git a/lib.h b/lib.h index 01ca97b..3ff4a38 100644 --- a/lib.h +++ b/lib.h @@ -37,8 +37,6 @@ # define MAX(a,b) ((a) < (b) ? (b) : (a)) # define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define FOREVER while (1) - void mutt_exit (int); /* Exit values used in send_msg() */ diff --git a/mbox.c b/mbox.c index 3b9fba0..d7d37e8 100644 --- a/mbox.c +++ b/mbox.c @@ -124,7 +124,7 @@ static int mmdf_parse_mailbox (CONTEXT * ctx) buf[sizeof (buf) - 1] = 0; - FOREVER { + for (;;) { if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL) break; diff --git a/menu.c b/menu.c index 52547de..1c4e7b9 100644 --- a/menu.c +++ b/menu.c @@ -800,7 +800,7 @@ int mutt_menuLoop (MUTTMENU * menu) { int i = OP_NULL; - FOREVER { + for (;;) { if (option (OPTMENUCALLER)) { unset_option (OPTMENUCALLER); return OP_NULL; diff --git a/mh.c b/mh.c index 8f40b39..5a84bec 100644 --- a/mh.c +++ b/mh.c @@ -200,7 +200,7 @@ static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) int fd; char path[_POSIX_PATH_MAX]; - FOREVER { + for (;;) { snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d", dest->path, NONULL (Hostname), (int) getpid (), Counter++); umask (Umask); @@ -1047,7 +1047,7 @@ static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr else strfcpy (subdir, "new", sizeof (subdir)); - FOREVER { + for (;;) { snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%u_%d.%s%s", dest->path, subdir, (long) time (NULL), (unsigned int) getpid (), Counter++, NONULL (Hostname), suffix); @@ -1123,7 +1123,7 @@ static int maildir_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr) suffix[0] = '\0'; /* construct a new file name. */ - FOREVER { + for (;;) { snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%u_%d.%s%s", subdir, (long) time (NULL), (unsigned int) getpid (), Counter++, NONULL (Hostname), suffix); @@ -1213,7 +1213,7 @@ static int _mh_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr, * slot. */ - FOREVER { + for (;;) { hi++; snprintf (tmp, sizeof (tmp), "%d", hi); snprintf (path, sizeof (path), "%s/%s", ctx->path, tmp); diff --git a/nntp/nntp.c b/nntp/nntp.c index b70c115..46a53eb 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -261,7 +261,7 @@ static int nntp_reconnect (NNTP_SERVER * serv) mutt_socket_close (serv->conn); - FOREVER { + for (;;) { if (nntp_connect_and_auth (serv) == 0) return 0; @@ -349,7 +349,7 @@ static int mutt_nntp_fetch (NNTP_DATA * nntp_data, const char *query, char *msg, line = 0; inbuf = p_new(char, sizeof(buf)); - FOREVER { + for (;;) { chunk = mutt_socket_readln_d (buf, sizeof (buf), nntp_data->nserv->conn, M_SOCK_LOG_HDR); if (chunk < 0) diff --git a/parse.c b/parse.c index 5457e65..9ff0deb 100644 --- a/parse.c +++ b/parse.c @@ -45,7 +45,7 @@ char *mutt_read_rfc822_line (FILE * f, char *line, size_t * linelen) char ch; size_t offset = 0; - FOREVER { + for (;;) { if (fgets (buf, *linelen - offset, f) == NULL || /* end of file or */ (ISSPACE (*line) && !offset)) { /* end of headers */ *line = 0; diff --git a/pgpkey.c b/pgpkey.c index a0aed72..05ca27a 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -653,7 +653,7 @@ pgp_key_t pgp_ask_for_key (char *tag, char *whatfor, } - FOREVER { + for (;;) { resp[0] = 0; if (mutt_get_field (tag, resp, sizeof (resp), M_CLEAR) != 0) return NULL; diff --git a/pop/pop.c b/pop/pop.c index 89e4dd8..2abedd7 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -259,7 +259,7 @@ int pop_open_mailbox (CONTEXT * ctx) conn->data = pop_data; - FOREVER { + for (;;) { if (pop_reconnect (ctx) != PQ_OK) return -1; @@ -354,7 +354,7 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) } } - FOREVER { + for (;;) { if (pop_reconnect (ctx) != PQ_OK) return -1; @@ -440,7 +440,7 @@ pop_query_status pop_sync_mailbox (CONTEXT * ctx, int unused, int *index_hint) pop_data->check_time = 0; - FOREVER { + for (;;) { if (pop_reconnect (ctx) != PQ_OK) return PQ_NOT_CONNECTED; diff --git a/pop/pop_auth.c b/pop/pop_auth.c index 9dd2625..5dc846d 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -56,7 +56,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) if (!method) method = pop_data->auth_list; - FOREVER { + for (;;) { #ifdef USE_SASL rc = sasl_client_start (saslconn, method, &interaction, &pc, &olen, &mech); @@ -81,7 +81,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) olen = strlen (buf); /* looping protocol */ - FOREVER { + for (;;) { strfcpy (buf + olen, "\r\n", sizeof (buf) - olen); mutt_socket_write (pop_data->conn, buf); if (mutt_socket_readln (inbuf, sizeof (inbuf), pop_data->conn) < 0) { @@ -104,7 +104,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) } if (!client_start) - FOREVER { + for (;;) { rc = sasl_client_step (saslconn, buf, len, &interaction, &pc, &olen); if (rc != SASL_INTERACT) break; diff --git a/pop/pop_lib.c b/pop/pop_lib.c index 89ffb87..285ed44 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -445,7 +445,7 @@ pop_query_status pop_fetch_data (POP_DATA * pop_data, const char *query, progres inbuf = p_new(char, sizeof(buf)); - FOREVER { + for (;;) { chunk = mutt_socket_readln_d (buf, sizeof (buf), pop_data->conn, M_SOCK_LOG_HDR); @@ -513,7 +513,7 @@ pop_query_status pop_reconnect (CONTEXT * ctx) if (pop_data->status == POP_BYE) return PQ_NOT_CONNECTED; - FOREVER { + for (;;) { mutt_socket_close (pop_data->conn); ret = pop_open_connection (pop_data); diff --git a/recvattach.c b/recvattach.c index e123884..d1c7117 100644 --- a/recvattach.c +++ b/recvattach.c @@ -994,7 +994,7 @@ void mutt_view_attachments (HEADER * hdr) attach_collapse (cur, 0, 1, 0); mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu); - FOREVER { + for (;;) { if (op == OP_NULL) op = mutt_menuLoop (menu); switch (op) { diff --git a/smime.c b/smime.c index be9b6b4..eb68c18 100644 --- a/smime.c +++ b/smime.c @@ -375,7 +375,7 @@ char *smime_ask_for_key (char *prompt, char *mailbox, short public) } fclose (index); - FOREVER { + for (;;) { *qry = 0; if (mutt_get_field (prompt, qry, sizeof (qry), 0)) return NULL; diff --git a/thread.c b/thread.c index 1bf0b5f..ae5ebbe 100644 --- a/thread.c +++ b/thread.c @@ -124,7 +124,7 @@ static void calculate_visibility (CONTEXT * ctx, int *max_depth) tree = tree->next; *max_depth = 0; - FOREVER { + for (;;) { if (depth > *max_depth) *max_depth = depth; @@ -180,7 +180,7 @@ static void calculate_visibility (CONTEXT * ctx, int *max_depth) /* now fix up for the OPTHIDETOP* options if necessary */ if (hide_top_limited || hide_top_missing) { tree = ctx->tree; - FOREVER { + for (;;) { if (!tree->visible && tree->deep && tree->subtree_visible < 2 && ((tree->message && hide_top_limited) || (!tree->message && hide_top_missing))) @@ -324,7 +324,7 @@ static LIST *make_subject_list (THREAD * cur, time_t * dateptr) LIST *curlist, *oldlist, *newlist, *subjects = NULL; int rc = 0; - FOREVER { + for (;;) { while (!cur->message) cur = cur->child; @@ -463,7 +463,7 @@ static void pseudo_threads (CONTEXT * ctx) insert_message (&parent->child, parent, cur); parent->sort_children = 1; tmp = cur; - FOREVER { + for (;;) { while (!tmp->message) tmp = tmp->child; @@ -899,7 +899,7 @@ static HEADER *find_virtual (THREAD * cur, int reverse) while (reverse && cur->next) cur = cur->next; - FOREVER { + for (;;) { if (cur->message && cur->message->virtual >= 0) return (cur->message); @@ -1081,7 +1081,7 @@ int _mutt_traverse_thread (CONTEXT * ctx, HEADER * cur, int flag) return (min_unread); } - FOREVER { + for (;;) { cur = thread->message; if (cur) { -- 2.20.1