make: remove overengineered Enum_ValueToString
For printing the status of a GNode, there was already made_name (now renamed to GNodeMade_Name), which prints user-friendly text instead of the bare enum constant names. To do this change confidently, I first had to demonstrate that the output really affects something other than just the word "UNMADE". There had not been a test for that case before, and the test immediately discovered a bug in the -dg2 and -dg3 options. This bug is one of the oldest in make, dating back to at least 1993.
This commit is contained in:
parent
553ee5f131
commit
0840915c87
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: enum.c,v 1.14 2021/01/09 16:06:09 rillig Exp $ */
|
||||
/* $NetBSD: enum.c,v 1.15 2021/02/02 17:56:31 rillig Exp $ */
|
||||
|
||||
/*
|
||||
Copyright (c) 2020 Roland Illig <rillig@NetBSD.org>
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include "make.h"
|
||||
|
||||
MAKE_RCSID("$NetBSD: enum.c,v 1.14 2021/01/09 16:06:09 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: enum.c,v 1.15 2021/02/02 17:56:31 rillig Exp $");
|
||||
|
||||
/*
|
||||
* Convert a bitset into a string representation, showing the names of the
|
||||
@ -78,15 +78,3 @@ Enum_FlagsToString(char *buf, size_t buf_size,
|
||||
buf[0] = '\0';
|
||||
return buf_start;
|
||||
}
|
||||
|
||||
/* Convert a fixed-value enum into a string representation. */
|
||||
const char *
|
||||
Enum_ValueToString(int value, const EnumToStringSpec *spec)
|
||||
{
|
||||
for (; spec->es_name[0] != '\0'; spec++) {
|
||||
if (value == spec->es_value)
|
||||
return spec->es_name;
|
||||
}
|
||||
abort(/* unknown enum value */);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: enum.h,v 1.16 2021/01/30 15:53:55 rillig Exp $ */
|
||||
/* $NetBSD: enum.h,v 1.17 2021/02/02 17:56:31 rillig Exp $ */
|
||||
|
||||
/*
|
||||
Copyright (c) 2020 Roland Illig <rillig@NetBSD.org>
|
||||
@ -39,8 +39,9 @@ typedef struct EnumToStringSpec {
|
||||
const char *es_name;
|
||||
} EnumToStringSpec;
|
||||
|
||||
|
||||
const char *Enum_FlagsToString(char *, size_t, int, const EnumToStringSpec *);
|
||||
const char *Enum_ValueToString(int, const EnumToStringSpec *);
|
||||
|
||||
|
||||
/* For Enum_FlagsToString, the separator between flags. */
|
||||
#define ENUM__SEP "|"
|
||||
@ -100,13 +101,6 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *);
|
||||
#define ENUM__SPECS_5(part1, part2, part3, part4, part5) \
|
||||
{ part1, part2, part3, part4, part5, { 0, "" } }
|
||||
|
||||
/* Declare the necessary data structures for calling Enum_ValueToString. */
|
||||
#define ENUM__VALUE_RTTI(typnam, specs) \
|
||||
static const EnumToStringSpec typnam ## _ ## ToStringSpecs[] = specs; \
|
||||
MAKE_INLINE const char *typnam ## _ToString(typnam value) \
|
||||
{ return Enum_ValueToString(value, typnam ## _ ## ToStringSpecs); } \
|
||||
extern void enum_value_rtti_dummy(void)
|
||||
|
||||
|
||||
/* Declare the necessary data structures for calling Enum_FlagsToString. */
|
||||
#define ENUM__FLAGS_RTTI(typnam, specs, joined) \
|
||||
@ -183,16 +177,6 @@ const char *Enum_ValueToString(int, const EnumToStringSpec *);
|
||||
ENUM__JOIN_STR_4(v1, v2, v3, v4), \
|
||||
ENUM__JOIN_STR_4(v5, v6, v7, v8)))
|
||||
|
||||
/*
|
||||
* Declare the necessary data structures for calling Enum_ValueToString
|
||||
* for an enum with 8 constants.
|
||||
*/
|
||||
#define ENUM_VALUE_RTTI_8(typnam, v1, v2, v3, v4, v5, v6, v7, v8) \
|
||||
ENUM__VALUE_RTTI(typnam, \
|
||||
ENUM__SPECS_2( \
|
||||
ENUM__SPEC_4(v1, v2, v3, v4), \
|
||||
ENUM__SPEC_4(v5, v6, v7, v8)))
|
||||
|
||||
/*
|
||||
* Declare the necessary data structures for calling Enum_FlagsToString
|
||||
* for an enum with 10 flags.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: make.c,v 1.238 2021/02/01 20:42:13 rillig Exp $ */
|
||||
/* $NetBSD: make.c,v 1.239 2021/02/02 17:56:31 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -103,7 +103,7 @@
|
||||
#include "job.h"
|
||||
|
||||
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
|
||||
MAKE_RCSID("$NetBSD: make.c,v 1.238 2021/02/01 20:42:13 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: make.c,v 1.239 2021/02/02 17:56:31 rillig Exp $");
|
||||
|
||||
/* Sequence # to detect recursion. */
|
||||
static unsigned int checked_seqno = 1;
|
||||
@ -137,10 +137,6 @@ make_abort(GNode *gn, int lineno)
|
||||
abort();
|
||||
}
|
||||
|
||||
ENUM_VALUE_RTTI_8(GNodeMade,
|
||||
UNMADE, DEFERRED, REQUESTED, BEINGMADE,
|
||||
MADE, UPTODATE, ERROR, ABORTED);
|
||||
|
||||
ENUM_FLAGS_RTTI_31(GNodeType,
|
||||
OP_DEPENDS, OP_FORCE, OP_DOUBLEDEP,
|
||||
/* OP_OPMASK is omitted since it combines other flags */
|
||||
@ -164,9 +160,9 @@ GNode_FprintDetails(FILE *f, const char *prefix, const GNode *gn,
|
||||
char type_buf[GNodeType_ToStringSize];
|
||||
char flags_buf[GNodeFlags_ToStringSize];
|
||||
|
||||
fprintf(f, "%smade %s, type %s, flags %s%s",
|
||||
fprintf(f, "%s%s, type %s, flags %s%s",
|
||||
prefix,
|
||||
GNodeMade_ToString(gn->made),
|
||||
GNodeMade_Name(gn->made),
|
||||
GNodeType_ToString(type_buf, gn->type),
|
||||
GNodeFlags_ToString(flags_buf, gn->flags),
|
||||
suffix);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nonints.h,v 1.189 2021/02/01 21:38:20 rillig Exp $ */
|
||||
/* $NetBSD: nonints.h,v 1.190 2021/02/02 17:56:31 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -278,6 +278,7 @@ const char *Targ_FmtTime(time_t);
|
||||
void Targ_PrintType(int);
|
||||
void Targ_PrintGraph(int);
|
||||
void Targ_Propagate(void);
|
||||
const char *GNodeMade_Name(GNodeMade);
|
||||
|
||||
/* var.c */
|
||||
void Var_Init(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: targ.c,v 1.160 2021/01/10 23:59:53 rillig Exp $ */
|
||||
/* $NetBSD: targ.c,v 1.161 2021/02/02 17:56:31 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -113,7 +113,7 @@
|
||||
#include "dir.h"
|
||||
|
||||
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: targ.c,v 1.160 2021/01/10 23:59:53 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: targ.c,v 1.161 2021/02/02 17:56:31 rillig Exp $");
|
||||
|
||||
/*
|
||||
* All target nodes that appeared on the left-hand side of one of the
|
||||
@ -450,8 +450,8 @@ Targ_PrintType(int type)
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
made_name(GNodeMade made)
|
||||
const char *
|
||||
GNodeMade_Name(GNodeMade made)
|
||||
{
|
||||
switch (made) {
|
||||
case UNMADE: return "unmade";
|
||||
@ -505,10 +505,10 @@ Targ_PrintNode(GNode *gn, int pass)
|
||||
if (gn->mtime != 0) {
|
||||
debug_printf("# last modified %s: %s\n",
|
||||
Targ_FmtTime(gn->mtime),
|
||||
made_name(gn->made));
|
||||
GNodeMade_Name(gn->made));
|
||||
} else if (gn->made != UNMADE) {
|
||||
debug_printf("# nonexistent (maybe): %s\n",
|
||||
made_name(gn->made));
|
||||
GNodeMade_Name(gn->made));
|
||||
} else
|
||||
debug_printf("# unmade\n");
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
#*** Input graph:
|
||||
# all, made UNMADE, type OP_DEPENDS, flags none
|
||||
# makeinfo, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# make-index, made UNMADE, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# braces-dot, made UNMADE, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# braces-no-dot, made UNMADE, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# braces-no-dot-modifier, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# parentheses-dot, made UNMADE, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# parentheses-no-dot, made UNMADE, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# all, unmade, type OP_DEPENDS, flags none
|
||||
# makeinfo, unmade, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# make-index, unmade, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# braces-dot, unmade, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# braces-no-dot, unmade, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# braces-no-dot-modifier, unmade, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# parentheses-dot, unmade, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
# parentheses-no-dot, unmade, type OP_DEPENDS|OP_SUBMAKE|OP_HAS_COMMANDS, flags none
|
||||
|
||||
exit status 0
|
||||
|
@ -1,12 +1,12 @@
|
||||
#*** Input graph:
|
||||
# all, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# made-target, made UNMADE, type OP_DEPENDS, flags none
|
||||
# made-target-no-sources, made UNMADE, type OP_DEPENDS, flags none
|
||||
# made-source, made UNMADE, type OP_DEPENDS, flags none
|
||||
# unmade-target, made UNMADE, type OP_DEPENDS, flags none
|
||||
# unmade-sources, made UNMADE, type none, flags none
|
||||
# unmade-silent-source, made UNMADE, type OP_SILENT, flags none
|
||||
# unmade-target-no-sources, made UNMADE, type OP_DEPENDS, flags none
|
||||
# all, unmade, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# made-target, unmade, type OP_DEPENDS, flags none
|
||||
# made-target-no-sources, unmade, type OP_DEPENDS, flags none
|
||||
# made-source, unmade, type OP_DEPENDS, flags none
|
||||
# unmade-target, unmade, type OP_DEPENDS, flags none
|
||||
# unmade-sources, unmade, type none, flags none
|
||||
# unmade-silent-source, unmade, type OP_SILENT, flags none
|
||||
# unmade-target-no-sources, unmade, type OP_DEPENDS, flags none
|
||||
|
||||
|
||||
#
|
||||
|
@ -5,7 +5,7 @@ false
|
||||
*** Error code 1 (continuing)
|
||||
`all' not remade because of errors.
|
||||
#*** Input graph:
|
||||
# made-target, made MADE, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
# made-target, made, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
#
|
||||
# *** MAIN TARGET ***
|
||||
# No unmade children
|
||||
@ -15,7 +15,7 @@ made-target :
|
||||
(null)
|
||||
|
||||
|
||||
# error-target, made ERROR, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
# error-target, error when made, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
#
|
||||
# No unmade children
|
||||
# nonexistent (maybe): error when made
|
||||
@ -24,8 +24,8 @@ error-target :
|
||||
(null)
|
||||
|
||||
|
||||
# aborted-target, made ABORTED, type OP_DEPENDS|OP_PHONY|OP_DEPS_FOUND|OP_MARK, flags none
|
||||
# aborted-target-dependency, made ERROR, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
# aborted-target, aborted, type OP_DEPENDS|OP_PHONY|OP_DEPS_FOUND|OP_MARK, flags none
|
||||
# aborted-target-dependency, error when made, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
#
|
||||
# No unmade children
|
||||
# nonexistent (maybe): error when made
|
||||
@ -34,14 +34,14 @@ aborted-target-dependency:
|
||||
(null)
|
||||
|
||||
|
||||
# all, made ABORTED, type OP_DEPENDS|OP_DEPS_FOUND, flags CHILDMADE|FORCE
|
||||
# all, aborted, type OP_DEPENDS|OP_DEPS_FOUND, flags CHILDMADE|FORCE
|
||||
#
|
||||
# 3 unmade children
|
||||
# nonexistent (maybe): aborted
|
||||
all : made-target error-target aborted-target
|
||||
|
||||
|
||||
# .END, made UNMADE, type OP_SPECIAL, flags none
|
||||
# .END, unmade, type OP_SPECIAL, flags none
|
||||
|
||||
|
||||
#
|
||||
|
@ -5,7 +5,7 @@ false
|
||||
*** Error code 1 (continuing)
|
||||
`all' not remade because of errors.
|
||||
#*** Input graph:
|
||||
# made-target, made MADE, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
# made-target, made, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
#
|
||||
# *** MAIN TARGET ***
|
||||
# No unmade children
|
||||
@ -15,7 +15,7 @@ made-target :
|
||||
(null)
|
||||
|
||||
|
||||
# error-target, made ERROR, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
# error-target, error when made, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
#
|
||||
# No unmade children
|
||||
# nonexistent (maybe): error when made
|
||||
@ -24,8 +24,8 @@ error-target :
|
||||
(null)
|
||||
|
||||
|
||||
# aborted-target, made ABORTED, type OP_DEPENDS|OP_PHONY|OP_DEPS_FOUND|OP_MARK, flags none
|
||||
# aborted-target-dependency, made ERROR, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
# aborted-target, aborted, type OP_DEPENDS|OP_PHONY|OP_DEPS_FOUND|OP_MARK, flags none
|
||||
# aborted-target-dependency, error when made, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS|OP_DEPS_FOUND|OP_MARK, flags REMAKE|DONE_ALLSRC
|
||||
#
|
||||
# No unmade children
|
||||
# nonexistent (maybe): error when made
|
||||
@ -34,14 +34,14 @@ aborted-target-dependency:
|
||||
(null)
|
||||
|
||||
|
||||
# all, made ABORTED, type OP_DEPENDS|OP_DEPS_FOUND, flags CHILDMADE|FORCE
|
||||
# all, aborted, type OP_DEPENDS|OP_DEPS_FOUND, flags CHILDMADE|FORCE
|
||||
#
|
||||
# 3 unmade children
|
||||
# nonexistent (maybe): aborted
|
||||
all : made-target error-target aborted-target
|
||||
|
||||
|
||||
# .END, made UNMADE, type OP_SPECIAL, flags none
|
||||
# .END, unmade, type OP_SPECIAL, flags none
|
||||
|
||||
|
||||
#
|
||||
|
@ -18,8 +18,8 @@ defining transformation from `.a' to `.c'
|
||||
inserting ".a" (1) at end of list
|
||||
inserting ".c" (3) at end of list
|
||||
# LinkSource: added child .a.c - ${.PREFIX}.dependency
|
||||
# .a.c, made UNMADE, type OP_DEPENDS|OP_TRANSFORM, flags none
|
||||
# ${.PREFIX}.dependency, made UNMADE, type none, flags none
|
||||
# .a.c, unmade, type OP_DEPENDS|OP_TRANSFORM, flags none
|
||||
# ${.PREFIX}.dependency, unmade, type none, flags none
|
||||
ParseReadLine (23): '.DEFAULT:'
|
||||
transformation .a.c complete
|
||||
ParseDoDependency(.DEFAULT:)
|
||||
|
@ -59,17 +59,17 @@ ParseReadLine (39): ' : Making ${.TARGET} out of nothing.'
|
||||
ParseReadLine (40): 'next-main: suff-main-several.{2,3,4}'
|
||||
ParseDoDependency(next-main: suff-main-several.{2,3,4})
|
||||
# LinkSource: added child next-main - suff-main-several.{2,3,4}
|
||||
# next-main, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# suff-main-several.{2,3,4}, made UNMADE, type none, flags none
|
||||
# next-main, unmade, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# suff-main-several.{2,3,4}, unmade, type none, flags none
|
||||
ParseReadLine (42): '.MAKEFLAGS: -d0 -dg1'
|
||||
ParseDoDependency(.MAKEFLAGS: -d0 -dg1)
|
||||
#*** Input graph:
|
||||
# .1.2, made UNMADE, type OP_TRANSFORM, flags none
|
||||
# .1.3, made UNMADE, type OP_TRANSFORM, flags none
|
||||
# .1.4, made UNMADE, type OP_TRANSFORM, flags none
|
||||
# next-main, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# suff-main-several.1, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# suff-main-several.{2,3,4}, made UNMADE, type none, flags none
|
||||
# .1.2, unmade, type OP_TRANSFORM, flags none
|
||||
# .1.3, unmade, type OP_TRANSFORM, flags none
|
||||
# .1.4, unmade, type OP_TRANSFORM, flags none
|
||||
# next-main, unmade, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# suff-main-several.1, unmade, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
|
||||
# suff-main-several.{2,3,4}, unmade, type none, flags none
|
||||
|
||||
|
||||
#
|
||||
|
@ -1,5 +1,5 @@
|
||||
#*** Input graph:
|
||||
# all, made UNMADE, type OP_DEPENDS, flags none
|
||||
# all, unmade, type OP_DEPENDS, flags none
|
||||
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user