nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: rader
Subject: Re: [Nmh-workers] GNU readline whatnowproc (was tab completion)
Date: Mon, 20 Dec 2010 09:28:07 -0600

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]