From af432f252ad14b44f8e6262bc3bc32b902774708 Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 17 Jun 2000 01:43:56 +0000 Subject: [PATCH] The "def" arg for fflagstostr is too specialized for ls. The caller can easily translate from "" to whatever it wants to print if no flags are set. (ls prints "-" and mtree prints "none".) Suggested by: bde --- lib/libc/gen/strtofflags.3 | 6 ++---- lib/libc/gen/strtofflags.c | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/libc/gen/strtofflags.3 b/lib/libc/gen/strtofflags.3 index c12551aeec59..f287c172cf73 100644 --- a/lib/libc/gen/strtofflags.3 +++ b/lib/libc/gen/strtofflags.3 @@ -44,7 +44,7 @@ .Sh SYNOPSIS .Fd #include .Ft char * -.Fn fflagstostr "u_long flags" "char *def" +.Fn fflagstostr "u_long flags" .Ft int .Fn strtofflags "char **stringp" "u_long *setp" "u_long *clrp" .Sh DESCRIPTION @@ -52,9 +52,7 @@ The .Fn fflagstostr function returns a comma separated string of the file flags represented by .Fa flags . -If no flags are set the string -.Fa def -is returned instead. +If no flags are set a zero length string is returned. .Pp The .Fn strtofflags diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c index 2cf6f39c484d..d9d2dc4f37b2 100644 --- a/lib/libc/gen/strtofflags.c +++ b/lib/libc/gen/strtofflags.c @@ -76,12 +76,11 @@ static struct { /* * fflagstostr -- * Convert file flags to a comma-separated string. If no flags - * are set, return the default string. + * are set, return the empty string. */ char * -fflagstostr(flags, def) +fflagstostr(flags) u_long flags; - char *def; { static char string[128]; char *sp, *dp; @@ -100,7 +99,7 @@ fflagstostr(flags, def) } } *dp = '\0'; - return (dp == string && def != NULL ? def : string); + return (string); } /*