Another space oddity
Hi,
I have found another strange space/newline behavior when changing iterator loops:
Following script:
@@
iterator name for0;
@@
for0()
- {
0;
- }
@@
iterator name for0;
@@
for0()
- { 1; }
+ 1;
@@
iterator name for0;
@@
- for0() { 2; }
+ for0() 2;
-----------
On file:
int f() {
for0() {
0;
}
for0() {
1;
}
for0() {
2;
}
}
Produces output:
int f() {
for0()
0;
for0() 1;
for0 ()
2;
}
---
Ie. in cases:
0 - it adds extra line,
1 - removes existing line,
2 - produces correct output, but modifies iterator header (I would like to avoid, extra space between for0 and '('.
I would expect 0 and 1 produce correct indentation in 0 and 1, is it possible to fix it?
Regards
Andrzej
Quoted 58 lines · Andrzej Hajda
Hi,
I have found another strange space/newline behavior when changing iterator loops:
Following script:
@@
iterator name for0;
@@
for0()
- {
0;
- }@@
iterator name for0;
@@
for0()
- { 1; }
+ 1;@@
iterator name for0;
@@
-for0(){ 2; }
+for0()2;
-----------
On file:
intf(){
for0(){
0;
}
for0(){
1;
}
for0(){
2;
}
}
Produces output:
intf(){
for0()0;
for0()1;for0 ()
2;
}
---
Ie. in cases:
0 - it adds extra line,
1 - removes existing line,
2 - produces correct output, but modifies iterator header (I would like to avoid, extra space between for0 and '('.
Quoted 2 lines
I would expect 0 and 1 produce correct indentation in 0 and 1, is it possible to fix it?
Thanks for the report and the nice small examples. I will look into it.
julia
Quoted 62 lines · Julia Lawall
Quoted 58 lines · Andrzej Hajda
Hi,
I have found another strange space/newline behavior when changing iterator loops:
Following script:
@@
iterator name for0;
@@
for0()
- {
0;
- }@@
iterator name for0;
@@
for0()
- { 1; }
+ 1;@@
iterator name for0;
@@
-for0(){ 2; }
+for0()2;
-----------
On file:
intf(){
for0(){
0;
}
for0(){
1;
}
for0(){
2;
}
}
Produces output:
intf(){
for0()0;
for0()1;for0 ()
2;
}
---
Ie. in cases:
0 - it adds extra line,
1 - removes existing line,
2 - produces correct output, but modifies iterator header (I would like to avoid, extra space between for0 and '('.
Quoted 4 lines
Quoted 2 lines
I would expect 0 and 1 produce correct indentation in 0 and 1, is it possible to fix it?
Thanks for the report and the nice small examples. I will look into it.
Surprisingly this performs nicely spaced transformation, even without adding space after for0:
@@
iterator name for0;
@@
- for0() {
+ for0()
0;
- }
--------
Andrzej
Quoted 2 lines
julia
Quoted 48 lines · Andrzej Hajda
Hi,
I have found another strange space/newline behavior when changing iterator loops:
Following script:
@@
iterator name for0;
@@
for0()
- {
0;
- }@@
iterator name for0;
@@
for0()
- { 1; }
+ 1;@@
iterator name for0;
@@
-for0(){ 2; }
+for0()2;
-----------
On file:
intf(){
for0(){
0;
}
for0(){
1;
}
for0(){
2;
}
}
Produces output:
intf(){
for0()0;
for0()1;
Quoted 9 lines
for0 ()
2;
}
---
Ie. in cases:
0 - it adds extra line,
1 - removes existing line,
2 - produces correct output, but modifies iterator header (I would like to avoid, extra space between for0 and '('.
To avoid the space, you can use the argument --smpl-spacing. Then it will follow the spacing strategy found in the semantic patch.
julia
Quoted 60 lines · Julia Lawall
Quoted 48 lines · Andrzej Hajda
Hi,
I have found another strange space/newline behavior when changing iterator loops:
Following script:
@@
iterator name for0;
@@
for0()
- {
0;
- }@@
iterator name for0;
@@
for0()
- { 1; }
+ 1;@@
iterator name for0;
@@
-for0(){ 2; }
+for0()2;
-----------
On file:
intf(){
for0(){
0;
}
for0(){
1;
}
for0(){
2;
}
}
Produces output:
intf(){
for0()0;
for0()1;Quoted 9 lines
for0 ()
2;
}
---
Ie. in cases:
0 - it adds extra line,
1 - removes existing line,
2 - produces correct output, but modifies iterator header (I would like to avoid, extra space between for0 and '('.
Quoted 2 lines
To avoid the space, you can use the argument --smpl-spacing. Then it will follow the spacing strategy found in the semantic patch.
Thanks for the hint.
Regards
Andrzej
Quoted 2 lines
julia