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: 07/16 Comment utilities

========== CSplit: Version 2.0 ==========
========== CSplit: Begin part 7/16 ==========
                || itsPrevState == InCComment)
                break;
        default:
            if (c)
                code_lines++;
        }
        if (open_comment > close_comment)
        {
            cmt_lines++;
        }
        c = 0;
    }
    switch (itsState)
    {
    case NormalInput:
        switch (theEvent)
        {
        case FOUND_SLASH:
        case FOUND_NL:
        case FOUND_WHITESPACE:
            break;
        default:
            c++;
        }
        break;
    case BeginComment:
        switch (theEvent)
        {
        case FOUND_SLASH:               // Yes, it's a C++ comment.
            cpp_comments++;
            cmt_lines++;
            break;
        case FOUND_STAR:                // Yes, it's a C comment.
            open_comment++;
            cmt_lines++;
            break;
        }
        break;
    case StarInCComment:
        switch (theEvent)
        {
        case FOUND_SLASH:               // End of C comment.
            close_comment++;
            break;
        }
        break;
    }
}
int   processFile (CommentCounter &obj, char *pszFile)
{
    if (0 == obj.init (pszFile))
    {
        return 0;
    }
    else
    {
        obj.run();
        obj.unInit();
        if (! bTotalsOnly)
        {
            char *p = pszFile;
            if (*p == '.')
                p++;
            if (*p == '.')
                p++;
            if (*p == '\\')
                p++;
            if (bBalance)
            {
                printf ("%s\t%4d/%-4d %s\n",
                    p,
                    obj.getOpenComment(),
                    obj.getCloseComment(),
                    obj.getOpenComment() != obj.getCloseComment() ? "*" \
\
: " "
                );
            }
            else
            {
                long ratio = 1000 * obj.getCommentLines() / \
\
obj.getLines();
                printf ("%s\n%8lu %8lu %8lu %8lu %10ld.%ld %%\n",
                    p,
                    obj.getCppComments(),
                    obj.getCommentLines(),
                    obj.getCodeLines(),
                    obj.getLines(),
                    ratio / 10,
                    ratio % 10
                );
            }
        }
        obj.sumTotals();
        obj.reset();
    }
    return 1;
}
// Go through each file that match the file mask.
// Do subdirectory search if requested.
int   forAllMatch (CommentCounter &obj, int *pnFiles, char *szSearchPath)
{
    FFbuff  *pBuff;
    int     rc;
    char    szNewPath[260];
    pBuff = new FFbuff;
    if (!pBuff)
    {
        return -1;
    }
    // Recursively process all subdirectory.
    if (szSearchPath[strlen (szSearchPath) - 1] == ':')
        strcat (szSearchPath, "*.*");
    else
        strcat (szSearchPath, "\\*.*");
    // Subdirectory search requested.
    if (bSubdirs)
    {
        rc = pBuff->FindFirst (szSearchPath, FFbuff::ATTR_DIRECTORY);
        if (rc)
        {
            delete pBuff;
            return rc;
========== CSplit: End part 7/16 crc: 116f ==========
        // 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™.