Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / share / doc / mawk / examples / | server ip : 104.21.89.46 your ip : 172.69.130.130 H O M E |
Filename | /usr/share/doc/mawk/examples/nocomment.awk |
Size | 590 |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:50 |
Last modified | 24-Mar-2014 17:53 |
Last accessed | 07-Jul-2025 12:42 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
#!/usr/bin/mawk -f
# remove C comments from a list of files
# using a comment as the record separator
#
# this is trickier than I first thought
# The first version in .97-.9993 was wrong
BEGIN {
# RS is set to a comment (this is mildly tricky, I blew it here
RS = "/\*([^*]|\*+[^*/])*\*+/"
ORS = " "
getline hold
filename = FILENAME
}
# if changing files
filename != FILENAME {
filename = FILENAME
printf "%s" , hold
hold = $0
next
}
{ # hold one record because we don't want ORS on the last
# record in each file
print hold
hold = $0
}
END { printf "%s", hold }
# remove C comments from a list of files
# using a comment as the record separator
#
# this is trickier than I first thought
# The first version in .97-.9993 was wrong
BEGIN {
# RS is set to a comment (this is mildly tricky, I blew it here
RS = "/\*([^*]|\*+[^*/])*\*+/"
ORS = " "
getline hold
filename = FILENAME
}
# if changing files
filename != FILENAME {
filename = FILENAME
printf "%s" , hold
hold = $0
next
}
{ # hold one record because we don't want ORS on the last
# record in each file
print hold
hold = $0
}
END { printf "%s", hold }