VirtualBox

Changeset 96401 in vbox


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).

Location:
trunk/src/bldprogs
Files:
4 edited

Legend:

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

    r94905 r96401  
    336336SCM_REWRITER_CFG(g_Copyright_SqlComment,            "copyright-sql-style",          rewrite_Copyright_SqlComment);
    337337SCM_REWRITER_CFG(g_Copyright_TickComment,           "copyright-tick-style",         rewrite_Copyright_TickComment);
     338SCM_REWRITER_CFG(g_Copyright_XmlComment,            "copyright-xml-style",          rewrite_Copyright_XmlComment);
    338339SCM_REWRITER_CFG(g_Makefile_kup,                    "makefile-kup",                 rewrite_Makefile_kup);
    339340SCM_REWRITER_CFG(g_Makefile_kmk,                    "makefile-kmk",                 rewrite_Makefile_kmk);
     
    648649    &g_SvnSyncProcess,
    649650    &g_UnicodeChecks,
    650     /** @todo copyright is in an XML comment. */
     651    &g_Copyright_XmlComment,
    651652};
    652653
     
    661662    &g_SvnSyncProcess,
    662663    &g_UnicodeChecks,
    663     /** @todo copyright is in an XML comment. */
     664    &g_Copyright_XmlComment,
    664665};
    665666
     
    674675    &g_SvnSyncProcess,
    675676    &g_UnicodeChecks,
    676     /** @todo copyright is in an XML comment. */
     677    &g_Copyright_XmlComment,
    677678};
    678679
     
    802803    SCM_CFG_ENTRY("kup",        g_apRewritersFor_Makefile_kup,     false, "Makefile.kup" ),
    803804    SCM_CFG_ENTRY("kmk",        g_apRewritersFor_Makefile_kmk,     false, "*.kmk" ),
    804     SCM_CFG_ENTRY("c",          g_apRewritersFor_C_and_CPP,        false, "*.c|*.cpp|*.C|*.CPP|*.cxx|*.cc|*.m|*.mm" ),
     805    SCM_CFG_ENTRY("c",          g_apRewritersFor_C_and_CPP,        false, "*.c|*.cpp|*.C|*.CPP|*.cxx|*.cc|*.m|*.mm|*.lds" ),
    805806    SCM_CFG_ENTRY("h",          g_apRewritersFor_H_and_HPP,        false, "*.h|*.hpp" ),
    806807    SCM_CFG_ENTRY("rc",         g_apRewritersFor_RC,               false, "*.rc" ),
     
    821822    SCM_CFG_ENTRY("image",      g_apRewritersFor_Images,           true,  "*.png|*.bmp|*.jpg|*.pnm|*.ico|*.icns|*.tiff|*.tif|*.xcf|*.gif" ),
    822823    SCM_CFG_ENTRY("xslt",       g_apRewritersFor_Xslt,             false, "*.xsl" ),
    823     SCM_CFG_ENTRY("xml",        g_apRewritersFor_Xml,              false, "*.xml" ),
     824    SCM_CFG_ENTRY("xml",        g_apRewritersFor_Xml,              false, "*.xml|*.dist|*.qhcp" ),
    824825    SCM_CFG_ENTRY("wix",        g_apRewritersFor_Wix,              false, "*.wxi|*.wxs|*.wxl" ),
    825826    SCM_CFG_ENTRY("qt-pro",     g_apRewritersFor_QtProject,        false, "*.pro" ),
     
    832833    SCM_CFG_ENTRY("binary",     g_apRewritersFor_BinaryFiles,      true,  "*.bin|*.pdf|*.zip|*.bz2|*.gz" ),
    833834    /* These should be be last: */
    834     SCM_CFG_ENTRY("make",       g_apRewritersFor_OtherMakefiles,   false, "Makefile|makefile|GNUmakefile|SMakefile|Makefile.am|Makefile.in|*.cmake" ),
     835    SCM_CFG_ENTRY("make",       g_apRewritersFor_OtherMakefiles,   false, "Makefile|makefile|GNUmakefile|SMakefile|Makefile.am|Makefile.in|*.cmake|*.gmk" ),
    835836    SCM_CFG_ENTRY("text",       g_apRewritersFor_TextFiles,        false, "*.txt|README*|readme*|ReadMe*|NOTE*|TODO*" ),
    836837    SCM_CFG_ENTRY("plaintext",  g_apRewritersFor_PlainTextFiles,   false, "LICENSE|ChangeLog|FAQ|AUTHORS|INSTALL|NEWS" ),
     
    28372838                             || strstr(paOpts[i+1].pszLong, "-not-") != NULL
    28382839                             || strstr(paOpts[i+1].pszLong, "-dont-") != NULL
    2839                              || strcmp(paOpts[i+1].pszLong, "--unrestricted-ASMMemPage-use") == 0
     2840                             || strstr(paOpts[i+1].pszLong, "-unrestricted-") != NULL
    28402841                             || (paOpts[i].iShort == 'q' && paOpts[i+1].iShort == 'v')
    28412842                             || (paOpts[i].iShort == 'd' && paOpts[i+1].iShort == 'D')
  • trunk/src/bldprogs/scm.h

    r94905 r96401  
    8585    kScmCommentStyle_Sql,
    8686    kScmCommentStyle_Tick,
     87    kScmCommentStyle_Xml,
    8788    kScmCommentStyle_End
    8889} SCMCOMMENTSTYLE;
     
    105106    kScmCommentType_MultiLine_Qt_After,         /**< Multi-line comment, Qt after-member style.  */
    106107    kScmCommentType_DocString,                  /**< Triple quoted python doc string. */
     108    kScmCommentType_Xml,                        /**< XML comment style. */
    107109    kScmCommentType_End                         /**< Customary exclusive end value. */
    108110} SCMCOMMENTTYPE;
     
    262264FNSCMREWRITER rewrite_Copyright_SqlComment;
    263265FNSCMREWRITER rewrite_Copyright_TickComment;
     266FNSCMREWRITER rewrite_Copyright_XmlComment;
    264267FNSCMREWRITER rewrite_Makefile_kup;
    265268FNSCMREWRITER rewrite_Makefile_kmk;
  • trunk/src/bldprogs/scmparser.cpp

    r93115 r96401  
    9595
    9696
     97/** Macro for checking for a XML comment start. */
     98#define IS_XML_COMMENT_START(a_pch, a_off, a_cch) \
     99        (   (a_off) + 4 <= (a_cch) \
     100         && (a_pch)[(a_off)    ] == '<' \
     101         && (a_pch)[(a_off) + 1] == '!' \
     102         && (a_pch)[(a_off) + 2] == '-' \
     103         && (a_pch)[(a_off) + 3] == '-' \
     104         && ((a_off) + 4 == (a_cch) || RT_C_IS_SPACE((a_pch)[(a_off) + 4])) )
     105
     106/** Macro for checking for a XML comment end. */
     107#define IS_XML_COMMENT_END(a_pch, a_off, a_cch) \
     108        (   (a_off) + 3 <= (a_cch) \
     109         && (a_pch)[(a_off)    ] == '-' \
     110         && (a_pch)[(a_off) + 1] == '-' \
     111         && (a_pch)[(a_off) + 2] == '>')
     112
     113
    97114/** Macro for checking for a batch file comment prefix. */
    98115#define IS_REM(a_pch, a_off, a_cch) \
     
    199216    off += cchSkip;
    200217
    201     /* Determin comment type. */
     218    /* Determine comment type. */
    202219    Info.enmType = kScmCommentType_Line;
    203220    char ch;
     
    340357
    341358/**
    342  * Common string litteral handler.
     359 * Common string literal handler.
    343360 *
    344361 * @returns new pchLine value.
     
    352369 * @param   poff        Pointer to the line offset variable.
    353370 */
    354 static const char *handleStringLitteral(PSCMSTREAM pIn, char chType, const char *pchLine, size_t *pcchLine, PSCMEOL penmEol,
    355                                         uint32_t *piLine, size_t *poff)
     371static const char *handleStringLiteral(PSCMSTREAM pIn, char chType, const char *pchLine, size_t *pcchLine, PSCMEOL penmEol,
     372                                       uint32_t *piLine, size_t *poff)
    356373{
    357374    size_t off = *poff;
     
    443460                        Info.cBlankLinesBefore  = 0;
    444461
    445                         /* Determin comment type (same as for line-comments). */
     462                        /* Determine comment type (same as for line-comments). */
    446463                        Info.enmType = kScmCommentType_MultiLine;
    447464                        if (   off < cchLine
     
    594611            {
    595612                /*
    596                  * String litterals may include sequences that looks like comments.  So,
     613                 * String literal may include sequences that looks like comments.  So,
    597614                 * they needs special handling to avoid confusion.
    598615                 */
    599                 pchLine = handleStringLitteral(pIn, '"', pchLine, &cchLine, &enmEol, &iLine, &off);
     616                pchLine = handleStringLiteral(pIn, '"', pchLine, &cchLine, &enmEol, &iLine, &off);
    600617            }
    601             /* else: We don't have to deal with character litterals as these shouldn't
     618            /* else: We don't have to deal with character literal as these shouldn't
    602619                     include comment-like sequences. */
    603620        } /* for each character in the line */
     
    659676            {
    660677                /*
    661                  * String litterals may be doc strings and they may legally include hashes.
     678                 * String literal may be doc strings and they may legally include hashes.
    662679                 */
    663680                const char chType = ch;
     
    665682                    || pchLine[off] != chType
    666683                    || pchLine[off + 1] != chType)
    667                     pchLine = handleStringLitteral(pIn, chType, pchLine, &cchLine, &enmEol, &iLine, &off);
     684                    pchLine = handleStringLiteral(pIn, chType, pchLine, &cchLine, &enmEol, &iLine, &off);
    668685                else
    669686                {
     
    806823                    break;
    807824            }
    808             /* else: We don't have to deal with character litterals as these shouldn't
     825            /* else: We don't have to deal with character literal as these shouldn't
    809826                     include comment-like sequences. */
     827        } /* for each character in the line */
     828
     829        iLine++;
     830    } /* for each line in the stream */
     831
     832    int rcStream = ScmStreamGetStatus(pIn);
     833    if (RT_SUCCESS(rcStream))
     834        return rcRet;
     835    return rcStream;
     836}
     837
     838
     839/**
     840 * Deals with XML comments.
     841 *
     842 * @returns VBox status code / callback return code.
     843 * @param   pIn                 The stream to parse.
     844 * @param   pfnCallback         The callback.
     845 * @param   pvUser              The user parameter for the callback.
     846 */
     847static int enumerateXmlComments(PSCMSTREAM pIn, PFNSCMCOMMENTENUMERATOR pfnCallback, void *pvUser)
     848{
     849    int             rcRet = VINF_SUCCESS;
     850    uint32_t        iLine = 0;
     851    SCMEOL          enmEol;
     852    size_t          cchLine;
     853    const char     *pchLine;
     854    while ((pchLine = ScmStreamGetLine(pIn, &cchLine, &enmEol)) != NULL)
     855    {
     856        size_t off = 0;
     857        while (off < cchLine)
     858        {
     859            /*
     860             * Skip leading blanks and check for start of XML comment.
     861             */
     862            while (off + 3 < cchLine && RT_C_IS_SPACE(pchLine[off]))
     863                off++;
     864            if (IS_XML_COMMENT_START(pchLine, off, cchLine))
     865            {
     866                /*
     867                 * XML comment.  Find the end.
     868                 *
     869                 * Note! This is very similar to the python doc string handling above.
     870                 */
     871                SCMCOMMENTINFO  Info;
     872                Info.iLineStart         = iLine;
     873                Info.offStart           = (uint32_t)off;
     874                Info.iLineEnd           = UINT32_MAX;
     875                Info.offEnd             = UINT32_MAX;
     876                Info.cBlankLinesBefore  = 0;
     877                Info.enmType            = kScmCommentType_Xml;
     878
     879                off += 4;
     880
     881                /*
     882                 * Copy the body and find the end of the XML comment.
     883                 */
     884                size_t          cbBodyAlloc = 0;
     885                size_t          cchBody     = 0;
     886                char           *pszBody     = NULL;
     887                for (;;)
     888                {
     889                    /* Parse the line up to the end-of-comment or end-of-line. */
     890                    size_t offLineStart     = off;
     891                    size_t offLastNonBlank  = off;
     892                    size_t offFirstNonBlank = ~(size_t)0;
     893                    while (off < cchLine)
     894                    {
     895                        if (!IS_XML_COMMENT_END(pchLine, off, cchLine))
     896                        {
     897                            char ch = pchLine[off++];
     898                            if (RT_C_IS_BLANK(ch))
     899                            {/* kind of likely */}
     900                            else
     901                            {
     902                                offLastNonBlank = off - 1;
     903                                if (offFirstNonBlank != ~(size_t)0)
     904                                {/* likely */}
     905                                else if (   (ch != '*' && ch != '#')    /* ignore continuation-asterisks */
     906                                         || off > Info.offStart + 1 + 1
     907                                         || off > cchLine
     908                                         || (   off < cchLine
     909                                              && !RT_C_IS_SPACE(pchLine[off]))
     910                                         || pszBody == NULL)
     911                                    offFirstNonBlank = off - 1;
     912                            }
     913                        }
     914                        else
     915                        {
     916                            off += 3;
     917                            Info.offEnd   = (uint32_t)off;
     918                            Info.iLineEnd = iLine;
     919                            break;
     920                        }
     921                    }
     922
     923                    /* Append line content to the comment body string. */
     924                    size_t cchAppend;
     925                    if (offFirstNonBlank == ~(size_t)0)
     926                        cchAppend = 0; /* empty line */
     927                    else
     928                    {
     929                        offLineStart = offFirstNonBlank;
     930                        cchAppend = offLastNonBlank + 1 - offLineStart;
     931                        Assert(cchAppend <= cchLine);
     932                    }
     933
     934                    size_t cchNewBody = cchBody + (cchBody > 0) + cchAppend;
     935                    if (cchNewBody >= cbBodyAlloc)
     936                    {
     937                        cbBodyAlloc = RT_MAX(cbBodyAlloc ? cbBodyAlloc * 2 : _1K, RT_ALIGN_Z(cchNewBody + 64, 128));
     938                        void *pvNew = RTMemRealloc(pszBody, cbBodyAlloc);
     939                        if (pvNew)
     940                            pszBody = (char *)pvNew;
     941                        else
     942                        {
     943                            RTMemFree(pszBody);
     944                            return VERR_NO_MEMORY;
     945                        }
     946                    }
     947
     948                    if (cchBody > 0)                        /* no leading blank lines */
     949                        pszBody[cchBody++] = '\n';
     950                    else if (cchAppend == 0)
     951                        Info.cBlankLinesBefore++;
     952                    memcpy(&pszBody[cchBody], &pchLine[offLineStart], cchAppend);
     953                    cchBody += cchAppend;
     954                    pszBody[cchBody] = '\0';
     955
     956                    /* Advance to the next line, if we haven't yet seen the end of this comment. */
     957                    if (Info.iLineEnd != UINT32_MAX)
     958                        break;
     959                    pchLine = ScmStreamGetLine(pIn, &cchLine, &enmEol);
     960                    if (!pchLine)
     961                    {
     962                        Info.offEnd   = (uint32_t)cchLine;
     963                        Info.iLineEnd = iLine;
     964                        break;
     965                    }
     966                    iLine++;
     967                    off = 0;
     968                }
     969
     970                /* Strip trailing empty lines in the body. */
     971                Info.cBlankLinesAfter = 0;
     972                while (cchBody >= 1 && pszBody[cchBody - 1] == '\n')
     973                {
     974                    Info.cBlankLinesAfter++;
     975                    pszBody[--cchBody] = '\0';
     976                }
     977
     978                /* Do the callback. */
     979                int rc = pfnCallback(&Info, pszBody, cchBody, pvUser);
     980                RTMemFree(pszBody);
     981                if (RT_FAILURE(rc))
     982                    return rc;
     983                if (rc > VINF_SUCCESS && rcRet == VINF_SUCCESS)
     984                    rcRet = rc;
     985            }
     986            else
     987                off++;
    810988        } /* for each character in the line */
    811989
     
    8391017        /*
    8401018         * Skip leading blanks and check for 'rem'.
    841          * At the moment we do not parse '::lable-comments'.
     1019         * At the moment we do not parse '::label-comments'.
    8421020         */
    8431021        size_t off = 0;
     
    10021180            return enumerateSimpleLineComments(pIn, '\'', isTickComment, pfnCallback, pvUser);
    10031181
     1182        case kScmCommentStyle_Xml:
     1183            return enumerateXmlComments(pIn, pfnCallback, pvUser);
     1184
    10041185        default:
    10051186            AssertFailedReturn(VERR_INVALID_PARAMETER);
  • 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