Changeset 96401 in vbox for trunk/src/bldprogs/scmrw.cpp
- Timestamp:
- Aug 22, 2022 3:06:19 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/scmrw.cpp
r94913 r96401 135 135 /** --license-ose-gpl */ 136 136 static const char g_szVBoxOseGpl[] = 137 "This file is part of VirtualBox base platform packages, as\n" 138 "available from https://www.virtualbox.org.\n" 139 "\n" 140 "This program is free software; you can redistribute it and/or\n" 141 "modify it under the terms of the GNU General Public License\n" 142 "as published by the Free Software Foundation, in version 3 of the\n" 143 "License.\n" 144 "\n" 145 "This program is distributed in the hope that it will be useful, but\n" 146 "WITHOUT ANY WARRANTY; without even the implied warranty of\n" 147 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" 148 "General Public License for more details.\n" 149 "\n" 150 "You should have received a copy of the GNU General Public License\n" 151 "along with this program; if not, see <https://www.gnu.org/licenses>.\n" 152 "\n" 153 "SPDX-License-Identifier: GPL-3.0-only\n"; 154 155 static const char g_szVBoxOseOldGpl2[] = 137 156 "This file is part of VirtualBox Open Source Edition (OSE), as\n" 138 157 "available from http://www.virtualbox.org. This file is free software;\n" … … 145 164 /** --license-ose-dual */ 146 165 static const char g_szVBoxOseDualGplCddl[] = 166 "This file is part of VirtualBox base platform packages, as\n" 167 "available from https://www.virtualbox.org.\n" 168 "\n" 169 "This program is free software; you can redistribute it and/or\n" 170 "modify it under the terms of the GNU General Public License\n" 171 "as published by the Free Software Foundation, in version 3 of the\n" 172 "License.\n" 173 "\n" 174 "This program is distributed in the hope that it will be useful, but\n" 175 "WITHOUT ANY WARRANTY; without even the implied warranty of\n" 176 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" 177 "General Public License for more details.\n" 178 "\n" 179 "You should have received a copy of the GNU General Public License\n" 180 "along with this program; if not, see <https://www.gnu.org/licenses>.\n" 181 "\n" 182 "The contents of this file may alternatively be used under the terms\n" 183 "of the Common Development and Distribution License Version 1.0\n" 184 "(CDDL), a copy of it is provided in the \"COPYING.CDDL\" file included\n" 185 "in the VirtualBox distribution, in which case the provisions of the\n" 186 "CDDL are applicable instead of those of the GPL.\n" 187 "\n" 188 "You may elect to license modified versions of this file under the\n" 189 "terms and conditions of either the GPL or the CDDL or both.\n" 190 "\n" 191 "SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0\n"; 192 193 static const char g_szVBoxOseOldDualGpl2Cddl[] = 147 194 "This file is part of VirtualBox Open Source Edition (OSE), as\n" 148 195 "available from http://www.virtualbox.org. This file is free software;\n" … … 164 211 /** --license-ose-cddl */ 165 212 static const char g_szVBoxOseCddl[] = 213 "This file is part of VirtualBox base platform packages, as\n" 214 "available from http://www.virtualbox.org.\n" 215 "\n" 216 "The contents of this file are subject to the terms of the Common\n" 217 "Development and Distribution License Version 1.0 (CDDL) only, as it\n" 218 "comes in the \"COPYING.CDDL\" file of the VirtualBox distribution.\n" 219 "\n" 220 "SPDX-License-Identifier: CDDL-1.0\n"; 221 222 static const char g_szVBoxOseOldCddl[] = 166 223 "This file is part of VirtualBox Open Source Edition (OSE), as\n" 167 224 "available from http://www.virtualbox.org. This file is free software;\n" … … 177 234 "it and/or modify it under the terms of the GNU Lesser General\n" 178 235 "Public License version 2.1 as published by the Free Software\n" 179 "Foundation and shipped in the \"COPYING \" file with this library.\n"236 "Foundation and shipped in the \"COPYING.LIB\" file with this library.\n" 180 237 "The library is distributed in the hope that it will be useful,\n" 181 238 "but WITHOUT ANY WARRANTY of any kind.\n" … … 188 245 "language indicating that LGPLv2 or any later version may be used,\n" 189 246 "or where a choice of which version of the LGPL is applied is\n" 190 "otherwise unspecified.\n"; 247 "otherwise unspecified.\n" 248 "\n" 249 "SPDX-License-Identifier: LGPL-2.1-only\n"; 191 250 192 251 /** --license-mit … … 333 392 /** Oracle confidential. */ 334 393 static const char g_szOracleConfidential[] = 394 "Oracle Corporation confidential\n"; 395 396 /** Oracle confidential, old style. */ 397 static const char g_szOracleConfidentialOld[] = 335 398 "Oracle Corporation confidential\n" 336 399 "All rights reserved\n"; … … 340 403 { 341 404 { kScmLicenseType_OseGpl, kScmLicense_OseGpl, RT_STR_TUPLE(g_szVBoxOseGpl)}, 405 { kScmLicenseType_OseGpl, kScmLicense_OseGpl, RT_STR_TUPLE(g_szVBoxOseOldGpl2)}, 342 406 { kScmLicenseType_OseDualGplCddl, kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseDualGplCddl) }, 407 { kScmLicenseType_OseDualGplCddl, kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseOldDualGpl2Cddl) }, 343 408 { kScmLicenseType_OseCddl, kScmLicense_OseCddl, RT_STR_TUPLE(g_szVBoxOseCddl) }, 409 { kScmLicenseType_OseCddl, kScmLicense_OseCddl, RT_STR_TUPLE(g_szVBoxOseOldCddl) }, 344 410 { kScmLicenseType_VBoxLgpl, kScmLicense_Lgpl, RT_STR_TUPLE(g_szVBoxLgpl)}, 345 411 { kScmLicenseType_Confidential, kScmLicense_End, RT_STR_TUPLE(g_szOracleConfidential) }, 412 { kScmLicenseType_Confidential, kScmLicense_End, RT_STR_TUPLE(g_szOracleConfidentialOld) }, 346 413 { kScmLicenseType_Invalid, kScmLicense_End, NULL, 0 }, 347 414 }; … … 357 424 { kScmLicenseType_Mit, kScmLicense_Mit, RT_STR_TUPLE(g_szMitAlt5) }, 358 425 { kScmLicenseType_OseGpl, kScmLicense_OseGpl, RT_STR_TUPLE(g_szVBoxOseGpl)}, 426 { kScmLicenseType_OseGpl, kScmLicense_OseGpl, RT_STR_TUPLE(g_szVBoxOseOldGpl2)}, 359 427 { kScmLicenseType_OseDualGplCddl, kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseDualGplCddl) }, 428 { kScmLicenseType_OseDualGplCddl, kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseOldDualGpl2Cddl) }, 360 429 { kScmLicenseType_VBoxLgpl, kScmLicense_Lgpl, RT_STR_TUPLE(g_szVBoxLgpl)}, 361 430 { kScmLicenseType_Confidential, kScmLicense_End, RT_STR_TUPLE(g_szOracleConfidential) }, 431 { kScmLicenseType_Confidential, kScmLicense_End, RT_STR_TUPLE(g_szOracleConfidentialOld) }, 362 432 { kScmLicenseType_Invalid, kScmLicense_End, NULL, 0 }, 363 433 }; 364 434 365 435 /** Copyright holder. */ 366 static const char g_szCopyrightHolder[] = "Oracle Corporation"; 436 static const char g_szCopyrightHolder[] = "Oracle and/or its affiliates."; 437 438 /** Old copyright holder. */ 439 static const char g_szOldCopyrightHolder[] = "Oracle Corporation"; 367 440 368 441 /** LGPL disclaimer. */ … … 388 461 { RT_STR_TUPLE("--") }, 389 462 { RT_STR_TUPLE("'") }, 463 { RT_STR_TUPLE("<!--") }, 390 464 { RT_STR_TUPLE("<end>") }, 391 465 }; … … 404 478 { RT_STR_TUPLE("-- ") }, 405 479 { RT_STR_TUPLE("' ") }, 480 { RT_STR_TUPLE(" ") }, 406 481 { RT_STR_TUPLE("<end>") }, 407 482 }; … … 420 495 { RT_STR_TUPLE("--") }, 421 496 { RT_STR_TUPLE("'") }, 497 { RT_STR_TUPLE("") }, 422 498 { RT_STR_TUPLE("<end>") }, 423 499 }; … … 436 512 { RT_STR_TUPLE("--") }, 437 513 { RT_STR_TUPLE("'") }, 514 { RT_STR_TUPLE("-->") }, 438 515 { RT_STR_TUPLE("<end>") }, 439 516 }; … … 446 523 * @param pIn The file to scan. Will be rewound. 447 524 */ 448 static SCMCOMMENTSTYLE determin BatchFileCommentStyle(PSCMSTREAM pIn)525 static SCMCOMMENTSTYLE determineBatchFileCommentStyle(PSCMSTREAM pIn) 449 526 { 450 527 /* … … 1333 1410 uint32_t cBlankLinesAfterCopyright = 0; 1334 1411 if ( pState->iLineCopyright == UINT32_MAX 1335 && cchBody > sizeof("Copyright") + sizeof(g_szCopyrightHolder)1412 && cchBody > sizeof("Copyright") + RT_MIN(sizeof(g_szCopyrightHolder), sizeof(g_szOldCopyrightHolder)) 1336 1413 && RTStrNICmp(pszBody, RT_STR_TUPLE("copyright")) == 0) 1337 1414 { … … 1342 1419 while (RT_C_IS_SPACE(pszEnd[-1])) 1343 1420 pszEnd--; 1344 if ( (uintptr_t)(pszEnd - pszBody) > sizeof(g_szCopyrightHolder) 1345 && (*(unsigned char *)(pszEnd - sizeof(g_szCopyrightHolder) + 1) & 0x80) == 0 /* to avoid annoying assertion */ 1346 && RTStrNICmp(pszEnd - sizeof(g_szCopyrightHolder) + 1, RT_STR_TUPLE(g_szCopyrightHolder)) == 0) 1421 if ( ( (uintptr_t)(pszEnd - pszBody) > sizeof(g_szCopyrightHolder) 1422 && (*(unsigned char *)(pszEnd - sizeof(g_szCopyrightHolder) + 1) & 0x80) == 0 /* to avoid annoying assertion */ 1423 && RTStrNICmp(pszEnd - sizeof(g_szCopyrightHolder) + 1, RT_STR_TUPLE(g_szCopyrightHolder)) == 0) 1424 || ( (uintptr_t)(pszEnd - pszBody) > sizeof(g_szOldCopyrightHolder) 1425 && (*(unsigned char *)(pszEnd - sizeof(g_szOldCopyrightHolder) + 1) & 0x80) == 0 /* to avoid annoying assertion */ 1426 && RTStrNICmp(pszEnd - sizeof(g_szOldCopyrightHolder) + 1, RT_STR_TUPLE(g_szOldCopyrightHolder)) == 0) ) 1347 1427 { 1348 1428 /* Parse out the year(s). */ … … 1361 1441 || pState->uFirstYear > 3000) 1362 1442 { 1363 ScmError(pState->pState, VERR_OUT_OF_RANGE, "Copyright year is out of range: %u ('%.*s')\n", 1364 pState->uFirstYear, pszEnd - pszBody, pszBody); 1443 char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody); 1444 RTStrPurgeEncoding(pszCopy); 1445 ScmError(pState->pState, VERR_OUT_OF_RANGE, "Copyright year is out of range: %u ('%s')\n", 1446 pState->uFirstYear, pszCopy); 1447 RTStrFree(pszCopy); 1365 1448 pState->uFirstYear = UINT32_MAX; 1366 1449 } … … 1381 1464 || pState->uLastYear > 3000) 1382 1465 { 1383 ScmError(pState->pState, VERR_OUT_OF_RANGE, "Second copyright year is out of range: %u ('%.*s')\n", 1384 pState->uLastYear, pszEnd - pszBody, pszBody); 1466 char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody); 1467 RTStrPurgeEncoding(pszCopy); 1468 ScmError(pState->pState, VERR_OUT_OF_RANGE, "Second copyright year is out of range: %u ('%s')\n", 1469 pState->uLastYear, pszCopy); 1470 RTStrFree(pszCopy); 1385 1471 pState->uLastYear = UINT32_MAX; 1386 1472 } 1387 1473 else if (pState->uFirstYear > pState->uLastYear) 1388 1474 { 1389 RTMsgWarning("Copyright years switched(?): '%.*s'\n", pszEnd - pszBody, pszBody); 1475 char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody); 1476 RTStrPurgeEncoding(pszCopy); 1477 RTMsgWarning("Copyright years switched(?): '%s'\n", pszCopy); 1478 RTStrFree(pszCopy); 1390 1479 uint32_t iTmp = pState->uLastYear; 1391 1480 pState->uLastYear = pState->uFirstYear; … … 1396 1485 { 1397 1486 pState->uLastYear = UINT32_MAX; 1487 char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody); 1488 RTStrPurgeEncoding(pszCopy); 1398 1489 ScmError(pState->pState, RT_SUCCESS(rc) ? -rc : rc, 1399 "Failed to parse second copyright year: '%.*s'\n", pszEnd - pszBody, pszBody); 1490 "Failed to parse second copyright year: '%s'\n", pszCopy); 1491 RTMemFree(pszCopy); 1400 1492 } 1401 1493 } 1402 1494 else if (*pszNext != g_szCopyrightHolder[0]) 1495 { 1496 char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody); 1497 RTStrPurgeEncoding(pszCopy); 1403 1498 ScmError(pState->pState, VERR_PARSE_ERROR, 1404 "Failed to parse copyright: '%.*s'\n", pszEnd - pszBody, pszBody); 1405 else 1499 "Failed to parse copyright: '%s'\n", pszCopy); 1500 RTMemFree(pszCopy); 1501 } else 1406 1502 pState->uLastYear = pState->uFirstYear; 1407 1503 } … … 1409 1505 { 1410 1506 pState->uFirstYear = UINT32_MAX; 1507 char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody); 1508 RTStrPurgeEncoding(pszCopy); 1411 1509 ScmError(pState->pState, RT_SUCCESS(rc) ? -rc : rc, 1412 "Failed to parse copyright year: '%.*s'\n", pszEnd - pszBody, pszBody); 1510 "Failed to parse copyright year: '%s'\n", pszCopy); 1511 RTMemFree(pszCopy); 1413 1512 } 1414 1513 } … … 1482 1581 } 1483 1582 else 1484 ScmVerbose(pState->pState, 3, "not oracle copyright: '%.*s'\n", pszEnd - pszBody, pszBody); 1583 { 1584 char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody); 1585 RTStrPurgeEncoding(pszCopy); 1586 ScmVerbose(pState->pState, 3, "not oracle copyright: '%s'\n", pszCopy); 1587 RTStrFree(pszCopy); 1588 } 1485 1589 1486 1590 if (!pszNextLine) … … 1611 1715 { 1612 1716 /* In C/C++ code, this must be a multiline comment. While in python it 1613 must be a */1717 must be a doc-string. */ 1614 1718 if (pState->enmCommentStyle == kScmCommentStyle_C && pInfo->enmType != kScmCommentType_MultiLine) 1615 1719 ScmError(pState->pState, VERR_WRONG_ORDER, "License must appear in a multiline comment (no doxygen stuff)\n"); … … 1626 1730 pState->pCurrentLicense = pCur; 1627 1731 pState->fExternalLicense = fExternal; 1628 pState->fIsCorrectLicense = pState->fOpenSource 1629 ? pCur == pState->pExpectedLicense 1630 : pCur->enmType == kScmLicenseType_Confidential; 1732 pState->fIsCorrectLicense = pCur == pState->pExpectedLicense; 1631 1733 pState->fWellFormedLicense = memcmp(pszBody, pCur->psz, pCur->cch - 1) == 0; 1632 1734 if (!pState->fWellFormedLicense) … … 2008 2110 bool rewrite_Copyright_RemComment(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings) 2009 2111 { 2010 return rewrite_Copyright_Common(pState, pIn, pOut, pSettings, determin BatchFileCommentStyle(pIn));2112 return rewrite_Copyright_Common(pState, pIn, pOut, pSettings, determineBatchFileCommentStyle(pIn)); 2011 2113 } 2012 2114 … … 2033 2135 { 2034 2136 return rewrite_Copyright_Common(pState, pIn, pOut, pSettings, kScmCommentStyle_Tick); 2137 } 2138 2139 /** Copyright updater for XML comments. */ 2140 bool rewrite_Copyright_XmlComment(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings) 2141 { 2142 return rewrite_Copyright_Common(pState, pIn, pOut, pSettings, kScmCommentStyle_Xml); 2035 2143 } 2036 2144
Note:
See TracChangeset
for help on using the changeset viewer.