#52 diff cannot compare unix and msdos files

closed
MSYS (18)
5
2005-08-17
2005-07-07
LBorgman
No

I did a test and let diff compare files with unix and
msdos line endings. It turns out that MSYS diff cannot
compare unix files with msdos files. By contrast
GnuWin32 diff handles this in a useful manner and
compare the files regardless of the line endings. It
would be very useful if MSYS diff did the same. (Can't
the code in GnuWin32 be reused here?)

This is the output from MSYS diff -c for the four
possible combinations of line endings (GnuWin32 diff
produces the same output for all cases):

12dd.diff

*** orig1-dos.txt Wed Jul 6 22:28:34 2005
--- orig2-dos.txt Wed Jul 6 22:36:57 2005
***************
*** 1,3 ****
This is original file first line.
- Second (maybe missing).
Third line.
--- 1,2 ----

12du.diff

*** orig1-dos.txt Wed Jul 6 22:28:34 2005
--- orig2-ux.txt Wed Jul 6 22:34:42 2005
***************
*** 1,3 ****
! This is original file first line.
! Second (maybe missing).
! Third line.
--- 1,2 ----
! This is original file first line.
! Third line.

12ud.diff

*** orig1-ux.txt Wed Jul 6 22:28:54 2005
--- orig2-dos.txt Wed Jul 6 22:36:57 2005
***************
*** 1,3 ****
! This is original file first line.
! Second (maybe missing).
! Third line.
--- 1,2 ----
! This is original file first line.
! Third line.

12uu.diff

*** orig1-ux.txt Wed Jul 6 22:28:54 2005
--- orig2-ux.txt Wed Jul 6 22:34:42 2005
***************
*** 1,3 ****
This is original file first line.
- Second (maybe missing).
Third line.
--- 1,2 ----

Discussion

  • Earnie Boyd

    Earnie Boyd - 2005-07-07
    • labels: 380073 --> MSYS
     
  • Earnie Boyd

    Earnie Boyd - 2005-07-07
    • milestone: --> Waiting_user_response
    • status: open --> pending
     
  • Earnie Boyd

    Earnie Boyd - 2005-07-07

    Logged In: YES
    user_id=15438

    A file with foo\n as compared with foo\r\n are indeed
    different and the mSys diff does a great job at finding the
    difference. Given that the files are indeed different;
    doesn't that make the gnuwin32 diff buggy? ;)

    The mSys diff -w option will treat \r as white space. Use
    the -w switch if you have one file in dos format and the
    other in unix format.

    Earnie

     
  • LBorgman

    LBorgman - 2005-07-07

    Logged In: YES
    user_id=1131370

    Yes it would. However, it is not even remotely close to being even on a low priority list for our developers.
    If you would like to contribute such an item we would consider offering it for general use. Thank you for
    your interest in MinGW.

     
  • LBorgman

    LBorgman - 2005-07-07
    • status: pending --> open
     
  • LBorgman

    LBorgman - 2005-07-07

    Logged In: YES
    user_id=1131370

    I have been thinking about your suggestion (using "diff
    -w"), but unfortunately it does not fit the needs. -w will
    not let you see whitespace changes and that is essential.

    There is of course nothing that is wrong or write here. The
    question is rather what is more useful. I think it is much
    more useful to use the approach GnuWin32 has choosen. It is
    also more intuitive. Many text editors shows the same text
    regardless of the line endings. (Some fail to handle it at
    all.)

    If you want to test line endings that could be done with
    other tools. From a user perspective I think of diff as a
    tool for comparing text, not line endings. I would like to
    be able to compare the text of two files regardless of their
    line endings.

    Best,
    Lennart

     
  • Earnie Boyd

    Earnie Boyd - 2005-07-07

    Logged In: YES
    user_id=15438

    How do emacs users in the UNIX environment handle text files
    with differing line endings? Yes I know we are not on UNIX.
    MSYS forces all files to be opened in binary mode. It
    works well 99.9% of the time. Your experience with diff is
    part of the .1%. I would be willing to accept patches to
    modify diff for a --ignore-cr or some other similarly named
    switch. I looked at that option when I decided to treat \r
    as whitespace and decided it was more work than I wanted to
    spend time to fix.

    Earnie

     
  • Earnie Boyd

    Earnie Boyd - 2005-07-07
    • status: open --> pending
     
  • Earnie Boyd

    Earnie Boyd - 2005-07-16

    Logged In: YES
    user_id=15438

    Ping lborgman

    Any further comment? Are you contemplating a patch for the
    MSYS diff?

    Earnie

     
  • LBorgman

    LBorgman - 2005-07-17
    • status: pending --> open
     
  • LBorgman

    LBorgman - 2005-07-17

    Logged In: YES
    user_id=1131370

    Hi Earnie, no but I am trying to understand the matter. I
    believe that diff should open the files in text mode, not
    binary (as I guess MSYS diff does today), because it is what
    the user regards as text that he/she probably wants to
    compare. If I understands things correctly this is how
    GnuWin32 diff opens files.

    What do you think about this? Could you change the open mode
    to text?

     
  • Earnie Boyd

    Earnie Boyd - 2005-07-17

    Logged In: YES
    user_id=15438

    MSYS opens all files in binary mode. So if the binary is
    msys dependent it doesn't have a chance to be different,
    i.e. open in text mode. MSYS' diff is correct in that the
    files, one in unix line ending mode and one in dos line
    ending mode are different. A unix system diff would treat
    the files the same way. MSYS is emulating unix and is
    correctly identifying the difference. The problem now
    becomes how to become how to coordinate the differences
    between UNIX and Windows. A MSYS specific change to diff to
    specify that \r\n is to be treated as \n in all cases is
    what I would accept as a change.

    Earnie

     
  • Earnie Boyd

    Earnie Boyd - 2005-07-17
    • status: open --> pending
     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 30 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending --> closed
     

Log in to post a comment.