xref: /csrg-svn/old/boggle/comp.c (revision 57818)
147854Sbostic /*-
247854Sbostic  * Copyright (c) 1982 The Regents of the University of California.
347854Sbostic  * All rights reserved.
447854Sbostic  *
547854Sbostic  * %sccs.include.proprietary.c%
621500Smckusick  */
721500Smckusick 
89896Ssam #ifndef lint
921500Smckusick char copyright[] =
1047854Sbostic "@(#) Copyright (c) 1982 The Regents of the University of California.\n\
1121500Smckusick  All rights reserved.\n";
1247854Sbostic #endif /* not lint */
139896Ssam 
1421500Smckusick #ifndef lint
15*57818Storek static char sccsid[] = "@(#)comp.c	5.3 (Berkeley) 02/03/93";
1647854Sbostic #endif /* not lint */
1721500Smckusick 
189896Ssam #include <stdio.h>
199896Ssam #define MAX ' '
209896Ssam 
219896Ssam char new[MAX], old[MAX];
229896Ssam 
23*57818Storek main()
249896Ssam {
259896Ssam 	register int i, j;
269896Ssam 	old[0] = '\0';
279896Ssam 	while (fgets(&new[0], MAX, stdin) != NULL) {
289896Ssam 		for (i=0; i<MAX && old[i]==new[i]; i++);
299896Ssam 		if (i >= MAX) {
309896Ssam 			fprintf(stderr, "long word\n");
319896Ssam 			exit(1);
329896Ssam 		}
339896Ssam 		putc(i, stdout);
349896Ssam 		for (j=0; (old[j]=new[j]) != '\n'; j++);
359896Ssam 		old[j] = '\0';
369896Ssam 		fputs(&old[i], stdout);
379896Ssam 	}
38*57818Storek 	exit(0);
399896Ssam }
40