nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] GNU readline whatnowproc (was tab completion)

2010-12-19 11:40:32
rader(_at_)hep(_dot_)wisc(_dot_)edu wrote:
Okay then, "made it work for me" patch enclosed.  I'm outa time
for now.  I'll contribute one that uses an autoconf probe soon--I'm
assuming even troglodytes won't vote for a ./configure flag.
 
+#include <readline/readline.h>
+#include <readline/history.h>

NB that the GNU readline library is GPL, not LGPL. That means
that any binary linked against it is distributable only under
GPL rules. (That's possible because nmh's license is 3-clause
BSD, which is compatible.) 

If we care about that there are some BSD-ish licensed equivalents
available, google tells me.

@@ -54,6 +57,7 @@
          continue;
      }
      cpp = brkstring (ansbuf, " ", NULL);
+printf("brkstring said \"%s\"\n", *cpp);

...we can lose the debug tracing :-)

@@ -69,6 +73,39 @@
}


+char **
+getans_via_readline (char *prompt, struct swit *ansp)
+{
+    SIGNAL_HANDLER istat = NULL;

I think you can drop all the signal handling here.

+    char *ans, **cpp;
+
+    for (;;) {
+        ans = readline (prompt);
+        if (ans[0] == '?' || ans[0] == 0 ) {
+            printf ("Options are:\n");
+            print_sw (ALL, ansp, "");
+            free(ans);
+          continue;
+        }
+      strcpy (ansbuf,ans); /* not sure why--but it makes brkstring() work */
+        cpp = brkstring (ansbuf, " ", NULL);

...so what happens if you don't strcpy but just pass ans to
brkstring()? I can't see anything in brkstring() that cares,
and it would be nice to avoid the fixed ansbuf[] buffer.

-- PMM

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
http://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>