Пример #1
0
int
runmacro(int dot, int argc, Rune **argv)
{
	Rune *p;
	int i;
	Mac *m;
	
if(verbose && isupperrune(argv[0][0])) fprint(2, "run: %S\n", argv[0]);
	p = getds(argv[0]);
	if(p == nil){
		if(verbose)
			warn("ignoring unknown request %C%S", dot, argv[0]);
		if(verbose > 1){
			for(i=0; i<argc; i++)
				fprint(2, " %S", argv[i]);
			fprint(2, "\n");
		}
		return -1;
	}
	if(nmstack >= nelem(mstack)){
		fprint(2, "%L: macro stack overflow:");
		for(i=0; i<nmstack; i++)
			fprint(2, " %S", mstack[i].argv[0]);
		fprint(2, "\n");
		return -1;
	}
	m = &mstack[nmstack++];
	m->argc = argc;
	for(i=0; i<argc; i++)
		m->argv[i] = erunestrdup(argv[i]);
	pushinputstring(p);
	nr(L(".$"), argc-1);
	inputnotify(popmacro);
	return 0;
}
Пример #2
0
int
isalpharune(Rune c)
{
	Rune *p;

	if(isupperrune(c) || islowerrune(c))
		return 1;
	p = bsearch(c, _alpha2, nelem(_alpha2)/2, 2);
	if(p && c >= p[0] && c <= p[1])
		return 1;
	p = bsearch(c, _alpha1, nelem(_alpha1), 1);
	if(p && c == p[0])
		return 1;
	return 0;
}
Пример #3
0
int
istitlerune(Rune c)
{
	return isupperrune(c) && islowerrune(c);
}