Changeset 551 for trunk/dll/internal/renum.c
- Timestamp:
- Feb 28, 2007, 2:33:51 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/internal/renum.c
r2 r551 17 17 */ 18 18 19 int main(int argc, char *argv[]) 20 { 19 21 20 int main (int argc,char *argv[]) { 21 22 static FILE *fpi,*fpo; 23 static int x = 20000; /* arbitrary starting number */ 24 static char s[256]; 25 static char filein[260],fileout[260]; 26 register char *p; 27 register int z; 22 static FILE *fpi, *fpo; 23 static int x = 20000; /* arbitrary starting number */ 24 static char s[256]; 25 static char filein[260], fileout[260]; 26 register char *p; 27 register int z; 28 28 29 29 printf("\nUsage: renum dlg.h\n Produces new renumbered dlg.h & dlg.bak\n"); 30 30 31 if (argc < 2)32 strcpy(filein, "FM3DLG.H");31 if (argc < 2) 32 strcpy(filein, "FM3DLG.H"); 33 33 else 34 strcpy(filein, argv[1]);35 strcpy(fileout, filein);36 p = strrchr(filein, '.');37 if (p)38 strcpy(p, ".BAK");34 strcpy(filein, argv[1]); 35 strcpy(fileout, filein); 36 p = strrchr(filein, '.'); 37 if (p) 38 strcpy(p, ".BAK"); 39 39 else 40 strcat(p, ".BAK");41 if (!stricmp(filein,fileout)) {40 strcat(p, ".BAK"); 41 if (!stricmp(filein, fileout)) { 42 42 printf(" **Error: input file == output file -- \"%s\" == \"%s\"\n", 43 filein,fileout);43 filein, fileout); 44 44 return 1; 45 45 } 46 46 47 47 remove(filein); 48 rename(fileout, filein);49 fpi = fopen(filein, "r+");50 if (fpi) {51 fpo = fopen(fileout, "w");52 if (fpo) {53 while (!feof(fpi)) {54 if(!fgets(s,256,fpi))55 56 if(s[strlen(s) - 1] == '\n')57 58 59 while(*p == ' ')60 61 if(p != s)62 memmove(s,p,strlen(p) + 1);63 if(*s) {64 65 while(*p == ' ' && p > s)66 67 if(*p == ' ')68 69 70 if(!*s) {71 fprintf(fpo,"\n");72 73 74 else if((*s == '#' && strncmp(s,"#define ",8)) ||75 !strncmp(s,"/*",2) || *s == '*')76 fprintf(fpo,"%s%s\n",(*s == '*') ? " " : "",s);77 78 79 80 while(*p == ' ' && p > s)81 82 if(*p == ' ')83 84 if(*s) {85 fprintf(fpo,"%s",s);86 for(z = strlen(s);z < 40;z++)87 fprintf(fpo," ");88 fprintf(fpo,"%d\n",x++);89 90 91 fprintf(fpo,"\n");92 48 rename(fileout, filein); 49 fpi = fopen(filein, "r+"); 50 if (fpi) { 51 fpo = fopen(fileout, "w"); 52 if (fpo) { 53 while (!feof(fpi)) { 54 if (!fgets(s, 256, fpi)) 55 break; 56 if (s[strlen(s) - 1] == '\n') 57 s[strlen(s) - 1] = 0; 58 p = s; 59 while (*p == ' ') 60 p++; 61 if (p != s) 62 memmove(s, p, strlen(p) + 1); 63 if (*s) { 64 p = &s[strlen(s) - 1]; 65 while (*p == ' ' && p > s) 66 p--; 67 if (*p == ' ') 68 *p = 0; 69 } 70 if (!*s) { 71 fprintf(fpo, "\n"); 72 x = (x - (x % 100)) + 100; 73 } 74 else if ((*s == '#' && strncmp(s, "#define ", 8)) || 75 !strncmp(s, "/*", 2) || *s == '*') 76 fprintf(fpo, "%s%s\n", (*s == '*') ? " " : "", s); 77 else { 78 s[39] = 0; 79 p = &s[strlen(s) - 1]; 80 while (*p == ' ' && p > s) 81 p--; 82 if (*p == ' ') 83 *p = 0; 84 if (*s) { 85 fprintf(fpo, "%s", s); 86 for (z = strlen(s); z < 40; z++) 87 fprintf(fpo, " "); 88 fprintf(fpo, "%d\n", x++); 89 } 90 else 91 fprintf(fpo, "\n"); 92 } 93 93 } 94 94 fclose(fpo); … … 97 97 fclose(fpi); 98 98 fpi = NULL; 99 rename(filein, fileout);100 printf(" **Error: couldn't open output file \"%s\"\n", fileout);99 rename(filein, fileout); 100 printf(" **Error: couldn't open output file \"%s\"\n", fileout); 101 101 return 1; 102 102 } 103 if (fpi)103 if (fpi) 104 104 fclose(fpi); 105 105 } 106 106 else { 107 rename(filein, fileout);108 printf(" **Error: couldn't open input file \"%s\"\n", filein);107 rename(filein, fileout); 108 printf(" **Error: couldn't open input file \"%s\"\n", filein); 109 109 return 1; 110 110 }
Note:
See TracChangeset
for help on using the changeset viewer.