Description
Each line of the first file except the last one
|
| Raw Input
| |
File 1:
| func1 add
func2 remove
func10 start
func20 stop
|
|
| Raw Input
|
| Desired Output
| |
File 2:
| func10 ()
{ step 10-1; func1; func20;
}
func1 ()
{ step 1-1; func10; func2;
}
func20 ()
{ step 20-1; func10; step 20-2;
}
func2 ()
{ step 2-1; step 2-2;
}
|
| start ()
{ step 10-1; add; stop;
}
add ()
{ step 1-1; start; remove;
}
stop ()
{ step 20-1; start; step 20-2;
}
remove ()
{ step 2-1; step 2-2;
}
|
|
Script and Comments
Script1 [ 1] 1,/^$/{
[ 2] /^$/!H
[ 3] d
[ 4] }
[ 5] G
[ 6] s/^([^\n]*)\n\n(.*)/\2\n\n\1/
[ 7] :loop
[ 8] s/^(\w+) +(\w+)(.*\n)(.*)\b\1\b/\1 \2\3\4\2/
[ 9] t loop
[10] s/^[^\n]*\n//
[11] /\n/b loop
| |
|