Commit 309a8875 by Doug Evans

(print_single_switch): Ultrix fprintf returns 0 on success.

From-SVN: r12676
parent ff482cef
...@@ -4120,7 +4120,8 @@ print_version (file, indent) ...@@ -4120,7 +4120,8 @@ print_version (file, indent)
} }
/* Print an option value and return the adjusted position in the line. /* 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 int
print_single_switch (file, pos, max, indent, sep, term, type, name) 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) ...@@ -4128,17 +4129,23 @@ print_single_switch (file, pos, max, indent, sep, term, type, name)
int pos, max; int pos, max;
char *indent, *sep, *term, *type, *name; 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 if (pos != 0
&& pos + strlen (sep) + strlen (type) + strlen (name) > max) && pos + len > max)
{ {
fprintf (file, "%s", term); fprintf (file, "%s", term);
pos = 0; pos = 0;
} }
if (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; return pos;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment