bugGNU nano - Bugs: bug #58357, a lone CR in a DOS file gets...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #58357: a lone CR in a DOS file gets mistreated

Submitter:  Benno Schulenberg <bens>
Submitted:  Tue 12 May 2020 02:20:27 PM UTC
   
 
Severity:  2 - Minor Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Tue 12 May 2020 04:58:37 PM UTC, comment #2: 

Fixed in git, commit ac0f2c94.

And final paragraph of comment #1 is implemented in the subsequent commit, fcbf8588.

Benno Schulenberg <bens>
Group administrator
Tue 12 May 2020 02:30:51 PM UTC, comment #1: 

Forgot to mention: after opening the file again with nano, type: ^O. See that the prompts just says: "File Name to Write: README".  It does not say "[DOS Format]" nor "[Mixed Format]" nor anything of the kind.  Which means that upon pressing <Enter>, the file gets saved in Unix format.  This is absurd!  Nano should at least preserve one of the two formattings: DOS or Mac.

So... when reading in a file, nano should never mark a file as mixed format.  It should stick to DOS format when the first \r was followed by a \n; should stick to Mac format when the first \r was NOT followed by a \n; and should stick to Unix format when \n was seen before any \r.

Benno Schulenberg <bens>
Group administrator
Tue 12 May 2020 02:20:27 PM UTC, original submission:  

To reproduce, first run:

src/nano --ignore +7,33 README

Then type: M-V ^M ^O M-D <Enter> ^X

Now first look at the README file with Vim and Emacs and Less.  See that they all show the file like it was shown in nano before we pressed ^X  (except that these other programs highlight the ^M in some way, which is nicer, but... let it be).

Now open the file again with nano: 'src/nano --ignore README'...  Oops!  Nano has removed the ^M and broken the line in two at that spot.  :/

On the status bar it says: "Read 80 lines (Converted from DOS and Mac format)".  But... does that ever occur: a mixed DOS and Mac formatted file?  Would it not always be either a DOS file with some stray CR, or a Mac file with some stray LF?

Anyway, this is the DOS-format equivalent of the Unix-format bug that was reported in https://bugs.launchpad.net/ubuntu/+source/nano/+bug/62666 (lone CR in Unix shell script) and was fixed by David in commit cfd4b89f in November 2007.

Benno Schulenberg <bens>
Group administrator

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Submitted the item)
  •  

    There are 0 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.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-07-30 bens Open/ClosedOpen Closed
    2020-05-12 bens StatusNone Fixed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code