X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=scripts%2Ftracediff.py;h=26395879a10b8c54f3308f6a3a8eeab2e5506414;hb=44d6e82ea0c10fe5c798b22fa25c2186dc77a6c0;hp=b3933a9d59ee1b11a5e6b0b9b81327345d9aa4ca;hpb=ee659c84695e9f94b1f6a5f8be203dc0012ca685;p=apitrace diff --git a/scripts/tracediff.py b/scripts/tracediff.py index b3933a9..2639587 100755 --- a/scripts/tracediff.py +++ b/scripts/tracediff.py @@ -70,6 +70,8 @@ else: def diff(ref_trace, src_trace): + isatty = sys.stdout.isatty() + ref_dumper = Dumper(ref_trace, options.ref_calls) src_dumper = Dumper(src_trace, options.src_calls) @@ -78,6 +80,9 @@ def diff(ref_trace, src_trace): diff_args = [ 'diff', '--speed-large-files', + ] + if isatty: + diff_args += [ '--old-line-format=' + start_delete + '%l' + end_delete + '\n', '--new-line-format=' + start_insert + '%l' + end_insert + '\n', ] @@ -92,6 +97,9 @@ def diff(ref_trace, src_trace): 'wdiff', #'--terminal', '--avoid-wraps', + ] + if isatty: + diff_args += [ '--start-delete=' + start_delete, '--end-delete=' + end_delete, '--start-insert=' + start_insert, @@ -105,7 +113,7 @@ def diff(ref_trace, src_trace): src_dumper.dump.wait() less = None - if sys.stdout.isatty(): + if isatty: less = subprocess.Popen( args = ['less', '-FRXn'], stdin = subprocess.PIPE @@ -124,6 +132,7 @@ def diff(ref_trace, src_trace): diff.wait() if less is not None: + less.stdin.close() less.wait() @@ -183,7 +192,7 @@ def main(): help="calls to compare from source trace") optparser.add_option( '-w', '--width', metavar='NUM', - type="string", dest="width", default=default_width, + type="int", dest="width", default=default_width, help="columns [default: %default]") global options