Commit 04c90eea by Devang Patel Committed by Devang Patel

charset.c (_cpp_convert_input): Check '\r' before inserting '\n' at the end.

      * charset.c (_cpp_convert_input): Check '\r' before inserting
      '\n' at the end.
      * gcc.dg/cpp/mac-eol-at-eof.c: New test.

From-SVN: r95289
parent 332e7efe
2005-02-19 Devang Patel <dpatel@apple.com>
* gcc.dg/cpp/mac-eol-at-eof.c: New test.
2005-02-19 Steven G. Kargl <kargls@comcast.net> 2005-02-19 Steven G. Kargl <kargls@comcast.net>
* gfortran.dg/achar_1.f90: New test. * gfortran.dg/achar_1.f90: New test.
......
/* Test no newline at eof warning when Mac line ending is used*//* { dg-do compile } */int main() { return 0; }
\ No newline at end of file
2005-02-19 Devang Patel <dpatel@apple.com>
* charset.c (_cpp_convert_input): Check '\r' before inserting
'\n' at the end.
2005-02-15 Eric Christopher <echristo@redhat.com> 2005-02-15 Eric Christopher <echristo@redhat.com>
PR preprocessor/19077 PR preprocessor/19077
......
...@@ -1405,7 +1405,15 @@ _cpp_convert_input (cpp_reader *pfile, const char *input_charset, ...@@ -1405,7 +1405,15 @@ _cpp_convert_input (cpp_reader *pfile, const char *input_charset,
if (to.len + 4096 < to.asize || to.len >= to.asize) if (to.len + 4096 < to.asize || to.len >= to.asize)
to.text = xrealloc (to.text, to.len + 1); to.text = xrealloc (to.text, to.len + 1);
to.text[to.len] = '\n'; /* 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.text[to.len - 1] == '\r')
to.text[to.len] = '\r';
else
to.text[to.len] = '\n';
*st_size = to.len; *st_size = to.len;
return to.text; return to.text;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment