SourceForge Logo Smatch Logo

Using smatch.py!!!

The smatch.py Python module is very similar to the smatch.pm Perl module. It's probably best to that documentation first. The functions have the same names and act the same in both modules. Here is a small useless program that shows how the module is used.
#!/usr/bin/python

import smatch

sm = smatch.Smatch()
while 1:
    data = sm.get_data()
    if not data:
        break

    filename = sm.get_filename()
    lineno = sm.get_lineno()
    print "%s %d %s" %(filename, lineno, data) 
The one API change for the smatch.py module is ...
 
sm.add_merge_function(merge)  
... in Python scripts you need to pass a function, the Perl scripts you pass a string.
 
add_merge_function("merge")
By this time next week, probably the Perl API will be changed to pass a function instead of a string. Also, hopefully this documentation will be updated and spell checked etc. ;)