Skip to content

Commit 07a9360

Browse files
committed
More clang fixes including use of promoted types in va_arg()
1 parent c7b4b3b commit 07a9360

20 files changed

+118
-121
lines changed

src/ashwface.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,18 @@ bool CFSTYX::cfx_CalcRatings(
175175
//-----------------------------------------------------------------------------
176176
CFSTYX::CFSTYX( // build a CFS
177177
const char* id, // unique ID (max len = CFSIDLEN)
178-
float _UcogNFRC, // externally calculated NFRC cog U-factor, Btuh/ft2-F
179-
float _SHGCcogNFRC, // externally calculated NFRC cog SHGC
178+
double _UcogNFRC, // externally calculated NFRC cog U-factor, Btuh/ft2-F
179+
double _SHGCcogNFRC, // externally calculated NFRC cog SHGC
180180
...) // add'l gap / layer info
181+
// NOTE: double not float for _UcogNFRC and _SHGCcogNFRC for consistency
182+
// with other numeric args (which will be promoted to double)
181183
// call = id, U, SHGC, layerID, gasID, gapT (inches), layerID, ...
182184
// layer order = outside -> inside
183185
{
184186
Clear();
185187
FCSET( ID, id);
186-
UcogNFRC = _UcogNFRC;
187-
SHGCcogNFRC = _SHGCcogNFRC;
188+
UcogNFRC = float(_UcogNFRC);
189+
SHGCcogNFRC = float(_SHGCcogNFRC);
188190
va_list ap;
189191
va_start( ap, _SHGCcogNFRC);
190192
RC rc = RCBAD;

src/ashwface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct CFSTYX : public CFSTY
3838
float SHGCcogAW; // ASHWAT cog SHGC
3939

4040
CFSTYX() { Clear(); }
41-
CFSTYX( const char* id, float _UcogNFRC, float _SHGCcogNFRC, ...);
41+
CFSTYX( const char* id, double _UcogNFRC, double _SHGCcogNFRC, ...);
4242
void Clear();
4343
// wrappers for CFSTY mbrs that to facilitate C++ <-> DLL comparisons
4444
bool cfx_CalcRatings( float& Urat, float& SHGCrat);

src/cnloads.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ RC ZNR::zn_AirRequest( // determine air requirement given rs_asSup
12781278
orWarn("Flipped tSup RSYS='%s', tPln=%0.3f, tSup=%0.3f, tSP=%0.1f, tZn=%0.3f\n",
12791279
rs->Name(), rs->rs_asOut.as_tdb, tSup0, zn_tzsp, tz);
12801280
}
1281-
if (zn_hcMode != RSYS::rsmOFF && zn_tzsp > 0.f)
1281+
if (zn_hcMode == RSYS::rsmOFF && zn_tzsp > 0.f)
12821282
orWarn("Inconsistent hcMode RSYS='%s', hcMode=%d, tSP=%0.1f, tZn=%0.3f\n",
12831283
rs->Name(), zn_hcMode, zn_tzsp, tz);
12841284
#endif

src/cpgbuild.cpp

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,19 @@ LOCAL void pbLabel( SI pgfmt, SI row, SI col, SI wid, const char *label);
7575

7676
//=========================================================================
7777
void CDEC pgbuildr(
78-
/* declared new way for passing FLOATs 2-90. DOES *NOT* WORK: MSC 5.1 passes floats in variable arg list double. */
7978

8079
// Add text to a pgpak page per tables; optionally allocs, outputs (via cpnat.c), frees.
8180

8281
char **ppp, /* NULL to use internal page ptr (2-90), or ptr to page ptr (may be updated on return).
8382
CAUTION: if ptr ptr given but page is alloc here (row nz), ptr must contain NULL or valid, freeable DM ptr. */
8483
RC *prc, /* If *prc is not RCOK, pgbuildr() does *NOTHING*;
8584
otherwise outcome of this operation is returned in *prc (non-RCOK if console interrupt, printer error, etc). */
86-
SI rows, /* Size of page to alloc, or row 0 if *ppp already alloc'd. */
87-
SI cols, /* .. */
88-
SI rOff, /* Row offset for *ALL* rows specified in all actions in this call: shifts display down w/o changing
85+
int rows, /* Size of page to alloc, or row 0 if *ppp already alloc'd. */
86+
int cols, /* .. */
87+
int rOff, /* Row offset for *ALL* rows specified in all actions in this call: shifts display down w/o changing
8988
many table entries. Typical use: make blank space above title (idx'd methods).
9089
[ CAUTION: avoid both nz rOff and > 1 PGCUR in table rows. fixing this bug 2-90.] */
91-
char *title, /* NULL or Title to appear PGLJ at position (1+rOff,1).
90+
const char *title, /* NULL or Title to appear PGLJ at position (1+rOff,1).
9291
" continued" is appended if table head repeated on continuation print page.
9392
Allow for row used by title in PBHEAD.val2 with PBTABLE, PBFILLREC. */
9493

@@ -119,12 +118,6 @@ void CDEC pgbuildr(
119118

120119
// *prc remains RCOK if allocation, addition, and output completed ok; else nz. Errors have been reported (using WRN).
121120
{
122-
va_list argp; // Working pointer for variable args
123-
USI meth;
124-
SI keepgoing;
125-
RC rc;
126-
char *rp = nullptr;
127-
char *tp;
128121
/* Size table -- !! MUST match PBxxxx method type defns in cpgbuild.c. Used to increment pointer through method driver tables.
129122
Currently not used by methods involving PBM_IDX (such as PB_TABCOL and PB_FILLREC), but they are in table anyway */
130123
static char sizetab[] = {
@@ -141,7 +134,10 @@ void CDEC pgbuildr(
141134
if (*prc != RCOK)
142135
return;
143136

137+
char *rp = nullptr;
138+
144139
/* Initialize */
140+
va_list argp; // Working pointer for variable args
145141
va_start( argp, title);
146142

147143
/* some arguments to file-globals for use by internal subfunctions */
@@ -166,10 +162,10 @@ void CDEC pgbuildr(
166162

167163
/* Loop over arguments */
168164

169-
keepgoing = TRUE; /* Loop termination flag, tested at end of loop */
165+
bool keepgoing = true; /* Loop termination flag, tested at end of loop */
170166
do
171167
{
172-
rc = RCOK; /* no error yet this arg */
168+
RC rc = RCOK; /* no error yet this arg */
173169
pbHd = va_arg( argp, PBHEAD *); /* Ptr to PBHEAD, or spec fcn. file-global used by callees. */
174170
if (pbHd==NULL)
175171
continue; /* skip NULL args */
@@ -202,8 +198,8 @@ void CDEC pgbuildr(
202198
/* Other arguments: output per method */
203199

204200
{
205-
meth = (pbHd->methopt) & PBMTHMASK; /* Formatting method */
206-
tp = (char *)pbHd->methtab; /* method table pointer, actual type depends on meth. */
201+
int meth = (pbHd->methopt) & PBMTHMASK; /* Formatting method */
202+
char* tp = (char *)pbHd->methtab; /* method table pointer, actual type depends on meth. */
207203
if (meth & PBM_RP) /* method bit says rp arg follows */
208204
rp = va_arg(argp, char *); /* Pick up record pointer */
209205
/* pbIdxMth() and its callees also picks up additional arguments */
@@ -222,16 +218,16 @@ void CDEC pgbuildr(
222218

223219
while ( ((PB_TEXT *)tp)->pgfmt != PBMETHEND )
224220
{
225-
SI wid = 0;
226-
SI units, cvfmt;
227-
SI off;
228-
USI dt;
221+
int wid = 0;
222+
int units, cvfmt;
223+
int off;
224+
int dt;
229225
char *p;
230226

231227
/* prefetch .pgfmt,.row,.col for cases where struct matches PBTEXT (all cases except those without .col, 2-90) */
232-
SI pgfmt = ((PB_TEXT *)tp)->pgfmt | PGGROW; /* pgpak format. PGGROW: say enlarge page if necess */
233-
SI row = ROWOFF( ((PB_TEXT *)tp)->row); /* ROWOFF: adds pbROff if not PGCUR-relative */
234-
SI col = ((PB_TEXT *)tp)->col;
228+
int pgfmt = ((PB_TEXT *)tp)->pgfmt | PGGROW; /* pgpak format. PGGROW: say enlarge page if necess */
229+
int row = ROWOFF( ((PB_TEXT *)tp)->row); /* ROWOFF: adds pbROff if not PGCUR-relative */
230+
int col = ((PB_TEXT *)tp)->col;
235231

236232
/* more common init */
237233
const char* label = nullptr; // default no label: for shared case code
@@ -297,17 +293,17 @@ void CDEC pgbuildr(
297293
cvfmt = ((PB_DATA *)tp)->cvfmt; /* get cvpak fmt */
298294
offJoin: /* PBDATOFF/L join here */
299295
if (dt==(USI)PBARGSI) /* on special value get dt */
300-
dt = va_arg( argp, USI); /* ...from pgbuildr arg list*/
296+
dt = va_arg( argp, int); /* ...from pgbuildr arg list*/
301297
if (p==NULL) /* for NULL data ptr */
302298
dt = DTUNDEF; /* show '?' (historical) */
303299
/* NB if both in arg list, dt precedes data */
304300

305301
if (units==PBARGSI) /* spec value says */
306-
units = va_arg( argp, SI); /* get from arg list*/
302+
units = va_arg( argp, int); /* get from arg list*/
307303
if (wid==PBARGSI) /* spec value says */
308-
wid = va_arg( argp, SI); /* get from arg list*/
304+
wid = va_arg( argp, int); /* get from arg list*/
309305
if (cvfmt==PBARGSI) /* spec value says */
310-
cvfmt = va_arg( argp, SI); /* get from arg list*/
306+
cvfmt = va_arg( argp, int); /* get from arg list*/
311307
if (p==PBOMITP) /* ptr value omits output & label */
312308
{
313309
/* s is "" from above (write anyway for PGCUR) */

src/cpgbuild.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ struct PB_DATOFFL /* code assumes same as PB_DATOFF + label at end */
306306

307307
/*------------------------- FUNCTION DECLARATIONS -------------------------*/
308308

309-
void CDEC pgbuildr( char **ppp, RC *prc, SI rows, SI cols, SI rOffs, char *title, ...);
309+
void CDEC pgbuildr( char **ppp, RC *prc, int rows, int cols, int rOffs, const char* title, ...);
310310

311311
// CAUTION: any FLOATs in variable arg list are passed as doubles
312312

src/cpnat.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ f } /* pnSetFooter */
179179
#endif /* FOOTERS */
180180

181181
//===========================================================================
182-
RC FC pnAlloc( char **ppp, SI rows, SI cols, int erOp)
182+
RC FC pnAlloc( char **ppp, int rows, int cols, int erOp)
183183

184184
/* allocate a pgpak PAGE for use thru cpnat.c */
185185
/* clears per-table stuff: "continued" posn, # head rows */
@@ -219,10 +219,10 @@ void FC pnTitle(
219219

220220
char **ppp, /* (used to put s in page)
221221
CAUTION info retained for only 1 page at a time */
222-
SI row, /* 0 or title row */
223-
SI col, /* 0 or title text left col if text given,
222+
int row, /* 0 or title row */
223+
int col, /* 0 or title text left col if text given,
224224
or exact left col for "continued" if s is NULL */
225-
char *s ) /* title text, NULL for none */
225+
const char *s ) /* title text, NULL for none */
226226
{
227227
thConRow = row;
228228
thConCol = col; /* strlen(s)+1 conditionally added below */

src/cuparse.cpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ LOCAL SYTBH symtab = { NULL, 0 };
570570
// many tentatively decl in cuparsex.h for [cumain.cpp 10-90 and now] cuprobe.cpp 12-91.
571571

572572
/*--- CURRENT TOKEN INFO. Set mainly by toke(). Not changed by unToke(). */
573-
SI tokTy = 0; // current token type (CUT__ define; cuTok ret val)
573+
int tokTy = 0; // current token type (CUT__ define; cuTok ret val)
574574
SI prec = 0; // "prec" (precedence) from opTbl[]. PR__ defines.
575575
SI nextPrec = 0; // "prec" of ungotten (ie next) token, ONLY valid after expTy()/expr()/unToke().
576576
LOCAL SI lastPrec = 0; // "prec" of PRIOR token (0 at bof) NOT after unToke.
@@ -682,9 +682,9 @@ LOCAL RC FC emitPtr( void** p);
682682
LOCAL RC FC emitStr(const char* s, int sLen);
683683
#endif
684684
LOCAL RC FC emiBufFull( void);
685-
LOCAL SI FC tokeTest( SI tokTyPar);
686-
LOCAL SI FC tokeIf2( SI tokTy1, SI tokTy2);
687-
LOCAL SI CDEC tokeIfn( SI tokTy1, ... );
685+
LOCAL bool tokeTest( int tokTyPar);
686+
LOCAL bool tokeIf2( int tokTy1, int tokTy2);
687+
LOCAL bool tokeIfn( int tokTy1, ... );
688688
LOCAL void FC cuptokeClean( CLEANCASE cs);
689689
LOCAL RC FC addLocalSyms( void);
690690
LOCAL const char* FC before( const char* tx, int aN);
@@ -4107,52 +4107,54 @@ LOCAL RC FC emiBufFull( void) // pseudo-code buffer full handler
41074107

41084108

41094109
//===========================================================================
4110-
LOCAL SI FC tokeTest( SI tokTyPar) // get next token, return nz if it is token of specified type.
4110+
LOCAL bool tokeTest( int tokTyPar) // get next token, return nz if it is token of specified type.
41114111
{
41124112
return (toke() // get token, cuparse.cpp. sets cutok.cpp:cuToktx.
41134113
== tokTyPar); // true if is specified token type
41144114
} // tokeTest
41154115
//===========================================================================
4116-
SI FC tokeNot( SI tokTyPar) // get next token, return nz if it is NOT token of specified type.
4116+
bool tokeNot( int tokTyPar) // get next token, return nz if it is NOT token of specified type.
41174117
{
41184118
return (toke() // get token, cuparse.cpp. sets cutok.cpp:cuToktx.
41194119
!= tokTyPar); // false if is specified token type
41204120
} // tokeNot
41214121
//===========================================================================
4122-
SI FC tokeIf( SI tokTyPar) // return nz if next token is token of specified type, else unget token.
4122+
bool tokeIf( int tokTyPar) // return nz if next token is token of specified type, else unget token.
41234123
{
41244124
if (toke() // get token, cuparse.cpp. sets cutok.cpp:cuToktx.
41254125
== tokTyPar) // if is requested token type
4126-
return 1;
4126+
return true;
41274127
unToke(); // wrong type. unget token (cuparse.cpp)
4128-
return 0;
4128+
return false;
41294129
} // tokeIf
41304130
//===========================================================================
4131-
LOCAL SI FC tokeIf2( SI tokTy1, SI tokTy2) // return nz if next token is token of either specified type, else unget.
4131+
LOCAL bool tokeIf2( int tokTy1, int tokTy2) // return nz if next token is token of either specified type, else unget.
41324132
{
41334133
if ( toke() // get token, cuparse.cpp. sets cutok.cpp:tokTy.
4134-
== tokTy1 // if is requested token type
4134+
== tokTy1 // if is requested token type
41354135
|| tokTy==tokTy2 ) // or other requested type
4136-
return 1; // return TRUE
4136+
return true; // return TRUE
41374137
unToke(); // wrong type. unget token (cuparse.cpp)
4138-
return 0;
4138+
return false;
41394139
} // tokeIf2
41404140
//===========================================================================
4141-
LOCAL SI CDEC tokeIfn( SI tokTy1, ...) // return nz if next token is of any type in 0-terminated list, else unget token.
4141+
LOCAL bool tokeIfn( int tokTy1, ...) // return nz if next token is of any type in 0-terminated list, else unget token.
41424142
{
4143-
va_list list; SI thisArg;
41444143

41454144
toke(); // get token, cuparse.cpp. sets cutok.cpp:tokTy.
4146-
thisArg = tokTy1; // 1st arg
4145+
4146+
va_list list;
41474147
va_start( list, tokTy1); // set up to fetch more args
4148+
4149+
int thisArg{ tokTy1 };
41484150
while (thisArg > 0) // 0 (or -1) arg terminates list
41494151
{
41504152
if (tokTy==thisArg) // if token type matches
4151-
return 1; // say found
4152-
thisArg = va_arg( list, SI); // next arg (stdarg.h)
4153+
return true; // say found
4154+
thisArg = va_arg( list, int); // next arg (stdarg.h)
41534155
}
41544156
unToke(); // unget token (cuparse.cpp)
4155-
return 0; // not found
4157+
return false; // not found
41564158
} // tokeIfn
41574159

41584160
/*==================== VARIABLES for toke() - unToke() ====================*/
@@ -4189,7 +4191,7 @@ LOCAL void FC cuptokeClean([[maybe_unused]] CLEANCASE cs) // cleanup for toke -
41894191

41904192
} // cuptokeClean
41914193
//==========================================================================
4192-
SI FC toke() /* local token-getter -- cutok.cpp:cuTok + unary/binary resolution +
4194+
int toke() /* local token-getter -- cutok.cpp:cuTok + unary/binary resolution +
41934195
symbol table lookup + other refinements */
41944196

41954197
/* sets: tokTy: token type: CUTxxx defines, cutok.h.

src/cuparse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RC FC exOrk( SI toprec, USI wanTy, USI choiDt, USI evfOkPar, const char* ermTx,
2121
RC FC itPile( PSOP *dest, USI sizeofDest);
2222
RC FC finPile( USI *pCodeSize);
2323
RC FC expTy( SI toprec, USI wanTy, const char* tx, SI aN);
24-
SI FC toke();
24+
int toke();
2525
void FC unToke();
2626

2727
RC FC cuAddItSyms( SI tokTyPar, SI casi, STBK *tbl, USI entLen, int op);

src/cuparsex.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/*----------------- cuparse.cpp's "mostly LOCAL" VARIABLES ----------------*/
2121

2222
/*--- CURRENT TOKEN INFO. Set mainly by toke(). Not changed by unToke(). */
23-
extern SI tokTy; // current token type (CUT__ define; cuTok ret val)
23+
extern int tokTy; // current token type (CUT__ define; cuTok ret val)
2424
extern SI prec; // "prec" (precedence) from opTbl[]. PR__ defines.
2525
extern SI nextPrec; // "prec" of ungotten (ie next) token, only valid after expTy()/expr()/unToke().
2626
//extern SI lastPrec; // "prec" of PRIOR token (0 at bof).
@@ -73,8 +73,8 @@ RC FC dropSfs( SI k, SI n);
7373
RC CDEC emiKon( USI ty, void *p, SI inDm, char **pp);
7474
RC FC emit( PSOP op);
7575
RC FC emit2( SI i);
76-
SI FC tokeNot( SI tokTyPar);
77-
SI FC tokeIf( SI tokTyPar);
76+
bool tokeNot( int tokTyPar);
77+
bool tokeIf( int tokTyPar);
7878

7979
// cuprobe.cpp
8080
RC FC probe();

src/pgpak.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,24 @@ LOCAL SI FC pgGenrRc( SI, SI);
4343
LOCAL USI pgcByto( const char **ps, USI *pnMax, const char* cods, SI bsF); // no FC: has check_stack
4444
LOCAL USI FC pgcStrWid( const char *s, USI nMax, SI bsF);
4545

46-
#if 0 // no calls in CSE, 11-91. use pgalloce.
47-
x //========================================================================
48-
x char * FC pgalloc( rows, cols)
49-
x
50-
x // Initialize a page for output, abort on error
51-
x
52-
x SI rows; // Number of rows in page (max value 255)
53-
x SI cols; // Number of columns in page (max value 255)
54-
x
55-
x // Returns pointer to area allocated for page
56-
x{
57-
x char *pp;
58-
x
59-
x pgalloce( rows, cols, &pp, ABT);
60-
x return pp;
61-
x} // pgalloc
62-
#endif
63-
6446
//========================================================================
6547
RC FC pgalloce( // Initialize a page for output with error handling, for pgalloc
6648

67-
SI rows, // Number of rows in page (max value 255)
68-
SI cols, // # of columns (max 254) (note PP->cols is 1 larger 11-91)
49+
int rows, // Number of rows in page (max value 255)
50+
int cols, // # of columns (max 254) (note PP->cols is 1 larger 11-91)
6951
char **ppp, // POINTER TO where to return pointer
7052
int erOp ) // error action: ABT, WRN, etc
7153

7254
// returns RCOK or RCBAD; pointer is returned via argument ONLY if ok.
7355
{
74-
char *pp;
7556

7657
/* Initial allocation includes space for line lengths, enhancement pointer values, and page buffer.
7758
[Space for enhancement flag values is not allocated until needed.] See pgwe() */
7859

60+
char* pp{ nullptr };
7961
if (dmal( DMPP( pp), PGSIZE( rows, cols), erOp | DMZERO) != RCOK) // dmpak.cpp
8062
return RCBAD; // if memory full (and not ABT), return error to caller
63+
8164
// appropriate uses of PP->cols changed to cols-1, or <= changed to <, when this added: many if's below.
8265
pgsetup( pp, rows, cols+1); // store rows, cols, init offset to segments, etc
8366
// cols+1: extra byte per row for \0 at row output, eg in pgprput.cpp, rob 11-91.

0 commit comments

Comments
 (0)