Fast Makefile generation for C-binary target
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

15 lines
590 B

#!/usr/bin/perl -w
# Code has been taken from this two webpages:
# http://bytes.com/topic/python/answers/155853-stripping-c-style-comments-using-python-regexp
# http://collectns.blogspot.com/2011/05/perl-script-to-remove-comments-from-c.html
$/ = undef; # no line delimiter
$_ = <>; # read entire file
s! ((['"]) (?: \\. | .)*? \2) | # skip quoted strings
/\* .*? \*/ | # delete C comments
// [^\n\r]* # delete C++ comments
! $1 || ' ' # change comments to a single space
!xseg; # ignore white space, treat as single line
# evaluate result, repeat globally
print;