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

Re: [MacPerl-Porters] [PATCH cfgperl 6212] MacOS regression suitemods




On Sun, 11 Jun 2000, Prymmer/Kahn wrote:

> However, it gets considerably more tortuous when one considers a 
> seemingly innocent open statement such as:
> 
>     open(HANDLE, "foo/bar/buz.dat");
> 
> note that it is under the 31 char limit, but that if  "foo/bar/buz.dat"
> does not exist in the current working directory where do we start?  Because 

Apologies for the slightly bad example.  I meant open() for reading,
or perhaps do or require or use or stat - basically any file spec op that 
needs to have a file in place.

Expanding slightly on what I wrote consider the slightly more general
case of switching s/:/\// and what it entails (aside from the matter
of re-writing File::Spec::Mac.pm in C).  For $n "/" characters there
are 2**$n distinct ways to translate that to viable Mac native file
specs (not allowing for further complications with things like 
s#\/\.\.\/#::#). Consider $n == 1 and take a possible file spec
using the letter "a" (the letter, provided it is not "/" nor ":" is
irrelevant to the discussion) then given a spec like "a/a" there are
these possible translations:

    "a/a"  ->
    ":a:a"
    ":a/a"

but I think you'll agree that the first and last are equivalent, hence I
have two == 2**1 possible valid specs to check out.
Assuming that for $n the number of translations is 2**$n then for $n+1
the number is simply doubled via these two possibilities:

    "a/a/a/... " . "a/a"
    "a/a/a/... " . "a:a"

that is 2 * the number for $n or 2 ** ($n+1).  Q.E.D.

In the case of file specs that lie under the 31 character limit I could
have:

  a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a

or a total of 15 "/" characters.  The resultant file operation on MacOS
would need to traverse a tree of 2**15 == 32768 possible file spec
translations before doing whatever it needed to do with the spec.
Ignoring the question of the path to finding the first viable spec that
sounds kind of nasty to me.

For longer than 31 "/" cases the algorithm would need to special case
the fact that 

  a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a

Would *have* to be tried as only:

  "a/a/a/a/a/a/a/a/a/a/a/a/a/a/a" . ":" . "a"

and so forth.

Peter Prymmer



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-porters-request@macperl.org