📄 lf2crlf.lex
字号:
// lf2crlf.lex // flex input to convert LF to CRLF, in the context of sftpc // copyright Scott McPeak, 1999 Terms of use are as specified in license.txt. // ------- Flex options ------------%option noyywrap%option nounput%option outfile="lf2crlf.cpp"%option prefix="lf2crlf_" // --------- C++ declarations ------------ #include "crlflex.h" // common declarations with crlf2lf.lex // say what the scanner's interface is #define YY_DECL void inner_LF_to_CRLF(StreamOutputDest &dest, \ int &CRs) #define yyterminate() return // ---------- rules ------------%%"\n" { dest.write("\r\n", 2);}"\r" { // \r isn't supposed to appear in LF text.. CRs++;}[^\r\n]+ { dest.write(yytext, yyleng);}%%// ---------------- additional C++ code ---------------#include "nonport.h" // LOCKERvoid LF_to_CRLF(StreamInputSource &source, StreamOutputDest &dest, int &CRs){ LOCKER streamSource = &source; inner_LF_to_CRLF(dest, CRs); streamSource = NULL;}#ifdef TEST_LF2CRLF#include "filesrc.h" // FileInputSource, FileOutputDest#include "test.h" // USUAL_MAINint entry(int argc, char *argv[]){ if (argc <= 2) { printf("usage: lf2crlf input-lf-file output-crlf-file\n"); return 0; } FILE *in = fopen(argv[1], "rb"); FILE *out = fopen(argv[2], "wb"); if (!in || !out) { printf("error opening one of the input files\n"); return 2; } FileInputSource src(in); FileOutputDest dest(out); int CRs=0; LF_to_CRLF(src, dest, CRs); printf("CRs=%d\n", CRs); fclose(in); fclose(out); return 0;}ARGS_MAIN#endif // TEST_LF2CRLF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -