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

 
 

bug #29379: wdiff hides space/tab differences

Submitted by:  None
Submitted on:  Tue 30 Mar 2010 10:36:31 AM UTC  
Votes:  100  
 
Category: NoneSeverity: 1 - Wish
Item Group: NoneStatus: None
Privacy: PublicAssigned to: Gilles B. <gbertran>
Originator Name: Gilles BOriginator Email: -unavailable-
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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)

LRN <lrn>
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)

LRN <lrn>
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.

LRN <lrn>
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 File(s):
   
   
Comment:
   

Attached Files
file #26430:  0002-spacediff.all.patch added by lrn (7kB - text/x-diff - A better spacediff)
file #26427:  spacediffs.patch added by lrn (7kB - 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
  • -unavailable- added by lrn (Voted in favor of this item)
  • -unavailable- added by lrn (Posted a comment)
  • -unavailable- added by gbertran (Updated the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 100 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 26 Aug 2012 09:47:37 PM UTClrnAttached File-=>Added 0002-spacediff.all.patch, #26430
    Sun 26 Aug 2012 05:09:19 PM UTClrnAttached File-=>Added spacediffs.patch, #26427
    Sun 26 Aug 2012 02:00:10 PM UTClrnCarbon-Copy-=>Added lrn
    Tue 30 Mar 2010 10:42:10 AM UTCgbertranSeverity3 - Normal=>1 - Wish
      Assigned toNone=>gbertran

    Back to the top


    Powered by Savane 3.1-cleanup