bugwdiff - Bugs: bug #29379, wdiff hides space/tab differences

 
 

bug #29379: wdiff hides space/tab differences

Submitter:  None
Submitted:  Tue 30 Mar 2010 10:36:31 AM UTC
Votes: 100
 
Category:  None Severity:  1 - Wish
Item Group:  None Status:  None
Privacy:  Public Assigned to:  gbertran
Originator Name:  Gilles B Originator Email:  -email is unavailable-
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 26 Aug 2012 09:47:37 PM UTC, comment #3: 

Actually, here's a much better version. I've done some tests, and it seems to behave correctly.

(file #26430)

-*- <_74148>
Sun 26 Aug 2012 05:09:19 PM UTC, comment #2: 

Here's a quick hack that makes wdiff perceive spaces as words.
It's rather bad, and breaks in cases where on the left side line ends with spaces, while on the right side spaces are removed, i.e.:

left:
foo<spaces>\nbar
rigth:
foo\nbar

might have other bugs as well.

Main problem is that currently wdiff doesn't handle newlines. Instead it considers newlines to be spaces (since isspace('\n') returns non-0). When it skips whitespace, it skips both trailing spaces of a line, the newline ('\r\n' or '\n' - it makes no difference), and leading spaces on the next line.
With diffable spaces wdiff must interpret trailing spaces as a separate word, newline as newline (somehow), and leading spaces as another word.
So it's all rather messy right now.

(file #26427)

-*- <_74148>
Sun 26 Aug 2012 01:59:42 PM UTC, comment #1: 

s/some/all/

AFAIU, wdiff interprets its input as "words separated by any combination of any spaces", where a character is considered to be a "space" if isspace() says so.
Thus, spaces are not considered to be words, and are not subject to difference checks, wdiff just skips over them.

This can be fixed by changing wdiff to interpret a sequence of any kind of spaces as a word in its own right (though wdiff should remember that it's a space-word, not a normal word), and check it for differences too.

Then an option to [not to] ignore whitespace difference can be added.

-*- <_74148>
Tue 30 Mar 2010 10:36:31 AM UTC, original submission:  

some space or tab differences are hidden by wdiff.

>
> Exple:
> -- Content of A.txt : --
> \begin{figure}[t]
>        \centering
>                \includegraphics[width=0.75\linewidth]{./figures/BRPC.eps}
>        \caption{Operations of BRPC for computing a path from $s$ to $t$ with
> the minimum number of hops along the sequence AS1-AS2-AS3}
> \label{fig:BRPC}
> \end{figure}
>
> -- Content of B.txt (just an additional tab in front of \label): --
> \begin{figure}[t]
>        \centering
>                \includegraphics[width=0.75\linewidth]{./figures/BRPC.eps}
>        \caption{Operations of BRPC for computing a path from $s$ to $t$ with
> the minimum number of hops along the sequence AS1-AS2-AS3}
>        \label{fig:BRPC}
> \end{figure}
>
> -- result of wdiff: --
>> wdiff -3 a.txt b.txt
>
>
> ======================================================================
>
> -- result of diff: --
>> diff a.txt b.txt
>
> 5c5
> < \label{fig:BRPC}
> ---
>>       \label{fig:BRPC}


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #26430:  0002-spacediff.all.patch added by _74148 (7KiB - text/x-diff - A better spacediff)
file #26427:  spacediffs.patch added by _74148 (7KiB - text/x-diff - A patch that makes spaces diffable)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by _74148 (Voted in favor of this item)
  • -email is unavailable- added by _74148 (Posted a comment)
  • -email is unavailable- added by gbertran (Updated the item)
  •  

    There are 100 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-08-26 _74148 Attached File- Added 0002-spacediff.all.patch, #26430
    2012-08-26 _74148 Attached File- Added spacediffs.patch, #26427
    2012-08-26 _74148 Carbon-Copy- Added lrn
    2010-03-30 gbertran Severity3 - Normal 1 - Wish
        Assigned toNone gbertran

    Back to the top

    Powered by Savane 3.13-da57.
    Corresponding source code