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

stephan 2019-09-06 10:36 trunk
Commit 9512ed93d37a7cfd00d075597bae4728b5178230b49bf8478ec628c5e4b103c8
1 file changed +15 -1
--- src/makeheaders.c
+++ src/makeheaders.c
@@ -1733,10 +1733,20 @@
17331733
pDecl->extraType = PS_Private;
17341734
}
17351735
}
17361736
StringAppend(&str, " ", 0);
17371737
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
+ }
17381748
StringAppend(&str, zDecl, 0);
17391749
SafeFree(zDecl);
17401750
pDecl->zExtra = StrDup(StringGet(&str), 0);
17411751
StringReset(&str);
17421752
return 0;
@@ -1783,11 +1793,14 @@
17831793
if( pName==0 ){
17841794
fprintf(stderr,"%s:%d: Malformed function or procedure definition.\n",
17851795
zFilename, pFirst->nLine);
17861796
return 1;
17871797
}
1788
-
1798
+ if( strncmp(pName->zText,"main",pName->nText)==0 ){
1799
+ /* skip main() decl. */
1800
+ return 0;
1801
+ }
17891802
/*
17901803
** At this point we've isolated a procedure declaration between pFirst
17911804
** and pLast with the name pName.
17921805
*/
17931806
#ifdef DEBUG
@@ -3217,10 +3230,11 @@
32173230
strcpy( zNew[j], zBuf );
32183231
}
32193232
}
32203233
}
32213234
}
3235
+ fclose(in);
32223236
newArgc = argc + nNew - 1;
32233237
for(i=0; i<=index; i++){
32243238
zNew[i] = argv[i];
32253239
}
32263240
for(i=nNew + index + 1; i<newArgc; i++){
32273241
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button