blob: 458bfab0686e71e50fd452e8dbf055ac13c7c820 [file] [log] [blame]
Guido van Rossum1bc716f1996-06-28 19:12:06 +00001#include <stdio.h>
2#include <direct.h>
3#include <string.h>
4
5/* Copy files from source directories to ./src changing
6file names and #include names to 8x3 lower case */
7
8char *usage = "You must be in the \"pc\" directory.\n";
9char *list[] = {"..\\Include", "..\\Modules", "..\\Objects", "..\\Parser", "..\\Python", ".", 0};
Thomas Wouters78890102000-07-22 19:25:51 +000010
11int
12main(int argc, char ** argv)
Guido van Rossum1bc716f1996-06-28 19:12:06 +000013{
14 DIR *dpath;
15 struct dirent *dir;
16 int len;
17 char **plist;
18 char *pt1, *pt2, *name;
19 char dest_path[256], src_path[256], buf256[256];
20 FILE *fpin, *fpout;
21
22 for (plist = list; *plist; plist++){
23 if ((dpath = opendir(*plist)) == NULL){
24 printf(usage);
25 return 1;
26 }
27
28 while (dir = readdir(dpath)){
29 name = dir->d_name;
30 len = strlen(name);
31 if (len > 2 && name[len - 2] == '.' &&
32 (name[len - 1] == 'c' || name[len - 1] == 'h')){
33 strcpy(buf256, name);
34 if (len > 10){
35 buf256[8] = '.';
36 buf256[9] = name[len - 1];
37 buf256[10] = 0;
38 }
39 strlwr(buf256);
40 strncpy(src_path, *plist, 256);
41 strncat(src_path, "\\", 256);
42 strncat(src_path, name, 256);
43 strncpy(dest_path, ".\\src\\", 256);
44 strncat(dest_path, buf256, 256);
45 printf("Copying %-30s to %s\n", src_path, dest_path);
46 fpin = fopen(src_path, "r");
47 fpout = fopen(dest_path, "w");
48 while (fgets(buf256, 256, fpin)){
49 if (!strncmp(buf256, "#include", 8)){
50 strlwr(buf256);
51 if ((pt1 = strstr(buf256, "\"")) &&
52 (pt2 = strstr(buf256, ".")) &&
53 (*(pt2 + 1) == 'h') &&
54 (pt2 - pt1 > 9)){
55 for (pt1 += 9; *pt2; pt1++, pt2++)
56 *pt1 = *pt2;
57 *pt1 = 0;
58 }
59 }
60 fputs(buf256, fpout);
61 }
62 fclose(fpin);
63 fclose(fpout);
64 }
65 }
66 closedir(dpath);
67 }
68 return 0;
Thomas Wouters78890102000-07-22 19:25:51 +000069}