#include <dump_entry.h>
-MODULE_ID("$Id: infocmp.c,v 1.159 2023/12/02 17:29:01 tom Exp $")
+MODULE_ID("$Id: infocmp.c,v 1.163 2023/12/16 17:27:47 tom Exp $")
#define MAX_STRING 1024 /* maximum formatted string */
return (_nc_capcmp(s, t));
}
+/*
+ * Predicate function to use for "use=" decompilation.
+ *
+ * Return value is used in fmt_entry:
+ * FAIL show nothing for this capability.
+ * FALSE show cancel for booleans (a compromise)
+ * TRUE show capability
+ *
+ * The only difference between FALSE/TRUE returns is in the treatment of
+ * booleans.
+ */
static int
use_predicate(unsigned type, PredIdx idx)
-/* predicate function to use for use decompilation */
{
+ int result = FAIL;
ENTRY *ep;
switch (type) {
if (idx < NUM_BOOLEANS(&(entries[0].tterm))) {
for (ep = &entries[1]; ep < entries + termcount; ep++) {
if (idx < NUM_BOOLEANS(&(ep->tterm))
- && ep->tterm.Booleans[idx] == TRUE) {
- is_set = entries[0].tterm.Booleans[idx];
+ && (is_set = ep->tterm.Booleans[idx])) {
break;
}
}
if (is_set != entries[0].tterm.Booleans[idx])
- return (!is_set);
+ result = (!is_set);
}
- return (FAIL);
}
+ break;
case NUMBER:
{
}
if (value != entries[0].tterm.Numbers[idx])
- return (value != ABSENT_NUMERIC);
+ result = (value != ABSENT_NUMERIC);
}
- return (FAIL);
}
+ break;
case STRING:
{
- char *termstr, *usestr = ABSENT_STRING;
-
- termstr = entries[0].tterm.Strings[idx];
+ char *termstr = entries[0].tterm.Strings[idx];
+ char *usestr = ABSENT_STRING;
/*
* We take the semantics of multiple uses to be 'each
break;
}
- if (usestr == ABSENT_STRING && termstr == ABSENT_STRING)
- return (FAIL);
+ if (usestr == CANCELLED_STRING && termstr == ABSENT_STRING)
+ result = (FAIL);
+ else if (usestr == CANCELLED_STRING && termstr == CANCELLED_STRING)
+ result = (TRUE);
+ else if (usestr == ABSENT_STRING && termstr == ABSENT_STRING)
+ result = (FAIL);
else if (!usestr || !termstr || capcmp(idx, usestr, termstr))
- return (TRUE);
+ result = (TRUE);
}
- return (FAIL);
}
+ break;
+
+ default:
+ result = FALSE;
+ break;
}
- return (FALSE); /* pacify compiler */
+ return (result);
}
static bool