xref: /original-bsd/old/boggle/comp.c (revision 4092c5cc)
1 /*-
2  * Copyright (c) 1982, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char copyright[] =
10 "@(#) Copyright (c) 1982, 1993\n\
11 	The Regents of the University of California.  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)comp.c	8.1 (Berkeley) 05/31/93";
16 #endif /* not lint */
17 
18 #include <stdio.h>
19 #define MAX ' '
20 
21 char new[MAX], old[MAX];
22 
23 main()
24 {
25 	register int i, j;
26 	old[0] = '\0';
27 	while (fgets(&new[0], MAX, stdin) != NULL) {
28 		for (i=0; i<MAX && old[i]==new[i]; i++);
29 		if (i >= MAX) {
30 			fprintf(stderr, "long word\n");
31 			exit(1);
32 		}
33 		putc(i, stdout);
34 		for (j=0; (old[j]=new[j]) != '\n'; j++);
35 		old[j] = '\0';
36 		fputs(&old[i], stdout);
37 	}
38 	exit(0);
39 }
40