INNER CODE UNIT · Python
count_enclosed_functions
tanersener/mobile-ffmpeg · src/libsndfile/make_lite.py:5
def count_enclosed_functions (source):
func_count = 0
open_brace = 0
close_brace = 0
for ch in source:
if ch == '{':
open_brace += 1
elif ch == '}':
close_brace += 1
if open_brace == close_brace:
func_count += 1
if open_brace < close_brace:
print "count_enclosed_functions : open_brace < close_brace"
return -1
return func_count
def find_function_prototype (source, proto_name):
proto_re = "(^[a-zA-Z_ \t]+\s+%s[^a-zA-Z0-9_]\s*\([^\)]+\)\s+;\n)" % (proto_name)