On Wed, 27 Mar 2019, Michael Stefaniuc wrote:
> Hello,
>
> I'm trying to do this transformation,
> from:
> const WCHAR wstr[] = {'u','t','f','1','6','
> ','s','t','r','i','n','g','\0'};
> to:
> const WCHAR wstr[] = u"utf16 string";
>
> I had hoped to be able to use an expression list for the array
> initializer, but that produces a parse error. I know that technically an
> array initializer is not an expression list, but it looks like one.
> Is there another metavariable that I can use instead?
I think that there is initializer list?
julia
>
>
> A way to workaround that would be to use something like:
> @r@
> typedef WCHAR;
> identifier wstr;
> constant ch;
> position p;
> @@
> const WCHAR wstr[] = { ..., ch@p, ..., '\0' };
>
>
> That would make the subsequent script:python rule run once for each
> char. With some surprises though:
> - The initializers ch get sorted before script:python runs. Thus the
> position is needed to undo the sorting.
> - More surprisingly, without @p the initializers get even deduplicated.
>
> This workaround is doable but tedious. Before I go down that rabbit hole
> I prefer to check if there's a better alternative.
>
> thanks
> bye
> michael
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci