📄 infocmp.c
字号:
pr_bfooting(); pr_nheading(); } for (i = 0; i < numnums; i++) { if (((num[i].val = tgetnum (num[i].capname)) > -1) && printing != pr_none) pr_number (num[i].infoname, num[i].capname, num[i].fullname, num[i].val); if (verbose) (void) fprintf (trace, "%s=%d.\n", num[i].infoname, num[i].val); } if (printing != pr_none) { if (printing == pr_cap) pr_ncaps(); pr_nfooting(); pr_sheading(); } for (i = 0; i < numstrs; i++) { str[i].val = tgetstr (str[i].capname, (char **)0); if ((str[i].val != NULL) && printing != pr_none) pr_string (str[i].infoname, str[i].capname, str[i].fullname, str[i].val); if (verbose) { (void) fprintf (trace, "%s='", str[i].infoname); PR (trace, str[i].val); (void) fprintf (trace, "'.\n"); } } if (printing == pr_cap) pr_scaps(); if (printing != pr_none) pr_sfooting();}/* Set up the n'th terminal.*/check_nth_terminal (nterm, n)char *nterm;int n;{ register char boolval; register short numval; register char *strval; register int i; if (use) used[n] = FALSE; if (verbose) (void) fprintf (trace, "adding in terminal type '%s'.\n", nterm); (void) setupterm (nterm, devnull, (int *) 0); if (printing != pr_none) { pr_heading (nterm, ttytype); pr_bheading (); } if (diff || common || neither) { if (Aflag && Bflag) (void) printf ("comparing %s (TERMINFO=%s) to %s (TERMINFO=%s).\n", firstterm, term1info, nterm, term2info); else if (Aflag) (void) printf ("comparing %s (TERMINFO=%s) to %s.\n", firstterm, term1info, nterm); else if (Bflag) (void) printf ("comparing %s to %s (TERMINFO=%s).\n", firstterm, nterm, term2info); else (void) printf ("comparing %s to %s.\n", firstterm, nterm); (void) printf (" comparing booleans.\n"); } /* save away the values for the nth terminal */ for (i = 0; i < numbools; i++) { boolval = tgetflag (ibool[i].capname); if (use) { if (ibool[i].seenagain) { /* We do not have to worry about this impossible case ** since booleans can have only two values: true and false. ** if (boolval && (boolval != ibool[i].secondval)) ** { ** (void) fprintf (trace, "use= order dependency found:\n"); ** (void) fprintf (trace, " %s: %s has %d, %s has %d.\n", ** ibool[i].capname, ibool[i].secondname, ** ibool[i].secondval, nterm, boolval); ** } */ } else { if (boolval == TRUE) { ibool[i].seenagain = TRUE; ibool[i].secondval = boolval; ibool[i].secondname = nterm; if (ibool[i].val != boolval) ibool[i].changed = TRUE; else used[n] = TRUE; } } } if (boolval) { if (printing != pr_none) pr_boolean (ibool[i].infoname, ibool[i].capname, ibool[i].fullname, 1); if (common && (ibool[i].val == boolval)) (void) printf ("\t%s= T.\n", ibool[i].infoname); } else if (neither && !ibool[i].val) (void) printf ("\t!%s.\n", ibool[i].infoname); if (diff && (ibool[i].val != boolval)) (void) printf ("\t%s: %c:%c.\n", ibool[i].infoname, ibool[i].val?'T':'F', boolval?'T':'F'); if (verbose) (void) fprintf (trace, "%s: %d:%d,changed=%d,seen=%d.\n", ibool[i].infoname, ibool[i].val, boolval, ibool[i].changed, ibool[i].seenagain); } if (printing != pr_none) { if (printing == pr_cap) pr_bcaps(); pr_bfooting(); pr_nheading(); } if (diff || common || neither) (void) printf (" comparing numbers.\n"); for (i = 0; i < numnums; i++) { numval = tgetnum (num[i].capname); if (use) { if (num[i].seenagain) { if ((numval > -1) && (numval != num[i].secondval)) { (void) fprintf (stderr, "%s: use= order dependency found:\n", progname); (void) fprintf (stderr, " %s: %s has %d, %s has %d.\n", num[i].capname, num[i].secondname, num[i].secondval, nterm, numval); } } else { if (numval > -1) { num[i].seenagain = TRUE; num[i].secondval = numval; num[i].secondname = nterm; if ((numval > -1) && (num[i].val != numval)) num[i].changed = TRUE; else used[n] = TRUE; } } } if (numval > -1) { if (printing != pr_none) pr_number (num[i].infoname, num[i].capname, num[i].fullname, numval); if (common && (num[i].val == numval)) (void) printf ("\t%s= %d.\n", num[i].infoname, numval); } else if (neither && (num[i].val == -1)) (void) printf ("\t!%s.\n", num[i].infoname); if (diff && (num[i].val != numval)) (void) printf ("\t%s: %d:%d.\n", num[i].infoname, num[i].val, numval); if (verbose) (void) fprintf (trace, "%s: %d:%d,changed=%d,seen=%d.\n", num[i].infoname, num[i].val, numval, num[i].changed, num[i].seenagain); } if (printing != pr_none) { if (printing == pr_cap) pr_ncaps(); pr_nfooting(); pr_sheading(); } if (diff || common || neither) (void) printf (" comparing strings.\n"); for (i = 0; i < numstrs; i++) { strval = tgetstr (str[i].capname, (char **)0); if (use) { if (str[i].seenagain && (strval != NULL)) { if (!EQUAL (strval, str[i].secondval)) { (void) fprintf (stderr, "use= order dependency found:\n"); (void) fprintf (stderr, " %s: %s has '", str[i].capname, str[i].secondname); PR (stderr, str[i].secondval); (void) fprintf (stderr, "', %s has '", nterm); PR (stderr, strval); (void) fprintf (stderr, "'.\n"); } } else { if (strval != NULL) { str[i].seenagain = TRUE; str[i].secondval = strval; str[i].secondname = nterm; if (!EQUAL (str[i].val, strval)) str[i].changed = TRUE; else used[n] = TRUE; } } } if (strval != NULL) { if (printing != pr_none) pr_string (str[i].infoname, str[i].capname, str[i].fullname, strval); if (common && EQUAL (str[i].val, strval)) { (void) printf ("\t%s= '", str[i].infoname); PR (stdout, strval); (void) printf ("'.\n"); } } else if (neither && (str[i].val == NULL)) (void) printf ("\t!%s.\n", str[i].infoname); if (diff && !EQUAL (str[i].val, strval)) { (void) printf ("\t%s: '", str[i].infoname); PR (stdout, str[i].val); (void) printf ("','"); PR (stdout, strval); (void) printf ("'.\n"); } if (verbose) { (void) fprintf (trace, "%s: '", str[i].infoname); PR (trace, str[i].val); (void) fprintf (trace, "':'"); PR (trace, strval); (void) fprintf (trace, "',changed=%d,seen=%d.\n", str[i].changed, str[i].seenagain); } } if (printing == pr_cap) pr_scaps(); if (printing != pr_none) pr_sfooting();}/* A capability gets an at-sign if it no longer exists, but one of the relative entries contains a value for it. It gets printed if the original value is not seen in ANY of the relative entries, or if the FIRST relative entry that has the capability gives a DIFFERENT value for the capability.*/void dorelative (firstoptind, argc, argv)register int firstoptind;register int argc;register char **argv;{ register int i; /* turn off printing of termcap and long names */ pr_init (pr_terminfo); /* print out the entry name */ pr_heading ((char *)0, savettytype); pr_bheading(); /* Print out all bools that are different. */ for (i = 0; i < numbools; i++) if (!ibool[i].val && ibool[i].changed) pr_boolean (ibool[i].infoname, (char *)0, (char *)0, -1); else if (ibool[i].val && (ibool[i].changed || !ibool[i].seenagain)) pr_boolean (ibool[i].infoname, (char *)0, (char *)0, 1); pr_bfooting(); pr_nheading(); /* Print out all nums that are different. */ for (i = 0; i < numnums; i++) if (num[i].val < 0 && num[i].changed) pr_number (num[i].infoname, (char *)0, (char *)0, -1); else if (num[i].val >= 0 && (num[i].changed || !num[i].seenagain)) pr_number (num[i].infoname, (char *)0, (char *)0, num[i].val); pr_nfooting(); pr_sheading(); /* Print out all strs that are different. */ for (i = 0; i < numstrs; i++) if (str[i].val == NULL && str[i].changed) pr_string (str[i].infoname, (char *)0, (char *)0, (char *)0); else if ((str[i].val != NULL) && (str[i].changed || !str[i].seenagain)) pr_string (str[i].infoname, (char *)0, (char *)0, str[i].val); pr_sfooting(); /* Finish it up. */ for (i = firstoptind; i < argc; i++) if (used[i - firstoptind]) (void) printf ("\tuse=%s,\n", argv[i]); else (void) fprintf (stderr, "%s: 'use=%s' did not add anything to the description.\n", progname, argv[i]);}void setenv (termNinfo)register char *termNinfo;{ extern char **environ; static char *newenviron[2] = { 0, 0 }; static unsigned int termsize = BUFSIZ; static char _terminfo[BUFSIZ]; static char *terminfo = &_terminfo[0]; register int termlen; if (termNinfo && *termNinfo) { if (verbose) (void) fprintf (trace, "setting TERMINFO=%s.\n", termNinfo); termlen = strlen (termNinfo); if (termlen + 10 > termsize) { termsize = termlen + 20; terminfo = (char *) malloc (termsize * sizeof (char)); } if (terminfo == (char *) NULL) badmalloc(); (void) sprintf (terminfo, "TERMINFO=%s", termNinfo); newenviron[0] = terminfo; } else newenviron[0] = (char *) 0; environ = newenviron;}main (argc, argv)int argc;char **argv;{ register int i, c, firstoptind; char *tempargv[2]; char *term = getenv ("TERM"); term1info = term2info = getenv ("TERMINFO"); progname = argv[0]; /* parse options */ while ((c = getopt (argc, argv, "ducnILCvV1rw:s:A:B:")) != EOF) switch (c) { case 'v': verbose++; break; case '1': pr_onecolumn(1); break; case 'w': pr_width (atoi(optarg)); break; case 'd': diff++; break; case 'c': common++; break; case 'n': neither++; break; case 'u': use++; break; case 'L': pr_init (printing = pr_longnames); break; case 'I': pr_init (printing = pr_terminfo); break; case 'C': pr_init (printing = pr_cap); break; case 'A': term1info = optarg; Aflag++; break; case 'B': term2info = optarg; Bflag++; break; case 'r': pr_caprestrict(0); break; case 's': if (strcmp(optarg, "d") == 0) sortorder = by_database; else if (strcmp(optarg, "i") == 0) sortorder = by_terminfo; else if (strcmp(optarg, "l") == 0) sortorder = by_longnames; else if (strcmp(optarg, "c") == 0) sortorder = by_cap; else goto usage; break; case 'V': (void) printf ("%s: version %s\n", progname, "infocmp.c 1.10"); exit (0); case '?': usage: (void) fprintf (stderr, "usage: %s [-ducn] [-ILC] [-1Vv] [-s d|i|l|c] [-A directory] [-B directory] term-names ...\n", progname); (void) fprintf (stderr, "\t-d\tprint differences (the default for >1 term-name)\n"); (void) fprintf (stderr, "\t-u\tproduce relative description\n"); (void) fprintf (stderr, "\t-c\tprint common entries\n"); (void) fprintf (stderr, "\t-n\tprint entries in neither\n"); (void) fprintf (stderr, "\t-I\tprint terminfo entries (the default for 1 term-name)\n"); (void) fprintf (stderr, "\t-C\tprint termcap entries\n"); (void) fprintf (stderr, "\t-L\tprint long C variable names\n"); (void) fprintf (stderr, "\t-1\tsingle column output\n"); (void) fprintf (stderr, "\t-V\tprint program version\n"); (void) fprintf (stderr, "\t-v\tverbose debugging output\n"); (void) fprintf (stderr, "\t-s\tchange sort order\n"); (void) fprintf (stderr, "\t-A\tset $TERMINFO for first term-name\n"); (void) fprintf (stderr, "\t-B\tset $TERMINFO for other term-names\n"); exit (-1); } argc -= optind; argv += optind; optind = 0; /* Default to $TERM for -n, -I, -C and -L options. */ /* This is done by faking argv[][], argc and optind. */ if (neither && (argc == 0 || argc == 1)) { if (argc == 0) tempargv[0] = term; else tempargv[0] = argv[optind]; tempargv[1] = term; argc = 2; argv = tempargv; optind = 0; } else if ((printing != pr_none) && (argc == 0)) { tempargv[0] = term; argc = 1; argv = tempargv; optind = 0; } /* Check for enough names. */ if ((use || diff || common) && (argc <= 1)) { (void) fprintf (stderr, "%s: must have at least two terminal names for a comparison to be done.\n", progname); goto usage; } /* Set the default of diff -d or print -I */ if (!use && (printing == pr_none) && !common && !neither) { if (argc == 0 || argc == 1) { if (argc == 0) { tempargv[0] = term; argc = 1; argv = tempargv; optind = 0; } pr_init (printing = pr_terminfo); } else diff++; } /* Set the default sorting order. */ if (sortorder == none) switch ((int) printing) { case (int) pr_cap: sortorder = by_cap; break; case (int) pr_longnames: sortorder = by_longnames; break; case (int) pr_terminfo: case (int) pr_none: sortorder = by_terminfo; break; } firstterm = argv[optind++]; firstoptind = optind; allocvariables (argc, firstoptind); sortnames (); devnull = open("/dev/null", O_RDWR); setenv(term1info); initfirstterm (firstterm); setenv(term2info); for (i = 0; optind < argc; optind++, i++) check_nth_terminal (argv[optind], i); if (use) dorelative (firstoptind, argc, argv); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -