Coccinelle archive mirror
 help / color / mirror / Atom feed
* [cocci] Function name change
       [not found] <CGME20240602141758uscas1p292dac565d2e37b835caaccab029d456f@uscas1p2.samsung.com>
@ 2024-06-02 14:17 ` Ali Raza
  2024-06-02 14:23   ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Ali Raza @ 2024-06-02 14:17 UTC (permalink / raw
  To: cocci@inria.fr

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

Hi

I am new to using spatch, and I have been through many resources online but cant figure out how to write a patch for the following function name change.

I have the following.

MY_MACRO(foo(arg1, arg2,
                                           arg3, arg4, arg5));

I want to change foo to bar, as follows.

MY_MACRO(bar(arg1, arg2,
                                           arg3, arg4, arg5));

I have tried many versions of the following, but to no avail.

@@
expression E;
@@
<...
-foo(E)
+bar(E)
...>

Thanks!

Ali


[-- Attachment #2: Type: text/html, Size: 3665 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [cocci] Function name change
  2024-06-02 14:17 ` [cocci] Function name change Ali Raza
@ 2024-06-02 14:23   ` Julia Lawall
       [not found]     ` <48ecf4ec00c942bb841a356567d2aef1@samsung.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2024-06-02 14:23 UTC (permalink / raw
  To: Ali Raza; +Cc: cocci@inria.fr

[-- Attachment #1: Type: text/plain, Size: 967 bytes --]



On Sun, 2 Jun 2024, Ali Raza wrote:

>
> Hi
>
>  
>
> I am new to using spatch, and I have been through many resources online but cant figure out how to write a patch for the following function name change.
>
>  
>
> I have the following.
>
>  
>
> MY_MACRO(foo(arg1, arg2,
>
>                                            arg3, arg4, arg5));
>
>  
>
> I want to change foo to bar, as follows.
>
>  
>
> MY_MACRO(bar(arg1, arg2,
>
>                                            arg3, arg4, arg5));

Try:

MY_MACRO(
- foo
+ bar
    (...))

If that doesn't work, then perhaps there is a problem in parsing your C
code.  Take a file that you expect to change and try

  spatch --parse-c file.c

See if the code that you expect to change has bad or BAD in front of it.

julia


>
>  
>
> I have tried many versions of the following, but to no avail.
>
>  
>
> @@
>
> expression E;
>
> @@
>
> <...
>
> -foo(E)
>
> +bar(E)
>
> ...>
>
>  
>
> Thanks!
>
>  
>
> Ali
>
>  
>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [cocci] Function name change
       [not found]     ` <48ecf4ec00c942bb841a356567d2aef1@samsung.com>
@ 2024-06-02 15:08       ` Julia Lawall
  0 siblings, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2024-06-02 15:08 UTC (permalink / raw
  To: Ali Raza; +Cc: cocci@inria.fr

[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]

> >> I have the following.
>
> >> 
>
> >> MY_MACRO(foo(arg1, arg2,
>
> >>                                            arg3, arg4, arg5));
>
> >> 
>
> >> I want to change foo to bar, as follows.
>
> >> 
>
> >> MY_MACRO(bar(arg1, arg2,
>
> >>                                            arg3, arg4, arg5));
>
> > 
>
> >Try:
>
> > 
>
> >MY_MACRO(
>
> >- foo
>
> >+ bar
>
> >    (...))
>
> > 
>
> >If that doesn't work, then perhaps there is a problem in parsing your C
>
> >code.  Take a file that you expect to change and try
>
>  
>
> Here is the spatch you suggested.
>
>  
>
> 18:    MY_MACRO(
>
> 19:   - foo
>
> 20:   + bar
>
> 21:   (...))

There should be at least one space in front of the ( on line 21.

julia

>
>  
>
> And here is the output that I get.
>
> disjunction parenthesis in line 21 column 0 matched to normal parenthesis on
>  line 21
>
>  
>
> > 
>
> >  spatch --parse-c file.c
>
> > 
>
> >See if the code that you expect to change has bad or BAD in front of it.
>
>  
>
> Running spatch --parse-c file.c gives me 100.00% good or passed.
>
>  
>
> Thanks
>
> Ali
>
>  
>
> > 
>
> >julia
>
> > 
>
> > 
>
> >> 
>
> >> I have tried many versions of the following, but to no avail.
>
> >> 
>
> >> 
>
> >> @@
>
> >> expression E;
>
> >> @@
>
> >> <...
>
> >> -foo(E)
>
> >> +bar(E)
>
> >> ...>
>
> >> 
>
> >> 
>
> >> Thanks!
>
> >> 
>
> >> Ali
>
> >> 
>
>  
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-02 15:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20240602141758uscas1p292dac565d2e37b835caaccab029d456f@uscas1p2.samsung.com>
2024-06-02 14:17 ` [cocci] Function name change Ali Raza
2024-06-02 14:23   ` Julia Lawall
     [not found]     ` <48ecf4ec00c942bb841a356567d2aef1@samsung.com>
2024-06-02 15:08       ` Julia Lawall

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 read-only IMAP folder(s) and NNTP newsgroup(s).