diff options
Diffstat (limited to 'lib/raid6/unroll.awk')
| -rw-r--r-- | lib/raid6/unroll.awk | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/raid6/unroll.awk b/lib/raid6/unroll.awk new file mode 100644 index 000000000000..c6aa03631df8 --- /dev/null +++ b/lib/raid6/unroll.awk | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | |||
| 2 | # This filter requires one command line option of form -vN=n | ||
| 3 | # where n must be a decimal number. | ||
| 4 | # | ||
| 5 | # Repeat each input line containing $$ n times, replacing $$ with 0...n-1. | ||
| 6 | # Replace each $# with n, and each $* with a single $. | ||
| 7 | |||
| 8 | BEGIN { | ||
| 9 | n = N + 0 | ||
| 10 | } | ||
| 11 | { | ||
| 12 | if (/\$\$/) { rep = n } else { rep = 1 } | ||
| 13 | for (i = 0; i < rep; ++i) { | ||
| 14 | tmp = $0 | ||
| 15 | gsub(/\$\$/, i, tmp) | ||
| 16 | gsub(/\$\#/, n, tmp) | ||
| 17 | gsub(/\$\*/, "$", tmp) | ||
| 18 | print tmp | ||
| 19 | } | ||
| 20 | } | ||
