This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Mac line ending at EOF AND no newline warnings


GCC emits no-newline warning when it sees Mac line ending
at the end of file. This is because _cpp_convert_input()
automatically inserts '\n' at the end of buffer. This
confuses _cpp_clean_line() when it sees '\r' and '\n' together.

This little patch updates _cpp_clean_line() to recognized
Mac eol by checking  buffer limit also. _cpp_clean_line() is
labeled as time-critical code with two almost identical loops
plus GOTOs and single character variable names and very little
comments, so please take a closer look.

Does it look good?

Thanks,
-
Devang


Index: lex.c =================================================================== RCS file: /cvs/gcc/gcc/libcpp/lex.c,v retrieving revision 1.2.2.7 diff -Idpatel.pbxuser -c -3 -p -r1.2.2.7 lex.c *** lex.c 17 Feb 2005 23:07:54 -0000 1.2.2.7 --- lex.c 17 Feb 2005 23:58:31 -0000 *************** _cpp_clean_line (cpp_reader *pfile) *** 134,142 **** goto done;

              /* DOS line ending? */
!             if (c == '\r' && s[1] == '\n')
                s++;
!
              if (s == buffer->rlimit)
                goto done;

--- 134,143 ----
                goto done;

              /* DOS line ending? */
!             /* Check buffer rlimit for Mac line ending. */
!             if (c == '\r' && s[1] == '\n' && (s+1) != buffer->rlimit)
                s++;
!
              if (s == buffer->rlimit)
                goto done;


0000000 / * T e s t n o n e w l i 0000020 n e a t e o f w a r n i n 0000040 g . * / \r / * { d g - d 0000060 o c o m p i l e } * / \r i 0000100 n t m a i n ( ) { r e t u 0000120 r n 0 ; } \r 0000131


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]