VirtualBox

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


Ignore:
Timestamp:
Oct 25, 2017 7:45:13 PM (7 years ago)
Author:
vboxsync
Message:

scm: tweaks for the drm thing.

File:
1 edited

Legend:

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

    r69291 r69324  
    268268    "all copies or substantial portions of the Software.\n";
    269269
     270/** --license-(based-on)mit, alternative wording \#4.
     271 * @note This differs from g_szMitAlt3 in using "sub license" instead of
     272 *       "sublicense" and adding an illogical "(including the next
     273 *       paragraph)" remark to the final paragraph. (vbox_ttm.c) */
     274static const char g_szMitAlt4[] =
     275    "Permission is hereby granted, free of charge, to any person obtaining a\n"
     276    "copy of this software and associated documentation files (the\n"
     277    "\"Software\"), to deal in the Software without restriction, including\n"
     278    "without limitation the rights to use, copy, modify, merge, publish,\n"
     279    "distribute, sub license, and/or sell copies of the Software, and to\n"
     280    "permit persons to whom the Software is furnished to do so, subject to\n"
     281    "the following conditions:\n"
     282    "\n"
     283    "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
     284    "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
     285    "FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n"
     286    "THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,\n"
     287    "DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n"
     288    "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n"
     289    "USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
     290    "\n"
     291    "The above copyright notice and this permission notice (including the\n"
     292    "next paragraph) shall be included in all copies or substantial portions\n"
     293    "of the Software.\n";
     294
    270295
    271296/** Oracle confidential. */
     
    285310};
    286311
    287 /** Licenses to detect when --license-mit _is_ used. */
     312/** Licenses to detect when --license-mit or --license-based-on-mit are used. */
    288313static const SCMLICENSETEXT g_aLicensesWithMit[] =
    289314{
     
    292317    { kScmLicenseType_Mit,              kScmLicense_Mit,            RT_STR_TUPLE(g_szMitAlt2) },
    293318    { kScmLicenseType_Mit,              kScmLicense_Mit,            RT_STR_TUPLE(g_szMitAlt3) },
     319    { kScmLicenseType_Mit,              kScmLicense_Mit,            RT_STR_TUPLE(g_szMitAlt4) },
    294320    { kScmLicenseType_OseGpl,           kScmLicense_OseGpl,         RT_STR_TUPLE(g_szVBoxOseGpl)},
    295321    { kScmLicenseType_OseDualGplCddl,   kScmLicense_OseDualGplCddl, RT_STR_TUPLE(g_szVBoxOseDualGplCddl) },
     
    12251251            cBlankLinesAfterCopyright++;
    12261252        }
     1253
     1254        /*
     1255         * If we have a based-on-mit scenario, check for the lead in now and
     1256         * complain if not found.
     1257         */
     1258        if (   fFoundCopyright
     1259            && pState->enmLicenceOpt == kScmLicense_BasedOnMit
     1260            && pState->iLineLicense == UINT32_MAX)
     1261        {
     1262            if (RTStrNICmp(pszBody, RT_STR_TUPLE("This file is based on ")) == 0)
     1263            {
     1264                /* Take down a comment area which goes up to 'this file is based on'.
     1265                   The license line and length isn't used but gets set to cover the current line. */
     1266                pState->iLineComment        = pInfo->iLineStart;
     1267                pState->cLinesComment       = iLine - pInfo->iLineStart;
     1268                pState->iLineLicense        = iLine;
     1269                pState->cLinesLicense       = 1;
     1270                pState->fExternalLicense    = true;
     1271                pState->fIsCorrectLicense   = true;
     1272                pState->fWellFormedLicense  = true;
     1273
     1274                /* Check if we've got a MIT a license here or not. */
     1275                pState->pCurrentLicense     = NULL;
     1276                do
     1277                {
     1278                    const char *pszEol = (const char *)memchr(pszBody, '\n', cchBody);
     1279                    if (!pszEol || pszEol[1] == '\0')
     1280                    {
     1281                        pszBody += cchBody;
     1282                        cchBody = 0;
     1283                        break;
     1284                    }
     1285                    cchBody -= pszEol - pszBody + 1;
     1286                    pszBody  = pszEol + 1;
     1287                    iLine++;
     1288
     1289                    for (PCSCMLICENSETEXT pCur = pState->paLicenses; pCur->cch > 0; pCur++)
     1290                    {
     1291                        const char *pszNext;
     1292                        if (   pCur->cch <= cchBody + 32 /* (+ 32 since we don't compare spaces and punctuation) */
     1293                            && IsEqualWordByWordIgnoreCase(pCur->psz, pszBody, &pszNext))
     1294                        {
     1295                            pState->pCurrentLicense = pCur;
     1296                            break;
     1297                        }
     1298                    }
     1299                } while (!pState->pCurrentLicense);
     1300                if (!pState->pCurrentLicense)
     1301                    ScmError(pState->pState, VERR_NOT_FOUND, "Could not find the based-on license!\n");
     1302                else if (pState->pCurrentLicense->enmType != kScmLicenseType_Mit)
     1303                    ScmError(pState->pState, VERR_NOT_FOUND, "The based-on license is not MIT (%.32s...)\n",
     1304                             pState->pCurrentLicense->psz);
     1305            }
     1306            else
     1307                ScmError(pState->pState, VERR_WRONG_ORDER, "Expected 'This file is based on ...' after our copyright!\n");
     1308            return VINF_SUCCESS;
     1309        }
    12271310    }
    12281311
     
    13611444        /*.fOpenSource = */             true,
    13621445        /*.pExpectedLicense = */        NULL,
    1363         /*.paLicenses = */              pSettings->enmUpdateLicense != kScmLicense_Mit ? &g_aLicenses[0] : &g_aLicensesWithMit[0],
     1446        /*.paLicenses = */                   pSettings->enmUpdateLicense != kScmLicense_Mit
     1447                                          && pSettings->enmUpdateLicense != kScmLicense_BasedOnMit
     1448                                        ? &g_aLicenses[0] : &g_aLicensesWithMit[0],
    13641449        /*.enmLicenceOpt = */           pSettings->enmUpdateLicense,
    13651450        /*.iLineLicense = */            UINT32_MAX,
     
    13861471    Info.pExpectedLicense = Info.paLicenses;
    13871472    if (Info.fOpenSource)
    1388         while (Info.pExpectedLicense->enmOpt != pSettings->enmUpdateLicense)
    1389             Info.pExpectedLicense++;
     1473    {
     1474        if (   pSettings->enmUpdateLicense != kScmLicense_Mit
     1475            && pSettings->enmUpdateLicense != kScmLicense_BasedOnMit)
     1476            while (Info.pExpectedLicense->enmOpt != pSettings->enmUpdateLicense)
     1477                Info.pExpectedLicense++;
     1478        else
     1479            Assert(Info.pExpectedLicense->enmOpt == kScmLicense_Mit);
     1480    }
    13901481    else
    13911482        while (Info.pExpectedLicense->enmType != kScmLicenseType_Confidential)
     
    14801571                        ScmStreamPutEol(pOut, enmEol);
    14811572
    1482                         /* Blank line separating the two. */
    1483                         ScmStreamPutLine(pOut, g_aCopyrightCommentEmpty[enmCommentStyle].psz,
    1484                                          g_aCopyrightCommentEmpty[enmCommentStyle].cch, enmEol);
    1485 
    1486                         /* Write the license text. */
    1487                         Assert(Info.pExpectedLicense->psz[Info.pExpectedLicense->cch - 1] == '\n');
    1488                         Assert(Info.pExpectedLicense->psz[Info.pExpectedLicense->cch - 2] != '\n');
    1489                         const char *psz = Info.pExpectedLicense->psz;
    1490                         do
     1573                        if (pSettings->enmUpdateLicense != kScmLicense_BasedOnMit)
    14911574                        {
    1492                             const char *pszEol = strchr(psz, '\n');
    1493                             if (pszEol != psz)
     1575                            /* Blank line separating the two. */
     1576                            ScmStreamPutLine(pOut, g_aCopyrightCommentEmpty[enmCommentStyle].psz,
     1577                                             g_aCopyrightCommentEmpty[enmCommentStyle].cch, enmEol);
     1578
     1579                            /* Write the license text. */
     1580                            Assert(Info.pExpectedLicense->psz[Info.pExpectedLicense->cch - 1] == '\n');
     1581                            Assert(Info.pExpectedLicense->psz[Info.pExpectedLicense->cch - 2] != '\n');
     1582                            const char *psz = Info.pExpectedLicense->psz;
     1583                            do
    14941584                            {
    1495                                 ScmStreamWrite(pOut, g_aCopyrightCommentPrefix[enmCommentStyle].psz,
    1496                                                g_aCopyrightCommentPrefix[enmCommentStyle].cch);
    1497                                 ScmStreamWrite(pOut, psz, pszEol - psz);
    1498                                 ScmStreamPutEol(pOut, enmEol);
    1499                             }
    1500                             else
    1501                                 ScmStreamPutLine(pOut, g_aCopyrightCommentEmpty[enmCommentStyle].psz,
    1502                                                  g_aCopyrightCommentEmpty[enmCommentStyle].cch, enmEol);
    1503                             psz = pszEol + 1;
    1504                         } while (*psz != '\0');
    1505 
    1506                         /* Final comment line (picking up the stream status here). */
    1507                         if (!Info.fExternalLicense)
    1508                             rc = ScmStreamPutLine(pOut, g_aCopyrightCommentEnd[enmCommentStyle].psz,
    1509                                                   g_aCopyrightCommentEnd[enmCommentStyle].cch, enmEol);
     1585                                const char *pszEol = strchr(psz, '\n');
     1586                                if (pszEol != psz)
     1587                                {
     1588                                    ScmStreamWrite(pOut, g_aCopyrightCommentPrefix[enmCommentStyle].psz,
     1589                                                   g_aCopyrightCommentPrefix[enmCommentStyle].cch);
     1590                                    ScmStreamWrite(pOut, psz, pszEol - psz);
     1591                                    ScmStreamPutEol(pOut, enmEol);
     1592                                }
     1593                                else
     1594                                    ScmStreamPutLine(pOut, g_aCopyrightCommentEmpty[enmCommentStyle].psz,
     1595                                                     g_aCopyrightCommentEmpty[enmCommentStyle].cch, enmEol);
     1596                                psz = pszEol + 1;
     1597                            } while (*psz != '\0');
     1598
     1599                            /* Final comment line. */
     1600                            if (!Info.fExternalLicense)
     1601                                ScmStreamPutLine(pOut, g_aCopyrightCommentEnd[enmCommentStyle].psz,
     1602                                                 g_aCopyrightCommentEnd[enmCommentStyle].cch, enmEol);
     1603                        }
    15101604                        else
    1511                             rc = ScmStreamGetStatus(pOut);
     1605                            Assert(Info.fExternalLicense);
    15121606
    15131607                        /* Skip the copyright and license text in the input file. */
     1608                        rc = ScmStreamGetStatus(pOut);
    15141609                        if (RT_SUCCESS(rc))
    15151610                        {
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