Annotation of dmsdos/src/remove_comments.awk, revision 1.1

1.1     ! root        1: #
        !             2: # This is an awk script which removes comments in c files.
        !             3: # it does not follow #include directives.
        !             4: #
        !             5: 
        !             6: BEGIN{
        !             7:        incomment=0
        !             8: }
        !             9: 
        !            10: # eliminate comments
        !            11: {
        !            12:     # remove all comments fully contained on a single line
        !            13:        gsub("\\/\\*.*\\*\\/", "")
        !            14:        if (incomment) {
        !            15:                if ($0 ~ /\*\//) {
        !            16:                        incomment = 0;
        !            17:                        gsub(".*\\*\\/", "")
        !            18:                } else {
        !            19:                        next
        !            20:                }
        !            21:        } else {
        !            22:                # start of multi-line comment
        !            23:                if ($0 ~ /\/\*/)
        !            24:                {
        !            25:                        incomment = 1;
        !            26:                        sub("\\/\\*.*", "")
        !            27:                } else if ($0 ~ /\*\//) {
        !            28:                        incomment = 0;
        !            29:                        sub(".*\\*\\/", "")
        !            30:                }
        !            31:        }
        !            32:        print $0
        !            33: }
        !            34: 
        !            35: END{
        !            36: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.