From 9c3a4bf5cb4460236474e876a2ef48a2f0838832 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 23 Nov 2024 05:03:02 +0300
Subject: [PATCH] fix build in C23 mode, wrt bool type.
---
rtfactn.c | 220 ++++++++++++++++++++++++++---------------------------
rtfreadr.c | 8 +-
rtftype.h | 13 ++--
3 files changed, 122 insertions(+), 119 deletions(-)
diff --git a/rtfactn.c b/rtfactn.c
index 3f63516..9f25e7f 100644
--- a/rtfactn.c
+++ b/rtfactn.c
@@ -52,111 +52,111 @@ PROP rgprop[ipropMax] =
SYM rgsymRtf[] =
{
/* keyword, dflt, fPassDflt, kwd, idx */
- {"fonttbl", 0, fFalse, kwdDest, idestFontTable},
- {"fnil", fnil, fTrue, kwdProp, ipropFontFamily},
- {"froman", froman, fTrue, kwdProp, ipropFontFamily},
- {"fswiss", fswiss, fTrue, kwdProp, ipropFontFamily},
- {"fmodern", fmodern, fTrue, kwdProp, ipropFontFamily},
- {"fscript", fscript, fTrue, kwdProp, ipropFontFamily},
- {"fdecor", fdecor, fTrue, kwdProp, ipropFontFamily},
- {"ftech", ftech, fTrue, kwdProp, ipropFontFamily},
- {"fbidi", fbidi, fTrue, kwdProp, ipropFontFamily},
- {"fcharset", 0, fFalse, kwdProp, ipropFontCharset},
- {"colortbl", 0, fFalse, kwdDest, idestColorTable},
- {"red", 0, fFalse, kwdProp, ipropColorRed},
- {"green", 0, fFalse, kwdProp, ipropColorGreen},
- {"blue", 0, fFalse, kwdProp, ipropColorBlue},
- {"info", 0, fFalse, kwdDest, idestInfo},
- {"title", 0, fFalse, kwdDest, idestTitle},
- {"subject", 0, fFalse, kwdDest, idestSubject},
- {"author", 0, fFalse, kwdDest, idestAuthor},
- {"f", 0, fFalse, kwdProp, ipropFont},
- {"fs", 24, fFalse, kwdProp, ipropFontSize},
- {"cb", 1, fFalse, kwdProp, ipropBgColor},
- {"cf", 1, fFalse, kwdProp, ipropFgColor},
- {"b", 1, fFalse, kwdProp, ipropBold},
- {"ul", 1, fFalse, kwdProp, ipropUnderline},
- {"ulnone", 0, fTrue, kwdProp, ipropUnderline},
- {"i", 1, fFalse, kwdProp, ipropItalic},
- {"li", 0, fFalse, kwdProp, ipropLeftInd},
- {"ri", 0, fFalse, kwdProp, ipropRightInd},
- {"fi", 0, fFalse, kwdProp, ipropFirstInd},
- {"cols", 1, fFalse, kwdProp, ipropCols},
- {"sbknone", sbkNon, fTrue, kwdProp, ipropSbk},
- {"sbkcol", sbkCol, fTrue, kwdProp, ipropSbk},
- {"sbkeven", sbkEvn, fTrue, kwdProp, ipropSbk},
- {"sbkodd", sbkOdd, fTrue, kwdProp, ipropSbk},
- {"sbkpage", sbkPg, fTrue, kwdProp, ipropSbk},
- {"pgnx", 0, fFalse, kwdProp, ipropPgnX},
- {"pgny", 0, fFalse, kwdProp, ipropPgnY},
- {"pgndec", pgDec, fTrue, kwdProp, ipropPgnFormat},
- {"pgnucrm", pgURom, fTrue, kwdProp, ipropPgnFormat},
- {"pgnlcrm", pgLRom, fTrue, kwdProp, ipropPgnFormat},
- {"pgnucltr", pgULtr, fTrue, kwdProp, ipropPgnFormat},
- {"pgnlcltr", pgLLtr, fTrue, kwdProp, ipropPgnFormat},
- {"qc", justC, fTrue, kwdProp, ipropJust},
- {"ql", justL, fTrue, kwdProp, ipropJust},
- {"qr", justR, fTrue, kwdProp, ipropJust},
- {"qj", justF, fTrue, kwdProp, ipropJust},
- {"paperw", 12240, fFalse, kwdProp, ipropXaPage},
- {"paperh", 15480, fFalse, kwdProp, ipropYaPage},
- {"margl", 1800, fFalse, kwdProp, ipropXaLeft},
- {"margr", 1800, fFalse, kwdProp, ipropXaRight},
- {"margt", 1440, fFalse, kwdProp, ipropYaTop},
- {"margb", 1440, fFalse, kwdProp, ipropYaBottom},
- {"pgnstart", 1, fTrue, kwdProp, ipropPgnStart},
- {"facingp", 1, fTrue, kwdProp, ipropFacingp},
- {"landscape", 1, fTrue, kwdProp, ipropLandscape},
- {"line", 0, fFalse, kwdChar, '\n'},
- {"par", 0, fFalse, kwdChar, '\n'},
- {"\0x0a", 0, fFalse, kwdChar, '\n'},
- {"\r", 0, fFalse, kwdChar, '\n'},
- {"\0x0d", 0, fFalse, kwdChar, '\n'},
- {"\n", 0, fFalse, kwdChar, '\n'},
- {"tab", 0, fFalse, kwdChar, '\t'},
- {"ldblquote", 0, fFalse, kwdChar, '"'},
- {"rdblquote", 0, fFalse, kwdChar, '"'},
- {"bin", 0, fFalse, kwdSpec, ipfnBin},
- {"*", 0, fFalse, kwdSpec, ipfnSkipDest},
- {"'", 0, fFalse, kwdSpec, ipfnHex},
- {"bkmkend", 0, fFalse, kwdDest, idestSkip},
- {"bkmkstart", 0, fFalse, kwdDest, idestSkip},
- {"buptim", 0, fFalse, kwdDest, idestSkip},
- {"colortbl", 0, fFalse, kwdDest, idestSkip},
- {"comment", 0, fFalse, kwdDest, idestSkip},
- {"creatim", 0, fFalse, kwdDest, idestSkip},
- {"doccomm", 0, fFalse, kwdDest, idestSkip},
- {"fonttbl", 0, fFalse, kwdDest, idestSkip},
- {"footer", 0, fFalse, kwdDest, idestSkip},
- {"footerf", 0, fFalse, kwdDest, idestSkip},
- {"footerl", 0, fFalse, kwdDest, idestSkip},
- {"footerr", 0, fFalse, kwdDest, idestSkip},
- {"footnote", 0, fFalse, kwdDest, idestSkip},
- {"ftncn", 0, fFalse, kwdDest, idestSkip},
- {"ftnsep", 0, fFalse, kwdDest, idestSkip},
- {"ftnsepc", 0, fFalse, kwdDest, idestSkip},
- {"header", 0, fFalse, kwdDest, idestSkip},
- {"headerf", 0, fFalse, kwdDest, idestSkip},
- {"headerl", 0, fFalse, kwdDest, idestSkip},
- {"headerr", 0, fFalse, kwdDest, idestSkip},
- {"info", 0, fFalse, kwdDest, idestSkip},
- {"keywords", 0, fFalse, kwdDest, idestSkip},
- {"operator", 0, fFalse, kwdDest, idestSkip},
- {"pict", 0, fFalse, kwdDest, idestSkip},
- {"printim", 0, fFalse, kwdDest, idestSkip},
- {"private1", 0, fFalse, kwdDest, idestSkip},
- {"revtim", 0, fFalse, kwdDest, idestSkip},
- {"rxe", 0, fFalse, kwdDest, idestSkip},
- {"stylesheet", 0, fFalse, kwdDest, idestSkip},
- {"tc", 0, fFalse, kwdDest, idestSkip},
- {"txe", 0, fFalse, kwdDest, idestSkip},
- {"xe", 0, fFalse, kwdDest, idestSkip},
- {"{", 0, fFalse, kwdChar, '{'},
- {"}", 0, fFalse, kwdChar, '}'},
- {"\\", 0, fFalse, kwdChar, '\\'},
- {"pard", 0, fFalse, kwdProp, ipropPard},
- {"plain", 0, fFalse, kwdProp, ipropPlain},
- {"sectd", 0, fFalse, kwdProp, ipropSectd}
+ {"fonttbl", 0, false, kwdDest, idestFontTable},
+ {"fnil", fnil, true, kwdProp, ipropFontFamily},
+ {"froman", froman, true, kwdProp, ipropFontFamily},
+ {"fswiss", fswiss, true, kwdProp, ipropFontFamily},
+ {"fmodern", fmodern, true, kwdProp, ipropFontFamily},
+ {"fscript", fscript, true, kwdProp, ipropFontFamily},
+ {"fdecor", fdecor, true, kwdProp, ipropFontFamily},
+ {"ftech", ftech, true, kwdProp, ipropFontFamily},
+ {"fbidi", fbidi, true, kwdProp, ipropFontFamily},
+ {"fcharset", 0, false, kwdProp, ipropFontCharset},
+ {"colortbl", 0, false, kwdDest, idestColorTable},
+ {"red", 0, false, kwdProp, ipropColorRed},
+ {"green", 0, false, kwdProp, ipropColorGreen},
+ {"blue", 0, false, kwdProp, ipropColorBlue},
+ {"info", 0, false, kwdDest, idestInfo},
+ {"title", 0, false, kwdDest, idestTitle},
+ {"subject", 0, false, kwdDest, idestSubject},
+ {"author", 0, false, kwdDest, idestAuthor},
+ {"f", 0, false, kwdProp, ipropFont},
+ {"fs", 24, false, kwdProp, ipropFontSize},
+ {"cb", 1, false, kwdProp, ipropBgColor},
+ {"cf", 1, false, kwdProp, ipropFgColor},
+ {"b", 1, false, kwdProp, ipropBold},
+ {"ul", 1, false, kwdProp, ipropUnderline},
+ {"ulnone", 0, true, kwdProp, ipropUnderline},
+ {"i", 1, false, kwdProp, ipropItalic},
+ {"li", 0, false, kwdProp, ipropLeftInd},
+ {"ri", 0, false, kwdProp, ipropRightInd},
+ {"fi", 0, false, kwdProp, ipropFirstInd},
+ {"cols", 1, false, kwdProp, ipropCols},
+ {"sbknone", sbkNon, true, kwdProp, ipropSbk},
+ {"sbkcol", sbkCol, true, kwdProp, ipropSbk},
+ {"sbkeven", sbkEvn, true, kwdProp, ipropSbk},
+ {"sbkodd", sbkOdd, true, kwdProp, ipropSbk},
+ {"sbkpage", sbkPg, true, kwdProp, ipropSbk},
+ {"pgnx", 0, false, kwdProp, ipropPgnX},
+ {"pgny", 0, false, kwdProp, ipropPgnY},
+ {"pgndec", pgDec, true, kwdProp, ipropPgnFormat},
+ {"pgnucrm", pgURom, true, kwdProp, ipropPgnFormat},
+ {"pgnlcrm", pgLRom, true, kwdProp, ipropPgnFormat},
+ {"pgnucltr", pgULtr, true, kwdProp, ipropPgnFormat},
+ {"pgnlcltr", pgLLtr, true, kwdProp, ipropPgnFormat},
+ {"qc", justC, true, kwdProp, ipropJust},
+ {"ql", justL, true, kwdProp, ipropJust},
+ {"qr", justR, true, kwdProp, ipropJust},
+ {"qj", justF, true, kwdProp, ipropJust},
+ {"paperw", 12240, false, kwdProp, ipropXaPage},
+ {"paperh", 15480, false, kwdProp, ipropYaPage},
+ {"margl", 1800, false, kwdProp, ipropXaLeft},
+ {"margr", 1800, false, kwdProp, ipropXaRight},
+ {"margt", 1440, false, kwdProp, ipropYaTop},
+ {"margb", 1440, false, kwdProp, ipropYaBottom},
+ {"pgnstart", 1, true, kwdProp, ipropPgnStart},
+ {"facingp", 1, true, kwdProp, ipropFacingp},
+ {"landscape", 1, true, kwdProp, ipropLandscape},
+ {"line", 0, false, kwdChar, '\n'},
+ {"par", 0, false, kwdChar, '\n'},
+ {"\0x0a", 0, false, kwdChar, '\n'},
+ {"\r", 0, false, kwdChar, '\n'},
+ {"\0x0d", 0, false, kwdChar, '\n'},
+ {"\n", 0, false, kwdChar, '\n'},
+ {"tab", 0, false, kwdChar, '\t'},
+ {"ldblquote", 0, false, kwdChar, '"'},
+ {"rdblquote", 0, false, kwdChar, '"'},
+ {"bin", 0, false, kwdSpec, ipfnBin},
+ {"*", 0, false, kwdSpec, ipfnSkipDest},
+ {"'", 0, false, kwdSpec, ipfnHex},
+ {"bkmkend", 0, false, kwdDest, idestSkip},
+ {"bkmkstart", 0, false, kwdDest, idestSkip},
+ {"buptim", 0, false, kwdDest, idestSkip},
+ {"colortbl", 0, false, kwdDest, idestSkip},
+ {"comment", 0, false, kwdDest, idestSkip},
+ {"creatim", 0, false, kwdDest, idestSkip},
+ {"doccomm", 0, false, kwdDest, idestSkip},
+ {"fonttbl", 0, false, kwdDest, idestSkip},
+ {"footer", 0, false, kwdDest, idestSkip},
+ {"footerf", 0, false, kwdDest, idestSkip},
+ {"footerl", 0, false, kwdDest, idestSkip},
+ {"footerr", 0, false, kwdDest, idestSkip},
+ {"footnote", 0, false, kwdDest, idestSkip},
+ {"ftncn", 0, false, kwdDest, idestSkip},
+ {"ftnsep", 0, false, kwdDest, idestSkip},
+ {"ftnsepc", 0, false, kwdDest, idestSkip},
+ {"header", 0, false, kwdDest, idestSkip},
+ {"headerf", 0, false, kwdDest, idestSkip},
+ {"headerl", 0, false, kwdDest, idestSkip},
+ {"headerr", 0, false, kwdDest, idestSkip},
+ {"info", 0, false, kwdDest, idestSkip},
+ {"keywords", 0, false, kwdDest, idestSkip},
+ {"operator", 0, false, kwdDest, idestSkip},
+ {"pict", 0, false, kwdDest, idestSkip},
+ {"printim", 0, false, kwdDest, idestSkip},
+ {"private1", 0, false, kwdDest, idestSkip},
+ {"revtim", 0, false, kwdDest, idestSkip},
+ {"rxe", 0, false, kwdDest, idestSkip},
+ {"stylesheet", 0, false, kwdDest, idestSkip},
+ {"tc", 0, false, kwdDest, idestSkip},
+ {"txe", 0, false, kwdDest, idestSkip},
+ {"xe", 0, false, kwdDest, idestSkip},
+ {"{", 0, false, kwdChar, '{'},
+ {"}", 0, false, kwdChar, '}'},
+ {"\\", 0, false, kwdChar, '\\'},
+ {"pard", 0, false, kwdProp, ipropPard},
+ {"plain", 0, false, kwdProp, ipropPlain},
+ {"sectd", 0, false, kwdProp, ipropSectd}
};
int isymMax = sizeof(rgsymRtf) / sizeof(SYM);
@@ -255,9 +255,9 @@ int ecParseSpecialProperty(RTF_Context *ctx, IPROP iprop, int val)
* Inputs:
* szKeyword: The RTF control to evaluate.
* param: The parameter of the RTF control.
- * fParam: fTrue if the control had a parameter; (that is, if param
+ * fParam: true if the control had a parameter; (that is, if param
* is valid)
- * fFalse if it did not.
+ * false if it did not.
*/
int ecTranslateKeyword(RTF_Context *ctx, char *szKeyword, int param,
bool fParam)
@@ -276,12 +276,12 @@ int ecTranslateKeyword(RTF_Context *ctx, char *szKeyword, int param,
if (ctx->fSkipDestIfUnk) /* if this is a new destination */
ctx->rds = rdsSkip; /* skip the destination */
/* else just discard it */
- ctx->fSkipDestIfUnk = fFalse;
+ ctx->fSkipDestIfUnk = false;
return ecOK;
}
/* found it! use kwd and idx to determine what to do with it. */
- ctx->fSkipDestIfUnk = fFalse;
+ ctx->fSkipDestIfUnk = false;
switch (rgsymRtf[isym].kwd)
{
case kwdProp:
@@ -396,7 +396,7 @@ int ecParseSpecialKeyword(RTF_Context *ctx, IPFN ipfn)
ctx->cbBin = ctx->lParam;
break;
case ipfnSkipDest:
- ctx->fSkipDestIfUnk = fTrue;
+ ctx->fSkipDestIfUnk = true;
break;
case ipfnHex:
ctx->ris = risHex;
diff --git a/rtfreadr.c b/rtfreadr.c
index ba7f82c..7c0fc54 100644
--- a/rtfreadr.c
+++ b/rtfreadr.c
@@ -566,8 +566,8 @@ int ecPopRtfState(RTF_Context *ctx)
int ecParseRtfKeyword(RTF_Context *ctx)
{
int ch;
- char fParam = fFalse;
- char fNeg = fFalse;
+ char fParam = false;
+ char fNeg = false;
int param = 0;
char *pch;
char szKeyword[30];
@@ -592,13 +592,13 @@ int ecParseRtfKeyword(RTF_Context *ctx)
*pch = '\0';
if (ch == '-')
{
- fNeg = fTrue;
+ fNeg = true;
if (ecRtfGetChar(ctx, &ch) != ecOK)
return ecEndOfFile;
}
if (SDL_isdigit(ch))
{
- fParam = fTrue; /* a digit after the control means we have a parameter */
+ fParam = true; /* a digit after the control means we have a parameter */
for (pch = szParameter; SDL_isdigit(ch);)
{
*pch++ = (char) ch;
diff --git a/rtftype.h b/rtftype.h
index 52fc74d..7002f99 100644
--- a/rtftype.h
+++ b/rtftype.h
@@ -6,12 +6,15 @@
#ifndef _RTFTYPE_H
#define _RTFTYPE_H
-#if !defined(__cplusplus) && !defined(bool)
-typedef char bool;
+#if !defined(__cplusplus)
+#if defined __STDC_VERSION__ && (__STDC_VERSION__ >= 199901L)
+#include <stdbool.h>
+#else
+typedef unsigned char bool;
+#define true 1
+#define false 0
+#endif
#endif
-
-#define fTrue 1
-#define fFalse 0
typedef struct char_prop
{