add -f on mv for Version
[unix-history] / usr / src / usr.bin / f77 / libF77 / mkvers.c
CommitLineData
dae4063a
JB
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7char id_mkvers[] = "@(#)mkvers.c 1.1 %G%";
8/*
9 * extract sccs id strings from source files
10 * first arg is lib name.
11 * Put them in Version.c
12 */
13
14#include <stdio.h>
15
16#define SCCS_ID "@(#)"
17#define VERSION "Version.c"
18
19main(argc, argv)
20int argc; char **argv;
21{
22 char buf[256];
23 char *s, *e;
24 char *index(), *ctime();
25 long t;
26 FILE *V, *fdopen();
27
28 V = stdout; /* fdopen(creat(VERSION, 0644), "w"); */
29 if (!V)
30 {
31 perror("mkvers");
32 exit(1);
33 }
34 if (argc > 1 && argv[1][0] != '.')
35 {
36 fprintf(V, "char *");
37 for (s = argv[1]; *s && *s != '.'; s++)
38 fputc(*s, V);
39 fprintf(V, "_id[] = {\n");
40 }
41 else
42 fprintf(V, "char *sccs_id[] = {\n");
43 if (argc-- > 1)
44 {
45 time(&t);
46 s = ctime(&t) + 4;
47 s[20] = '\0';
48 fprintf(V, "\t\"%s%s\t%s\",\n", SCCS_ID, *++argv, s);
49 }
50 while (--argc)
51 {
52 if (freopen(*++argv, "r", stdin) == NULL)
53 {
54 perror(*argv);
55 continue;
56 }
57 while(gets(buf))
58 {
59 s = buf;
60 while(s = index(s, '@'))
61 if (strncmp(s, SCCS_ID, 4) == 0)
62 break;
63 if (s)
64 {
65 e = index(s, '"');
66 if (e)
67 *e = '\0';
68 fprintf(V, "\t\"%s\",\n", s);
69 break;
70 }
71 }
72 if (feof(stdin))
73 fprintf(stderr, "%s: no sccs id string\n", *argv);
74 }
75 fprintf(V, "};\n");
76 fclose(V);
77 fflush(stdout);
78 fflush(stderr);
79}