What is the spatch file for this change and the corresponding spatch command line invocation
Hello,
I give up trying to write the spatch myself:
Before file:
---
int i;
for ( ; ; ++i ) {
if (1) {
continue; }
}
---
After file:
---
int i;
for ( ; ; ) {
if (1) {
++i;
continue; }
++i;
}
---
All my trials don't work, not any change in the file appears if I try --in-place and -o fails because
"-o can not be applied because there are no modified files"
Thanks a lot,
Francois.
Quoted 23 lines · Francois Berenger
Hello,
I give up trying to write the spatch myself:
Before file:
---
int i;for ( ; ; ++i ) {
if (1) { continue;}
}
---After file:
---
int i;for ( ; ; ) {
if (1) { ++i; continue;
Quoted 8 lines
}
++i;
}
---All my trials don't work, not any change in the file appears if I try --in-place and -o fails because
"-o can not be applied because there are no modified files"
Can you take the hands on tutorial before expecting folks to write rules for you?
https://www.youtube.com/watch?v=buZrNd6XkEw
Luis
Quoted 23 lines · Francois Berenger
Hello,
I give up trying to write the spatch myself:
Before file:
---
int i;for ( ; ; ++i ) {
if (1) { continue;}
}
---After file:
---
int i;for ( ; ; ) {
if (1) { ++i; continue;
Quoted 8 lines
}
++i;
}
---All my trials don't work, not any change in the file appears if I try --in-place and -o fails because
"-o can not be applied because there are no modified files"
It's hard to know how much generality you want. But just for the code you have shown, the following code works fine for me:
@@
expression i;
@@
for ( ; ;
- ++i
) {
if (1) {
+ ++i;
continue; }
}
julia
Hello,
What is the spatch command line you used and which version of coccinelle are you using?
I tried this:
# apply.spatch is your exact proposal spatch --sp-file apply.spatch test_before.c -o /dev/stdout
Then I see on stdout the exact same file than what's in test_before.c
Quoted 14 lines · Julia Lawall
@@
expression i;
@@for ( ; ;
- ++i) { if (1) { + ++i; continue;}
}julia
Signature · 2 lines
Regards, Francois.
Quoted 9 lines · Francois Berenger
Hello,
What is the spatch command line you used and which version of coccinelle are you using?
I tried this:
# apply.spatch is your exact proposal spatch --sp-file apply.spatch test_before.c -o /dev/stdout
spatch apply.spatch test_before.c
See what happens if you add -debug to the argument list.
julia
Quoted 27 lines
Then I see on stdout the exact same file than what's in
test_before.cQuoted 6 lines · Julia Lawall
@@
expression i;
@@for ( ; ;
- ++iQuoted 8 lines
) { if (1) { + ++i; continue;}
}julia
--
Regards,
Francois.
_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 7 lines · Julia Lawall
Quoted 5 lines · Francois Berenger
Hello,
What is the spatch command line you used and which version of coccinelle are you using?
Quoted 8 lines
Quoted 4 lines
I tried this:
# apply.spatch is your exact proposal spatch --sp-file apply.spatch test_before.c -o /dev/stdoutspatch apply.spatch
test_before.cSee what happens if you add -debug to the argument list.
# spatch -debug -sp apply.spatch test_before.c init_defs_builtins: /home/berenger/.opam/4.01.0/share/coccinelle/standard.h ----------------------------------------------------------------------- processing semantic patch file: /tmp/sp-15933-b4165a.cocci with isos from: /home/berenger/.opam/4.01.0/share/coccinelle/standard.iso ----------------------------------------------------------------------- @@ @@ * apply.spatch
warning: line 3: should apply be a metavariable?
(ONCE) Expected tokens spatch apply
Skipping:test_before.c
Check duplication for 0 files
@@
@@
* apply.spatch
Quoted 29 lines
julia
Quoted 27 lines
Then I see on stdout the exact same file than what's in
test_before.cQuoted 6 lines · Julia Lawall
@@
expression i;
@@for ( ; ;
- ++iQuoted 8 lines
) { if (1) { + ++i; continue; } }julia
--
Regards,
Francois.
_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
Signature · 2 lines
Regards, Francois.
Quoted 28 lines · Francois Berenger
Quoted 8 lines · Julia Lawall
Quoted 6 lines · Francois Berenger
Hello,
What is the spatch command line you used and which version of coccinelle are
you using?Quoted 8 lines
Quoted 4 lines
I tried this:
# apply.spatch is your exact proposal spatch --sp-file apply.spatch test_before.c -o /dev/stdoutspatch apply.spatch
test_before.cSee what happens if you add -debug to the argument list.
# spatch -debug -sp apply.spatch test_before.c init_defs_builtins: /home/berenger/.opam/4.01.0/share/coccinelle/standard.h ----------------------------------------------------------------------- processing semantic patch file: /tmp/sp-15933-b4165a.cocci with isos from: /home/berenger/.opam/4.01.0/share/coccinelle/standard.iso ----------------------------------------------------------------------- @@ @@ * apply.spatch
Quoted 1 line
warning: line 3: should apply be a metavariable?
In my whole apply.spatch file, there is nothing named apply ... I am puzzled.
Quoted 37 lines
(ONCE) Expected tokens spatch apply
Skipping:test_before.c
Check duplication for 0 files
@@
@@
* apply.spatchQuoted 29 lines
julia
Quoted 27 lines
Then I see on stdout the exact same file than what's in
test_before.cQuoted 6 lines · Julia Lawall
@@
expression i;
@@for ( ; ;
- ++iQuoted 8 lines
) { if (1) { + ++i; continue; } }julia
--
Regards,
Francois.
_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
Signature · 2 lines
Regards, Francois.
Quoted 11 lines · Francois Berenger
Quoted 10 lines · Julia Lawall
Quoted 8 lines · Francois Berenger
Hello,
What is the spatch command line you used and which version of coccinelle are
you using?I tried this:
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
# apply.spatch is your exact proposal spatch --sp-file apply.spatch test_before.c -o /dev/stdoutspatch apply.spatch
test_before.cSee what happens if you add -debug to the argument list.
# spatch -debug -sp apply.spatch test_before.c
The argument -sp does not do what you think. It takes the following text as a semantic patch. It is useful for doing very simple searches, since you don't have to make a separate file.
julia
Quoted 51 lines
init_defs_builtins:/home/berenger/.opam/4.01.0/share/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file:/tmp/sp-15933-b4165a.cocci
with isos from:/home/berenger/.opam/4.01.0/share/coccinelle/standard.iso
-----------------------------------------------------------------------
@@
@@
* apply.spatchwarning: line 3: should apply be a metavariable?
(ONCE) Expected tokens spatch apply
Skipping:test_before.c
Check duplication for 0 files
@@
@@
* apply.spatchQuoted 29 lines
julia
Quoted 27 lines
Then I see on stdout the exact same file than what's in
test_before.cQuoted 6 lines · Julia Lawall
@@
expression i;
@@for ( ; ;
- ++iQuoted 8 lines
) { if (1) { + ++i; continue; } }julia
--
Regards,
Francois.
_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci--
Regards,
Francois.
Quoted 29 lines · Luis R. Rodriguez
Quoted 28 lines · Francois Berenger
Hello,
I give up trying to write the spatch myself:
Before file:
---
int i;for ( ; ; ++i ) { if (1) { continue; } }---
After file:
---
int i;for ( ; ; ) { if (1) { ++i; continue; } ++i; }---
Quoted 8 lines
Quoted 3 lines
All my trials don't work, not any change in the file appears if I try --in-place and -o fails because
"-o can not be applied because there are no modified files"Can you take the hands on tutorial before expecting folks to write rules for you?
If I really need to invest two hours before being able to use coccinelle productively, that would be a serious entry barrier.
And probably not just for me: for any potential new user of coccinelle.
Quoted 37 lines · Francois Berenger
Quoted 36 lines · Luis R. Rodriguez
Quoted 26 lines · Francois Berenger
Hello,
I give up trying to write the spatch myself:
Before file:
---
int i;for ( ; ; ++i ) { if (1) { continue; } }---
After file:
---
int i;for ( ; ; ) { if (1) { ++i; continue; } ++i; }Quoted 5 lines
---
All my trials don't work, not any change in the file appears if I try --in-place and -o fails because
"-o can not be applied because there are no modified files"Can you take the hands on tutorial before expecting folks to write rules for you?
Quoted 7 lines
Quoted 1 line
If I really need to invest two hours before being able to use coccinelle productively, that would be a serious entry barrier.
And probably not just for me: for any potential new user of coccinelle.
I think that you may have started with an unfortunate case. I'm not sure what is the strategy for matching the empty space in a for header. It's not an expression, so what is it. It may be possible only to match it exactly.
On the other hand, it is helpful if you provide a semantic patch that you have tried, rather than just the before and after code. From one example of before and after code, it is not always possible to guess the full generality of the rule that you are trying to implement.
julia
Quoted 53 lines · Julia Lawall
Quoted 37 lines · Francois Berenger
Quoted 36 lines · Luis R. Rodriguez
Quoted 26 lines · Francois Berenger
Hello,
I give up trying to write the spatch myself:
Before file:
---
int i;for ( ; ; ++i ) { if (1) { continue; } }---
After file:
---
int i;for ( ; ; ) { if (1) { ++i; continue; } ++i; }Quoted 5 lines
---
All my trials don't work, not any change in the file appears if I try --in-place and -o fails because
"-o can not be applied because there are no modified files"Can you take the hands on tutorial before expecting folks to write rules for you?
Quoted 7 lines
Quoted 1 line
If I really need to invest two hours before being able to use coccinelle productively, that would be a serious entry barrier.
And probably not just for me: for any potential new user of coccinelle.
I think that you may have started with an unfortunate case. I'm not sure what is the strategy for matching the empty space in a for header. It's not an expression, so what is it. It may be possible only to match it exactly.
Quoted 4 lines
On the other hand, it is helpful if you provide a semantic patch that you have tried, rather than just the before and after code. From one example of before and after code, it is not always possible to guess the full generality of the rule that you are trying to implement.
My mistake. Thanks for providing me ealier an example spatch.
The availability of a working spdiff tool, shipping and synchronized with coccinelle may lower the entry barrier to new users:
users could start writing working spatches just by editing a working starting example they may have inferred using spdiff from an actual source code difference.
Signature · 2 lines
Regards, Francois.
Quoted 46 lines · Julia Lawall
Quoted 42 lines · Francois Berenger
Quoted 29 lines · Luis R. Rodriguez
Quoted 28 lines · Francois Berenger
Hello,
I give up trying to write the spatch myself:
Before file:
---
int i;for ( ; ; ++i ) { if (1) { continue; } }---
After file:
---
int i;for ( ; ; ) { if (1) { ++i; continue; } ++i; }---
Quoted 8 lines
Quoted 3 lines
All my trials don't work, not any change in the file appears if I try --in-place and -o fails because
"-o can not be applied because there are no modified files"Can you take the hands on tutorial before expecting folks to write rules for you?
If I really need to invest two hours before being able to use coccinelle productively, that would be a serious entry barrier.
Quoted 6 lines
Quoted 2 lines
And probably not just for me: for any potential new user of coccinelle.
I think that you may have started with an unfortunate case. I'm not sure what is the strategy for matching the empty space in a for header. It's not an expression, so what is it.
It is an optional expression: either there is an expression, either there is none.
I could not find such thing in the SmPL grammar manual (v1.0.0-rc21).
Quoted 10 lines
It may be possible only to match it
exactly.On the other hand, it is helpful if you provide a semantic patch that you have tried, rather than just the before and after code. From one example of before and after code, it is not always possible to guess the full generality of the rule that you are trying to implement.
julia
Signature · 2 lines
Regards, Francois.
Quoted 5 lines · Francois Berenger
The availability of a working spdiff tool, shipping and synchronized with coccinelle may lower the entry barrier to new users:
users could start writing working spatches just by editing
a working starting example they may have inferred using spdiff from an actual source code difference.
Agreed. One must not lightly discard the theoretical complexities and challenges to even come up with Coccinelle and spdiff, as Coccienlle matures I'm afraid we haven't yet had much exposure on users to spdiff, so it may take some time to get users what you describe seamlessly.
Luis