X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=progs%2Finfocmp.c;fp=progs%2Finfocmp.c;h=7932203ac2b1aa189f37e5dd7ffbdd662f6ad988;hb=d90067f9008bb8338a77c1ed519bc108c275ed04;hp=62cbb17a8398bde6eea926b21f6f3ff567df2a3d;hpb=b97ea58e03d5faebed2166faa4e0e590f2cdea34;p=ncurses.git diff --git a/progs/infocmp.c b/progs/infocmp.c index 62cbb17a..7932203a 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -43,7 +43,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.161 2023/12/09 19:56:10 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 */ @@ -187,9 +187,19 @@ capcmp(PredIdx idx, const char *s, const char *t) 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; @@ -213,8 +223,7 @@ use_predicate(unsigned type, PredIdx idx) 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; } } @@ -267,6 +276,8 @@ use_predicate(unsigned type, PredIdx idx) 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))