/* PWfix.c Version 1.0 22 May 1988 Compiles clean under Manx 3.4a Copyright (c) 1988 by Dan Fish All rights reserved. Permission is granted to redistribute this program in a non-profit manner provided the source code is included in the distribution and this copyright notice is unchanged. Power Windows V1.3, wonderful program that it is, makes several incorrect type declarations within the structures it writes for compilation under Manx. BorderVectors is defined as USHORT and should be SHORT By default, the text pointer in an IntuiText structure is defined as BYTE * and should be UBYTE * The same is also true of the text pointer to the window name in a NewWindow structure. So far these are the only noted problems, though there may be more. (I haven't generated anything extremely complicated with Power Windows yet.) Left untreated, these incorrect declarations, cause great aggravation in the form of a humongous compiler warning list. Crude, but effective, this program reads the source code file generated by Power Windows; through "casting" corrects the troublesome buggers and writes out a corrected file with a .pwfix suffix in the same directory. If you plan on modifying the Power Windows source code (putting things on the same line, etc.), I suggest you do so after running PWfix on it, as its relies heavily on the line structure of the code to accomplish its goals. If you find other problems or modify this code substantially, please drop a hardcopy of your new source code listing in the mail to: Dan Fish 7293 W. Desert Cove #95 Peoria, Az. 85345 "C"-ya! */ #include #include #define MAXLIN 100 #define TAB 9 main(argc,argv) int argc; char *argv[]; { FILE *infile, *outfile; static char fname[30]; /* copy of the input filename */ char string[MAXLIN]; /* maximum characters per line */ char *adr; /* variable pointer to above string */ int i=0, j=0, k=0; /* event counters */ int line=0; /* line counter */ int ch; /* Initialize these next variables to some ridiculous value so lines preceeding the first Itext and NewWindow structures won't be affected */ int Itxt=99999, NewWind=99999; if (argc<2) { printf("\n"); printf(" Usage: PWFix \n\n"); exit(); } if((infile = fopen(argv[1],"r")) != NULL) { strcpy(fname,argv[1]); strcat(fname,".pwfix"); outfile = fopen(fname,"w"); while (fgets(string,MAXLIN,infile)!=NULL) /* until EOF */ { line++; /* Let's see now... what line are we on? */ if ( strncmp(string,"USHORT BorderVectors",20) == 0) { i++; /* running tab on # of occurences */ adr = string; adr++; /* Get rid of the "U" */ fputs(adr,outfile); } else if (strncmp(string,"struct IntuiText IText",22)==0) { j++; /* another running tab */ Itxt = line; /* remember the line */ fputs(string,outfile); } else if (strncmp(string,"struct NewWindow",16)==0) { k++; /* yet another running tab */ NewWind = line; /* don't forget this line either */ fputs(string,outfile); } else if ((line == Itxt + 4)||(line == NewWind + 8)) { adr = string; adr ++; /* Get rid of the old Tab */ putc(TAB,outfile); /* Write a new tab */ fputs("(UBYTE *)",outfile); /* Add the "cast" */ fputs(adr,outfile); /* and tack on the string */ } else /* Don't change anything, */ fputs(string,outfile); /* just pass on the line */ /* to the output file */ } printf("\n"); printf("Corrected: %3d BorderVector(s)\n", i); /* Output */ printf(" %3d Intuitext structure(s)\n", j); /* the */ printf(" %3d NewWindow structure(s)\n\n", k); /* tally */ fclose(infile); fclose(outfile); exit(); } printf("\n"); printf(" Ack ! -- Can't open \"%s\" for input!\n\n", argv[1]); } /* end of manual input source generation!!! */