Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Gltokensp06 Guest

    Default Ignoring Line Differences

    I'm sure this has been asked and answered before but I just can't find it in the forums. My question is, how do you ignore line differences while using BC3. I'm personally using PDF files so for example: This is file 1 compared to file 2




    My problem is, is that what i'm comparing, the lines are gonna be different the text is going to be the same. So is there a way to tell the session to ignore those differences so there isn't red everywhere on the screen?
    Last edited by Gltokensp06; 31-Mar-2009 at 09:25 AM.

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,908

    Default

    Hello,

    Beyond Compare uses the different lines to perform the alignment, and then compares those lines. It is not possible to ignore line endings (that option ignores the 'type' of line ending, not where they occur).

    Often, users will run a script or conversion that will sort their data in a comparable way.

    Would you be able to email your example files, your support package (Help menu -> Support; Export), and a link to this forum post? We could look at your PDF files and try to determine exactly why there are line breaks there.
    Aaron P Scooter Software

  3. #3
    Join Date
    Aug 2009
    Location
    Lexington, MA
    Posts
    6

    Default

    Paragraph detection would be a nice feature, and not all that hard to add (certainly much less trouble than implementing PDF comparison in the first place). This problem also comes up in text documents that are hard-filled (e.g. README files designed for terminal reading), but have skipped lines between paragraphs. All BC would need to be able to do would be to strip the single new lines, and leave breaks between paragraphs.

    In other words, I want an option to treat single line separators as whitespace differences (ignorable), and double line separators as single line breaks. In source code, it makes sense to use single line breaks as the unit of decomposition, but in prose, (especially when different layout engines may have gotten involved), it really isn't.

    My current solution to copy the text from the pdf, run a regex replacement on the pairs of newlines new lines in each version (say with <<TEMP_PARAGRAPH_BREAK>>), delete all the single newlines, then replace the temporary break pattern with an actual line ending.

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,908

    Default

    Thanks for the suggestion. This is on our Customer Wishlist, and I've added your notes to the entry.

    If you are able to perform that conversion from the command line, bat file, or script, you could create a custom Conversion for BC3 to use and call each time you open your specific file format. The bat file could call BC3's PDF conversion line, then format that file the way you want for comparison purposes and return that temp file. Make sure the file format is read-only to prevent accidental saving.
    Aaron P Scooter Software

  5. #5
    Join Date
    Jun 2007
    Posts
    3

    Default Source Code Too

    My scenario is to make differences due to source code formatting ignorable. For instance, in C# source, I'd like

    MethodCall(1, 2, 3, 4);

    to be the same as

    MethodCall(
    1,
    2,
    3,
    4);

    I'm intrigued by an earlier reply about conversions: I hadn't looked into them before. Unfortunately, it would take a week or so for me to come up with the code to recognize statements and write them out with the newlines replaced by space. I'd also want to be able to recognize other multi-line structures, for instance:

    public class SomeClass<T1, T2>
    where T1 : constraint
    where T2 : constraint
    {
    }

    should be the same as

    public class SomeClass<T1, T2> where T1 : constraint where T2 : constraint
    {
    }

  6. #6
    Join Date
    Nov 2011
    Posts
    1

    Default Any progress on this?

    In many languages and file formats newlines are treated as ordinary whitespace. There are some odd exceptions and that always makes it harder to get completely right.

    It'd be helpful to have an option that would make one pass through the changes and reclassify blocks that are purely newline and whitespace as unimportant changes.

  7. #7
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,908

    Default

    Hello,

    Such a process is dependent on your current files (such as programming language or structure). We support an external conversion to perform this pass, and have several for download in our additional and alternative file formats. This is functionality we would like to build into BC3, but is not currently supported.
    Aaron P Scooter Software

  8. #8
    Join Date
    Sep 2015
    Posts
    3

    Default any progress on this ?

    Hello,

    Was this feature actually implemented ?

    Indeed, we have to compare large .ptu files (IBM Rational Test RealTime scripts) and this file format has the capacity to split a line into several by escaping them with a "&". So, we have plenty of files which differ only on the positions of line breaks, and we would really need it such a feature. Unfortunately, I cannot find it in BC4.

    Even if .ptu file format is quite uncommon, I think that such a feature would also be a great help for considering as non-important the differences on, for example, the verbatim string literals in C# and C++11, or more generally speaking, because most programming languages treat the line breaks as whitespace.

  9. #9
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,908

    Default

    Hello,

    BC4 does not currently support comparing across line breaks. We use External Conversions to help reorganize and normalize whitespace for comparisons. We have a few available for download on our downloads page, but do not have one available for PTU files. We do have a KB article that helps and goes into detail on defining any custom command line tool, using RESX files as the example:
    http://www.scootersoftware.com/suppo...rnalconversion
    Aaron P Scooter Software

  10. #10
    Join Date
    Sep 2015
    Posts
    3

    Default

    Hello,

    Thank you for the workaround you suggested.

    So, I wrote a very basic Windows PowerShell script ("Normalize-PTU.ps1") to normalize the lines by concatenating the instructions split across several lines :

    Code:
    if ( $args.Length -ne 2 )
    {
        echo "args.Length /= 2 !"
        exit;
    }
    
    $source = $args[0]
    $target = $args[1]
    
    if ( ! ( Test-Path $source -pathType leaf ) )
    {
        echo "source file does not exist !"
        exit;
    }
    
    ( Get-Content $source -Raw ) -replace ("`r`n\s*&\s*"," ") | Set-Content ( $target + ".normalized" )
    And, since Beyond Compare seems to handle only Batch scripts, I also wrote a Batch wrapper script ("Normalize-PTU.bat") to call the Windows PowerShell script :

    Code:
    @echo off
    
    powershell -File Normalize-PTU.ps1 %1 %2
    When I run the Batch file manually (for example with the command "Normalize-PTU.bat my_source_file.ptu my_target_file.ptu"), everything goes well, with the target file being created with the expected contents.

    However, when trying to use it via Beyond Compare, I get a "conversion error" message in both the left pane and the right pane of the window :

    Beyond_Compare.png

    Here is the configuration I set up :

    Beyond_Compare_1.png
    Beyond_Compare_2.png

    Is there anything I missed ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •