bug-m4
[Top][All Lists]
Advanced

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

Re: ltdl misuse? (Gary... :-)


From: Gary V . Vaughan
Subject: Re: ltdl misuse? (Gary... :-)
Date: Sun, 12 Aug 2001 15:07:34 +0100

On Sunday 12 August 2001 11:52 am, address@hidden wrote:
> Hi!
>
> I believe -M is dead broken.

Indeed :-(

>  I don't know ltdl too well (i.e., not at
> all), but according to the weird behavior of multi -M, and according
> to fprintf, I think this code is broken:
>
>       case 'M':
>       {
>         const char *search_path = lt_dlgetsearchpath ();
>         if (lt_dlsetsearchpath (optarg) != 0)
>         {
>           const char *dlerr = lt_dlerror();
>           if (dlerr == NULL)
>             M4ERROR ((EXIT_FAILURE, 0,
>                       _("ERROR: failed to add search directory `%s'"),
>                       optarg));
>           else
>             M4ERROR ((EXIT_FAILURE, 0,
>                       _("ERROR: failed to add search directory `%s': %s"),
>                       optarg, dlerr));
>         }
>         if (search_path)
>           lt_dladdsearchdir (search_path);
>       }
>       break;
>
> My guess is that lt_dlgetsearchpath returns a privately allocated
> string which has no reason to be kept alive accross lt_dlsetsearchpath
> calls.  Therefore, the last lt_dladdsearchdir part has no reason to
> do what was expected.  In particular, unless there is reallocation,
> in most cases it just means setting the path to twice optarg.

As I recall, the ltdl implementation was pretty manky when I wrote this.  But 
you're right that even with a broken ltdl search path handling, this code is 
still bad.

> I suppose the goal is to preprend optarg instead of appending it.  But
> then, either we need to strdup somewhere, or ltdl should provide means
> to do that cleanly.

Yes.  And Yes.  The current ideom is:

        foo = lt_dlgetsearchpath ();
        bar = (char *) xmalloc (1+ xstrlen (newdir) + 1 + xstrlen (foo)); 
        sprintf (bar, "%s:%s", newdir, foo);
        if (lt_dlsetsearchpath (bar) != 0)
          complain (lt_dlerror ());

Or thereabouts.  But since I recently converted all of the path handling in 
libltdl to use argz, adding an insert function to libltdl will be cinch.  
I'll do that later today -- I am decorating at the moment (and being glared 
at by the wife for checking email :-P), and have TKD at 7pm.

Cheers,
        Gary.
-- 
  ())_. Gary V. Vaughan     gary@(oranda.demon.co.uk|gnu.org)
  ( '/  Research Scientist  http://www.oranda.demon.co.uk       ,_())____
  / )=  GNU Hacker          http://www.gnu.org/software/libtool  \'      `&
`(_~)_  Tech' Author        http://sources.redhat.com/autobook   =`---d__/



reply via email to

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