2013-07-31 11:45:44 +02:00
|
|
|
#!/usr/bin/awk -f
|
|
|
|
|
|
|
|
## Default to C block comments. You can change the comment delimiters from
|
|
|
|
## command line. The delims are regexes. For instance call this script with
|
|
|
|
##
|
2013-11-01 20:33:17 +01:00
|
|
|
## awk -v begin="#" -v end="$" -f <this-script> <files>
|
2013-07-31 11:45:44 +02:00
|
|
|
##
|
|
|
|
## to use shell comment delimiters.
|
|
|
|
|
|
|
|
BEGIN {
|
2013-11-01 20:33:17 +01:00
|
|
|
## Since 'begin' and 'end' are regexes, we need to escape some sequences.
|
|
|
|
if(begin == "")
|
|
|
|
begin="/\\*"
|
|
|
|
if(end == "")
|
|
|
|
end="\\*/"
|
2013-07-31 11:45:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-11-01 20:33:17 +01:00
|
|
|
while (match ($0, begin))
|
2013-10-06 19:54:15 +02:00
|
|
|
{
|
2013-07-31 11:45:44 +02:00
|
|
|
before = substr ($0, 1, RSTART-1)
|
|
|
|
$0 = substr($0, RSTART)
|
2013-10-30 15:57:24 +01:00
|
|
|
printf("%s", before)
|
2013-07-31 11:45:44 +02:00
|
|
|
|
2013-11-01 20:33:17 +01:00
|
|
|
## Reach line where first 'end' is found.
|
|
|
|
while (! match($0, end) )
|
2013-07-31 11:45:44 +02:00
|
|
|
getline
|
|
|
|
|
2013-11-01 20:33:17 +01:00
|
|
|
$0 = substr($0, RSTART + length(end) -1)
|
2013-07-31 11:45:44 +02:00
|
|
|
}
|
|
|
|
print
|
|
|
|
}
|