/* Changes comment format from pre-1.10 format (c in first column, $ in later columns) to 1.10 comment format (c++ syntax). does so by changing all comments to // Renames the old file to filename^ I Highly suggest you archive ALL files processed before running this program You should be able to run with wildcards ! */ /* Jeffrey V. Siebers (JVS) !! Use at Your Own Risk !! !! The author is NOT responsible for any damage done by this software !! Modification History: 16-April-1997: 1.00: Program Created */ #define Revision 1.00 #define MAIN // define this as the module that has MAIN in it const char *Prog_Name = "convert_dcomment"; /* to convert data */ #include #include #include #include /* for tolower */ #include /* for time_t */ #define MAX_STR_LEN 512 #define OK 0 #define FAIL -1 /* ******************* function prototypes ******************************* */ int dcomment_convert(char *source); /* *********************************************************************** */ void print_runtime_info(int argc, char *argv[]) { // print file header stuff printf("Command Line: "); for(int i=0; i icount) strcpy(filename, argv[icount]); else { char string[MAX_STR_LEN]; printf("\n INPUT NAME OF FILE TO READ >"); gets(string);sscanf(string,"%s",filename); } if(dcomment_convert(filename)!=OK) { printf("\n ERROR Processing File %s",filename); } }while(++icount < argc); printf("\n Normal Termination for %s\n",Prog_Name); exit(EXIT_SUCCESS); } /* *********************************************************************** */ int dcomment_convert(char *source) { char destination[MAX_STR_LEN]; strcpy(destination,source); /* create temp output file name */ strcat(destination,"temp_file"); /* open files for input and output */ FILE *istream = fopen(source,"r"); if(istream == NULL) { printf("\n File Open Error: %s",source); exit(1); } FILE *ostream = fopen(destination,"w"); if(ostream == NULL) { printf("\n File Open Error: %s", destination); exit(1); } /* process the input */ char string[MAX_STR_LEN]; while( fgets(string, MAX_STR_LEN, istream) != NULL) /* read a line from a file */ { /* check for comment, convert it to c++ style comments */ switch( string[0] ) { /* check for full line comments */ case 'c': // Comment Fields case 'C': // Comment Fields fprintf(ostream,"//%s",string); break; default: /* check for partial line comments */ int length = strlen(string); /* have temporary string to put everything in */ char ostring[MAX_STR_LEN]; int j=0; for(int i=0; i