Move #include from h/mh.h to source files
[mmh] / uip / new.c
index a43a710..e95ee6a 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
 ** Inspired by Luke Mewburn's new: http://www.mewburn.net/luke/src/new
 */
 
+#include <h/mh.h>
+#include <h/crawl_folders.h>
+#include <h/utils.h>
 #include <sys/types.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#include <h/mh.h>
-#include <h/crawl_folders.h>
-#include <h/utils.h>
+#include <unistd.h>
+#include <locale.h>
 
 static struct swit switches[] = {
 #define MODESW 0
@@ -314,7 +314,7 @@ doit(char *cur, char *folders, char *sequences[])
        char *sequences_s = NULL;
        int argc = 0;
        char *argv[MAXARGS];
-       char *cp;
+       char **seqp;
        char buf[BUFSIZ];
 
        if (cur == NULL || cur[0] == '\0') {
@@ -391,8 +391,8 @@ doit(char *cur, char *folders, char *sequences[])
                        argv[argc++] = "scan";
                        snprintf(buf, sizeof buf, "+%s", node->n_name);
                        argv[argc++] = buf;
-                       for (cp=*sequences; *cp; cp++) {
-                               argv[argc++] = cp;
+                       for (seqp=sequences; *seqp; seqp++) {
+                               argv[argc++] = *seqp;
                        }
                        argv[argc] = (char *)NULL;
                        execprog(*argv, argv);
@@ -457,7 +457,7 @@ main(int argc, char **argv)
                        switch (smatch(++cp, switches)) {
                        case AMBIGSW:
                                ambigsw(cp, switches);
-                               done(1);
+                               exit(1);
                        case UNKWNSW:
                                adios(NULL, "-%s unknown", cp);
 
@@ -466,10 +466,10 @@ main(int argc, char **argv)
                                                "%s [switches] [sequences]",
                                                invo_name);
                                print_help(help, switches, 1);
-                               done(1);
+                               exit(0);
                        case VERSIONSW:
                                print_version(invo_name);
-                               done(1);
+                               exit(0);
 
                        case FOLDERSSW:
                                if (!(folders = *argp++) || *folders == '-')
@@ -526,7 +526,7 @@ main(int argc, char **argv)
 
        folder = doit(context_find(curfolder), folders, sequences);
        if (folder == NULL) {
-               done(0);
+               exit(0);
                return 1;
        }
 
@@ -550,6 +550,5 @@ main(int argc, char **argv)
 
        context_save();
 
-       done(0);
-       return 1;
+       return 0;
 }