On Sun, 28 Mar 2021, Markus Elfring wrote: > > And what is the problem here? > > Would you like to discuss further software development ideas > according to another SmPL script example like the following? The following looks like what one might want to do to find #defines that are near each other. julia > > > @initialize:python@ > @@ > import sys > > records = {} > > class integrity_error: > pass > > def store_positions(places, name, text): > """Add source code positions to an internal table.""" > for place in places: > key = place.file, place.line, int(place.column) + 1 > > if key in records: > sys.stderr.write("\n".join(["-> duplicate data", > "file:", key[0], > "function:", place.current_element, > "line:", str(place.line)])) > sys.stderr.write("\n") > raise integrity_error > else: > records[key] = name, text, place.current_element > > @find@ > expression e; > identifier i; > position p; > @@ > #define i@p e > > @script:python collection@ > i << find.i; > e << find.e; > places << find.p; > @@ > store_positions(places, i, e) > > @finalize:python@ > @@ > if len(records) > 0: > delimiter = "|" > sys.stdout.write(delimiter.join(['name', > 'text', > 'function', > '"source file"', > 'line', > 'column' > ])) > sys.stdout.write("\r\n") > > for key, value in records.items(): > sys.stdout.write(delimiter.join([value[0], > value[1], > value[2], > key[0], > key[1], > str(key[2]) > ])) > sys.stdout.write("\r\n") > else: > sys.stderr.write("No result for this analysis!\n") > > > elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch list_macros.cocci /usr/include/pipewire-0.3/pipewire/client.h > … > name|text|function|"source file"|line|column > … > PW_CLIENT_METHOD_GET_PERMISSIONS|3|something_else|/usr/include/pipewire-0.3/pipewire/client.h|98|1 > PW_CLIENT_METHOD_UPDATE_PROPERTIES|2|something_else|/usr/include/pipewire-0.3/pipewire/client.h|97|1 > … > > > Regards, > Markus >