Annotation of src/usr.bin/tic/tic.c, Revision 1.6
1.6 ! millert 1: /* $OpenBSD: tic.c,v 1.5 1999/01/24 19:33:51 millert Exp $ */
1.1 millert 2:
3: /****************************************************************************
4: * Copyright (c) 1998 Free Software Foundation, Inc. *
5: * *
6: * Permission is hereby granted, free of charge, to any person obtaining a *
7: * copy of this software and associated documentation files (the *
8: * "Software"), to deal in the Software without restriction, including *
9: * without limitation the rights to use, copy, modify, merge, publish, *
10: * distribute, distribute with modifications, sublicense, and/or sell *
11: * copies of the Software, and to permit persons to whom the Software is *
12: * furnished to do so, subject to the following conditions: *
13: * *
14: * The above copyright notice and this permission notice shall be included *
15: * in all copies or substantial portions of the Software. *
16: * *
17: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20: * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21: * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22: * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23: * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24: * *
25: * Except as contained in this notice, the name(s) of the above copyright *
26: * holders shall not be used in advertising or otherwise to promote the *
27: * sale, use or other dealings in this Software without prior written *
28: * authorization. *
29: ****************************************************************************/
30:
31: /****************************************************************************
32: * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
33: * and: Eric S. Raymond <esr@snark.thyrsus.com> *
34: ****************************************************************************/
35:
36: /*
37: * tic.c --- Main program for terminfo compiler
38: * by Eric S. Raymond
39: *
40: */
41:
42: #include <progs.priv.h>
43:
44: #include <dump_entry.h>
45: #include <term_entry.h>
46:
1.6 ! millert 47: MODULE_ID("$From: tic.c,v 1.45 1999/02/19 10:40:00 tom Exp $")
1.1 millert 48:
49: const char *_nc_progname = "tic";
50:
51: static FILE *log_fp;
1.2 millert 52: static FILE *tmp_fp;
1.1 millert 53: static bool showsummary = FALSE;
1.2 millert 54: static const char *to_remove;
1.1 millert 55:
1.6 ! millert 56: static void (*save_check_termtype)(TERMTYPE *);
! 57: static void check_termtype(TERMTYPE *tt);
! 58:
1.1 millert 59: static const char usage_string[] = "[-h] [-v[n]] [-e names] [-CILNRTcfrsw1] source-file\n";
60:
1.2 millert 61: static void cleanup(void)
62: {
1.3 millert 63: if (tmp_fp != 0)
64: fclose(tmp_fp);
1.2 millert 65: if (to_remove != 0)
66: remove(to_remove);
67: }
68:
69: static void failed(const char *msg)
70: {
71: perror(msg);
72: cleanup();
73: exit(EXIT_FAILURE);
74: }
75:
1.1 millert 76: static void usage(void)
77: {
78: static const char *const tbl[] = {
79: "Options:",
80: " -1 format translation output one capability per line",
81: " -C translate entries to termcap source form",
82: " -I translate entries to terminfo source form",
83: " -L translate entries to full terminfo source form",
84: " -N disable smart defaults for source translation",
85: " -R restrict translation to given terminfo/termcap version",
86: " -T remove size-restrictions on compiled description",
87: " -c check only, validate input without compiling or translating",
88: " -f format complex strings for readability",
1.2 millert 89: " -g format %'char' to %{number}",
1.1 millert 90: " -e<names> translate/compile only entries named by comma-separated list",
91: " -o<dir> set output directory for compiled entry writes",
92: " -r force resolution of all use entries in source translation",
93: " -s print summary statistics",
94: " -v[n] set verbosity level",
95: " -w[n] set format width for translation output",
96: "",
97: "Parameters:",
98: " <file> file to translate or compile"
99: };
100: size_t j;
101:
102: printf("Usage: %s %s\n", _nc_progname, usage_string);
103: for (j = 0; j < sizeof(tbl)/sizeof(tbl[0]); j++)
104: puts(tbl[j]);
105: exit(EXIT_FAILURE);
106: }
107:
1.2 millert 108: #define L_BRACE '{'
109: #define R_BRACE '}'
110: #define S_QUOTE '\'';
111:
112: static void write_it(ENTRY *ep)
113: {
114: unsigned n;
115: int ch;
116: char *s, *d, *t;
117: char result[MAX_ENTRY_SIZE];
118:
119: /*
120: * Look for strings that contain %{number}, convert them to %'char',
121: * which is shorter and runs a little faster.
122: */
123: for (n = 0; n < STRCOUNT; n++) {
124: s = ep->tterm.Strings[n];
125: if (VALID_STRING(s)
126: && strchr(s, L_BRACE) != 0) {
127: d = result;
128: t = s;
129: while ((ch = *t++) != 0) {
130: *d++ = ch;
131: if (ch == '\\') {
132: *d++ = *t++;
133: } else if ((ch == '%')
134: && (*t == L_BRACE)) {
135: char *v = 0;
136: long value = strtol(t+1, &v, 0);
137: if (v != 0
138: && *v == R_BRACE
139: && value > 0
140: && value != '\\' /* FIXME */
141: && value < 127
142: && isprint((int)value)) {
143: *d++ = S_QUOTE;
144: *d++ = (int)value;
145: *d++ = S_QUOTE;
146: t = (v + 1);
147: }
148: }
149: }
150: *d = 0;
151: if (strlen(result) < strlen(s))
152: strcpy(s, result);
153: }
154: }
155:
156: _nc_set_type(_nc_first_name(ep->tterm.term_names));
157: _nc_curr_line = ep->startline;
158: _nc_write_entry(&ep->tterm);
159: }
160:
1.5 millert 161: static bool immedhook(ENTRY *ep GCC_UNUSED)
1.1 millert 162: /* write out entries with no use capabilities immediately to save storage */
163: {
164: #ifndef HAVE_BIG_CORE
165: /*
166: * This is strictly a core-economy kluge. The really clean way to handle
167: * compilation is to slurp the whole file into core and then do all the
168: * name-collision checks and entry writes in one swell foop. But the
169: * terminfo master file is large enough that some core-poor systems swap
170: * like crazy when you compile it this way...there have been reports of
171: * this process taking *three hours*, rather than the twenty seconds or
172: * less typical on my development box.
173: *
174: * So. This hook *immediately* writes out the referenced entry if it
175: * has no use capabilities. The compiler main loop refrains from
176: * adding the entry to the in-core list when this hook fires. If some
177: * other entry later needs to reference an entry that got written
178: * immediately, that's OK; the resolution code will fetch it off disk
179: * when it can't find it in core.
180: *
181: * Name collisions will still be detected, just not as cleanly. The
182: * write_entry() code complains before overwriting an entry that
183: * postdates the time of tic's first call to write_entry(). Thus
184: * it will complain about overwriting entries newly made during the
185: * tic run, but not about overwriting ones that predate it.
186: *
187: * The reason this is a hook, and not in line with the rest of the
188: * compiler code, is that the support for termcap fallback cannot assume
189: * it has anywhere to spool out these entries!
190: *
191: * The _nc_set_type() call here requires a compensating one in
192: * _nc_parse_entry().
193: *
194: * If you define HAVE_BIG_CORE, you'll disable this kluge. This will
195: * make tic a bit faster (because the resolution code won't have to do
196: * disk I/O nearly as often).
197: */
198: if (ep->nuses == 0)
199: {
200: int oldline = _nc_curr_line;
201:
1.2 millert 202: write_it(ep);
1.1 millert 203: _nc_curr_line = oldline;
204: free(ep->tterm.str_table);
205: return(TRUE);
206: }
207: else
208: #endif /* HAVE_BIG_CORE */
209: return(FALSE);
210: }
211:
212: static void put_translate(int c)
213: /* emit a comment char, translating terminfo names to termcap names */
214: {
215: static bool in_name = FALSE;
216: static char namebuf[132], suffix[132], *sp;
217:
218: if (!in_name)
219: {
220: if (c == '<')
221: {
222: in_name = TRUE;
223: sp = namebuf;
224: }
225: else
226: putchar(c);
227: }
228: else if (c == '\n' || c == '@')
229: {
230: *sp++ = '\0';
231: (void) putchar('<');
232: (void) fputs(namebuf, stdout);
233: putchar(c);
234: in_name = FALSE;
235: }
236: else if (c != '>')
237: *sp++ = c;
238: else /* ah! candidate name! */
239: {
240: char *up;
241: NCURSES_CONST char *tp;
242:
243: *sp++ = '\0';
244: in_name = FALSE;
245:
246: suffix[0] = '\0';
247: if ((up = strchr(namebuf, '#')) != 0
248: || (up = strchr(namebuf, '=')) != 0
249: || ((up = strchr(namebuf, '@')) != 0 && up[1] == '>'))
250: {
251: (void) strcpy(suffix, up);
252: *up = '\0';
253: }
254:
255: if ((tp = nametrans(namebuf)) != 0)
256: {
257: (void) putchar(':');
258: (void) fputs(tp, stdout);
259: (void) fputs(suffix, stdout);
260: (void) putchar(':');
261: }
262: else
263: {
264: /* couldn't find a translation, just dump the name */
265: (void) putchar('<');
266: (void) fputs(namebuf, stdout);
267: (void) fputs(suffix, stdout);
268: (void) putchar('>');
269: }
270:
271: }
272: }
273:
274: /* Returns a string, stripped of leading/trailing whitespace */
275: static char *stripped(char *src)
276: {
277: while (isspace(*src))
278: src++;
279: if (*src != '\0') {
280: char *dst = strcpy(malloc(strlen(src)+1), src);
281: size_t len = strlen(dst);
282: while (--len != 0 && isspace(dst[len]))
283: dst[len] = '\0';
284: return dst;
285: }
286: return 0;
287: }
288:
289: /* Parse the "-e" option-value into a list of names */
290: static const char **make_namelist(char *src)
291: {
292: const char **dst = 0;
293:
294: char *s, *base;
1.2 millert 295: unsigned pass, n, nn;
1.1 millert 296: char buffer[BUFSIZ];
297:
1.2 millert 298: if (src == 0) {
299: /* EMPTY */;
300: } else if (strchr(src, '/') != 0) { /* a filename */
1.1 millert 301: FILE *fp = fopen(src, "r");
1.2 millert 302: if (fp == 0)
303: failed(src);
304:
1.1 millert 305: for (pass = 1; pass <= 2; pass++) {
306: nn = 0;
307: while (fgets(buffer, sizeof(buffer), fp) != 0) {
308: if ((s = stripped(buffer)) != 0) {
309: if (dst != 0)
310: dst[nn] = s;
311: nn++;
312: }
313: }
314: if (pass == 1) {
315: dst = (const char **)calloc(nn+1, sizeof(*dst));
316: rewind(fp);
317: }
318: }
319: fclose(fp);
320: } else { /* literal list of names */
321: for (pass = 1; pass <= 2; pass++) {
322: for (n = nn = 0, base = src; ; n++) {
323: int mark = src[n];
324: if (mark == ',' || mark == '\0') {
325: if (pass == 1) {
326: nn++;
327: } else {
328: src[n] = '\0';
329: if ((s = stripped(base)) != 0)
330: dst[nn++] = s;
331: base = &src[n+1];
332: }
333: }
334: if (mark == '\0')
335: break;
336: }
337: if (pass == 1)
338: dst = (const char **)calloc(nn+1, sizeof(*dst));
339: }
340: }
341: if (showsummary) {
342: fprintf(log_fp, "Entries that will be compiled:\n");
343: for (n = 0; dst[n] != 0; n++)
344: fprintf(log_fp, "%d:%s\n", n+1, dst[n]);
345: }
346: return dst;
347: }
348:
349: static bool matches(const char **needle, const char *haystack)
350: /* does entry in needle list match |-separated field in haystack? */
351: {
352: bool code = FALSE;
353: size_t n;
354:
355: if (needle != 0)
356: {
357: for (n = 0; needle[n] != 0; n++)
358: {
359: if (_nc_name_match(haystack, needle[n], "|"))
360: {
361: code = TRUE;
362: break;
363: }
364: }
365: }
366: else
367: code = TRUE;
368: return(code);
369: }
370:
371: int main (int argc, char *argv[])
372: {
1.2 millert 373: char my_tmpname[PATH_MAX];
1.1 millert 374: int v_opt = -1, debug_level;
375: int smart_defaults = TRUE;
376: char *termcap;
377: ENTRY *qp;
378:
379: int this_opt, last_opt = '?';
380:
381: int outform = F_TERMINFO; /* output format */
382: int sortmode = S_TERMINFO; /* sort_mode */
383:
1.2 millert 384: int fd;
1.1 millert 385: int width = 60;
386: bool formatted = FALSE; /* reformat complex strings? */
1.2 millert 387: bool numbers = TRUE; /* format "%'char'" to "%{number}" */
1.1 millert 388: bool infodump = FALSE; /* running as captoinfo? */
389: bool capdump = FALSE; /* running as infotocap? */
390: bool forceresolve = FALSE; /* force resolution */
391: bool limited = TRUE;
392: char *tversion = (char *)NULL;
393: const char *source_file = "terminfo";
394: const char **namelst = 0;
395: char *outdir = (char *)NULL;
396: bool check_only = FALSE;
397:
398: log_fp = stderr;
399:
400: if ((_nc_progname = strrchr(argv[0], '/')) == NULL)
401: _nc_progname = argv[0];
402: else
403: _nc_progname++;
404:
405: infodump = (strcmp(_nc_progname, "captoinfo") == 0);
406: capdump = (strcmp(_nc_progname, "infotocap") == 0);
407:
408: /*
409: * Processing arguments is a little complicated, since someone made a
410: * design decision to allow the numeric values for -w, -v options to
411: * be optional.
412: */
1.2 millert 413: while ((this_opt = getopt(argc, argv, "0123456789CILNR:TVce:fgo:rsvw")) != EOF) {
1.1 millert 414: if (isdigit(this_opt)) {
415: switch (last_opt) {
416: case 'v':
417: v_opt = (v_opt * 10) + (this_opt - '0');
418: break;
419: case 'w':
420: width = (width * 10) + (this_opt - '0');
421: break;
422: default:
423: if (this_opt != '1')
424: usage();
425: last_opt = this_opt;
426: width = 0;
427: }
428: continue;
429: }
430: switch (this_opt) {
431: case 'C':
432: capdump = TRUE;
433: outform = F_TERMCAP;
434: sortmode = S_TERMCAP;
435: break;
436: case 'I':
437: infodump = TRUE;
438: outform = F_TERMINFO;
439: sortmode = S_TERMINFO;
440: break;
441: case 'L':
442: infodump = TRUE;
443: outform = F_VARIABLE;
444: sortmode = S_VARIABLE;
445: break;
446: case 'N':
447: smart_defaults = FALSE;
448: break;
449: case 'R':
450: tversion = optarg;
451: break;
452: case 'T':
453: limited = FALSE;
454: break;
455: case 'V':
456: puts(NCURSES_VERSION);
457: return EXIT_SUCCESS;
458: case 'c':
459: check_only = TRUE;
460: break;
461: case 'e':
462: namelst = make_namelist(optarg);
463: break;
464: case 'f':
465: formatted = TRUE;
466: break;
1.2 millert 467: case 'g':
468: numbers = FALSE;
469: break;
1.1 millert 470: case 'o':
471: outdir = optarg;
472: break;
473: case 'r':
474: forceresolve = TRUE;
475: break;
476: case 's':
477: showsummary = TRUE;
478: break;
479: case 'v':
480: v_opt = 0;
481: break;
482: case 'w':
483: width = 0;
484: break;
485: default:
486: usage();
487: }
488: last_opt = this_opt;
489: }
490:
491: debug_level = (v_opt > 0) ? v_opt : (v_opt == 0);
492: _nc_tracing = (1 << debug_level) - 1;
493:
1.6 ! millert 494: if (_nc_tracing)
! 495: {
! 496: save_check_termtype = _nc_check_termtype;
! 497: _nc_check_termtype = check_termtype;
! 498: }
! 499:
1.4 millert 500: #ifndef HAVE_BIG_CORE
501: /*
502: * Aaargh! immedhook seriously hoses us!
503: *
504: * One problem with immedhook is it means we can't do -e. Problem
505: * is that we can't guarantee that for each terminal listed, all the
506: * terminals it depends on will have been kept in core for reference
507: * resolution -- in fact it's certain the primitive types at the end
508: * of reference chains *won't* be in core unless they were explicitly
509: * in the select list themselves.
510: */
511: if (namelst && (!infodump && !capdump))
512: {
513: (void) fprintf(stderr,
514: "Sorry, -e can't be used without -I or -C\n");
515: cleanup();
516: return EXIT_FAILURE;
517: }
518: #endif /* HAVE_BIG_CORE */
519:
1.1 millert 520: if (optind < argc) {
521: source_file = argv[optind++];
522: if (optind < argc) {
523: fprintf (stderr,
524: "%s: Too many file names. Usage:\n\t%s %s",
525: _nc_progname,
526: _nc_progname,
527: usage_string);
528: return EXIT_FAILURE;
529: }
530: } else {
531: if (infodump == TRUE) {
532: /* captoinfo's no-argument case */
1.2 millert 533: source_file = "/usr/share/misc/termcap";
534: if ((termcap = getenv("TERMCAP")) != 0
535: && (namelst = make_namelist(getenv("TERM"))) != 0) {
1.1 millert 536: if (access(termcap, F_OK) == 0) {
537: /* file exists */
538: source_file = termcap;
1.2 millert 539: } else
540: if (strcpy(my_tmpname, "/tmp/tic.XXXXXXXX")
541: && (fd = mkstemp(my_tmpname)) != -1
542: && (tmp_fp = fdopen(fd, "w")) != 0) {
543: fprintf(tmp_fp, "%s\n", termcap);
544: fclose(tmp_fp);
545: tmp_fp = fopen(source_file, "r");
546: to_remove = source_file;
547: } else {
548: failed("mkstemp");
1.1 millert 549: }
550: }
551: } else {
552: /* tic */
553: fprintf (stderr,
554: "%s: File name needed. Usage:\n\t%s %s",
555: _nc_progname,
556: _nc_progname,
557: usage_string);
1.2 millert 558: cleanup();
1.1 millert 559: return EXIT_FAILURE;
560: }
561: }
562:
1.2 millert 563: if (tmp_fp == 0
564: && (tmp_fp = fopen(source_file, "r")) == 0) {
1.1 millert 565: fprintf (stderr, "%s: Can't open %s\n", _nc_progname, source_file);
566: return EXIT_FAILURE;
567: }
568:
569: if (infodump)
570: dump_init(tversion,
571: smart_defaults
572: ? outform
573: : F_LITERAL,
574: sortmode, width, debug_level, formatted);
575: else if (capdump)
576: dump_init(tversion,
577: outform,
578: sortmode, width, debug_level, FALSE);
579:
580: /* parse entries out of the source file */
581: _nc_set_source(source_file);
582: #ifndef HAVE_BIG_CORE
583: if (!(check_only || infodump || capdump))
584: _nc_set_writedir(outdir);
585: #endif /* HAVE_BIG_CORE */
1.2 millert 586: _nc_read_entry_source(tmp_fp, (char *)NULL,
1.1 millert 587: !smart_defaults, FALSE,
588: (check_only || infodump || capdump) ? NULLHOOK : immedhook);
589:
590: /* do use resolution */
1.2 millert 591: if (check_only || (!infodump && !capdump) || forceresolve) {
592: if (!_nc_resolve_uses() && !check_only) {
593: cleanup();
1.1 millert 594: return EXIT_FAILURE;
1.2 millert 595: }
596: }
1.1 millert 597:
598: /* length check */
599: if (check_only && (capdump || infodump))
600: {
601: for_entry_list(qp)
602: {
603: if (matches(namelst, qp->tterm.term_names))
604: {
1.2 millert 605: int len = fmt_entry(&qp->tterm, NULL, TRUE, infodump, numbers);
1.1 millert 606:
607: if (len>(infodump?MAX_TERMINFO_LENGTH:MAX_TERMCAP_LENGTH))
608: (void) fprintf(stderr,
609: "warning: resolved %s entry is %d bytes long\n",
610: _nc_first_name(qp->tterm.term_names),
611: len);
612: }
613: }
614: }
615:
616: /* write or dump all entries */
617: if (!check_only)
618: {
619: if (!infodump && !capdump)
620: {
621: _nc_set_writedir(outdir);
622: for_entry_list(qp)
623: if (matches(namelst, qp->tterm.term_names))
1.2 millert 624: write_it(qp);
1.1 millert 625: }
626: else
627: {
628: /* this is in case infotocap() generates warnings */
629: _nc_curr_col = _nc_curr_line = -1;
630:
631: for_entry_list(qp)
632: if (matches(namelst, qp->tterm.term_names))
633: {
634: int j = qp->cend - qp->cstart;
635: int len = 0;
636:
637: /* this is in case infotocap() generates warnings */
638: _nc_set_type(_nc_first_name(qp->tterm.term_names));
639:
1.2 millert 640: (void) fseek(tmp_fp, qp->cstart, SEEK_SET);
1.1 millert 641: while (j-- )
642: if (infodump)
1.2 millert 643: (void) putchar(fgetc(tmp_fp));
1.1 millert 644: else
1.2 millert 645: put_translate(fgetc(tmp_fp));
1.1 millert 646:
1.2 millert 647: len = dump_entry(&qp->tterm, limited, numbers, NULL);
1.1 millert 648: for (j = 0; j < qp->nuses; j++)
649: len += dump_uses((char *)(qp->uses[j].parent), infodump);
650: (void) putchar('\n');
651: if (debug_level != 0 && !limited)
652: printf("# length=%d\n", len);
653: }
654: if (!namelst)
655: {
656: int c, oldc = '\0';
657: bool in_comment = FALSE;
658: bool trailing_comment = FALSE;
659:
1.2 millert 660: (void) fseek(tmp_fp, _nc_tail->cend, SEEK_SET);
661: while ((c = fgetc(tmp_fp)) != EOF)
1.1 millert 662: {
663: if (oldc == '\n') {
664: if (c == '#') {
665: trailing_comment = TRUE;
666: in_comment = TRUE;
667: } else {
668: in_comment = FALSE;
669: }
670: }
671: if (trailing_comment
672: && (in_comment || (oldc == '\n' && c == '\n')))
673: putchar(c);
674: oldc = c;
675: }
676: }
677: }
678: }
679:
680: /* Show the directory into which entries were written, and the total
681: * number of entries
682: */
683: if (showsummary
684: && (!(check_only || infodump || capdump))) {
685: int total = _nc_tic_written();
686: if (total != 0)
687: fprintf(log_fp, "%d entries written to %s\n",
688: total,
689: _nc_tic_dir((char *)0));
690: else
691: fprintf(log_fp, "No entries written\n");
692: }
1.2 millert 693: cleanup();
1.1 millert 694: return(EXIT_SUCCESS);
1.6 ! millert 695: }
! 696:
! 697: /*
! 698: * This bit of legerdemain turns all the terminfo variable names into
! 699: * references to locations in the arrays Booleans, Numbers, and Strings ---
! 700: * precisely what's needed (see comp_parse.c).
! 701: */
! 702:
! 703: #undef CUR
! 704: #define CUR tp->
! 705:
! 706: /* other sanity-checks (things that we don't want in the normal
! 707: * logic that reads a terminfo entry)
! 708: */
! 709: static void check_termtype(TERMTYPE *tp)
! 710: {
! 711: bool conflict = FALSE;
! 712: unsigned j, k;
! 713: char fkeys[STRCOUNT];
! 714:
! 715: /*
! 716: * A terminal entry may contain more than one keycode assigned to
! 717: * a given string (e.g., KEY_END and KEY_LL). But curses will only
! 718: * return one (the last one assigned).
! 719: */
! 720: memset(fkeys, 0, sizeof(fkeys));
! 721: for (j = 0; _nc_tinfo_fkeys[j].code; j++) {
! 722: char *a = tp->Strings[_nc_tinfo_fkeys[j].offset];
! 723: bool first = TRUE;
! 724: if (!VALID_STRING(a))
! 725: continue;
! 726: for (k = j+1; _nc_tinfo_fkeys[k].code; k++) {
! 727: char *b = tp->Strings[_nc_tinfo_fkeys[k].offset];
! 728: if (!VALID_STRING(b)
! 729: || fkeys[k])
! 730: continue;
! 731: if (!strcmp(a,b)) {
! 732: fkeys[j] = 1;
! 733: fkeys[k] = 1;
! 734: if (first) {
! 735: if (!conflict) {
! 736: _nc_warning("Conflicting key definitions (using the last)");
! 737: conflict = TRUE;
! 738: }
! 739: fprintf(stderr, "... %s is the same as %s",
! 740: keyname(_nc_tinfo_fkeys[j].code),
! 741: keyname(_nc_tinfo_fkeys[k].code));
! 742: first = FALSE;
! 743: } else {
! 744: fprintf(stderr, ", %s",
! 745: keyname(_nc_tinfo_fkeys[k].code));
! 746: }
! 747: }
! 748: }
! 749: if (!first)
! 750: fprintf(stderr, "\n");
! 751: }
! 752:
! 753: /*
! 754: * Quick check for color. We could also check if the ANSI versus
! 755: * non-ANSI strings are misused.
! 756: */
! 757: if ((max_colors > 0) != (max_pairs > 0)
! 758: || (max_colors > max_pairs))
! 759: _nc_warning("inconsistent values for max_colors and max_pairs");
! 760:
! 761: PAIRED(set_foreground, set_background)
! 762: PAIRED(set_a_foreground, set_a_background)
! 763:
! 764: /*
! 765: * These may be mismatched because the terminal description relies on
! 766: * restoring the cursor visibility by resetting it.
! 767: */
! 768: ANDMISSING(cursor_invisible, cursor_normal)
! 769: ANDMISSING(cursor_visible, cursor_normal)
! 770:
! 771: /*
! 772: * From XSI & O'Reilly, we gather that sc/rc are required if csr is
! 773: * given, because the cursor position after the scrolling operation is
! 774: * performed is undefined.
! 775: */
! 776: ANDMISSING(change_scroll_region, save_cursor)
! 777: ANDMISSING(change_scroll_region, restore_cursor)
! 778:
! 779: /*
! 780: * Some standard applications (e.g., vi) and some non-curses
! 781: * applications (e.g., jove) get confused if we have both ich/ich1 and
! 782: * smir/rmir. Let's be nice and warn about that, too, even though
! 783: * ncurses handles it.
! 784: */
! 785: if ((PRESENT(enter_insert_mode) || PRESENT(exit_insert_mode))
! 786: && (PRESENT(insert_character) || PRESENT(parm_ich))) {
! 787: _nc_warning("non-curses applications may be confused by ich/ich1 with smir/rmir");
! 788: }
! 789:
! 790: /*
! 791: * Finally, do the non-verbose checks
! 792: */
! 793: if (save_check_termtype != 0)
! 794: save_check_termtype(tp);
1.1 millert 795: }