From: lars@metafoo.de (Lars-Peter Clausen)
To: cocci@systeme.lip6.fr
Subject: [Cocci] How can i rename a specific structure field?
Date: Thu, 02 Oct 2014 22:44:58 +0200 [thread overview]
Message-ID: <542DB94A.5030900@metafoo.de> (raw)
In-Reply-To: <CAHsAT8KbZS0xb4DpdL9oSKWRCJJ4gm0DWaiHi_+KvsqnFGaBNQ@mail.gmail.com>
On 10/02/2014 10:12 PM, jmiguel hernandez wrote:
> if i have this
>
> typedef struct type1 {
> char8 a;
> char8 b;
> char8 c;
> }
>
> typedef struct _interface {
> type1 field1;
> }interface;
>
> and want to change to
>
> typedef struct type1 {
> char8 d;
> char8 b;
> char8 c;
> }
>
> typedef struct _protocol {
> type1 *field1;
> }interface;
>
> interface *p
>
> -p->field->a
> +p->field->d
>
> I have tried just changing field1 to field2. This gives parsing errors.
>
> @@
> typedef interface;
> interface *p;
> typedef type1;
> type1 field1;
> @@
> <...
> -p->field1
> +p->fieldnew
> ...>
If you want to change the field from being embedded in the parent struct to
a pointer and rename the field at the same time the way to go is
@@
typedef interface;
interface *p;
@@
p->field1
-.a
+->b
That replaces the ".a" with a "->b"
- Lars
next prev parent reply other threads:[~2014-10-02 20:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-02 20:12 [Cocci] How can i rename a specific structure field? jmiguel hernandez
2014-10-02 20:22 ` Julia Lawall
2014-10-02 20:44 ` Lars-Peter Clausen [this message]
[not found] ` <CAHsAT8Knor4wG+398-BZ15Upwv1PWz=6VOGQvEXcHSGzimkD9Q@mail.gmail.com>
2014-10-06 17:11 ` [Cocci] Fwd: " jmiguel hernandez
2014-10-06 17:32 ` Julia Lawall
2014-10-06 18:14 ` jmiguel hernandez
2014-10-07 7:27 ` 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=542DB94A.5030900@metafoo.de \
--to=lars@metafoo.de \
--cc=cocci@systeme.lip6.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox