mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 04:00:07 +08:00
* listing.c (buffer_line): Open the source file with FOPEN_RB.
Manually process line ends.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2008-10-03 Kazu Hirata <kazu@codesourcery.com>
|
||||||
|
|
||||||
|
* listing.c (buffer_line): Open the source file with FOPEN_RB.
|
||||||
|
Manually process line ends.
|
||||||
|
|
||||||
2008-09-30 Wesley W. Terpstra <wesley@terpstra.ca>
|
2008-09-30 Wesley W. Terpstra <wesley@terpstra.ca>
|
||||||
Nick Clifton <nickc@redhat.com>
|
Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
@ -471,8 +471,10 @@ buffer_line (file_info_type *file, char *line, unsigned int size)
|
|||||||
fclose (last_open_file);
|
fclose (last_open_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Open the file in the binary mode so that ftell above can
|
||||||
|
return a reliable value that we can feed to fseek below. */
|
||||||
last_open_file_info = file;
|
last_open_file_info = file;
|
||||||
last_open_file = fopen (file->filename, FOPEN_RT);
|
last_open_file = fopen (file->filename, FOPEN_RB);
|
||||||
if (last_open_file == NULL)
|
if (last_open_file == NULL)
|
||||||
{
|
{
|
||||||
file->at_end = 1;
|
file->at_end = 1;
|
||||||
@ -489,7 +491,7 @@ buffer_line (file_info_type *file, char *line, unsigned int size)
|
|||||||
/* Leave room for null. */
|
/* Leave room for null. */
|
||||||
size -= 1;
|
size -= 1;
|
||||||
|
|
||||||
while (c != EOF && c != '\n')
|
while (c != EOF && c != '\n' && c != '\r')
|
||||||
{
|
{
|
||||||
if (count < size)
|
if (count < size)
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
@ -498,6 +500,17 @@ buffer_line (file_info_type *file, char *line, unsigned int size)
|
|||||||
c = fgetc (last_open_file);
|
c = fgetc (last_open_file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If '\r' is followed by '\n', swallow that. Likewise, if '\n'
|
||||||
|
is followed by '\r', swallow that as well. */
|
||||||
|
if (c == '\r' || c == '\n')
|
||||||
|
{
|
||||||
|
int next = fgetc (last_open_file);
|
||||||
|
if ((c == '\r' && next != '\n')
|
||||||
|
|| (c == '\n' && next != '\r'))
|
||||||
|
ungetc (next, last_open_file);
|
||||||
|
}
|
||||||
|
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
{
|
{
|
||||||
file->at_end = 1;
|
file->at_end = 1;
|
||||||
|
Reference in New Issue
Block a user