]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fix-header.c (main): Move inf_buffer termination and inf_limit calculation to after...
authorDouglas B Rupp <rupp@gnat.com>
Sat, 24 Nov 2001 22:17:58 +0000 (17:17 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Sat, 24 Nov 2001 22:17:58 +0000 (17:17 -0500)
* fix-header.c (main): Move inf_buffer termination and inf_limit
calculation to after read.

From-SVN: r47307

gcc/ChangeLog
gcc/fix-header.c

index 7124dc239bb6d44945e11fc134ab192bf61df939..d5ca26c35d9c02e0d551dd2a8bb1f7ebac72f9c1 100644 (file)
@@ -1,5 +1,8 @@
 Sat Nov 24 17:04:10 2001  Douglas B. Rupp  <rupp@gnat.com>
 
+       * 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.
 
index 9b1386a78df3799871cb83dfcdb599846b62df46..e96b6bb0fecf3ca1307289f5887c588840949950 100644 (file)
@@ -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++;