|
|
1.1 root 1: /*
2: * Copyright (c) 1989 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * This code is derived from software contributed to Berkeley by
6: * James A. Woods.
7: *
8: * Redistribution and use in source and binary forms are permitted
9: * provided that: (1) source distributions retain this entire copyright
10: * notice and comment, and (2) distributions including binaries display
11: * the following acknowledgement: ``This product includes software
12: * developed by the University of California, Berkeley and its contributors''
13: * in the documentation or other materials provided with the distribution
14: * and in all advertising materials mentioning features or use of this
15: * software. Neither the name of the University nor the names of its
16: * contributors may be used to endorse or promote products derived
17: * from this software without specific prior written permission.
18: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21: */
22:
23: #ifndef lint
24: char copyright[] =
25: "@(#) Copyright (c) 1989 The Regents of the University of California.\n\
26: All rights reserved.\n";
27: #endif /* not lint */
28:
29: #ifndef lint
30: static char sccsid[] = "@(#)locate.bigram.c 4.7 (Berkeley) 6/1/90";
31: #endif /* not lint */
32:
33: /*
34: * bigram < text > bigrams
35: *
36: * List bigrams for 'updatedb' script.
37: * Use 'code' to encode a file using this output.
38: */
39:
40: #include <stdio.h>
41: #include <sys/param.h> /* for MAXPATHLEN */
42:
43: char buf1[MAXPATHLEN] = " ";
44: char buf2[MAXPATHLEN];
45:
46: main ( )
47: {
48: register char *cp;
49: register char *oldpath = buf1, *path = buf2;
50:
51: while ( fgets ( path, sizeof(buf2), stdin ) != NULL ) {
52:
53: /* skip longest common prefix */
54: for ( cp = path; *cp == *oldpath; cp++, oldpath++ )
55: if ( *oldpath == NULL )
56: break;
57: /*
58: * output post-residue bigrams only
59: */
60: while ( *cp != NULL && *(cp + 1) != NULL ) {
61: putchar ( *cp++ );
62: putchar ( *cp++ );
63: putchar ( '\n' );
64: }
65: if ( path == buf1 ) /* swap pointers */
66: path = buf2, oldpath = buf1;
67: else
68: path = buf1, oldpath = buf2;
69: }
70: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.