xref: /original-bsd/old/boggle/comp.c (revision cd89438c)
1 /*-
2  * Copyright (c) 1982 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 char copyright[] =
10 "@(#) Copyright (c) 1982 The Regents of the University of California.\n\
11  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)comp.c	5.2 (Berkeley) 04/08/91";
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 }
39