zlib2ansi revision 1b33c96954667ba382fa595baf7b31290bfdd517
98N/A# Transform K&R C function definitions into ANSI equivalent. 98N/A# Date: 3 October 2006 98N/A# Asumes no function pointer parameters. unless they are typedefed. 98N/A# Assumes no literal strings that look like function definitions 98N/A# Assumes functions start at the beginning of a line 98N/Amy $sp =
qr{ \s* (?: /\* .*? \*/ )? \s* }x; # assume no nested comments 98N/A .*? # Minimal eat content 98N/A ( ^ \w [\w\s\*]+ ) # $3 -- function name 851N/A \s* # optional whitespace 98N/A ) # $2 - Matched up to before parameter list 235N/A \( \s* # Literal "(" + optional whitespace 156N/A ( [^\)]+ ) # $4 - one or more anythings except ")" 156N/A \s* \) # optional whitespace surrounding a Literal ")" 98N/A $sp ^ { # literal "{" at start of line 810N/A# Output any trailing code. 98N/A # Strip C & C++ coments 98N/A /\* ## Start of /* ... */ comment 591N/A [^*]*\*+ ## Non-* followed by 1-or-more *'s 111N/A )* ## 0-or-more things which don't start with / 111N/A / ## End of /* ... */ comment 851N/A // ## Start of C++ comment // 851N/A [^\n]* ## followed by 0-or-more non end of line characters 606N/A | ## OR various things which aren't comments: 733N/A " ## Start of " ... " string 851N/A " ## End of " ... " string 851N/A ' ## Start of ' ... ' string 212N/A ' ## End of ' ... ' string 606N/A . ## Anything other char