Exemplo n.º 1
0
static void
initmain()
{
	object *m, *d;
	m = add_module("__main__");
	if (m == NULL)
		fatal("can't create __main__ module");
	d = getmoduledict(m);
	if (dictlookup(d, "__builtins__") == NULL) {
		if (dictinsert(d, "__builtins__", getbuiltins()))
			fatal("can't add __builtins__ to __main__");
	}
}
Exemplo n.º 2
0
dicthashelement_t *dictinstall(char *name, dicthashelement_t **hashtable)
{
    dicthashelement_t  *np;
    unsigned hashval;

    if ((np = dictlookup(name, hashtable)) == NULL)
    {
        np = (dicthashelement_t *) calloc (1,sizeof(*np));
        if (np == NULL || (np->word = strdup(name)) == NULL)
            return NULL;

        np->nphns = 0;
        hashval = dicthash(name);
        np->next = hashtable[hashval];
        hashtable[hashval] = np;
    }
    return np;
}