Changeset 41195 in vbox
- Timestamp:
- May 8, 2012 12:51:07 AM (13 years ago)
- Location:
- trunk/src/bldprogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/VBoxCPP.cpp
r41194 r41195 93 93 /** Variable argument count. */ 94 94 bool fVarArg; 95 /** Set if originating on the command line. */ 96 bool fCmdLine; 95 97 /** The number of known arguments.*/ 96 98 uint32_t cArgs; … … 534 536 * @param pszValue The value. 535 537 * @param cchDefine The length of the value. 538 * @param fCmdLine Set if originating on the command line. 536 539 */ 537 540 static RTEXITCODE vbcppDefineAddFn(PVBCPP pThis, const char *pszDefine, size_t cchDefine, 538 541 const char *pszParams, size_t cchParams, 539 const char *pszValue, size_t cchValue) 542 const char *pszValue, size_t cchValue, 543 bool fCmdLine) 540 544 541 545 { … … 598 602 pDef->fFunction = true; 599 603 pDef->fVarArg = false; 604 pDef->fCmdLine = fCmdLine; 600 605 pDef->cArgs = cArgs; 601 606 pDef->papszArgs = (const char **)((uintptr_t)pDef + cbDef - sizeof(const char *) * cArgs); … … 651 656 * @param pszValue The value. 652 657 * @param cchDefine The length of the value. RTSTR_MAX is ok. 658 * @param fCmdLine Set if originating on the command line. 653 659 */ 654 660 static RTEXITCODE vbcppDefineAdd(PVBCPP pThis, const char *pszDefine, size_t cchDefine, 655 const char *pszValue, size_t cchValue )661 const char *pszValue, size_t cchValue, bool fCmdLine) 656 662 { 657 663 /* … … 688 694 pszParams++; 689 695 cchParams -= 2; 690 return vbcppDefineAddFn(pThis, pszDefine, cchDefine, pszParams, cchParams, pszValue, cchValue );696 return vbcppDefineAddFn(pThis, pszDefine, cchDefine, pszParams, cchParams, pszValue, cchValue, fCmdLine); 691 697 } 692 698 … … 706 712 pDef->fFunction = false; 707 713 pDef->fVarArg = false; 714 pDef->fCmdLine = fCmdLine; 708 715 pDef->cArgs = 0; 709 716 pDef->papszArgs = NULL; … … 817 824 const char *pszEqual = strchr(ValueUnion.psz, '='); 818 825 if (pszEqual) 819 rcExit = vbcppDefineAdd(pThis, ValueUnion.psz, pszEqual - ValueUnion.psz, pszEqual + 1, RTSTR_MAX );826 rcExit = vbcppDefineAdd(pThis, ValueUnion.psz, pszEqual - ValueUnion.psz, pszEqual + 1, RTSTR_MAX, true); 820 827 else 821 rcExit = vbcppDefineAdd(pThis, ValueUnion.psz, RTSTR_MAX, "1", 1 );828 rcExit = vbcppDefineAdd(pThis, ValueUnion.psz, RTSTR_MAX, "1", 1, true); 822 829 if (rcExit != RTEXITCODE_SUCCESS) 823 830 return rcExit; … … 938 945 939 946 940 static RTEXITCODE vbcppOutputComment(PVBCPP pThis, PSCMSTREAM pStrmInput, size_t offStart, size_t cchOutputted) 947 static RTEXITCODE vbcppOutputComment(PVBCPP pThis, PSCMSTREAM pStrmInput, size_t offStart, size_t cchOutputted, 948 size_t cchMinIndent) 941 949 { 942 950 size_t offCur = ScmStreamTell(pStrmInput); … … 1360 1368 /* Pretty print the passthru. */ 1361 1369 unsigned cchIndent = pThis->pCondStack ? pThis->pCondStack->iKeepLevel : 0; 1362 size_t cch;1370 size_t cch; 1363 1371 if (chType == '<') 1364 1372 cch = ScmStreamPrintf(&pThis->StrmOutput, "#%*sinclude <%.*s>", … … 1371 1379 cchIndent, "", cchFileSpec, pchFileSpec); 1372 1380 if (cch > 0) 1373 rcExit = vbcppOutputComment(pThis, pStrmInput, offIncEnd, cch );1381 rcExit = vbcppOutputComment(pThis, pStrmInput, offIncEnd, cch, 1); 1374 1382 else 1375 1383 rcExit = vbcppError(pThis, "Output error %Rrc", (int)cch); … … 1394 1402 static RTEXITCODE vbcppProcessDefine(PVBCPP pThis, PSCMSTREAM pStrmInput, size_t offStart) 1395 1403 { 1396 return vbcppError(pThis, "Not implemented %s", __FUNCTION__); 1404 /* 1405 * Parse it. 1406 */ 1407 RTEXITCODE rcExit = vbcppProcessSkipWhiteEscapedEolAndComments(pThis, pStrmInput); 1408 if (rcExit == RTEXITCODE_SUCCESS) 1409 { 1410 size_t cchDefine; 1411 const char *pchDefine = ScmStreamCGetWord(pStrmInput, &cchDefine); 1412 if (pchDefine) 1413 { 1414 /* If it's a function style define, parse out the parameter list. */ 1415 size_t cchParams = 0; 1416 const char *pchParams = NULL; 1417 unsigned ch = ScmStreamPeekCh(pStrmInput); 1418 if (ch == '(') 1419 { 1420 ScmStreamGetCh(pStrmInput); 1421 pchParams = ScmStreamGetCur(pStrmInput); 1422 1423 unsigned chPrev = ch; 1424 while ((ch = ScmStreamPeekCh(pStrmInput)) != ~(unsigned)0) 1425 { 1426 if (ch == '\r' || ch == '\n') 1427 { 1428 if (chPrev != '\\') 1429 { 1430 rcExit = vbcppError(pThis, "Missing ')'"); 1431 break; 1432 } 1433 ScmStreamSeekByLine(pStrmInput, ScmStreamTellLine(pStrmInput) + 1); 1434 } 1435 if (ch == ')') 1436 { 1437 cchParams = ScmStreamGetCur(pStrmInput) - pchParams; 1438 ScmStreamGetCh(pStrmInput); 1439 break; 1440 } 1441 ScmStreamGetCh(pStrmInput); 1442 } 1443 } 1444 /* The simple kind. */ 1445 else if (!RT_C_IS_SPACE(ch) && ch != ~(unsigned)0) 1446 rcExit = vbcppError(pThis, "Expected whitespace after macro name"); 1447 1448 /* Parse out the value. */ 1449 if (rcExit == RTEXITCODE_SUCCESS) 1450 rcExit = vbcppProcessSkipWhiteEscapedEolAndComments(pThis, pStrmInput); 1451 if (rcExit == RTEXITCODE_SUCCESS) 1452 { 1453 size_t offValue = ScmStreamTell(pStrmInput); 1454 const char *pchValue = ScmStreamGetCur(pStrmInput); 1455 unsigned chPrev = ch; 1456 while ((ch = ScmStreamPeekCh(pStrmInput)) != ~(unsigned)0) 1457 { 1458 if (ch == '\r' || ch == '\n') 1459 { 1460 if (chPrev != '\\') 1461 break; 1462 ScmStreamSeekByLine(pStrmInput, ScmStreamTellLine(pStrmInput) + 1); 1463 } 1464 ScmStreamGetCh(pStrmInput); 1465 } 1466 size_t cchValue = ScmStreamGetCur(pStrmInput) - pchValue; 1467 1468 /* 1469 * Execute. 1470 */ 1471 if (pchParams) 1472 rcExit = vbcppDefineAddFn(pThis, pchDefine, cchDefine, pchParams, cchParams, pchValue, cchValue, false); 1473 else 1474 rcExit = vbcppDefineAdd(pThis, pchDefine, cchDefine, pchValue, cchValue, false); 1475 1476 /* 1477 * Pass thru? 1478 */ 1479 if ( pThis->enmMode >= kVBCppMode_Selective 1480 && pThis->enmMode != kVBCppMode_SelectiveD 1481 && rcExit == RTEXITCODE_SUCCESS) 1482 { 1483 unsigned cchIndent = pThis->pCondStack ? pThis->pCondStack->iKeepLevel : 0; 1484 size_t cch; 1485 if (pchParams) 1486 cch = ScmStreamPrintf(&pThis->StrmOutput, "#%*sdefine %.*s(%.*s)", 1487 cchIndent, "", cchDefine, pchDefine, cchParams, pchParams); 1488 else 1489 cch = ScmStreamPrintf(&pThis->StrmOutput, "#%*sdefine %.*s", 1490 cchIndent, "", cchDefine, pchDefine); 1491 if (cch > 0) 1492 vbcppOutputComment(pThis, pStrmInput, offValue, cch, 1); 1493 else 1494 rcExit = vbcppError(pThis, "output error"); 1495 } 1496 } 1497 1498 } 1499 } 1500 return rcExit; 1397 1501 } 1398 1502 … … 1576 1680 } 1577 1681 else 1578 rcExit = vbcppError(pThis, "Malformed #if def");1682 rcExit = vbcppError(pThis, "Malformed #ifndef"); 1579 1683 } 1580 1684 return rcExit; … … 1628 1732 ssize_t cch = ScmStreamPrintf(&pThis->StrmOutput, "#%*selse", pCond->iKeepLevel - 1, ""); 1629 1733 if (cch > 0) 1630 rcExit = vbcppOutputComment(pThis, pStrmInput, offStart, cch );1734 rcExit = vbcppOutputComment(pThis, pStrmInput, offStart, cch, 2); 1631 1735 else 1632 1736 rcExit = vbcppError(pThis, "Output error %Rrc", (int)cch); … … 1678 1782 ssize_t cch = ScmStreamPrintf(&pThis->StrmOutput, "#%*sendif", pCond->iKeepLevel - 1, ""); 1679 1783 if (cch > 0) 1680 rcExit = vbcppOutputComment(pThis, pStrmInput, offStart, cch );1784 rcExit = vbcppOutputComment(pThis, pStrmInput, offStart, cch, 1); 1681 1785 else 1682 1786 rcExit = vbcppError(pThis, "Output error %Rrc", (int)cch); -
trunk/src/bldprogs/scmstream.cpp
r41194 r41195 1286 1286 1287 1287 /* Is it a leading C character. */ 1288 if (!RT_C_IS_ALPHA(*psz) && *psz == '_')1288 if (!RT_C_IS_ALPHA(*psz) && *psz != '_') 1289 1289 return NULL; 1290 1290 … … 1325 1325 1326 1326 /* Is it a leading C character. */ 1327 if (!RT_C_IS_ALPHA(*psz) && *psz == '_')1327 if (!RT_C_IS_ALPHA(*psz) && *psz != '_') 1328 1328 return NULL; 1329 1329
Note:
See TracChangeset
for help on using the changeset viewer.