]> diplodocus.org Git - nmh/commitdiff
Merge remote-tracking branch 'origin' into xoauth
authorDavid Levine <david.levine@gonift.com>
Sun, 26 Jun 2016 01:16:36 +0000 (21:16 -0400)
committerDavid Levine <david.levine@gonift.com>
Sun, 26 Jun 2016 01:16:36 +0000 (21:16 -0400)
32 files changed:
Makefile.am
h/prototypes.h
man/slocal.man
sbr/ambigsw.c
sbr/context_read.c
sbr/makedir.c
sbr/print_sw.c
sbr/read_line.c [new file with mode: 0644]
sbr/read_switch.c [moved from sbr/gans.c with 84% similarity]
sbr/read_switch_multiword.c [moved from sbr/getans.c with 92% similarity]
sbr/read_switch_multiword_via_readline.c [moved from sbr/getansreadline.c with 93% similarity]
sbr/read_yes_or_no_if_tty.c [moved from sbr/getanswer.c with 65% similarity]
sbr/smatch.c
sbr/ssequal.c
sbr/utils.c
test/slocal/test-slocal
uip/comp.c
uip/dist.c
uip/forw.c
uip/inc.c
uip/install-mh.c
uip/mhcachesbr.c
uip/mhmisc.c
uip/mhparse.c
uip/mhstoresbr.c
uip/packf.c
uip/repl.c
uip/replsbr.c
uip/rmf.c
uip/send.c
uip/slocal.c
uip/whatnowsbr.c

index 2ec9d5c..de88060 100644 (file)
@@ -490,6 +490,10 @@ uip_viamail_LDADD = $(LDADD) $(POSTLINK)
 test_getfullname_SOURCES = test/getfullname.c
 test_getfullname_LDADD = $(LDADD) $(POSTLINK)
 
+##
+## Other program definitions
+##
+
 test_getcanon_SOURCES = test/getcanon.c
 test_getcanon_LDADD = $(POSTLINK)
 
@@ -517,6 +521,7 @@ docs_contrib_sendfrom_LDADD = $(LDADD) $(TERMLIB) $(CURLLIB) $(POSTLINK)
 
 ## Hard-code the config/version.c target, instead of using $@, so this
 ## rule works for the distcheck target with Solaris (System V) make.
+
 ## distcheck uses VPATH, causes that make to prepend the VPATH to $@.
 config/version.c: Makefile $(srcdir)/config/version.sh
        env srcdir="$(srcdir)" sh $(srcdir)/config/version.sh $(VERSION) > ./config/version.c
@@ -601,10 +606,11 @@ sbr_libmh_a_SOURCES = sbr/addrsbr.c sbr/ambigsw.c sbr/atooi.c sbr/arglist.c \
                      sbr/error.c sbr/ext_hook.c sbr/fdcompare.c \
                      sbr/folder_addmsg.c sbr/folder_delmsgs.c \
                      sbr/folder_free.c sbr/folder_pack.c \
-                     sbr/folder_read.c sbr/folder_realloc.c sbr/gans.c \
-                     sbr/getans.c sbr/getanswer.c sbr/getarguments.c \
+                     sbr/folder_read.c sbr/folder_realloc.c sbr/read_switch.c \
+                     sbr/read_switch_multiword.c sbr/read_switch_multiword_via_readline.c \
+                     sbr/read_yes_or_no_if_tty.c sbr/getarguments.c \
                      sbr/getcpy.c sbr/geteditor.c sbr/getfolder.c \
-                     sbr/getpass.c \
+                     sbr/getpass.c sbr/read_line.c \
                      sbr/fmt_addr.c sbr/fmt_compile.c sbr/fmt_new.c \
                      sbr/fmt_rfc2047.c sbr/fmt_scan.c \
                      sbr/icalparse.y sbr/icalendar.l sbr/datetime.c \
@@ -628,8 +634,8 @@ sbr_libmh_a_SOURCES = sbr/addrsbr.c sbr/ambigsw.c sbr/atooi.c sbr/arglist.c \
                      sbr/trimcpy.c sbr/unquote.c \
                      sbr/uprf.c sbr/vfgets.c \
                      sbr/mf.c sbr/utils.c sbr/ctype-checked.c \
-                     sbr/m_mktemp.c sbr/getansreadline.c sbr/vector.c \
-                     config/config.c config/version.c sbr/oauth.c \
+                     sbr/m_mktemp.c sbr/vector.c sbr/oauth.c \
+                     config/config.c config/version.c \
                      thirdparty/jsmn/jsmn.c
 
 ##
index fc96909..782939b 100644 (file)
@@ -26,7 +26,7 @@ char **argsplit (char *, char **, int *);
 void argsplit_msgarg (struct msgs_array *, char *, char **);
 void argsplit_insert (struct msgs_array *, char *, char **);
 void arglist_free (char *, char **);
-void ambigsw (char *, struct swit *);
+void ambigsw (const char *, const struct swit *);
 int atooi(char *);
 char **brkstring (char *, char *, char *);
 
@@ -118,12 +118,44 @@ int folder_pack (struct msgs **, int);
 struct msgs *folder_read (char *name, int lockflag);
 
 struct msgs *folder_realloc (struct msgs *, int, int);
-int gans (char *, struct swit *);
-char **getans (char *, struct swit *);
+
+/*
+ * Flush standard output, read a line from standard input into a static buffer,
+ * zero out the newline, and return a pointer to the buffer.
+ * On error, return NULL.
+ */
+const char *read_line(void);
+
+/*
+ * Print null-terminated PROMPT to and flush standard output.  Read answers from
+ * standard input until one matches an entry in SWITCHES.  When one matches,
+ * return its swret field.  Return 0 on EOF.
+ */
+int read_switch(const char *PROMPT, const struct swit *SWITCHES);
+
+/*
+ * If standard input is not a tty, return 1 without printing anything.  Else,
+ * print null-terminated PROMPT to and flush standard output.  Read answers from
+ * standard input until one is "yes" or "no", returning 1 for "yes" and 0 for
+ * "no".  Also return 0 on EOF.
+ */
+int read_yes_or_no_if_tty(const char *PROMPT);
+
+/*
+ * Print null-terminated PROMPT to and flush standard output.  Read multi-word
+ * answers from standard input until a first word matches an entry in SWITCHES.
+ * When one matches, return a pointer to an array of pointers to the words.
+ * Return NULL on EOF, interrupt, or other error.
+ */
+char **read_switch_multiword(const char *PROMPT, const struct swit *SWITCHES);
+
+/*
+ * Same as read_switch_multiword but using readline(3) for input.
+ */
 #ifdef READLINE_SUPPORT
-char **getans_via_readline (char *, struct swit *);
+char **read_switch_multiword_via_readline (char *, struct swit *);
 #endif /* READLINE_SUPPORT */
-int getanswer (char *);
+
 char **getarguments (char *, int, char **, int);
 
 /*
@@ -247,7 +279,7 @@ void m_popen(char *name, int savestdout);
 void m_pclose(void);
 
 void m_unknown(m_getfld_state_t *, FILE *);
-int makedir (char *);
+int makedir (const char *);
 char *message_id (time_t, int);
 
 /*
@@ -282,7 +314,7 @@ int pidwait (pid_t, int);
 int pidstatus (int, FILE *, char *);
 char *pluspath(char *);
 void print_help (char *, struct swit *, int);
-void print_sw (char *, struct swit *, char *, FILE *);
+void print_sw (const char *, const struct swit *, char *, FILE *);
 void print_version (char *);
 void push (void);
 char *pwd (void);
@@ -328,7 +360,7 @@ void seq_setcur (struct msgs *, int);
 void seq_setprev (struct msgs *);
 void seq_setunseen (struct msgs *, int);
 int showfile (char **, char *);
-int smatch(char *, struct swit *);
+int smatch(const char *, const struct swit *);
 
 /*
  * Convert a set of bit flags to printable format.
@@ -363,7 +395,7 @@ int smatch(char *, struct swit *);
  * from least significant bit to most significant.
  */
 char *snprintb (char *buffer, size_t size, unsigned flags, char *bitfield);
