1: #ifndef lint
   2: static char sccsid[] = "@(#)bigram.c	4.2	(Berkeley)	7/21/83";
   3: #endif not lint
   4: 
   5: /*
   6:  *  bigram < text > bigrams
   7:  *
   8:  * List bigrams for 'updatedb' script.
   9:  * Use 'code' to encode a file using this output.
  10:  */
  11: 
  12: #include <stdio.h>
  13: 
  14: #define MAXPATH 1024        /* maximum pathname length */
  15: 
  16: char path[MAXPATH];
  17: char oldpath[MAXPATH] = " ";
  18: 
  19: main ( )
  20: {
  21:     register int count, j;
  22: 
  23:         while ( gets ( path ) != NULL ) {
  24: 
  25:         count = prefix_length ( oldpath, path );
  26:         /*
  27: 		   output post-residue bigrams only
  28: 		*/
  29:         for ( j = count; path[j] != NULL; j += 2 ) {
  30:             if ( path[j + 1] == NULL )
  31:                 break;
  32:             putchar ( path[j] );
  33:             putchar ( path[j + 1] );
  34:             putchar ( '\n' );
  35:         }
  36:         strcpy ( oldpath, path );
  37:     }
  38: }
  39: 
  40: prefix_length ( s1, s2 )    /* return length of longest common prefix */
  41:     char *s1, *s2;      /* ... of strings s1 and s2 */
  42: {
  43:     register char *start;
  44: 
  45:         for ( start = s1; *s1 == *s2; s1++, s2++ )
  46:         if ( *s1 == NULL )
  47:                 break;
  48:         return ( s1 - start );
  49: }

Defined functions

main defined in line 19; never used
prefix_length defined in line 40; used 1 times
  • in line 25

Defined variables

oldpath defined in line 17; used 2 times
path defined in line 16; used 7 times
sccsid defined in line 2; never used

Defined macros

MAXPATH defined in line 14; used 2 times
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2298
Valid CSS Valid XHTML 1.0 Strict