Changeset 46737 in vbox
- Timestamp:
- Jun 23, 2013 12:11:45 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxAutostart/VBoxAutostartCfg.cpp
r42732 r46737 381 381 } 382 382 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 */ 389 static const char *autostartConfigTokenTypeToStr(CFGTOKENTYPE enmType) 390 { 391 switch (enmType) 386 392 { 387 393 case CFGTOKENTYPE_COMMA: … … 396 402 return "<EOF>"; 397 403 case CFGTOKENTYPE_ID: 398 return pToken->u.Id.achToken;404 return "<Identifier>"; 399 405 default: 400 406 AssertFailed(); … … 406 412 } 407 413 414 /** 415 * Returns a stringified version of the token. 416 * 417 * @returns Stringified version of the token type. 418 * @param pToken Token. 419 */ 420 static 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 */ 408 434 static size_t autostartConfigTokenGetLength(PCFGTOKEN pToken) 409 435 { … … 428 454 } 429 455 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 */ 430 463 static void autostartConfigTokenizerMsgUnexpectedToken(PCFGTOKEN pToken, const char *pszExpected) 431 464 { 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); 436 469 } 437 470 … … 453 486 if (pCfgToken->enmType != enmType) 454 487 { 455 autostartConfigTokenizerMsgUnexpectedToken(pCfgToken, "@todo");488 autostartConfigTokenizerMsgUnexpectedToken(pCfgToken, autostartConfigTokenTypeToStr(enmType)); 456 489 rc = VERR_INVALID_PARAMETER; 457 490 } … … 570 603 571 604 pCfgAst->enmType = CFGASTNODETYPE_COMPOUND; 605 pCfgAst->u.Compound.cAstNodes = 0; 572 606 pCfgAst->pszKey = RTStrDup(pszScopeId); 573 607 if (!pCfgAst->pszKey) … … 619 653 if (RT_SUCCESS(rc)) 620 654 { 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 } 625 671 } 626 672 … … 630 676 631 677 if (RT_SUCCESS(rc)) 632 {633 pCfgAst->u.Compound.cAstNodes = idxAstNodeCur;634 678 *ppCfgAst = pCfgAst; 635 }636 679 else 637 680 autostartConfigAstDestroy(pCfgAst);
Note:
See TracChangeset
for help on using the changeset viewer.