VirtualBox

Changeset 96401 in vbox for trunk/src/bldprogs/scmrw.cpp


Ignore:
Timestamp:
Aug 22, 2022 3:06:19 PM (2 years ago)
Author:
vboxsync
Message:

bldprogs/scm: Teach it to replace the old copyright and license notices with the updated ones (e.g. GPlv2 to GPLv3).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bldprogs/scmrw.cpp

    r94913 r96401  
    135135/** --license-ose-gpl */
    136136static 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
     155static const char g_szVBoxOseOldGpl2[] =
    137156    "This file is part of VirtualBox Open Source Edition (OSE), as\n"
    138157    "available from http://www.virtualbox.org. This file is free software;\n"
     
    145164/** --license-ose-dual */
    146165static 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
     193static const char g_szVBoxOseOldDualGpl2Cddl[] =
    147194    "This file is part of VirtualBox Open Source Edition (OSE), as\n"
    148195    "available from http://www.virtualbox.org. This file is free software;\n"
     
    164211/** --license-ose-cddl   */
    165212static 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
     222static const char g_szVBoxOseOldCddl[] =
    166223    "This file is part of VirtualBox Open Source Edition (OSE), as\n"
    167224    "available from http://www.virtualbox.org. This file is free software;\n"
     
    177234    "it and/or modify it under the terms of the GNU Lesser General\n"
    178235    "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"
    180237    "The library is distributed in the hope that it will be useful,\n"
    181238    "but WITHOUT ANY WARRANTY of any kind.\n"
     
    188245    "language indicating that LGPLv2 or any later version may be used,\n"
    189246    "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";
    191250
    192251/** --license-mit
     
    333392/** Oracle confidential. */
    334393static const char g_szOracleConfidential[] =
     394    "Oracle Corporation confidential\n";
     395
     396/** Oracle confidential, old style. */
     397static const char g_szOracleConfidentialOld[] =
    335398    "Oracle Corporation confidential\n"
    336399    "All rights reserved\n";
     
    340403{
    341404    { kScmLicenseType_OseGpl,           kScmLicense_OseGpl,         RT_STR_TUPLE(g_szVBoxOseGpl)},
     405    { kScmLicenseType_OseGpl,           kScmLicense_OseGpl,         RT_STR_TUPLE(g_szVBoxOseOldGpl2)},
    342406    { kScmLicenseType_OseDualGplCddl,   kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseDualGplCddl) },
     407    { kScmLicenseType_OseDualGplCddl,   kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseOldDualGpl2Cddl) },
    343408    { kScmLicenseType_OseCddl,          kScmLicense_OseCddl,        RT_STR_TUPLE(g_szVBoxOseCddl) },
     409    { kScmLicenseType_OseCddl,          kScmLicense_OseCddl,        RT_STR_TUPLE(g_szVBoxOseOldCddl) },
    344410    { kScmLicenseType_VBoxLgpl,         kScmLicense_Lgpl,           RT_STR_TUPLE(g_szVBoxLgpl)},
    345411    { kScmLicenseType_Confidential,     kScmLicense_End,            RT_STR_TUPLE(g_szOracleConfidential) },
     412    { kScmLicenseType_Confidential,     kScmLicense_End,            RT_STR_TUPLE(g_szOracleConfidentialOld) },
    346413    { kScmLicenseType_Invalid,          kScmLicense_End,            NULL, 0 },
    347414};
     
    357424    { kScmLicenseType_Mit,              kScmLicense_Mit,            RT_STR_TUPLE(g_szMitAlt5) },
    358425    { kScmLicenseType_OseGpl,           kScmLicense_OseGpl,         RT_STR_TUPLE(g_szVBoxOseGpl)},
     426    { kScmLicenseType_OseGpl,           kScmLicense_OseGpl,         RT_STR_TUPLE(g_szVBoxOseOldGpl2)},
    359427    { kScmLicenseType_OseDualGplCddl,   kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseDualGplCddl) },
     428    { kScmLicenseType_OseDualGplCddl,   kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseOldDualGpl2Cddl) },
    360429    { kScmLicenseType_VBoxLgpl,         kScmLicense_Lgpl,           RT_STR_TUPLE(g_szVBoxLgpl)},
    361430    { kScmLicenseType_Confidential,     kScmLicense_End,            RT_STR_TUPLE(g_szOracleConfidential) },
     431    { kScmLicenseType_Confidential,     kScmLicense_End,            RT_STR_TUPLE(g_szOracleConfidentialOld) },
    362432    { kScmLicenseType_Invalid,          kScmLicense_End,            NULL, 0 },
    363433};
    364434
    365435/** Copyright holder. */
    366 static const char g_szCopyrightHolder[] = "Oracle Corporation";
     436static const char g_szCopyrightHolder[] = "Oracle and/or its affiliates.";
     437
     438/** Old copyright holder. */
     439static const char g_szOldCopyrightHolder[] = "Oracle Corporation";
    367440
    368441/** LGPL disclaimer. */
     
    388461    { RT_STR_TUPLE("--") },
    389462    { RT_STR_TUPLE("'") },
     463    { RT_STR_TUPLE("<!--") },
    390464    { RT_STR_TUPLE("<end>") },
    391465};
     
    404478    { RT_STR_TUPLE("-- ") },
    405479    { RT_STR_TUPLE("' ") },
     480    { RT_STR_TUPLE("    ") },
    406481    { RT_STR_TUPLE("<end>") },
    407482};
     
    420495    { RT_STR_TUPLE("--") },
    421496    { RT_STR_TUPLE("'") },
     497    { RT_STR_TUPLE("") },
    422498    { RT_STR_TUPLE("<end>") },
    423499};
     
    436512    { RT_STR_TUPLE("--") },
    437513    { RT_STR_TUPLE("'") },
     514    { RT_STR_TUPLE("-->") },
    438515    { RT_STR_TUPLE("<end>") },
    439516};
     
    446523 * @param   pIn         The file to scan.  Will be rewound.
    447524 */
    448 static SCMCOMMENTSTYLE determinBatchFileCommentStyle(PSCMSTREAM pIn)
     525static SCMCOMMENTSTYLE determineBatchFileCommentStyle(PSCMSTREAM pIn)
    449526{
    450527    /*
     
    13331410    uint32_t cBlankLinesAfterCopyright = 0;
    13341411    if (   pState->iLineCopyright == UINT32_MAX
    1335         && cchBody > sizeof("Copyright") + sizeof(g_szCopyrightHolder)
     1412        && cchBody > sizeof("Copyright") + RT_MIN(sizeof(g_szCopyrightHolder), sizeof(g_szOldCopyrightHolder))
    13361413        && RTStrNICmp(pszBody, RT_STR_TUPLE("copyright")) == 0)
    13371414    {
     
    13421419        while (RT_C_IS_SPACE(pszEnd[-1]))
    13431420            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) )
    13471427        {
    13481428            /* Parse out the year(s). */
     
    13611441                        || pState->uFirstYear > 3000)
    13621442                    {
    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);
    13651448                        pState->uFirstYear = UINT32_MAX;
    13661449                    }
     
    13811464                                || pState->uLastYear > 3000)
    13821465                            {
    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);
    13851471                                pState->uLastYear = UINT32_MAX;
    13861472                            }
    13871473                            else if (pState->uFirstYear > pState->uLastYear)
    13881474                            {
    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);
    13901479                                uint32_t iTmp = pState->uLastYear;
    13911480                                pState->uLastYear = pState->uFirstYear;
     
    13961485                        {
    13971486                            pState->uLastYear = UINT32_MAX;
     1487                            char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody);
     1488                            RTStrPurgeEncoding(pszCopy);
    13981489                            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);
    14001492                        }
    14011493                    }
    14021494                    else if (*pszNext != g_szCopyrightHolder[0])
     1495                    {
     1496                        char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody);
     1497                        RTStrPurgeEncoding(pszCopy);
    14031498                        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
    14061502                        pState->uLastYear = pState->uFirstYear;
    14071503                }
     
    14091505                {
    14101506                    pState->uFirstYear = UINT32_MAX;
     1507                    char *pszCopy = RTStrDupN(pszBody, pszEnd - pszBody);
     1508                    RTStrPurgeEncoding(pszCopy);
    14111509                    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);
    14131512                }
    14141513            }
     
    14821581        }
    14831582        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        }
    14851589
    14861590        if (!pszNextLine)
     
    16111715                {
    16121716                    /* In C/C++ code, this must be a multiline comment.  While in python it
    1613                        must be a */
     1717                       must be a doc-string. */
    16141718                    if (pState->enmCommentStyle == kScmCommentStyle_C && pInfo->enmType != kScmCommentType_MultiLine)
    16151719                        ScmError(pState->pState, VERR_WRONG_ORDER, "License must appear in a multiline comment (no doxygen stuff)\n");
     
    16261730                    pState->pCurrentLicense     = pCur;
    16271731                    pState->fExternalLicense    = fExternal;
    1628                     pState->fIsCorrectLicense   = pState->fOpenSource
    1629                                                 ? pCur == pState->pExpectedLicense
    1630                                                 : pCur->enmType == kScmLicenseType_Confidential;
     1732                    pState->fIsCorrectLicense   = pCur == pState->pExpectedLicense;
    16311733                    pState->fWellFormedLicense  = memcmp(pszBody, pCur->psz, pCur->cch - 1) == 0;
    16321734                    if (!pState->fWellFormedLicense)
     
    20082110bool rewrite_Copyright_RemComment(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
    20092111{
    2010     return rewrite_Copyright_Common(pState, pIn, pOut, pSettings, determinBatchFileCommentStyle(pIn));
     2112    return rewrite_Copyright_Common(pState, pIn, pOut, pSettings, determineBatchFileCommentStyle(pIn));
    20112113}
    20122114
     
    20332135{
    20342136    return rewrite_Copyright_Common(pState, pIn, pOut, pSettings, kScmCommentStyle_Tick);
     2137}
     2138
     2139/** Copyright updater for XML comments.   */
     2140bool rewrite_Copyright_XmlComment(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
     2141{
     2142    return rewrite_Copyright_Common(pState, pIn, pOut, pSettings, kScmCommentStyle_Xml);
    20352143}
    20362144
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