Ejemplo n.º 1
0
static void
compare_predicate(PredType type, PredIdx idx, const char *name)
/* predicate function to use for entry difference reports */
{
    ENTRY *e1 = &entries[0];
    ENTRY *e2 = &entries[1];
    char buf1[MAX_STRING];
    char buf2[MAX_STRING];
    int b1, b2;
    int n1, n2;
    char *s1, *s2;
    bool found;
    int extra = 1;

    switch (type) {
    case CMP_BOOLEAN:
	check_user_definable(idx, BOOLWRITE);
	b1 = e1->tterm.Booleans[idx];
	switch (compare) {
	case C_DIFFERENCE:
	    b2 = next_entry->Booleans[idx];
	    if (!(b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN) && b1 != b2)
		(void) printf("\t%s: %s%s%s.\n",
			      name,
			      dump_boolean(b1),
			      bool_sep,
			      dump_boolean(b2));
	    break;

	case C_COMMON:
	    if (b1 != ABSENT_BOOLEAN) {
		found = TRUE;
		for_each_entry() {
		    b2 = next_entry->Booleans[idx];
		    if (b1 != b2) {
			found = FALSE;
			break;
		    }
		}
		if (found) {
		    (void) printf("\t%s= %s.\n", name, dump_boolean(b1));
		}
	    }
	    break;

	case C_NAND:
	    if (b1 == ABSENT_BOOLEAN) {
		found = TRUE;
		for_each_entry() {
		    b2 = next_entry->Booleans[idx];
		    if (b1 != b2) {
			found = FALSE;
			break;
		    }
		}
		if (found) {
		    (void) printf("\t!%s.\n", name);
		}
	    }
	    break;
	}
Ejemplo n.º 2
0
static void
compare_predicate(int type, int idx, const char *name)
/* predicate function to use for entry difference reports */
{
    register ENTRY *e1 = &entries[0];
    register ENTRY *e2 = &entries[1];
    char buf1[MAX_STRING], buf2[MAX_STRING];
    int b1, b2;
    int n1, n2;
    char *s1, *s2;

    switch (type) {
    case CMP_BOOLEAN:
	b1 = e1->tterm.Booleans[idx];
	b2 = e2->tterm.Booleans[idx];
	switch (compare) {
	case C_DIFFERENCE:
	    if (!(b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN) && b1 != b2)
		(void) printf("\t%s: %s%s%s.\n",
			      name,
			      dump_boolean(b1),
			      bool_sep,
			      dump_boolean(b2));
	    break;

	case C_COMMON:
	    if (b1 == b2 && b1 != ABSENT_BOOLEAN)
		(void) printf("\t%s= %s.\n", name, dump_boolean(b1));
	    break;

	case C_NAND:
	    if (b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN)
		(void) printf("\t!%s.\n", name);
	    break;
	}
	break;

    case CMP_NUMBER:
	n1 = e1->tterm.Numbers[idx];
	n2 = e2->tterm.Numbers[idx];
	dump_numeric(n1, buf1);
	dump_numeric(n2, buf2);
	switch (compare) {
	case C_DIFFERENCE:
	    if (!((n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC)) && n1 != n2)
		(void) printf("\t%s: %s, %s.\n", name, buf1, buf2);
	    break;

	case C_COMMON:
	    if (n1 != ABSENT_NUMERIC && n2 != ABSENT_NUMERIC && n1 == n2)
		(void) printf("\t%s= %s.\n", name, buf1);
	    break;

	case C_NAND:
	    if (n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC)
		(void) printf("\t!%s.\n", name);
	    break;
	}
	break;

    case CMP_STRING:
	s1 = e1->tterm.Strings[idx];
	s2 = e2->tterm.Strings[idx];
	switch (compare) {
	case C_DIFFERENCE:
	    if (capcmp(idx, s1, s2)) {
		dump_string(s1, buf1);
		dump_string(s2, buf2);
		if (strcmp(buf1, buf2))
		    (void) printf("\t%s: %s, %s.\n", name, buf1, buf2);
	    }
	    break;

	case C_COMMON:
	    if (s1 && s2 && !capcmp(idx, s1, s2))
		(void) printf("\t%s= '%s'.\n", name, TIC_EXPAND(s1));
	    break;

	case C_NAND:
	    if (!s1 && !s2)
		(void) printf("\t!%s.\n", name);
	    break;
	}
	break;

    case CMP_USE:
	/* unlike the other modes, this compares *all* use entries */
	switch (compare) {
	case C_DIFFERENCE:
	    if (!useeq(e1, e2)) {
		(void) fputs("\tuse: ", stdout);
		print_uses(e1, stdout);
		fputs(", ", stdout);
		print_uses(e2, stdout);
		fputs(".\n", stdout);
	    }
	    break;

	case C_COMMON:
	    if (e1->nuses && e2->nuses && useeq(e1, e2)) {
		(void) fputs("\tuse: ", stdout);
		print_uses(e1, stdout);
		fputs(".\n", stdout);
	    }
	    break;

	case C_NAND:
	    if (!e1->nuses && !e2->nuses)
		(void) printf("\t!use.\n");
	    break;
	}
    }
}