X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fpick.c;h=040ebecdc2bd31c87dacb897989c0c861de6f65a;hp=95f99cdf804f6b927d11838a6c160579c3a8e446;hb=714b5c530ece27ea2835a313013f5b770163403c;hpb=ced6090a330d3d83d0bce709f756aa3d7d65fea4 diff --git a/uip/pick.c b/uip/pick.c index 95f99cd..040ebec 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -65,10 +65,10 @@ static struct swit switches[] = { static int listsw = -1; -static void putzero_done (int) NORETURN; +static void putzero_done(int) NORETURN; int -main (int argc, char **argv) +main(int argc, char **argv) { int publicsw = -1, zerosw = 1, seqp = 0, vecp = 0; int lo, hi, msgnum; @@ -84,12 +84,12 @@ main (int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex (argv[0], '/'); + invo_name = r1bindex(argv[0], '/'); /* read user profile/context */ context_read(); - arguments = getarguments (invo_name, argc, argv, 1); + arguments = getarguments(invo_name, argc, argv, 1); argp = arguments; while ((cp = *argp++)) { @@ -98,23 +98,23 @@ main (int argc, char **argv) vec[vecp++] = --cp; goto pattern; } - switch (smatch (cp, switches)) { + switch (smatch(cp, switches)) { case AMBIGSW: - ambigsw (cp, switches); + ambigsw(cp, switches); listsw = 0; /* HACK */ - done (1); + done(1); case UNKWNSW: - adios (NULL, "-%s unknown", cp); + adios(NULL, "-%s unknown", cp); case HELPSW: - snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); - print_help (buf, switches, 1); + snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); + print_help(buf, switches, 1); listsw = 0; /* HACK */ - done (1); + done(1); case VERSIONSW: print_version(invo_name); listsw = 0; /* HACK */ - done (1); + done(1); case CCSW: case DATESW: @@ -128,12 +128,12 @@ main (int argc, char **argv) vec[vecp++] = --cp; pattern: if (!(cp = *argp++)) /* allow -xyz arguments */ - adios (NULL, "missing argument to %s", + adios(NULL, "missing argument to %s", argp[-2]); vec[vecp++] = cp; continue; case OTHRSW: - adios (NULL, "internal error!"); + adios(NULL, "internal error!"); case ANDSW: case ORSW: @@ -145,15 +145,15 @@ main (int argc, char **argv) case SEQSW: if (!(cp = *argp++) || *cp == '-') - adios (NULL, "missing argument to %s", + adios(NULL, "missing argument to %s", argp[-2]); /* check if too many sequences specified */ if (seqp >= NUMATTRS) - adios (NULL, "too many sequences (more than %d) specified", NUMATTRS); + adios(NULL, "too many sequences (more than %d) specified", NUMATTRS); - if (!seq_nameok (cp)) - done (1); + if (!seq_nameok(cp)) + done(1); seqs[seqp++] = cp; continue; @@ -180,16 +180,16 @@ main (int argc, char **argv) } if (*cp == '+' || *cp == '@') { if (folder) - adios (NULL, "only one folder at a time!"); + adios(NULL, "only one folder at a time!"); else - folder = pluspath (cp); + folder = pluspath(cp); } else app_msgarg(&msgs, cp); } vec[vecp] = NULL; - if (!context_find ("path")) - free (path ("./", TFOLDER)); + if (!context_find("path")) + free(path("./", TFOLDER)); /* ** If we didn't specify which messages to search, @@ -199,25 +199,25 @@ main (int argc, char **argv) app_msgarg(&msgs, "all"); if (!folder) - folder = getfolder (1); - maildir = m_maildir (folder); + folder = getfolder(1); + maildir = m_maildir(folder); - if (chdir (maildir) == NOTOK) - adios (maildir, "unable to change directory to"); + if (chdir(maildir) == NOTOK) + adios(maildir, "unable to change directory to"); /* read folder and create message structure */ - if (!(mp = folder_read (folder))) - adios (NULL, "unable to read folder %s", folder); + if (!(mp = folder_read(folder))) + adios(NULL, "unable to read folder %s", folder); /* check for empty folder */ if (mp->nummsg == 0) - adios (NULL, "no messages in %s", folder); + adios(NULL, "no messages in %s", folder); /* parse all the message ranges/sequences and set SELECTED */ for (msgnum = 0; msgnum < msgs.size; msgnum++) - if (!m_convert (mp, msgs.msgs[msgnum])) - done (1); - seq_setprev (mp); /* set the previous-sequence */ + if (!m_convert(mp, msgs.msgs[msgnum])) + done(1); + seq_setprev(mp); /* set the previous-sequence */ /* ** If we aren't saving the results to a sequence, @@ -227,11 +227,11 @@ main (int argc, char **argv) listsw = !seqp; if (publicsw == 1 && is_readonly(mp)) - adios (NULL, "folder %s is read-only, so -public not allowed", + adios(NULL, "folder %s is read-only, so -public not allowed", folder); - if (!pcompile (vec, NULL)) - done (1); + if (!pcompile(vec, NULL)) + done(1); lo = mp->lowsel; hi = mp->hghsel; @@ -241,31 +241,31 @@ main (int argc, char **argv) ** force line buffering on. */ if (listsw) - setvbuf (stdout, NULL, _IOLBF, 0); + setvbuf(stdout, NULL, _IOLBF, 0); /* ** Scan through all the SELECTED messages and check for a ** match. If the message does not match, then unselect it. */ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { - if (is_selected (mp, msgnum)) { - if ((fp = fopen (cp = m_name (msgnum), "r")) == NULL) - admonish (cp, "unable to read message"); - if (fp && pmatches (fp, msgnum, 0L, 0L)) { + if (is_selected(mp, msgnum)) { + if ((fp = fopen(cp = m_name(msgnum), "r")) == NULL) + admonish(cp, "unable to read message"); + if (fp && pmatches(fp, msgnum, 0L, 0L)) { if (msgnum < lo) lo = msgnum; if (msgnum > hi) hi = msgnum; if (listsw) - printf ("%s\n", m_name (msgnum)); + printf("%s\n", m_name(msgnum)); } else { /* if it doesn't match, then unselect it */ - unset_selected (mp, msgnum); + unset_selected(mp, msgnum); mp->numsel--; } if (fp) - fclose (fp); + fclose(fp); } } @@ -273,7 +273,7 @@ main (int argc, char **argv) mp->hghsel = hi; if (mp->numsel <= 0) - adios (NULL, "no messages match specification"); + adios(NULL, "no messages match specification"); seqs[seqp] = NULL; @@ -281,29 +281,29 @@ main (int argc, char **argv) ** Add the matching messages to sequences */ for (seqp = 0; seqs[seqp]; seqp++) - if (!seq_addsel (mp, seqs[seqp], publicsw, zerosw)) - done (1); + if (!seq_addsel(mp, seqs[seqp], publicsw, zerosw)) + done(1); /* ** Print total matched if not printing each matched message number. */ if (!listsw) { - printf ("%d hit%s\n", mp->numsel, mp->numsel == 1 ? "" : "s"); + printf("%d hit%s\n", mp->numsel, mp->numsel == 1 ? "" : "s"); } - context_replace (pfolder, folder); /* update current folder */ - seq_save (mp); /* synchronize message sequences */ - context_save (); /* save the context file */ - folder_free (mp); /* free folder/message structure */ - done (0); + context_replace(pfolder, folder); /* update current folder */ + seq_save(mp); /* synchronize message sequences */ + context_save(); /* save the context file */ + folder_free(mp); /* free folder/message structure */ + done(0); return 1; } static void -putzero_done (int status) +putzero_done(int status) { - if (listsw && status && !isatty (fileno (stdout))) - printf ("0\n"); - exit (status); + if (listsw && status && !isatty(fileno(stdout))) + printf("0\n"); + exit(status); }