BSD 4_4 release
[unix-history] / usr / src / usr.bin / f77 / libU77 / mkvers.c
CommitLineData
82492b51
KB
1/*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
ad787160
C
5 * This module is believed to contain source code proprietary to AT&T.
6 * Use and redistribution is subject to the Berkeley Software License
7 * Agreement and your Software Agreement with AT&T (Western Electric).
161423a6
RE
8 */
9
82492b51
KB
10#ifndef lint
11char copyright[] =
12"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
13 All rights reserved.\n";
14#endif /* not lint */
15
16#ifndef lint
ad787160 17static char sccsid[] = "@(#)mkvers.c 5.2 (Berkeley) 4/12/91";
82492b51
KB
18#endif /* not lint */
19
ad787160 20char id_mkvers[] = "@(#)mkvers.c 5.2 4/12/91";
82492b51 21
939c0595
DL
22/*
23 * extract sccs id strings from source files
24 * first arg is lib name.
25 * Put them in Version.c
26 */
27
28#include <stdio.h>
29
30#define SCCS_ID "@(#)"
31#define VERSION "Version.c"
32
33main(argc, argv)
34int argc; char **argv;
35{
36 char buf[256];
37 char *s, *e;
38 char *index(), *ctime();
39 long t;
40 FILE *V, *fdopen();
41
42 V = stdout; /* fdopen(creat(VERSION, 0644), "w"); */
43 if (!V)
44 {
45 perror("mkvers");
46 exit(1);
47 }
48 if (argc > 1 && argv[1][0] != '.')
49 {
50 fprintf(V, "char *");
51 for (s = argv[1]; *s && *s != '.'; s++)
52 fputc(*s, V);
53 fprintf(V, "_id[] = {\n");
54 }
55 else
56 fprintf(V, "char *sccs_id[] = {\n");
57 if (argc-- > 1)
58 {
59 time(&t);
60 s = ctime(&t) + 4;
61 s[20] = '\0';
62 fprintf(V, "\t\"%s%s\t%s\",\n", SCCS_ID, *++argv, s);
63 }
64 while (--argc)
65 {
66 if (freopen(*++argv, "r", stdin) == NULL)
67 {
68 perror(*argv);
69 continue;
70 }
71 while(gets(buf))
72 {
73 s = buf;
74 while(s = index(s, '@'))
75 if (strncmp(s, SCCS_ID, 4) == 0)
76 break;
77 if (s)
78 {
79 e = index(s, '"');
80 if (e)
81 *e = '\0';
82 fprintf(V, "\t\"%s\",\n", s);
83 break;
84 }
85 }
86 if (feof(stdin))
87 fprintf(stderr, "%s: no sccs id string\n", *argv);
88 }
89 fprintf(V, "};\n");
90 fclose(V);
91 fflush(stdout);
92 fflush(stderr);
93}