smatch.c

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 45 行

C
45
字号
/* smatch.c - match a switch */#include "../h/mh.h"#define abs(i) (i < 0 ? -i : i)smatch(string, swp)register char *string;register struct swit *swp;{    register char  *sp,                   *tcp;    struct swit *tp;    int     firstone,            stringlen;    firstone = UNKWNSW;    if (string == 0)	return firstone;    for (stringlen = strlen (string), tp = swp; tcp = tp -> sw; tp++) {	if (stringlen < abs (tp -> minchars))	    continue;		/* no match */	for (sp = string; *sp == *tcp++;) {	    if (*sp++ == 0)		return (tp - swp);/* exact match */	}	if (*sp != 0) {	    if (*sp != ' ')		continue;	/* no match */	    if (*--tcp == 0)		return (tp - swp);/* exact match */	}	if (firstone == UNKWNSW)	    firstone = tp - swp;	else	    firstone = AMBIGSW;    }    return (firstone);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?