[Cmake] Modules/FindPythonLibs.cmake : 8.4 + registry support

Ken Martin ken.martin at kitware.com
Sat May 12 15:31:14 EDT 2001


> OK Ken, I've added the following stuff :
>
> >The regexp is \[(HKEY[A-Za-z_0-9\.\\]*)\] so I'm basically looking for
> >[HKEY I don't think there is any need for a special word.
>
> Correct me if I'm wrong, but you forgot the space ' ' in your
> regexp. Added.

Sounds good.

> I've also added registry support. I had to modify cmSystemTools, for the
> following reason :
>
> HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
> is working OK because the data located in this key is in its
> "default" value.
>
> This does not work for Tcl, because the "default" value of
> HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4
> has no data...
> The data (the install path) is located in the "Root" value.
>
> I've modified ReadAValue to support the following syntax :
>
> // Get the data of key value.
> // Example :
> //      HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
> //      =>  will return the data of the "default" value of the key
> //      HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4§Root
> //      =>  will return the data of the "Root" value of the key
>
> The specific value name is appended to the key name after the "§" char (I
> modified the regexp accordingly to accept this char). Every suggestion is
> welcome as a better separator : I tried ':', '|', '#', '$', sadly they
> could all be found in some (or many) key name. "§" was not found
> in any key
> name of my registry (which is big).

Can we pick a different character for this? US keyboards do not have that
symbol so many of us will end up sitting around trying to figure out how to
type it for hours. Do you think any of ~ - ; * ^ would work for most cases?
Or maybe we could rework the logic so that when given

HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4\Root

it tries the entire "path" first and if that entry doesn't exist then it
strips of the last value and uses it for the key.

> As a consequence of this observation, I've just modified the regexp to
> accept all chars, the previous char set was really to small, don't you
> think so ? :
>    cmRegularExpression regEntry("\\[(HKEY.*)\\]");
>
> I do not know how your regexp engine works, but if it tries to match as
> many chars as possible, this regexp will fail if *more* than one key is
> used in the same string (eg. [HKEY stuff]foo/bar[KHEY stuff2] will return
> only one match : [HKEY stuff]foo/bar[KHEY stuff2] instead of [HKEY stuff]
> then [HKEY stuff2] ). The usual regexp trick is to disable this "greedy
> mode" by using *? instead of *. I does not seem to be supported. Neither
> does the \\[(HKEY[^\\]]*)\\] look to be supported. Any clues ?

Instead of allowing all characters we should exclude [ and ] so that we
don't have the problem of multiple keys. The regexp code will keep replacing
keys until none are left, so as long as we exclude [ and ] your example
above should work.

Ken





More information about the CMake mailing list