File: 08_516143_xml_is_text.patch

package info (click to toggle)
xxdiff 1%3A4.0%2Bhg437%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,124 kB
  • ctags: 2,397
  • sloc: cpp: 18,485; python: 6,088; ansic: 1,535; sh: 1,533; perl: 308; lex: 284; yacc: 277; lisp: 250; tcl: 213; makefile: 82
file content (24 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Description: Don't classify XML files as non-text
 thanks "J.P. Delport" <jpdelport@csir.co.za> for the bug 
 report #516143 and the patch.
Author: Y Giridhar Appaji Nag <appaji@debian.org>

--- a/lib/python/xxdiff/utils.py
+++ b/lib/python/xxdiff/utils.py
@@ -52,6 +52,7 @@
 # options were taken from Ian F. Darwin's file implementation.
 guesscmd = ['file', '-b', '-L']
 text_re = re.compile('\\btext\\b')
+xml_re = re.compile('\\bXML\\b')
 empty_re = re.compile('^empty$')
 
 def istextfile(fn):
@@ -68,7 +69,7 @@
     if p.returncode != 0 or stderr or stdout.startswith('cannot open'):
         raise RuntimeError("Error: running 'file' on '%s'." % fn)
 
-    return bool(text_re.search(stdout) or empty_re.match(stdout))
+    return bool(text_re.search(stdout) or xml_re.search(stdout) or empty_re.match(stdout))
 
 
 def makedirs(dirn, error_on_exist=True):