diff options
author | Gerald Combs <gerald@wireshark.org> | 2011-04-08 19:51:39 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2011-04-08 19:51:39 +0000 |
commit | a5b20fbdf63a40b946d68175ee412506be766206 (patch) | |
tree | d3c4b02577860d2752f3223b2aaa4a40c175eb6e /tools/asn2wrs.py | |
parent | de938dddceccb5f4c1da64924a758c2d214912dc (diff) |
Add a relative path to the "#line" directives we produce. Regenerate the
SNMP and SPNEGO dissectors to see if it helps Coverity locate the
original source files.
svn path=/trunk/; revision=36522
Diffstat (limited to 'tools/asn2wrs.py')
-rwxr-xr-x | tools/asn2wrs.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/asn2wrs.py b/tools/asn2wrs.py index 0214179ae2..265c2e4e7f 100755 --- a/tools/asn2wrs.py +++ b/tools/asn2wrs.py @@ -557,6 +557,16 @@ def dependency_compute(items, dependency, map_fn = lambda t: t, ignore_fn = lamb x[e] = True return (item_ord, item_cyc) +# Given a filename, return a relative path from epan/dissectors +def rel_dissector_path(filename): + path_parts = os.path.abspath(filename).split(os.sep) + while (len(path_parts) > 3 and path_parts[0] != 'asn1'): + path_parts.pop(0) + path_parts.insert(0, '..') + path_parts.insert(0, '..') + return '/'.join(path_parts) + + #--- EthCtx ------------------------------------------------------------------- class EthCtx: def __init__(self, conform, output, indent = 0): @@ -2175,7 +2185,7 @@ class EthCnf: self.fn[name][ctx]['used'] = True out = self.fn[name][ctx]['text'] if (not self.suppress_line): - out = '#line %u "%s"\n%s\n' % (self.fn[name][ctx]['lineno'], os.path.basename(self.fn[name][ctx]['fn']), out); + out = '#line %u "%s"\n%s\n' % (self.fn[name][ctx]['lineno'], rel_dissector_path(self.fn[name][ctx]['fn']), out); return out def add_pdu(self, par, is_new, fn, lineno): @@ -2878,7 +2888,7 @@ class EthOut: fout.write(self.fhdr(out_nm)) fout.write('/* Input file: ' + os.path.basename(in_nm) +' */\n') fout.write('\n') - fout.write('#line %u "%s"\n' % (1, os.path.basename(in_nm))) + fout.write('#line %u "%s"\n' % (1, rel_dissector_path(in_nm))) include = re.compile(r'^\s*#\s*include\s+[<"](?P<fname>[^>"]+)[>"]', re.IGNORECASE) @@ -2900,12 +2910,12 @@ class EthOut: if (ifile): fout.write('\n') fout.write('/*--- Included file: ' + ifile + ' ---*/\n') - fout.write('#line %u "%s"\n' % (1, os.path.basename(ifile))) + fout.write('#line %u "%s"\n' % (1, rel_dissector_path(ifile))) finc = file(ifile, "r") fout.write(finc.read()) fout.write('\n') fout.write('/*--- End of included file: ' + ifile + ' ---*/\n') - fout.write('#line %u "%s"\n' % (cont_linenum+1, os.path.basename(in_nm)) ) + fout.write('#line %u "%s"\n' % (cont_linenum+1, rel_dissector_path(in_nm)) ) finc.close() else: fout.write(line) |