2TFC026.MOD 1A Working and Enhanced STRIP.C for MAKEing FCNS! The Flying Chicken [SysOp] #1 @12456 3Friday, March 19, 1993 1 5:58 pm TFC026.MOD - Enhanced STRIP.C Author: The Flying Chicken Source: WWIV 4.20e-4.22 Version: 1.2 The original version of STRIP.C that came with the WWIV source for 4.20 had some bugs in it. In addition, it wasn't very smart. (Sorry Wayne <:) ) The biggest problem is that if you comment your code, i.e.: void input_str(char *s) /* ADD - ALTERNATE INPUT STRING MOD */ like I do, (everyone should comment their code!) or simply had a space after '(char *s)' up above, then STRIP.C would not include that line in your FCNS.H and unless the function returned an integer, you'd get a compiler error. Well, I prettied STRIP.C up to remove comments and dead space after the final ')' and included the bug fixes someone else wrote (sorry, can't find the author!). So, replace your old STRIP.C with the code below, compile using the small model (instructions below) and type MAKE FCNS (don't include the .H, it won't work!). v1.2 - Upgrade for 4.22 - now includes statics v1.0 - Initial release Before using this or any mod, back up your source !!!!! PKZIP source *.c *.h *.mak If you mess something up later and want to unstall the mod, just type: PKUNZIP source -o /* STRIP.C **********************************************************/ #include #include void strip_file(char *fn, FILE *out) { int i,i1; FILE *f; char s[161],s1[161],*ss; f=fopen(fn,"r"); if (!f) return; /* Tell who we're processing */ fprintf(out,"\n\n/* File: %s */\n\n",fn); printf("Processing: %s \r",fn); while (fgets(s,160,f)) { ss=strchr(s,'\n'); if (ss) *ss=0; if ((s[0]) && (strchr("*{}\t/# ",s[0])==NULL)) { /* removed trailing spaces */ i=strlen(s)-1; while ((s[i]==' ') && (i>=0)) { s[i--]=0; } while ((s[0]) && (s[strlen(s)-1]=='/') && (s[strlen(s)-2]=='*')) { /* remove comments at end of line */ for (i=strlen(s)-3; i>0; i--) { if ((s[i]=='*') && (s[i-1]=='/')) { s[i-2]=0; /* remove trailing spaces again */ i-=3; while ((s[i]==' ') && (i>=0)) { s[i--]=0; } break; } } if (i<=0) { s[0]=0; break; } } if (s[strlen(s)-1]==')') if (strncmp(s,"static",6)) fprintf(out,"%s;\n",s); } } fclose(f); } /****************************************************************************/ void main(int argc, char *argv[]) { int i,i1; FILE *out, *tmpin; char *ss,s[161]; if (argc!=3) { printf("Run the STRIP program only from the makefile.\n\n"); exit(-1); } printf("\n"); out=fopen(argv[1],"w"); fprintf(out,"#ifndef _FCNS_H_\n#define _FCNS_H_\n\n"); fprintf(out,"#include \"vardec.h\"\n#include \"net.h\"\n"); tmpin = fopen(argv[2],"r"); do { i1=fscanf(tmpin,"%s",s); if (i1>0) { if ((ss=strstr(s,".obj"))!=NULL) { *ss=0; strcat(s,".c"); ss=strrchr(s,'\\'); if (!ss) ss=s; else ++ss; } else ss=s; strip_file(ss,out); } } while (i1>0); fclose(tmpin); fprintf(out,"\n#endif\n"); fclose(out); exit(0); } /* End of STRIP.C ***************************************************/ Okay, now compile STRIP.C using the small model. With newer versions of WWIV, typing MAKE FCNS will compile STRIP.C if it is needed. You can try that first. If that doesn't compile it, do the following: If you really don't want to use the TC IDE to compile, issue this command from your source directory: tcc -ms -Ic:\tc\include -Lc:\tc\lib strip.c !!! MAKE SURE YOU POINT THE DIRECTORIES TO THE RIGHT PLACE ABOVE !!! I set my include and library directory to the defaults that TC set up, you should point yours to wherever your files are: -I - This is the location of your STDIO.H file. -L - This is the location of your C0S.OBJ file. DISCLAIMER: I make no guarantees with this mod whatsoever. Your installation of the mod is your acceptance of any damages caused to your hardware or software, incendental or otherwise. PLEASE REPORT ANY BUGS!