Exemple #1
0
/* The GNU hash table is an array of 32-bit values. (Although in a
 * 64-bit ELF file the mask subpart consists of 64-bit values. But an
 * array cannot change its type midway through, so in this case the
 * mask values are split across two array entries.)
 */
static void outgnuhash(void const *ptr, long size, int ndx)
{
    Elf64_Word const *entries = ptr;
    long count = size / sizeof *entries;
    int buckets, masks;
    int i, n;

    (void)ndx;
    if (count < 4) {
	outwords(ptr, size, ndx);
	return;
    }
    buckets = entries[0];
    masks = entries[2];
    if (iself64())
	masks *= 2;
    if (4 + masks + buckets > count) {
	outwords(ptr, size, ndx);
	return;
    }

    beginblock(TRUE);
    for (i = 0 ; i < 4 ; ++i)
	outdec(entries[i]);
    n = i;
    if (masks) {
	linebreak();
	for (i = 0 ; i < masks ; ++i)
	    outf("0x%08lX", entries[n + i]);
	n += i;
    }
    if (buckets) {
	linebreak();
	for (i = 0 ; i < buckets ; ++i)
	    outdec(entries[n + i]);
	n += i;
    }
    if (n < count) {
	linebreak();
	for (i = n ; i < count ; ++i)
	    outf("0x%08lX", entries[i]);
    }
    endblock();
}
Exemple #2
0
/*
	Analyze a two word sentence
*/
int english(void)
{
	char *msg;
	int type1, type2, val1, val2;

	verb = object = motion = 0;
	type2 = val2 = -1;
	type1 = val1 = -1;
	msg = "bad grammar...";

	getwords();

	if (!(*word1))
		return 0;		    /* ignore whitespace	*/
	if (!analyze(word1, &type1, &val1)) /* check word1	*/
		return 0;		    /* didn't know it	*/

	if (type1 == 2 && val1 == SAY) {
		verb = SAY; /* repeat word & act upon if..	*/
		object = 1;
		return 1;
	}

	if (*word2)
		if (!analyze(word2, &type2, &val2))
			return 0; /* didn't know it	*/

	/* check his grammar */
	if ((type1 == 3) && (type2 == 3) &&
	    (val1 == 51) && (val2 == 51)) {
		outwords();
		return 0;
	} else if (type1 == 3) {
		rspeak(val1);
		return 0;
	} else if (type2 == 3) {
		rspeak(val2);
		return 0;
	} else if (type1 == 0) {
		if (type2 == 0) {
			printf("%s\n", msg);
			return 0;
		} else
			motion = val1;
	} else if (type2 == 0)
		motion = val2;
	else if (type1 == 1) {
		object = val1;
		if (type2 == 2)
			verb = val2;
		if (type2 == 1) {
			printf("%s\n", msg);
			return 0;
		}
	} else if (type1 == 2) {
		verb = val1;
		if (type2 == 1)
			object = val2;
		if (type2 == 2) {
			printf("%s\n", msg);
			return 0;
		}
	} else
		bug(36);
	return 1;
}