nmh-workers
[Top] [All Lists]

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

2010-12-21 08:16:55

Enclosed please find a good patch for whatnowproc readine.


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

Yes, done.


I think you can drop all the signal handling here.

Yes, done.


+    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.

Sorry, my comment was still in "debug tracing" mode.  The problem isn't with
brkstring().  The problem is that readline() mallocs the char * it returns
and expects it to be free'ed.  I assume that not free'ing ans might lead to
a memory leak or something worse.

steve
--


Attachment: PATCH-readline
Description: Text document

_______________________________________________
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>