Ignore:
Timestamp:
Feb 28, 2007, 2:33:51 AM (19 years ago)
Author:
Gregg Young
Message:

Indentation cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/internal/renum.c

    r2 r551  
    1717 */
    1818
     19int main(int argc, char *argv[])
     20{
    1921
    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;
    2828
    2929  printf("\nUsage:  renum dlg.h\n Produces new renumbered dlg.h & dlg.bak\n");
    3030
    31   if(argc < 2)
    32     strcpy(filein,"FM3DLG.H");
     31  if (argc < 2)
     32    strcpy(filein, "FM3DLG.H");
    3333  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");
    3939  else
    40     strcat(p,".BAK");
    41   if(!stricmp(filein,fileout)) {
     40    strcat(p, ".BAK");
     41  if (!stricmp(filein, fileout)) {
    4242    printf(" **Error: input file == output file -- \"%s\" == \"%s\"\n",
    43            filein,fileout);
     43           filein, fileout);
    4444    return 1;
    4545  }
    4646
    4747  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           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         }
     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        }
    9393      }
    9494      fclose(fpo);
     
    9797      fclose(fpi);
    9898      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);
    101101      return 1;
    102102    }
    103     if(fpi)
     103    if (fpi)
    104104      fclose(fpi);
    105105  }
    106106  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);
    109109    return 1;
    110110  }
Note: See TracChangeset for help on using the changeset viewer.