Completely reworked the path convertion functions
[mmh] / uip / new.c
index cb2abc4..fc87b3a 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -57,11 +57,11 @@ count_messages(char *field)
        field = getcpy(field);
 
        /* copied from seq_read.c:seq_init */
-       for (ap = brkstring (field, " ", "\n"); *ap; ap++) {
+       for (ap = brkstring(field, " ", "\n"); *ap; ap++) {
                if ((cp = strchr(*ap, '-')))
                        *cp++ = '\0';
-               if ((j = m_atoi (*ap)) > 0) {
-                       k = cp ? m_atoi (cp) : j;
+               if ((j = m_atoi(*ap)) > 0) {
+                       k = cp ? m_atoi(cp) : j;
 
                        total += k - j + 1;
                }
@@ -94,7 +94,7 @@ seq_in_list(char *name, char *sequences[])
 static char *
 get_msgnums(char *folder, char *sequences[])
 {
-       char *seqfile = concat(m_maildir(folder), "/", mh_seq, (void *)NULL);
+       char *seqfile = concat(toabsdir(folder), "/", mh_seq, (void *)NULL);
        FILE *fp = fopen(seqfile, "r");
        int state;
        char name[NAMESZ], field[BUFSIZ];
@@ -108,18 +108,19 @@ get_msgnums(char *folder, char *sequences[])
 
        /* copied from seq_read.c:seq_public */
        for (state = FLD;;) {
-               switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+               switch (state = m_getfld(state, name, field, sizeof(field),
+                               fp)) {
                        case FLD:
                        case FLDPLUS:
                        case FLDEOF:
                                if (state == FLDPLUS) {
-                                       cp = getcpy (field);
+                                       cp = getcpy(field);
                                        while (state == FLDPLUS) {
-                                               state = m_getfld (state, name,
+                                               state = m_getfld(state, name,
                                                                field,
                                                                sizeof(field),
                                                                fp);
-                                               cp = add (field, cp);
+                                               cp = add(field, cp);
                                        }
 
                                        /*
@@ -139,7 +140,7 @@ get_msgnums(char *folder, char *sequences[])
                                                        free(this_msgnums);
                                                }
                                        }
-                                       free (cp);
+                                       free(cp);
                                } else {
                                        /* and here */
                                        if (seq_in_list(name, sequences)) {
@@ -161,14 +162,14 @@ get_msgnums(char *folder, char *sequences[])
 
                        case BODY:
                        case BODYEOF:
-                               adios (NULL, "no blank lines are permitted in %s", seqfile);
+                               adios(NULL, "no blank lines are permitted in %s", seqfile);
                                /* fall */
 
                        case FILEEOF:
                                break;
 
                        default:
-                               adios (NULL, "%s is poorly formatted", seqfile);
+                               adios(NULL, "%s is poorly formatted", seqfile);
                }
                break;  /* break from for loop */
        }
@@ -251,7 +252,7 @@ check_folders(struct node **first, struct node **last,
        b.sequences = sequences;
 
        if (folders == NULL) {
-               chdir(m_maildir(""));
+               chdir(toabsdir("+"));
                crawl_folders(".", crawl_callback, &b);
        } else {
                fp = fopen(folders, "r");
@@ -399,11 +400,10 @@ doit(char *cur, char *folders, char *sequences[])
                        count = count_messages(node->n_field);
                        total += count;
 
-                       printf("%-*s %6d.%c %s\n",
-                                  (int) folder_len, node->n_name,
-                                  count,
-                                  (strcmp(node->n_name, cur) == 0 ? '*' : ' '),
-                                  node->n_field);
+                       printf("%-*s %6d.%c %s\n", (int) folder_len,
+                               node->n_name, count,
+                               (strcmp(node->n_name, cur) == 0 ? '*' : ' '),
+                               node->n_field);
                }
        }
 
@@ -436,12 +436,12 @@ 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();
 
-       arguments = getarguments (invo_name, argc, argv, 1);
+       arguments = getarguments(invo_name, argc, argv, 1);
        argp = arguments;
 
        /*
@@ -449,22 +449,22 @@ main(int argc, char **argv)
        */
        while ((cp = *argp++)) {
                if (*cp == '-') {
-                       switch (smatch (++cp, switches)) {
+                       switch (smatch(++cp, switches)) {
                        case AMBIGSW:
-                               ambigsw (cp, switches);
-                               done (1);
+                               ambigsw(cp, switches);
+                               done(1);
                        case UNKWNSW:
-                               adios (NULL, "-%s unknown", cp);
+                               adios(NULL, "-%s unknown", cp);
 
                        case HELPSW:
-                               snprintf (help, sizeof(help),
+                               snprintf(help, sizeof(help),
                                                "%s [switches] [sequences]",
                                                invo_name);
-                               print_help (help, switches, 1);
-                               done (1);
+                               print_help(help, switches, 1);
+                               done(1);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done (1);
+                               done(1);
 
                        case FOLDERSSW:
                                if (!(folders = *argp++) || *folders == '-')
@@ -475,7 +475,7 @@ main(int argc, char **argv)
                                if (!(invo_name = *argp++) || *invo_name == '-')
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
-                               invo_name = r1bindex(invo_name, '/');
+                               invo_name = mhbasename(invo_name);
                                continue;
                        }
                }
@@ -497,7 +497,7 @@ main(int argc, char **argv)
                /* will flists */
        } else {
                if (folders[0] != '/') {
-                       folders = m_maildir(folders);
+                       folders = toabsdir(folders);
                }
        }
 
@@ -539,6 +539,6 @@ main(int argc, char **argv)
 
        context_save();
 
-       done (0);
+       done(0);
        return 1;
 }