File:  [MW Coherent from dump] / coherent / a / usr / src / misc / skip.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:34 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * One or more characters not matching some criterion.
 * skip(s1, matcher, fin)
 */
#include <stdio.h>
char *
skip(s1, matcher, fin)
register char *s1;
int (*matcher)();
register char **fin;
{
	char c;
	char *start = s1;

	for(*fin = NULL; (c = *s1++) && !(*matcher)(c); *fin = s1)
		;
	if(NULL == *fin)
		return(NULL);
	return(start);
}
#ifdef TEST
#include <ctype.h>
#include "misc.h"

/* eliminatye under ansi */
digit(s)
char s;
{
	return(isdigit(s));
}

main()
{
	char s1[80], *fin;

	for(;;) {
		ask(s1, "s1");
		if(!strcmp(s1, "quit"))
			exit(0);
		if(NULL == skip(s1, digit, &fin))
			printf("No non digits\n");
		else {
			*fin = '\0';
			printf("%s\n", s1);
		}
	}
}
#endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.