From 309a88759be543e45aa902af611a3ad6188204ff Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Wed, 28 Aug 1996 22:07:28 +0000 Subject: (print_single_switch): Ultrix fprintf returns 0 on success. From-SVN: r12676 --- gcc/toplev.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'gcc') diff --git a/gcc/toplev.c b/gcc/toplev.c index ee35c30..bd4b3bd 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -4120,7 +4120,8 @@ print_version (file, indent) } /* Print an option value and return the adjusted position in the line. - ??? We don't handle error returns from fprintf (disk full). */ + ??? We don't handle error returns from fprintf (disk full); presumably + other code will catch a disk full though. */ int print_single_switch (file, pos, max, indent, sep, term, type, name) @@ -4128,17 +4129,23 @@ print_single_switch (file, pos, max, indent, sep, term, type, name) int pos, max; char *indent, *sep, *term, *type, *name; { + /* The ultrix fprintf returns 0 on success, so compute the result we want + here since we need it for the following test. */ + int len = strlen (sep) + strlen (type) + strlen (name); + if (pos != 0 - && pos + strlen (sep) + strlen (type) + strlen (name) > max) + && pos + len > max) { fprintf (file, "%s", term); pos = 0; } if (pos == 0) { - pos = fprintf (file, "%s", indent); + fprintf (file, "%s", indent); + pos = strlen (indent); } - pos += fprintf (file, "%s%s%s", sep, type, name); + fprintf (file, "%s%s%s", sep, type, name); + pos += len; return pos; } -- cgit v1.1