1#!/usr/bin/mawk -f
2
3# remove C comments  from a list of files
4# using a comment as the record separator
5#
6# this is trickier than I first thought
7# The first version in .97-.9993 was wrong
8
9BEGIN {
10 # RS is set to  a comment (this is mildly tricky, I blew it here
11 RS = "/\*([^*]|\*+[^*/])*\*+/"
12 ORS = " "
13 getline hold
14 filename = FILENAME
15}
16
17# if changing files
18filename != FILENAME {
19  filename = FILENAME
20  printf "%s" , hold
21  hold = $0
22  next
23}
24
25{ # hold one record because we don't want ORS on the last
26  #  record in each file
27  print hold
28  hold = $0
29}
30
31END { printf "%s", hold }
32