Changeset 96401 in vbox
- Timestamp:
- Aug 22, 2022 3:06:19 PM (2 years ago)
- Location:
- trunk/src/bldprogs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/scm.cpp
r94905 r96401 336 336 SCM_REWRITER_CFG(g_Copyright_SqlComment, "copyright-sql-style", rewrite_Copyright_SqlComment); 337 337 SCM_REWRITER_CFG(g_Copyright_TickComment, "copyright-tick-style", rewrite_Copyright_TickComment); 338 SCM_REWRITER_CFG(g_Copyright_XmlComment, "copyright-xml-style", rewrite_Copyright_XmlComment); 338 339 SCM_REWRITER_CFG(g_Makefile_kup, "makefile-kup", rewrite_Makefile_kup); 339 340 SCM_REWRITER_CFG(g_Makefile_kmk, "makefile-kmk", rewrite_Makefile_kmk); … … 648 649 &g_SvnSyncProcess, 649 650 &g_UnicodeChecks, 650 /** @todo copyright is in an XML comment. */651 &g_Copyright_XmlComment, 651 652 }; 652 653 … … 661 662 &g_SvnSyncProcess, 662 663 &g_UnicodeChecks, 663 /** @todo copyright is in an XML comment. */664 &g_Copyright_XmlComment, 664 665 }; 665 666 … … 674 675 &g_SvnSyncProcess, 675 676 &g_UnicodeChecks, 676 /** @todo copyright is in an XML comment. */677 &g_Copyright_XmlComment, 677 678 }; 678 679 … … 802 803 SCM_CFG_ENTRY("kup", g_apRewritersFor_Makefile_kup, false, "Makefile.kup" ), 803 804 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" ), 805 806 SCM_CFG_ENTRY("h", g_apRewritersFor_H_and_HPP, false, "*.h|*.hpp" ), 806 807 SCM_CFG_ENTRY("rc", g_apRewritersFor_RC, false, "*.rc" ), … … 821 822 SCM_CFG_ENTRY("image", g_apRewritersFor_Images, true, "*.png|*.bmp|*.jpg|*.pnm|*.ico|*.icns|*.tiff|*.tif|*.xcf|*.gif" ), 822 823 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" ), 824 825 SCM_CFG_ENTRY("wix", g_apRewritersFor_Wix, false, "*.wxi|*.wxs|*.wxl" ), 825 826 SCM_CFG_ENTRY("qt-pro", g_apRewritersFor_QtProject, false, "*.pro" ), … … 832 833 SCM_CFG_ENTRY("binary", g_apRewritersFor_BinaryFiles, true, "*.bin|*.pdf|*.zip|*.bz2|*.gz" ), 833 834 /* 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" ), 835 836 SCM_CFG_ENTRY("text", g_apRewritersFor_TextFiles, false, "*.txt|README*|readme*|ReadMe*|NOTE*|TODO*" ), 836 837 SCM_CFG_ENTRY("plaintext", g_apRewritersFor_PlainTextFiles, false, "LICENSE|ChangeLog|FAQ|AUTHORS|INSTALL|NEWS" ), … … 2837 2838 || strstr(paOpts[i+1].pszLong, "-not-") != NULL 2838 2839 || strstr(paOpts[i+1].pszLong, "-dont-") != NULL 2839 || str cmp(paOpts[i+1].pszLong, "--unrestricted-ASMMemPage-use") == 02840 || strstr(paOpts[i+1].pszLong, "-unrestricted-") != NULL 2840 2841 || (paOpts[i].iShort == 'q' && paOpts[i+1].iShort == 'v') 2841 2842 || (paOpts[i].iShort == 'd' && paOpts[i+1].iShort == 'D') -
trunk/src/bldprogs/scm.h
r94905 r96401 85 85 kScmCommentStyle_Sql, 86 86 kScmCommentStyle_Tick, 87 kScmCommentStyle_Xml, 87 88 kScmCommentStyle_End 88 89 } SCMCOMMENTSTYLE; … … 105 106 kScmCommentType_MultiLine_Qt_After, /**< Multi-line comment, Qt after-member style. */ 106 107 kScmCommentType_DocString, /**< Triple quoted python doc string. */ 108 kScmCommentType_Xml, /**< XML comment style. */ 107 109 kScmCommentType_End /**< Customary exclusive end value. */ 108 110 } SCMCOMMENTTYPE; … … 262 264 FNSCMREWRITER rewrite_Copyright_SqlComment; 263 265 FNSCMREWRITER rewrite_Copyright_TickComment; 266 FNSCMREWRITER rewrite_Copyright_XmlComment; 264 267 FNSCMREWRITER rewrite_Makefile_kup; 265 268 FNSCMREWRITER rewrite_Makefile_kmk; -
trunk/src/bldprogs/scmparser.cpp
r93115 r96401 95 95 96 96 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 97 114 /** Macro for checking for a batch file comment prefix. */ 98 115 #define IS_REM(a_pch, a_off, a_cch) \ … … 199 216 off += cchSkip; 200 217 201 /* Determin comment type. */218 /* Determine comment type. */ 202 219 Info.enmType = kScmCommentType_Line; 203 220 char ch; … … 340 357 341 358 /** 342 * Common string lit teral handler.359 * Common string literal handler. 343 360 * 344 361 * @returns new pchLine value. … … 352 369 * @param poff Pointer to the line offset variable. 353 370 */ 354 static const char *handleStringLit teral(PSCMSTREAM pIn, char chType, const char *pchLine, size_t *pcchLine, PSCMEOL penmEol,355 uint32_t *piLine, size_t *poff)371 static const char *handleStringLiteral(PSCMSTREAM pIn, char chType, const char *pchLine, size_t *pcchLine, PSCMEOL penmEol, 372 uint32_t *piLine, size_t *poff) 356 373 { 357 374 size_t off = *poff; … … 443 460 Info.cBlankLinesBefore = 0; 444 461 445 /* Determin comment type (same as for line-comments). */462 /* Determine comment type (same as for line-comments). */ 446 463 Info.enmType = kScmCommentType_MultiLine; 447 464 if ( off < cchLine … … 594 611 { 595 612 /* 596 * String lit teralsmay include sequences that looks like comments. So,613 * String literal may include sequences that looks like comments. So, 597 614 * they needs special handling to avoid confusion. 598 615 */ 599 pchLine = handleStringLit teral(pIn, '"', pchLine, &cchLine, &enmEol, &iLine, &off);616 pchLine = handleStringLiteral(pIn, '"', pchLine, &cchLine, &enmEol, &iLine, &off); 600 617 } 601 /* else: We don't have to deal with character lit teralsas these shouldn't618 /* else: We don't have to deal with character literal as these shouldn't 602 619 include comment-like sequences. */ 603 620 } /* for each character in the line */ … … 659 676 { 660 677 /* 661 * String lit teralsmay be doc strings and they may legally include hashes.678 * String literal may be doc strings and they may legally include hashes. 662 679 */ 663 680 const char chType = ch; … … 665 682 || pchLine[off] != chType 666 683 || pchLine[off + 1] != chType) 667 pchLine = handleStringLit teral(pIn, chType, pchLine, &cchLine, &enmEol, &iLine, &off);684 pchLine = handleStringLiteral(pIn, chType, pchLine, &cchLine, &enmEol, &iLine, &off); 668 685 else 669 686 { … … 806 823 break; 807 824 } 808 /* else: We don't have to deal with character lit teralsas these shouldn't825 /* else: We don't have to deal with character literal as these shouldn't 809 826 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 */ 847 static 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++; 810 988 } /* for each character in the line */ 811 989 … … 839 1017 /* 840 1018 * Skip leading blanks and check for 'rem'. 841 * At the moment we do not parse '::lab le-comments'.1019 * At the moment we do not parse '::label-comments'. 842 1020 */ 843 1021 size_t off = 0; … … 1002 1180 return enumerateSimpleLineComments(pIn, '\'', isTickComment, pfnCallback, pvUser); 1003 1181 1182 case kScmCommentStyle_Xml: 1183 return enumerateXmlComments(pIn, pfnCallback, pvUser); 1184 1004 1185 default: 1005 1186 AssertFailedReturn(VERR_INVALID_PARAMETER); -
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.

