static bool files_merge(){ rewind(cinTableFile); rewind(cinGouCiFile); char buf[FILE_READ_BUFFER_SIZE]; VERBOSE_PRINT("Merging files.\n"); while(fgets(buf,FILE_READ_BUFFER_SIZE, tmplFile)!=NULL){ bool printAsIs=true; if (strncasecmp(buf,"END_TABLE",strlen("END_TABLE"))==0){ file_cat(outFile,cinTableFile); }else if (strncasecmp(buf,"END_GOUCI",strlen("END_GOUCI"))==0){ file_cat(outFile,cinGouCiFile); }else if (strncmp(buf,"VALID_INPUT_CHARS",strlen("VALID_INPUT_CHARS"))==0){ fprintf(outFile,"VALID_INPUT_CHARS = %s\n",validInputChars); printAsIs=false; }else if (strncmp(buf,"MAX_KEY_LENGTH",strlen("MAX_KEY_LENGTH"))==0){ fprintf(outFile,"MAX_KEY_LENGTH = %d\n",maxKeyLength); printAsIs=false; } if (printAsIs){ fputs(buf,outFile); } } fclose(cinTableFile); fclose(cinGouCiFile); return true; }
static inline void _current_phrase (FILE * const output, const wave_phrase * const p, unsigned int phrase_count) { FILE * code_file = tmpfile (); FILE * alloc_file = tmpfile (); wave_collection* collection = wave_phrase_get_collection(p); /* Print the beginning of the function. * Each function shall contain exactly one phrase. */ fprintf (output, "void phrase_%d (void)\n{\n", phrase_count); /* Unroll repetitions that depend on paths. */ wave_collection_unroll_path(collection); /* Compute the AST indexes. */ wave_collection_compute_indexes(collection); /* Replace paths that can be replaced. */ wave_collection_replace_path(collection); /* Compute the lengths and coordinates of the collections. */ wave_collection_compute_length_and_coords(collection); /* Generate the code and the allocations. * Required allocations are discovered while generating the code, but must * be put at the beginning. */ wave_code_generation_collection(code_file, alloc_file, collection); /* Append the contents of the files to the real output. */ fseek (alloc_file, 0, SEEK_SET); fseek (code_file, 0, SEEK_SET); file_cat (output, alloc_file); file_cat (output, code_file); /* Print the garbage cleaning at the end of the function. */ fprintf (output, "wave_garbage_clean ();\n"); /* Close the function. */ fprintf (output, "}\n"); fclose (code_file); fclose (alloc_file); }
static void cmd_cat( int cmdc, char *cmdv[COMMAND_WORD_NUM] ) { file_cat( cmdv[1] ); }