559
same_param(const char *table, const char *param, unsigned length)
562
if (strncmp(table, param, length) == 0) {
563
result = !isdigit(UChar(param[length]));
569
lookup_params(const assoc * table, char *dst, char *src)
571
const char *ep = strtok(src, ";");
577
for (ap = table; ap->from; ap++) {
578
size_t tlen = strlen(ap->from);
580
if (same_param(ap->from, ep, tlen)) {
581
(void) strcat(dst, ap->to);
588
(void) strcat(dst, ep);
589
(void) strcat(dst, ";");
591
((ep = strtok((char *) 0, ";")));
593
dst[strlen(dst) - 1] = '\0';
559
599
analyze_string(const char *name, const char *cap, TERMTYPE *tp)
561
601
char buf[MAX_TERMINFO_LENGTH];
562
602
char buf2[MAX_TERMINFO_LENGTH];
565
605
int tp_lines = tp->Numbers[2];
632
676
&& (csi = skip_csi(sp)) != 0
633
677
&& (len = strspn(sp + csi, "0123456789;"))
634
&& ((sp[csi + len] == 'h') || (sp[csi + len] == 'l'))) {
635
char buf3[MAX_TERMINFO_LENGTH];
678
&& (next = csi + len)
679
&& ((sp[next] == 'h') || (sp[next] == 'l'))) {
637
(void) strcpy(buf2, (sp[csi + len] == 'h') ? "ECMA+" : "ECMA-");
681
(void) strcpy(buf2, (sp[next] == 'h') ? "ECMA+" : "ECMA-");
638
682
(void) strncpy(buf3, sp + csi, len);
642
ep = strtok(buf3, ";");
646
for (ap = std_modes; ap->from; ap++) {
647
size_t tlen = strlen(ap->from);
649
if (strncmp(ap->from, ep, tlen) == 0) {
650
(void) strcat(buf2, ap->to);
657
(void) strcat(buf2, ep);
658
(void) strcat(buf2, ";");
660
((ep = strtok((char *) 0, ";")));
661
buf2[strlen(buf2) - 1] = '\0';
686
expansion = lookup_params(std_modes, buf2, buf3);
665
689
/* now check for private-mode sequences */
667
691
&& (csi = skip_csi(sp)) != 0
668
692
&& sp[csi] == '?'
669
693
&& (len = strspn(sp + csi + 1, "0123456789;"))
670
&& ((sp[csi + 1 + len] == 'h') || (sp[csi + 1 + len] == 'l'))) {
671
char buf3[MAX_TERMINFO_LENGTH];
694
&& (next = csi + 1 + len)
695
&& ((sp[next] == 'h') || (sp[next] == 'l'))) {
673
(void) strcpy(buf2, (sp[csi + 1 + len] == 'h') ? "DEC+" : "DEC-");
697
(void) strcpy(buf2, (sp[next] == 'h') ? "DEC+" : "DEC-");
674
698
(void) strncpy(buf3, sp + csi + 1, len);
678
ep = strtok(buf3, ";");
682
for (ap = private_modes; ap->from; ap++) {
683
size_t tlen = strlen(ap->from);
685
if (strncmp(ap->from, ep, tlen) == 0) {
686
(void) strcat(buf2, ap->to);
693
(void) strcat(buf2, ep);
694
(void) strcat(buf2, ";");
696
((ep = strtok((char *) 0, ";")));
697
buf2[strlen(buf2) - 1] = '\0';
702
expansion = lookup_params(private_modes, buf2, buf3);
701
705
/* now check for ECMA highlight sequences */
703
707
&& (csi = skip_csi(sp)) != 0
704
708
&& (len = strspn(sp + csi, "0123456789;")) != 0
705
&& sp[csi + len] == 'm') {
706
char buf3[MAX_TERMINFO_LENGTH];
709
&& (next = csi + len)
710
&& sp[next] == 'm') {
708
712
(void) strcpy(buf2, "SGR:");
709
713
(void) strncpy(buf3, sp + csi, len);
713
ep = strtok(buf3, ";");
717
for (ap = ecma_highlights; ap->from; ap++) {
718
size_t tlen = strlen(ap->from);
720
if (strncmp(ap->from, ep, tlen) == 0) {
721
(void) strcat(buf2, ap->to);
728
(void) strcat(buf2, ep);
729
(void) strcat(buf2, ";");
731
((ep = strtok((char *) 0, ";")));
733
buf2[strlen(buf2) - 1] = '\0';
717
expansion = lookup_params(ecma_highlights, buf2, buf3);
1496
1481
status = _nc_read_file_entry(tfile[termcount],
1497
1482
&entries[termcount].tterm);
1484
(void) fprintf(stderr, "terminfo files not supported\n");
1485
ExitProgram(EXIT_FAILURE);
1500
1489
(void) fprintf(stderr,
1501
"infocmp: reading entry %s from system directories %s\n",
1502
argv[optind], tname[termcount]);
1490
"infocmp: reading entry %s from database\n",
1504
1493
status = _nc_read_entry(tname[termcount],
1505
1494
tfile[termcount],
1545
1533
analyze_string("smcup", enter_ca_mode, &entries[0].tterm);
1546
1534
analyze_string("rmcup", exit_ca_mode, &entries[0].tterm);
1548
ExitProgram(EXIT_SUCCESS);
1552
* Here's where the real work gets done
1557
(void) fprintf(stderr,
1558
"infocmp: about to dump %s\n",
1560
(void) printf("#\tReconstructed via infocmp from file: %s\n",
1562
len = dump_entry(&entries[0].tterm,
1563
suppress_untranslatable,
1570
(void) fprintf(stderr, "infocmp: length %d\n", len);
1575
(void) fprintf(stderr, "infocmp: dumping differences\n");
1576
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
1577
compare_entry(compare_predicate, &entries->tterm, quiet);
1582
(void) fprintf(stderr,
1583
"infocmp: dumping common capabilities\n");
1584
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
1585
compare_entry(compare_predicate, &entries->tterm, quiet);
1590
(void) fprintf(stderr,
1591
"infocmp: dumping differences\n");
1592
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
1593
compare_entry(compare_predicate, &entries->tterm, quiet);
1598
(void) fprintf(stderr, "infocmp: dumping use entry\n");
1599
len = dump_entry(&entries[0].tterm,
1600
suppress_untranslatable,
1605
for (i = 1; i < termcount; i++)
1606
len += dump_uses(tname[i], !(outform == F_TERMCAP
1607
|| outform == F_TCONVERR));
1610
(void) fprintf(stderr, "infocmp: length %d\n", len);
1539
* Here's where the real work gets done
1544
(void) fprintf(stderr,
1545
"infocmp: about to dump %s\n",
1547
(void) printf("#\tReconstructed via infocmp from file: %s\n",
1549
dump_entry(&entries[0].tterm,
1550
suppress_untranslatable,
1556
(void) fprintf(stderr, "infocmp: length %d\n", len);
1561
(void) fprintf(stderr, "infocmp: dumping differences\n");
1562
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
1563
compare_entry(compare_predicate, &entries->tterm, quiet);
1568
(void) fprintf(stderr,
1569
"infocmp: dumping common capabilities\n");
1570
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
1571
compare_entry(compare_predicate, &entries->tterm, quiet);
1576
(void) fprintf(stderr,
1577
"infocmp: dumping differences\n");
1578
(void) printf("comparing %s to %s.\n", tname[0], tname[1]);
1579
compare_entry(compare_predicate, &entries->tterm, quiet);
1584
(void) fprintf(stderr, "infocmp: dumping use entry\n");
1585
dump_entry(&entries[0].tterm,
1586
suppress_untranslatable,
1590
for (i = 1; i < termcount; i++)
1591
dump_uses(tname[i], !(outform == F_TERMCAP
1592
|| outform == F_TCONVERR));
1595
(void) fprintf(stderr, "infocmp: length %d\n", len);
1613
1599
} else if (compare == C_USEALL)
1614
1600
(void) fprintf(stderr, "Sorry, -u doesn't work with -F\n");