-int ssequal (char *, char *);
+int ssequal (const char *, const char *);
 int stringdex (char *, char *);
 char *trimcpy (char *);
 int unputenv (char *);
index 53f9314..6c8e490 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLOCAL %manext1% "November 23, 2012" "%nmhversion%"
+.TH SLOCAL %manext1% "May 2, 2016" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
@@ -76,7 +76,7 @@ The
 switch tells
 .B slocal
 the name of the user for
-whom it is delivering mail.  The
+whom it is delivering mail.  It must exist on the local system.  The
 .B \-mailbox
 switch tells
 .B slocal
@@ -383,8 +383,14 @@ quicker delivery into your maildrop.
 .RB ` \-maildelivery "' defaults to $HOME/\&.maildelivery"
 .RB ` \-mailbox "' deaults to %mailspool%/$USER"
 .RB ` \-file "' defaults to stdin"
+.RB ` \-addr "' defaults to the current user"
 .RB ` \-user "' defaults to the current user"
 .fi
+.PP
+.B \-addr
+and
+.B \-user
+will be set the the user part of the Local-Mailbox profile entry, if set.
 .SH CONTEXT
 None
 .SH HISTORY
index c11b9e7..15ff34c 100644 (file)
@@ -11,7 +11,7 @@
 
 
 void
-ambigsw (char *arg, struct swit *swp)
+ambigsw (const char *arg, const struct swit *swp)
 {
     advise (NULL, "-%s ambiguous.  It matches", arg);
     print_sw (arg, swp, "-", stderr);
index 8034068..de14b0d 100644 (file)
@@ -107,7 +107,7 @@ context_read (void)
 
        cp = concat ("Your MH-directory \"", nd, "\" doesn't exist; Create it? ", NULL);
 
-       if (!getanswer(cp))
+       if (!read_yes_or_no_if_tty(cp))
            adios (NULL, "unable to access MH-directory \"%s\"", nd);
 
        free (cp);
index 562949b..6d3f0dc 100644 (file)
@@ -15,7 +15,7 @@
 #include <sys/file.h>
 
 int
-makedir (char *dir)
+makedir (const char *dir)
 {
     char            path[PATH_MAX];
     char*           folder_perms_ASCII;
index 6d475ab..d790db6 100644 (file)
@@ -11,7 +11,7 @@
 
 
 void
-print_sw (char *substr, struct swit *swp, char *prefix, FILE *fp)
+print_sw (const char *substr, const struct swit *swp, char *prefix, FILE *fp)
 {
     int len, optno;
     register int i;
diff --git a/sbr/read_line.c b/sbr/read_line.c
new file mode 100644 (file)
index 0000000..35d71a7
--- /dev/null
@@ -0,0 +1,16 @@
+#include <h/mh.h>
+
+const char *
+read_line(void)
+{
+    char *cp;
+    static char line[BUFSIZ];
+
+    fflush(stdout);
+    if (fgets(line, sizeof(line), stdin) == NULL)
+            return NULL;
+    if ((cp = strchr(line, '\n')))
+       *cp = 0;
+    return line;
+}
+
similarity index 84%
rename from sbr/gans.c
rename to sbr/read_switch.c
index 7023402..4599a41 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * gans.c -- get an answer from the user
+ * read_switch.c -- prompt the user for an answer from the list
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
 
 
 int
-gans (char *prompt, struct swit *ansp)
+read_switch (const char *prompt, const struct swit *ansp)
 {
     register int i;
     register char *cp;
-    register struct swit *ap;
+    register const struct swit *ap;
     char ansbuf[BUFSIZ];
 
     for (;;) {
similarity index 92%
rename from sbr/getans.c
rename to sbr/read_switch_multiword.c
index 0800a3c..f653a7f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * getans.c -- get an answer from the user and return a string array
+ * read_switch_multiword.c -- get an answer from the user and return a string array
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -21,7 +21,7 @@ static void intrser (int);
 
 
 char **
-getans (char *prompt, struct swit *ansp)
+read_switch_multiword (const char *prompt, const struct swit *ansp)
 {
     int i;
     SIGNAL_HANDLER istat = NULL;
similarity index 93%
rename from sbr/getansreadline.c
rename to sbr/read_switch_multiword_via_readline.c
index 5d80dd9..570469b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * getansreadline.c -- get an answer from the user, with readline
+ * read_switch_multiword_via_readline.c -- get an answer from the user, with readline
  *
  * This code is Copyright (c) 2012, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -26,7 +26,7 @@ static char ansbuf[BUFSIZ];
  */
 
 char **
-getans_via_readline(char *prompt, struct swit *ansp)
+read_switch_multiword_via_readline(char *prompt, struct swit *ansp)
 {
     char *ans, **cpp;
 
similarity index 65%
rename from sbr/getanswer.c
rename to sbr/read_yes_or_no_if_tty.c
index 7392215..07f1122 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * getanswer.c -- get a yes/no answer from the user
+ * read_yes_or_no_if_tty.c -- get a yes/no answer from the user
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
 
 
 int
-getanswer (char *prompt)
+read_yes_or_no_if_tty (const char *prompt)
 {
     static int interactive = -1;
 
     if (interactive < 0)
        interactive = isatty (fileno (stdin)) ? 1 : 0;
 
-    return (interactive ? gans (prompt, anoyes) : 1);
+    return (interactive ? read_switch (prompt, anoyes) : 1);
 }
index 4d1d3d6..8ec6e3f 100644 (file)
 
 
 int
-smatch(char *string, struct swit *swp)
+smatch(const char *string, const struct swit *swp)
 {
-    char *sp, *tcp;
+    const char *sp, *tcp;
     int firstone, len;
-    struct swit *tp;
+    const struct swit *tp;
 
     firstone = UNKWNSW;
 
index 5ccf28f..cb76520 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 int
-ssequal (char *s1, char *s2)
+ssequal (const char *s1, const char *s2)
 {
     if (!s1)
        s1 = "";
index c6f75e0..6ab5f53 100644 (file)
@@ -200,7 +200,7 @@ void create_folder(char *folder, int autocreate, void (*done_callback)(int))
         if (autocreate == 0) {
             /* ask before creating folder */
             cp = concat ("Create folder \"", folder, "\"? ", NULL);
-            if (!getanswer (cp))
+            if (!read_yes_or_no_if_tty (cp))
                 done_callback (1);
             free (cp);
         } else if (autocreate == -1) {
index 08eb1a8..3fb73b2 100755 (executable)
@@ -143,19 +143,23 @@ run_prog $slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/5
 check "$MH_TEST_DIR/Mail/inbox/5" "$actual" 'keep first'
 check "$MH_TEST_DIR/Mail/inbox/5" "$actual2" 'keep first'
 
-# Use current login for address, user, etc., because it must be an
-# existing user on the host.
-me=`"$MH_LIBEXEC_DIR"/ap -format '%(me)' 0`
-
 # check -addr
 cat >"$md"  <<EOF
-addr "$me" qpipe A "$tee $actual"
+addr someaddress qpipe A "$tee $actual"
 EOF
 
-run_prog $slocal -addr "$me" -maildelivery "$md" $mbox \
+run_prog $slocal -addr someaddress -maildelivery "$md" $mbox \
   <"$MH_TEST_DIR"/Mail/inbox/6
 check "$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
 
+# check -addr with . in address
+cat >"$md"  <<EOF
+addr "first.last" qpipe A "$tee $actual"
+EOF
+run_prog $slocal -addr 'first.last' \
+  -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/6
+check "$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
+
 # check -info
 cat >"$md"  <<EOF
 * - qpipe A "\$(info) $actual"
@@ -167,10 +171,10 @@ check "$MH_TEST_DIR/Mail/inbox/7" "$actual" 'keep first'
 
 # check -sender, which is compared with "source"
 cat >"$md"  <<EOF
-source "$me" qpipe A "$tee $actual"
+source somesender qpipe A "$tee $actual"
 EOF
 
-run_prog $slocal -sender "$me" -maildelivery "$md" $mbox \
+run_prog $slocal -sender somesender -maildelivery "$md" $mbox \
   <"$MH_TEST_DIR"/Mail/inbox/8
 check "$MH_TEST_DIR/Mail/inbox/8" "$actual" 'keep first'
 
@@ -179,10 +183,16 @@ cat >"$md"  <<EOF
 * - qpipe A "$tee $actual"
 EOF
 
+# Use current login for user because it must be an existing user on the host.
+me=`"$MH_LIBEXEC_DIR"/ap -format '%(me)' 0`
 run_prog $slocal -user "$me" -maildelivery "$md" $mbox \
   <"$MH_TEST_DIR"/Mail/inbox/9
 check "$MH_TEST_DIR/Mail/inbox/9" "$actual" 'keep first'
 
+# Can't check -user with . in address because the user must
+# have an account on the local system, and we can't guarantee
+# that there is one.
+
 # check -mailbox
 cat >"$md"  <<EOF
 EOF
@@ -221,5 +231,4 @@ run_prog $slocal -suppress -nosuppressdup -maildelivery "$md" $mbox \
   <"$MH_TEST_DIR"/Mail/inbox/2
 check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
 
-
 exit ${failed:-0}
index 13d73c1..a11f1b7 100644 (file)
@@ -337,7 +337,8 @@ try_it_again:
            adios (drft, "unable to stat");
        printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
        for (i = LISTDSW; i != YESW;) {
-           if (!(argp = getans ("\nDisposition? ", isdf ? aqrunl : aqrul)))
+           if (!(argp = read_switch_multiword ("\nDisposition? ",
+                                               isdf ? aqrunl : aqrul)))
                done (1);
            switch (i = smatch (*argp, isdf ? aqrunl : aqrul)) {
                case NOSW: 
index 5a35e59..09c501a 100644 (file)
@@ -232,7 +232,8 @@ try_it_again:
     if (stat (drft, &st) != NOTOK) {
        printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
        for (i = LISTDSW; i != YESW;) {
-           if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl)))
+           if (!(argp = read_switch_multiword ("\nDisposition? ",
+                                               isdf ? aqrnl : aqrl)))
                done (1);
            switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
                case NOSW: 
index 12a323b..c4e1dde 100644 (file)
@@ -313,7 +313,8 @@ try_it_again:
     if (!buildsw && stat (drft, &st) != NOTOK) {
        printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
        for (i = LISTDSW; i != YESW;) {
-           if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl)))
+           if (!(argp = read_switch_multiword ("\nDisposition? ",
+                                               isdf ? aqrnl : aqrl)))
                done (1);
            switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
                case NOSW: 
index f1bafd9..7891453 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -605,7 +605,7 @@ go_to_it:
                if (errno != ENOENT)
                    adios (packfile, "error on file");
                cp = concat ("Create file \"", packfile, "\"? ", NULL);
-               if (noisy && !getanswer (cp))
+               if (noisy && !read_yes_or_no_if_tty (cp))
                    done (1);
                free (cp);
            }
index ce8e294..627c48e 100644 (file)
@@ -24,17 +24,13 @@ DEFINE_SWITCH_ENUM(INSTALLMH);
 DEFINE_SWITCH_ARRAY(INSTALLMH, switches);
 #undef X
 
-/*
- * static prototypes
- */
-static char *geta(void);
-
 
 int
 main (int argc, char **argv)
 {
     int autof = 0;
-    char *cp, *pathname, buf[BUFSIZ];
+    char *cp, buf[BUFSIZ];
+    const char *pathname;
     char *dp, **arguments, **argp;
     struct node *np;
     struct passwd *pw;
@@ -122,7 +118,7 @@ main (int argc, char **argv)
        done(1);
     }
 
-    if (!autof && gans ("Do you want help? ", anoyes)) {
+    if (!autof && read_switch ("Do you want help? ", anoyes)) {
        (void)printf(
         "\n"
         "Prior to using nmh, it is necessary to have a file in your login\n"
@@ -138,7 +134,7 @@ main (int argc, char **argv)
        if (S_ISDIR(st.st_mode)) {
            cp = concat ("You already have the standard nmh directory \"",
                    cp, "\".\nDo you want to use it for nmh? ", NULL);
-           if (gans (cp, anoyes))
+           if (read_switch (cp, anoyes))
                pathname = "Mail";
            else
                goto query;
@@ -151,17 +147,20 @@ main (int argc, char **argv)
        else
            cp = concat ("Do you want the standard nmh path \"",
                    mypath, "/", "Mail\"? ", NULL);
-       if (autof || gans (cp, anoyes))
+       if (autof || read_switch (cp, anoyes))
            pathname = "Mail";
        else {
 query:
-           if (gans ("Do you want a path below your login directory? ",
+           if (read_switch ("Do you want a path below your login directory? ",
                        anoyes)) {
                printf ("What is the path?  %s/", mypath);
-               pathname = geta ();
+               pathname = read_line ();
+               if (pathname == NULL) done (1);
            } else {
                printf ("What is the whole path?  /");
-               pathname = concat ("/", geta (), NULL);
+               pathname = read_line ();
+               if (pathname == NULL) done (1);
+               pathname = concat ("/", pathname, NULL);
            }
        }
     }
@@ -171,7 +170,7 @@ query:
     }
     if (chdir (pathname) == NOTOK) {
        cp = concat ("\"", pathname, "\" doesn't exist; Create it? ", NULL);
-       if (autof || gans (cp, anoyes))
+       if (autof || read_switch (cp, anoyes))
            if (makedir (pathname) == 0)
                adios (NULL, "unable to create %s", pathname);
     } else {
@@ -223,18 +222,3 @@ query:
     done (0);
     return 1;
 }
-
-
-static char *
-geta (void)
-{
-    char *cp;
-    static char line[BUFSIZ];
-
-    fflush(stdout);
-    if (fgets(line, sizeof(line), stdin) == NULL)
-       done (1);
-    if ((cp = strchr(line, '\n')))
-       *cp = 0;
-    return line;
-}
index ae563c2..7afbadd 100644 (file)
@@ -258,7 +258,7 @@ got_it:
        snprintf (bp, buflen, "\n    in file %s? ", buffer);
 
        /* Now, check answer */
-       if (!getanswer (query))
+       if (!read_yes_or_no_if_tty (query))
            status = NOTOK;
     }
 
index 8b1f0d0..2d6ec56 100644 (file)
@@ -146,7 +146,7 @@ losing_directory:
            }
 
            ep = concat ("Create directory \"", file, "\"? ", NULL);
-           answer = getanswer (ep);
+           answer = read_yes_or_no_if_tty (ep);
            free (ep);
 
            if (!answer)
index 1193d56..ca5558a 100644 (file)
@@ -2583,7 +2583,7 @@ openFTP (CT ct, char **file)
     /*
      * Now, check the answer
      */
-    if (!getanswer (buffer))
+    if (!read_yes_or_no_if_tty (buffer))
        return NOTOK;
 
     if (e->eb_flags) {
@@ -2770,7 +2770,7 @@ openMail (CT ct, char **file)
                    e->eb_subject ? e->eb_subject : e->eb_body);
 
     /* Now, check answer */
-    if (!getanswer (buffer))
+    if (!read_yes_or_no_if_tty (buffer))
        return NOTOK;
 
     vecp = 0;
index 62b2f4a..62a5ba4 100644 (file)
@@ -1285,7 +1285,7 @@ clobber_check (char *original_file, mhstoreinfo_t info) {
           if (isatty (fileno (stdin))) {
             char *prompt =
               concat ("Overwrite \"", file, "\" [y/n/rename]? ", NULL);
-            ans = getans (prompt, answer);
+            ans = read_switch_multiword (prompt, answer);
             free (prompt);
           } else {
             /* Overwrite, that's what nmh used to do.  And warn. */
index 30f0f48..d8e037d 100644 (file)
@@ -111,7 +111,7 @@ main (int argc, char **argv)
        if (errno != ENOENT)
            adios (file, "error on file");
        cp = concat ("Create file \"", file, "\"? ", NULL);
-       if (!getanswer (cp))
+       if (!read_yes_or_no_if_tty (cp))
            done (1);
        free (cp);
     }
index ebe72ff..5686b5b 100644 (file)
@@ -370,7 +370,8 @@ try_it_again:
     if (!buildsw && stat (drft, &st) != NOTOK) {
        printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
        for (i = LISTDSW; i != YESW;) {
-           if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl)))
+           if (!(argp = read_switch_multiword ("\nDisposition? ",
+                                               isdf ? aqrnl : aqrl)))
                done (1);
            switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
                case NOSW: 
index c4ca0c4..6380884 100644 (file)
@@ -402,7 +402,7 @@ insert (struct mailname *np)
 
     if (querysw) {
        snprintf (buffer, sizeof(buffer), "Reply to %s? ", adrformat (np));
-       if (!gans (buffer, anoyes))
+       if (!read_switch (buffer, anoyes))
        return 0;
     }
     mp->m_next = np;
index c7e6426..f714c47 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -103,7 +103,7 @@ main (int argc, char **argv)
 
     if (interactive) {
        cp = concat ("Remove folder \"", folder, "\"? ", NULL);
-       if (!getanswer (cp))
+       if (!read_yes_or_no_if_tty (cp))
            done (0);
        free (cp);
     }
index a623964..03a5469 100644 (file)
@@ -333,7 +333,7 @@ main (int argc, char **argv)
                adios (msgs[0], "unable to stat draft file");
            cp = concat ("Use \"", msgs[0], "\"? ", NULL);
            for (status = LISTDSW; status != YESW;) {
-               if (!(argp = getans (cp, anyl)))
+               if (!(argp = read_switch_multiword (cp, anyl)))
                    done (1);
                switch (status = smatch (*argp, anyl)) {
                    case NOSW: 
index a26432c..927e858 100644 (file)
@@ -273,8 +273,9 @@ main (int argc, char **argv)
 
     if (addr == NULL)
        addr = getusername ();
-    if (user == NULL)
-       user = (cp = strchr(addr, '.')) ? ++cp : addr;
+    if (user == NULL) {
+       user = getusername ();
+    }
     if ((pw = getpwnam (user)) == NULL)
        adios (NULL, "no such local user as %s", user);
 
index 2198879..d0423f5 100644 (file)
@@ -237,9 +237,9 @@ WhatNow (int argc, char **argv)
     snprintf (prompt, sizeof(prompt), myprompt, invo_name);
     for (;;) {
 #ifdef READLINE_SUPPORT
-       if (!(argp = getans_via_readline (prompt, aleqs))) {
+       if (!(argp = read_switch_multiword_via_readline (prompt, aleqs))) {
 #else /* ! READLINE_SUPPORT */
-       if (!(argp = getans (prompt, aleqs))) {
+       if (!(argp = read_switch_multiword (prompt, aleqs))) {
 #endif /* READLINE_SUPPORT */
            (void) m_unlink (LINK);
            done (1);