]> diplodocus.org Git - nmh/commitdiff
Rename and document functions that read from stdin.
authorEric Gillespie <epg@pretzelnet.org>
Sun, 3 Apr 2016 08:23:11 +0000 (08:23 +0000)
committerEric Gillespie <epg@pretzelnet.org>
Sun, 3 Apr 2016 08:23:11 +0000 (08:23 +0000)
- gans becomes read_switch
- getans becomes read_switch_multiword
- getans_via_readline becomes read_switch_multiword_via_readline
- getanswer becomes read_yes_or_no_if_tty
- install-mh.c geta becomes read_line

30 files changed:
Makefile.am
h/prototypes.h
sbr/ambigsw.c
sbr/context_read.c
sbr/error.c
sbr/gans.c
sbr/getans.c
sbr/getansreadline.c
sbr/getanswer.c
sbr/makedir.c
sbr/print_sw.c
sbr/read_line.c [new file with mode: 0644]
sbr/smatch.c
sbr/ssequal.c
sbr/utils.c
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/whatnowsbr.c

index ec523ec468055b7d4c4851bbab6c64c7bfb97f91..413a6e298a048fa55d97fad7f5bcf4ed0f2a68a2 100644 (file)
@@ -582,7 +582,7 @@ sbr_libmh_a_SOURCES = sbr/addrsbr.c sbr/ambigsw.c sbr/atooi.c sbr/arglist.c \
                      sbr/folder_read.c sbr/folder_realloc.c sbr/gans.c \
                      sbr/getans.c sbr/getanswer.c sbr/getarguments.c \
                      sbr/getcpy.c sbr/geteditor.c sbr/getfolder.c \
                      sbr/folder_read.c sbr/folder_realloc.c sbr/gans.c \
                      sbr/getans.c sbr/getanswer.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 \
                      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 \
index 3399384ea8a6671d6746e0de0be6f910ee21f10c..441863ac25663195f672b649f599c82d08370cf6 100644 (file)
@@ -20,13 +20,13 @@ struct msgs_array;
 void add_profile_entry (const char *, const char *);
 void adios (char *, char *, ...) NORETURN;
 void admonish (char *, char *, ...);
 void add_profile_entry (const char *, const char *);
 void adios (char *, char *, ...) NORETURN;
 void admonish (char *, char *, ...);
-void advertise (char *, char *, char *, va_list);
-void advise (char *, char *, ...);
+void advertise (const char *, char *, char *, va_list);
+void advise (const char *, char *, ...);
 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 **);
 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 *);
 
 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);
 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
 #ifdef READLINE_SUPPORT
-char **getans_via_readline (char *, struct swit *);
+char **read_switch_multiword_via_readline (char *, struct swit *);
 #endif /* READLINE_SUPPORT */
 #endif /* READLINE_SUPPORT */
-int getanswer (char *);
+
 char **getarguments (char *, int, char **, int);
 
 /*
 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 *);
 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);
 
 /*
 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);
 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);
 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 *);
 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.
 
 /*
  * 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);
  * 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 *);
 int stringdex (char *, char *);
 char *trimcpy (char *);
 int unputenv (char *);
index c11b9e752e732d5fdeef899884897ce85cc38e34..15ff34cbf828989ca9c2d614187c356bdaa53ff8 100644 (file)
@@ -11,7 +11,7 @@
 
 
 void
 
 
 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);
 {
     advise (NULL, "-%s ambiguous.  It matches", arg);
     print_sw (arg, swp, "-", stderr);
index 803406881024fc8dfe8883911e50ae8d88f8931a..de14b0d560920aec7b7fb7231b394536b5d24d71 100644 (file)
@@ -107,7 +107,7 @@ context_read (void)
 
        cp = concat ("Your MH-directory \"", nd, "\" doesn't exist; Create it? ", NULL);
 
 
        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);
            adios (NULL, "unable to access MH-directory \"%s\"", nd);
 
        free (cp);
index 0b6d77774589def21f2552cae634e014b0873ae7..6fb0d5cc8677e9081450cfbd46b9536f77c698d1 100644 (file)
@@ -17,7 +17,7 @@
  * print out error message
  */
 void
  * print out error message
  */
 void
