Changeset 69215 in vbox for trunk/src/bldprogs/scmrw.cpp
- Timestamp:
- Oct 24, 2017 2:38:50 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/scmrw.cpp
r69211 r69215 77 77 /** The comment style (neede for C/C++). */ 78 78 SCMCOMMENTSTYLE enmCommentStyle; /**< input */ 79 80 /** Copy of the contributed-by line if present. */ 81 char *pszContributedBy; 79 82 80 83 /** @name Common info … … 900 903 901 904 /* 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. 903 938 */ 904 939 bool fFoundCopyright = false; … … 1037 1072 } 1038 1073 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 1039 1085 fFoundCopyright = true; 1040 1086 ScmVerbose(pState->pState, 2, "oracle copyright %u-%u: up-to-date=%RTbool well-formed=%RTbool\n", … … 1061 1107 1062 1108 /* 1063 * Now try match against the license texts if we haven't already found it.1109 * Look for the license text. 1064 1110 */ 1065 1111 if (pState->iLineLicense == UINT32_MAX) … … 1181 1227 /*.enmCommentStyle = */ enmCommentStyle, 1182 1228 1229 /*.pszContributedBy = */ NULL, 1230 1183 1231 /*.iLineComment = */ UINT32_MAX, 1184 1232 /*.cLinesComment = */ 0, … … 1228 1276 && RT_SUCCESS(pState->rc)) 1229 1277 { 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) 1231 1286 ScmError(pState, VERR_NOT_FOUND, "Missing copyright!\n"); 1232 1287 else if (Info.iLineLicense == UINT32_MAX) … … 1266 1321 ScmStreamPutLine(pOut, g_aCopyrightCommentStart[enmCommentStyle].psz, 1267 1322 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 } 1268 1335 1269 1336 /* Write the copyright comment line. */ … … 1327 1394 } 1328 1395 if (RT_FAILURE(rc)) 1396 { 1397 RTStrFree(Info.pszContributedBy); 1329 1398 return false; 1330 } 1399 } 1400 } /* for each source line */ 1401 1402 RTStrFree(Info.pszContributedBy); 1331 1403 return true; 1332 1404 } … … 1336 1408 ScmError(pState, rc, "ScmEnumerateComments: %Rrc\n", rc); 1337 1409 NOREF(pState); NOREF(pOut); 1410 RTStrFree(Info.pszContributedBy); 1338 1411 return false; 1339 1412 }
Note:
See TracChangeset
for help on using the changeset viewer.