r285291 - Fix warnings from python difflib.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 06:46:49 PDT 2016


Author: alexfh
Date: Thu Oct 27 08:46:49 2016
New Revision: 285291

URL: http://llvm.org/viewvc/llvm-project?rev=285291&view=rev
Log:
Fix warnings from python difflib.

Modified:
    cfe/trunk/tools/clang-format/clang-format.py

Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=285291&r1=285290&r2=285291&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Thu Oct 27 08:46:49 2016
@@ -51,8 +51,8 @@ if vim.eval('exists("g:clang_format_fall
 def main():
   # Get the current text.
   encoding = vim.eval("&encoding")
-  buf = vim.current.buffer
-  text = unicode('\n'.join(buf), encoding)
+  buf = [ unicode(line, encoding) for line in vim.current.buffer ]
+  text = '\n'.join(buf)
 
   # Determine range to format.
   if vim.eval('exists("l:lines")') == '1':
@@ -99,7 +99,7 @@ def main():
     lines = stdout.decode(encoding).split('\n')
     output = json.loads(lines[0])
     lines = lines[1:]
-    sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
+    sequence = difflib.SequenceMatcher(None, buf, lines)
     for op in reversed(sequence.get_opcodes()):
       if op[0] is not 'equal':
         vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]




More information about the cfe-commits mailing list