Hi,

On Sun, 27 Jan 2008, Kirill wrote:

> diff --git a/systeminfo.c b/systeminfo.c
> index 08429bf..07444d6 100644
> --- a/systeminfo.c
> +++ b/systeminfo.c
> @@ -8,32 +8,45 @@ TCHAR * msys_path(void)
>       static int found_path = 0;
>       HKEY hKey;
>       LONG lRet;
> +     DWORD msysPathLen = MAX_PATH * sizeof(TCHAR);
> 
>       /* Only bother to get it once. */
>       if (found_path)
>               return msysPath;
>       
> -     lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
> +     /* try to find user-specific settings first */
> +     lRet = RegOpenKeyEx(HKEY_CURRENT_USER,
>                           TEXT(GIT_CHEETAH_REG_PATH),
>                           0, KEY_QUERY_VALUE, &hKey);
> -     
> -     if (lRet == ERROR_SUCCESS)
> -     {
> -             DWORD msysPathLen = MAX_PATH * sizeof(TCHAR);
> -             
> +     if (ERROR_SUCCESS == lRet) {
>               lRet = RegQueryValueEx(hKey,
>                                      TEXT(GIT_CHEETAH_REG_PATHTOMSYS),
>                                      NULL, NULL,
>                                      (LPBYTE)msysPath,
>                                      &msysPathLen);
>               RegCloseKey(hKey);
> +     }
> 
> -             if (lRet == ERROR_SUCCESS)
> -             {
> -                     found_path = 1;
> -                     return msysPath;
> +     /* if current user does not have the path, try machine-wide */
> +     if (ERROR_SUCCESS != lRet) {
> +             lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
> +                         TEXT(GIT_CHEETAH_REG_PATH),
> +                         0, KEY_QUERY_VALUE, &hKey);
> +             if (ERROR_SUCCESS == lRet) {
> +                     lRet = RegQueryValueEx(hKey,
> +                                    TEXT(GIT_CHEETAH_REG_PATHTOMSYS),
> +                                    NULL, NULL,
> +                                    (LPBYTE)msysPath,
> +                                    &msysPathLen);
> +                     RegCloseKey(hKey);
>               }
>       }
> +     
> +     if (lRet == ERROR_SUCCESS)
> +     {
> +             found_path = 1;
> +             return msysPath;
> +     }
> 
>       return NULL;
>  }

Except for this part (like I said, I'd like it refactored into a helper 
function), I like your patch.

Ciao,
Dscho

Reply via email to