137637Sbostic /*
262059Sbostic  * Copyright (c) 1989, 1993
362059Sbostic  *	The Regents of the University of California.  All rights reserved.
437637Sbostic  *
537637Sbostic  * This code is derived from software contributed to Berkeley by
637637Sbostic  * James A. Woods.
737637Sbostic  *
842737Sbostic  * %sccs.include.redist.c%
937637Sbostic  */
1037637Sbostic 
1114042Smckusick #ifndef lint
1262059Sbostic static char copyright[] =
1362059Sbostic "@(#) Copyright (c) 1989, 1993\n\
1462059Sbostic 	The Regents of the University of California.  All rights reserved.\n";
1537637Sbostic #endif /* not lint */
1614042Smckusick 
1737637Sbostic #ifndef lint
18*69016Sbostic static char sccsid[] = "@(#)locate.bigram.c	8.2 (Berkeley) 04/28/95";
1937637Sbostic #endif /* not lint */
2037637Sbostic 
2114042Smckusick /*
2214042Smckusick  *  bigram < text > bigrams
2314042Smckusick  *
2414051Smckusick  * List bigrams for 'updatedb' script.
2514051Smckusick  * Use 'code' to encode a file using this output.
2614042Smckusick  */
2714042Smckusick 
2814042Smckusick #include <stdio.h>
2937635Sjak #include <sys/param.h>			/* for MAXPATHLEN */
3014042Smckusick 
3137635Sjak char buf1[MAXPATHLEN] = " ";
3237635Sjak char buf2[MAXPATHLEN];
3314042Smckusick 
main()3414042Smckusick main ( )
3514042Smckusick {
3637242Sjak   	register char *cp;
3737242Sjak 	register char *oldpath = buf1, *path = buf2;
3814042Smckusick 
3938085Sbostic      	while ( fgets ( path, sizeof(buf2), stdin ) != NULL ) {
4014042Smckusick 
4137242Sjak 		/* skip longest common prefix */
4237242Sjak 		for ( cp = path; *cp == *oldpath; cp++, oldpath++ )
43*69016Sbostic 			if ( *oldpath == '\0' )
4437242Sjak 				break;
4514042Smckusick 		/*
4637635Sjak 		 * output post-residue bigrams only
4737635Sjak 		 */
48*69016Sbostic 		while ( *cp != '\0' && *(cp + 1) != '\0' ) {
4937242Sjak 			putchar ( *cp++ );
5037242Sjak 			putchar ( *cp++ );
5114042Smckusick 			putchar ( '\n' );
5214042Smckusick 		}
5337242Sjak 		if ( path == buf1 )		/* swap pointers */
5437242Sjak 			path = buf2, oldpath = buf1;
5537242Sjak 		else
5637242Sjak 			path = buf1, oldpath = buf2;
5714042Smckusick    	}
58*69016Sbostic 	return (0);
5914042Smckusick }
60