From e1c12209fdd75145b4b34ebaa0bd38dba822eedc Mon Sep 17 00:00:00 2001 From: Douglas B Rupp Date: Sat, 24 Nov 2001 17:17:58 -0500 Subject: [PATCH] fix-header.c (main): Move inf_buffer termination and inf_limit calculation to after read. * fix-header.c (main): Move inf_buffer termination and inf_limit calculation to after read. From-SVN: r47307 --- gcc/ChangeLog | 3 +++ gcc/fix-header.c | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7124dc239bb..d5ca26c35d9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ Sat Nov 24 17:04:10 2001 Douglas B. Rupp + * fix-header.c (main): Move inf_buffer termination and inf_limit + calculation to after read. + * config/alpha/xm-vms.h (FILE_TYPE): Remove undef and baggage. (__UNIX_FOPEN): Define. diff --git a/gcc/fix-header.c b/gcc/fix-header.c index 9b1386a78df..e96b6bb0fec 100644 --- a/gcc/fix-header.c +++ b/gcc/fix-header.c @@ -1184,9 +1184,6 @@ main (argc, argv) } inf_size = sbuf.st_size; inf_buffer = (char *) xmalloc (inf_size + 2); - inf_buffer[inf_size] = '\n'; - inf_buffer[inf_size + 1] = '\0'; - inf_limit = inf_buffer + inf_size; inf_ptr = inf_buffer; to_read = inf_size; @@ -1209,6 +1206,11 @@ main (argc, argv) close (inf_fd); + /* Inf_size may have changed if read was short (as on VMS) */ + inf_buffer[inf_size] = '\n'; + inf_buffer[inf_size + 1] = '\0'; + inf_limit = inf_buffer + inf_size; + /* If file doesn't end with '\n', add one. */ if (inf_limit > inf_buffer && inf_limit[-1] != '\n') inf_limit++;