Exemplo n.º 1
0
/*
 ****************************************************************
 *	Ponto de Entrada					*
 ****************************************************************
 */
int
main (int argc, const char *argv[])
{
	int		sz;

	/*
	 *	Descobre o tamanho que não provoca colisões.
	 */
	for (sz = 300; insert_names (sz) < 0; sz++)
		/* vazio */;

	printf ("*** Tamanho calculado para tabela HASH: %d ***\n", sz);
	printf ("*** Tamanho da tabela de símbolos: %d entradas, %d bytes ***\n",
		sizeof (symtb) / sizeof (SYM), sizeof (symtb));

	/*
	 *	Gera 3 arquivos: "hashtb.s", "symtb.s" e "hashsz.s".
	 */
	mkasmtb
	(
		"hashtb.s",
		"hashtb",
		hashtb,
		sz * sizeof (SYM *),
		RW,
		sizeof (SYM *),
		hashtb_rel
	);

	mkasmtb
	(
		"symtb.s",
		"symtb",
		symtb,
		sizeof (symtb),
		RW,
		sizeof (SYM),
		symtb_rel	/* desnecessário: os ponteiros são nulos */
	);

	mkasmtb
	(
		"hashsz.s",
		"hashsz",
		&sz,
		sizeof (int),
		RO,
		sizeof (int),
		NOOBJENT
	);

	return (0);

}	/* end main */
void read_name(FILE* fp) {
	int readC;
	char name[8];
	int counter = 0;
	while (counter < 9) {
		if ((readC = getc(fp)) == -1) {
			return;
		}
		if (readC == ';') {
			name[7] = '\0';
			insert_names(name);
		} else if (readC == '\n') {
		} else {
			name[counter % 9] = readC;
		}
		counter++;
	}
}