cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Michael Stefaniuc <mstefani@mykolab.com>
Cc: Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Capturing all array initializers?
Date: Wed, 27 Mar 2019 08:26:33 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.21.1903270826060.2461@hadrien> (raw)
In-Reply-To: <51927c57-784e-6154-7032-0a4a266ac6f0@mykolab.com>



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
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  reply	other threads:[~2019-03-27  7:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 23:46 [Cocci] Capturing all array initializers? Michael Stefaniuc
2019-03-27  7:26 ` Julia Lawall [this message]
2019-03-27 10:20   ` Michael Stefaniuc
2019-03-27 10:30     ` Julia Lawall
2019-03-27  7:28 ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.1903270826060.2461@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=mstefani@mykolab.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).