From: Eric Wheeler <cocci@lists.ewheeler.net>
To: Nicolas Palix <nicolas.palix@univ-grenoble-alpes.fr>
Cc: cocci@inria.fr
Subject: Re: [cocci] Does SmPL support regex groups?
Date: Tue, 22 Mar 2022 23:00:51 -0700 (PDT) [thread overview]
Message-ID: <ec26179-1de1-35a-1bd3-c33151f939cb@ewheeler.net> (raw)
In-Reply-To: <b77b2358-50fb-69ff-3205-52781e6bf405@univ-grenoble-alpes.fr>
On Tue, 22 Mar 2022, Nicolas Palix wrote:
> For the record, is it the expected SmPL ?
>
> @ fu @
> identifier F,file_chooser;
> parameter list PL;
> expression list EL1, EL2;
> constant U =~ "untitled";
> @@
>
> F(PL)
> {
> ...
> file_chooser = Open_Filechooser(EL1, U, EL2);
> ...
> }
>
> @script:python py@
> U << fu.U;
> C;
> @@
>
> print U # Rewrite U to extract the extension
> coccinelle.C = cocci.make_expr("\".gplot\"")
The extension varies, there were half a dozen or so: I had to replace
several Open_Filechooser() calls that had different extensions. Here is
the diff for that commit:
https://github.com/KJ7LNW/xnec2c/commit/9fb0381c24365311e3bb1fc8158f18112864ebfb#diff-1d0efcfbefd013aedf0477bd522a1e4506339c5ef239a6ef770f39270747c14cL222
Here is one such diff for .png:
file_chooser = Open_Filechooser( GTK_FILE_CHOOSER_ACTION_SAVE,
- "*.png", NULL, "untitled.png", rc_config.working_dir );
+ "*.png", NULL, get_nec_filename_stem(newfn, ".png", PATH_MAX),
rc_config.working_dir );
I'm not so familiar with Python, so forgive my likely incorrect syntax,
but this might work:
coccinelle.C = re.match("(\..*)$", U).group(1)
-Eric
> @ replace_untitled @
> identifier F,file_chooser;
> parameter list PL;
> expression list EL1, EL2;
> constant fu.U;
> expression py.C;
> @@
>
> F(PL)
> {
> + char newfn[PATH_MAX];
> ...
> file_chooser = Open_Filechooser(EL1,
> - U,
> + get_nec_filename_stem(newfn, C, PATH_MAX),
> EL2);
> ...
> }
>
>
>
> --
> Nicolas Palix
>
prev parent reply other threads:[~2022-03-23 6:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 23:15 [cocci] Does SmPL support regex groups? Eric Wheeler
2022-03-09 5:55 ` Julia Lawall
2022-03-09 20:56 ` Eric Wheeler
2022-03-09 21:20 ` Julia Lawall
2022-03-10 2:25 ` Eric Wheeler
2022-03-10 6:12 ` Julia Lawall
2022-03-10 9:16 ` Markus Elfring
2022-03-10 22:03 ` Eric Wheeler
2022-03-11 11:12 ` Nicolas Palix
2022-03-11 12:39 ` Julia Lawall
2022-03-12 7:00 ` Markus Elfring
2022-03-10 8:39 ` Markus Elfring
2022-03-09 18:38 ` Markus Elfring
2022-03-09 20:51 ` Eric Wheeler
2022-03-09 21:16 ` Markus Elfring
2022-03-22 14:30 ` Nicolas Palix
2022-03-22 19:26 ` Markus Elfring
2022-03-23 6:00 ` Eric Wheeler [this message]
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=ec26179-1de1-35a-1bd3-c33151f939cb@ewheeler.net \
--to=cocci@lists.ewheeler.net \
--cc=cocci@inria.fr \
--cc=nicolas.palix@univ-grenoble-alpes.fr \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.