Last change
on this file since 2 was 2, checked in by root, 23 years ago |
Initial revision
|
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
2.1 KB
|
Line | |
---|
1 | #define INCL_DOS
|
---|
2 |
|
---|
3 | #include <stdlib.h>
|
---|
4 | #include <stdio.h>
|
---|
5 | #include <string.h>
|
---|
6 | #include <ctype.h>
|
---|
7 | #include <os2.h>
|
---|
8 |
|
---|
9 | #define lstrip(s) strip_lead_char(" \t",(s))
|
---|
10 | #define rstrip(s) strip_trail_char(" \t",(s))
|
---|
11 | #define stripcr(s) strip_trail_char("\r\n",(s))
|
---|
12 |
|
---|
13 | char * strip_trail_char (char *strip,char *a) {
|
---|
14 |
|
---|
15 | register char *p;
|
---|
16 |
|
---|
17 | if(a && *a && strip && *strip) {
|
---|
18 | p = &a[strlen(a) - 1];
|
---|
19 | while (*a && strchr(strip,*p) != NULL) {
|
---|
20 | *p = 0;
|
---|
21 | p--;
|
---|
22 | }
|
---|
23 | }
|
---|
24 | return a;
|
---|
25 | }
|
---|
26 |
|
---|
27 | char * strip_lead_char (char *strip,char *a) {
|
---|
28 |
|
---|
29 | register char *p = a;
|
---|
30 |
|
---|
31 | if(a && *a && strip && *strip) {
|
---|
32 | while(*p && strchr(strip,*p) != NULL)
|
---|
33 | p++;
|
---|
34 | if(p != a)
|
---|
35 | memmove(a,p,strlen(p) + 1);
|
---|
36 | }
|
---|
37 | return a;
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 | int main (void) {
|
---|
42 |
|
---|
43 | FILE *fpi,*fpo;
|
---|
44 | static char s[256];
|
---|
45 | char w;
|
---|
46 | int x;
|
---|
47 |
|
---|
48 | printf("Fixing up FM3STR.H\n");
|
---|
49 | fpi = fopen("FM3STR.H","r");
|
---|
50 | if(fpi) {
|
---|
51 | printf("FM3STR.H opened for read.\n");
|
---|
52 | fpo = fopen("FM3STR.BAK","w");
|
---|
53 | if(fpo) {
|
---|
54 | printf("FM3STR.BAK opened for write.\n");
|
---|
55 | for(x = 0;x < 4;x++) {
|
---|
56 | if(feof(fpi) ||
|
---|
57 | !fgets(s,
|
---|
58 | 256,
|
---|
59 | fpi)) {
|
---|
60 | printf("Premature end of FM3STR.H -- aborting.\n");
|
---|
61 | exit(1);
|
---|
62 | }
|
---|
63 | s[255] = 0;
|
---|
64 | stripcr(s);
|
---|
65 | lstrip(rstrip(s));
|
---|
66 | fprintf(fpo,
|
---|
67 | "%s\n",
|
---|
68 | s);
|
---|
69 | }
|
---|
70 | x = 0;
|
---|
71 | while(!feof(fpi)) {
|
---|
72 | if(!fgets(s,
|
---|
73 | 256,
|
---|
74 | fpi))
|
---|
75 | break;
|
---|
76 | s[255] = 0;
|
---|
77 | stripcr(s);
|
---|
78 | lstrip(rstrip(s));
|
---|
79 | w = s[60];
|
---|
80 | s[60] = 0;
|
---|
81 | if(*s &&
|
---|
82 | strncmp(s,
|
---|
83 | "/*",
|
---|
84 | 2)) {
|
---|
85 | fprintf(fpo,
|
---|
86 | "%-60.60s %u\n",
|
---|
87 | s,
|
---|
88 | x);
|
---|
89 | x++;
|
---|
90 | printf("%u \r",
|
---|
91 | x);
|
---|
92 | fflush(stdout);
|
---|
93 | }
|
---|
94 | else {
|
---|
95 | s[60] = w;
|
---|
96 | fprintf(fpo,
|
---|
97 | "%s\n",
|
---|
98 | s);
|
---|
99 | }
|
---|
100 | }
|
---|
101 | printf("Complete.\n");
|
---|
102 | fclose(fpo);
|
---|
103 | }
|
---|
104 | fclose(fpi);
|
---|
105 | }
|
---|
106 | return 0;
|
---|
107 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.