|
@@ -13,6 +13,7 @@ import sys
|
13
|
13
|
if sys.hexversion < 0x02050000:
|
14
|
14
|
sys.stderr.write("ERROR: requires python >= 2.5.0\n")
|
15
|
15
|
sys.exit(1)
|
|
16
|
+_is_py3 = sys.hexversion >= 0x03000000
|
16
|
17
|
|
17
|
18
|
import os
|
18
|
19
|
import re
|
|
@@ -160,7 +161,7 @@ class Diff(object):
|
160
|
161
|
out.append(patt.sub(r'\1', markup))
|
161
|
162
|
markup = patt.sub(r'\3', markup)
|
162
|
163
|
else:
|
163
|
|
- # FIXME: utf-8 char broken here
|
|
164
|
+ # FIXME: utf-8 wchar broken here
|
164
|
165
|
out.append(markup[0])
|
165
|
166
|
markup = markup[1:]
|
166
|
167
|
count += 1
|
|
@@ -468,7 +469,11 @@ if __name__ == '__main__':
|
468
|
469
|
opts, args = parser.parse_args()
|
469
|
470
|
|
470
|
471
|
if len(args) >= 1:
|
471
|
|
- diff_hdl = open(args[0], 'r')
|
|
472
|
+ if _is_py3:
|
|
473
|
+ # Python3 needs the newline='' to keep '\r' (DOS format)
|
|
474
|
+ diff_hdl = open(args[0], mode='rt', newline='')
|
|
475
|
+ else:
|
|
476
|
+ diff_hdl = open(args[0], mode='rt')
|
472
|
477
|
elif sys.stdin.isatty():
|
473
|
478
|
sys.stderr.write('Try --help option for usage\n')
|
474
|
479
|
sys.exit(1)
|
|
@@ -477,6 +482,7 @@ if __name__ == '__main__':
|
477
|
482
|
|
478
|
483
|
# FIXME: can't use generator for now due to current implementation in parser
|
479
|
484
|
stream = diff_hdl.readlines()
|
|
485
|
+
|
480
|
486
|
# Don't let empty diff pass thru
|
481
|
487
|
if not stream:
|
482
|
488
|
sys.exit(0)
|