123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. commit 15bfa564b9db08fb277a343a3d0a01d377800606
  2. Author: Matthew Wang <XXXXXXX@gmail.com>
  3. Date: Thu Jan 31 15:27:17 2013 +0800
  4. 
  5.  Default width is now 80
  6. 
  7. diff --git a/src/cdiff.py b/src/cdiff.py
  8. index 13f725f..bf15ef1 100755
  9. --- a/src/cdiff.py
  10. +++ b/src/cdiff.py
  11. @@ -128,9 +128,7 @@ class Diff(object):
  12.  yield self._markup_common(' ' + old[1])
  13. 
  14.  def markup_side_by_side(self, width):
  15. - """width of 0 means infinite width, None means auto detect. Returns a
  16. + """Returns a generator"""
  17. - generator
  18. - """
  19.  def _normalize(line):
  20.  return line.replace('\t', ' ' * 8).replace('\n', '')
  21. 
  22. @@ -147,7 +145,8 @@ class Diff(object):
  23.  return markup
  24. 
  25.  # Setup line width and number width
  26. - if not width: width = 80
  27. + if width <= 0:
  28. + width = 80
  29.  (start, offset) = self._hunks[-1].get_old_addr()
  30.  max1 = start + offset - 1
  31.  (start, offset) = self._hunks[-1].get_new_addr()
  32. @@ -430,13 +429,10 @@ if __name__ == '__main__':
  33.  parser = optparse.OptionParser(usage)
  34.  parser.add_option('-s', '--side-by-side', action='store_true',
  35.  help=('show in side-by-side mode'))
  36. - parser.add_option('-w', '--width', type='int', default=None,
  37. + parser.add_option('-w', '--width', type='int', default=80,
  38. - help='set line width (side-by-side mode only)')
  39. + help='set line width (side-by-side mode only), default is 80')
  40.  opts, args = parser.parse_args()
  41. -
  42. - if opts.width and opts.width < 0:
  43. - opts.width = 0
  44. 
  45.  if len(args) >= 1:
  46.  diff_hdl = open(args[0], 'r')
  47.  elif sys.stdin.isatty():
  48.