xref: /csrg-svn/usr.bin/f77/libF77/mkvers.c (revision 47940)
1*47940Sbostic /*-
2*47940Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47940Sbostic  * All rights reserved.
4*47940Sbostic  *
5*47940Sbostic  * %sccs.include.proprietary.c%
623853Sjerry  */
723853Sjerry 
8*47940Sbostic #ifndef lint
9*47940Sbostic char copyright[] =
10*47940Sbostic "@(#) Copyright (c) 1980 The Regents of the University of California.\n\
11*47940Sbostic  All rights reserved.\n";
12*47940Sbostic #endif /* not lint */
13*47940Sbostic 
14*47940Sbostic #ifndef lint
15*47940Sbostic static char sccsid[] = "@(#)mkvers.c	1.2 (Berkeley) 04/12/91";
16*47940Sbostic #endif /* not lint */
17*47940Sbostic 
18*47940Sbostic char id_mkvers[] = "@(#)mkvers.c	1.2 04/12/91";
19*47940Sbostic 
2023853Sjerry /*
2123853Sjerry  * extract sccs id strings from source files
2223853Sjerry  * first arg is lib name.
2323853Sjerry  * Put them in Version.c
2423853Sjerry  */
2523853Sjerry 
2623853Sjerry #include	<stdio.h>
2723853Sjerry 
2823853Sjerry #define SCCS_ID		"@(#)"
2923853Sjerry #define VERSION		"Version.c"
3023853Sjerry 
main(argc,argv)3123853Sjerry main(argc, argv)
3223853Sjerry int argc; char **argv;
3323853Sjerry {
3423853Sjerry 	char buf[256];
3523853Sjerry 	char *s, *e;
3623853Sjerry 	char *index(), *ctime();
3723853Sjerry 	long t;
3823853Sjerry 	FILE *V, *fdopen();
3923853Sjerry 
4023853Sjerry 	V = stdout; /* fdopen(creat(VERSION, 0644), "w"); */
4123853Sjerry 	if (!V)
4223853Sjerry 	{
4323853Sjerry 		perror("mkvers");
4423853Sjerry 		exit(1);
4523853Sjerry 	}
4623853Sjerry 	if (argc > 1 && argv[1][0] != '.')
4723853Sjerry 	{
4823853Sjerry 		fprintf(V, "char *");
4923853Sjerry 		for (s = argv[1]; *s && *s != '.'; s++)
5023853Sjerry 			fputc(*s, V);
5123853Sjerry 		fprintf(V, "_id[] = {\n");
5223853Sjerry 	}
5323853Sjerry 	else
5423853Sjerry 		fprintf(V, "char *sccs_id[] = {\n");
5523853Sjerry 	if (argc-- > 1)
5623853Sjerry 	{
5723853Sjerry 		time(&t);
5823853Sjerry 		s = ctime(&t) + 4;
5923853Sjerry 		s[20] = '\0';
6023853Sjerry 		fprintf(V, "\t\"%s%s\t%s\",\n", SCCS_ID, *++argv, s);
6123853Sjerry 	}
6223853Sjerry 	while (--argc)
6323853Sjerry 	{
6423853Sjerry 		if (freopen(*++argv, "r", stdin) == NULL)
6523853Sjerry 		{
6623853Sjerry 			perror(*argv);
6723853Sjerry 			continue;
6823853Sjerry 		}
6923853Sjerry 		while(gets(buf))
7023853Sjerry 		{
7123853Sjerry 			s = buf;
7223853Sjerry 			while(s = index(s, '@'))
7323853Sjerry 				if (strncmp(s, SCCS_ID, 4) == 0)
7423853Sjerry 					break;
7523853Sjerry 			if (s)
7623853Sjerry 			{
7723853Sjerry 				e = index(s, '"');
7823853Sjerry 				if (e)
7923853Sjerry 					*e = '\0';
8023853Sjerry 				fprintf(V, "\t\"%s\",\n", s);
8123853Sjerry 				break;
8223853Sjerry 			}
8323853Sjerry 		}
8423853Sjerry 		if (feof(stdin))
8523853Sjerry 			fprintf(stderr, "%s: no sccs id string\n", *argv);
8623853Sjerry 	}
8723853Sjerry 	fprintf(V, "};\n");
8823853Sjerry 	fclose(V);
8923853Sjerry 	fflush(stdout);
9023853Sjerry 	fflush(stderr);
9123853Sjerry }
92