From 43ae44731bc0732c894ba6dc7de2d2881c5888e0 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Wed, 11 Nov 2015 07:31:00 +0100 Subject: [PATCH] Use continue instead of one long if for the whole loop body Plus remove unnecessary comments. This improves the signal-noise ratio. The identifiers are already telling us enough. --- uip/inc.c | 16 +++++++------- uip/scan.c | 68 ++++++++++++++++++++++++++++++------------------------------ 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/uip/inc.c b/uip/inc.c index 368bce3..f08fb4f 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -162,17 +162,16 @@ main(int argc, char **argv) adios(EX_OSERR, NULL, "atexit failed"); } -/* -** absolutely the first thing we do is save our privileges, -** and drop them if we can. -*/ + /* + ** absolutely the first thing we do is save our privileges, + ** and drop them if we can. + */ SAVEGROUPPRIVS(); TRYDROPGROUPPRIVS(); setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); - /* read user profile/context */ context_read(); arguments = getarguments(invo_name, argc, argv, 1); @@ -311,7 +310,6 @@ main(int argc, char **argv) if (chdir(maildir) == NOTOK) adios(EX_OSERR, maildir, "unable to change directory to"); - /* read folder and create message structure */ if (!(mp = folder_read(folder))) adios(EX_IOERR, NULL, "unable to read folder %s", folder); @@ -494,9 +492,9 @@ main(int argc, char **argv) fclose(in); in = NULL; } - seq_setunseen(mp, 1); /* add new msgs to unseen sequences */ - seq_save(mp); /* synchronize sequences */ - context_save(); /* save the context file */ + seq_setunseen(mp, 1); + seq_save(mp); + context_save(); return 0; } diff --git a/uip/scan.c b/uip/scan.c index 0f755ca..d6a4372 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -149,7 +149,6 @@ main(int argc, char **argv) if (chdir(maildir) == NOTOK) adios(EX_OSERR, maildir, "unable to change directory to"); - /* read folder and create message structure */ if (!(mp = folder_read(folder))) adios(EX_IOERR, NULL, "unable to read folder %s", folder); @@ -161,11 +160,11 @@ main(int argc, char **argv) for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert(mp, msgs.msgs[msgnum])) exit(EX_USAGE); - seq_setprev(mp); /* set the Previous-Sequence */ + seq_setprev(mp); - context_replace(curfolder, folder); /* update current folder */ - seq_save(mp); /* synchronize message sequences */ - context_save(); /* save the context file */ + context_replace(curfolder, folder); + seq_save(mp); + context_save(); /* ** Get the sequence number for each `unseen' sequence @@ -188,42 +187,43 @@ main(int argc, char **argv) } for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { - if (is_selected(mp, msgnum)) { - if ((in = fopen(cp = m_name(msgnum), "r")) == NULL) { - admonish(cp, "unable to open message"); - continue; - } + if (!is_selected(mp, msgnum)) { + continue; + } - /* - ** Check if message is in any sequence given - ** by Unseen-Sequence profile entry. - */ - unseen = 0; - for (i = 0; i < num_unseen_seq; i++) { - if (in_sequence(mp, seqnum[i], msgnum)) { - unseen = 1; - break; - } - } + if ((in = fopen(cp = m_name(msgnum), "r")) == NULL) { + admonish(cp, "unable to open message"); + continue; + } - switch (state = scan(in, msgnum, SCN_FOLD, fmtstr, - width, msgnum==mp->curmsg, unseen)) { - case SCNMSG: - case SCNERR: + /* + ** Check if message is in any sequence given + ** by Unseen-Sequence profile entry. + */ + unseen = 0; + for (i = 0; i < num_unseen_seq; i++) { + if (in_sequence(mp, seqnum[i], msgnum)) { + unseen = 1; break; + } + } - default: - adios(EX_SOFTWARE, NULL, "scan() botch(%d)", state); + switch (state = scan(in, msgnum, SCN_FOLD, fmtstr, + width, msgnum==mp->curmsg, unseen)) { + case SCNMSG: + case SCNERR: + break; - case SCNEOF: - advise(NULL, "message %d: empty", msgnum); - break; - } - fclose(in); + default: + adios(EX_SOFTWARE, NULL, "scan() botch(%d)", state); + + case SCNEOF: + advise(NULL, "message %d: empty", msgnum); + break; } + fclose(in); } - - folder_free(mp); /* free folder/message structure */ + folder_free(mp); return 0; } -- 1.7.10.4