[PATCH v2 6/7] shell32/autocomplete: Use the optional IACList interface and IACList::Expand, if available

Huw Davies huw at codeweavers.com
Mon Oct 15 05:15:51 CDT 2018


On Fri, Sep 28, 2018 at 02:44:11PM +0300, Gabriel Ivăncescu wrote:
> @@ -229,6 +231,54 @@ static LRESULT change_selection(IAutoCompleteImpl *ac, HWND hwnd, UINT key)
>      return 0;
>  }
>  
> +static void aclist_expand(IAutoCompleteImpl *ac, WCHAR *txt)
> +{
> +    /* call IACList::Expand only when needed
> +       '/' is allowed as a delim for unix paths */
> +    WCHAR c, *p, *last_delim, *old_txt = ac->txtbackup;
> +    size_t i = 0;
> +
> +    /* skip the shared prefix */
> +    while ((c = tolowerW(txt[i])) == tolowerW(old_txt[i]))
> +    {
> +        if (c == '\0') return;
> +        i++;
> +    }
> +
> +    /* they differ at this point, check for a delim further in txt */
> +    last_delim = NULL;
> +    for (p = &txt[i]; *p != '\0'; p++)
> +        if (*p == '\\' || *p == '/')
> +            last_delim = p;
> +    if (last_delim)
> +        goto expand;
> +
> +    /* txt has no delim after i, check for a delim further in old_txt */
> +    for (p = &old_txt[i]; *p != '\0'; p++)
> +        if (*p == '\\' || *p == '/')
> +        {
> +            /* find the delim before i (if any) */
> +            while (i--)
> +            {
> +                if (txt[i] == '\\' || txt[i] == '/')
> +                {
> +                    last_delim = &txt[i];
> +                    goto expand;
> +                }
> +            }
> +            break;  /* Windows doesn't expand without a delim */
> +        }
> +
> +    /* they differ, but without any different delims, so no need to expand */
> +    return;
> +
> +expand:
> +    c = last_delim[1];
> +    last_delim[1] = '\0';
> +    IACList_Expand(ac->aclist, txt);
> +    last_delim[1] = c;
> +}

This is going to need some work; trying to follow this code is just too hard.

Huw.



More information about the wine-devel mailing list