https://jxself.org/git/linux-libre.git
Raw File
Tip revision: d8a75cbb8c9aabc30941458c6c3140ef76faae78 authored by Jason Self on 03 October 2011, 18:48:50 UTC
Linux-libre 3.0.5-gnu1
Tip revision: d8a75cb
unroll.awk

# This filter requires one command line option of form -vN=n
# where n must be a decimal number.
#
# Repeat each input line containing $$ n times, replacing $$ with 0...n-1.
# Replace each $# with n, and each $* with a single $.

BEGIN {
	n = N + 0
}
{
	if (/\$\$/) { rep = n } else { rep = 1 }
	for (i = 0; i < rep; ++i) {
		tmp = $0
		gsub(/\$\$/, i, tmp)
		gsub(/\$\#/, n, tmp)
		gsub(/\$\*/, "$", tmp)
		print tmp
	}
}
back to top