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
This commit is contained in:
joe 2000-06-17 01:43:56 +00:00
parent 27d76a0d0f
commit af432f252a
2 changed files with 5 additions and 8 deletions

View File

@ -44,7 +44,7 @@
.Sh SYNOPSIS
.Fd #include <unistd.h>
.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

View File

@ -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);
}
/*