https://github.com/torvalds/linux
Raw File
Tip revision: 3d7cb6b04c3f3115719235cc6866b10326de34cd authored by Linus Torvalds on 31 July 2022, 21:03:01 UTC
Linux 5.19
Tip revision: 3d7cb6b
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