⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmtconvr.cpp

📁 C语言库函数的源代码,是C语言学习参考的好文档。
💻 CPP
字号:
// +++Date last modified: 05-Jul-1997

/*
 * CMTCONVR.CPP
 * Implementation of comment converter.
 *
 * ver 1.0, 30 Jun 1996
 *
 * Public domain by:
 *   Jari Laaksonen
 *   Arkkitehdinkatu 30 A 2
 *   FIN-33720 Tampere
 *   FINLAND
 *
 *   Fidonet : 2:221/360.20
 *   Internet: jla@to.icl.fi
 */

#include "cmtconvr.h"

void CommentConverter::ProcessActions (Event theEvent)
{
    switch (itsState)
    {
    case BeginComment:
        if (theEvent == FOUND_SLASH)    // Yes, it's a C++ comment...
        {
            ChangeChar ('*');           // ...change to C-style.
        }
        break;

    case InCppComment:
        switch (theEvent)
        {
        case END_OF_FILE:           // EOF: if we are still in C++ comment...
        case FOUND_NL:              // End of C++ comment...
            print (" */");          // ...put ending C-comment mark.
            break;
        }
        break;

    case StarInCppComment:
        // End of C comment -- add space to prevent nested C comment.
        // For example: "// /*comment*/"
        //     becomes: "/* /*comment* / */"
        if (theEvent == FOUND_SLASH)
        {
            print (' ');
        }
        break;
    }

    PrintChar();
}

int   main (int argc, char **argv)
{
    CommentConverter CommConv;

    if (0 == CommConv.Init (argc, argv))
    {
        fprintf (stderr, "USAGE: CMTCONVR InFile [OutFile]\n");
    }
    else
    {
        CommConv.Run();
        CommConv.Uninit();

        fprintf (stderr, "\nOK! %lu lines processed. Last state = %d\n",
            CommConv.GetLines(), CommConv.GetLastState()
        );
    }

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -