From cb039f8aa0fa4838ce8842b02eb2416d505c027e Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Sun, 26 Jun 1994 05:37:16 -0400 Subject: [PATCH] (v_message_with_decl): Avoid fwrite for stderr; mixing it with fprintf and fputs can cause strange results under VMS. From-SVN: r7570 --- gcc/toplev.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gcc/toplev.c b/gcc/toplev.c index f73a60adb07..f3aeb09f6ec 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1149,10 +1149,17 @@ v_message_with_decl (decl, prefix, s, ap) } } - if (p > s) - fwrite (s, p - s, 1, stderr); + if (p > s) /* Print the left-hand substring. */ + { + char fmt[sizeof "%.255s"]; + long width = p - s; + + if (width > 255L) width = 255L; /* arbitrary */ + sprintf (fmt, "%%.%lds", width); + fprintf (stderr, fmt, s); + } - if (*p == '%') + if (*p == '%') /* Print the name. */ { char *n = (DECL_NAME (decl) ? (*decl_printable_name) (decl, &junk) @@ -1166,7 +1173,7 @@ v_message_with_decl (decl, prefix, s, ap) } } - if (*p) + if (*p) /* Print the rest of the message. */ vmessage ((char *)NULL, p, ap); fputc ('\n', stderr);