📄 fcnrules.c
字号:
/************************************************************* Copyright (c) 1993-1995 by Paul Long All rights reserved.**************************************************************//************************************************************* fcnrules.c This source file contains a set of rules for writing the code of each function out to a file named <function name>.fcn and the code that precedes each function out to a file named <function name>.pre. The code following the last function is written out to a file named epilogue.out. NOTE: The *.fcn file does not contain the function declarator. The declarator is in the corresponding *.pre file. NOTE: This technique assumes that your file system supports file names as long as your function name.**************************************************************/#include <string.h>#include <stdio.h>#include <stdlib.h>#include "metre.h"/* Name of the file that will contain the code following the last function. Until then, it is a dummy name for the file that contains the code that precedes a function (and includes the function declarator) until the file can be renamed. This works out nicely because then we do not have to rename the last file.*/#define LAST_FILE_NAME "epilogue.out"void rules(void){ /* Pointer to output-file stream. */ static FILE *fp; /* Tells lin.end that line written. */ static BOOLEAN line_written; /* At beginning of module, initialize variables and open output file. */ if (mod.begin) { line_written = FALSE; fp = fopen(LAST_FILE_NAME, "w"); } /* Close last file (just being tidy). */ if (mod.end) fclose(fp); /* At beginning of function, close the code-preceding-function file, rename it to <function name>.pre, then open new file as <function name>.fcn. This will hold the function body. */ if (fcn.begin) { static char file_name[FILENAME_MAX]; fclose(fp); strcpy(file_name, fcn_name()); strcat(file_name, ".pre"); rename(LAST_FILE_NAME, file_name); strcpy(file_name, fcn_name()); strcat(file_name, ".fcn"); fp = fopen(file_name, "w"); } /* At end of function, write the last line of the function body, tell the lin.end trigger that we have already taken care of it, then open new file which will either be for the code preceding the next function or the code following the last function--we do not know which yet. */ if (fcn.end) { fputs(line(), fp); line_written = TRUE; freopen(LAST_FILE_NAME, "w", fp); } /* At the end of every line, write it out if supposed to. */ if (lin.end) if (line_written) line_written = FALSE; else fputs(line(), fp);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -