Karim Belabas on Sun, 05 Aug 2012 02:15:19 +0200

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

Re: Patch: default(sopath), default(outputsp[aces])

I finally found time to go back to this patch proposed by Gonzalo Tornaria
more than 8 years ago:


( Sorry it took so looong: so much to do, so little time :-( )

Some comments and implementation notes:

* Gonzalo Tornaria [2004-01-13 20:48]:
> This is a patch to add two new default's to gp:
> 1) default(outputsp):
> flag that determines if output routines show spaces. Pretty trivial,
> just adds a one-line function sd_outputsp() and adds it to
> gp_default_list[].

This one is not implemented as a defaut, but via the new function printsep(),
suggested by Don Zagier:

(01:14) gp > ??printsep

   Outputs  its   (string)   arguments  in  raw format,  ending with a newline.
Successive entries are separated by sep:

   ? printsep(":", 1,2,3,4)

This serves the same purpose as the proposed default, in a more flexible way.

> 2) default(sopath):
> similar to default(path), but for dynamic libraries loaded with
> install(). The bulk of it is a function sd_sopath() [almost copied from
> sd_path()], and gp_dlopen(), a wrapper for dlopen(). Note that if
> default(sopath) is not set, gp_dlopen() defaults to the old dlopen().


I simplifed a bit the logic by refactoring:

- sd_path / sd_sopath are now subsumed in a generic routine meant to
  handle an arbitrary gp_path structures [ path and sopath for now ].

- deciding whether we use the 'path' mechanism for a given file name is
  handled by path_is_absolute()

- trying out all possible paths is now done through a simple iterator,
  removing explicit allocation / concatenation from the involved routines
  ( gp_dlopen(), gp_LoadLibrary(), switchin() )

> Note also that I allow the special path ":" to stand for "" (meaning:
> revert back to the old behaviour), since there is no way to set a
> default to an empty value!!! (since the argument "" is used to retrieve
> the value of the default)

This is no longer true, we now use NULL instead of "". So no need
to make the value special.

> I've only done it for dlopen(), but a similar wrapper should work for
> win32 LoadLibrary().

I have implemented such a wrapper, but have no way to test it. (My last
Windows system died 2 or 3 years ago.) Hopefully it works...

> BTW, is it intentional that gp_expand_path() takes empty path components
> as if they where "/" ??? I think they should be ignored.
> ? default(path,"/usr::/bin")
>    path = "/usr::/bin"
> ? read("proc")
>   ***   Warning: skipping directory /proc.
>   ***   error opening input file: proc

It was not intentional, and it is gone now.


Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]