Created
January 17, 2017 12:13
-
-
Save movitto/6c6d187f7a350c2d71480834892552ab to your computer and use it in GitHub Desktop.
Unmatched Braces / Preprocessor Finder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# search for unmatched '{' / '}' pairs and '#ifndef' / '#endif' pairs | |
# assuming that any given file should have fully matched sets of both | |
Dir.glob("src/**/*\.[h,cpp]").each { |src| | |
c = File.read(src) | |
ob = c.count('{') | |
cb = c.count('}') | |
od = c.count('#ifndef') | |
cd = c.count('#endif') | |
puts "! #{src}" if ob != cb || od != cd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment