123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Term based tool to view **colored**, **incremental** diff in Git/Mercurial/Svn
  5. workspace, given patch or two files, or from stdin, with **side by side** and
  6. **auto pager** support. Requires python (>= 2.5.0) and ``less``.
  7. """
  8. META_INFO = {
  9. 'version' : '0.6',
  10. 'license' : 'BSD-3',
  11. 'author' : 'Matthew Wang',
  12. 'email' : 'mattwyl(@)gmail(.)com',
  13. 'url' : 'https://github.com/ymattw/cdiff',
  14. 'keywords' : 'colored incremental side-by-side diff',
  15. 'description' : ('View colored, incremental diff in workspace, given patch '
  16. 'or two files, or from stdin, with side by side and auto '
  17. 'pager support')
  18. }
  19. import sys
  20. if sys.hexversion < 0x02050000:
  21. raise SystemExit("*** Requires python >= 2.5.0")
  22. IS_PY3 = sys.hexversion >= 0x03000000
  23. import re
  24. import subprocess
  25. import errno
  26. import difflib
  27. COLORS = {
  28. 'reset' : '\x1b[0m',
  29. 'underline' : '\x1b[4m',
  30. 'reverse' : '\x1b[7m',
  31. 'red' : '\x1b[31m',
  32. 'green' : '\x1b[32m',
  33. 'yellow' : '\x1b[33m',
  34. 'blue' : '\x1b[34m',
  35. 'magenta' : '\x1b[35m',
  36. 'cyan' : '\x1b[36m',
  37. 'lightred' : '\x1b[1;31m',
  38. 'lightgreen' : '\x1b[1;32m',
  39. 'lightyellow' : '\x1b[1;33m',
  40. 'lightblue' : '\x1b[1;34m',
  41. 'lightmagenta' : '\x1b[1;35m',
  42. 'lightcyan' : '\x1b[1;36m',
  43. }
  44. # Keys for revision control probe, diff and log with diff
  45. VCS_INFO = {
  46. 'Git': {
  47. 'probe' : ['git', 'rev-parse'],
  48. 'diff' : ['git', 'diff'],
  49. 'log' : ['git', 'log', '--patch'],
  50. },
  51. 'Mercurial': {
  52. 'probe' : ['hg', 'summary'],
  53. 'diff' : ['hg', 'diff'],
  54. 'log' : ['hg', 'log', '--patch'],
  55. },
  56. 'Svn': {
  57. 'probe' : ['svn', 'info'],
  58. 'diff' : ['svn', 'diff'],
  59. 'log' : ['svn', 'log', '--diff', '--use-merge-history'],
  60. },
  61. }
  62. def colorize(text, start_color, end_color='reset'):
  63. return COLORS[start_color] + text + COLORS[end_color]
  64. class Hunk(object):
  65. def __init__(self, hunk_headers, hunk_meta, old_addr, new_addr):
  66. self._hunk_headers = hunk_headers
  67. self._hunk_meta = hunk_meta
  68. self._old_addr = old_addr # tuple (start, offset)
  69. self._new_addr = new_addr # tuple (start, offset)
  70. self._hunk_list = [] # list of tuple (attr, line)
  71. def append(self, hunk_line):
  72. """hunk_line is a 2-element tuple: (attr, text), where attris : '-':
  73. old, '+': new, ' ': common"""
  74. self._hunk_list.append(hunk_line)
  75. def mdiff(self):
  76. r"""The difflib._mdiff() function returns an interator which returns a
  77. tuple: (from line tuple, to line tuple, boolean flag)
  78. from/to line tuple -- (line num, line text)
  79. line num -- integer or None (to indicate a context separation)
  80. line text -- original line text with following markers inserted:
  81. '\0+' -- marks start of added text
  82. '\0-' -- marks start of deleted text
  83. '\0^' -- marks start of changed text
  84. '\1' -- marks end of added/deleted/changed text
  85. boolean flag -- None indicates context separation, True indicates
  86. either "from" or "to" line contains a change, otherwise False.
  87. """
  88. return difflib._mdiff(self._get_old_text(), self._get_new_text())
  89. def _get_old_text(self):
  90. out = []
  91. for (attr, line) in self._hunk_list:
  92. if attr != '+':
  93. out.append(line)
  94. return out
  95. def _get_new_text(self):
  96. out = []
  97. for (attr, line) in self._hunk_list:
  98. if attr != '-':
  99. out.append(line)
  100. return out
  101. def __iter__(self):
  102. for hunk_line in self._hunk_list:
  103. yield hunk_line
  104. class Diff(object):
  105. def __init__(self, headers, old_path, new_path, hunks):
  106. self._headers = headers
  107. self._old_path = old_path
  108. self._new_path = new_path
  109. self._hunks = hunks
  110. # Following detectors, parse_hunk_meta() and parse_hunk_line() are suppose
  111. # to be overwritten by derived class. No is_header() anymore, all
  112. # non-recognized lines are considered as headers
  113. #
  114. def is_old_path(self, line):
  115. return False
  116. def is_new_path(self, line):
  117. return False
  118. def is_hunk_meta(self, line):
  119. return False
  120. def parse_hunk_meta(self, line):
  121. """Returns a 2-element tuple, each of them is a tuple in form of (start,
  122. offset)"""
  123. return None
  124. def parse_hunk_line(self, line):
  125. """Returns a 2-element tuple: (attr, text), where attr is: '-': old,
  126. '+': new, ' ': common"""
  127. return None
  128. def is_old(self, line):
  129. return False
  130. def is_new(self, line):
  131. return False
  132. def is_common(self, line):
  133. return False
  134. def is_eof(self, line):
  135. return False
  136. def markup_traditional(self):
  137. """Returns a generator"""
  138. for line in self._headers:
  139. yield self._markup_header(line)
  140. yield self._markup_old_path(self._old_path)
  141. yield self._markup_new_path(self._new_path)
  142. for hunk in self._hunks:
  143. for hunk_header in hunk._hunk_headers:
  144. yield self._markup_hunk_header(hunk_header)
  145. yield self._markup_hunk_meta(hunk._hunk_meta)
  146. for old, new, changed in hunk.mdiff():
  147. if changed:
  148. if not old[0]:
  149. # The '+' char after \x00 is kept
  150. # DEBUG: yield 'NEW: %s %s\n' % (old, new)
  151. line = new[1].strip('\x00\x01')
  152. yield self._markup_new(line)
  153. elif not new[0]:
  154. # The '-' char after \x00 is kept
  155. # DEBUG: yield 'OLD: %s %s\n' % (old, new)
  156. line = old[1].strip('\x00\x01')
  157. yield self._markup_old(line)
  158. else:
  159. # DEBUG: yield 'CHG: %s %s\n' % (old, new)
  160. yield self._markup_old('-') + \
  161. self._markup_mix(old[1], 'red')
  162. yield self._markup_new('+') + \
  163. self._markup_mix(new[1], 'green')
  164. else:
  165. yield self._markup_common(' ' + old[1])
  166. def markup_side_by_side(self, width):
  167. """Returns a generator"""
  168. wrap_char = colorize('>', 'lightmagenta')
  169. def _normalize(line):
  170. return line.replace('\t', ' '*8).replace('\n', '').replace('\r', '')
  171. def _fit_with_marker(text, markup_fn, width, pad=False):
  172. """Wrap or pad input pure text, then markup"""
  173. if len(text) > width:
  174. return markup_fn(text[:width-1]) + wrap_char
  175. elif pad:
  176. pad_len = width - len(text)
  177. return '%s%*s' % (markup_fn(text), pad_len, '')
  178. else:
  179. return markup_fn(text)
  180. def _fit_with_marker_mix(text, base_color, width, pad=False):
  181. """Wrap or pad input text which contains mdiff tags, markup at the
  182. meantime with the markup_fix_fn, note only left side need to set
  183. `pad`"""
  184. out = [COLORS[base_color]]
  185. count = 0
  186. tag_re = re.compile(r'\x00[+^-]|\x01')
  187. while text and count < width:
  188. if text.startswith('\x00-'): # del
  189. out.append(COLORS['reverse'] + COLORS[base_color])
  190. text = text[2:]
  191. elif text.startswith('\x00+'): # add
  192. out.append(COLORS['reverse'] + COLORS[base_color])
  193. text = text[2:]
  194. elif text.startswith('\x00^'): # change
  195. out.append(COLORS['underline'] + COLORS[base_color])
  196. text = text[2:]
  197. elif text.startswith('\x01'): # reset
  198. out.append(COLORS['reset'] + COLORS[base_color])
  199. text = text[1:]
  200. else:
  201. # FIXME: utf-8 wchar might break the rule here, e.g.
  202. # u'\u554a' takes double width of a single letter, also this
  203. # depends on your terminal font. I guess audience of this
  204. # tool never put that kind of symbol in their code :-)
  205. #
  206. out.append(text[0])
  207. count += 1
  208. text = text[1:]
  209. if count == width and tag_re.sub('', text):
  210. # Was stripped: output fulfil and still has normal char in text
  211. out[-1] = COLORS['reset'] + wrap_char
  212. elif count < width and pad:
  213. pad_len = width - count
  214. out.append('%s%*s' % (COLORS['reset'], pad_len, ''))
  215. else:
  216. out.append(COLORS['reset'])
  217. return ''.join(out)
  218. # Setup line width and number width
  219. if width <= 0:
  220. width = 80
  221. (start, offset) = self._hunks[-1]._old_addr
  222. max1 = start + offset - 1
  223. (start, offset) = self._hunks[-1]._new_addr
  224. max2 = start + offset - 1
  225. num_width = max(len(str(max1)), len(str(max2)))
  226. left_num_fmt = colorize('%%(left_num)%ds' % num_width, 'yellow')
  227. right_num_fmt = colorize('%%(right_num)%ds' % num_width, 'yellow')
  228. line_fmt = left_num_fmt + ' %(left)s ' + COLORS['reset'] + \
  229. right_num_fmt + ' %(right)s\n'
  230. # yield header, old path and new path
  231. for line in self._headers:
  232. yield self._markup_header(line)
  233. yield self._markup_old_path(self._old_path)
  234. yield self._markup_new_path(self._new_path)
  235. # yield hunks
  236. for hunk in self._hunks:
  237. for hunk_header in hunk._hunk_headers:
  238. yield self._markup_hunk_header(hunk_header)
  239. yield self._markup_hunk_meta(hunk._hunk_meta)
  240. for old, new, changed in hunk.mdiff():
  241. if old[0]:
  242. left_num = str(hunk._old_addr[0] + int(old[0]) - 1)
  243. else:
  244. left_num = ' '
  245. if new[0]:
  246. right_num = str(hunk._new_addr[0] + int(new[0]) - 1)
  247. else:
  248. right_num = ' '
  249. left = _normalize(old[1])
  250. right = _normalize(new[1])
  251. if changed:
  252. if not old[0]:
  253. left = '%*s' % (width, ' ')
  254. right = right.lstrip('\x00+').rstrip('\x01')
  255. right = _fit_with_marker(right, self._markup_new, width)
  256. elif not new[0]:
  257. left = left.lstrip('\x00-').rstrip('\x01')
  258. left = _fit_with_marker(left, self._markup_old, width)
  259. right = ''
  260. else:
  261. left = _fit_with_marker_mix(left, 'red', width, 1)
  262. right = _fit_with_marker_mix(right, 'green', width)
  263. else:
  264. left = _fit_with_marker(left, self._markup_common, width, 1)
  265. right = _fit_with_marker(right, self._markup_common, width)
  266. yield line_fmt % {
  267. 'left_num': left_num,
  268. 'left': left,
  269. 'right_num': right_num,
  270. 'right': right
  271. }
  272. def _markup_header(self, line):
  273. return colorize(line, 'cyan')
  274. def _markup_old_path(self, line):
  275. return colorize(line, 'yellow')
  276. def _markup_new_path(self, line):
  277. return colorize(line, 'yellow')
  278. def _markup_hunk_header(self, line):
  279. return colorize(line, 'lightcyan')
  280. def _markup_hunk_meta(self, line):
  281. return colorize(line, 'lightblue')
  282. def _markup_common(self, line):
  283. return colorize(line, 'reset')
  284. def _markup_old(self, line):
  285. return colorize(line, 'lightred')
  286. def _markup_new(self, line):
  287. return colorize(line, 'lightgreen')
  288. def _markup_mix(self, line, base_color):
  289. del_code = COLORS['reverse'] + COLORS[base_color]
  290. add_code = COLORS['reverse'] + COLORS[base_color]
  291. chg_code = COLORS['underline'] + COLORS[base_color]
  292. rst_code = COLORS['reset'] + COLORS[base_color]
  293. line = line.replace('\x00-', del_code)
  294. line = line.replace('\x00+', add_code)
  295. line = line.replace('\x00^', chg_code)
  296. line = line.replace('\x01', rst_code)
  297. return colorize(line, base_color)
  298. class Udiff(Diff):
  299. def is_old_path(self, line):
  300. return line.startswith('--- ')
  301. def is_new_path(self, line):
  302. return line.startswith('+++ ')
  303. def is_hunk_meta(self, line):
  304. """Minimal valid hunk meta is like '@@ -1 +1 @@', note extra chars might
  305. occur after the ending @@, e.g. in git log
  306. """
  307. return (line.startswith('@@ -') and line.find(' @@') >= 8) or \
  308. (line.startswith('## -') and line.find(' ##') >= 8)
  309. def parse_hunk_meta(self, hunk_meta):
  310. # @@ -3,7 +3,6 @@
  311. a = hunk_meta.split()[1].split(',') # -3 7
  312. if len(a) > 1:
  313. old_addr = (int(a[0][1:]), int(a[1]))
  314. else:
  315. # @@ -1 +1,2 @@
  316. old_addr = (int(a[0][1:]), 0)
  317. b = hunk_meta.split()[2].split(',') # +3 6
  318. if len(b) > 1:
  319. new_addr = (int(b[0][1:]), int(b[1]))
  320. else:
  321. # @@ -0,0 +1 @@
  322. new_addr = (int(b[0][1:]), 0)
  323. return (old_addr, new_addr)
  324. def parse_hunk_line(self, line):
  325. return (line[0], line[1:])
  326. def is_old(self, line):
  327. """Exclude old path and header line from svn log --diff output, allow
  328. '----' likely to see in diff from yaml file
  329. """
  330. return line.startswith('-') and not self.is_old_path(line) and \
  331. not re.match(r'^-{5,}$', line.rstrip())
  332. def is_new(self, line):
  333. return line.startswith('+') and not self.is_new_path(line)
  334. def is_common(self, line):
  335. return line.startswith(' ')
  336. def is_eof(self, line):
  337. # \ No newline at end of file
  338. # \ No newline at end of property
  339. return line.startswith(r'\ No newline at end of')
  340. class PatchStream(object):
  341. def __init__(self, diff_hdl):
  342. self._diff_hdl = diff_hdl
  343. self._stream_header_size = 0
  344. self._stream_header = []
  345. # Test whether stream is empty by read 1 line
  346. line = self._diff_hdl.readline()
  347. if not line:
  348. self._is_empty = True
  349. else:
  350. self._stream_header.append(line)
  351. self._stream_header_size += 1
  352. self._is_empty = False
  353. def is_empty(self):
  354. return self._is_empty
  355. def read_stream_header(self, stream_header_size):
  356. """Returns a small chunk for patch type detect, suppose to call once"""
  357. for i in range(1, stream_header_size):
  358. line = self._diff_hdl.readline()
  359. if not line:
  360. break
  361. self._stream_header.append(line)
  362. self._stream_header_size += 1
  363. return self._stream_header
  364. def __iter__(self):
  365. for line in self._stream_header:
  366. yield line
  367. for line in self._diff_hdl:
  368. yield line
  369. class DiffParser(object):
  370. def __init__(self, stream):
  371. """Detect Udiff with 3 conditions, '## ' uaually indicates svn property
  372. changes in output from `svn log --diff`
  373. """
  374. self._stream = stream
  375. flag = 0
  376. for line in self._stream.read_stream_header(100):
  377. line = decode(line)
  378. if line.startswith('--- '):
  379. flag |= 1
  380. elif line.startswith('+++ '):
  381. flag |= 2
  382. elif line.startswith('@@ ') or line.startswith('## '):
  383. flag |= 4
  384. if (flag & 7) == 7:
  385. self._type = 'udiff'
  386. break
  387. else:
  388. raise RuntimeError('unknown diff type')
  389. def get_diff_generator(self):
  390. try:
  391. return self._parse()
  392. except (AssertionError, IndexError):
  393. raise RuntimeError('invalid patch format')
  394. def _parse(self):
  395. """parse all diff lines, construct a list of Diff objects"""
  396. if self._type == 'udiff':
  397. difflet = Udiff(None, None, None, None)
  398. else:
  399. raise RuntimeError('unsupported diff format')
  400. diff = Diff([], None, None, [])
  401. headers = []
  402. for line in self._stream:
  403. line = decode(line)
  404. if difflet.is_old_path(line):
  405. # FIXME: '--- ' breaks here, need to probe next 3 lines
  406. if diff._old_path and diff._new_path and len(diff._hunks) > 0:
  407. # One diff constructed
  408. yield diff
  409. diff = Diff([], None, None, [])
  410. diff = Diff(headers, line, None, [])
  411. headers = []
  412. elif difflet.is_new_path(line):
  413. diff._new_path = line
  414. elif difflet.is_hunk_meta(line):
  415. hunk_meta = line
  416. old_addr, new_addr = difflet.parse_hunk_meta(hunk_meta)
  417. hunk = Hunk(headers, hunk_meta, old_addr, new_addr)
  418. headers = []
  419. diff._hunks.append(hunk)
  420. elif len(diff._hunks) > 0 and (difflet.is_old(line) or \
  421. difflet.is_new(line) or difflet.is_common(line)):
  422. diff._hunks[-1].append(difflet.parse_hunk_line(line))
  423. elif difflet.is_eof(line):
  424. # ignore
  425. pass
  426. else:
  427. # All other non-recognized lines are considered as headers or
  428. # hunk headers respectively
  429. #
  430. headers.append(line)
  431. if headers:
  432. raise RuntimeError('dangling header(s):\n%s' % ''.join(headers))
  433. # Validate and yield the last patch set
  434. assert diff._old_path is not None
  435. assert diff._new_path is not None
  436. assert len(diff._hunks) > 0
  437. assert len(diff._hunks[-1]._hunk_meta) > 0
  438. yield diff
  439. class DiffMarkup(object):
  440. def __init__(self, stream):
  441. self._diffs = DiffParser(stream).get_diff_generator()
  442. def markup(self, side_by_side=False, width=0):
  443. """Returns a generator"""
  444. if side_by_side:
  445. return self._markup_side_by_side(width)
  446. else:
  447. return self._markup_traditional()
  448. def _markup_traditional(self):
  449. for diff in self._diffs:
  450. for line in diff.markup_traditional():
  451. yield line
  452. def _markup_side_by_side(self, width):
  453. for diff in self._diffs:
  454. for line in diff.markup_side_by_side(width):
  455. yield line
  456. def markup_to_pager(stream, opts):
  457. markup = DiffMarkup(stream)
  458. color_diff = markup.markup(side_by_side=opts.side_by_side,
  459. width=opts.width)
  460. # args stolen fron git source: github.com/git/git/blob/master/pager.c
  461. pager = subprocess.Popen(['less', '-FRSX'],
  462. stdin=subprocess.PIPE, stdout=sys.stdout)
  463. try:
  464. for line in color_diff:
  465. pager.stdin.write(line.encode('utf-8'))
  466. except KeyboardInterrupt:
  467. pass
  468. pager.stdin.close()
  469. pager.wait()
  470. def check_command_status(arguments):
  471. """Return True if command returns 0."""
  472. try:
  473. return subprocess.call(
  474. arguments, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
  475. except OSError:
  476. return False
  477. def revision_control_diff():
  478. """Return diff from revision control system."""
  479. for _, ops in VCS_INFO.items():
  480. if check_command_status(ops['probe']):
  481. return subprocess.Popen(ops['diff'], stdout=subprocess.PIPE).stdout
  482. def revision_control_log():
  483. """Return log from revision control system."""
  484. for _, ops in VCS_INFO.items():
  485. if check_command_status(ops['probe']):
  486. return subprocess.Popen(ops['log'], stdout=subprocess.PIPE).stdout
  487. def decode(line):
  488. """Decode UTF-8 if necessary."""
  489. try:
  490. return line.decode('utf-8')
  491. except AttributeError:
  492. return line
  493. def main():
  494. import optparse
  495. supported_vcs = sorted(VCS_INFO.keys())
  496. usage = """
  497. %prog [options]
  498. %prog [options] <patch>
  499. %prog [options] <file1> <file2>"""
  500. parser = optparse.OptionParser(usage=usage,
  501. description=META_INFO['description'],
  502. version='%%prog %s' % META_INFO['version'])
  503. parser.add_option('-s', '--side-by-side', action='store_true',
  504. help='show in side-by-side mode')
  505. parser.add_option('-w', '--width', type='int', default=80, metavar='N',
  506. help='set text width (side-by-side mode only), default is 80')
  507. parser.add_option('-l', '--log', action='store_true',
  508. help='show diff log from revision control')
  509. parser.add_option('-c', '--color', default='auto', metavar='X',
  510. help='colorize mode "auto" (default), "always", or "never"')
  511. opts, args = parser.parse_args()
  512. if opts.log:
  513. diff_hdl = revision_control_log()
  514. if not diff_hdl:
  515. sys.stderr.write(('*** Not in a supported workspace, supported '
  516. 'are: %s\n') % ', '.join(supported_vcs))
  517. return 1
  518. elif len(args) > 2:
  519. parser.print_help()
  520. return 1
  521. elif len(args) == 2:
  522. diff_hdl = subprocess.Popen(['diff', '-u', args[0], args[1]],
  523. stdout=subprocess.PIPE).stdout
  524. elif len(args) == 1:
  525. if IS_PY3:
  526. # Python3 needs the newline='' to keep '\r' (DOS format)
  527. diff_hdl = open(args[0], mode='rt', newline='')
  528. else:
  529. diff_hdl = open(args[0], mode='rt')
  530. elif sys.stdin.isatty():
  531. diff_hdl = revision_control_diff()
  532. if not diff_hdl:
  533. sys.stderr.write(('*** Not in a supported workspace, supported '
  534. 'are: %s\n\n') % ', '.join(supported_vcs))
  535. parser.print_help()
  536. return 1
  537. else:
  538. diff_hdl = sys.stdin
  539. stream = PatchStream(diff_hdl)
  540. # Don't let empty diff pass thru
  541. if stream.is_empty():
  542. return 0
  543. if opts.color == 'always' or (opts.color == 'auto' and sys.stdout.isatty()):
  544. try:
  545. markup_to_pager(stream, opts)
  546. except IOError:
  547. e = sys.exc_info()[1]
  548. if e.errno == errno.EPIPE:
  549. pass
  550. else:
  551. # pipe out stream untouched to make sure it is still a patch
  552. for line in stream:
  553. sys.stdout.write(decode(line))
  554. if diff_hdl is not sys.stdin:
  555. diff_hdl.close()
  556. return 0
  557. if __name__ == '__main__':
  558. sys.exit(main())
  559. # vim:set et sts=4 sw=4 tw=80: