bugGNU source-highlight - Bugs: bug #33354, additional line endings

 
 

bug #33354: additional line endings

Submitted by:  Lorenzo Bettini <bettini>
Submitted on:  Fri 20 May 2011 01:48:59 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Works For Me
Privacy: PublicAssigned to: Lorenzo Bettini <bettini>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Fri 02 Sep 2011 12:01:46 PM UTC, comment #2:

Actually source-highlight does not fix input files, nor it adds any extra lines: it looks like it's the editors that automatically fix C files which do not have the blank line at the end!

For instance, take a look at the attached input files (test_no_line_at_the_end.c was created manually using a 'cat' command and by making sure to issue a ^D after the line, while test_line_at_the_end.c is the same file opened with Emacs and saved by not adding the newline - the same happened also in Eclipse), and now see the diff

diff test_no_line_at_the_end.c test_line_at_the_end.c
1c1
< #include <stdio.h>
\ No newline at end of file
---

> #include <stdio.h>


as you see the new blank line was added by the editor. Source-highlight correctly highlights the blank line, but does not add a new one if not present (see also the corresponding output files).

This does not happen with Java files, for instance (in Emacs and Eclipse).

(file #23926, file #23927, file #23928, file #23929)

Lorenzo Bettini <bettini>
Project AdministratorIn charge of this item.
Fri 02 Sep 2011 10:50:36 AM UTC, comment #1:

Bogus.cpp Bogus.html C++ files
hello.c hello.html C files
Makefile - invocation of source-highlight

All files use Unix line endings.

BUG: html output has an "extra" line beyond the 1 blank line in the C/C++ input file(s) when using --line-number.

Since the C/C++ standard requires a blank line at the end of each file, and because source-highlight "fixes" those input files that fail to do this by adding a blank line, the parser/formatter produces incorrect output for conforming code while quietly "fixing" non-conforming code.

Lorenzo Bettini <bettini>
Project AdministratorIn charge of this item.
Fri 20 May 2011 01:48:59 PM UTC, original submission:
Lorenzo Bettini <bettini>
Project AdministratorIn charge of this item.

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #23926:  test_no_line_at_the_end.c added by bettini (18B - application/octet-stream)
file #23928:  test_line_at_the_end.c added by bettini (19B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bettini (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 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 25 Dec 2011 09:56:10 AM UTCbettiniOpen/ClosedOpen=>Closed
    Fri 02 Sep 2011 12:03:28 PM UTCbettiniStatusNone=>Works For Me
      Assigned toNone=>bettini
    Fri 02 Sep 2011 12:01:46 PM UTCbettiniAttached File-=>Added test_no_line_at_the_end.c, #23926
      Attached File-=>Added test_no_line_at_the_end.c.html, #23927
      Attached File-=>Added test_line_at_the_end.c, #23928
      Attached File-=>Added test_line_at_the_end.c.html, #23929

    Back to the top


    Powered by Savane 3.1-cleanup1