-advise (char *what, char *fmt, ...)
+advise (const char *what, char *fmt, ...)
 {
     va_list ap;
 
 {
     va_list ap;
 
@@ -60,7 +60,7 @@ admonish (char *what, char *fmt, ...)
  * main routine for printing error messages.
  */
 void
  * main routine for printing error messages.
  */
 void
-advertise (char *what, char *tail, char *fmt, va_list ap)
+advertise (const char *what, char *tail, char *fmt, va_list ap)
 {
     int        eindex = errno;
     char buffer[BUFSIZ], err[BUFSIZ];
 {
     int        eindex = errno;
     char buffer[BUFSIZ], err[BUFSIZ];
@@ -85,7 +85,7 @@ advertise (char *what, char *tail, char *fmt, va_list ap)
        if (*what) {
            iov->iov_len = strlen (iov->iov_base = " ");
            iov++;
        if (*what) {
            iov->iov_len = strlen (iov->iov_base = " ");
            iov++;
-           iov->iov_len = strlen (iov->iov_base = what);
+           iov->iov_len = strlen (iov->iov_base = (void*)what);
            iov++;
            iov->iov_len = strlen (iov->iov_base = ": ");
            iov++;
            iov++;
            iov->iov_len = strlen (iov->iov_base = ": ");
            iov++;
index 70234029ed9720754da058ef20f894ef04438dda..f5ad194a892933fb0e6c1d683546479f670605f5 100644 (file)
 
 
 int
 
 
 int
-gans (char *prompt, struct swit *ansp)
+read_switch (const char *prompt, const struct swit *ansp)
 {
     register int i;
     register char *cp;
 {
     register int i;
     register char *cp;
-    register struct swit *ap;
+    const register struct swit *ap;
     char ansbuf[BUFSIZ];
 
     for (;;) {
     char ansbuf[BUFSIZ];
 
     for (;;) {
index 0800a3c0fea5e9ce0eeb9d5632182466e2d5cc9c..d388e2b98f4beac48944765daaf9187361398c36 100644 (file)
@@ -21,7 +21,7 @@ static void intrser (int);
 
 
 char **
 
 
 char **
-getans (char *prompt, struct swit *ansp)
+read_switch_multiword (const char *prompt, const struct swit *ansp)
 {
     int i;
     SIGNAL_HANDLER istat = NULL;
 {
     int i;
     SIGNAL_HANDLER istat = NULL;
index 5d80dd9716d86a3f221e16fd27f8ae2f8cc834e4..bc2b5636cdc19f762702aed5a2e6990bdb63c1e5 100644 (file)
@@ -26,7 +26,7 @@ static char ansbuf[BUFSIZ];
  */
 
 char **
  */
 
 char **
-getans_via_readline(char *prompt, struct swit *ansp)
+read_switch_multiword_via_readline(char *prompt, struct swit *ansp)
 {
     char *ans, **cpp;
 
 {
     char *ans, **cpp;
 
index 73922158d8ef4c218d2067ea6afa14aed19911cb..490d833eaa13f0f5add7f24b8f453bb5e10ad024 100644 (file)
 
 
 int
 
 
 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;
 
 {
     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 562949bebafb249f83d80545a8d9547475db2594..6d3f0dc315525c111a44c6f69b6f589c729b4ae5 100644 (file)
@@ -15,7 +15,7 @@
 #include <sys/file.h>
 
 int
 #include <sys/file.h>
 
 int
-makedir (char *dir)
+makedir (const char *dir)
 {
     char            path[PATH_MAX];
     char*           folder_perms_ASCII;
 {
     char            path[PATH_MAX];
     char*           folder_perms_ASCII;
index 6d475aba175eedd361ae4871cdee3d608c7667bc..d790db69d60604d3876ddd3b05cdf14f7aa5edd7 100644 (file)
@@ -11,7 +11,7 @@
 
 
 void
 
 
 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;
 {
     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;
+}
+
index 4d1d3d6814b7f977897a2dbd22819de3ee220788..8ec6e3f2b3aae99b6a565d6f46a0ecf8cda162dc 100644 (file)
 
 
 int
 
 
 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;
     int firstone, len;
-    struct swit *tp;
+    const struct swit *tp;
 
     firstone = UNKWNSW;
 
 
     firstone = UNKWNSW;
 
index 5ccf28fd134a59f7ac3252dd358c4b2ea265ea5b..cb7652030dd9c5f8ad8311092e209f8818233e7e 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 int
  */
 
 int
-ssequal (char *s1, char *s2)
+ssequal (const char *s1, const char *s2)
 {
     if (!s1)
        s1 = "";
 {
     if (!s1)
        s1 = "";
index c6f75e07379e3c47878359c7eb88c6a4485a945f..6ab5f53461608e5a17759f26de79e1b180d492cc 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 (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) {
                 done_callback (1);
             free (cp);
         } else if (autocreate == -1) {
index 13d73c1bc27c2b201f83e2188c5cd0045004f467..a11f1b7da665f3883324d75d46fe44624dae699f 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;) {
            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: 
                done (1);
            switch (i = smatch (*argp, isdf ? aqrunl : aqrul)) {
                case NOSW: 
index 5a35e59a7385b052b918a9f3b47b81f2ac308114..09c501a8b7e6a0b3920ada06fd6e5f6a9d349c3f 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 (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: 
                done (1);
            switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
                case NOSW: 
index 12a323bb874cfe2746ffa161846e64871f3a1dd5..c4e1dde5271af314cea033b287a2c85f7a091a33 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 (!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: 
                done (1);
            switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
                case NOSW: 
index 7d128420ae6e2e7a3c7f2f7fd78187ae8bbce16b..41e785ff3a80f94c439fff881e1b3fe6d3dbae0a 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -584,7 +584,7 @@ go_to_it:
                if (errno != ENOENT)
                    adios (packfile, "error on file");
                cp = concat ("Create file \"", packfile, "\"? ", NULL);
                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);
            }
                    done (1);
                free (cp);
            }
index ce8e2940c112e94dfc35fc29d1348617944cb8cb..627c48e2d603eaa5207e6e9820252f01e8f5603a 100644 (file)
@@ -24,17 +24,13 @@ DEFINE_SWITCH_ENUM(INSTALLMH);
 DEFINE_SWITCH_ARRAY(INSTALLMH, switches);
 #undef X
 
 DEFINE_SWITCH_ARRAY(INSTALLMH, switches);
 #undef X
 
-/*
- * static prototypes
- */
-static char *geta(void);
-
 
 int
 main (int argc, char **argv)
 {
     int autof = 0;
 
 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;
     char *dp, **arguments, **argp;
     struct node *np;
     struct passwd *pw;
@@ -122,7 +118,7 @@ main (int argc, char **argv)
        done(1);
     }
 
        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"
        (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 (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;
                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);
        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:
            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);
                        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?  /");
            } 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 (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 {
            if (makedir (pathname) == 0)
                adios (NULL, "unable to create %s", pathname);
     } else {
@@ -223,18 +222,3 @@ query:
     done (0);
     return 1;
 }
     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 ae563c2fdf1118db5e38fe8abecf8297fdf99ecc..7afbadd5bc48d7b709b660f007a0a4841cdfeeaf 100644 (file)
@@ -258,7 +258,7 @@ got_it:
        snprintf (bp, buflen, "\n    in file %s? ", buffer);
 
        /* Now, check answer */
        snprintf (bp, buflen, "\n    in file %s? ", buffer);
 
        /* Now, check answer */
-       if (!getanswer (query))
+       if (!read_yes_or_no_if_tty (query))
            status = NOTOK;
     }
 
            status = NOTOK;
     }
 
index 8b1f0d00536ae0f5128c118629c7600281ca938b..2d6ec569c2383ee0a80edb260e4d6d7ae85b06b9 100644 (file)
@@ -146,7 +146,7 @@ losing_directory:
            }
 
            ep = concat ("Create directory \"", file, "\"? ", NULL);
            }
 
            ep = concat ("Create directory \"", file, "\"? ", NULL);
-           answer = getanswer (ep);
+           answer = read_yes_or_no_if_tty (ep);
            free (ep);
 
            if (!answer)
            free (ep);
 
            if (!answer)
index 1193d5648cc75216b1e42a5be0a4b5755922dde9..ca5558ae486551dee77e7576d94bea77e41136be 100644 (file)
@@ -2583,7 +2583,7 @@ openFTP (CT ct, char **file)
     /*
      * Now, check the answer
      */
     /*
      * Now, check the answer
      */
-    if (!getanswer (buffer))
+    if (!read_yes_or_no_if_tty (buffer))
        return NOTOK;
 
     if (e->eb_flags) {
        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 */
                    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;
        return NOTOK;
 
     vecp = 0;
index 62b2f4afa72cac556bbf3b89a7db9b4bba85480c..62a5ba43b19fa43e7125a0254545ad0b4d1f9ef2 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);
           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. */
             free (prompt);
           } else {
             /* Overwrite, that's what nmh used to do.  And warn. */
index 30f0f484059cd234f81e8e8129f9a9805040d836..d8e037db3d17bfecb862dd9e087f0d378363c526 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 (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);
     }
            done (1);
        free (cp);
     }
index ebe72ff2bbd1cb2d3f8e8c1b4d4a05c7ff55d03a..5686b5bf5e6c8ec0e43caed6043aed82f6cc2dc1 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 (!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: 
                done (1);
            switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
                case NOSW: 
index c4ca0c4b2f86d23b3ad3b9ae1040a8db4c2065d7..6380884c50262233d9e4dffaa4d82f1531fdc93c 100644 (file)
@@ -402,7 +402,7 @@ insert (struct mailname *np)
 
     if (querysw) {
        snprintf (buffer, sizeof(buffer), "Reply to %s? ", adrformat (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;
        return 0;
     }
     mp->m_next = np;
index c7e6426c130b46d0dd7e9f016702e7b4f4d8d34f..f714c472bcbb40b5fbfa9b3ff78f0c0545d24a0b 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 (interactive) {
        cp = concat ("Remove folder \"", folder, "\"? ", NULL);
-       if (!getanswer (cp))
+       if (!read_yes_or_no_if_tty (cp))
            done (0);
        free (cp);
     }
            done (0);
        free (cp);
     }
index 26ef89a8b4d18997da75416e1cb01f59f78a6722..f4c4910673a9552c941504a60839ded959b3a5ba 100644 (file)
@@ -301,7 +301,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;) {
                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: 
                    done (1);
                switch (status = smatch (*argp, anyl)) {
                    case NOSW: 
index d8862dc9fc2250b1baf5f92ff545501a3a478b57..62320f9447214e82ae15c129ba3deb9b97bcdb4f 100644 (file)
@@ -233,9 +233,9 @@ WhatNow (int argc, char **argv)
     snprintf (prompt, sizeof(prompt), myprompt, invo_name);
     for (;;) {
 #ifdef READLINE_SUPPORT
     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 */
 #else /* ! READLINE_SUPPORT */
-       if (!(argp = getans (prompt, aleqs))) {
+       if (!(argp = read_switch_multiword (prompt, aleqs))) {
 #endif /* READLINE_SUPPORT */
            (void) m_unlink (LINK);
            done (1);
 #endif /* READLINE_SUPPORT */
            (void) m_unlink (LINK);
            done (1);