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

📄 asconvrt.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 3 页
字号:
                    TabCount = 0;                }                FirstNonBlank = NULL;                LastLineColumnStart = ThisColumnStart;            }            SpaceCount = 0;            continue;        }        /* Ignore quoted strings */        if ((!CommentEnd) && (*SubBuffer == '\"'))        {            SubBuffer++;            SubBuffer = AsSkipPastChar (SubBuffer, '\"');            if (!SubBuffer)            {                return;            }            SpaceCount = 0;        }        if (*SubBuffer != ' ')        {            /* Not a space, skip to end of line */            SubBuffer = AsSkipUntilChar (SubBuffer, '\n');            if (!SubBuffer)            {                return;            }            if (TabCount > 0)            {                LastLineTabCount = TabCount;                TabCount = 0;            }            FirstNonBlank = NULL;            LastLineColumnStart = ThisColumnStart;            Column = 0;            SpaceCount = 0;        }        else        {            /* Another space */            SpaceCount++;            if (SpaceCount >= 4)            {                /* Replace this group of spaces with a tab character */                SpaceCount = 0;                NewSubBuffer = SubBuffer - 3;                if (TabCount <= ThisTabCount ? (ThisTabCount +1) : 0)                {                    *NewSubBuffer = '\t';                    NewSubBuffer++;                    SubBuffer++;                    TabCount++;                }                /* Remove the spaces */                SubBuffer = AsRemoveData (NewSubBuffer, SubBuffer);                continue;            }        }        SubBuffer++;    }}/****************************************************************************** * * FUNCTION:    AsCountLines * * DESCRIPTION: Count the number of lines in the input buffer.  Also count *              the number of long lines (lines longer than 80 chars). * ******************************************************************************/UINT32AsCountLines (    char                    *Buffer,    char                    *Filename){    char                    *SubBuffer = Buffer;    char                    *EndOfLine;    UINT32                  LineCount = 0;    UINT32                  LongLineCount = 0;    while (*SubBuffer)    {        EndOfLine = AsSkipUntilChar (SubBuffer, '\n');        if (!EndOfLine)        {            Gbl_TotalLines += LineCount;            return LineCount;        }        if ((EndOfLine - SubBuffer) > 80)        {            LongLineCount++;            VERBOSE_PRINT (("long: %.80s\n", SubBuffer));        }        LineCount++;        SubBuffer = EndOfLine + 1;    }    if (LongLineCount)    {        VERBOSE_PRINT (("%d Lines longer than 80 found in %s\n", LongLineCount, Filename));        Gbl_LongLines += LongLineCount;    }    Gbl_TotalLines += LineCount;    return LineCount;}/****************************************************************************** * * FUNCTION:    AsCountTabs * * DESCRIPTION: Simply count the number of tabs in the input file buffer * ******************************************************************************/voidAsCountTabs (    char                    *Buffer,    char                    *Filename){    UINT32                  i;    UINT32                  TabCount = 0;    for (i = 0; Buffer[i]; i++)    {        if (Buffer[i] == '\t')        {            TabCount++;        }    }    if (TabCount)    {        AsPrint ("Tabs found", TabCount, Filename);        Gbl_Tabs += TabCount;    }    AsCountLines (Buffer, Filename);}/****************************************************************************** * * FUNCTION:    AsCountNonAnsiComments * * DESCRIPTION: Count the number of "//" comments.  This type of comment is *              non-ANSI C. * ******************************************************************************/voidAsCountNonAnsiComments (    char                    *Buffer,    char                    *Filename){    char                    *SubBuffer = Buffer;    UINT32                  CommentCount = 0;    while (SubBuffer)    {        SubBuffer = strstr (SubBuffer, "//");        if (SubBuffer)        {            CommentCount++;            SubBuffer += 2;        }    }    if (CommentCount)    {        AsPrint ("Non-ANSI Comments found", CommentCount, Filename);        Gbl_NonAnsiComments += CommentCount;    }}/****************************************************************************** * * FUNCTION:    AsCountSourceLines * * DESCRIPTION: Count the number of C source lines.  Defined by 1) not a *              comment, and 2) not a blank line. * ******************************************************************************/voidAsCountSourceLines (    char                    *Buffer,    char                    *Filename){    char                    *SubBuffer = Buffer;    UINT32                  LineCount = 0;    UINT32                  WhiteCount = 0;    UINT32                  CommentCount = 0;    while (*SubBuffer)    {        /* Ignore comments */        if ((SubBuffer[0] == '/') &&            (SubBuffer[1] == '*'))        {            CommentCount++;            SubBuffer += 2;            while (SubBuffer[0] && SubBuffer[1] &&                    !(((SubBuffer[0] == '*') &&                      (SubBuffer[1] == '/'))))            {                if (SubBuffer[0] == '\n')                {                    CommentCount++;                }                SubBuffer++;            }        }        /* A linefeed followed by a non-linefeed is a valid source line */        else if ((SubBuffer[0] == '\n') &&                 (SubBuffer[1] != '\n'))        {            LineCount++;        }        /* Two back-to-back linefeeds indicate a whitespace line */        else if ((SubBuffer[0] == '\n') &&                 (SubBuffer[1] == '\n'))        {            WhiteCount++;        }        SubBuffer++;    }    /* Adjust comment count for legal header */    CommentCount -= Gbl_HeaderSize;    Gbl_SourceLines += LineCount;    Gbl_WhiteLines += WhiteCount;    Gbl_CommentLines += CommentCount;    VERBOSE_PRINT (("%d Comment %d White %d Code %d Lines in %s\n",                CommentCount, WhiteCount, LineCount, LineCount+WhiteCount+CommentCount, Filename));}/****************************************************************************** * * FUNCTION:    AsInsertPrefix * * DESCRIPTION: Insert struct or union prefixes * ******************************************************************************/voidAsInsertPrefix (    char                    *Buffer,    char                    *Keyword,    UINT8                   Type){    char                    *SubString;    char                    *SubBuffer;    char                    *EndKeyword;    int                     StrLength;    int                     InsertLength;    char                    *InsertString;    int                     TrailingSpaces;    char                    LowerKeyword[128];    int                     KeywordLength;    switch (Type)    {    case SRC_TYPE_STRUCT:        InsertString = "struct ";        break;    case SRC_TYPE_UNION:        InsertString = "union ";        break;    default:        return;    }    strcpy (LowerKeyword, Keyword);    strlwr (LowerKeyword);    SubBuffer = Buffer;    SubString = Buffer;    InsertLength = strlen (InsertString);    KeywordLength = strlen (Keyword);    while (SubString)    {        /* Find an instance of the keyword */        SubString = strstr (SubBuffer, LowerKeyword);        if (!SubString)        {            return;        }        SubBuffer = SubString;        /* Must be standalone word, not a substring */        if (AsMatchExactWord (SubString, KeywordLength))        {            /* Make sure the keyword isn't already prefixed with the insert */            if (!strncmp (SubString - InsertLength, InsertString, InsertLength))            {                /* Add spaces if not already at the end-of-line */                if (*(SubBuffer + KeywordLength) != '\n')                {                    /* Already present, add spaces after to align structure members */// ONLY FOR C FILES//                    AsInsertData (SubBuffer + KeywordLength, "        ", 8);                }                goto Next;            }            /* Make sure the keyword isn't at the end of a struct/union */            /* Note: This code depends on a single space after the brace */            if (*(SubString - 2) == '}')            {                goto Next;            }            /* Prefix the keyword with the insert string */            Gbl_MadeChanges = TRUE;            StrLength = strlen (SubString);            /* Is there room for insertion */            EndKeyword = SubString + strlen (LowerKeyword);            TrailingSpaces = 0;            while (EndKeyword[TrailingSpaces] == ' ')            {                TrailingSpaces++;            }            /*             * Use "if (TrailingSpaces > 1)" if we want to ignore casts             */            SubBuffer = SubString + InsertLength;            if (TrailingSpaces > InsertLength)            {                /* Insert the keyword */                memmove (SubBuffer, SubString, KeywordLength);                /* Insert the keyword */                memmove (SubString, InsertString, InsertLength);            }            else            {                AsInsertData (SubString, InsertString, InsertLength);            }        }Next:        SubBuffer += KeywordLength;    }}#ifdef ACPI_FUTURE_IMPLEMENTATION/****************************************************************************** * * FUNCTION:    AsTrimComments * * DESCRIPTION: Finds 3-line comments with only a single line of text * ******************************************************************************/voidAsTrimComments (    char                    *Buffer,    char                    *Filename){    char                    *SubBuffer = Buffer;    char                    *Ptr1;    char                    *Ptr2;    UINT32                  LineCount;    UINT32                  ShortCommentCount = 0;    while (1)    {        /* Find comment open, within procedure level */        SubBuffer = strstr (SubBuffer, "    /*");        if (!SubBuffer)        {            goto Exit;        }        /* Find comment terminator */        Ptr1 = strstr (SubBuffer, "*/");        if (!Ptr1)        {            goto Exit;        }        /* Find next EOL (from original buffer) */        Ptr2 = strstr (SubBuffer, "\n");        if (!Ptr2)        {            goto Exit;        }        /* Ignore one-line comments */        if (Ptr1 < Ptr2)        {            /* Normal comment, ignore and continue; */            SubBuffer = Ptr2;            continue;        }        /* Examine multi-line comment */        LineCount = 1;        while (Ptr1 > Ptr2)        {            /* Find next EOL */            Ptr2++;            Ptr2 = strstr (Ptr2, "\n");            if (!Ptr2)            {                goto Exit;            }            LineCount++;        }        SubBuffer = Ptr1;        if (LineCount <= 3)        {            ShortCommentCount++;        }    }Exit:    if (ShortCommentCount)    {        AsPrint ("Short Comments found", ShortCommentCount, Filename);    }}#endif

⌨️ 快捷键说明

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