public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/88424] Inserts newlines when preserving comments for a file using Windows newlines
       [not found] <bug-88424-4@http.gcc.gnu.org/bugzilla/>
@ 2024-05-25 16:49 ` peter0x44 at disroot dot org
  2024-05-25 16:55 ` peter0x44 at disroot dot org
  2024-05-25 18:20 ` peter0x44 at disroot dot org
  2 siblings, 0 replies; 3+ messages in thread
From: peter0x44 at disroot dot org @ 2024-05-25 16:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88424

--- Comment #3 from Peter Damianov <peter0x44 at disroot dot org> ---
Looking in a hex editor, what gcc is doing is changing the CRLF to LFLF, there
is no CR in the output.

  /* If the file is using old-school Mac line endings (\r only),
     terminate with another \r, not an \n, so that we do not mistake
     the \r\n sequence for a single DOS line ending and erroneously
     issue the "No newline at end of file" diagnostic.  */
  if (to.len && to.text[to.len - 1] == '\r')
    to.text[to.len] = '\r';
  else
    to.text[to.len] = '\n';

I noticed this code, but commenting it out makes the compiler fail selftests.

I'll keep looking to see if I can find the code responsible for doing that.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug preprocessor/88424] Inserts newlines when preserving comments for a file using Windows newlines
       [not found] <bug-88424-4@http.gcc.gnu.org/bugzilla/>
  2024-05-25 16:49 ` [Bug preprocessor/88424] Inserts newlines when preserving comments for a file using Windows newlines peter0x44 at disroot dot org
@ 2024-05-25 16:55 ` peter0x44 at disroot dot org
  2024-05-25 18:20 ` peter0x44 at disroot dot org
  2 siblings, 0 replies; 3+ messages in thread
From: peter0x44 at disroot dot org @ 2024-05-25 16:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88424

--- Comment #4 from Peter Damianov <peter0x44 at disroot dot org> ---
All of the non-commments are turned to LF line endings.

So it must be something specifically to do with comment processing.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug preprocessor/88424] Inserts newlines when preserving comments for a file using Windows newlines
       [not found] <bug-88424-4@http.gcc.gnu.org/bugzilla/>
  2024-05-25 16:49 ` [Bug preprocessor/88424] Inserts newlines when preserving comments for a file using Windows newlines peter0x44 at disroot dot org
  2024-05-25 16:55 ` peter0x44 at disroot dot org
@ 2024-05-25 18:20 ` peter0x44 at disroot dot org
  2 siblings, 0 replies; 3+ messages in thread
From: peter0x44 at disroot dot org @ 2024-05-25 18:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88424

--- Comment #5 from Peter Damianov <peter0x44 at disroot dot org> ---
I checked clang's behavior, and it does CRLF -> LF from non-comments, but it
leaves them intact in comments. I'm not really sure if this behavior is worth
emulating or not. I think it would be better to remove the CR from the CRLF in
comments too.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-25 18:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-88424-4@http.gcc.gnu.org/bugzilla/>
2024-05-25 16:49 ` [Bug preprocessor/88424] Inserts newlines when preserving comments for a file using Windows newlines peter0x44 at disroot dot org
2024-05-25 16:55 ` peter0x44 at disroot dot org
2024-05-25 18:20 ` peter0x44 at disroot dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).