Patch to fix makeheaders bug
(1) By anonymous on 2022-04-10 02:26:33 [source]
The makeheaders parser accepts lines like this "#define INTERFACE\n"
.
But, it does not recognise lines with \r
, link this: "#define INTERFACE\r\n"
.
In the original code the nArg==9
check does not work if there was a \r
.
This patch alters nArg
to allow for the \r
.
Regards,
Sam
sam@octech.com.au
--- a/util/makeheaders.c
+++ b/util/makeheaders.c
@@ -2209,6 +2209,7 @@ static int ParsePreprocessor(Token *pToken, int flags, int *pPresetFlags){
}
if( *zArg==0 || *zArg=='\n' ){ return 0; }
nArg = pToken->nText + (int)(pToken->zText - zArg);
+ if (pToken->zText[pToken->nText-1] == '\r') { nArg--; }
if( nArg==9 && strncmp(zArg,"INTERFACE",9)==0 ){
PushIfMacro(0,0,0,pToken->nLine,PS_Interface);
}else if( nArg==16 && strncmp(zArg,"EXPORT_INTERFACE",16)==0 ){
(2) By Stephan Beal (stephan) on 2022-04-10 20:00:00 in reply to 1 [link] [source]
This patch alters nArg to allow for the
\r
.
Patched, thank you!
(3) By anonymous on 2022-04-11 03:45:48 in reply to 2 [link] [source]
I have since found a couple of other places with the same problem:
@@ -2230,6 +2231,7 @@ static int ParsePreprocessor(Token *pToken, int flags, int *pPresetFlags){
}
if( *zArg==0 || *zArg=='\n' ){ return 0; }
nArg = pToken->nText + (int)(pToken->zText - zArg);
+ if (pToken->zText[pToken->nText-1] == '\r') { nArg--; }
PushIfMacro("defined",zArg,nArg,pToken->nLine,0);
}else if( nCmd==6 && strncmp(zCmd,"ifndef",6)==0 ){
/*
@@ -2241,6 +2243,7 @@ static int ParsePreprocessor(Token *pToken, int flags, int *pPresetFlags){
}
if( *zArg==0 || *zArg=='\n' ){ return 0; }
nArg = pToken->nText + (int)(pToken->zText - zArg);
+ if (pToken->zText[pToken->nText-1] == '\r') { nArg--; }
PushIfMacro("!defined",zArg,nArg,pToken->nLine,0);
}else if( nCmd==4 && strncmp(zCmd,"else",4)==0 ){
/*
(4) By Stephan Beal (stephan) on 2022-04-11 06:39:32 in reply to 3 [link] [source]
I have since found a couple of other places with the same problem:
Patched, thank you!