[PATCH 1/2] sc: Fix parsing parameter name in the 'switch=param' constructs.
Dmitry Timoshkov
dmitry at baikal.ru
Sat Mar 19 01:54:00 CDT 2022
Hi Emil,
Emil Velikov <emil.l.velikov at gmail.com> wrote:
> The proposed patch fixes the original issue, although the parsing feels off.
> In particular: we silently accept any empty/invalid attribute for
> tag/type/start...
I'd suggest to submit a separate patch for this issue.
> I tend to split the parsing and conversion/validation wrapping the lot
> into a macro like below.
> In this case one needs to change the type of
> cp->{tag,type,start,error} to WCHAR * + add new variables for the
> original data.
>
> #define parse_argv(_arg) \
> do { \
> static const WCHAR *_larg = L ### _arg "="; \
> static const unsigned _size = wcslen(_larg); \
> if (!wcsnicmp( argv[i], _larg, _size )) { \
> cp-> _arg = argv[i] + _size; \
> validate_ # _arg(cp); \
> } \
> } while (0)
>
> Then the function becomes short and sweet:
> parse_argv(displayname);
> parse_argv(binpath);
> ....
> parse_argv(type);
> ...
Yes, that looks nicer. Although using a macro like this is usually frowned
upon in Wine community, and the suggestion is to use an inline helper instead.
Thanks.
--
Dmitry.
More information about the wine-devel
mailing list