[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Which Diff tool could I use for visually comparing two text files where Word Wrap is possible?



On Tue, 4 Apr 2023 davidson@freevolt.org wrote:
On Tue, 4 Apr 2023 davidson wrote:
[trim]
icdiff will not do that. icdiff is faithful to its sources. I have
determined this by trying it out a little myself, and by examining the
command line options documented in its manual page ("man icdiff").

You could give it different sources:

$ icdiff <( tr '\n' ' ' <file1 ) <( tr '\n' ' ' <file2 )

You can define a function to do the same thing, to save some typing at
future invocations,

Typos ahead:

True.

$ icdiff-flowed () { <( tr '\n' ' ' <file1 ) <( tr '\n' ' ' <file2 ) ; }

Correction:

$ icdiff-flowed () { <( tr '\n' ' ' <"$1" ) <( tr '\n' ' ' <"$2" ) ; }

Yet another correction:

 $ icdiff-flowed () { icdiff <( tr '\n' ' ' <"$1" ) <( tr '\n' ' ' <"$2" ) ; }

and then use it like so

$ icdiff-flowed file1 file2 | less -R

And a caveat:

I recall that the files you are comparing are quite large.

The above worked on okay on about 1000 line files with about 50,000
characters.

But I would not use it with significantly larger files.

  $ wc -l vinge_1981_true_names.*html # how many lines
  3688 vinge_1981_true_names.html
  4152 vinge_1981_true_names.parafix.html

  $ du -h vinge_1981_true_names.*html
  176K    vinge_1981_true_names.html
  176K    vinge_1981_true_names.parafix.html

I think those were too big:

  $ icdiff-flowed vinge_1981_true_names.html vinge_1981_true_names.parafix.html >vinge_1981_true_names.icdiff_flowed
 Traceback (most recent call last):
  File "/usr/bin/icdiff", line 11, in <module>
    load_entry_point('icdiff==1.9.5', 'console_scripts', 'icdiff')()
  File "/usr/lib/python3/dist-packages/icdiff.py", line 598, in start
    diff(options, *args)
  File "/usr/lib/python3/dist-packages/icdiff.py", line 635, in diff
    diff_files(options, a, b)
  File "/usr/lib/python3/dist-packages/icdiff.py", line 764, in diff_files
    for line in cd.make_table(
  File "/usr/lib/python3/dist-packages/icdiff.py", line 350, in make_table
    for left, right in self._generate_table(fromdesc, todesc, diffs):
  File "/usr/lib/python3/dist-packages/icdiff.py", line 360, in _generate_table
    for i, line in enumerate(diffs):
  File "/usr/lib/python3/dist-packages/icdiff.py", line 255, in _collect_lines
    for fromdata, todata, flag in diffs:
  File "/usr/lib/python3/dist-packages/icdiff.py", line 232, in _line_wrapper
    self._split_line(fromlist, fromline, fromtext)
  File "/usr/lib/python3/dist-packages/icdiff.py", line 217, in _split_line
    self._split_line(data_list, '>', line2)
  File "/usr/lib/python3/dist-packages/icdiff.py", line 217, in _split_line
    self._split_line(data_list, '>', line2)
  File "/usr/lib/python3/dist-packages/icdiff.py", line 217, in _split_line
    self._split_line(data_list, '>', line2)
  [Previous line repeated 984 more times]
  File "/usr/lib/python3/dist-packages/icdiff.py", line 180, in _split_line
    if ((self._display_len(text) - (text.count('\0') * 3) <=
  File "/usr/lib/python3/dist-packages/icdiff.py", line 163, in _display_len
    return sum(width(c) for c in s)
  File "/usr/lib/python3/dist-packages/icdiff.py", line 163, in <genexpr>
    return sum(width(c) for c in s)
  File "/usr/lib/python3/dist-packages/icdiff.py", line 156, in width
    if ((isinstance(c, type(u"")) and
RecursionError: maximum recursion depth exceeded while calling a Python object

--
Sometimes it pays to have squirrels in your head running around making
you question everything.  -- Clive Robinson


Reply to: