VirtualBox

Changeset 46737 in vbox


Ignore:
Timestamp:
Jun 23, 2013 12:11:45 PM (12 years ago)
Author:
vboxsync
Message:

FE/VBoxAutostart: Todos and comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxAutostart/VBoxAutostartCfg.cpp

    r42732 r46737  
    381381}
    382382
    383 static const char *autostartConfigTokenToString(PCFGTOKEN pToken)
    384 {
    385     switch (pToken->enmType)
     383/**
     384 * Returns a stringified version of the token type.
     385 *
     386 * @returns Stringified version of the token type.
     387 * @param   enmType         Token type.
     388 */
     389static const char *autostartConfigTokenTypeToStr(CFGTOKENTYPE enmType)
     390{
     391    switch (enmType)
    386392    {
    387393        case CFGTOKENTYPE_COMMA:
     
    396402            return "<EOF>";
    397403        case CFGTOKENTYPE_ID:
    398             return pToken->u.Id.achToken;
     404            return "<Identifier>";
    399405        default:
    400406            AssertFailed();
     
    406412}
    407413
     414/**
     415 * Returns a stringified version of the token.
     416 *
     417 * @returns Stringified version of the token type.
     418 * @param   pToken         Token.
     419 */
     420static const char *autostartConfigTokenToString(PCFGTOKEN pToken)
     421{
     422    if (pToken->enmType == CFGTOKENTYPE_ID)
     423        return pToken->u.Id.achToken;
     424    else
     425        return autostartConfigTokenTypeToStr(pToken->enmType);
     426}
     427
     428/**
     429 * Returns the length of the token in characters (without zero terminator).
     430 *
     431 * @returns Token length.
     432 * @param   pToken          Token.
     433 */
    408434static size_t autostartConfigTokenGetLength(PCFGTOKEN pToken)
    409435{
     
    428454}
    429455
     456/**
     457 * Log unexpected token error.
     458 *
     459 * @returns nothing.
     460 * @param   pToken          The token which caused the error.
     461 * @param   pszExpected     String of the token which was expected.
     462 */
    430463static void autostartConfigTokenizerMsgUnexpectedToken(PCFGTOKEN pToken, const char *pszExpected)
    431464{
    432     RTMsgError("Unexpected token '%s' at %d:%d.%d, expected '%s'",
    433                autostartConfigTokenToString(pToken),
    434                pToken->iLine, pToken->cchStart,
    435                pToken->cchStart + autostartConfigTokenGetLength(pToken) - 1, pszExpected);
     465    autostartSvcLogError("Unexpected token '%s' at %d:%d.%d, expected '%s'",
     466                         autostartConfigTokenToString(pToken),
     467                         pToken->iLine, pToken->cchStart,
     468                         pToken->cchStart + autostartConfigTokenGetLength(pToken) - 1, pszExpected);
    436469}
    437470
     
    453486        if (pCfgToken->enmType != enmType)
    454487        {
    455             autostartConfigTokenizerMsgUnexpectedToken(pCfgToken, "@todo");
     488            autostartConfigTokenizerMsgUnexpectedToken(pCfgToken, autostartConfigTokenTypeToStr(enmType));
    456489            rc = VERR_INVALID_PARAMETER;
    457490        }
     
    570603
    571604    pCfgAst->enmType = CFGASTNODETYPE_COMPOUND;
     605    pCfgAst->u.Compound.cAstNodes = 0;
    572606    pCfgAst->pszKey  = RTStrDup(pszScopeId);
    573607    if (!pCfgAst->pszKey)
     
    619653        if (RT_SUCCESS(rc))
    620654        {
    621             Assert(idxAstNodeCur < cAstNodesMax);
    622             pCfgAst->u.Compound.apAstNodes[idxAstNodeCur] = pAstNode;
    623             idxAstNodeCur++;
    624             /** @todo: realloc if array is getting to small. */
     655            if (pCfgAst->u.Compound.cAstNodes >= cAstNodesMax)
     656            {
     657                cAstNodesMax += 10;
     658
     659                PCFGAST pCfgAstNew = (PCFGAST)RTMemRealloc(pCfgAst, RT_OFFSETOF(CFGAST, u.Compound.apAstNodes[cAstNodesMax]));
     660                if (!pCfgAstNew)
     661                    rc = VERR_NO_MEMORY;
     662                else
     663                    pCfgAst = pCfgAstNew;
     664            }
     665
     666            if (RT_SUCCESS(rc))
     667            {
     668                pCfgAst->u.Compound.apAstNodes[pCfgAst->u.Compound.cAstNodes] = pAstNode;
     669                pCfgAst->u.Compound.cAstNodes++;
     670            }
    625671        }
    626672
     
    630676
    631677    if (RT_SUCCESS(rc))
    632     {
    633         pCfgAst->u.Compound.cAstNodes = idxAstNodeCur;
    634678        *ppCfgAst = pCfgAst;
    635     }
    636679    else
    637680        autostartConfigAstDestroy(pCfgAst);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette