commit 15bfa564b9db08fb277a343a3d0a01d377800606 Author: Matthew Wang Date: Thu Jan 31 15:27:17 2013 +0800 Default width is now 80 diff --git a/src/cdiff.py b/src/cdiff.py index 13f725f..bf15ef1 100755 --- a/src/cdiff.py +++ b/src/cdiff.py @@ -128,9 +128,7 @@ class Diff(object): yield self._markup_common(' ' + old[1]) def markup_side_by_side(self, width): - """width of 0 means infinite width, None means auto detect. Returns a - generator - """ + """Returns a generator""" def _normalize(line): return line.replace('\t', ' ' * 8).replace('\n', '') @@ -147,7 +145,8 @@ class Diff(object): return markup # Setup line width and number width - if not width: width = 80 + if width <= 0: + width = 80 (start, offset) = self._hunks[-1].get_old_addr() max1 = start + offset - 1 (start, offset) = self._hunks[-1].get_new_addr() @@ -430,13 +429,10 @@ if __name__ == '__main__': parser = optparse.OptionParser(usage) parser.add_option('-s', '--side-by-side', action='store_true', help=('show in side-by-side mode')) - parser.add_option('-w', '--width', type='int', default=None, - help='set line width (side-by-side mode only)') + parser.add_option('-w', '--width', type='int', default=80, + help='set line width (side-by-side mode only), default is 80') opts, args = parser.parse_args() - if opts.width and opts.width < 0: - opts.width = 0 - if len(args) >= 1: diff_hdl = open(args[0], 'r') elif sys.stdin.isatty():