bugGNU nano - Bugs: bug #51760, unindent mishandles some blank...

 
 

bug #51760: unindent mishandles some blank lines with a tab's worth of whitespace

Submitted by:  David Lawrence Ramsey <dolorous>
Submitted on:  Tue 15 Aug 2017 08:13:52 PM UTC  
 
Severity: 3 - NormalStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 16 Aug 2017 03:23:53 PM UTC, comment #2:

I suppose your fix works, but it adds unneeded code. I have pushed a simpler fix in commit bd770ea2.

And closing, because an unreleased bug.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 15 Aug 2017 08:18:10 PM UTC, comment #1:

The problem is caused by do_unindent()'s check for a line's containing less than a tab's worth of whitespace: it compares tabsize (the number of columns that make up a tab's worth of space) with indent_len (the number of bytes that make up a tab's worth of space). If the indentation consists of anything other than tabsize spaces, the comparison will erroneously fail.

The attached patch fixes this by using strnlenpt() on indent_len, so as to compare columns to columns.

(file #41532)

David Lawrence Ramsey <dolorous>
Project Administrator
Tue 15 Aug 2017 08:13:52 PM UTC, original submission:

Currently, as of git 8b86af3, the newly overhauled unindent doesn't properly unindent all blank lines that contain less than a tab's worth of whitespace. This can be reproduced as follows, with the attached file.

1. In an 80x24 terminal, run:

./nano --ignore --nonewlines unindent-test.txt

2. Press Meta-P to turn on whitespace display.

3. Press Ctrl-^ to turn the mark on.

4. Press PageDown once, in order to highlight all lines of the file containing indentation.

5. Press Meta-{ to unindent, followed by Meta-} to indent again. Do this several times in succession, and you'll notice that every other lines besides line 1 and the blank line following it (which contain indentation consisting only of spaces) are affected by indent, but unaffected by unindent, despite the fact that all lines contain a tab's worth of whitespace.

David Lawrence Ramsey <dolorous>
Project Administrator

 

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

Attach File(s):
   
   
Comment:
   

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bens (Posted a comment)
  • -unavailable- added by dolorous (Submitted 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 0 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 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 16 Aug 2017 03:23:53 PM UTCbensStatusNone=>Fixed
      Assigned toNone=>bens
      Open/ClosedOpen=>Closed
    Tue 15 Aug 2017 08:18:10 PM UTCdolorousAttached File-=>Added 0001-text-fix-unindent-s-handling-of-blank-lines.patch, #41532
    Tue 15 Aug 2017 08:14:22 PM UTCdolorousSummaryunindent mishandles some blank lines with less than a tab's worth of whitespace=>unindent mishandles some blank lines with a tab's worth of whitespace
    Tue 15 Aug 2017 08:13:52 PM UTCdolorousAttached File-=>Added unindent-test.txt, #41531

    Back to the top


    Powered by Savane 3.1-cleanup1