TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: JARI LAAKSONEN
date: 1997-03-28 21:57:00
subject: 13/16 Comment utilities

========== CSplit: Version 2.0 ==========
========== CSplit: Begin part 13/16 ==========
 *   FIN-33720 Tampere
 *   FINLAND
 *
 *   Fidonet : 2:221/360.20
 *   Internet: jla@to.icl.fi
 */
#include "cmtxtrac.h"
void CommentExtractor::processActions (Event theEvent)
{
    int rc = 0;
    // This flag is needed when comment starting is continued in next \
\
line:
    //   /\
    //   * comment */
    // The BeginComment state is still on after InsideEscape state and
    // without flag the slash would be printed twice.
    static int SlashPrinted = 0;
    static int backsl = 0;
    static int nl = 0;
    switch (itsState)
    {
    case NormalInput:
        if (printWhiteSpace && theEvent == FOUND_WHITESPACE)
        {
            rc = 1;                     // Print whitespace.
        }
        break;
    case BeginComment:
        switch (theEvent)
        {
        case FOUND_SLASH:               // Yes, it's a C++ comment.
        case FOUND_STAR:                // Yes, it's a C comment.
            rc = 1;
            if (! SlashPrinted)
            {
                if (printLineNumbers)
                {
                    printLineNumber();
                }
                // Comment starting slash was not yet printed,
                // so print it now.
                print ('/');
                if (backsl)
                {
                    print ('\\');       // Print the previous backslash.
                    backsl = 0;
                }
                if (nl)
                {
                    print ('\n');       // Print the previous newline.
                    nl = 0;
                }
                SlashPrinted = 1;
            }
            else
                SlashPrinted = 0;
            break;
        case FOUND_BACKSLASH:           // Escaped character.
            backsl = 1;
            break;
        default:
            backsl = 0;
            nl = 0;
        }
        break;
    case InsideEscape:
        switch (itsPrevState)
        {
        case InCppComment:
        case InCComment:
        case StarInCppComment:
        case StarInCComment:
            rc = 1;
            break;
        case BeginComment:
            if (theEvent == FOUND_NL)
            {
                nl = 1;
            }
            break;
        }
        break;
    case StarInCComment:
        if (theEvent == FOUND_SLASH)
            SlashPrinted = 0;           // End of comment, clear flag.
        rc = 1;
        break;
    case StarInCppComment:
    case InCppComment:
        if (theEvent == FOUND_NL)
            SlashPrinted = 0;           // End of comment, clear flag.
    case InCComment:
        rc = 1;
        break;
    }
    if (theEvent == FOUND_NL)           // Newline can be printed always.
    {
        rc = 1;
    }
    if (rc)
        printChar();
}
int   main (int argc, char **argv)
{
    CommentExtractor obj;
    if (0 == obj.init (argc, argv))
    {
        fprintf (stderr, "USAGE: CMTREMOV InFile [OutFile]\n");
    }
    else
    {
        obj.setWhiteSpace (0);
        obj.setLineNumbers (1);
        obj.run();
        obj.unInit();
    }
    return 0;
}
========== CSplit: End file CMTXTRAC.CPP ==========
========== CSplit: Begin file FFBUFF.CPP ==========
/*
 * FFBUFF.CPP
 * Portable class for FindFirst/FindNext operations.
 *
 * ver 1.0, 28 Mar 1997
========== CSplit: End part 13/16 crc: 0890 ==========
        // Albert                      email: jla@to.icl.fi
--- GoldED/2 2.50+
---------------
* Origin: Albert's Point/2 in Finland, Europe (2:221/360.20)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.