VirtualBox

Changeset 69215 in vbox for trunk/src


Ignore:
Timestamp:
Oct 24, 2017 2:38:50 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118528
Message:

scm: Check for 'Contributed by' preceeding the copyright statement.

Location:
trunk/src/bldprogs
Files:
3 edited

Legend:

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

    r69207 r69215  
    7979    SCMOPT_UPDATE_COPYRIGHT_YEAR,
    8080    SCMOPT_NO_UPDATE_COPYRIGHT_YEAR,
     81    SCMOPT_EXTERNAL_COPYRIGHT,
     82    SCMOPT_NO_EXTERNAL_COPYRIGHT,
    8183    SCMOPT_NO_UPDATE_LICENSE,
    8284    SCMOPT_LICENSE_OSE_GPL,
     
    161163    /* .fFixTodos = */                              true,
    162164    /* .fUpdateCopyrightYear = */                   false,
     165    /* .fExternalCopyright = */                     false,
    163166    /* .enmUpdateLicense = */                       kScmLicense_OseGpl,
    164167    /* .fOnlySvnFiles = */                          false,
     
    196199    { "--update-copyright-year",            SCMOPT_UPDATE_COPYRIGHT_YEAR,           RTGETOPT_REQ_NOTHING },
    197200    { "--no-update-copyright-year",         SCMOPT_NO_UPDATE_COPYRIGHT_YEAR,        RTGETOPT_REQ_NOTHING },
     201    { "--external-copyright",               SCMOPT_EXTERNAL_COPYRIGHT,              RTGETOPT_REQ_NOTHING },
     202    { "--no-external-copyright",            SCMOPT_NO_EXTERNAL_COPYRIGHT,           RTGETOPT_REQ_NOTHING },
    198203    { "--no-update-license",                SCMOPT_NO_UPDATE_LICENSE,               RTGETOPT_REQ_NOTHING },
    199204    { "--license-ose-gpl",                  SCMOPT_LICENSE_OSE_GPL,                 RTGETOPT_REQ_NOTHING },
     
    511516        case SCMOPT_NO_UPDATE_COPYRIGHT_YEAR:
    512517            pSettings->fUpdateCopyrightYear = false;
     518            return VINF_SUCCESS;
     519
     520        case SCMOPT_EXTERNAL_COPYRIGHT:
     521            pSettings->fExternalCopyright = true;
     522            return VINF_SUCCESS;
     523        case SCMOPT_NO_EXTERNAL_COPYRIGHT:
     524            pSettings->fExternalCopyright = false;
    513525            return VINF_SUCCESS;
    514526
     
    18541866                RTPrintf("      Update the copyright year.  Default: %RTbool\n", g_Defaults.fUpdateCopyrightYear);
    18551867                break;
     1868            case SCMOPT_EXTERNAL_COPYRIGHT:
     1869                RTPrintf("      Only external copyright holders.  Default: %RTbool\n", g_Defaults.fExternalCopyright);
     1870                break;
    18561871            case SCMOPT_NO_UPDATE_LICENSE:
    18571872                RTPrintf("      License selection.  Default: --license-ose-gpl\n");
  • trunk/src/bldprogs/scm.h

    r69207 r69215  
    258258    /** Update the copyright year. */
    259259    bool            fUpdateCopyrightYear;
     260    /** Only external copyright holders. */
     261    bool            fExternalCopyright;
    260262    /** How to update the license. */
    261263    SCMLICENSE      enmUpdateLicense;
  • trunk/src/bldprogs/scmrw.cpp

    r69211 r69215  
    7777    /** The comment style (neede for C/C++). */
    7878    SCMCOMMENTSTYLE     enmCommentStyle;        /**< input */
     79
     80    /** Copy of the contributed-by line if present. */
     81    char               *pszContributedBy;
    7982
    8083    /** @name Common info
     
    900903
    901904    /*
    902      * Since the license statement is typically prefaced by a copyright line.
     905     * Look for a 'contributed by' line, this comes first.
     906     */
     907    const char *pchContributedBy = NULL;
     908    size_t      cchContributedBy = 0;
     909    size_t      cBlankLinesAfterContributedBy = 0;
     910    if (    pState->pszContributedBy == NULL
     911        && (   pState->iLineCopyright == UINT32_MAX
     912            || pState->iLineLicense == UINT32_MAX)
     913        && cchBody > sizeof("Contributed by")
     914        && RTStrNICmp(pszBody, RT_STR_TUPLE("contributed by")) == 0)
     915    {
     916        const char *pszNextLine = (const char *)memchr(pszBody, '\n', cchBody);
     917        if (pszNextLine)
     918        {
     919            pchContributedBy = pszBody;
     920            cchContributedBy = pszNextLine - pszBody;
     921
     922            /* Skip the copyright line and any blank lines following it. */
     923            cchBody -= cchContributedBy + 1;
     924            pszBody  = pszNextLine + 1;
     925            iLine   += 1;
     926            while (*pszBody == '\n')
     927            {
     928                pszBody++;
     929                cchBody--;
     930                iLine++;
     931                cBlankLinesAfterContributedBy++;
     932            }
     933        }
     934    }
     935
     936    /*
     937     * Look for the copyright line.
    903938     */
    904939    bool     fFoundCopyright = false;
     
    10371072            }
    10381073
     1074            if (pchContributedBy)
     1075            {
     1076                pState->pszContributedBy = RTStrDupN(pchContributedBy, cchContributedBy);
     1077                if (cBlankLinesAfterContributedBy != 1)
     1078                {
     1079                    ScmVerbose(pState->pState, 1, "* %u blank lines between contributed by and copyright, should be 1\n",
     1080                               cBlankLinesAfterContributedBy);
     1081                    pState->fWellFormedCopyright = false;
     1082                }
     1083            }
     1084
    10391085            fFoundCopyright = true;
    10401086            ScmVerbose(pState->pState, 2, "oracle copyright %u-%u: up-to-date=%RTbool well-formed=%RTbool\n",
     
    10611107
    10621108    /*
    1063      * Now try match against the license texts if we haven't already found it.
     1109     * Look for the license text.
    10641110     */
    10651111    if (pState->iLineLicense == UINT32_MAX)
     
    11811227        /*.enmCommentStyle = */         enmCommentStyle,
    11821228
     1229        /*.pszContributedBy = */        NULL,
     1230
    11831231        /*.iLineComment = */            UINT32_MAX,
    11841232        /*.cLinesComment = */           0,
     
    12281276        && RT_SUCCESS(pState->rc))
    12291277    {
    1230         if (Info.iLineCopyright == UINT32_MAX)
     1278        if (pSettings->fExternalCopyright)
     1279        {
     1280            if (Info.iLineCopyright != UINT32_MAX)
     1281                ScmError(pState, VERR_NOT_FOUND,
     1282                         "Marked as external copyright only, but found non-external copyright statement at line %u!\n",
     1283                         Info.iLineCopyright + 1);
     1284        }
     1285        else if (Info.iLineCopyright == UINT32_MAX)
    12311286            ScmError(pState, VERR_NOT_FOUND, "Missing copyright!\n");
    12321287        else if (Info.iLineLicense == UINT32_MAX)
     
    12661321                        ScmStreamPutLine(pOut, g_aCopyrightCommentStart[enmCommentStyle].psz,
    12671322                                         g_aCopyrightCommentStart[enmCommentStyle].cch, enmEol);
     1323
     1324                        /* Contributed by someone? */
     1325                        if (Info.pszContributedBy)
     1326                        {
     1327                            ScmStreamWrite(pOut, g_aCopyrightCommentPrefix[enmCommentStyle].psz,
     1328                                           g_aCopyrightCommentPrefix[enmCommentStyle].cch);
     1329                            ScmStreamWrite(pOut, Info.pszContributedBy, strlen(Info.pszContributedBy));
     1330                            ScmStreamPutEol(pOut, enmEol);
     1331
     1332                            ScmStreamPutLine(pOut, g_aCopyrightCommentEmpty[enmCommentStyle].psz,
     1333                                             g_aCopyrightCommentEmpty[enmCommentStyle].cch, enmEol);
     1334                        }
    12681335
    12691336                        /* Write the copyright comment line. */
     
    13271394                    }
    13281395                    if (RT_FAILURE(rc))
     1396                    {
     1397                        RTStrFree(Info.pszContributedBy);
    13291398                        return false;
    1330                 }
     1399                    }
     1400                } /* for each source line */
     1401
     1402                RTStrFree(Info.pszContributedBy);
    13311403                return true;
    13321404            }
     
    13361408        ScmError(pState, rc,  "ScmEnumerateComments: %Rrc\n", rc);
    13371409    NOREF(pState); NOREF(pOut);
     1410    RTStrFree(Info.pszContributedBy);
    13381411    return false;
    13391412}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette