Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/ls flags_to_strings() changes:
details: https://anonhg.NetBSD.org/src/rev/49e46ba10b30
branches: trunk
changeset: 516171:49e46ba10b30
user: lukem <lukem%NetBSD.org@localhost>
date: Thu Oct 18 03:16:20 2001 +0000
description:
flags_to_strings() changes:
- fix bug where the 'clear' flag was set outside of main loop, so
"dump,uchg,arch" on a file with flags would clear all the bits
(because "dump" sets 'clear'). noted in FreeBSD PR 10071, and fix
obtained from FreeBSD.
- enforce right-most priority on arguments by clearing the appropriate
bit in the opposite set; if a string of "nouchg,uchg" is given,
chflags(8) would clear uchg because it applies the "set" bits before
clearing the "clear" bits. now, "uchg" sets UF_IMMUTABLE in setp
and also resets it in clrp, solving this problem
- constify second arg (the `default' arg)
diffstat:
bin/ls/stat_flags.c | 24 ++++++++++++++++--------
bin/ls/stat_flags.h | 4 ++--
2 files changed, 18 insertions(+), 10 deletions(-)
diffs (87 lines):
diff -r 702f824844f9 -r 49e46ba10b30 bin/ls/stat_flags.c
--- a/bin/ls/stat_flags.c Thu Oct 18 02:36:33 2001 +0000
+++ b/bin/ls/stat_flags.c Thu Oct 18 03:16:20 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: stat_flags.c,v 1.8 2000/07/29 03:46:15 lukem Exp $ */
+/* $NetBSD: stat_flags.c,v 1.9 2001/10/18 03:16:20 lukem Exp $ */
/*-
* Copyright (c) 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)stat_flags.c 8.2 (Berkeley) 7/28/94";
#else
-__RCSID("$NetBSD: stat_flags.c,v 1.8 2000/07/29 03:46:15 lukem Exp $");
+__RCSID("$NetBSD: stat_flags.c,v 1.9 2001/10/18 03:16:20 lukem Exp $");
#endif
#endif /* not lint */
@@ -64,7 +64,7 @@
* are set, return the default string.
*/
char *
-flags_to_string(u_long flags, char *def)
+flags_to_string(u_long flags, const char *def)
{
static char string[128];
char *prefix;
@@ -85,16 +85,24 @@
SAPPEND("arch");
if (flags & SF_IMMUTABLE)
SAPPEND("schg");
- return (prefix == NULL && def != NULL ? def : string);
+ if (prefix == NULL)
+ strlcpy(string, def, sizeof(def));
+ return (string);
}
#define TEST(a, b, f) { \
- if (!memcmp(a, b, sizeof(b))) { \
+ if (!strcmp(a, b)) { \
if (clear) { \
if (clrp) \
*clrp |= (f); \
- } else if (setp) \
- *setp |= (f); \
+ if (setp) \
+ *setp &= ~(f); \
+ } else { \
+ if (setp) \
+ *setp |= (f); \
+ if (clrp) \
+ *clrp &= ~(f); \
+ } \
break; \
} \
}
@@ -111,13 +119,13 @@
int clear;
char *string, *p;
- clear = 0;
if (setp)
*setp = 0;
if (clrp)
*clrp = 0;
string = *stringp;
while ((p = strsep(&string, "\t ,")) != NULL) {
+ clear = 0;
*stringp = p;
if (*p == '\0')
continue;
diff -r 702f824844f9 -r 49e46ba10b30 bin/ls/stat_flags.h
--- a/bin/ls/stat_flags.h Thu Oct 18 02:36:33 2001 +0000
+++ b/bin/ls/stat_flags.h Thu Oct 18 03:16:20 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: stat_flags.h,v 1.2 2000/07/29 03:46:15 lukem Exp $ */
+/* $NetBSD: stat_flags.h,v 1.3 2001/10/18 03:16:20 lukem Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -35,5 +35,5 @@
* @(#)extern.h 8.1 (Berkeley) 5/31/93
*/
-char *flags_to_string(u_long, char *);
+char *flags_to_string(u_long, const char *);
int string_to_flags(char **, u_long *, u_long *);
Home |
Main Index |
Thread Index |
Old Index