X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Finfocmp.c;h=2e6f67a8b6981e6648d2e36caf15f8925508d168;hp=021d8011edebbfc99b503191ae8cfdad1ac4c9ae;hb=18b7b94579f108e649ece3fb12165833dbf5d95a;hpb=8b06e371ed1bce3dd6f37138e6becb5e1a562fe0;ds=sidebyside diff --git a/progs/infocmp.c b/progs/infocmp.c index 021d8011..2e6f67a8 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.112 2012/02/22 23:59:53 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.115 2012/04/07 19:12:01 tom Exp $") #define L_CURL "{" #define R_CURL "}" @@ -333,6 +333,21 @@ dump_string(char *val, char *buf) } } +/* + * ncurses stores two types of non-standard capabilities: + * a) capabilities listed past the "STOP-HERE" comment in the Caps file. + * These are used in the terminfo source file to provide data for termcaps, + * e.g., when there is no equivalent capability in terminfo, as well as for + * widely-used non-standard capabilities. + * b) user-definable capabilities, via "tic -x". + * + * However, if "-x" is omitted from the tic command, both types of + * non-standard capability are not loaded into the terminfo database. This + * macro is used for limit-checks against the symbols that tic uses to omit + * the two types of non-standard entry. + */ +#define check_user_definable(n,limit) if (!_nc_user_definable && (n) > (limit)) break + static void compare_predicate(PredType type, PredIdx idx, const char *name) /* predicate function to use for entry difference reports */ @@ -346,6 +361,7 @@ compare_predicate(PredType type, PredIdx idx, const char *name) switch (type) { case CMP_BOOLEAN: + check_user_definable(idx, BOOLWRITE); b1 = e1->tterm.Booleans[idx]; b2 = e2->tterm.Booleans[idx]; switch (compare) { @@ -371,6 +387,7 @@ compare_predicate(PredType type, PredIdx idx, const char *name) break; case CMP_NUMBER: + check_user_definable(idx, NUMWRITE); n1 = e1->tterm.Numbers[idx]; n2 = e2->tterm.Numbers[idx]; dump_numeric(n1, buf1); @@ -394,6 +411,7 @@ compare_predicate(PredType type, PredIdx idx, const char *name) break; case CMP_STRING: + check_user_definable(idx, STRWRITE); s1 = e1->tterm.Strings[idx]; s2 = e2->tterm.Strings[idx]; switch (compare) { @@ -1089,9 +1107,10 @@ dump_initializers(TERMTYPE *term) if (VALID_STRING(term->Strings[n])) { tp = buf; +#define TP_LIMIT ((MAX_STRING - 5) - (size_t)(tp - buf)) *tp++ = '"'; for (sp = term->Strings[n]; - *sp != 0 && (tp - buf) < MAX_STRING - 6; + *sp != 0 && TP_LIMIT > 2; sp++) { if (isascii(UChar(*sp)) && isprint(UChar(*sp)) @@ -1099,7 +1118,7 @@ dump_initializers(TERMTYPE *term) && *sp != '"') *tp++ = *sp; else { - _nc_SPRINTF(tp, _nc_SLIMIT(MAX_STRING) "\\%03o", UChar(*sp)); + _nc_SPRINTF(tp, _nc_SLIMIT(TP_LIMIT) "\\%03o", UChar(*sp)); tp += 4; } }