rlook.c
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 72 行
C
72 行
#ifndef lintstatic char sccsid[] = "@(#)rlook.c 1.2 (Berkeley) 8/11/83";#endif#define NULL 0#define EOS 0#define HSHSIZ 101struct nlist { char *name; char *def; int ydef; struct nlist *next;};struct nlist *hshtab[HSHSIZ];struct nlist *lookup();char *install();char *malloc();char *copy();int hshval;struct nlist *lookup(str)char *str;{ register char *s1, *s2; register struct nlist *np; static struct nlist nodef; s1 = str; for (hshval = 0; *s1; ) hshval += *s1++; hshval %= HSHSIZ; for (np = hshtab[hshval]; np!=NULL; np = np->next) { s1 = str; s2 = np->name; while (*s1++ == *s2) if (*s2++ == EOS) return(np); } return(&nodef);}char *install(nam, val, tran)char *nam, *val;int tran;{ register struct nlist *np; if ((np = lookup(nam))->name == NULL) { np = (struct nlist *)malloc(sizeof(*np)); np->name = copy(nam); np->def = copy(val); np->ydef = tran; np->next = hshtab[hshval]; hshtab[hshval] = np; return(np->def); } free(np->def); np->def = copy(val); return(np->def);}char *copy(s)register char *s;{ register char *p, *s1; p = s1 = (char *) malloc((unsigned)strlen(s)+1); while (*s1++ = *s++); return(p);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?