xref: /csrg-svn/usr.bin/f77/libU77/mkvers.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
4*47944Sbostic  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623041Skre  */
723041Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic char copyright[] =
10*47944Sbostic "@(#) Copyright (c) 1980 The Regents of the University of California.\n\
11*47944Sbostic  All rights reserved.\n";
12*47944Sbostic #endif /* not lint */
13*47944Sbostic 
14*47944Sbostic #ifndef lint
15*47944Sbostic static char sccsid[] = "@(#)mkvers.c	5.2 (Berkeley) 04/12/91";
16*47944Sbostic #endif /* not lint */
17*47944Sbostic 
18*47944Sbostic char id_mkvers[] = "@(#)mkvers.c	5.2 04/12/91";
19*47944Sbostic 
2023041Skre /*
2110560Sdlw  * extract sccs id strings from source files
2210560Sdlw  * first arg is lib name.
2310560Sdlw  * Put them in Version.c
2410560Sdlw  */
2510560Sdlw 
2610560Sdlw #include	<stdio.h>
2710560Sdlw 
2810560Sdlw #define SCCS_ID		"@(#)"
2910560Sdlw #define VERSION		"Version.c"
3010560Sdlw 
main(argc,argv)3110560Sdlw main(argc, argv)
3210560Sdlw int argc; char **argv;
3310560Sdlw {
3410560Sdlw 	char buf[256];
3510560Sdlw 	char *s, *e;
3610560Sdlw 	char *index(), *ctime();
3710560Sdlw 	long t;
3810560Sdlw 	FILE *V, *fdopen();
3910560Sdlw 
4010560Sdlw 	V = stdout; /* fdopen(creat(VERSION, 0644), "w"); */
4110560Sdlw 	if (!V)
4210560Sdlw 	{
4310560Sdlw 		perror("mkvers");
4410560Sdlw 		exit(1);
4510560Sdlw 	}
4612001Sdlw 	if (argc > 1 && argv[1][0] != '.')
4712001Sdlw 	{
4812001Sdlw 		fprintf(V, "char *");
4912001Sdlw 		for (s = argv[1]; *s && *s != '.'; s++)
5012001Sdlw 			fputc(*s, V);
5112001Sdlw 		fprintf(V, "_id[] = {\n");
5212001Sdlw 	}
5312001Sdlw 	else
5412001Sdlw 		fprintf(V, "char *sccs_id[] = {\n");
5510560Sdlw 	if (argc-- > 1)
5610560Sdlw 	{
5710560Sdlw 		time(&t);
5810560Sdlw 		s = ctime(&t) + 4;
5910560Sdlw 		s[20] = '\0';
6010560Sdlw 		fprintf(V, "\t\"%s%s\t%s\",\n", SCCS_ID, *++argv, s);
6110560Sdlw 	}
6210560Sdlw 	while (--argc)
6310560Sdlw 	{
6410560Sdlw 		if (freopen(*++argv, "r", stdin) == NULL)
6510560Sdlw 		{
6610560Sdlw 			perror(*argv);
6710560Sdlw 			continue;
6810560Sdlw 		}
6910560Sdlw 		while(gets(buf))
7010560Sdlw 		{
7110560Sdlw 			s = buf;
7210560Sdlw 			while(s = index(s, '@'))
7310560Sdlw 				if (strncmp(s, SCCS_ID, 4) == 0)
7410560Sdlw 					break;
7510560Sdlw 			if (s)
7610560Sdlw 			{
7710560Sdlw 				e = index(s, '"');
7810560Sdlw 				if (e)
7910560Sdlw 					*e = '\0';
8010560Sdlw 				fprintf(V, "\t\"%s\",\n", s);
8110560Sdlw 				break;
8210560Sdlw 			}
8310560Sdlw 		}
8410560Sdlw 		if (feof(stdin))
8510560Sdlw 			fprintf(stderr, "%s: no sccs id string\n", *argv);
8610560Sdlw 	}
8710560Sdlw 	fprintf(V, "};\n");
8810560Sdlw 	fclose(V);
8910560Sdlw 	fflush(stdout);
9010560Sdlw 	fflush(stderr);
9110560Sdlw }
92