Fossil SCM
makeheaders.c: suggestions from https://fossil-scm.org/forum/forumpost/00ff64e63e: do not emit main() decl, elide C++ constructor member initialization, and add a missing fclose().
Commit
9512ed93d37a7cfd00d075597bae4728b5178230b49bf8478ec628c5e4b103c8
Parent
569cc741d65fbd3…
1 file changed
+15
-1
+15
-1
| --- src/makeheaders.c | ||
| +++ src/makeheaders.c | ||
| @@ -1733,10 +1733,20 @@ | ||
| 1733 | 1733 | pDecl->extraType = PS_Private; |
| 1734 | 1734 | } |
| 1735 | 1735 | } |
| 1736 | 1736 | StringAppend(&str, " ", 0); |
| 1737 | 1737 | zDecl = TokensToString(pFirst, pLast, ";\n", pClass, 2); |
| 1738 | + if(strncmp(zDecl, pClass->zText, pClass->nText)==0){ | |
| 1739 | + /* If member initializer list is found after a constructor, | |
| 1740 | + ** skip that part. */ | |
| 1741 | + char * colon = strchr(zDecl, ':'); | |
| 1742 | + if(colon!=0 && colon[1]!=0){ | |
| 1743 | + *colon++ = ';'; | |
| 1744 | + *colon++ = '\n'; | |
| 1745 | + *colon = 0; | |
| 1746 | + } | |
| 1747 | + } | |
| 1738 | 1748 | StringAppend(&str, zDecl, 0); |
| 1739 | 1749 | SafeFree(zDecl); |
| 1740 | 1750 | pDecl->zExtra = StrDup(StringGet(&str), 0); |
| 1741 | 1751 | StringReset(&str); |
| 1742 | 1752 | return 0; |
| @@ -1783,11 +1793,14 @@ | ||
| 1783 | 1793 | if( pName==0 ){ |
| 1784 | 1794 | fprintf(stderr,"%s:%d: Malformed function or procedure definition.\n", |
| 1785 | 1795 | zFilename, pFirst->nLine); |
| 1786 | 1796 | return 1; |
| 1787 | 1797 | } |
| 1788 | - | |
| 1798 | + if( strncmp(pName->zText,"main",pName->nText)==0 ){ | |
| 1799 | + /* skip main() decl. */ | |
| 1800 | + return 0; | |
| 1801 | + } | |
| 1789 | 1802 | /* |
| 1790 | 1803 | ** At this point we've isolated a procedure declaration between pFirst |
| 1791 | 1804 | ** and pLast with the name pName. |
| 1792 | 1805 | */ |
| 1793 | 1806 | #ifdef DEBUG |
| @@ -3217,10 +3230,11 @@ | ||
| 3217 | 3230 | strcpy( zNew[j], zBuf ); |
| 3218 | 3231 | } |
| 3219 | 3232 | } |
| 3220 | 3233 | } |
| 3221 | 3234 | } |
| 3235 | + fclose(in); | |
| 3222 | 3236 | newArgc = argc + nNew - 1; |
| 3223 | 3237 | for(i=0; i<=index; i++){ |
| 3224 | 3238 | zNew[i] = argv[i]; |
| 3225 | 3239 | } |
| 3226 | 3240 | for(i=nNew + index + 1; i<newArgc; i++){ |
| 3227 | 3241 |
| --- src/makeheaders.c | |
| +++ src/makeheaders.c | |
| @@ -1733,10 +1733,20 @@ | |
| 1733 | pDecl->extraType = PS_Private; |
| 1734 | } |
| 1735 | } |
| 1736 | StringAppend(&str, " ", 0); |
| 1737 | zDecl = TokensToString(pFirst, pLast, ";\n", pClass, 2); |
| 1738 | StringAppend(&str, zDecl, 0); |
| 1739 | SafeFree(zDecl); |
| 1740 | pDecl->zExtra = StrDup(StringGet(&str), 0); |
| 1741 | StringReset(&str); |
| 1742 | return 0; |
| @@ -1783,11 +1793,14 @@ | |
| 1783 | if( pName==0 ){ |
| 1784 | fprintf(stderr,"%s:%d: Malformed function or procedure definition.\n", |
| 1785 | zFilename, pFirst->nLine); |
| 1786 | return 1; |
| 1787 | } |
| 1788 | |
| 1789 | /* |
| 1790 | ** At this point we've isolated a procedure declaration between pFirst |
| 1791 | ** and pLast with the name pName. |
| 1792 | */ |
| 1793 | #ifdef DEBUG |
| @@ -3217,10 +3230,11 @@ | |
| 3217 | strcpy( zNew[j], zBuf ); |
| 3218 | } |
| 3219 | } |
| 3220 | } |
| 3221 | } |
| 3222 | newArgc = argc + nNew - 1; |
| 3223 | for(i=0; i<=index; i++){ |
| 3224 | zNew[i] = argv[i]; |
| 3225 | } |
| 3226 | for(i=nNew + index + 1; i<newArgc; i++){ |
| 3227 |
| --- src/makeheaders.c | |
| +++ src/makeheaders.c | |
| @@ -1733,10 +1733,20 @@ | |
| 1733 | pDecl->extraType = PS_Private; |
| 1734 | } |
| 1735 | } |
| 1736 | StringAppend(&str, " ", 0); |
| 1737 | zDecl = TokensToString(pFirst, pLast, ";\n", pClass, 2); |
| 1738 | if(strncmp(zDecl, pClass->zText, pClass->nText)==0){ |
| 1739 | /* If member initializer list is found after a constructor, |
| 1740 | ** skip that part. */ |
| 1741 | char * colon = strchr(zDecl, ':'); |
| 1742 | if(colon!=0 && colon[1]!=0){ |
| 1743 | *colon++ = ';'; |
| 1744 | *colon++ = '\n'; |
| 1745 | *colon = 0; |
| 1746 | } |
| 1747 | } |
| 1748 | StringAppend(&str, zDecl, 0); |
| 1749 | SafeFree(zDecl); |
| 1750 | pDecl->zExtra = StrDup(StringGet(&str), 0); |
| 1751 | StringReset(&str); |
| 1752 | return 0; |
| @@ -1783,11 +1793,14 @@ | |
| 1793 | if( pName==0 ){ |
| 1794 | fprintf(stderr,"%s:%d: Malformed function or procedure definition.\n", |
| 1795 | zFilename, pFirst->nLine); |
| 1796 | return 1; |
| 1797 | } |
| 1798 | if( strncmp(pName->zText,"main",pName->nText)==0 ){ |
| 1799 | /* skip main() decl. */ |
| 1800 | return 0; |
| 1801 | } |
| 1802 | /* |
| 1803 | ** At this point we've isolated a procedure declaration between pFirst |
| 1804 | ** and pLast with the name pName. |
| 1805 | */ |
| 1806 | #ifdef DEBUG |
| @@ -3217,10 +3230,11 @@ | |
| 3230 | strcpy( zNew[j], zBuf ); |
| 3231 | } |
| 3232 | } |
| 3233 | } |
| 3234 | } |
| 3235 | fclose(in); |
| 3236 | newArgc = argc + nNew - 1; |
| 3237 | for(i=0; i<=index; i++){ |
| 3238 | zNew[i] = argv[i]; |
| 3239 | } |
| 3240 | for(i=nNew + index + 1; i<newArgc; i++){ |
| 3241 |