Module Name: src
Committed By: rillig
Date: Tue Sep 1 20:34:51 UTC 2020
Modified Files:
src/usr.bin/make: enum.c enum.h
Log Message:
make(1): improve documentation for enum.c and enum.h
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/enum.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/enum.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/enum.c
diff -u src/usr.bin/make/enum.c:1.5 src/usr.bin/make/enum.c:1.6
--- src/usr.bin/make/enum.c:1.5 Fri Aug 28 19:46:04 2020
+++ src/usr.bin/make/enum.c Tue Sep 1 20:34:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: enum.c,v 1.5 2020/08/28 19:46:04 rillig Exp $ */
+/* $NetBSD: enum.c,v 1.6 2020/09/01 20:34:51 rillig Exp $ */
/*
Copyright (c) 2020 Roland Illig <[email protected]>
@@ -28,11 +28,11 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: enum.c,v 1.5 2020/08/28 19:46:04 rillig Exp $";
+static char rcsid[] = "$NetBSD: enum.c,v 1.6 2020/09/01 20:34:51 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: enum.c,v 1.5 2020/08/28 19:46:04 rillig Exp $");
+__RCSID("$NetBSD: enum.c,v 1.6 2020/09/01 20:34:51 rillig Exp $");
#endif
#endif
@@ -42,8 +42,11 @@ __RCSID("$NetBSD: enum.c,v 1.5 2020/08/2
#include "enum.h"
-/* Convert a bitset into a string representation showing the names of the
- * individual bits, or optionally shortcuts for groups of bits. */
+/* Convert a bitset into a string representation, showing the names of the
+ * individual bits.
+ *
+ * Optionally, shortcuts for groups of bits can be added. To have an effect,
+ * they need to be listed before their individual bits. */
const char *
Enum_FlagsToString(char *buf, size_t buf_size,
int value, const EnumToStringSpec *spec)
@@ -73,6 +76,8 @@ Enum_FlagsToString(char *buf, size_t buf
sep = ENUM__SEP;
sep_len = sizeof ENUM__SEP - 1;
}
+
+ /* If this assertion fails, the listed enum values are incomplete. */
assert(value == 0);
if (buf == buf_start)
Index: src/usr.bin/make/enum.h
diff -u src/usr.bin/make/enum.h:1.8 src/usr.bin/make/enum.h:1.9
--- src/usr.bin/make/enum.h:1.8 Tue Aug 25 16:27:24 2020
+++ src/usr.bin/make/enum.h Tue Sep 1 20:34:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: enum.h,v 1.8 2020/08/25 16:27:24 rillig Exp $ */
+/* $NetBSD: enum.h,v 1.9 2020/09/01 20:34:51 rillig Exp $ */
/*
Copyright (c) 2020 Roland Illig <[email protected]>
@@ -30,9 +30,7 @@
#ifndef MAKE_ENUM_H
#define MAKE_ENUM_H
-/*
- * Generate string representation for bitmasks.
- */
+/* Generate string representations for bitmasks and simple enums. */
#include <stddef.h>