https://github.com/torvalds/linux
Raw File
Tip revision: 569dbb88e80deb68974ef6fdd6a13edb9d686261 authored by Linus Torvalds on 03 September 2017, 20:56:17 UTC
Linux 4.13
Tip revision: 569dbb8
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