Relayouted all switch statements: case aligns with switch.
[mmh] / uip / anno.c
index a2cfc84..5de385f 100644 (file)
@@ -99,7 +99,7 @@ main(int argc, char **argv)
 #ifdef LOCALE
        setlocale(LC_ALL, "");
 #endif
-       invo_name = r1bindex(argv[0], '/');
+       invo_name = mhbasename(argv[0]);
 
        /* read user profile/context */
        context_read();
@@ -110,95 +110,98 @@ main(int argc, char **argv)
        while ((cp = *argp++)) {
                if (*cp == '-') {
                        switch (smatch(++cp, switches)) {
-                               case AMBIGSW:
-                                       ambigsw(cp, switches);
-                                       done(1);
-                               case UNKWNSW:
-                                       adios(NULL, "-%s unknown", cp);
-
-                               case HELPSW:
-                                       snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
-                                               invo_name);
-                                       print_help(buf, switches, 1);
-                                       done(1);
-                               case VERSIONSW:
-                                       print_version(invo_name);
-                                       done(1);
-
-                               case COMPSW:
-                                       if (comp)
-                                               adios(NULL, "only one component at a time!");
-                                       if (!(comp = *argp++) || *comp == '-')
+                       case AMBIGSW:
+                               ambigsw(cp, switches);
+                               done(1);
+                       case UNKWNSW:
+                               adios(NULL, "-%s unknown", cp);
+
+                       case HELPSW:
+                               snprintf(buf, sizeof(buf),
+                                       "%s [+folder] [msgs] [switches]",
+                                       invo_name);
+                               print_help(buf, switches, 1);
+                               done(1);
+                       case VERSIONSW:
+                               print_version(invo_name);
+                               done(1);
+
+                       case COMPSW:
+                               if (comp)
+                                       adios(NULL, "only one component at a time!");
+                               if (!(comp = *argp++) || *comp == '-')
+                                       adios(NULL, "missing argument to %s",
+                                                       argp[-2]);
+                               continue;
+
+                       case DATESW:
+                               datesw++;
+                               continue;
+                       case NDATESW:
+                               datesw = 0;
+                               continue;
+
+                       case INPLSW:
+                               inplace++;
+                               continue;
+                       case NINPLSW:
+                               inplace = 0;
+                               continue;
+
+                       case TEXTSW:
+                               if (text)
+                                       adios(NULL, "only one body at a time!");
+                               if (!(text = *argp++) || *text == '-')
+                                       adios(NULL, "missing argument to %s",
+                                                       argp[-2]);
+                               continue;
+
+                       case DELETESW:  /* delete annotations */
+                               delete = 0;
+                               continue;
+
+                       case LISTSW:  /* produce a listing */
+                               list = 1;
+                               continue;
+
+                       case NUMBERSW: /* number listing or delete by number */
+                               if (number != 0)
+                                       adios(NULL, "only one number at a time!");
+
+                               if (argp-arguments == argc-1 || **argp == '-')
+                                       number = 1;
+
+                               else {
+                                               if (strcmp(*argp, "all") == 0)
+                                                       number = -1;
+
+                                               else if (!(number = atoi(*argp)))
                                                adios(NULL, "missing argument to %s", argp[-2]);
-                                       continue;
-
-                               case DATESW:
-                                       datesw++;
-                                       continue;
-                               case NDATESW:
-                                       datesw = 0;
-                                       continue;
-
-                               case INPLSW:
-                                       inplace++;
-                                       continue;
-                               case NINPLSW:
-                                       inplace = 0;
-                                       continue;
-
-                               case TEXTSW:
-                                       if (text)
-                                               adios(NULL, "only one body at a time!");
-                                       if (!(text = *argp++) || *text == '-')
-                                               adios(NULL, "missing argument to %s", argp[-2]);
-                                       continue;
-
-                               case DELETESW:  /* delete annotations */
-                                       delete = 0;
-                                       continue;
-
-                               case LISTSW:  /* produce a listing */
-                                       list = 1;
-                                       continue;
-
-                               case NUMBERSW:  /* number listing or delete by number */
-                                       if (number != 0)
-                                               adios(NULL, "only one number at a time!");
-
-                                       if (argp - arguments == argc - 1 || **argp == '-')
-                                               number = 1;
-
-                                       else {
-                                                       if (strcmp(*argp, "all") == 0)
-                                                               number = -1;
-
-                                                       else if (!(number = atoi(*argp)))
-                                                       adios(NULL, "missing argument to %s", argp[-2]);
 
-                                               argp++;
-                                       }
+                                       argp++;
+                               }
 
-                                       delete = number;
-                                       continue;
+                               delete = number;
+                               continue;
 
-                               case APPENDSW:  /* append annotations instead of default prepend */
-                                       append = 1;
-                                       continue;
+                       case APPENDSW:  /* append annotations instead of default prepend */
+                               append = 1;
+                               continue;
 
-                               case PRESERVESW:  /* preserve access and modification times on annotated message */
-                                       annopreserve(1);
-                                       continue;
+                       case PRESERVESW:  /* preserve access and modification times on annotated message */
+                               annopreserve(1);
+                               continue;
 
-                               case NOPRESERVESW:  /* don't preserve access and modification times on annotated message (default) */
-                                       annopreserve(0);
-                                       continue;
+                       case NOPRESERVESW:  /* don't preserve access and modification times on annotated message (default) */
+                               annopreserve(0);
+                               continue;
                        }
                }
                if (*cp == '+' || *cp == '@') {
                        if (folder)
                                adios(NULL, "only one folder at a time!");
                        else
-                               folder = pluspath(cp);
+                               folder = getcpy(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -208,13 +211,11 @@ main(int argc, char **argv)
                datesw = 0;
 #endif /* UCI */
 
-       if (!context_find("path"))
-               free(path("./", TFOLDER));
        if (!msgs.size)
                app_msgarg(&msgs, "cur");
        if (!folder)
-               folder = getfolder(1);
-       maildir = m_maildir(folder);
+               folder = getcurfol();
+       maildir = toabsdir(folder);
 
        if (chdir(maildir) == NOTOK)
                adios(maildir, "unable to change directory to");
@@ -244,7 +245,7 @@ main(int argc, char **argv)
                }
        }
 
-       context_replace(pfolder, folder);  /* update current folder  */
+       context_replace(curfolder, folder);  /* update current folder  */
        seq_setcur(mp, mp->lowsel);  /* update current message */
        seq_save(mp);  /* synchronize message sequences */
        folder_free(mp);  /* free folder/message structure */