diff --git a/src/CNRECS.DEF b/src/CNRECS.DEF index 4b49f80e7..a786bfeea 100644 --- a/src/CNRECS.DEF +++ b/src/CNRECS.DEF @@ -628,7 +628,7 @@ o *s POWER radDiffSh // .. end subhour instantaneous value, interpolated RECORD PYLINEAR "linear poly sub" *SUBSTRUCT // linear polnomial (mononomial?)(one independent variable) for TOWERPLANT *declare "DBL val(DBL x) { return k[0] + k[1]*x; }" - *declare "RC normalize( record *r, SI fn, char *descrip, DBL x=1.0);" // function in cncult5.cpp + *declare "RC normalize( record *r, SI fn, const char* descrip, DBL x=1.0);" // function in cncult5.cpp *f *ARRAY 3 FLOAT k // FLOAT k[3]. One extra member needed as terminator by cul.cpp array input logic. *END // PYLINEAR @@ -636,7 +636,7 @@ RECORD PYLINEAR "linear poly sub" *SUBSTRUCT // linear polnomial (mononomial?)(o RECORD PYCUBIC "cubic poly sub" *SUBSTRUCT // cubic polnomial (one independent variable) for FAN, COIL, *declare "DBL val(DBL x) { return k[0] + k[1]*x + k[2]*x*x + k[3]*x*x*x; }" - *declare "RC normalize( record *r, SI fn, char *descrip, DBL x=1.0);" // function in cncult5.cpp + *declare "RC normalize( record *r, SI fn, const char* descrip, DBL x=1.0);" // function in cncult5.cpp *f *ARRAY 5 FLOAT k // FLOAT k[5]. One extra member needed as terminator by cul.cpp array input logic, 5-92. /* possible future setup optimizations: 1) select ptr to fcn that does not compute terms whose k is 0; @@ -646,7 +646,7 @@ RECORD PYCUBIC "cubic poly sub" *SUBSTRUCT // cubic polnomial (one independent v RECORD PYCUBIC2 "cubic poly sub" *SUBSTRUCT // cubic polnomial (one independent variable) with x0 for FAN, COIL, *declare "DBL val(DBL x) { x -= k[4]; if (x < 0.) x = 0.; return k[0] + k[1]*x + k[2]*x*x + k[3]*x*x*x; }" - *declare "RC normalize( record *r, SI fn, char *descrip, DBL x=1.0);" // function in cncult5.cpp + *declare "RC normalize( record *r, SI fn, const char *descrip, DBL x=1.0);" // function in cncult5.cpp *f *ARRAY 6 FLOAT k // FLOAT k[6]. [0..3] are coeff, [4] is minimum x, [5] is terminator needed by cul.cpp. *END // PYCUBIC2 @@ -654,7 +654,7 @@ RECORD PYCUBIC2 "cubic poly sub" *SUBSTRUCT // cubic polnomial (one independent RECORD PYBIQUAD "biquadratic ply sub" *SUBSTRUCT // biQuadratic polynomial (two independent variables) *declare "DBL val( DBL x, DBL y) { return k[0] + k[1]*x + k[2]*x*x + k[3]*y + k[4]*y*y + k[5]*x*y; }" - *declare "RC normalize( record *r, SI fn, char *descX, char*descY, DBL x, DBL y, BOO noWarn=FALSE);" // cncult5.cpp + *declare "RC normalize( record *r, SI fn, const char* descX, const char* descY, DBL x, DBL y, BOO noWarn=FALSE);" // cncult5.cpp *declare "RC normalizeCoil( AH *ah, SI fn);" // function in cncult5.cpp *f *ARRAY 7 FLOAT k // FLOAT k[7]. One extra member needed as terminator by cul.cpp array input logic, 5-92. @@ -2854,7 +2854,7 @@ RECORD HEATEXCHANGER "heat exchanger sub" *SUBSTRUCT // Used in DOAS and AIRHAN *prefix hx_ *declare "RC hx_setup( record *r, SI parentFieldNum);" - *declare "void hx_begSubhr(AIRFLOW supInletAF, AIRFLOW exhInletAF, DBL tWant);" // calculates bypass and final outlet air state given setpoint + *declare "RC hx_begSubhr(AIRFLOW supInletAF, AIRFLOW exhInletAF, DBL tWant);" // calculates bypass and final outlet air state given setpoint *declare "void hx_calc();" // calculates hx only, called by begSubhr() *declare "double hx_calcBypass(float bypassFraction);" // returns outlet temperature for a given bypass fraction @@ -4606,7 +4606,7 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater // C_WHTYPECH_STRGSML, _STRGLRG, _INSTSML, _INSTLRG, // _INSTUEF, _BUILTUP *i ANAME wh_desc; // probe-able description text - *declare "virtual const char* GetDescription( int options=0) { options; return wh_desc; }" + *declare "virtual const char* GetDescription( int /*options*/=0) { return wh_desc; }" *r INT wh_fcn; // function of this DHWHEATER per whfcnXXX enum *declare "enum { whfcnUNKNOWN=0, whfcnPRIMARY, whfcnLOOPHEATER, whfcnSUPPLIESCHDHW=0x10, whfcnSUPPLIESLOOP=0x20, whfcnSUPPLIESLOAD=0x40 };" *declare "int wh_SetFunction();" diff --git a/src/RCDEF/rcdef.cpp b/src/RCDEF/rcdef.cpp index dd6d08649..eb72b3f6d 100644 --- a/src/RCDEF/rcdef.cpp +++ b/src/RCDEF/rcdef.cpp @@ -268,7 +268,7 @@ class LUTAB unsigned char* lu_stat; // optional char array of status bytes public: - LUTAB(const char** nmp, int N, unsigned char* stat = nullptr) : lu_nmp(nmp), lu_nent(0), lu_mxent(N), lu_stat(stat) + LUTAB(const char** nmp, int N, unsigned char* stat = nullptr) : lu_nent(0), lu_mxent(N), lu_nmp(nmp), lu_stat(stat) { } int lu_GetCount() const { return lu_nent; } @@ -314,8 +314,8 @@ class LUTAB /*------------ General variables ------------*/ -char * ProgVrsnId = "RCDEF"; /* program version identifying string used in errorlog file header info, erpak2.cpp. - Defined in config.cpp in "real" products. */ +const char* ProgVrsnId = "RCDEF"; // program version identifying string used in errorlog file header info, erpak2.cpp. + // Defined in config.cpp in "real" products. FILE * Fpm; /* current input stream, read by gtoks. Note several files are opened during command line checking; Fpm is set to each in sequence as they are used. */ FILE *Fout; /* current output .hx file stream -- used locally several places. */ @@ -387,7 +387,7 @@ struct FIELDDESC int lmtype; int untype; }; -static FIELDDESC Fdtab[MAXFIELDS] = { 0 }; // field descriptors table +static FIELDDESC Fdtab[MAXFIELDS] = { { 0} }; // field descriptors table // Field name stuff static const char * rcfdnms[MAXFIELDS]; // Table of field name pointers @@ -420,13 +420,16 @@ LOCAL void wRcTd( FILE *f); LOCAL void wSrfd1( FILE *f); LOCAL void wSrfd2( FILE *f); LOCAL void wSrfd3( FILE *f); -LOCAL void wSrfd4( FILE *f); +#if 0 +0 unused +0 LOCAL void wSrfd4( FILE *f); +#endif LOCAL void sumry( void); LOCAL FILE * rcfopen( const char *s, char **argv, int argi); LOCAL int gtoks( const char * ); LOCAL void rcderr( const char *s, ...); LOCAL int update( const char* old, const char* nu); -LOCAL void newsec( char *); +LOCAL void newsec( const char *); LOCAL const char* enquote( const char *s); // Common string buffer @@ -660,19 +663,18 @@ static int determine_size( // size of a data type // returns size (bytes) of decl if known else 0 { static SWTABLE declSize[] = -{ "short", sizeof(short), - "int", sizeof(int), - "unsigned short", sizeof(unsigned short), - "unsigned", sizeof(unsigned), - "long", sizeof(unsigned long), - "unsigned long", sizeof(unsigned long), - "float", sizeof(float), - "double", sizeof(double), - "char", sizeof(char), - "unsigned char", sizeof(unsigned char), - "time_t", sizeof(time_t), - - NULL, 0 +{ { "short", sizeof(short) }, + { "int", sizeof(int) }, + { "unsigned short", sizeof(unsigned short) }, + { "unsigned", sizeof(unsigned) }, + { "long", sizeof(unsigned long) }, + { "unsigned long", sizeof(unsigned long) }, + { "float", sizeof(float) }, + { "double", sizeof(double) }, + { "char", sizeof(char) }, + { "unsigned char", sizeof(unsigned char) }, + { "time_t", sizeof(time_t) }, + { NULL, 0 } }; int sz = 0; if (strchr(decl, '*')) @@ -2273,8 +2275,8 @@ LOCAL void base_fds() // base fields info. MUST BE MAINTAINED TO MATCH BASE CLASS (ancrec.h:record, or as changed). static struct BASEFIELDS { - char* name; - char* fdTyNam; + const char* name; + const char* fdTyNam; int evf; int ff; } baseFields[] = @@ -3291,7 +3293,7 @@ LOCAL int gtoks( // Retrieve tokens from input stream "Fpm" acco printf( "\n gtoks removing leading null from token !? \n"); } #endif - static char* comdelims[2] = { "/*", "*/" }; // Comment delimiters + static const char* comdelims[2] = { "/*", "*/" }; // Comment delimiters oldcommentflag = commentflag; commentflag = !(commentflag ^ (strcmp( token, comdelims[commentflag]) !=0) ); @@ -3397,7 +3399,7 @@ LOCAL void rcderr( const char *s, ...) // Print an error message #endif } // rcderr //====================================================================== -LOCAL void newsec(char *s) // Output heading (s) for new section of run +LOCAL void newsec(const char *s) // Output heading (s) for new section of run { printf("\n%-16s ", s); // no trailing \n. -20s-->-16s 1-31-94. } // newsec diff --git a/src/ancrec.cpp b/src/ancrec.cpp index f4a00a9aa..86dad5444 100644 --- a/src/ancrec.cpp +++ b/src/ancrec.cpp @@ -130,7 +130,7 @@ int record::IsNameMatch( const char* _name) const { // records must already be constructed (can't construct here without knowning b, ss). if (!b || !pSrc) // (or gud? wd error here if init then destroyed) - err( PABT, (char *)MH_X0051); // err msg "record::Copy(): unconstructed destination or !pSrc" + err( PABT, MH_X0051); // err msg "record::Copy(): unconstructed destination or !pSrc" #if defined( _DEBUG) b->validate("Copy() dest"); // abort if records not well anchored pSrc->b->validate("Copy() src"); @@ -154,7 +154,7 @@ int record::IsNameMatch( const char* _name) const else { // partial copy (e.g. ZNI->ZNR) if (pSrc->b->sOff > b->sOff) - err(PABT, (char*)MH_X0052); + err(PABT, MH_X0052); else { memcpy((char*)this + offBeg, (const char*)pSrc + offBeg, pSrc->b->sOff - offBeg); memcpy((char*)this + b->sOff, (const char*)pSrc + pSrc->b->sOff, pSrc->b->nFlds); @@ -261,7 +261,7 @@ const char* record::objIdTx( { // verify basAnc record ptr if (r->b->rt != r->rt/* || r->ss <= 0*/) // part commented out 1-21-92 rejects Top. - err( PWRN, (char *)MH_S0273); // display internal error msg + err( PWRN, MH_S0273); // display internal error msg // "*** objIdTx(); probable non-RAT record ptr ***" s = scWrapIf( s, // concat string so far (s) w strtcat( tween, r->classObjTx( op), NULL), // class and object name text, @@ -291,10 +291,10 @@ const char* record::classObjTx( // get class name - object name text // verify basAnc record arg (C compiler doesn't as void used for varying types) if (b->rt != rt) - err( PWRN, (char *)MH_S0274); // display internal error msg + err( PWRN, MH_S0274); // display internal error msg // "*** classObjTx(); probable non-RAT record arg ***" - const char* what = (char *)b->what; // class name from basAnc + const char* what = b->what; // class name from basAnc // if it has a name ... if (!name.IsBlank()) // if this record has nonblank name @@ -336,8 +336,8 @@ RC record::CkSet( // verify that required member has been set // Unexpected, but issue msg here to prevent mysterious messageless non-runs. // Devel aid. Might occur, for example, if RQD flag removed on member and // code that calls here not updated to match (defaults do not set FsSET). - return oer( (char *)MH_S0493, // "Required member '%s' has not been set,\n" - // " and apparently no message about it appeared above" + return oer( MH_S0493, // "Required member '%s' has not been set,\n" + // " and apparently no message about it appeared above" MNAME(b->fir + fn) ); // macro (srd.h) accesses mName, possibly in special segment } // record::CkSet //----------------------------------------------------------------------------- @@ -443,34 +443,22 @@ RC record::limitCheckRatio( // check the ratio of two fields /////////////////////////////////////////////////////////////////////////////// // 'record' MEMBER FUNCTIONS TO REQUIRE/DISALLOW FIELDS (class declaration: ancrec.h) /////////////////////////////////////////////////////////////////////////////// -static void WhenSave(const char*& when, char* whenBuf, size_t whenBufSize) -// optionally make stack copy of possible Tmpstr -{ - if (!msgIsHan(when)) // not if handle given - if (when) // copy arg to local buffer in case in Tmpstr[], ... - when = strncpy0(whenBuf, when, whenBufSize); // so any (possible future) strtprintf's in following loop - // won't overwrite it -} // WhenSave -//----------------------------------------------------------------------------- RC record::ValidateFN(int fn, const char* caller) const { RC rc = RCOK; if (fn < 0 || fn > 1024) - rc |= oer((char*)MH_S0495, // "%s Internal error: field # %nd: unterminated arg list?" + rc |= oer( MH_S0495, // "%s Internal error: field # %nd: unterminated arg list?" caller, fn); return rc; } // record::ValidateFN //----------------------------------------------------------------------------- RC record::checkN( // general purpose check multiple fields - const char* when, // message insert. message handle ok (see messages.cpp). - RC(record::* checkFcn)(const char* when, int fn), // check function called for each field + MSGORHANDLE when, // message insert. message handle ok (see messages.cpp). + RC(record::* checkFcn)(MSGORHANDLE when, int fn), // check function called for each field va_list ap) // int field numbers, 0 ends list REMEMBER THE 0! { RC rc = RCOK; - char whenBuf[1000]; - WhenSave(when, whenBuf, sizeof( whenBuf)); - for (; ; ) { int fn = va_arg(ap, int); @@ -482,23 +470,20 @@ RC record::checkN( // general purpose check multiple fields } // record::checkN //----------------------------------------------------------------------------- RC record::checkN( // general purpose check multiple fields - const char* when, // message insert. message handle ok (see messages.cpp). - RC(record::* checkFcn)(const char* when, int fn), // check function called for each field + MSGORHANDLE when, // message insert. message handle ok (see messages.cpp). + RC(record::* checkFcn)(MSGORHANDLE when, int fn), // check function called for each field const int16_t* fnList) // array of field numbers, 0 ends list REMEMBER THE 0! { RC rc = RCOK; - char whenBuf[1000]; - WhenSave(when, whenBuf, sizeof(whenBuf)); - int fn = 0; - for (int iFn = 0; fn = fnList[iFn]; iFn++) + for (int iFn = 0; (fn = fnList[iFn]); iFn++) rc |= (this->*checkFcn)(when, fn); return rc; } // record::checkN //----------------------------------------------------------------------------- RC record::disallowN( // issue "not allowed" message for each given field in 0-terminated list of field numbers - const char* when, // NULL or message insert. message handle ok (see messages.cpp). + MSGORHANDLE when, // message insert. message handle ok (see messages.cpp). ...) // int field numbers, 0 ends list REMEMBER THE 0! { va_list ap; @@ -508,7 +493,7 @@ RC record::disallowN( // issue "not allowed" message for each given field in } // record::disallowN //----------------------------------------------------------------------------- RC record::disallow( // issue "not allowed" message for each given field in an array of field numbers - const char* when, // NULL or message insert. message handle ok (see messages.cpp). + MSGORHANDLE when, // message insert. message handle ok (see messages.cpp). const int16_t* fnList) // array of field numbers, 0 ends list REMEMBER THE 0 { RC rc = checkN(when, &record::disallow, fnList); @@ -516,7 +501,7 @@ RC record::disallow( // issue "not allowed" message for each given field in an } // record::disallow //----------------------------------------------------------------------------- RC record::disallow( // issue "not allowed" message if field is given - const char* when, // NULL or message insert, worded for work context "Can't give ", handle ok + MSGORHANDLE when, // message insert, worded for work context "Can't give ", handle ok int fn) { RC rc = ValidateFN(fn, "disallow"); @@ -526,7 +511,7 @@ RC record::disallow( // issue "not allowed" message if field is given } // record::disallow //----------------------------------------------------------------------------- RC record::requireN( // issue "missing" message for each omitted field in 0-terminated list of field numbers - const char* when, // NULL or message insert (message handle ok) + MSGORHANDLE when, // message insert (message handle ok) ...) // int field numbers, 0 ends list REMEMBER THE 0! { va_list ap; @@ -536,7 +521,7 @@ RC record::requireN( // issue "missing" message for each omitted field in 0-t } // record::requireN //----------------------------------------------------------------------------- RC record::require( // issue "missing" message for each given field in an array of field numbers - const char* when, // NULL or message insert. message handle ok (see messages.cpp). + MSGORHANDLE when, // message insert. message handle ok (see messages.cpp). const int16_t* fnList) // array of field numbers, 0 ends list REMEMBER THE 0 { RC rc = checkN(when, &record::disallow, fnList); @@ -544,7 +529,7 @@ RC record::require( // issue "missing" message for each given field in an arra } // record::require //----------------------------------------------------------------------------- RC record::require( // issue message if field is not given - const char* when, // NULL or message insert (msghan ok) + MSGORHANDLE when, // message insert (msghan ok) int fn) // field number { RC rc = ValidateFN(fn, "require"); @@ -554,7 +539,7 @@ RC record::require( // issue message if field is not given } // record::require //------------------------------------------------------------------------------- RC record::ignoreN( // issue "ignored" message for each given field in 0-terminated list of field numbers - const char* when, // NULL or message insert. message handle ok (see messages.cpp). + MSGORHANDLE when, // message insert. message handle ok (see messages.cpp). ...) // int field numbers, 0 ends list REMEMBER THE 0! { va_list ap; @@ -564,7 +549,7 @@ RC record::ignoreN( // issue "ignored" message for each given field in 0-termi } // record::ignoreN //----------------------------------------------------------------------------- RC record::ignore( // issue "ignored" message for each given in an array of field numbers - const char* when, // NULL or message insert. message handle ok (see messages.cpp). + MSGORHANDLE when, // message insert. message handle ok (see messages.cpp). const int16_t* fnList) // array of field numbers, 0 ends list REMEMBER THE 0 { RC rc = checkN(when, &record::ignore, fnList); @@ -572,7 +557,7 @@ RC record::ignore( // issue "ignored" message for each given in an array of fi } // record::ignore //----------------------------------------------------------------------------- RC record::ignore( // issue "ignored" message if field is given - const char* when, // NULL or message insert, worded for work context + MSGORHANDLE when, // message insert, worded for work context int fn) { RC rc = ValidateFN(fn, "ignore"); @@ -586,7 +571,7 @@ RC record::ignore( // issue "ignored" message if field is given * 'record' MEMBER FUNCTIONS TO MAKE CHANGE FLAG ENTRIES IN RUNTIME TABLES (class declaration: ancrec.h) ****************************************************************************************************************************/ void CDEC record::chafSelf( // say increment change flag IN SAME RECORD on change in list of fields of record - SI chafFn, // field NUMBER of change flag: an SI field in same record + int chafFn, // field NUMBER of change flag: an SI field in same record ...) // 0-terminated list of field numbers in record to monitor for change if contain expressions { va_list ap; @@ -596,8 +581,8 @@ void CDEC record::chafSelf( // say increment change flag IN SAME RECORD on cha //============================================================================================================================ void CDEC record::chafN( // say increment specified flag during run on change in list of fields in curr record - BP _b, TI i, USI off, // location of SI change flag: anchor, record subscript, offset in record - ...) // 0-terminated list of field numbers + BP _b, TI i, int off, // location of SI change flag: anchor, record subscript, offset in record + ...) // 0-terminated list of field numbers /* for each given field which contains an expression handle, make expression manager runtime table entry to increment flag at b-i-off when value of that expression changes. */ @@ -609,8 +594,8 @@ void CDEC record::chafN( // say increment specified flag during run on change //=========================================================================== void record::chafNV( // say increment specified flag during run on change in var list of fields in curr record - BP _b, TI i, USI off, // location of SI change flag: anchor, record subscript, offset in record - va_list ap) // pointer to 0-terminated list of field numbers + BP _b, TI i, int off, // location of SI change flag: anchor, record subscript, offset in record + va_list ap) // pointer to 0-terminated list of field numbers // var arg list level for flexibility { @@ -620,7 +605,7 @@ void record::chafNV( // say increment specified flag during run on change in v if (!fn) break; if (fn > 1024) - oer((char*)MH_S0495, // "cncult2.cpp:%s Internal error: field # %d: probable unterminated arg list" + oer( MH_S0495, // "cncult2.cpp:%s Internal error: field # %d: probable unterminated arg list" "chavNV", fn); addChafIf((NANDAT*)field(fn), _b->ancN, i, off); /* test pointed to field contents, add increment-on-change table entry if is expr handle. exman.cpp. */ @@ -634,36 +619,35 @@ void record::chafNV( // say increment specified flag during run on change in v //----------------------------------------------------------------------------- RC record::cantGiveEr( // issue message (using ooer) for disallowed field that user gave int fn, - const char* when /*=NULL*/) // NULL or message insert, worded for work context "Can't give " + MSGORHANDLE when) // message insert, worded for work context "Can't give " { return ooer(fn, // message for record & field if 1st error for field, & flag bad. - (char*)MH_S0496, // "Can't give '%s' %s" + MH_S0496, // "Can't give '%s' %s" mbrIdTx(fn), // input name (id) - when ? strtprintf(when) : ""); // user's explanatory insert, eg "when no local heat". + when.mh_IsSet() ? strtprintf(when) : ""); // user's explanatory insert, eg "when no local heat". // use strtprintf to retrieve text (to Tmpstr) if handle given. } // cantGiveEr //----------------------------------------------------------------------------- RC record::notGivenEr( // issue message (using ooer) for disallowed field that user gave int fn, - const char* when /*=NULL*/) // NULL or message insert, worded for work context " missing: required " + MSGORHANDLE when) // message insert, worded for work context " missing: required " { - if (when) + if (when.mh_IsSet()) return ooer(fn, // message if 1st error for record & field, & flag field bad - (char*)MH_S0497, // handle of message "'%s' missing: required %s" + MH_S0497, // handle of message "'%s' missing: required %s" mbrIdTx(fn), // input name (id) strtprintf(when)); // user's explanatory insert, eg "when tuTLh given" - // use strtprintf to retrieve text (to Tmpstr) if handle given. - return ooer(fn, (char*)MH_S0498, // "'%s' missing" + return ooer(fn, MH_S0498, // "'%s' missing" mbrIdTx(fn)); } // record::notGivenEr //----------------------------------------------------------------------------- RC record::ignoreInfo( // issue info message for ignored field int fn, - const char* when /*=NULL*/) // NULL or message insert - // worded for context " is ignored " + MSGORHANDLE when) // message insert + // worded for context " is ignored " { const char* msg = strtprintf( - when ? "'%s' is ignored %s" : "ignoring '%s'", + when.mh_IsSet() ? "'%s' is ignored %s" : "ignoring '%s'", mbrIdTx(fn), strtprintf(when)); // when might be handle return oerI(1, 1, 2, msg, NULL); // do msg using vbl arg list flavor of oer @@ -671,7 +655,7 @@ RC record::ignoreInfo( // issue info message for ignored field //----------------------------------------------------------------------------- RC record::notGzEr(int fn) // issue error message for field not greater than 0. finds user name in CULTs. { - return ooer(fn, (char*)MH_S0499, mbrIdTx(fn)); // "'%s' must be > 0" + return ooer(fn, MH_S0499, mbrIdTx(fn)); // "'%s' must be > 0" } //----------------------------------------------------------------------------- RC record::AtMost( // check for interacting input @@ -688,11 +672,8 @@ RC record::AtMost( // check for interacting input va_list ap; va_start(ap, fn); int setCount = 0; // # of IsSet() fields - int fnCount; // # of fields - for (fnCount = 0; ; ++fnCount) + while (fn) { - if (!fn) - break; if (IsSet(fn)) ++setCount; fnIdList.push_back(mbrIdTx(fn)); @@ -775,7 +756,7 @@ basAnc::basAnc() // default c'tor (for derived copy c'tor memset( (char *)this+SZVFTP, 0, sizeof(*this)-SZVFTP); // SZVFTP: virtFcnTblPtr: cnglob.h. } // basAnc::basAnc //--------------------------------------------------------------------------------------------------------------------------- -basAnc::basAnc( int flags, SFIR * _fir, USI _nFlds, char * _what, USI _eSz, RCT _rt, USI _sOff, const CULT* pCULT, int dontRegister/*=0*/ ) +basAnc::basAnc( int flags, SFIR * _fir, USI _nFlds, const char * _what, USI _eSz, RCT _rt, USI _sOff, const CULT* pCULT, int dontRegister/*=0*/ ) { memset( (char *)this+SZVFTP, 0, sizeof(basAnc)-SZVFTP); // zero all basAnc members but virtFcnTblPtr at front ba_flags = flags; @@ -863,16 +844,15 @@ void basAnc::desRecs( SI _mn, SI _n) void FC cleanBasAncs( // destroy/free all basAnc records, and delete subsidiary "types" basAncs (.tyB) [[maybe_unused]] CLEANCASE cs) // what is being cleaned { - if (ancs) // skip if heap array not allocated - for (USI i = 1; i < Nanc; i++) // loop over basAnc ptrs in ancs - { - BP b = ancs[i]; // fetch ptr - if (!b) - continue; // skip (unexpected) NULL pointer - b->free(); // destroy b's records, free record memory unless static, clear flags - delete b->tyB; - b->tyB = NULL; - } + for (USI i = 1; i < Nanc; i++) // loop over basAnc ptrs in ancs + { + BP b = ancs[i]; // fetch ptr + if (!b) + continue; // skip (unexpected) NULL pointer + b->free(); // destroy b's records, free record memory unless static, clear flags + delete b->tyB; + b->tyB = NULL; + } // if (cs == DONE || cs == CRASH) // { // nothing to do @@ -899,7 +879,7 @@ RC FC basAnc::al( // destroy any existing records and allocate space for n // use explicitly to alloc n spaces at once when n known, for speed & non-fragmentation. { if (_ownB) - ownB = _ownB; + ownB = _ownB; desRecs(); // destroy any existing records in place (without freeing storage block) return reAl( _n, erOp); // (re)allocate to size _n, using existing block if possible. } // basAnc::al @@ -1054,9 +1034,9 @@ void basAnc::statSetup( // init anchor with given non-expandable static record //--------------------------------------------------------------------------------------------------------------------------- BP FC basAnc::anc4n( USI an, int erOp/*=ABT*/) // access anc for anchor number { - if (an < 1 || an > Nanc || !ancs || ancs[an]==0) + if (an < 1 || an > Nanc || ancs[an]==0) { - err( erOp, (char *)MH_X0053, an); // "anc4n: bad or unassigned record anchor number %d" + err( erOp, MH_X0053, an); // "anc4n: bad or unassigned record anchor number %d" return 0; } return ancs[an]; @@ -1078,7 +1058,7 @@ RC FC basAnc::findAnchorByNm( char *_what, BP * _b) // find anchor by name (.wha BP b; size_t an = 0; while (ancNext( an, &b)) // iterate anchors - if (!_stricmp( _what, (char *)b->what)) // if name matches + if (!_stricmp( _what, b->what)) // if name matches { if (_b) *_b = b; return RCOK; // NULL _b may be given to just test for validity of anchor name @@ -1112,15 +1092,15 @@ RC basAnc::validate( // validate an anchor: check self-consistency of anchor and erOp |= PROGERR; // any errors here are internal errors (cnglob.h) if (!this) // test for NULL this - return err( erOp, (char *)MH_X0054, fcnName); // "%s() called for NULL object pointer 'this'". + return err( erOp, MH_X0054, fcnName); // "%s() called for NULL object pointer 'this'". - if (p && (p->rt != rt // check self-consistency: if bk alloc'd & rt does not match - || p->b != this) // or bk 0 doesn't point back at base - || !(rt & RTBRAT) ) // or base rt not a RAT rt - return err( erOp, (char *)MH_X0055, fcnName); // errMsg "%s() argument not a valid anchor" & abort or return per erOp. rmkerr.cpp. + if ((p && (p->rt != rt // check self-consistency: if bk alloc'd & rt does not match + || p->b != this)) // or bk 0 doesn't point back at base + || !(rt & RTBRAT) ) // or base rt not a RAT rt + return err( erOp, MH_X0055, fcnName); // errMsg "%s() argument not a valid anchor" & abort or return per erOp. rmkerr.cpp. if (noStat && (ba_flags & RFSTAT) ) // check staticness - return err( erOp, (char *)MH_X0056, fcnName); // "%s(): illegal use of static-storage anchor" + return err( erOp, MH_X0056, fcnName); // "%s(): illegal use of static-storage anchor" return RCOK; // if here, all OK } // basAnc::validate @@ -1132,7 +1112,7 @@ RC basAnc::findRecByNm1( // find record by 1st match on name, RCOK if found, no record **_r ) // NULL or receives entry ptr if found { if (!this) // test for 0 'this' pointer - return RCBAD; // return NOT FOUND if called for NULL anc pointer (ocurs re types if .tyB 0) + return RCBAD; // return NOT FOUND if called for NULL anc pointer (occurs re types if .tyB 0) record *r; RLUPTHIS(r) // loop over records, setting r to point to each good one if (r->IsNameMatch( _name)) // if matches (disregarding unexpected excess chars 11-94) @@ -1154,11 +1134,12 @@ RC basAnc::findRecByNmU( // find record by unique name match. RCBAD not found record *r, *r1 = nullptr; int nHits = 0; RLUPTHIS(r) // loop over records, setting r to point to each good one - { if (r->IsNameMatch( _name)) // if matches - if (nHits++) + { if (r->IsNameMatch(_name)) // if matches + { if (nHits++) return RCBAD2; // if seen before, bad (ambigous) return else r1 = r; // else save record addr, continue search to be sure unique + } } if (!nHits) @@ -1178,7 +1159,7 @@ RC basAnc::findRecByNmO( // find record by name and owner subscript (first mat record **_r ) // NULL or receives entry ptr if found { if (!this) - return RCBAD; // return NOT FOUND if called for NULL anc pointer (occurs re types if .tyB 0) + return RCBAD; // return NOT FOUND if called for NULL anc pointer (occurs re types if .tyB 0) // add isOwnable check if it is possible for anchor to be non-ownAble, 2-92. record *r; @@ -1210,7 +1191,7 @@ RC basAnc::findRecByNmDefO( // find record by name, and owner if ambiguous { // add isOwnable check if it is possible for anchor to be non-ownAble, 2-92. if (_r1) *_r1 = NULL; // init to "not found" as opposed to "ambiguous" - if (!this) return RCBAD; // return NOT FOUND if called for NULL anc pointer (ocurs re types if .tyB 0) + if (!this) return RCBAD; // return NOT FOUND if called for NULL anc pointer (ocurs re types if .tyB 0) SI oSeen=0, nHits=0; // no name matches found yet record *r, *r1=NULL, *r2=NULL; RLUPTHIS(r) // loop over records, setting r to point to each good one diff --git a/src/ancrec.h b/src/ancrec.h index 69b82f482..c870bba0a 100644 --- a/src/ancrec.h +++ b/src/ancrec.h @@ -51,8 +51,8 @@ typedef basAnc* BP; // basAnc pointer -- formerly used to localize NEARness //*************************************************************************************************************************** // class basAnc: base class for application record anchors. //*************************************************************************************************************************** -#define RTBRAT 0x2000 /* Old (1992) "Record Array Table" record type bit, now always on here, used in validity checks. - also defined in srd.h, MUST MATCH!. */ +#define RTBRAT 0x2000 // Old (1992) "Record Array Table" record type bit, now always on here, used in validity checks. + // also defined in srd.h, MUST MATCH! //--- bits for basAnc.flags #define RFSTAT 0x4000 // "static" record basAnc: not reallocable, min subscr 0 not 1. set ancrec.cpp, tested ancrec,cul,cuprobe.cpp. #define RFTYS 0x1000 // is in TYPES sub-basAnc (pted to by a basAnc.tys) @@ -86,7 +86,7 @@ class basAnc // base class for record anchors: basAnc const CULT* an_pCULT; // NULL or associated CULT input table for records of this type // simplifies back translation of input names basAnc(); - basAnc( int flags, SFIR * fir, USI nFlds, char * what, USI eSz, RCT rt, USI sOff, const CULT* pCult, int dontRegister=0 ); + basAnc( int flags, SFIR * fir, USI nFlds, const char * what, USI eSz, RCT rt, USI sOff, const CULT* pCult, int dontRegister=0 ); void FC regis(); virtual ~basAnc(); // destroyed in deriv classes, to use vf virtual record* ptr() = 0; // access block ptr (in drv class: typed) @@ -244,36 +244,36 @@ class record // base class for records // input-checking support functions RC ValidateFN(int fn, const char* caller) const; // require/disallow/ignore fields - RC checkN(const char* when, RC(record::* checkFcn)(const char* when, int fn), va_list ap); - RC checkN(const char* when, RC(record::* checkFcn)(const char* when, int fn), const int16_t* fnList); - RC disallowN( const char* when, ...); - RC disallow(int fn) { return disallow(NULL, fn); } - RC disallow(const char* when, int fn); - RC disallow(const char* when, const int16_t* fnList); + RC checkN(MSGORHANDLE when, RC(record::* checkFcn)(MSGORHANDLE when, int fn), va_list ap); + RC checkN(MSGORHANDLE when, RC(record::* checkFcn)(MSGORHANDLE when, int fn), const int16_t* fnList); + RC disallowN( MSGORHANDLE when, ...); + RC disallow(int fn) { return disallow( MSGORHANDLE(), fn); } + RC disallow(MSGORHANDLE when, int fn); + RC disallow(MSGORHANDLE when, const int16_t* fnList); template - RC disallowX(const char* when, Args... args) { return (disallow(when, args) | ...); } - RC requireN( const char* when, ...); - RC require(int fn) { return require(NULL, fn); } - RC require( const char* when, int fn); - RC require( const char* when, const int16_t* fnList); + RC disallowX(MSGORHANDLE when, Args... args) { return (disallow(when, args) | ...); } + RC requireN( MSGORHANDLE when, ...); + RC require(int fn) { return require(MSGORHANDLE(), fn); } + RC require( MSGORHANDLE when, int fn); + RC require( MSGORHANDLE when, const int16_t* fnList); template - RC requireX(const char* when, Args... args) { return (require(when, args) | ...); } - RC ignoreN( const char* when, ...); - RC ignore(int fn) { return ignore(NULL, fn); } - RC ignore( const char* when, int fn); - RC ignore( const char* when, const int16_t* fnList); + RC requireX(MSGORHANDLE when, Args... args) { return (require(when, args) | ...); } + RC ignoreN( MSGORHANDLE when, ...); + RC ignore(int fn) { return ignore(MSGORHANDLE(), fn); } + RC ignore( MSGORHANDLE when, int fn); + RC ignore( MSGORHANDLE when, const int16_t* fnList); template - RC ignoreX(const char* when, Args... args) { return (ignore(when, args) | ...); } + RC ignoreX(MSGORHANDLE when, Args... args) { return (ignore(when, args) | ...); } // specific error messages - RC cantGiveEr( int fn, const char* when=NULL); - RC notGivenEr( int fn, const char* when=NULL); - RC ignoreInfo( int fn, const char* when=NULL); + RC cantGiveEr( int fn, MSGORHANDLE when); + RC notGivenEr( int fn, MSGORHANDLE when); + RC ignoreInfo( int fn, MSGORHANDLE when); RC FC notGzEr( int fn); // change propogation support functions in cncult2.cpp - void CDEC chafSelf( SI chafFn, ...); - void CDEC chafN( BP _b, TI i, USI off, ...); - void chafNV( BP _b, TI i, USI off, va_list ap); + void CDEC chafSelf( int chafFn, ...); + void CDEC chafN( BP _b, TI i, int off, ...); + void chafNV( BP _b, TI i, int off, va_list ap); RC AtMost(int setMax, int fn, ...); RC CheckArray(int fn, int nSetExpected); @@ -282,20 +282,20 @@ class record // base class for records RC limitCheckFix(int fn, float vMin, float vMax, int erOp = ERR); RC limitCheckRatio(int fn1, int fn2, double vMin, double vMax); - RC CDEC ooer( int fn, const char* message, ... ); - RC CDEC ooerV( int fn, const char* message, va_list ap); - RC CDEC ooer( int fn1, int fn2, const char* message, ... ); - RC CDEC ooerV( int fn1, int fn2, const char* message, va_list ap); - RC CDEC oer( const char* message, ... ) const; - RC CDEC oWarn( const char* message, ... ) const; - RC CDEC oInfo( const char* message, ... ) const; - RC CDEC orer(const char* message, ...) const; - RC CDEC orWarn(const char* message, ...) const; - RC CDEC orInfo(const char* message, ...) const; + RC CDEC ooer( int fn, MSGORHANDLE message, ... ); + RC CDEC ooerV( int fn, MSGORHANDLE message, va_list ap); + RC CDEC ooer2( int fn1, int fn2, MSGORHANDLE message, ... ); + RC CDEC ooer2V( int fn1, int fn2, MSGORHANDLE message, va_list ap); + RC CDEC oer( MSGORHANDLE message, ... ) const; + RC CDEC oWarn( MSGORHANDLE message, ... ) const; + RC CDEC oInfo( MSGORHANDLE message, ... ) const; + RC CDEC orer( MSGORHANDLE message, ...) const; + RC CDEC orWarn(MSGORHANDLE message, ...) const; + RC CDEC orInfo(MSGORHANDLE message, ...) const; - RC orMsg( int erOp, const char* message, ...) const; + RC orMsg( int erOp, MSGORHANDLE message, ...) const; - RC oerI( int shoTx, int shoFnLn, int isWarn, const char* fmt, va_list ap) const; + RC oerI( int shoTx, int shoFnLn, int isWarn, MSGORHANDLE fmt, va_list ap) const; record* getOwner() const; const char* whatIn() const; @@ -307,7 +307,7 @@ class record // base class for records record *ownRec=NULL, record **pp=NULL, RC *prc=NULL ); // self-check - virtual RC Validate( int options=0) { options; return RCOK; } + virtual RC Validate( int /*options*/ = 0) { return RCOK; } }; // class record @@ -318,7 +318,7 @@ class record // base class for records template class anc : public basAnc { public: - anc( char *what, SFIR *sFir, USI nFlds, RCT rt, CULT* pCULT=nullptr) // cpp'tor used for static instances + anc( const char *what, SFIR *sFir, USI nFlds, RCT rt, CULT* pCULT=nullptr) // cpp'tor used for static instances : basAnc( 0, sFir, nFlds, what, sizeof(T), rt, offsetof( T, sstat), pCULT) { p = 0; } anc( const BP src, int flags, char *_what, // like-another constructor, diff --git a/src/ashwat.cpp b/src/ashwat.cpp index 9f549f0df..b5bc9a322 100644 --- a/src/ashwat.cpp +++ b/src/ashwat.cpp @@ -83,7 +83,7 @@ static const double SIG = 5.6704E-8; // Stephan-Boltzman constant (W/m2-K4) // http://physics.nist.gov/cuu/Constants/index.html static const double R_UNIV=8.314472; // Universal gas constant (J/mol-K) static const double PATM = 101325.; // Atmospheric pressure (Pa) -static const double HOC_ASHRAE = 16.9; // nominal ASHRAE exterior convective +[[maybe_unused]] static const double HOC_ASHRAE = 16.9; // nominal ASHRAE exterior convective // coefficient, W/m2-K // 7.5 mph cooling conditions @@ -128,9 +128,9 @@ template< typename T> inline static T RadPwr(T t, T eps) // radiant emitted powe //----------------------------------------------------------------------------- template< typename T> static int vNEQ( // compare, 0 iff "equal" T v1, T v2, // values - T tol=0, // fractional diff + T tol, // fractional diff // if 0, require exact equality - T eps=1.e-10) // absolute diff + T eps=T(1.e-10)) // absolute diff // returns 0 iff v1 "equals" v2 { if (tol==0) return v1!=v2; // 0 iff exactly equal @@ -328,8 +328,7 @@ static bool MessageV( if (pMsgCallBackFunc) (*pMsgCallBackFunc)( awMsgContext, msgTy, msg); // transmit message to caller else - { printf( msg.c_str()); // no message callback defined, use printf - printf("\n"); + { printf( "%s\n", msg.c_str()); // no message callback defined, use printf } return msgTy >= msgWRN; // TODO } // ::MessageV @@ -1445,7 +1444,7 @@ bool CFSTY::cf_Thermal( // layer temps / heat fluxes A.Solve( XSOL); // calculate Q_conv and Q_rad - double Q_CONVdv = HC2D(0,NL+1)*(TOUTdv-TINdv); + [[maybe_unused]] double Q_CONVdv = HC2D(0,NL+1)*(TOUTdv-TINdv); double Q_RADdv = HR2D(0,NL+1)*(TRMOUTdv-TRMINdv); for (I=1; I<=NL; I++) @@ -3043,7 +3042,7 @@ static void PD_BEAM_CASE_II( // pleated drape 14 surface flat-fabric model, cas // shape factors double F12, F13, F15, F16, F21, F25, F26, F31, F35, F36, F41, F42, F43, F45, F46; - double F51, F52, F53, F54, F61, F62, F63; + double F51, F52, F53, F61, F62, F63; double F78, F79, F710, F711, F712, F810, F811, F812, F910, F911; double F912, F108, F109, F1011, F1012, F118, F119, F1110, F128, F129, F1210; F12 = (S+GN-AN)/(2.0*S); @@ -3064,7 +3063,7 @@ static void PD_BEAM_CASE_II( // pleated drape 14 surface flat-fabric model, cas F51 = (W+BG-(AB+CG))/(2.0*BC); F52 = (S+CG-(BG+CN))/(2.0*BC); F53 = (BK+CN-2.0*S)/(2.0*BC); - F54 = (S+BC-BK)/(2.0*BC); + // F54 = (S+BC-BK)/(2.0*BC); // unused F61 = (S+AB-BG)/(2.0*AB); F62 = (AN+BG-2.0*S)/(2.0*AB); F63 = (S+AK-(AN+BK))/(2.0*AB); @@ -3285,7 +3284,7 @@ static void PD_BEAM_CASE_III( // pleated drape 14 surface flat-fabric model, ca // shape factors double F12, F13, F15, F16, F21, F25, F26, F31, F35, F36, F41, F42, F43, F45, F46; - double F51, F52, F53, F54, F61, F62, F63; + double F51, F52, F53, F61, F62, F63; double F78, F79, F710, F711, F712, F810, F811, F812, F910, F911, F912; double F108, F109, F1011, F1012, F118, F119, F1110, F128, F129, F1210; @@ -3307,7 +3306,7 @@ static void PD_BEAM_CASE_III( // pleated drape 14 surface flat-fabric model, ca F51 = (W+BG-(AB+CG))/(2.0*BC); F52 = (S+CG-(BG+CN))/(2.0*BC); F53 = (BK+CN-2.0*S)/(2.0*BC); - F54 = (S+BC-BK)/(2.0*BC); + // F54 = (S+BC-BK)/(2.0*BC); // unused F61 = (S+AB-BG)/(2.0*AB); F62 = (AN+BG-2.0*S)/(2.0*AB); F63 = (S+AK-(AN+BK))/(2.0*AB); @@ -4011,7 +4010,7 @@ bool CFSLAYER::cl_PDSWP( // Drape SW diffuse properties from fabric / geometry // = wall-solar azimuth angle { #if defined( _DEBUG) -static int caseCount[ 7] = { 0}; +[[maybe_unused]] static int caseCount[ 7] = { 0}; #endif if (LTYPE != ltyDRAPE) return false; @@ -4736,13 +4735,13 @@ CFSLAYER::CFSLAYER( // layer c'tor //----------------------------------------------------------------------------- CFSLAYER::CFSLAYER( // special glazing layer c'tor (Windows 6 arg order) const char* id, // ID (name) of layer - float thk, // thickness, in (unused) + [[maybe_unused]] float thk, // thickness, in (unused) float tSol, float rSol1, float rSol2, // solar properties - float tVis, float rVis1, float rVis2, // visible properties (unused) + [[maybe_unused]] float tVis, [[maybe_unused]] float rVis1, + [[maybe_unused]] float rVis2, // visible properties (unused) float tIR, float eIR1, float eIR2, // LW properties - float kEff) // conductivity + [[maybe_unused]] float kEff) // conductivity { - thk, tVis, rVis1, rVis2, kEff; cl_InitGlaze( id, tSol, rSol1, eIR1, rSol2, eIR2, tIR); } // CFSLAYER::CFSLAYER //----------------------------------------------------------------------------- @@ -5366,8 +5365,8 @@ int CFSLWP::clw_IsNEQ( // compare long wave properties const CFSLWP& lwp, // compare lwp to *this double tol /*=0.*/, // relative tolerance // 0=require exact equality - int options/*=0*/, // options (unused) - [[maybe_unused]] const char* w1/*="?"*/, // context for msgs + [[maybe_unused]] int options/*=0*/, // options (unused) + [[maybe_unused]] const char* w1/*="?"*/, // context for msgs [[maybe_unused]] const char* w2/*="?"*/) const { #if defined( _DEBUG) @@ -5378,7 +5377,6 @@ int errCount=0; // non-debug: use early out #define XC( m) vNEQ( m, lwp.m, tol) #endif - options; int ret = XC( EPSLF) _X_ XC( EPSLB) _X_ XC( TAUL); return ret; #undef XC diff --git a/src/ashwface.cpp b/src/ashwface.cpp index c9fb5cd20..2aa5ed9f1 100644 --- a/src/ashwface.cpp +++ b/src/ashwface.cpp @@ -15,11 +15,6 @@ #include "ashwface.h" -// ASHWAT constants -// WHY: use fixed size arrays to avoid FORTRAN array descriptors -const int MSGMAXLEN = 100; -const int MSGMAXCOUNT = 20; - static const CFSSWP swpBlack; // black room (c'tor leaves all values 0) /////////////////////////////////////////////////////////////////////////////// @@ -390,11 +385,11 @@ RC FENAW::fa_InsertLayer( RC rc = RCOK; int nL = fa_NL(); if (nL == CFSMAXNL) - { rc = err( "ASHWAT '%s': cannot add shading layer (max # of layers is %d)", + { rc = err( ERR, "ASHWAT '%s': cannot add shading layer (max # of layers is %d)", fa_Name(), CFSMAXNL); } else if (iLIns < 0 || iLIns > nL) - { rc = err( "ASHWAT '%s': invalid layer insert (NL=%d, iLIns=%d)", + { rc = err( ERR, "ASHWAT '%s': invalid layer insert (NL=%d, iLIns=%d)", fa_Name(), nL, iLIns); } else @@ -540,7 +535,6 @@ RC FENAW::fa_Subhr( // subhr calcs for single time step int bDoFrm) // nz = do frame calcs { -const double tol = .001; #if !defined( ASHWAT_USECPP) if (!ASHWAT.xw_pAWThermal) diff --git a/src/battery.cpp b/src/battery.cpp index a82ebe9b7..9a5c1b536 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -88,7 +88,7 @@ RC BATTERY::bt_DoHour( { if (!Wthr.d.wd_HasTdvData()) { - rer(ABT, "BATTERY '%s': No TDV values available for bt_ControlAlg=TDVPeakSave.\n" + rerErOp(ABT, "BATTERY '%s': No TDV values available for bt_ControlAlg=TDVPeakSave.\n" " Use Top.tdvFName to specify TDV data file.", Name()); controlAlg = 0; } diff --git a/src/cgcomp.cpp b/src/cgcomp.cpp index 1daba643a..6b949b9b8 100644 --- a/src/cgcomp.cpp +++ b/src/cgcomp.cpp @@ -215,20 +215,20 @@ float TOPRAT::tp_WindFactor( // local wind factor static constexpr float fTerrain[5][2] = { // gamma alpha - 0.10f, 1.30f, // ocean or other body of water with at least 5 km unrestriced expanse - 0.15f, 1.00f, // flat terrain with some isolated obstacles (buildings or trees well separated) - 0.20f, 0.85f, // rural areas with low buildings, trees, etc. - 0.25f, 0.67f, // urban, industrial, or forest areas - 0.35f, 0.47f // center of large city + { 0.10f, 1.30f }, // ocean or other body of water with at least 5 km unrestriced expanse + { 0.15f, 1.00f }, // flat terrain with some isolated obstacles (buildings or trees well separated) + { 0.20f, 0.85f }, // rural areas with low buildings, trees, etc. + { 0.25f, 0.67f }, // urban, industrial, or forest areas + { 0.35f, 0.47f } // center of large city }; static constexpr float fShield[5][2] = { // C' SC - 0.324f, 1.000f, // no obstructions or local shielding - 0.285f, 0.880f, // light local shielding with few obstructions - 0.240f, 0.741f, // moderate local shielding, some obstructions within two house heights - 0.185f, 0.571f, // heavy shielding, obstructions around most of the perimeter - 0.102f, 0.315f // very heavy shielding, large obstructions surrounding the perimeter + { 0.324f, 1.000f }, // no obstructions or local shielding + { 0.285f, 0.880f }, // light local shielding with few obstructions + { 0.240f, 0.741f }, // moderate local shielding, some obstructions within two house heights + { 0.185f, 0.571f }, // heavy shielding, obstructions around most of the perimeter + { 0.102f, 0.315f } // very heavy shielding, large obstructions surrounding the perimeter // within two house heights }; @@ -928,12 +928,14 @@ double HEATEXCHANGER::hx_calcBypass( } //=============================================================================== -void HEATEXCHANGER::hx_begSubhr( +RC HEATEXCHANGER::hx_begSubhr( AIRFLOW supInletAF, // Supply inlet AIRFLOW (typically at outdoor air conditions) AIRFLOW exhInletAF, // Exhaust inlet AIRFLOW (typically at return/exhaust air conditions + fan heat) DBL tWant) // Desired supply (hx + bypass) air drybulb temperature, F // returns AIRFLOW of air after mixing bypass air { + RC rc = RCOK; + hx_supInAF = supInletAF; hx_exhInAF = exhInletAF; hx_tSet = tWant; @@ -943,7 +945,7 @@ void HEATEXCHANGER::hx_begSubhr( if (hx_bypass==C_NOYESCH_NO || hx_supInAF.as_tdb == hx_supOutAF.as_tdb) { // if bypass is disabled or the heat exchanger has no sensible effect - return; + return rc; } // Initial guess of bypass fraction // < 1.0 when hx helps get closer to twant @@ -965,12 +967,16 @@ void HEATEXCHANGER::hx_begSubhr( { // Calculate bypass fraction needed to acheive twant // Iterate since effectiveness depends on flow rate double x1{ hx_bypassFrac }; - int rc = regula( [](void* pO, double& bf) { return ((HEATEXCHANGER*)pO)->hx_calcBypass(bf); }, + int ret = regula( [](void* pO, double& bf) { return ((HEATEXCHANGER*)pO)->hx_calcBypass(bf); }, this, hx_tSet, .001, x1, // x1 0., // xMin 1.); // xMax + if (!ret) + rc = RCBAD; } + + return rc; } //=============================================================================== RC DOAS::oa_CkfDOAS() // input checks @@ -1360,7 +1366,7 @@ RC IZXRAT::iz_Ckf( // input checks // UA coupling only if (iz_nvcntrl == C_IZNVTYCH_NONE) - { rc |= disallowN( (char *)MH_S0474, // "when izNVType is NONE or omitted" + { rc |= disallowN( MH_S0474, // "when izNVType is NONE or omitted" IZXRAT_A1, IZXRAT_A2, // error if user gave any of these fields IZXRAT_HZ, IZXRAT_CD, 0); // clear unused defaults @@ -1460,8 +1466,6 @@ int IZXRAT::iz_PathLenToAmbientHelper() const // re finding path length ZNR* pZ1 = ZrB.GetAt(iz_zi1); ZNR* pZ2 = ZrB.GetAt(iz_zi2); - int z2path = pZ2->zn_anPathLenToAmbient; - ret = 1; if (pZ2->zn_anPathLenToAmbient + 1 < pZ1->zn_anPathLenToAmbient) pZ1->zn_anPathLenToAmbient = pZ2->zn_anPathLenToAmbient + 1; @@ -1534,17 +1538,17 @@ RC IZXRAT::iz_Setup( // set up run record break; case C_IZNVTYCH_TWOWAY: - rc |= require((char*)MH_S0475, IZXRAT_HZ); // specific message if izHD omitted + rc |= require( MH_S0475, IZXRAT_HZ); // specific message if izHD omitted // (no ventilation is modelled with no height difference)" - rc |= requireN((char*)MH_S0476, // "when izNVType is TWOWAY" + rc |= requireN( MH_S0476, // "when izNVType is TWOWAY" IZXRAT_A1, IZXRAT_A2, // error if user OMITTED any of IZXRAT_HZ, 0); // ... these fields. cncult2.cpp. - rc |= disallowN((char*)MH_S0476, // "when izNVType is TWOWAY" + rc |= disallowN( MH_S0476, // "when izNVType is TWOWAY" IZXRAT_VFMIN, IZXRAT_VFMAX, IZXRAT_DOAS, ZFAN(VFDS), 0); // error if user gave any of break; default: - ooer(IZXRAT_NVCNTRL, (char*)MH_S0473, izTy, iz_nvcntrl); // "Internal error: bad izNVType 0x%x" + ooer(IZXRAT_NVCNTRL, MH_S0473, izTy, iz_nvcntrl); // "Internal error: bad izNVType 0x%x" break; } @@ -1635,7 +1639,7 @@ x } break; default: - ooer(IZXRAT_NVCNTRL, (char*)MH_S0473, izTy, iz_nvcntrl); // "Internal error: bad izNVType 0x%x" + ooer(IZXRAT_NVCNTRL, MH_S0473, izTy, iz_nvcntrl); // "Internal error: bad izNVType 0x%x" break; } } @@ -2254,7 +2258,7 @@ RC TOPRAT::tp_AirNetInit() // AIRNET msg triggers if (Top.tp_ANPressWarn >= Top.tp_ANPressErr) - rc |= err("ANPressWarn (%0.1f) must be less than ANPressErr (%0.1f)", Top.tp_ANPressWarn, Top.tp_ANPressErr); + rc |= err( ERR, "ANPressWarn (%0.1f) must be less than ANPressErr (%0.1f)", Top.tp_ANPressWarn, Top.tp_ANPressErr); tp_pAirNet = new AIRNET(); @@ -2283,8 +2287,8 @@ using Eigen::VectorXd; struct AIRNET_SOLVER { AIRNET_SOLVER( AIRNET* pParent) - : an_pParent( pParent), an_jac(), an_V1(), an_V2(), an_mdotAbs(nullptr), - an_didLast(nullptr), an_nz( 0), an_unreasonablePressureCount( 0) + : an_pParent( pParent), an_nz( 0), an_jac(), an_V1(), an_V2(), an_mdotAbs(nullptr), + an_didLast(nullptr), an_unreasonablePressureCount( 0) { } ~AIRNET_SOLVER() { diff --git a/src/cgdebug.cpp b/src/cgdebug.cpp index e9035e081..9781f33ca 100644 --- a/src/cgdebug.cpp +++ b/src/cgdebug.cpp @@ -443,7 +443,7 @@ static PBHEAD ashwatH = { PBDATOFFL, ashwatT, 0, 0, 0 }; &wshadh, &WshadR.p[xs->x.iwshad], PBSPECEND ); for (int i = -1; ++i < xs->x.nsgdist; ) // dump its solar gain dists { - char* s1 = nullptr; + const char* s1 = nullptr; const char *s3 = nullptr; BP rb = nullptr; switch (xs->x.sgdist[i].sd_targTy) diff --git a/src/cgresult.cpp b/src/cgresult.cpp index 31fd866fb..a9e7f65d1 100644 --- a/src/cgresult.cpp +++ b/src/cgresult.cpp @@ -105,7 +105,7 @@ struct COLDEF char width; // report column width; export max width excluding (CVS) quotes char dfw; // decimal places USI offset; // offset of field value in record, or USE_NEXT_ARG for next var arg list value - char cvflag; // CVS, CV1, CVK, CVM, CVI, CVWB, NOCV -- below + SI cvflag; // CVS, CV1, CVK, CVM, CVI, CVWB, NOCV -- below int cd_GetDT( bool bSrc=false) const // true: DT of source data @@ -500,7 +500,8 @@ struct RXPORTINFO // instantiated as "rxt" in vpRxports and vpRxFooter. /*-------------------------------- OTHER DATA -----------------------------*/ -static char * shortIvlTexts[] = { "bg0", "Yr ", "Mon", "Day", "Hr ", "sHr", "s/h" }; // subscript is IVLCH value +static const char* shortIvlTexts[] = +{ "bg0", "Yr ", "Mon", "Day", "Hr ", "sHr", "s/h" }; // subscript is IVLCH value /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ @@ -516,8 +517,8 @@ LOCAL void FC vpUdtRpColHeads( DVRI *dvrip); LOCAL void FC vpUdtExColHeads( DVRI *dvrip); LOCAL void FC vpUdtRpRow( DVRI *dvrip); LOCAL void FC vpUdtExRow( DVRI *dvrip); -LOCAL char * CDEC fmtRpColhd( COLDEF *colDef, char *buf, USI flags, ...); -LOCAL char * CDEC fmtExColhd( COLDEF *colDef, char *buf, USI flags, ...); +LOCAL char * CDEC fmtRpColhd( const COLDEF* colDef, char *buf, int flags, ...); +LOCAL char * CDEC fmtExColhd( const COLDEF* colDef, char *buf, int flags, ...); @@ -639,7 +640,7 @@ void FC vpRxports( // virtual print reports and exports of given frequency for doFoot0 = Top.isLastDay; break; default: - err( PWRN, (char *)MH_R0150, (INT)rxt.fq); // "cgresult:vrRxports: unexpected rpFreq %d" + err( PWRN, MH_R0150, rxt.fq); // "cgresult:vrRxports: unexpected rpFreq %d" } // init that applies to frequency and more often: fall thru cases. @@ -675,8 +676,8 @@ void FC vpRxports( // virtual print reports and exports of given frequency for | ( isExport ? (16|8) // exports show BOTH name and the 4 export time columns : (isAll ? 16 : 8) ); // all- reports show name, others rpts show time column rxt.flags = (rxt.flags &~(64|32)) // include shutter frac * (64) and Mode (32) columns - | ( rxt.fq >= C_IVLCH_S // .. in _HS and _S reports - && (dvrip->ownTi > 0 || isAll ) // .. for a single zone or all zones + | (( rxt.fq >= C_IVLCH_S // .. in _HS and _S reports + && (dvrip->ownTi > 0 || isAll)) // .. for a single zone or all zones || isExport // .. and in all exports (keep format constant) ? (64|32) : 0 ); // (but data is blanked/0'd below in non-subhr lines) @@ -694,7 +695,7 @@ void FC vpRxports( // virtual print reports and exports of given frequency for if (ISNANDLE(dvrip->rpCond)) // if condition UNSET (bug) or not yet evaluated { - rer( (char *)MH_R0152, // "%sCond for %s '%s' is unset or not yet evaluated" + rer( MH_R0152, // "%sCond for %s '%s' is unset or not yet evaluated" isExport ? "ex" : "rp", isExport ? "export" : "report", dvrip->rpTitle.CStrIfNotBlank( dvrip->Name())); // title if any, else name continue; // treat as FALSE @@ -755,7 +756,7 @@ o vrChangeOptn( vrh, VR_NEEDFOOT, VR_NEEDFOOT); // (need a way to print last break; // UDT uses no COLDEF table default: - err( PWRN, (char *)MH_R0151, (INT)rpTy); // "cgresult.c:vpRxports: unexpected rpType %d" + err( PWRN, MH_R0151, rpTy); // "cgresult.c:vpRxports: unexpected rpType %d" } #ifdef DEFFOOT /* no reports with conditional rows have footers, 1-6-92. (no longer true 1-20-92; tentatively let @@ -769,10 +770,10 @@ o vpRxFooter(dvrip); // virtual print report or export footer, below. c // heading first time, and periodically per report type if ( vrIsEmpty(vrh) // if nothing yet output to this virtual report - || !isExport // exports do not get reHeaded + || (!isExport // exports do not get reHeaded && ( reHead // if a heading due now (set in init) - || vrGetOptn(vrh) & VR_NEEDHEAD // or heading request pending from prior skipped line - || isAll ) ) // All- reports gets header (and footer) every time + || (vrGetOptn(vrh) & VR_NEEDHEAD) // or heading request pending from prior skipped line + || isAll ))) // All- reports gets header (and footer) every time vpRxHeader( dvrip, &rxt); // do report/export heading, below. clears VR_NEEDHEAD. // report/export row (or body for all-zones, all-meter reports) @@ -909,11 +910,11 @@ LOCAL void FC vpRxHeader( // do report/export header appropropriate for type a const char *objTx = ""; // "zone ", "All Zones", "Sum of Zones", etc, or "meter " etc const char *what = NULL; // set to "Energy Balance", "Statistics", etc for standard report title & col heads per colDef - char *fqTx = " "; // "Annual ", "Monthly ", etc for use in report title text - char *ivlTx = "Bug"; // "Year", "Month", etc for use in All- export head (Y,M,D,H only) - const char *when = ""; // "" or monStr, dateStr, etc to add " for ..." to report title - char *hd1; // "Mon", "Day" etc short text for 1st ZEB/ZST/MTR/AH report col head. - char *xhd1 = ""; // export col 1 head: object name + const char *fqTx = " "; // "Annual ", "Monthly ", etc for use in report title text + const char *ivlTx = "Bug"; // "Year", "Month", etc for use in All- export head (Y,M,D,H only) + const char *when = ""; // "" or monStr, dateStr, etc to add " for ..." to report title + const char* hd1; // "Mon", "Day" etc short text for 1st ZEB/ZST/MTR/AH report col head. + const char* xhd1 = ""; // export col 1 head: object name SI hour = 0; // 0 or hour 1-24 to show in report heading (all- reports) SI subHour = -1; // -1 or subhour 0.. to show in report heading (all- reports) @@ -1400,7 +1401,7 @@ LOCAL void FC vpEbStRow( // virtual print zone ZEB or ZST row for zone or su // .fqr is H or S when .fq is HS for hourly+subhourly reports ZNRES_IVL_SUB *res = &ZnresB.p[resi].curr.Y + resSubi; // point results substructure for interval to be reported SI xMode = 0; // for ZEB export: CSE zone mode as integer - char *znSC = ""; // for ZEB report and export: shutter fraction, "" or "*" + const char* znSC = ""; // for ZEB report and export: shutter fraction, "" or "*" char mode[10]; // for ZEB report: CSE zone mode as text mode[0] = 0; @@ -1544,11 +1545,13 @@ LOCAL void CDEC vpRxRow( // virtual print report or export row given COLDEF tabl // column spacing or separating if (s != temp) // unless first field on line. Moved to apply to reports too, 6-95. + { if (isExport) // if exporting (spreadsheet format) *s++ = ','; // comma after prior datum else // not export - if ( !(colDef->flags & 1) ) // unless colDef option bit on + if (!(colDef->flags & 1)) // unless colDef option bit on *s++ = ' '; // skip a space b4 each col + } // determine data format USI mfw, fmt; @@ -1955,9 +1958,9 @@ LOCAL void FC vpUdtExRow( DVRI *dvrip) // virtual print current interval row for //================================================================== LOCAL char * CDEC fmtRpColhd( // format report columns table heading per COLDEF table - COLDEF *colDef, // Pointer to table which describes heading format + const COLDEF *colDef, // Pointer to table which describes heading format char *head, // ptr to (big enough) buffer in which to build head - USI flags, /* col head enable bits, matched against colDef .flags for each column: + int flags, /* col head enable bits, matched against colDef .flags for each column: If any SKIPFLAGS on in colDef but off in this arg, col is OMITTED; If any BLANKFLAGS on in colDef but off in this arg, col is head is BLANKED. */ ... ) // add'l char * args are used where colDef->colhd is -1, eg for Mon/Day/Hr for ZrRep 1st col per rpFreq @@ -1998,7 +2001,7 @@ LOCAL char * CDEC fmtRpColhd( // format report columns table heading per COLDEF blankit = (BLANKFLAGS & colDef->flags &~flags); // BLANK OUT column with BLANKFLAGS bit that caller did not give #endif - const char *colhd = (colDef->colhd==(const char *)-1L) + const char* colhd = (colDef->colhd==(const char *)-1L) ? va_arg( ap, const char *) : colDef->colhd; // for pointer -1L, use next arg @@ -2020,9 +2023,9 @@ LOCAL char * CDEC fmtRpColhd( // format report columns table heading per COLDEF //================================================================== LOCAL char * CDEC fmtExColhd( // format export file columns heading per COLDEF table - COLDEF *colDef, // Pointer to table which describes heading format - char *head, // ptr to (big enough) buffer in which to build head - USI flags, /* col head enable bits, matched against colDef .flags for each column: + const COLDEF *colDef, // Pointer to table which describes heading format + char *head, // ptr to (big enough) buffer in which to build head + int flags, /* col head enable bits, matched against colDef .flags for each column: SKIPFLAGS: if any of these bits on in colDef but off in this arg, col is OMITTED BLANKFLAGS: if any of these bits on in colDef but off in this arg, col is output as "" only */ ... ) // add'l char * args are used where colDef->colhd is -1L, eg for Mon/Day/Hr for ZrRep 1st col per rpFreq @@ -2042,7 +2045,7 @@ LOCAL char * CDEC fmtExColhd( // format export file columns heading per COLDEF *s++ = '"'; // enclose in quotes const char* colhd = (colDef->colhd==(const char *)-1L) - ? va_arg( ap, char *) + ? va_arg( ap, const char *) : colDef->colhd; // for "pointer" -1L use next arg #if BLANKFLAGS // omit code if no such bits diff --git a/src/cgsolar.cpp b/src/cgsolar.cpp index 93b07f5b2..a01b7ecaf 100644 --- a/src/cgsolar.cpp +++ b/src/cgsolar.cpp @@ -244,7 +244,6 @@ LOCAL void sgrPut( const char* sgName, SGTARG* pTarg, float* pCtrl, BOO isSubhrl BOO isEndIvl, #endif double bmBm, double dfDf, double bmDf=0.); -LOCAL void FC cgRefGls( float eta, float* trans, float* abso); LOCAL void toSurfSide( TI xsi, SI si, TI czi, const double sgf[ socCOUNT][ sgcCOUNT]); LOCAL void toZoneCAir( TI zi, TI czi, float bmo, float dfo, float bmc, float dfc); @@ -381,7 +380,7 @@ void FC makHrSgt( // make solar tables for an hour for current month * if (Fslrdbg == NULL) * Fslrdbg = fopen( "SGAIN.VMT", "wt"); * fprintf( Fslrdbg, "\n\n\n=============== Month = %d Day = %d\n", -* INT(Top.tp_date.month-1), INT(slrCalcJDays[Top.tp_date.month]) ); +* Top.tp_date.month-1, slrCalcJDays[Top.tp_date.month] ); #endif // Initialize slpak for a standard day near middle of month. Note restored at exit. @@ -637,7 +636,7 @@ void XSRAT::xr_SGIncTrans( // hour exterior incident and transmitted solar gai // window...: check that scc <= sco: runtime variable expressions if (x.scc > x.sco + ABOUT0) // note wnSMSO/C values may be from gtSMSO/C. - rer( (char *)MH_R0163, Name(), x.scc, x.sco); + rer( MH_R0163, Name(), x.scc, x.sco); // "Window '%s': wnSMSC (%g) > wnSMSO (%g):\n" // " SHGC Multiplier for Shades Closed must be <= same for Shades Open" tDf1[ 0] = gDf * x.sco; @@ -893,7 +892,7 @@ void SgThruWin::tw_Doit() { switch (sgd->sd_targTy) // subtract target area if new target { case SGDTTZNAIR: case SGDTTZNTOT: - rer( PWRN, "cgsolar.cpp:makHrSgt(): misplaced obsolete sgdist to zone"); + rerErOp( PWRN, "cgsolar.cpp:makHrSgt(): misplaced obsolete sgdist to zone"); break; case SGDTTSURFO: case SGDTTSURFI: undistArea -= XsB[ sgd->sd_targTi].x.xs_area; @@ -909,7 +908,7 @@ void SgThruWin::tw_Doit() for (int oc = 0; oc < 2; oc++) // for shades open, shades closed if (undistF[oc] < 0.f) // issue runtime error msg (exman.cpp) with day/hour: { - rer( (char *)MH_R0162, // "%g percent of %s solar gain for window '%s'\n" Also used just below + rer( MH_R0162, // "%g percent of %s solar gain for window '%s'\n" Also used just below // " of zone '%s' distributed: more than 100 percent. Check SGDISTs." (1.f - undistF[oc]) * 100.f, // eg 110% oc ? "shades-closed" : "shades-open", @@ -975,8 +974,8 @@ void SgThruWin::tw_Doit() #ifdef DEBUG // if found any untargeted surface(s) to rcv untargeted gain, // should have found surf for all gain to strike - if ( foundUntSurf && unHitF > ABOUT0 || unHitF < -ABOUT0 ) - rer( (char *)MH_R0164, zp->Name(), tw_xr->Name(), unHitF); + if ( (foundUntSurf && unHitF > ABOUT0) || unHitF < -ABOUT0 ) + rer( MH_R0164, zp->Name(), tw_xr->Name(), unHitF); /* "cgsolar.cpp:SgThruWin::doit(): zone \"%s\", window \"%s\":\n" " undistributed gain fraction is %g (should be 0)." */ #endif @@ -1076,7 +1075,7 @@ void SgThruWin::tw_ToZoneCav( // put gain to zone cavity // to implement, must distribute to target zone using control zone's znSC in sgrAdd calls. // meanwhile, issue message and fall thru to use wrong control zone. - rer( PWRN, (char *)MH_R0165, ZrB[ czi].Name(), zp->Name()); /* "cgsolar.cpp:SgThruWin::toZoneCav:\n" + rerErOp( PWRN, MH_R0165, ZrB[ czi].Name(), zp->Name()); /* "cgsolar.cpp:SgThruWin::toZoneCav:\n" " control zone (\"%s\") differs from target zone (\"%s\")."*/ } @@ -1229,7 +1228,7 @@ o BOO isEndIvl = FALSE; // non-0 for end-time-interval gain (zone air), 0 for break; case SGDTTZNTOT: // zone total: can be internally generated only, 2-95 - rer( PWRN, (char *)MH_R0166, targTy); // "cgsolar.cpp:sgrAdd(): called for SGDTT %d" + rerErOp( PWRN, MH_R0166, targTy); // "cgsolar.cpp:sgrAdd(): called for SGDTT %d" return RCBAD; case SGDTTZNAIR: diff --git a/src/cnah1.cpp b/src/cnah1.cpp index d55437cbe..7543a7d79 100644 --- a/src/cnah1.cpp +++ b/src/cnah1.cpp @@ -356,7 +356,7 @@ RC AH::ah_p2EndTest() // autoSize pass 2 end test float reducedCap = hcAs.xPkAs * (hcAs.plrPkAs + 1.f) / 2.f; setToMin(ahhc.captRat, reducedCap); // reduce (precaution) cap to bring plr half way to 1 // (just half way in case relation between capt & plr not linear) - if ( Top.verbose > 2 && !Top.tp_auszNotDone // at verbose = 3 show the first not done thing, rob 6-97 + if ( (Top.verbose > 2 && !Top.tp_auszNotDone) // at verbose = 3 show the first not done thing, rob 6-97 || Top.verbose > 3) // at verbose = 4 show all not dones screen( 0, " ah[%d] p2EndTest hc plr%6.3g capt%8g -->%8g", ss, hcAs.plrPkAs, was, ahhc.captRat); } @@ -402,7 +402,7 @@ RC AH::ah_p2EndTest() // autoSize pass 2 end test // setToMax( ahcc.captRat, // reduce (precaution) NEGATIVE captRat ccAs.xPkAs * 6 * plr / (5 - 2*Top.auszTol + plr) ); // as derived just above - if ( Top.verbose > 2 && !Top.tp_auszNotDone // at verbose = 3 show the first not done thing, rob 6-97 + if ( (Top.verbose > 2 && !Top.tp_auszNotDone) // at verbose = 3 show the first not done thing, rob 6-97 || Top.verbose > 3) // at verbose = 4 show all not dones screen( 0, " ah[%d] p2EndTest cc plr%6.3g capt%8g -->%8g", ss, ccAs.plrPkAs, was, ahcc.captRat); } @@ -423,7 +423,7 @@ RC AH::ah_p2EndTest() // autoSize pass 2 end test // correct 5/6 of the way to plr = 1 - tol/3 as derived above for ahcc.captRat: setToMin( sfan.vfDs, // ceil not = is a precaution fanAs.xPkAs * 6 * fanAs.plrPkAs / (5 - 2*Top.auszTol + fanAs.plrPkAs) ); - if ( Top.verbose > 2 && !Top.tp_auszNotDone // at verbose = 3 show the first not done thing, rob 6-97 + if ( (Top.verbose > 2 && !Top.tp_auszNotDone) // at verbose = 3 show the first not done thing, rob 6-97 || Top.verbose > 3) // at verbose = 4 show all not dones screen( 0, " ah[%d] p2EndTest fan plr%6.3g vfMx%8g -->%8g", ss, fanAs.plrPkAs, was, sfan.vfDs ); @@ -792,7 +792,7 @@ RC AH::begHour() // airHandler stuff done at start of hour, after expression // check hourly variables if (ahTsMn > ahTsMx) - rer( (char *)MH_R1270, Name(), ahTsMn, ahTsMx); // "airHandler '%s': ahTsMn (%g) > ahTsMx (%g)" + rer( MH_R1270, Name(), ahTsMn, ahTsMx); // "airHandler '%s': ahTsMn (%g) > ahTsMx (%g)" // default autoSizing design supply temps (hourly) ahTsMn/Mx, and check. 6-95. if (!(sstat[AH_AHTSDSH] & FsSET)) // if ahTsDsH not given @@ -820,33 +820,37 @@ RC AH::begHour() // airHandler stuff done at start of hour, after expression // frFanOnNx will be set each subhour by puteRa. // fanCyles and ZN2 are contradictory if (ISNCHOICE(ahTsSp) && CHN(ahTsSp)==C_TSCMNC_ZN2) - rer( PABT, (char *)MH_R1271, Name()); // "airHandler '%s': ahFanCycles=YES not allowed when ahTsSp is ZN2" + rerErOp( PABT, MH_R1271, Name()); // "airHandler '%s': ahFanCycles=YES not allowed when ahTsSp is ZN2" // only one terminal is supported, because we are using znTerminal's fraction flow to represent ah's fraction time on. // (for additional terminals, would need to force same flow fraction as control terminal.) if (TuB.p[tu1].nxTu4a) // test 'next' of first to detect > 1 terminal - return rer( PWRN, (char *)MH_R1272, name ); /* "airHandler '%s': more than one terminal\n" - " not allowed when fan cycles" */ + return rerErOp( PWRN, MH_R1272, Name() ); // "airHandler '%s': more than one terminal\n" + // " not allowed when fan cycles" // require control terminal if (!ahCtu) // (insurance: msg shd not occur cuz ahCtu defaults to tu when only one) - rer( PABT, (char *)MH_R1273, name ); /* "airHandler '%s': fan cycles, but no control terminal:\n" + rerErOp( PABT, MH_R1273, Name() ); /* "airHandler '%s': fan cycles, but no control terminal:\n" " ahCtu = ... apparently missing" */ // check that minimum flow is 0 (cuz at min don't know whether heating or cooling). hourly vbl --> runtime check required. TU *ctu = TuB.p + ahCtu; if (ahCtu) + { if (ctu->tuVfMn != 0.) + { if (ctu->sstat[TU_TUVFMN] & FsAS) /* if non-0 because of autoSize give specific message 7-95 - (errors at input time if inputs constant; may be ok at runtime - if fcc always on: goes non-0 in cnztu.cpp only when fcc off) */ - rer( PWRN, "Control terminal '%s' of airHandler '%s':\n" + (errors at input time if inputs constant; may be ok at runtime + if fcc always on: goes non-0 in cnztu.cpp only when fcc off) */ + rerErOp(PWRN, "Control terminal '%s' of airHandler '%s':\n" " can't AUTOSIZE tuVfMn when air handler fan cycles:\n" " When fan cycles, terminal minimum flow must be zero, but \n" " AUTOSIZE tuVfMn makes minumum flow equal to maximum flow.", // NUMS - ctu->Name(), Name(), ctu->tuVfMn ); + ctu->Name(), Name(), ctu->tuVfMn); else - rer( PWRN, (char *)MH_R1274, //"Control terminal '%s' of airHandler '%s':\n" - ctu->Name(), Name(), ctu->tuVfMn ); //" terminal minumum flow (tuVfMn=%g) must be 0 when fan cycles" + rerErOp(PWRN, MH_R1274, //"Control terminal '%s' of airHandler '%s':\n" + ctu->Name(), Name(), ctu->tuVfMn); //" terminal minumum flow (tuVfMn=%g) must be 0 when fan cycles" + } + } } // determine upper limit of fanF that could reduce ah flow this hour: @@ -1063,17 +1067,19 @@ RC AH::ahCompute() // airHandler full computation ("refine"), after terminals // CAUTION -Pr's & ts random: assumes .ahPtf set when turned ON again #ifdef DEBUG if (frFanOn > Top.hiTol /* + Top.relTol if necess */) // no msg if within vsh tolerances - rWarn( PWRN, (char *)MH_R1275, Name(), frFanOn); // devel aid warning "airHandler '%s': frFanOn (%g) > 1.0" + rWarnErOp( PWRN, MH_R1275, Name(), frFanOn); // devel aid warning "airHandler '%s': frFanOn (%g) > 1.0" #endif /* set flags re tu_endAutosize message if autoSizing flow got huge in antRatTs as ts approached sp, and ts ended up on wrong side of sp. Cuz ztuMode won't detect if ts already on wrong side of sp. */ if (asFlow) // else not autoSizing any tu's on ah - for (TU *tu = 0; nxTu(tu); ) // loop ah's tu's + { + for (TU* tu = 0; nxTu(tu); ) // loop ah's tu's if (tu->useAr & uStH) // if this terminal is set temp heating tu->aDtLoHSh |= tu->aDtLoTem && aTs <= ZhxB.p[tu->xiArH].sp; // TU::begSubhr clears when ts > sp. else if (tu->useAr & uStC) // if terminal is set temp cooling tu->aDtLoCSh |= tu->aDtLoTem && aTs >= ZhxB.p[tu->xiArC].sp; // TU::begSubhr clears when ts < sp + } // outputs and change-flagging upCouple( aTs, ah_tSup, aWs, ah_wSup); /* adjust aqO/bO of tu's on OTHER AH's in zones served by this ah for changes diff --git a/src/cnah2.cpp b/src/cnah2.cpp index 152da1e2a..5148867ef 100644 --- a/src/cnah2.cpp +++ b/src/cnah2.cpp @@ -245,9 +245,9 @@ x // autoSized fan should always be big enough, expect no fanF/fanlimited #ifdef DEBUG2 // omit message from release version. TESTED 5-12-95: enabled msg did not occur in any CKALL tests. if ( Top.iter >= 2 // conditional warning. 2 non-cnvs seen in SA11B13, consider normal. && Top.iter < 12 ) // crude way to limit to 10 messages in one subhour - rWarn( (char *)MH_R1294, Name(), (INT)Top.iter, // "airHandler '%s' not yet converged. Top.iter=%d\n" + rWarn( MH_R1294, Name(), Top.iter, // "airHandler '%s' not yet converged. Top.iter=%d\n" tr, wr, cr, frFanOn, // " tr=%g wr=%g cr=%g frFanOn=%g\n" - po, aTs, aWs, fanF, (INT)ahMode, // " po=%g ts=%g ws=%g fanF=%g ahMode=%d\n" + po, aTs, aWs, fanF, ahMode, // " po=%g ts=%g ws=%g fanF=%g ahMode=%d\n" trNx, wrNx, crNx ); // " trNx=%g wrNx=%g crNx=%g\n" // " DISREGARD THIS DEBUGGING MESSAGE UNLESS FOLLOWED BY\n" // " \"Air handler - Terminals convergence failure\" error message." @@ -304,8 +304,9 @@ x // autoSized fan should always be big enough, expect no fanF/fanlimited // only points on zero-power curve or full-power curve are used for extrapolation (they converge slowly) // see eg OUT459B.ZIP for if'd out (!TRY4) code to use converger only at full, not 0, power, 5-95. if (!ffc) // don't xtrap from ts if fanF just changed - if (coilLimited) tsHis[0].gud = 1; // full-power point + { if (coilLimited) tsHis[0].gud = 1; // full-power point else if (coilUsed==cuNONE) tsHis[0].gud = 2; // no-power point, eg ZN2 floating between heat and cool + } // else leave .gud, dT, rdT 0: code assumes. /* compute dT and rdT for xtrapGeo if a point on full power or zero power curve and fanF did not change @@ -758,8 +759,8 @@ BOO AH::converger() // interpolate/extrapolate ts (and ws) for iter4Fs DBL wr2 = tsHis[0].rdW; // ratio of last 2 dW's, like rdT. 0 if not valid, just xtrap'd, etc. if ( wr2 != 0 // if have 3 w points, 2 non-0 dW's, & other conditions && ( coilUsed != cuCOOL // only when cooling, because condensation on coil nonlinear, - || !tsHis[2].x // can't start from xtrap'd w - && tsHis[1].gud==tsHis[2].gud ) ) // initial 0/part/full load must match + || (!tsHis[2].x // can't start from xtrap'd w + && tsHis[1].gud==tsHis[2].gud) ) ) // initial 0/part/full load must match { setToMin( wr2, .8); // limit non-alternating change in case a big oscillation, not a trend //setToMax( wr2, .7); I'm unclear about negative wr2 limit, 4-29-95. @@ -834,16 +835,20 @@ BOO AH::binClip() // conditionally limit ts, ws changes to act like binary sear DBL tsIncr1 = tsHis[1].t - tsHis[2].t; // previous ditto DBL thisMaxTsIncr = maxTsIncr; // max increment to use: fudged at reversal if (tsIncr0 * tsIncr1 < 0.) // if sign of change changed, is a reversal + { if (ntRev++==0) // if first reversal thisMaxTsIncr = // set current limit same so not limited on fallthru - maxTsIncr = max( fabs(tsIncr0), fabs(tsIncr1), .5); // init max incr to larger of last 2 incrs, at least .5 degrees. - // TESTED 11-92: minimum max incr seems to save a few iterations. + maxTsIncr = max(fabs(tsIncr0), fabs(tsIncr1), .5); // init max incr to larger of last 2 incrs, at least .5 degrees. + // TESTED 11-92: minimum max incr seems to save a few iterations. else // at each successive reversal + { if (maxTsIncr > 1.e-11) // unless incr might get insignificant when added to aTs, 5-29-92 { maxTsIncr /= 2.; // halve maximum increment thisMaxTsIncr = 3.*maxTsIncr/2.; // at reversal use 3/2 new incr (3/4 old): stagger points tested } + } + } #ifdef WSCLIP // if including code re aWs (undef'd at head file) // if ws reversed direction of change, init or halve max increment @@ -1384,13 +1389,15 @@ void AH::doOa() // do outside air for airHandler DBL oaLeakC = tem * oaOaLeak * Top.tp_airxOSh; // outside air leak. convert cfm to hc at outside temp. DBL raLeakC = sfan.vfDs * oaRaLeak * cnv; // return air leak, heat cap units if (oaLeakC + raLeakC) // if there is any leakage + { if (oaLeakC + raLeakC >= cr1On) // if more leakage than flow (incl cr1On==0) mnPo = mxPo = oaLeakC/(oaLeakC+raLeakC); // apportion flow in ratio of leakages else // leak less than flow: normal case; implies cr1On non-0 { - setToMax( mnPo, oaLeakC/cr1On); // oa leakage gives min outside air flow - setToMin( mxPo, 1. - raLeakC/cr1On); // ra leakage gives max outside air flow + setToMax(mnPo, oaLeakC/cr1On); // oa leakage gives min outside air flow + setToMin(mxPo, 1. - raLeakC/cr1On); // ra leakage gives max outside air flow } + } } // fraction outside air if no economizer or disabled @@ -1446,7 +1453,7 @@ void AH::doEco() // do econimizer for ah, called only if eco present. #if defined( _DEBUG) else { - rer( PWRN,(char *)MH_R1277, CSE_V oaLimT); // "airHandler '%s': bad oaLimT 0x%lx" + rerErOp( PWRN,MH_R1277, CSE_V oaLimT); // "airHandler '%s': bad oaLimT 0x%lx" return; } #endif @@ -1465,7 +1472,7 @@ void AH::doEco() // do econimizer for ah, called only if eco present. #ifdef DEBUG else { - rer( PWRN,(char *)MH_R1278, CSE_V oaLimE); // "airHandler '%s': bad oaLimE 0x%lx" + rerErOp( PWRN,MH_R1278, CSE_V oaLimE); // "airHandler '%s': bad oaLimE 0x%lx" return; } #endif @@ -2015,13 +2022,15 @@ DBL AH::tsfo( // detailed computation of fan-only supply temp DBL oaLeakC = tem * oaOaLeak * Top.tp_airxOSh; // outside air leak. convert cfm to hc at outside temp. DBL raLeakC = sfan.vfDs * oaRaLeak * cnv; // return air leak, heat cap units if (oaLeakC + raLeakC) // if there is any leakage + { if (oaLeakC + raLeakC >= cr1On) // if more leakage than flow (incl cr1On==0) _mnPo = /*_mxPo=*/ oaLeakC/(oaLeakC+raLeakC); // apportion flow in ratio of leakages else // leak less than flow: normal case; implies cr1On non-0 { - setToMax( _mnPo, oaLeakC/cr1On); // oa leakage gives min outside air flow + setToMax(_mnPo, oaLeakC/cr1On); // oa leakage gives min outside air flow //setToMin( _mxPo, 1. - raLeakC/cr1On); // ra leakage gives max outside air flow } + } } // fraction outside air if no economizer or disabled @@ -2236,34 +2245,34 @@ x setToMin( ulim, max( tSen, ulim1) ); // don't let tSen go hier, switch (CHN(ahTsSp)) { default: - rer( PABT, (char *)MH_R1279, // "Internal error: Airhandler '%s': unrecognized ts sp control method 0x%lx" + rerErOp(PABT, MH_R1279, // "Internal error: Airhandler '%s': unrecognized ts sp control method 0x%lx" Name(), CSE_V ahTsSp); case C_TSCMNC_RA: // return air supply temp setpoint control #if 0 // No, I think we should just let RA operate normally during sizing - no ah ts changes. Rob 7-2-95. -* // can't use RA with autoSize part A model as don't know whether to use Hi or Lo supply temp. -* if (asFlow && Top.tp_pass1A) // must check at run time cuz ahTsSp is hourly variable. -* rc |= rer( "airHandler '%s': Cannot use \"ahTsSp = RA\"\n" -* " when autoSizing supply fan or any connected terminal", Name()); // NUMS + * // can't use RA with autoSize part A model as don't know whether to use Hi or Lo supply temp. + *if (asFlow && Top.tp_pass1A) // must check at run time cuz ahTsSp is hourly variable. + *rc |= rer("airHandler '%s': Cannot use \"ahTsSp = RA\"\n" + * " when autoSizing supply fan or any connected terminal", Name()); // NUMS #endif // limits of return air range over which ts sp varies must be given. fatal 6-13-92 if (!(sstat[AH_AHTSRAMN] & FsSET)) - rc |= rer(ABT,(char *)MH_R1280,Name()); // "airHandler '%s': ahTsSp is RA but no ahTsRaMn has been given" + rc |= rerErOp(ABT, MH_R1280, Name()); // "airHandler '%s': ahTsSp is RA but no ahTsRaMn has been given" if (!(sstat[AH_AHTSRAMX] & FsSET)) - rc |= rer(ABT,(char *)MH_R1281,Name()); // "airHandler '%s': ahTsSp is RA but no ahTsRaMx has been given" + rc |= rerErOp(ABT, MH_R1281, Name()); // "airHandler '%s': ahTsSp is RA but no ahTsRaMx has been given" // ts sp limits, otherwise optional, must also be given: these specify range over which ts sp varies if (!(sstat[AH_AHTSMN] & FsSET)) - rc |= rer( ABT, (char *)MH_R1282, Name()); // "airHandler '%s': ahTsSp is RA but no ahTsMn has been given" + rc |= rerErOp(ABT, MH_R1282, Name()); // "airHandler '%s': ahTsSp is RA but no ahTsMn has been given" if (!(sstat[AH_AHTSMX] & FsSET)) - rc |= rer( ABT, (char *)MH_R1283, Name()); // "airHandler '%s': ahTsSp is RA but no ahTsMx has been given" + rc |= rerErOp(ABT, MH_R1283, Name()); // "airHandler '%s': ahTsSp is RA but no ahTsMx has been given" if (!rc) // if error (missing input), let ts sp be default set above tTsSp = ahTsMx // when tr2Nx is ahTsRaMn, ts sp is Mx - + (ahTsMn - ahTsMx)/(ahTsRaMx - ahTsRaMn) // slope - * (tr2Nx - ahTsRaMn)/(ahTsRaMx - ahTsRaMn); // fraction 0 for tr2Nx==ahTsRaMn, 1 for Mx. + + (ahTsMn - ahTsMx)/(ahTsRaMx - ahTsRaMn) // slope + * (tr2Nx - ahTsRaMn)/(ahTsRaMx - ahTsRaMn); // fraction 0 for tr2Nx==ahTsRaMn, 1 for Mx. break; // ts is limited to range ahTsMn..ahTsMx below. case C_TSCMNC_ZN2: // the other ZN method 8-92: WZ or CZ or fan only -- fan runs even when coils disabled @@ -2277,7 +2286,7 @@ x setToMin( ulim, max( tSen, ulim1) ); // don't let tSen go hier, if (ahCtu) // no control terminal possible if ahTsSp is runtime expr ctu = &TuB.p[ahCtu]; // point to specified control terminal for ZN/ZN2 methods else // fatal error 6-13-92 - rer( ABT, (char *)MH_R1284, Name()); // "ahTsSp for airHandler '%s' is ZN or ZN2 but no ahCtu has been given" + rerErOp(ABT, MH_R1284, Name()); // "ahTsSp for airHandler '%s' is ZN or ZN2 but no ahCtu has been given" if (ahMode & ahCOOLBIT) // heating & cooling exclusive here cooling = TRUE; // if cooling, say so (low setpoint); leave FALSE for heating (hi sp). /* limitation: if ah has TWO terminals in zone (nothing yet disallows this if not fcc?), @@ -2302,32 +2311,32 @@ x setToMin( ulim, max( tSen, ulim1) ); // don't let tSen go hier, } // require ahTsMn/Mx with ZN and fancycles, since used as setpoints. .460, 5-95. if (!(sstat[AH_AHTSMN] & FsSET)) - rer( ABT, (char *)MH_R1295, Name()); /* "airHandler '%s': ahTsSp is ZN (with ahFanCycles=YES)" - " but no ahTsMn has been given." */ + rerErOp(ABT, MH_R1295, Name()); /* "airHandler '%s': ahTsSp is ZN (with ahFanCycles=YES)" + " but no ahTsMn has been given." */ if (!(sstat[AH_AHTSMX] & FsSET)) - rer( ABT, (char *)MH_R1296, Name()); /* "airHandler '%s': ahTsSp is ZN (with ahFanCycles=YES)" - " but no ahTsMx has been given." */ + rerErOp(ABT, MH_R1296, Name()); /* "airHandler '%s': ahTsSp is ZN (with ahFanCycles=YES)" + " but no ahTsMx has been given." */ #ifdef ZNJUST // (un)def'd at top file, 6-97. - /* for ZN/ZN2 autosizing, use only ts that coil can now produce or zone needs, to get large frFanOn. - Intended to combat tendency to size coil & fan too large with frFanOn unnec small at peak load, - especially eg when fan oversize for heat has already been forced by cooling requirements. 6-16-97. */ + /* for ZN/ZN2 autosizing, use only ts that coil can now produce or zone needs, to get large frFanOn. + Intended to combat tendency to size coil & fan too large with frFanOn unnec small at peak load, + especially eg when fan oversize for heat has already been forced by cooling requirements. 6-16-97. */ if (Top.tp_autoSizing) { DBL canGet = tTsSp; // init: precaution. - if ( !tsPoss( trNx, wrNx, crNx, // calc approx ts current coil size can produce. above. - cooling, // 0 max heat ts, 1 max cool ts. - canGet ) ) // receives result + if (!tsPoss(trNx, wrNx, crNx, // calc approx ts current coil size can produce. above. + cooling, // 0 max heat ts, 1 max cool ts. + canGet)) // receives result break; // certain not-covered cases leave tTsSp unchanged DBL loadNeeds = cooling ? ulim : llim; // init to opposite extreme FLOAT cznCSink; - wzczSp( est, cooling, FALSE, llim, ulim, // calc ts needed to meet load. below. - &TuB.p[ahCtu], loadNeeds, cznCSink ); + wzczSp(est, cooling, FALSE, llim, ulim, // calc ts needed to meet load. below. + &TuB.p[ahCtu], loadNeeds, cznCSink); FLOAT m = est ? 0 : 2.; // .1 ah/tu nonconvergence (BUG0090); explore values more. // 1. ditto warning; 2. good; 4. not as good as 2. 6-16-97. if (cooling) - setToMax( tTsSp, min( canGet-m, loadNeeds)); // limit to lower of present coil, load req't + setToMax(tTsSp, min(canGet-m, loadNeeds)); // limit to lower of present coil, load req't else - setToMin( tTsSp, max( canGet+m, loadNeeds)); // .. higher .. + setToMin(tTsSp, max(canGet+m, loadNeeds)); // .. higher .. } #endif break; // done for fcc @@ -2359,13 +2368,13 @@ x setToMin( ulim, max( tSen, ulim1) ); // don't let tSen go hier, // get better coil-off ts estimate, assuming control terminal @ min flow, for CONST VOL cases /* (for vav, don't know what flow makes min ts & accuracy less critical cuz tu can adjust flow, so stay with preset value based on previous flow & fan heats) */ - if (ctu->cMn > .99 * ( (ctu->useAr & (uMxH|uStH)) // if min flow > 99% of applicable max flow - ? ctu->cMxH : ctu->cMxC ) ) // .. (test sloppy re uMn (expected), uSo (not)) + if (ctu->cMn > .99 * ((ctu->useAr & (uMxH|uStH)) // if min flow > 99% of applicable max flow + ? ctu->cMxH : ctu->cMxC)) // .. (test sloppy re uMn (expected), uSo (not)) { //tsMnFoOk = FALSE; to force fresh calculation even if just calc'd eg from ztuMode // TESTED above line had NO EFFECT on 48 const-vol ZN/ZN2 test runs, 5-10-95. tTsSp = getTsMnFo(FALSE); // do much of ah calc for ctu min flow - tTsSp = (tTsSp - ahSOLoss*Top.tDbOSh)/(1. - min(ahSOLoss,.9f)); // reverse-calc supply duct loss + tTsSp = (tTsSp - ahSOLoss*Top.tDbOSh)/(1. - min(ahSOLoss, .9f)); // reverse-calc supply duct loss } } } @@ -2373,31 +2382,35 @@ x setToMin( ulim, max( tSen, ulim1) ); // don't let tSen go hier, tTsSp = cooling ? ulim : llim; // ... so ah doesn't waste energy matching any estimating inaccuracies. FLOAT cznC; // receives ctrl zn tu flow, re ah shutdown under ZN/ZN2 cm's - wzczSp( est, cooling, FALSE, llim, ulim, ctu, tTsSp, cznC); // determine required setpoint tTsSp. next. + wzczSp(est, cooling, FALSE, llim, ulim, ctu, tTsSp, cznC); // determine required setpoint tTsSp. next. // wz/cz/zn/zn2... if no demand under ZN or ZN2 ctrl method, go to off or fanOnly. Expected here only when ah's interact. if (cznC==0.) /* if no control zone wanted any flow (per ztuMode): if there is flow, ah may be heating - or cooling zone via supply duct gain/loss even if coils not in use, so leave on. - OBSERVED 5-16-92, file T9. Probably makes next test redundant: */ + or cooling zone via supply duct gain/loss even if coils not in use, so leave on. + OBSERVED 5-16-92, file T9. Probably makes next test redundant: */ + { #if 0 // believe not needed, or if is needed, test for tTsSp value saved b4 wzczSp call just above. 7-95. x // removing made NO DIFFERENCE in all my tests, rob 7-12-95. x if (tTsSp==tr2Nx) // if no control zone wanted air warmer/cooler than return air #endif - if (!est) // if not est'ing: interferes with turn-on, cuz cMx is still 0 on 1st call - if (CHN(ahTsSp)==C_TSCMNC_ZN) // if ZN control method (if not ZN or ZN2, ah stays on til scheduled off) - { - ahMode = ahOFF; // turn airHandler off - ctu->wantMd = ahOFF; // turn off terminal's request to be sure ah stays off til needed. needed? - flagTus(); // redo terminals in zone(s) served - return FALSE; // tell caller not to continue ah execution - } - else if (CHN(ahTsSp)==C_TSCMNC_ZN2) // if ZN2 control method - { - ahMode = ahFAN; // turn airHandler coils off, leave fan on - ctu->wantMd = ahFAN; // set request same to be sure coils stay off til needed. needed? - flagTus(); // redo terminals in zone(s) served - } // fall thru intended to return tr2Nx... in tsOut. + if (!est) // if not est'ing: interferes with turn-on, cuz cMx is still 0 on 1st call + { + if (CHN(ahTsSp)==C_TSCMNC_ZN) // if ZN control method (if not ZN or ZN2, ah stays on til scheduled off) + { + ahMode = ahOFF; // turn airHandler off + ctu->wantMd = ahOFF; // turn off terminal's request to be sure ah stays off til needed. needed? + flagTus(); // redo terminals in zone(s) served + return FALSE; // tell caller not to continue ah execution + } + else if (CHN(ahTsSp)==C_TSCMNC_ZN2) // if ZN2 control method + { + ahMode = ahFAN; // turn airHandler coils off, leave fan on + ctu->wantMd = ahFAN; // set request same to be sure coils stay off til needed. needed? + flagTus(); // redo terminals in zone(s) served + } // fall thru intended to return tr2Nx... in tsOut. + } + } break; } // switch (CHN(ahTsSp)) ts sp control method switch (cases set tTsSp) } @@ -2518,8 +2531,8 @@ void AH::wzczSp( // determine required supply temp for warmest zone/coolest z // (file SUTTER\GROFIX01.INP reproduces the case.) if (!est || tu->useAr != uNONE) // when turning on ah, when estimating, 0 is expected #endif - rer( PWRN, - (char *)MH_R1285, //"Unexpected use 0x%x for terminal [%d] for control zone [%d] for ah [%d]" + rerErOp( PWRN, + MH_R1285, //"Unexpected use 0x%x for terminal [%d] for control zone [%d] for ah [%d]" tu->useAr, tu->ss, czp->ss, ss ); continue; @@ -2785,8 +2798,8 @@ x (and increasing (heat) ts INCREASES flow) */ // endtest BOO enuf = fabs((cMx - tu->cMn) * bsF) < .04*cMx; // TRUE if have searched to resolution of 4%? of max flow if ( bestScore > GUDENUF // if have a good enough point - || enuf && bestScore > MEETTOL // if have searched enuf points and have an adequate one 5-3-95 - || bsF==0 ) // if just tested approach=0 after all other points (see below) + || (enuf && bestScore > MEETTOL) // if have searched enuf points and have an adequate one 5-3-95 + || bsF==0 ) // if just tested approach=0 after all other points (see below) { ttTsSp = bestTtTsSp; // restore best value found } // and fall thru to stop search @@ -2896,8 +2909,8 @@ x (and increasing (heat) ts INCREASES flow) */ if (!foundCzn && !est) { - char *whatSp = cooling ? "tuTC" : "tuTH"; - char *cmtx = CHN(ahTsSp)==C_TSCMNC_ZN2 ? "ZN2" + const char *whatSp = cooling ? "tuTC" : "tuTH"; + const char *cmtx = CHN(ahTsSp)==C_TSCMNC_ZN2 ? "ZN2" : CHN(ahTsSp)==C_TSCMNC_ZN ? "ZN" : CHN(ahTsSp)==C_TSCMNC_CZ ? "coolest zone" : "warmest zone"; @@ -2905,10 +2918,10 @@ x (and increasing (heat) ts INCREASES flow) */ if ( isZNorZN2 // if ZN or ZN2 ts control method (set in AH::begHour) && ctu // and control terminal not missing && !(ctu->sstat[cooling ? TU_TUTC : TU_TUTH] & FsSET) ) // and needed ctrl tu sp not set, specific msg - rer( ABT, (char *)MH_R1286, // "airHandler '%s': ahTsSp is '%s'\n" + rerErOp( ABT, MH_R1286, // "airHandler '%s': ahTsSp is '%s'\n" Name(), cmtx, ctu->Name(), whatSp ); // " but control terminal '%s' has no %s" else // else general msg - rer( PABT, (char *)MH_R1287, // "airHandler '%s': ahTsSp is '%s'\n" + rerErOp( PABT, MH_R1287, // "airHandler '%s': ahTsSp is '%s'\n" Name(), cmtx, whatSp ); // " but no control zone with terminal with %s found" } } // AH::wzczSp @@ -3043,7 +3056,7 @@ void AH::antRatTs() // anticipated return air conditions for current (changed) int md = zp->zn_md; // zone's mode, used in following checks #ifdef DEBUG if (zp->mdSeq[md] != MDS_FLOAT) - rer( PWRN, (char *)MH_R1288, Name()); // "airHandler %s: antRatTs: internal error: not float mode as expected" + rerErOp( PWRN, MH_R1288, Name()); // "airHandler %s: antRatTs: internal error: not float mode as expected" #endif DBL cMx = aCv; // max aCv: set to tu->cMxH or C in some paths below if (md > 0) // if not mode 0, there is sp mode below the float. @@ -3134,7 +3147,7 @@ x || aTs > tz && ahMode & ahHEATBIT ) ZHX *x = ZhxB.p + (tuCooling ? tu->xiArC : tu->xiArH); // point zhx in use #ifdef DEBUG2 // internal consistency check, omit in release version if (x->mda != zp->zn_md) - rer( PWRN, (char *)MH_R1289, Name(), tu->Name()); // "airHandler %s: Internal error in antRatTs: \n" + rerErOp( PWRN, MH_R1289, Name(), tu->Name()); // "airHandler %s: Internal error in antRatTs: \n" // " terminal %s is not terminal of zone's active zhx" #endif /* autoSize flow-tried-to-run-away flag: clear here if ts on "right" side of sp; @@ -3357,7 +3370,7 @@ x || aTs > tz && ahMode & ahHEATBIT ) if now larger, but not below start subhour value. ztuMode.cpp. */ } else // end of if tu->useAr...else if... - rer( PWRN, (char *)MH_R1290, // printf-->rer 10-92 + rerErOp( PWRN, MH_R1290, Name(), tu->useAr ); // "airHandler %s: Internal error in antRatTs: unexpected tu->useAr 0x%x" @@ -3579,14 +3592,14 @@ void AH::setFrFanOn( // determine fan on fraction this subhour. Call only if { // require 0 min flow cuz dunno whether to use cMxC or cMxH re cMxnx. if (ctu->cMn != 0.) // insurance check here: begHour cks vfDsMn==0. - rer( WRN, (char *)MH_R1291, ctu->Name(), ctu->cMn ); // "Terminal '%s': tuVfMn is %g, not 0, when ahFanCyles = YES" + rerErOp( WRN, MH_R1291, ctu->Name(), ctu->cMn ); // "Terminal '%s': tuVfMn is %g, not 0, when ahFanCyles = YES" cMxnx = 0.; // allow no flow; fall thru } else { #ifdef DEBUG if (!(uUseAr & (uStH|uStC|uMxH|uMxC))) // devel aid check. uUseAr is set in zRat. - rer( PWRN, (char *)MH_R1292, // "AH::setFrFanOn: airHandler '%s': unexpected 'uUseAr' 0x%x" + rerErOp( PWRN, MH_R1292, // "AH::setFrFanOn: airHandler '%s': unexpected 'uUseAr' 0x%x" Name(), uUseAr ); // after msg fall thru (assumes heating) #endif cMxnx = // flow for frFanOn=1.0 this subhour for this ah/tu is smaller of tu, sfan @@ -3598,7 +3611,7 @@ void AH::setFrFanOn( // determine fan on fraction this subhour. Call only if if (cMxnx==0. && crNx != 0.) // fatal error if there is flow when no flow is possible if (!Top.tp_sizing) /* in autoSizing can have flow here b4 tu and/or sfan cMx made non-0 to reflect the demand. Fall thru & make frFanOnNx 1. 7-95. */ - rer( PABT, (char *)MH_R1293, Name(), crNx ); //"AH::setFrFanOn: airHandler '%s': \n cMxnx is 0 but crNx is non-0: %g" + rerErOp( PABT, MH_R1293, Name(), crNx ); //"AH::setFrFanOn: airHandler '%s': \n cMxnx is 0 but crNx is non-0: %g" /* cMxnx==0 cd occur if ctu->cMxH/C scheduled 0 to disable function, and there were no leaks. But then there shd be no flow. (Only 1 tu allowed under fcc.) (Review re future infil/exfil imbalance.) */ diff --git a/src/cnausz.cpp b/src/cnausz.cpp index b7ddb9a3f..641430b7e 100644 --- a/src/cnausz.cpp +++ b/src/cnausz.cpp @@ -962,12 +962,16 @@ void AUSZ::az_p2EndTest(void* /*=pO*/) // set Top.tp_auszNotDone if another pa snprintf(doing, sizeof(doing), "%s %s", az_context, az_what); if (az_active && az_px) + { if (!Top.tp_auszNotDone || Top.verbose > 3) + { if (az_orig != 0.f) - { float fChange = fabs((*az_px - az_orig) / az_orig); + { + float fChange = fabs((*az_px - az_orig) / az_orig); if (fChange > Top.auszTol2) // if value changed by > 1/2 tolerance - { if (Top.verbose > 2) - screen( 0, " %s: %8g %8g not done: changed", doing, *az_px, az_orig); + { + if (Top.verbose > 2) + screen(0, " %s: %8g %8g not done: changed", doing, *az_px, az_orig); az_NotDone(); return; // do another pass thru design days } @@ -975,12 +979,14 @@ void AUSZ::az_p2EndTest(void* /*=pO*/) // set Top.tp_auszNotDone if another pa else if (*az_px) // if went from 0 to non-0 { if (Top.verbose > 2) // believe redudant - not called if not - screen( 0, " %s: %8g %8g not done: 0 became non-0", doing, *az_px, az_orig); + screen(0, " %s: %8g %8g not done: 0 became non-0", doing, *az_px, az_orig); az_NotDone(); return; // do another pass thru design days } else if (Top.verbose > 4) - screen( 0, " %s: %8g %8g done", doing, *az_px, az_orig); + screen(0, " %s: %8g %8g done", doing, *az_px, az_orig); + } + } // in addition AH::, TU::, etc object member functions test for oversize capacities: plr too small. } // AUSZ::az_p2EndTest diff --git a/src/cncoil.cpp b/src/cncoil.cpp index 94ec6e317..1cf0144a3 100644 --- a/src/cncoil.cpp +++ b/src/cncoil.cpp @@ -128,10 +128,10 @@ RC AHHEATCOIL::setup( // set up heat coil per current capacity in record -- ini cdm = (in47 / pCyc47 - cd - (1. - cd) * tmCycPer / tmCycOn) / (in47 / pCyc47 - 1.); // /0 prot needed?? if (cdm < 0. || cdm >= 1.0) - rc |= ah->oer((char*)MH_S0673, cdm); /* "cdm (%g) not in range 0 <= cdm < 1\n" + rc |= ah->oer(MH_S0673, cdm); /* "cdm (%g) not in range 0 <= cdm < 1\n" " (cdm is ahpCd modified internally to remove crankcase heater effects)" */ else if (cdm > cd) - ah->oWarn((char*)MH_S0674, cdm, cd); /* "cdm (%g) not <= ahpCd (%g): does this mean bad input?\n" + ah->oWarn(MH_S0674, cdm, cd); /* "cdm (%g) not <= ahpCd (%g): does this mean bad input?\n" " (cdm is ahpCd modified internally to remove crankcase heater effects)" */ } else @@ -153,7 +153,7 @@ RC AHHEATCOIL::setup( // set up heat coil per current capacity in record -- ini cap35 = terp35 * fd35Df; // default to interpolated value times frost/defrost degradation factor else // ahpCap35 given (not expected) if (cap35 > terp35) - rc |= ah->ooer(AH_AHHC + AHHEATCOIL_CAP35, (char*)MH_S0672, cap35, terp35, cap17, captRat); + rc |= ah->ooer(AH_AHHC + AHHEATCOIL_CAP35, MH_S0672, cap35, terp35, cap17, captRat); /* "ahpCap35 (%g) cannot be > proportional value (%g) between \n" " ahpCap17 (%g) and ahhcCaptRat (%g) -- \n" " that is, frost/defrost effects cannot increase capacity." */ @@ -207,7 +207,7 @@ RC COOLCOIL::reSetup( // re set up coil for changed total capacity (.captRat) break; // dxSetup is called after switch. case C_COILTYCH_CHW: - return rer( PWRN, "COOLCOIL::reSetup: cannot autoSize CHW coils."); // insurance + return rerErOp( PWRN, "COOLCOIL::reSetup: cannot autoSize CHW coils."); // insurance /* CHW issues: Does not use captRat. I guess use a different AUTOSIZE input and different ccAs.px. size-dependent inputs: gpmDs, vfR. Is gpmDs what we autoSize? @@ -353,7 +353,7 @@ BOO AH::doCoils( // compute tex1 and aWs that applicable coil can and will pro && ahMode & ahHEATBIT // and ahMode allows heating (both always ok except ZN or ZN2 ts cm) #if 1 // 10-96 for 0 autoSized coil size && ( ahhc.captRat != 0 // and either the coil has non-0 capacity (autoSize can make 0, 10-96) - || Top.tp_sizing && hcAs.az_active ) ) // or is now being autoSized + || (Top.tp_sizing && hcAs.az_active) ) ) // or is now being autoSized #endif { // heat coil modelling @@ -403,7 +403,7 @@ BOO AH::doCoils( // compute tex1 and aWs that applicable coil can and will pro && !coilLockout // and coil not locked out by full open non-integrated economizer #if 1 // 10-96 for 0 autoSize coil size results && ( ahcc.captRat != 0 // and either coil has non-0 capacity (autoSizing can leave 0, 10-96) - || Top.tp_sizing && ccAs.az_active // or is now being autoSized + || (Top.tp_sizing && ccAs.az_active) // or is now being autoSized || ahcc.coilTy==C_COILTYCH_CHW ) ) // or is a CHW coil (does not use captRat, is not autoSizable 10-96) #endif { @@ -645,7 +645,7 @@ BOO AH::doHWCoil( // compute tex that HW heating coil can and will produce if (!hp->hpOn()) // if heatplant is off (turns it on if scheduled AVAIL) (cnhp.cpp) { //rWarn? - rer( (char *)MH_R1310, // "AirHandler %s's heat coil is scheduled on, \n but heatPlant %s is scheduled off." + rer( MH_R1310, // "AirHandler %s's heat coil is scheduled on, \n but heatPlant %s is scheduled off." Name(), hp->Name() ); ahhc.co_capMax = 0.; // coil capac is 0 when plant is off. fall thru to set tex, ahhc.q, coilLimited. // should coilLimited be TRUE when plant OFF? probably not, as not on when coil off, but unimportant now since error 9-92. @@ -1000,21 +1000,21 @@ void AHHEATCOIL::doAhpHeat( // execute heat pump heating mode model // debug aid checks. display only 1st message: other errors might be consequential, or vbls unset. if (rootArg < 0.) // if wd have gotten sqrt neg # runtime lib err - rer( (char *)MH_R1341, ah->Name(), // "airHandler %s: Internal error in doAhpCoil: \n" + rer( MH_R1341, ah->Name(), // "airHandler %s: Internal error in doAhpCoil: \n" rootArg, // " arg to sqrt (%g) for quad formula hlf not >= 0.\n" cdm, qDfrhCon, capCon, qWant, // " cdm %g qDfrhCon %g capCon %g qWant %g\n" A, B, C ); // " A %g B %g C %g\n" else if (hlf <= 0. || hlf > Top.hiTol*qWant/capCon) // hlf excludes dfr rh --> less than qWant/capCon. - rer( (char *)MH_R1342, ah->Name(), // "airHandler %s: Internal error in doAhpCoil: \n" + rer( MH_R1342, ah->Name(), // "airHandler %s: Internal error in doAhpCoil: \n" hlf, qWant/capCon ); // " hlf (%g) not in range 0 < hlf <= qWant/capCon (%g)" else if (plf <= 0.) // prevent /0, report < 0 (bug) - rer( (char *)MH_R1343, ah->Name(), plf); // "airHandler %s: Internal error in doAhpCoil: \n" + rer( MH_R1343, ah->Name(), plf); // "airHandler %s: Internal error in doAhpCoil: \n" // " plf (%g) not > 0" else if (frCprOn > frFanOn * Top.hiTol) // cpr shd run < fan ( >= uses other case above) - rer( (char *)MH_R1344, ah->Name(), frCprOn, frFanOn); // "airHandler %s: Internal error in doAhpCoil: \n" + rer( MH_R1344, ah->Name(), frCprOn, frFanOn); // "airHandler %s: Internal error in doAhpCoil: \n" // " frCprOn (%g) > frFanOn (%g)" else if (RELCHANGE( q, qWant) > Top.relTol) // q should come out heat desired - rer( (char *)MH_R1345, ah->Name(), q, qWant); // "airHandler %s: Internal error in doAhpCoil: \n" + rer( MH_R1345, ah->Name(), q, qWant); // "airHandler %s: Internal error in doAhpCoil: \n" // " q = %g but qWant is %g -- should be the same" } #else//worked in brief tests, but did not relate to flow or frfanOn -- runs cpr more than caller runs fan, etc. @@ -1365,7 +1365,7 @@ BOO AH::doChwCoil( // compute tex, etc, that CHW cooling coil can and will prod if (!cp->cpOn()) // if coolplant is off (turns it on if scheduled AVAIL) (cncp.cpp) { //rWarn? - rer( (char *)MH_R1311, // "AirHandler %s's cool coil is scheduled on, \n but coolPlant %s is scheduled off." + rer( MH_R1311, // "AirHandler %s's cool coil is scheduled on, \n but coolPlant %s is scheduled off." Name(), cp->Name() ); //plant off. set output variables for plant off, and return. doCoils has done: tex=ten, wex=wen, chwQ=0. //should coilLimited be TRUE when plant OFF? probably not, as not on when coil off, but unimportant now since error 9-92. @@ -1575,7 +1575,7 @@ x coilIsWet = 0; // means coil is dry as model does not compute flow (conservative) */ // error if water clearly frozen (eg when texWant < 32 cuz of hi dT of following poorly-spec'd drawthru fan, 12-3-92) if (ahcc.tr < 32. && cp->cpTs >= 32.) // but if entering "water" temp < 32 (assume cncp.cpp msg'd), omit per-coil msg here. - rer( (char *)MH_R1340, // "airHandler %s: frozen CHW cooling coil: leaving water temperature computed as %g F or less" + rer( MH_R1340, // "airHandler %s: frozen CHW cooling coil: leaving water temperature computed as %g F or less" Name(), ahcc.tr ); // conditionally call-flag coolplant serving coil @@ -1641,7 +1641,7 @@ RC COOLCOIL::dxFlowCheck(AH* ah, bool ausz) // check for reasonable flow rate a if ( 1.251 * vfR < ah->sfan.vfDs || vfR > 1.251 * ah->sfan.vfDs ) // if supply fan rating 25% different from coil rating flow { - ah->oWarn((char *)MH_S0647, /* "%scoiling coil rating air flow (%g) differs \n" + ah->oWarn(MH_S0647, /* "%scoiling coil rating air flow (%g) differs \n" " from supply fan design flow (%g) by more than 25%" */ vfRgiven || perTonGiven ? "" : "defaulted ", // NUMS no use moved from cncult5. vfRperTon); @@ -1700,7 +1700,7 @@ x DBL tenR = dsTDbEn; // entering temp: rated x DBL wenR = psyHumRat1( tenR, dsTWbEn); // entering w. w for drybulb, wetbulb, lib\psychro2.cpp. x DBL henR = psyEnthalpy( tenR, wenR); // entering enthalpy x if (henR > psySatEnthalpy(tenR)) -x return oer( ah, (char *)MH_R1312); // "DX coil rated entering conditions are supersaturated." +x return oer( ah, MH_R1312); // "DX coil rated entering conditions are supersaturated." x x x// exit state at rated entry conditions and full rated load @@ -1718,7 +1718,7 @@ x// exit state at rated entry conditions and full rated load DBL henR = psyEnthalpy( tenR, wenR); // entering enthalpy if (henR > psySatEnthalpy(tenR)) { - ah->oer( (char *)MH_R1312); // "DX coil rated entering conditions are supersaturated." + ah->oer( MH_R1312); // "DX coil rated entering conditions are supersaturated." psyElevation(Top.elevation); // restore altitude in psychro package to building site elevation return RCBAD; // bad return } @@ -1741,7 +1741,7 @@ x// exit state at rated entry conditions and full rated load if (hexR > hSatR) // if exit state not in moist air region of psychro chart { ah->oer( // issue message, stop run, do not attempt to continue setup - (char *)MH_R1313, //"DX coil capacity specifications yield supersaturated air at coil exit:\n" + MH_R1313, //"DX coil capacity specifications yield supersaturated air at coil exit:\n" hexR, //" full-load exit enthalpy (%g) greater than saturated air enthalpy\n" hSatR, texR); //" (%g) at full-load exit temp (%g) at rated conditions." psyElevation(Top.elevation); // restore altitude in psychro package to building site elevation @@ -1771,13 +1771,13 @@ x// exit state at rated entry conditions and full rated load DBL errHi = ENTHERR(hi), errLo = ENTHERR(lo); if (errHi <= 0) // if solution > ten, ten is oversaturated, don't bother to search { - ah->oer( (char *)MH_R1314 ); /* "Program Error: DX coil effective temp (te) at rated conditions\n" - " seems to be greater than entering air temp" + ah->oer( MH_R1314 ); // "Program Error: DX coil effective temp (te) at rated conditions\n" + // " seems to be greater than entering air temp" psyElevation(Top.elevation); // restore altitude in psychro package to building site elevation return RCBAD; // bad return } if (errLo > 0) - { oer( ah, (char *)MH_R1315); /* "DX coil effective temperature (intersection of coil process line with\n" + { ah->oer( MH_R1315); /* "DX coil effective temperature (intersection of coil process line with\n" " saturation line on psychro chart) at rated conditions is less than 0F.\n" " Possibly your ahccCaptRat is too large relative to ahccCapsRat." */ psyElevation(Top.elevation); // restore altitude in psychro package to building site elevation @@ -1804,7 +1804,7 @@ x// exit state at rated entry conditions and full rated load } if (iter > MAXITER) { - err( PWRN, (char *)MH_R1316, // "airHandler '%s': \n" + err( PWRN, MH_R1316, // "airHandler '%s': \n" ah->Name(), errTe ); // " DX coil setup effective point search convergence failure\n" break; // " errTe=%g" } @@ -1815,7 +1815,7 @@ x// exit state at rated entry conditions and full rated load efecOR = (tenR - texR)/(tenR - teR); // definition of effectiveness if (efecOR > 1. || efecOR <= 0.) { - ah->oer( (char *)MH_R1317, efecOR ); // "Program Error: DX coil effectiveness %g not in range 0 to 1" + ah->oer( MH_R1317, efecOR ); // "Program Error: DX coil effectiveness %g not in range 0 to 1" psyElevation(Top.elevation); // restore altitude in psychro package to building site elevation return RCBAD; // bad return } @@ -1905,7 +1905,7 @@ x } // msg issued in coilsEndSubhr if xLGain nz at ah-tu convergence. #else // old 10-96 x // if entering air supersaturated, message & do nothing x if (wen > psyHumRat3(ten0)) // (-1 for ten0 > boiling not expected) -x { rer( (char *)MH_R1320, // "airHandler '%s': Air entering DX cooling coil is supersaturated:\n" +x { rer( MH_R1320, // "airHandler '%s': Air entering DX cooling coil is supersaturated:\n" x Name(), ten0, wen); // " ten = %g wen = %g. Coil model won't work." x return; // caller has set tex=ten, wex=wen for 0 coil output: ahcc.q = .co_plr = 0. x } @@ -1963,7 +1963,7 @@ x } Will be > 1 if flow > rated flow or air denser. */ ahcc.efecO = 1. - exp(-ahcc.ntuR * pow( plrM, double( ahcc.k1))); // ntu = ntuR * plrM^k1. k1 is negative. mbr for probing. if (ahcc.efecO <= 0. || ahcc.efecO > 1.) - rer( (char *)MH_R1321, ahcc.efecO); // "airHandler '%s': DX coil effectiveness %g not in range 0 to 1" + rer( MH_R1321, ahcc.efecO); // "airHandler '%s': DX coil effectiveness %g not in range 0 to 1" //--- DX coil capacity and full-load exit state for current entering air conditions @@ -2011,11 +2011,11 @@ x } if (RELCHANGE( he, he1) > Top.relTol/5.) // /20 gets messages from cs=1. Is psyTWSat() limited. // /10 gets messages for CBECC cases, 5-2022 // /5 seems tight enough? - RER( (char *)MH_R1322, // "airHandler '%s' DX coil inconsistency:\n" - Name(), he, te,we, he1, wena, (INT)cs1 ); // " he is %g but h(te=%g,we=%g) is %g. wena=%g. cs1=%d" + RER( MH_R1322, // "airHandler '%s' DX coil inconsistency:\n" + Name(), he, te,we, he1, wena, cs1 ); // " he is %g but h(te=%g,we=%g) is %g. wena=%g. cs1=%d" #endif // endtest: done if line horizontal, or, on first iteration, slopes down toward effective point - if ( !nIter && we <= wena || fabs(we-wena) < .000003 // TESTED 5-92: .000001 vs .00001 adds but 1 iter. + if ( (!nIter && we <= wena) || fabs(we-wena) < .000003 // TESTED 5-92: .000001 vs .00001 adds but 1 iter. + .0000003*nIter ) /* get looser cuz believe TLVF.INP nonCvg 8-28-95 due to precision limits eg in psychro. */ break; @@ -2032,7 +2032,7 @@ x } } if (nIter > MAXITER1) // non-convergence check & msg, while max info avail { - rer( (char *)MH_R1323, Name(), // "airHandler '%s':\n" + rer( MH_R1323, Name(), // "airHandler '%s':\n" // " DX coil full-load exit state convergence failure.\n" ten0, wen0, ahcc.plrVf, // " entry conditions: ten=%g wen=%g plrVf=%g\n" te, we, we1, // " unfinished results: te=%g we=%g last we=%g\n" @@ -2145,7 +2145,7 @@ x } // " capt = %g, but menFOn*(hexf-hen) = %g.\n" // " wen=%g wena=%g we=%g wexf=%g; ten=%g texf=%g; cs=%d,%d\n" // " hexf=%g hexf2=%g hen=%g hen2=%g (hena-hen)*menFOn=%g", - // Name(), ahcc.capt, capt2, wen0, wena, we, wexf, ten0, texf, (INT)cs1,(INT)cs2, + // Name(), ahcc.capt, capt2, wen0, wena, we, wexf, ten0, texf, cs1,cs2, // hexf, hexf2, ahcc.hen, hen2, capt3, hh ); //} @@ -2155,7 +2155,7 @@ x } // RER( "airHandler '%s' DX cool coil caps-capt inconsistency: \n" // " capt = %g, but caps=%g + 1061*menFOn*(wexf-wen)=%g = %g.\n" // " wen=%g wena=%g we=%g wexf=%g; ten=%g texf=%g; cs=%d,%d", - // Name(), ahcc.capt, ahcc.caps, capl2, ahcc.caps + capl2, wen0, wena, we, wexf, ten0, texf, (INT)cs1,(INT)cs2 ); + // Name(), ahcc.capt, ahcc.caps, capl2, ahcc.caps + capl2, wen0, wena, we, wexf, ten0, texf, cs1,cs2 ); // restore if slopee-slopef test gives messages //if (te != ten0) @@ -2164,7 +2164,7 @@ x } // RER( "airHandler '%s' DX cool coil inconsistency: \n" // " efecO = %g but (texf - ten)/(te - ten) = %g.\n" // " wen=%g wena=%g we=%g wexf=%g; ten=%g texf=%g; cs=%d,%d", - // Name(), ahcc.efecO, efecT, wen0, wena, we, wexf, ten0, texf, (INT)cs1,(INT)cs2 ); + // Name(), ahcc.efecO, efecT, wen0, wena, we, wexf, ten0, texf, cs1,cs2 ); //} // restore if slopee-slopef test gives messages @@ -2174,7 +2174,7 @@ x } // RER( "airHandler '%s' DX cool coil inconsistency: \n" // " efecO = %g but (wexf - wen)/(we - wen) = %g. \n" // " wen=%g wena=%g we=%g wexf=%g; ten=%g texf=%g; cs=%d,%d", - // Name(), ahcc.efecO, efecW, wen0, wena, we, wexf, ten0, texf, (INT)cs1,(INT)cs2 ); + // Name(), ahcc.efecO, efecW, wen0, wena, we, wexf, ten0, texf, cs1,cs2 ); //} if ( we <= wen0 // if we > wen, wexf == wen, slopes not ==. @@ -2183,10 +2183,10 @@ x } DBL slopee = (we - wen0)/(te - ten0); DBL slopef = (wexf - wen0)/(texf - ten0); if (RELCHANGE( slopef, slopee) > Top.relTol/10.) - RER( (char *)MH_R1324, Name(), // "airHandler '%s' DX cool coil inconsistency: \n" + RER( MH_R1324, Name(), // "airHandler '%s' DX cool coil inconsistency: \n" slopef, slopee, // " slopef = %g but slopee = %g.\n" wen0, wena, we, wexf, // " wen=%g wena=%g we=%g wexf=%g;\n" - ten0, texf, (INT)cs1,(INT)cs2 ); // " ten=%g texf=%g; cs=%d,%d" + ten0, texf, cs1,cs2 ); // " ten=%g texf=%g; cs=%d,%d" } #endif @@ -2254,7 +2254,7 @@ x } consistency msgs (b4 tolerances increased) */ if (nIter1 > MAXITER2) // non-convergence check & msg { - rer( (char *)MH_R1325, Name(), // "airHandler '%s':\n" + rer( MH_R1325, Name(), // "airHandler '%s':\n" // " DX coil exit humidity ratio convergence failure.\n" ten0, wen0, tex, // " inputs: ten=%g wen=%g tex=%g\n" wex, wexWas, // " unfinished result: wex=%g last wex=%g\n" @@ -2281,40 +2281,40 @@ x } // actual significance level is maybe .01 or .1. */ { if (ahcc.capt >= 0.) - RER( (char *)MH_R1326, Name(), ahcc.capt); // "airHandler %s: Inconsistency #1: total capacity (%g) not negative" + RER( MH_R1326, Name(), ahcc.capt); // "airHandler %s: Inconsistency #1: total capacity (%g) not negative" if (ahcc.caps >= 0.) - RER( (char *)MH_R1327, Name(), ahcc.caps); // "airHandler %s: Inconsistency #1a: sensible capacity (%g) not negative" + RER( MH_R1327, Name(), ahcc.caps); // "airHandler %s: Inconsistency #1a: sensible capacity (%g) not negative" if (ahcc.caps < ahcc.capt - .01) - RER( (char *)MH_R1328, Name(), ahcc.caps, ahcc.capt); // "airHandler %s: Inconsistency #2: sensible capacity (%g)\n" + RER( MH_R1328, Name(), ahcc.caps, ahcc.capt); // "airHandler %s: Inconsistency #2: sensible capacity (%g)\n" // " larger than total capacity (%g)" if (wex > wen0 + .000001) - RER( (char *)MH_R1329, Name(), wex, wen0); // "airHandler %s: Inconsistency #3: wex (%g) > wen (%g)" + RER( MH_R1329, Name(), wex, wen0); // "airHandler %s: Inconsistency #3: wex (%g) > wen (%g)" if (ten0 < tex - .00001) - RER( (char *)MH_R1330, Name(), tex, ten0); // "airHandler %s: Inconsistency #4: tex (%g) > ten (%g)" + RER( MH_R1330, Name(), tex, ten0); // "airHandler %s: Inconsistency #4: tex (%g) > ten (%g)" if (teCOn < te - .040) /* .0001 ok most files 3..10-92; larger seen with sutter\SA11B13.INP. .002 is 4e-5 relative, ok cuz a psy fcn (psyHumRat3) is used re teCOn. -->.003 after seeing .0022 in AUSZ testing 7-7-95. -->.005 after seeing .0046 in saturation testing (T17) rob 5-97. -->.040 after Bruce got a .01 in one of his tests. */ - RER( (char *)MH_R1331, Name(), teCOn, te, // "airHandler %s: Inconsistency #5: teCOn (%g) < te (%g)\n" + RER( MH_R1331, Name(), teCOn, te, // "airHandler %s: Inconsistency #5: teCOn (%g) < te (%g)\n" wen0, wena, we, wexf, ten0, texf, // " wen=%g wena=%g we=%g wexf=%g; ten=%g texf=%g\n" ahcc.qs, ahcc.ql, ahcc.q, // " ql=%g qs=%g q=%g; plr=%g plrSens=%g; case=%d,%d" - ahcc.co_plr, ahcc.plrSens, (INT)cs1,(INT)cs2 ); + ahcc.co_plr, ahcc.plrSens, cs1,cs2 ); if (weSatCOn < we - .000010) /* .0000001 ok most files 3..10-92; larger seen with sutter\SA11B13.INP; .0000012 seen in testing condensation 5-97 (humtst2.inp). .0000025 produced by Bruce, 6-97. */ - RER( (char *)MH_R1332, Name(), weSatCOn, we, // "airHandler %s: Inconsistency #6: weSatCOn (%g) < we (%g)\n" + RER( MH_R1332, Name(), weSatCOn, we, // "airHandler %s: Inconsistency #6: weSatCOn (%g) < we (%g)\n" wen0, wena, we, wexf, ten0, texf, // " wen=%g wena=%g we=%g wexf=%g; ten=%g texf=%g\n" ahcc.qs, ahcc.ql, ahcc.q, // " ql=%g qs=%g q=%g; plr=%g plrSens=%g; case=%d,%d" - ahcc.co_plr, ahcc.plrSens, (INT)cs1,(INT)cs2 ); + ahcc.co_plr, ahcc.plrSens, cs1,cs2 ); if (wex < wen0) { if (wex < weSatCOn - .000001) - RER( (char *)MH_R1333, Name(), wex, weSatCOn); // "airHandler %s: Inconsistency #7: wex (%g) < weSatCOn (%g)" + RER( MH_R1333, Name(), wex, weSatCOn); // "airHandler %s: Inconsistency #7: wex (%g) < weSatCOn (%g)" if (wex < we - .00001) - RER( (char *)MH_R1334, Name(), wex, we); // "airHandler %s: Inconsistency #8: wex (%g) < we (%g)" + RER( MH_R1334, Name(), wex, we); // "airHandler %s: Inconsistency #8: wex (%g) < we (%g)" if (wex < wexf - .00001) - RER( (char *)MH_R1335, Name(), wex, wexf); // "airHandler %s: Inconsistency #9: wex (%g) < wexf (%g)" + RER( MH_R1335, Name(), wex, wexf); // "airHandler %s: Inconsistency #9: wex (%g) < wexf (%g)" } } #endif @@ -2400,9 +2400,9 @@ x if (coilUsed==cuHEAT) // if heat coil used, 12-3-92 case C_COILTYCH_OIL: // oil furnace "coil" case C_COILTYCH_GAS: // gas furnace "coil" // runtime checks cuz exprs may be allowed for captRat, eirRat eg re flue loss simulation 7-6-92. - if (ahhc.captRat <= 0) rer( (char *)MH_R1336, // "airHandler '%s':\n" + if (ahhc.captRat <= 0) rer( MH_R1336, // "airHandler '%s':\n" Name(), ahhc.captRat ); // " heat coil capacity 'ahhcCaptRat' (%g) not > 0" - if (ahhc.eirRat < 1.0) rer( (char *)MH_R1337, // "airHandler '%s':\n" + if (ahhc.eirRat < 1.0) rer( MH_R1337, // "airHandler '%s':\n" Name(), ahhc.eirRat ); // " heat coil full-load energy input ratio 'ahhcEirR' (%g) not > 1.0" // optional DOE2 gas/oil furnace part-load flueLoss. Skip for speed if none (default 0; .flueLoss 0'd above). @@ -2446,7 +2446,7 @@ x if (coilUsed==cuHEAT) // if heat coil used, 12-3-92 //case C_COILTYCH_NONE: // if no coil, shd be no q default: - rer( PWRN, (char *)MH_R1338, ahhc.coilTy); // "cncoil.cpp:AH::coilsEndSubhr: Bad heat coil type 0x%x" + rerErOp( PWRN, MH_R1338, ahhc.coilTy); // "cncoil.cpp:AH::coilsEndSubhr: Bad heat coil type 0x%x" } //if (ahhc.q) add /0 protection add if need found ahhc.eir = (ahhc.p + ahhc.pSh + cch.p)/ahhc.q; /* energy input ratio: input/output: @@ -2497,7 +2497,7 @@ x if (coilUsed==cuHEAT) // if heat coil used, 12-3-92 //case C_COILTYCH_NONE: // if no coil, expect no q --> don't get here. default: - rer( PWRN, (char *)MH_R1339, ahcc.coilTy); // "cncoil.cpp:AH::coilsEndSubhr: Bad cool coil type 0x%x" + rerErOp( PWRN, MH_R1339, ahcc.coilTy); // "cncoil.cpp:AH::coilsEndSubhr: Bad cool coil type 0x%x" break; case C_COILTYCH_DX: // DX coil @@ -2658,7 +2658,7 @@ x Only one terminal (enforced in setup): allowing addl terminals would r x { x TU * ctu = &TuB.p[ahCtu]; // ah's control terminal x if (!ahCtu) // ** enforce in cncult5, unless fcc becomes run-variable -x rer( PABT, "fanCyCoil for airHandler '%s' is YES but no ahCtu has been given", Name()); // no return +x rerErOp( PABT, "fanCyCoil for airHandler '%s' is YES but no ahCtu has been given", Name()); // no return x x cPoss = min( ctu->cMxC, sfan.cMx); // ruling max flow is smaller of tu's current cool max and sfan's (with overrun) x // tu->cMxC is set in AH::ahVshNLims; sfan->cMx is set in FAN::pute. @@ -2666,9 +2666,9 @@ x // sfan->pute is called AFTER coils if blowthru; xtra iter4Fs conv x // add setup code to insure sfan.cMx is non-0 even for blowthru fan x // cPoss is used below and in cnah:AH::setTsSp1; is actual fan-on flow here. x -x if (cPoss==0.) rer( PABT, "doElecCoolCoil: cPoss is 0"); // prevent /0; remove check here when insured elsewhere. +x if (cPoss==0.) rerErOp( PABT, "doElecCoolCoil: cPoss is 0"); // prevent /0; remove check here when insured elsewhere. x -x if (cen > cPoss) rWarn( PWRN, "doElecCoolCoil: cen (%g) > cPoss (%g)", cen, cPoss); // tolerance?? +x if (cen > cPoss) rWarnErOp( PWRN, "doElecCoolCoil: cen (%g) > cPoss (%g)", cen, cPoss); // tolerance?? x // dev aid warning cuz possible balance problems if cen/frFanOn != cPoss ?? x x frFanOn = min( 1.0, cen/cPoss); // fraction on = fraction of ah poss output needed = requested flow / ah max flow diff --git a/src/cncp.cpp b/src/cncp.cpp index edeba912d..353d5348e 100644 --- a/src/cncp.cpp +++ b/src/cncp.cpp @@ -99,8 +99,8 @@ RC COOLPLANT::cpEstimate(BOO wantCool /*=FALSE*/) // estimate a coolPlant: set // changes to towerplant: not known till cpCompute done. if ( cpMode != cpModeWas // if mode changed - || CHN(cpSched)!=C_OFFAVAILONVC_OFF // if supply temp changed when not off & not avail - && ABSCHANGE( cpTs, cpTsEstPr) >= Top.absTol ) // .. + || (CHN(cpSched)!=C_OFFAVAILONVC_OFF // if supply temp changed when not off & not avail + && ABSCHANGE( cpTs, cpTsEstPr) >= Top.absTol) ) // .. { cpPtf++; // say compute this coolplant. Top.cpKf set above. for (AH* ah=NULL; nxAh(ah); ) // loop AH's with CHW coils served by this COOLPLANT @@ -199,7 +199,7 @@ RC COOLPLANT::cpCompute() // conditionally compute coolplant { // check hourly variable ts setpoint (do in a begHour fcn if one is added). 12-3-92. if (cpTsSp < 32.) - rer( (char *)MH_R1360, Name(), cpTsSp); // "COOLPLANT '%s': cpTsSp (%g F) is below freezing" + rer( MH_R1360, Name(), cpTsSp); // "COOLPLANT '%s': cpTsSp (%g F) is below freezing" #undef DUMMYCHW // also independenly definable in cncoil.cpp, cntp.cpp. #ifdef DUMMYCHW // for simple computation model for initial test of interfaces & overall program logic @@ -287,7 +287,7 @@ RC COOLPLANT::cpCompute() // conditionally compute coolplant // move following check to endSubhr fcn, if one is added, for fewer messages. if ( tr < 32. // if return "water" is frozen (lo texWant, CHW coils heating cold air) && cpTs >= 32. ) // but omit msg if supplied "water" frozen (cpTsSp < 32 msg'd above) - rer( (char *)MH_R1361, Name(), // "COOLPLANT '%s': \n" + rer( MH_R1361, Name(), // "COOLPLANT '%s': \n" tr ); // " return water temperature (%g F) from coils is below freezing" // chillers input power and heat to cooling towers, for ON chillers of ON coolplant @@ -387,8 +387,8 @@ DBL/*POWER*/ COOLPLANT::capStg() // power of stage .stgi incl pump heat at curre ch->chCapDs * ch->chPyCapT.val( cpTs, tCnd); /* design cap adjusted with poly for supply & condenser temps. cap, chCapDs negative. */ if (cap > 0.) // positive capacity may screw up calling code - rer( (char *)MH_R1362, - Name(), INT(stgi+1), -(cap - stgPPQ[stgi]), // "COOLPLANT '%s' stage %d chiller capacity (%g)\n" + rer( MH_R1362, + Name(), stgi+1, -(cap - stgPPQ[stgi]), // "COOLPLANT '%s' stage %d chiller capacity (%g)\n" stgPPQ[stgi], cpTs, tCnd ); // " is less than pump heat (%g) (ts=%g, tCnd=%g)" return cap; } // COOLPLANT::capStg @@ -414,7 +414,7 @@ RC CHILLER::endSubhr() DBL chTs = cp->tr + q / chpp.mw; // this chiller output temp assuming no flow overrun (q negative) if ( chTs < 32. // if frozen && cp->cpTs >= 32. ) // but overall coolplant not frozen (that yields msg in cpCompute) - rer( (char *)MH_R1363, Name(), cp->Name(), chTs); /* "CHILLER '%s' of COOLPLANT '%s': \n" + rer( MH_R1363, Name(), cp->Name(), chTs); /* "CHILLER '%s' of COOLPLANT '%s': \n" " delivered water temp (%g F) is below freezing" */ } else // chiller is off @@ -469,8 +469,8 @@ BOO COOLPLANT::nxChStg( CHILLER *&ch, int _stgi /*=-1*/ ) // first/next chille if (_stgi < 0) _stgi = this->stgi; // default to current stage if (_stgi < 0 || _stgi >= NCPSTAGES) // if bad arg given or stgi member not yet set { - rer( PWRN, (char *)MH_R1364, // "COOLPLANT %s: bad stage number %d: not in range 1..%d" - Name(), (INT)_stgi, INT(NCPSTAGES-1) ); // NCPSTAGES: rccn.h. + rerErOp( PWRN, MH_R1364, // "COOLPLANT %s: bad stage number %d: not in range 1..%d" + Name(), _stgi, NCPSTAGES-1 ); // NCPSTAGES: rccn.h. return FALSE; } diff --git a/src/cncult.cpp b/src/cncult.cpp index e76cc9a0c..3367f8b43 100644 --- a/src/cncult.cpp +++ b/src/cncult.cpp @@ -96,18 +96,20 @@ LOCAL RC FC lrStarCkf([[maybe_unused]] CULT *c, /* LR* */ void *p, [[maybe_unuse // error if one only of framing fraction and framing material given if (!defTyping) // omit msg when defining a type: missing info can be given in type use. - if (fs[ LR_FRMMATI ] & FsSET) // if framing material given + { + if (fs[LR_FRMMATI] & FsSET) // if framing material given { - if ( !(fs[ LR_FRMFRAC ] & FsSET) ) // if frame fraction not given + if (!(fs[LR_FRMFRAC] & FsSET)) // if frame fraction not given rc |= P->oer( // issue object error message, cul.cpp - (char *)MH_S0400 ); // handle of msg "lrFrmMat given but lrFrmFrac omitted" (msghans.h) + MH_S0400); // handle of msg "lrFrmMat given but lrFrmFrac omitted" (msghans.h) } else // lrFrmMat not given { - if (fs[ LR_FRMFRAC ] & FsVAL) // if frame fraction given and has been stored + if (fs[LR_FRMFRAC] & FsVAL) // if frame fraction given and has been stored if (P->lr_frmFrac > 0.f) // no message if 0 value - rc |= P->oer( (char *)MH_S0401, P->lr_frmFrac ); // "lrFrmFrac=%g given but lrFrmMat omitted" + rc |= P->oer(MH_S0401, P->lr_frmFrac); // "lrFrmFrac=%g given but lrFrmMat omitted" } + } return rc; } // lrStarCkf @@ -154,12 +156,12 @@ LOCAL RC FC conStarCkf([[maybe_unused]] CULT *c, /*CON* */ void *p, [[maybe_unus { if (n) // if 1 or more layers given // skip if defTyping? COULD delete layers later... unlikely. - rc |= P->oer( (char *)MH_S0402); // "Cannot give both conU and layers". Issue object error message, cul.cpp + rc |= P->oer( MH_S0402); // "Cannot give both conU and layers". Issue object error message, cul.cpp } else // conU not given if (n==0) // if no layers given if (!defTyping) // not error during type define: conU/layers can be given when type used. - rc |= P->oer( (char *)MH_S0403); // "Neither conU nor any layers given" + rc |= P->oer( MH_S0403); // "Neither conU nor any layers given" return rc; #undef P @@ -335,7 +337,7 @@ LOCAL RC sgStarPrf([[maybe_unused]] CULT *c, /*SGDIST* */ void *p, /*SFI* */ voi // error message if too many if (n > HSMXSGDIST) // HSMXSGDIST (cnguts.h) = 8, 2-95. - return ((record*)p)->oer( (char *)MH_S0404, (INT)HSMXSGDIST); // "More than %d sgdist's for same window" + return ((record*)p)->oer( MH_S0404, HSMXSGDIST); // "More than %d sgdist's for same window" return RCOK; } // sgStarPrf @@ -411,10 +413,9 @@ static CULT shT[] = //------------------------------------- SHADE command table */ //----------------------------------------------------------- RC SFI::sf_CkfWINDOW( - int options) // option bits - // 1: caller is sf_TopSf1 (as opposed to CULT) + [[maybe_unused]] int options) // option bits + // 1: caller is sf_TopSf1 (as opposed to CULT) { - options; RC rc = RCOK; sfClass = sfcWINDOW; FixUp(); @@ -483,10 +484,9 @@ CULT() //---------------------- DOOR, for surface, for zone ------------------------ RC SFI::sf_CkfDOOR( - int options) // option bits + [[maybe_unused]] int options) // option bits // 1: caller is sf_TopSf1 (as opposed to CULT) { - options; sfClass = sfcDOOR; // assign class FixUp(); #if defined( _DEBUG) @@ -500,9 +500,9 @@ RC SFI::sf_CkfDOOR( BOO consSet = IsSet( SFI_SFCON); BOO uSet = IsSet( SFI_SFU); if (!consSet && !uSet && !defTyping) - rc |= oer( (char *)MH_S0405); // "Neither drCon nor drU given". oer: cul.cpp. + rc |= oer( MH_S0405); // "Neither drCon nor drU given". oer: cul.cpp. else if (consSet && uSet) - rc |= oer( (char *)MH_S0406); // "Both drCon and drU given" + rc |= oer( MH_S0406); // "Both drCon and drU given" // getting uval from construction: defer to topCkf. x.xs_modelr = C_SFMODELCH_QUICK; @@ -583,16 +583,16 @@ RC SFI::sf_CkfSURF( // surface checker // note ABOUT0 (cnglob.h) is const tolerance for float compares. // compare in degrees for smaller (but enuf) effective tolerance. if (DEG(t) <= 60.f-ABOUT0 || DEG(t) >= 180.f+ABOUT0) - rc |= ooer( SFX( TILT), (char *)MH_S0408, DEG(t) ); // "Wall sfTilt = %g: not 60 to 180 degrees" + rc |= ooer( SFX( TILT), MH_S0408, DEG(t) ); // "Wall sfTilt = %g: not 60 to 180 degrees" break; case C_OSTYCH_FLR: // note fAboutEqual (cnglob.h) compares for fabs(difference) < ABOUT0 if (!fAboutEqual(DEG(t),180.f)) // no msg if 180 - rc |= ooer( SFX( TILT), (char *)MH_S0409 ); // "sfTilt (other than 180 degrees) may not be specified for a floor" + rc |= ooer( SFX( TILT), MH_S0409 ); // "sfTilt (other than 180 degrees) may not be specified for a floor" break; case C_OSTYCH_CEIL: if (t < 0.f || DEG(t) > 60.f+ABOUT0) - rc |= ooer( SFX( TILT), (char *)MH_S0410, DEG(t) ); // "Ceiling sfTilt = %g: not 0 to 60 degrees" + rc |= ooer( SFX( TILT), MH_S0410, DEG(t) ); // "Ceiling sfTilt = %g: not 0 to 60 degrees" break; //[case C_OSTYCH_IM1: case C_OSTYCH_IM2:] default: @@ -627,7 +627,7 @@ RC SFI::sf_CkfSURF( // surface checker { case C_OSTYCH_FLR: if (azmSet) - rc |= ooer( SFX( AZM), (char *)MH_S0411); // "sfAzm may not be given for floors [and intmasses]" + rc |= ooer( SFX( AZM), MH_S0411); // "sfAzm may not be given for floors [and intmasses]" break; default: @@ -638,7 +638,7 @@ RC SFI::sf_CkfSURF( // surface checker && IsVal( SFX( TILT)) // tilt has a value (in t) && ( !fAboutEqual(DEG(t),0.f) && !fAboutEqual(DEG(t),180.f) ); // if tilted surface if (azmNeeded) - rc |= ooer( SFX( AZM), (char *)MH_S0412); // "No sfAzm given for tilted surface" + rc |= ooer( SFX( AZM), MH_S0412); // "No sfAzm given for tilted surface" } break; } @@ -676,7 +676,7 @@ RC SFI::sf_CkfSURF( // surface checker BOO consSet = IsSet( SFI_SFCON ); if (SFI::sf_IsDelayed( x.xs_model)) { if (!consSet && !defTyping) // (MH_S0513 also used in cncult3) - ooer( SFI_SFCON, (char *)MH_S0513, // "Can't use delayed (massive) sfModel=%s without giving sfCon" + ooer( SFI_SFCON, MH_S0513, // "Can't use delayed (massive) sfModel=%s without giving sfCon" getChoiTx( SFX( MODEL))); } // else @@ -685,9 +685,9 @@ RC SFI::sf_CkfSURF( // surface checker // sf_CkfSURF: require construction or u value, not both BOO uSet = IsSet( SFI_SFU); if (!consSet && !uSet && !defTyping) - rc |= oer( (char *)MH_S0417); // "Neither sfCon nor sfU given" + rc |= oer( MH_S0417); // "Neither sfCon nor sfU given" else if (consSet && uSet) - rc |= oer( (char *)MH_S0418); // "Both sfCon and sfU given" + rc |= oer( MH_S0418); // "Both sfCon and sfU given" // getting uval from construction: defer to topCkf. // sfExAbs needed unless adiabatic; tentatively don't bother disallowing 2-95. @@ -697,10 +697,10 @@ RC SFI::sf_CkfSURF( // surface checker BOO xtSet = IsSet( SFX( SFEXT)); // nz if sfExT entered if (xc==C_EXCNDCH_SPECT) { if (!xtSet && !defTyping) - ooer( SFX( SFEXT), (char *)MH_S0422); // "sfExCnd is SpecifiedT but no sfExT given" + ooer( SFX( SFEXT), MH_S0422); // "sfExCnd is SpecifiedT but no sfExT given" } else if (xtSet) - oWarn( (char *)MH_S0423); // "sfExT not needed when sfExCnd not 'SpecifiedT'". + oWarn( MH_S0423); // "sfExT not needed when sfExCnd not 'SpecifiedT'". // Do an ooWarn: warn once? // sf_CkfSURF: Set xs_modelr and kiva related checks @@ -753,10 +753,10 @@ RC SFI::sf_CkfSURF( // surface checker if (xc==C_EXCNDCH_ADJZN) { if (!ajzSet && !defTyping) - ooer( SFX( SFADJZI), (char *)MH_S0425); // "sfExCnd is Zone but no sfAdjZn given" + ooer( SFX( SFADJZI), MH_S0425); // "sfExCnd is Zone but no sfAdjZn given" } else if (ajzSet) - oWarn( (char *)MH_S0426); // "sfAdjZn not needed when sfExCnd not 'Zone'". ooWarn? + oWarn( MH_S0426); // "sfAdjZn not needed when sfExCnd not 'Zone'". ooWarn? // shouldn't we use more warnings? } #if defined( _DEBUG) @@ -946,7 +946,7 @@ LOCAL RC tuPrf([[maybe_unused]] CULT *c, TU *p, ZNI *p2, [[maybe_unused]] void * // error if too many if (n > MAX_ZONETUS) // =3, cndefns.h - return p->oer( (char *)MH_S0427, (INT)MAX_ZONETUS, p2->Name() ); // "More than %d terminals for zone '%s'" + return p->oer( MH_S0427, MAX_ZONETUS, p2->Name() ); // "More than %d terminals for zone '%s'" return RCOK; } // tuPrf @@ -1269,7 +1269,7 @@ LOCAL RC FC infShldCkf([[maybe_unused]] CULT *c, /*SI* */ void *p, [[maybe_unuse // check sheilding when entered, not called if expr. check is repeated in topZn. { if (*(SI *)p < 1 || *(SI *)p > 5) - return ((ZNI *)p2)->ooer( ZNI_I + ZNISUB_INFSHLD, (char *)MH_S0443, (INT)*(SI *)p); // "infShld = %d: not in range 1 to 5" + return ((ZNI *)p2)->ooer( ZNI_I + ZNISUB_INFSHLD, MH_S0443, *(SI *)p); // "infShld = %d: not in range 1 to 5" return RCOK; } @@ -1278,7 +1278,7 @@ LOCAL RC FC infStoriesCkf([[maybe_unused]] CULT *c, /*SI* */ void *p, [[maybe_un // check stories at entry, not called if expr. check is repeated in topZn. { if (*(SI *)p < 1 || *(SI *)p > 3) - return ((ZNI *)p2)->ooer( ZNI_I + ZNISUB_INFSTORIES, (char *)MH_S0444, (INT)*(SI *)p); // "infStories = %d: not in range 1 to 3" + return ((ZNI *)p2)->ooer( ZNI_I + ZNISUB_INFSTORIES, MH_S0444, *(SI *)p); // "infStories = %d: not in range 1 to 3" return RCOK; } @@ -3242,7 +3242,7 @@ int CULTDOC::cu_Doc1( // document CULT table and children std::string doc; while (pCX->id) { - if (bDoAll || (pCX->cs == DAT || pCX->cs == ENDER) && !(pCX->f & NO_INP)) + if (bDoAll || ((pCX->cs == DAT || pCX->cs == ENDER) && !(pCX->f & NO_INP))) { // all: show every CULT in table // names only: DAT (except NO_INP) and END doc = pCX->cu_MakeDoc(pCULT, linePfx, cu_options); @@ -3362,7 +3362,7 @@ o n++; // count it o o // error if too many o if (n > MAX_ZONETUS) // =3, cndefns.h -o return oer( p, "More than %d terminals for zone '%s'", (INT)MAX_ZONETUS, p2->Name() ); +o return oer( p, "More than %d terminals for zone '%s'", MAX_ZONETUS, p2->Name() ); o o return RCOK; o} // tuxPrf diff --git a/src/cncult.h b/src/cncult.h index e9218cb3b..e1cd2950f 100644 --- a/src/cncult.h +++ b/src/cncult.h @@ -42,11 +42,11 @@ void cncultClean(CLEANCASE cs); // cncultn.cpp cleanup fcn 12-3-93 RC topReCkf(); // re-check/setup for main run after autosize // cncult4.cpp -- externally called fcns re report/export formatting -char* getErrTitleText(); // access ERR report title text -char* getLogTitleText(); // access LOG report title text -char* getInpTitleText(); // access INP report title text -char* getHeaderText( int pageN); // access header text -char* getFooterText( int pageN); // .. footer .. inserts given page number +const char* getErrTitleText(); // access ERR report title text +const char* getLogTitleText(); // access LOG report title text +const char* getInpTitleText(); // access INP report title text +const char* getHeaderText( int pageN); // access header text +const char* getFooterText( int pageN); // .. footer .. inserts given page number int getBodyLpp(); // get lines of report body per page, similarly void freeHdrFtr(); // free header, footer, report title texts RC FC freeRepTexts(); diff --git a/src/cncult2.cpp b/src/cncult2.cpp index 79c7c23e9..6e6e05fa2 100644 --- a/src/cncult2.cpp +++ b/src/cncult2.cpp @@ -41,7 +41,7 @@ #include "irats.h" // declarations of input record arrays (rats) #include "cnculti.h" // cncult internal functions shared only amoung cncult,2,3,4.cpp -#include "Foundation.h" // access to Kiva objects +#include "foundation.h" // access to Kiva objects /*-------------------------------- DEFINES --------------------------------*/ @@ -425,7 +425,7 @@ RC TOPRAT::tp_SetDerived() if (!DTEndDay) // if daylight time end date not given DTEndDay = tdHoliDate( year, C_HDAYCASECH_FIRST, 0/*Sun*/, 11/*Nov*/); // default to 1st Sun in Nov. if (DTBegDay==DTEndDay) - per( (char *)MH_S0470); // "Daylight saving time should not start and end on same day" + per( MH_S0470); // "Daylight saving time should not start and end on same day" // notes: if DT end day < start day, southern hemisphere summer assumed. // precision of hvac computations (app\cnztu.cpp, cnah.cpp, perhaps cnloads.cpp) @@ -536,7 +536,7 @@ RC TOPRAT::tp_Wfile( // find/read weather file / init top members with data fro endDay += Wfile.jd1; // (or else beyond) } if (begDay < jd1 || endDay > jdl) - rc = per( (char *)MH_S0501, /* "Weather file does not include all run dates:\n" + rc = per( MH_S0501, /* "Weather file does not include all run dates:\n" " run is %s to %s,\n" " but '%s' dates are %s to %s.\n" */ tddys( tp_begDay), tddys( tp_endDay), @@ -695,7 +695,7 @@ RC TOPRAT::tp_Psychro() // initialize air properties members of top tp_refW = psyHumRat2( refTemp, refRH); // hum rat for temp, rel humidity if (tp_refW <= 0.) - { per( (char *)MH_S0500, refTemp, elevation); // "refTemp (%g) seems to be over boiling for elevation (%g)" + { per( MH_S0500, refTemp, elevation); // "refTemp (%g) seems to be over boiling for elevation (%g)" tp_refW = PsyWmin; } tp_refWX = 1./(1.+tp_refW); // commonly used @@ -731,7 +731,7 @@ RC TOPRAT::brFileCk() // check/clean up inputs re binary results files, rob 12-2 tddyi( tp_begDay, -1, &iDateBeg); // break down Julian date, tdpak.cpp tddyi( tp_endDay, -1, &iDateEnd); if (iDateBeg.month==iDateEnd.month) // per() stops run due to global error count - per( (char *)MH_S0502); /* "Run over a month long cannot end in starting month\n" + per( MH_S0502); /* "Run over a month long cannot end in starting month\n" " when hourly binary results are requested." */ return RCBAD; // omit following warnings after fatal error } @@ -747,7 +747,7 @@ RC TOPRAT::brFileCk() // check/clean up inputs re binary results files, rob 12-2 { // warning for extension given (won't be used) - pWarn( (char *)MH_S0503, // "Extension given in binary results file name \"%s\" \n" + pWarn( MH_S0503, // "Extension given in binary results file name \"%s\" \n" tp_brFileName.CStr() ); // " will not be used -- extensions \".brs\" and \".bhr\" are always used." *(dot + 1) = '\0'; // remove the extension so warning does not repeat } @@ -758,7 +758,7 @@ RC TOPRAT::brFileCk() // check/clean up inputs re binary results files, rob 12-2 // warnings if file name given when it won't be used (why tp_SetOptions() must be called first, 12-94) if (tp_brs != C_NOYESCH_YES && tp_brHrly != C_NOYESCH_YES) - pWarn( (char *)MH_S0504, // "You have given a binary results file name with\n" + pWarn( MH_S0504, // "You have given a binary results file name with\n" tp_brFileName.CStr() ); // " \"BinResFileName = %s\",\n" // " but no binary results file will be written as you have not given\n" // " any of the following commands:\n" @@ -766,7 +766,7 @@ RC TOPRAT::brFileCk() // check/clean up inputs re binary results files, rob 12-2 // " nor either of the following command line switches:\n" // " -r -h\n" else if (tp_brMem && !tp_brDiscardable) - pWarn( (char *)MH_S0505, // "You have given a binary results file name with\n" + pWarn( MH_S0505, // "You have given a binary results file name with\n" tp_brFileName.CStr() ); // " \"BinResFileName = %s\",\n" // " but no binary results file will be written as you have also specified\n" // " memory-only binary results with the -m DLL command line switch." @@ -777,7 +777,6 @@ RC TOPRAT::brFileCk() // check/clean up inputs re binary results files, rob 12-2 //=========================================================================== /*virtual*/ void TOPRAT::Copy(const record* pSrc, int options/*=0*/) { - options; if (gud) // if record already in use (eg 2nd run) (insurance). Note record must be constructed b4 operator=. freeDM(); @@ -902,7 +901,7 @@ LOCAL RC topZn( // all-zone initialization Top.tp_bAllCR = nCR > 0; if (nCR > 0 && nCR != nALL) - rc = err( "Illegal znModel mix -- must be all CNE or all convective/radiant"); + rc = err( ERR, "Illegal znModel mix -- must be all CNE or all convective/radiant"); return rc; // error returns above in each CSE_E macro } // topZn @@ -935,10 +934,10 @@ RC ZNI::zi_Top( // top-level input check and defaults // repeat checks done by input ckf's // in case skipped due to expr, and as gel insurance. ooer minimizes duplicate msgs. if (i.zn_infShld<1 || i.zn_infShld>5) - ooer( ZI( INFSHLD), (char *)MH_S0471, i.zn_infShld); // "zn_infShld = %d: not in range 1 to 5" + ooer( ZI( INFSHLD), MH_S0471, i.zn_infShld); // "zn_infShld = %d: not in range 1 to 5" if (i.zn_infStories<1 || i.zn_infStories>3) - ooer( ZI( INFSTORIES), (char *)MH_S0472, i.zn_infStories); // "infStories = %d: not in range 1 to 3" + ooer( ZI( INFSTORIES), MH_S0472, i.zn_infStories); // "infStories = %d: not in range 1 to 3" // default eave height if (!IsSet(ZI( EAVEZ))) @@ -1227,7 +1226,7 @@ RC LR::lr_TopLr() else // layer material not given. Already msg'd at end of material object, unless // material is part of a construction type or copy; issue another message to be sure. */ { - rc |= ooer( LR_MATI, (char *)MH_S0477); // "lrMat not given". msg only if no msg yet for this field. + rc |= ooer( LR_MATI, MH_S0477); // "lrMat not given". msg only if no msg yet for this field. return rc; // do other layers, then end session } int matThkSet = mat->IsSet( MAT_THK); // nz if mt_thk given @@ -1241,7 +1240,7 @@ RC LR::lr_TopLr() return rc; // nominal R value in framing unexpected & not used. Rob. if (frmMat->mt_rNom > 0.f) - oWarn( (char *)MH_S0478, // "Ignoring unexpected mt_rNom=%g of framing material '%s'" + oWarn( MH_S0478, // "Ignoring unexpected mt_rNom=%g of framing material '%s'" frmMat->mt_rNom, frmMat->Name() ); // test whether thickness given in framing material frmMatThkSet = frmMat->IsSet( MAT_THK); // non-0 if framing material thickness given @@ -1250,10 +1249,10 @@ RC LR::lr_TopLr() // layer: framing fraction / framing material given/omitted consistency. duplicates lrStarCkf check, as required. if (framed && !frmMatSet) - rc |= oer( (char *)MH_S0479, frmFrac); // "Non-0 lrFrmFrac %g given but lrFrmMat omitted." + rc |= oer( MH_S0479, frmFrac); // "Non-0 lrFrmFrac %g given but lrFrmMat omitted." // continue here now, but end session upon return (due to rc). else if (!frmFracSet && frmMatSet) - oer( (char *)MH_S0480); // "lrFrmMat given, but lrFrmFrac omitted" + oer( MH_S0480); // "lrFrmMat given, but lrFrmFrac omitted" // and proceed w framing fraction 0 (oer prevented RUN). // else: framing fraction of 0 given: framing material optional. @@ -1264,12 +1263,12 @@ RC LR::lr_TopLr() { if ( matThkSet // if mat'l thk also given && mat->mt_thk != lr_thk ) // must be the same - oer( (char *)MH_S0481, // "Material thickness %g does not match lrThk %g" + oer( MH_S0481, // "Material thickness %g does not match lrThk %g" mat->mt_thk, lr_thk ); // continue for now; oer() prevents RUN. if ( frmMatThkSet // if frmMat & its thk given && frmMat->mt_thk != lr_thk ) // it too must be the same - oer( (char *)MH_S0482, // "Framing material thickness %g does not match lrThk %g" + oer( MH_S0482, // "Framing material thickness %g does not match lrThk %g" frmMat->mt_thk, lr_thk ); // continue for now; oer() prevents RUN. } @@ -1278,7 +1277,7 @@ RC LR::lr_TopLr() lr_thk = mat->mt_thk; // copy mat'l thk to layer if ( frmMatThkSet // if framing mat'l thk given && frmMat->mt_thk != mat->mt_thk ) // must be the same - oer( (char *)MH_S0483, frmMat->mt_thk, mat->mt_thk); /* "Framing material thickness %g does not match \n" + oer( MH_S0483, frmMat->mt_thk, mat->mt_thk); /* "Framing material thickness %g does not match \n" " material thickness %g" */ // continue for now; oer() prevents RUN. } @@ -1287,7 +1286,7 @@ RC LR::lr_TopLr() lr_thk = frmMat->mt_thk; // use it } else // have no thickness - rc |= oer( (char *)MH_S0484, // "No thickness given in layer, nor in its material%s" + rc |= oer( MH_S0484, // "No thickness given in layer, nor in its material%s" frmMatSet ? ", nor its framing material" : "" ); // layer: message if > 1 framed layers in construction @@ -1295,7 +1294,7 @@ RC LR::lr_TopLr() if (framed) { if (con->nFrmLr) - oer( (char *)MH_S0485); // "Only 1 framed layer allowed per construction" + oer( MH_S0485); // "Only 1 framed layer allowed per construction" // keep processing -- but oer has prevented run. } @@ -1354,28 +1353,30 @@ LOCAL RC topCon2() // constructions pass 2, at RUN // construction: error if > 1 framed layer if (con->nFrmLr > 1) // counted in topLr. REDUNDANT MSG - con->oer( (char *)MH_S0486); // "More than 1 framed layer in construction" + con->oer( MH_S0486); // "More than 1 framed layer in construction" // construction: error if both or neither layer subobjects and .conU given. duplicates conStarCkf check. if (fs[ CON_CONU ] & FsSET) // if .conU given { if (con->nLr) // if layers given (counted in topLr) - con->oer( (char *)MH_S0487); // "Both conU and layers given" + con->oer( MH_S0487); // "Both conU and layers given" // proceed, but oer() has prevented run. } else // .conU not given if (con->nLr==0) // if no layers given - con->oer( (char *)MH_S0488); // "Neither conU nor layers given" + con->oer( MH_S0488); // "Neither conU nor layers given" // proceed, but oer() has prevented run. // construction: if layers given, compute U from r accumulated in topLay() if (con->nLr) // if layer subobjects given + { if (con->r > 0.f) // insurance con->conU = 1.f / con->r; // conductance = 1/resistance else // 0 resistance (unexpected) con->conU = FHuge; // large value for inf conductance + } /* else leave conU as input (checked above) if 0 layers. */ #if 0 // 1-95: incorporate in topSf1 where actual surface film h's known @@ -1450,7 +1451,7 @@ LOCAL RC topGt() // check/default GTs (glazing types) and copy records to run ba if ( !ISNANDLE(gti->gtSMSO) // if expressions given, && !ISNANDLE(gti->gtSMSC) // .. don't check: FPE's!!! && gti->gtSMSC > gti->gtSMSO ) - gti->oer( (char *)MH_S0506, /* "gtSMSC (%g) > gtSMSO (%g):\n" + gti->oer( MH_S0506, /* "gtSMSC (%g) > gtSMSO (%g):\n" " Shades-Closed Solar heat gain coeff Multiplier\n" " must be <= shades-Open value." */ gti->gtSMSC, gti->gtSMSO ); @@ -2025,7 +2026,7 @@ LOCAL RC badRefMsg( // message for bad reference (rat subscript) // >>> using oer, can we drop ownRec arg? review calls. date? Does make observed redundancy in messages, 1-92. return fromRec->oer( - (char *)MH_S0494, // "bad %s index %d in%s %s '%s' [%d]%s" + MH_S0494, // "bad %s index %d in%s %s '%s' [%d]%s" (char *)((BP)toBase)->what, mbr, mbrName && *mbrName ? strtprintf(" %s of", mbrName) : "", @@ -2033,7 +2034,7 @@ LOCAL RC badRefMsg( // message for bad reference (rat subscript) fromRec->Name(), fromRec->ss, ownRec - ? strtprintf( " of %s '%s'", (char *)ownRec->b->what, ownRec->Name() ) + ? strtprintf( " of %s '%s'", ownRec->b->what, ownRec->Name() ) : "" ); } // badRefMsg diff --git a/src/cncult3.cpp b/src/cncult3.cpp index 4f6cecfeb..37ac8c208 100644 --- a/src/cncult3.cpp +++ b/src/cncult3.cpp @@ -261,7 +261,7 @@ RC SFI::sf_TopSf1() // disallow in interior wall, rob 2-95: we don't have appropriate radiative modelling (conductive part probobly ok). // note ok & receives sun in adiabatic or specT wall. if (ownSf->x.sfExCnd==C_EXCNDCH_ADJZN) - oer( (char *)MH_S0530); // "Window in interior wall not allowed" + oer( MH_S0530); // "Window in interior wall not allowed" // always use conductance model for windows x.xs_model = C_SFMODELCH_QUICK; @@ -293,12 +293,12 @@ RC SFI::sf_TopSf1() { // child bigger than parent oer( ownSf->x.xs_area >= ownSf->sfArea // if nothing subtracted yet - ? (char *)MH_S0511 // "Area of %s (%g) is greater than \n area of %s's surface%s (%g)" - : (char *)MH_S0512, // "Area of %s (%g) is greater than \n" + ? MH_S0511 // "Area of %s (%g) is greater than \n area of %s's surface%s (%g)" + : MH_S0512, // "Area of %s (%g) is greater than \n" // " remaining area of %s's surface%s \n" // (%g after subtraction of previous door areas)" classObjTx(), sfArea, - (char *)b->what, quifnn( ownSf->Name()), // quote if not "" + b->what, quifnn( ownSf->Name()), // quote if not "" ownSf->x.xs_area ); ownSf->x.xs_area = 0.f; // use 0 / no more msgs } @@ -391,12 +391,14 @@ RC SFI::sf_TopSf1() // Values are multiplied at runtime (cgsolar.cpp) by common part (normal transmissivity gtSHGC). */ if (!IsSet( SFX( SCO))) // if x.sco not given (as wnSMSO) for window CSE_V x.sco = CSE_V gt->gtSMSO; // use gt shades-Open SMS, m-h variable, default 1.0. - if (!IsSet( SFX( SCC))) // if x.scc not given (as wnSMSC) for window - if (IsSet( SFX( SCO))) // if x.sco given (as wnSMSO) for window + if (!IsSet(SFX(SCC))) // if x.scc not given (as wnSMSC) for window + { + if (IsSet(SFX(SCO))) // if x.sco given (as wnSMSO) for window CSE_V x.scc = CSE_V x.sco; // use window shades-open value, checked/defaulted just above - // note that this makes shades inoperable even if gtSMSC != gtSMSO. + // note that this makes shades inoperable even if gtSMSC != gtSMSO. else CSE_V x.scc = CSE_V gt->gtSMSC; // use gt shades-Closed SMS. checked/defaulted in cncult2:topGt(). m-h. + } // default window values from GT if (!IsSet( SFX( FMULT))) // if wnFMult (frame/mullion multplier) not given for window @@ -431,13 +433,15 @@ RC SFI::sf_TopSf1() } } - if (!IsSet( SFI_SFU)) // if wnU not given in window - if (gt->IsSet( GT_GTU)) // if gtU given in glazing type - { sfU = gt->gtU; // use u-value given in glazing type - fs[ SFI_SFU] |= FsSET; // say sfU set, so it will be used below. 2-17-95. + if (!IsSet(SFI_SFU)) // if wnU not given in window + { if (gt->IsSet(GT_GTU)) // if gtU given in glazing type + { + sfU = gt->gtU; // use u-value given in glazing type + fs[SFI_SFU] |= FsSET; // say sfU set, so it will be used below. 2-17-95. } else - rc1 = oer( (char *)MH_S0531, gt->Name()); // "No U-value given: neither wnU nor glazeType '%s' gtU given" + rc1 = oer(MH_S0531, gt->Name()); // "No U-value given: neither wnU nor glazeType '%s' gtU given" + } } else { // no wnGT @@ -462,7 +466,7 @@ RC SFI::sf_TopSf1() && !ISNANDLE(x.sco) // .. (also checked at runtime in cgsolar.cpp) && x.scc > x.sco ) // if shades closed admit more light than shades open { oer( - (char *)MH_S0532, /* "wnSMSC (%g) > wnSMSO (%g):\n" + MH_S0532, /* "wnSMSC (%g) > wnSMSO (%g):\n" " shades-closed solar heat gain coefficient multiplier must be <= \n" " shades-open solar heat gain coefficient multiplier." */ x.scc, x.sco ); // note defaults gtSMSC & gtSMSO were checked in topGt() @@ -543,12 +547,12 @@ x printf( "Hit\n"); // common checks if (!conSet) // if no constr specified { // checked in sfStarCkf; redundant insurance here. - rc |= oer( (char *)MH_S0513, // "Can't use delayed (massive) sfModel=%s without giving sfCon" + rc |= oer( MH_S0513, // "Can't use delayed (massive) sfModel=%s without giving sfCon" getChoiTx( SFX( MODEL))); break; // (is preset to quick) } if (con->nLr==0) // can't do delayed with uval only - { rc |= oer( (char *)MH_S0514, // "delayed (massive) sfModel=%s selected\n" + { rc |= oer( MH_S0514, // "delayed (massive) sfModel=%s selected\n" // " but surface's construction, '%s', has no layers" getChoiTx( SFX( MODEL)), con->Name() ); @@ -567,7 +571,7 @@ x printf( "Hit\n"); case C_SFMODELCH_DELAYED_SUBHOUR: if (tc < TC_SHMASS_WARN) // warn if time const too small for computation interval - then do anyway - oWarn( (char *)MH_S0533, /* "Time constant %g probably too short for delayed (massive) sfModel.\n" + oWarn( MH_S0533, /* "Time constant %g probably too short for delayed (massive) sfModel.\n" " Use of sfModel=Delayed, Delayed_Subhour, or Delayed_Hour \n" " is NOT recommened when time constant is < %g.\n" " Results may be strange. \n" @@ -578,7 +582,7 @@ x printf( "Hit\n"); case C_SFMODELCH_DELAYED_HOUR: if (tc < TC_HMASS_WARN) // warn if time const too small for computation interval - then do anyway - oWarn( (char *)MH_S0534, /* "Time constant %g probably too short for sfModel=Delayed_Hour.\n" + oWarn( MH_S0534, /* "Time constant %g probably too short for sfModel=Delayed_Hour.\n" " Use of sfModel=Delayed_Hour \n" " is NOT recommened when time constant is < %g.\n" " Results may be strange. \n" @@ -686,7 +690,7 @@ RC MSRAT::ms_Make( // fill MSRAT for SFI + CON } #endif if (rc) - sf->oer( (char *)rc); // report error + sf->oer( rc); // report error // fill mass record (even if not RCOK) name = sf->name; // name @@ -708,7 +712,7 @@ x printf( "Hit\n"); : sf->x.sfExCnd==C_EXCNDCH_GROUND ? MSBCGROUND : sf->x.sfExCnd==C_EXCNDCH_SPECT ? MSBCSPECT : sf->x.sfExCnd==C_EXCNDCH_ADIABATIC ? MSBCADIABATIC - : (rc |= sf->oer( (char *)MH_S0526, sf->x.sfExCnd)); // "Bad sfExCnd %d (cnuclt.cpp:makMs())" + : (rc |= sf->oer( MH_S0526, sf->x.sfExCnd)); // "Bad sfExCnd %d (cnuclt.cpp:makMs())" outside.bc_Setup( ss, adjTy, 1); // 1 = doing outside for (int si=0; si<2; si++) @@ -731,7 +735,7 @@ x printf( "Hit\n"); } } if (rc) // if failed (already msg'd) - rc = sf->oer( (char *)MH_S0527 ); // "ms_makMs: mass model setup error (above)" + rc = sf->oer( MH_S0527 ); // "ms_makMs: mass model setup error (above)" // continue here, but perlc stopped run & rc ret will stop caller. // if outside of mass is exposed, add XSURF to inside zone to rcv insolation @@ -831,7 +835,7 @@ RC FC topSg() // SGDIST processing at RUN if (gz->x.nsgdist >= HSMXSGDIST) // =8, 2-95 (cndefns.h) { - gz->oer( (char *)MH_S0517, INT(HSMXSGDIST) ); // "More than %d SGDISTS for same window" + gz->oer( MH_S0517, HSMXSGDIST ); // "More than %d SGDISTS for same window" continue; // next sg } @@ -852,7 +856,7 @@ RC FC topSg() // SGDIST processing at RUN targSf->x.sfExCnd==C_EXCNDCH_ADJZN // if ext cond zone, not specT,ambient,adiabatic. && targSf->x.sfAdjZi==gzZi; // and the zone is window's - char* s = nullptr; // set non-NULL iff error + const char* s = nullptr; // set non-NULL iff error BOO toOutside = 0; if (fs[SGI_SGSIDE] & FsSET) // if sgSide given in input { @@ -882,7 +886,7 @@ RC FC topSg() // SGDIST processing at RUN } if (s) // if error { sg->oer( // message to scrn, and disable RUN. - (char *)MH_S0518, /* "%ssurface '%s' not in zone '%s'. \n" + MH_S0518, /* "%ssurface '%s' not in zone '%s'. \n" " Can't target solar gain to surface not in window's zone." */ s, targSf->Name(), zp->Name() ); continue; // next sg @@ -901,7 +905,7 @@ RC FC topSg() // SGDIST processing at RUN if (!SFI::sf_IsDelayed( targSf->x.xs_modelr) && !SFI::sf_IsKiva(targSf->x.xs_modelr)) { - sg->oWarn( (char *)MH_S0519, // "Target surface '%s' is not delayed model.\n" + sg->oWarn( MH_S0519, // "Target surface '%s' is not delayed model.\n" // " Solar gain being directed to zone '%s' air." targSf->Name(), zp->Name() ); // need do nothing to redirect the gain since target is in zone. @@ -953,7 +957,7 @@ RC FC topSh() // SHADE processing at RUN if ( !fAboutEqual( DEG(gz->x.tilt), (float)90.f ) ) // surf tilt-->gz in topSf1() { - sh->oer( (char *)MH_S0521, // "sfTilt is %g. Shaded window must be in vertical surface." + sh->oer( MH_S0521, // "sfTilt is %g. Shaded window must be in vertical surface." DEG(gz->x.tilt) ); continue; // skip this shade (and msg prevented run) } @@ -979,7 +983,7 @@ RC FC topSh() // SHADE processing at RUN if (gz->x.iwshad) // if window already has a SHADE { - sh->oer( (char *)MH_S0522, /* "Window '%s' is already shaded by shade '%s'. \n" + sh->oer( MH_S0522, /* "Window '%s' is already shaded by shade '%s'. \n" " Only 1 SHADE per window allowed. */ gz->Name(), WshadR.p[gz->x.iwshad].Name() ); continue; // skip (msg prevented RUN) @@ -1129,7 +1133,7 @@ RC SFI::sf_TopSf2() break; // ... outside won't receive solar default: - rc |= oer( (char *)MH_S0524, x.sfExCnd ); + rc |= oer( MH_S0524, x.sfExCnd ); // "Internal error in cncult.cpp:topSf2(): Bad exterior condition %d" } } @@ -1146,7 +1150,7 @@ RC SFI::sf_TopSf2() break; default: - rc |= oer( (char *)MH_S0524, x.sfExCnd ); + rc |= oer( MH_S0524, x.sfExCnd ); // "Internal error in cncult.cpp:topSf2(): Bad exterior condition %d" } } @@ -1156,7 +1160,7 @@ RC SFI::sf_TopSf2() // for walls, add index to sf_sharedFndWalls } else - rc |= oer( (char *)MH_S0525, x.xs_modelr ); + rc |= oer( MH_S0525, x.xs_modelr ); // "Internal error in cncult.cpp:topSf2(): Bad surface model %d" #if defined( _DEBUG) @@ -1371,8 +1375,8 @@ RC ZNR::zn_RadX() zn_FAir = 1.; // initial value, updated below zn_SetAirRadXArea(); - int nSSpace = 0; // # of space definition surfaces (info only) - // not sfcDUCT, not sfcPIPE + [[maybe_unused]] int nSSpace = 0; // # of space definition surfaces (info only) + // not sfcDUCT, not sfcPIPE int iS; for (iS=0; iS(this), pXS, sizeof( XSURF)); // bitwise copy xs_pParent = pParent; // restore parent ptr xs_Init( xs_pParent); // fix sub-objects // (deletes FENAWs, xs_SetRunConstants remakes) @@ -2321,10 +2325,10 @@ RC XSURF::xs_SetUNom() // derive/set nominal U-factor // also sets xs_UANom, xs_rSrfNom, xs_hSrfNom, and ms_UNom { static float rSrfASHRAE[ 3][ 2] = -// down up -{ .92f, .61f, // ceiling - .68f, .68f, // wall - .61f, .92f // floor +// down up +{ { .92f, .61f }, // ceiling + { .68f, .68f }, // wall + { .61f, .92f } // floor }; if (xs_IsASHWAT()) @@ -2546,9 +2550,9 @@ void SBC::sb_SetRunConstants( // set mbrs that do not change during simulation // Table order assumed consistent with xstyCEILING etc static float hcNatASHRAE[ 3][ 2] = // down up - { .162f, .712f, // ceiling - .542f, .542f, // wall - .162f, .712f // floor + { { .162f, .712f }, // ceiling + { .542f, .542f }, // wall + { .162f, .712f } // floor }; // TODO: generalize for arbitrary tilt? // TODO: handle non-canonical tilts (e.g. -5, 190, ...)? @@ -2847,8 +2851,8 @@ void SBC::sb_HCAmbient() // ambient surface convection coefficients // Using DOE-2 coefficients (correlated to local windspeed at zone hight--change if we ever use surface hight). static const float mowittCoeffs[2][2] = { // a b - 0.2639f, 0.89f, // Windward 0.2639 = 2.99 Btu/hr-ft2-R-(knot)^0.89 - 0.3659f, 0.617f // Leeward 0.2804 = 3.99 Btu/hr-ft2-R-(knot)^0.617 + { 0.2639f, 0.89f }, // Windward 0.2639 = 2.99 Btu/hr-ft2-R-(knot)^0.89 + { 0.3659f, 0.617f } // Leeward 0.2804 = 3.99 Btu/hr-ft2-R-(knot)^0.617 }; auto parentZone = sb_pXS->xs_sbcI.sb_zi; // Get surface parent zone @@ -3421,7 +3425,7 @@ LOCAL FLOAT FC seriesU( FLOAT u1, FLOAT u2) { if (ISUNSET(u1) || ISUNSET(u2) ) // protect re NAN's. exman.h macro. { - perl( (char *)MH_S0528); // "cncult:seriesU(): unexpected unset h or u" + perl( MH_S0528); // "cncult:seriesU(): unexpected unset h or u" return 0.f; } if (u1==0.f || u2==0.f) // FEQUALs may be needed @@ -3445,7 +3449,7 @@ LOCAL RC FC cnuCompAdd( // Add an XSRAT entry to zone's XSURF chain // check and access zone if (zi <= 0 || zi > ZrB.n) - return err( PWRN, (char *)MH_S0529, (INT)zi); // "cncult3.cpp:cnuCompAdd: bad zone index %d". + return err( PWRN, MH_S0529, zi); // "cncult3.cpp:cnuCompAdd: bad zone index %d". // CAUTION: err does not errCount++; be sure error return propogated back so cul.cuf can errCount++. ZNR* zp = ZrB.p + zi; diff --git a/src/cncult4.cpp b/src/cncult4.cpp index 1d039abdb..c4c5c1253 100644 --- a/src/cncult4.cpp +++ b/src/cncult4.cpp @@ -57,10 +57,10 @@ LOCAL char* footerPageN = NULL; // NULL or ptr into footer at which to store cur /*---------------------- LOCAL FUNCTION DECLARATIONS ----------------------*/ -LOCAL RC addRep( TI rfi, char *name, RPTYCH rpTy, TI zi, IVLCH freq, SI putAtEnd); +LOCAL RC addRep( TI rfi, const char* name, RPTYCH rpTy, TI zi, IVLCH freq, SI putAtEnd); LOCAL void addTx( const char* s, int spc, char **pp, int* pr, int rReserve=0); -LOCAL void addHdayDate( char *name, DOY date); -LOCAL void addHdayRule( char *name, HDAYCASECH hdCase, DOWCH dow, int mon); +LOCAL void addHdayDate( const char* name, DOY date); +LOCAL void addHdayRule( const char* name, HDAYCASECH hdCase, DOWCH dow, int mon); @@ -133,7 +133,7 @@ RC topPrfRep() // REPORT/EXPORT PRE-INPUT FCN called by cncult2.cpp:topStarPrf return RCOK; // also E macros have error returns } // topPrfRep //=========================================================================== -LOCAL RC addRep( TI rfi, char *name, RPTYCH rpTy, TI zi, IVLCH freq, SI putAtEnd) +LOCAL RC addRep( TI rfi, const char* name, RPTYCH rpTy, TI zi, IVLCH freq, SI putAtEnd) // add non-zone-dependent report record for given report file (rfi). for topStarPrf. @@ -180,13 +180,13 @@ RC topRep() // check Top rep___ members, set up page header and footer 11-91 // check page dimensions if (Top.repCpl < 72 || Top.repCpl > 132) - rc = Top.oer( (char *)MH_S0540, Top.repCpl); // "repCpl %d is not between 78 and 132" + rc = Top.oer( MH_S0540, Top.repCpl); // "repCpl %d is not between 78 and 132" if (Top.repLpp < 48) - rc = Top.oer( (char *)MH_S0541, Top.repLpp); // "repLpp %d is less than 50" + rc = Top.oer( MH_S0541, Top.repLpp); // "repLpp %d is less than 50" if (Top.repTopM < 0 || Top.repTopM > 12) - rc = Top.oer( (char *)MH_S0542, Top.repTopM); // "repTopM %d is not between 0 and 12" + rc = Top.oer( MH_S0542, Top.repTopM); // "repTopM %d is not between 0 and 12" if (Top.repBotM < 0 || Top.repBotM > 12) - rc = Top.oer( (char *)MH_S0543, Top.repBotM); // "repBotM %d is not between 0 and 12" + rc = Top.oer( MH_S0543, Top.repBotM); // "repBotM %d is not between 0 and 12" return rc; } // topRep @@ -275,7 +275,7 @@ RC topCol( int isExport) // check report / get ptr to it / if bad continue; // if no or bad report, done with this one if (rp->rpTy && rp->rpTy != C_RPTYCH_UDT) - colp->oer( (char *)MH_S0545, exrePort, exrePort, exrp); // "%sCol associated with %s whose %sType is not UDT" + colp->oer( MH_S0545, exrePort, exrePort, exrp); // "%sCol associated with %s whose %sType is not UDT" // check variability of end-of-interval eval'd expression vs frequency of report /* problems of too-frequent reporting can include: @@ -309,7 +309,7 @@ RC topCol( int isExport) && rpfreqEvf > colEvf // and rpFreq faster than colVal varies (leftmost bit farther left) && (colEvf & (EVXBEGIVL)) ) // and colVal evaluated at end/post interval (results probe) colip->oWarn( - (char *)MH_S0546, // "End-of-interval varying value is reported more often than it is set:\n" + MH_S0546, // "End-of-interval varying value is reported more often than it is set:\n" exrp, exrePort, rp->Name(), // " %sFreq of %s '%s' is '%s',\n" eg "rpFreq of report 'foo' is 'day' // " but colVal for colHead '%s' varies (is given a value) only at end of %s." rp->getChoiTx( RI_RPFREQ, 1), // text for rpfreq choice @@ -375,11 +375,11 @@ RC RI::ri_CkF() case C_RPTYCH_TUSIZE: // 6-95 case C_RPTYCH_TULOAD: // 6-95 if (fs[ RI_RPFREQ ] & FsSET) - rc = ooer( RI_RPFREQ, (char *)MH_S0428, exrp, exrp, tyTx); // "%sFreq may not be given with %sType=%s" + rc = ooer( RI_RPFREQ, MH_S0428, exrp, exrp, tyTx); // "%sFreq may not be given with %sType=%s" if (fs[ RI_RPDAYBEG ] & FsSET) - rc = ooer( RI_RPDAYBEG, (char *)MH_S0429, exrp, exrp, tyTx); // "%sDayBeg may not be given with %sType=%s" + rc = ooer( RI_RPDAYBEG, MH_S0429, exrp, exrp, tyTx); // "%sDayBeg may not be given with %sType=%s" if (fs[ RI_RPDAYEND ] & FsSET) - rc = ooer( RI_RPDAYEND, (char *)MH_S0430, exrp, exrp, tyTx); // "%sDayEnd may not be given with %sType=%s" + rc = ooer( RI_RPDAYEND, MH_S0430, exrp, exrp, tyTx); // "%sDayEnd may not be given with %sType=%s" break; // types requiring rpFreq and allowing or requiring start and end day depending on rpFreq @@ -394,15 +394,15 @@ RC RI::ri_CkF() switch (rpFreq) // rpFreq is TYCH with evf==0 ---> no exprs { case 0: - return oer( (char *)MH_S0431, exrp, exrp, tyTx); // "No %sFreq given: required with %sType=%s" + return oer( MH_S0431, exrp, exrp, tyTx); // "No %sFreq given: required with %sType=%s" // dates not allowed: year case C_IVLCH_Y: if (fs[ RI_RPDAYBEG ] & FsSET) - rc = ooer( RI_RPDAYBEG, (char *)MH_S0432, // "%sDayBeg may not be given with %sFreq=%s" + rc = ooer( RI_RPDAYBEG, MH_S0432, // "%sDayBeg may not be given with %sFreq=%s" exrp, exrp, fqTx); if (fs[ RI_RPDAYEND ] & FsSET) - rc = ooer( RI_RPDAYEND, (char *)MH_S0433, // "%sDayEnd may not be given with %sFreq=%s" + rc = ooer( RI_RPDAYEND, MH_S0433, // "%sDayEnd may not be given with %sFreq=%s" exrp, exrp, fqTx); break; // date optional: month @@ -415,34 +415,34 @@ RC RI::ri_CkF() if ( rpTy==C_RPTYCH_MTR // have no subhourly meter info || rpTy==C_RPTYCH_DHWMTR // have no subhourly DHW meter info || rpTy==C_RPTYCH_ZST ) // have no subhourly statistics info, right? - return ooer( RI_RPFREQ, (char *)MH_S0434, // "%sFreq=%s not allowed with %sty=%s" + return ooer( RI_RPFREQ, MH_S0434, // "%sFreq=%s not allowed with %sty=%s" exrp, fqTx, exrp, tyTx ); { - char *badSumOf=NULL; // check for types without subhour sum info + const char* badSumOf=nullptr; // check for types without subhour sum info if (rpTy==C_RPTYCH_ZEB && (fs[RI_ZI] & FsSET) && zi==TI_SUM) badSumOf = "zones"; else if (rpTy==C_RPTYCH_AH && (fs[RI_AHI] & FsSET) && ahi==TI_SUM) badSumOf = "ahs"; if (badSumOf) - return ooer( RI_RPFREQ, (char *)MH_S0435, // "%sFreq=%s not allowed in Sum-of-%s %s" + return ooer( RI_RPFREQ, MH_S0435, // "%sFreq=%s not allowed in Sum-of-%s %s" exrp, fqTx, badSumOf, exrePort ); } /*lint -e616 fall thru */ case C_IVLCH_H: case C_IVLCH_D: if (!rpDayBeg) - rc = oer( (char *)MH_S0436, // "No %sDayBeg given: required with %sFreq=%s" + rc = oer( MH_S0436, // "No %sDayBeg given: required with %sFreq=%s" exrp, exrp, fqTx ); break; /*lint +e616 */ default: - return ooer( RI_RPFREQ, (char *)MH_S0437, // "Internal error in RI::ri_CkF: bad rpFreq %d" - (INT)rpFreq); + return ooer( RI_RPFREQ, MH_S0437, // "Internal error in RI::ri_CkF: bad rpFreq %d" + rpFreq); } break; default: - return ooer( RI_RPTY, (char *)MH_S0438, // "Internal error in RI::ri_CkF: bad rpTy %d" - (INT)rpTy); + return ooer( RI_RPTY, MH_S0438, // "Internal error in RI::ri_CkF: bad rpTy %d" + rpTy); } // switch (rpTy) @@ -451,9 +451,9 @@ RC RI::ri_CkF() if (rpTy != C_RPTYCH_UDT) { if (fs[RI_RPCPL] & FsSET) - rc = ooer( RI_RPCPL, (char *)MH_S0439, exrp, exrp); // "%sCpl cannot be given unless %sTy is UDT" + rc = ooer( RI_RPCPL, MH_S0439, exrp, exrp); // "%sCpl cannot be given unless %sTy is UDT" if (fs[RI_RPTITLE] & FsSET) - rc = ooer( RI_RPTITLE, (char *)MH_S0440, exrp, exrp); // "%sTitle cannot be given unless %sTy is UDT" + rc = ooer( RI_RPTITLE, MH_S0440, exrp, exrp); // "%sTitle cannot be given unless %sTy is UDT" } // disallow export-only header options for report @@ -562,7 +562,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp case C_RPTYCH_TUSIZE: case C_RPTYCH_TULOAD: // 6-95 if (rpCondGiven) - rc = oer( (char *)MH_S0548, exrp, exrp, tyTx); // "%sCond may not be given with %sType=%s" + rc = oer( MH_S0548, exrp, exrp, tyTx); // "%sCond may not be given with %sType=%s" break; default: ; @@ -624,14 +624,15 @@ RC RI::ri_oneRxp() // process one report or export for topRxp // default/check file reference. Defaulted to rp/exfile in which nested, else default here to "Primary" (supplied by TopStarPrf) if (!ownTi) // if no file given & not defaulted (note default does not set FsSET bit) - { - anc * fb = isEx ? &XfiB : &RfiB; // ptr to reportfile or exportfile input ratbase - if (fb->findRecByNm1( "Primary", &ownTi, NULL)) // find first record by name (ancrec.cpp) / if not found + { anc* fb = isEx ? &XfiB : &RfiB; // ptr to reportfile or exportfile input ratbase + if (fb->findRecByNm1("Primary", &ownTi, NULL)) // find first record by name (ancrec.cpp) / if not found + { if (fb->n) // if not found, if there are ANY r/xport files, ownTi = 1; // use first one: is probably Primary renamed with ALTER else // no r/xport files at all - rc |= ooer( RI_OWNTI, // issue error once (cul.cpp), no run - (const char *)LI(isEx ? MH_S0556 : MH_S0557) ); // "No exExportfile given" or "No rpReportfile given" + rc |= ooer(RI_OWNTI, // issue error once (cul.cpp), no run + isEx ? MH_S0556 : MH_S0557); // "No exExportfile given" or "No rpReportfile given" + } } RFI* rfp=NULL; if (ownTi) @@ -651,7 +652,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp } else // zi <= 0: none given, or SUM or ALL. { - char *znTx /*=""*/; // (redundant init removed 12-94 when BCC 32 4.5 warned) + const char* znTx=""; if (zi==TI_SUM) switch (rpTy) { @@ -674,7 +675,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp default: znTx = "all"; badZn4ty: - return ooer( RI_RPTY, (char *)MH_S0558, // "rpZone=='%s' cannot be used with %sType '%s'" + return ooer( RI_RPTY, MH_S0558, // "rpZone=='%s' cannot be used with %sType '%s'" znTx, exrp, tyTx ); } //else: zi is 0 (or negative garbage). error'd above if omitted when rqd. @@ -689,7 +690,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp } else // no meter given, or ALL or SUM. { - char *mtrTx /*=""*/; // (redundant init removed 12-94 when BCC 32 4.5 warned) + const char* mtrTx = ""; if (mtri==TI_SUM) switch (rpTy) { @@ -711,7 +712,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp default: mtrTx = "all"; badMtr4ty: - return ooer( RI_RPTY, (char *)MH_S0559, // "rpMeter=='%s' cannot be used with %sType '%s'" + return ooer( RI_RPTY, MH_S0559, // "rpMeter=='%s' cannot be used with %sType '%s'" mtrTx, exrp, tyTx ); } //else: mtri is 0 (or negative garbage). error'd above if omitted when rqd. @@ -725,7 +726,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp return RCBAD; } else // no DHW meter given, or ALL - { char *mtrTx /*=""*/; + { const char* mtrTx=""; if (ri_dhwMtri==TI_SUM) { mtrTx = "sum"; goto badDHWMtr4ty; @@ -755,7 +756,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp } else // no DHW meter given, or ALL { - char *mtrTx /*=""*/; + const char* mtrTx=""; if (ri_afMtri == TI_SUM) switch (rpTy) { @@ -791,7 +792,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp } else // no air handler given, or ALL or SUM. { - char *ahTx /*=""*/; // (redundant init removed 12-94 when BCC 32 4.5 warned) + const char* ahTx = ""; if (ahi==TI_SUM) switch (rpTy) { @@ -814,7 +815,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp default: ahTx = "all"; badAh4ty: - return ooer( RI_RPTY, (char *)MH_S0560, // "rpAh=='%s' cannot be used with %sType '%s'" + return ooer( RI_RPTY, MH_S0560, // "rpAh=='%s' cannot be used with %sType '%s'" ahTx, exrp, tyTx ); } //else: ahi is 0 (or negative garbage). error'd above if omitted when rqd. @@ -829,7 +830,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp } else // no air handler given, or ALL or SUM. { - char *tuTx /*=""*/; // (redundant init removed 12-94 when BCC 32 4.5 warned) + const char* tuTx =""; if (tui==TI_SUM) switch (rpTy) { @@ -865,32 +866,35 @@ RC RI::ri_oneRxp() // process one report or export for topRxp // modified value can carry over to later runs if (rpTy) // if good type not given, skip these type-dependent checks + { if (rpTy != C_RPTYCH_UDT) // not user defined { - if (IsSet( RI_RPTITLE)) - oer( (char *)MH_S0561, exrp, exrp); // "%sTitle may only be given when %sType=UDT" + if (IsSet(RI_RPTITLE)) + oer(MH_S0561, exrp, exrp); // "%sTitle may only be given when %sType=UDT" if (coli) - oer( (char *)MH_S0562, exrp, exrePort, exrp); // "%sport has %sCols but %sType is not UDT" + oer(MH_S0562, exrp, exrePort, exrp); // "%sport has %sCols but %sType is not UDT" } else // is a user-defined report { //rpTitle is optional if (!coli) - oer( (char *)MH_S0563, exrp, exrePort); // "no %sCols given for user-defined %s" + oer(MH_S0563, exrp, exrePort); // "no %sCols given for user-defined %s" if (!isEx && coli) // no width check for exports or if no columns - { if (wid > rpCplLocal) // if report too wide - { if (rpCplLocal > 0) - oInfo( "%s width %d is greater than line width %d.\n" + { + if (wid > rpCplLocal) // if report too wide + { + if (rpCplLocal > 0) + oInfo("%s width %d is greater than line width %d.\n" " Line width has been adjusted.", exrePort, wid, rpCplLocal); - // else rpCpl < 0 -> "as wide as needed" (w/o message) + // else rpCpl < 0 -> "as wide as needed" (w/o message) rpCplLocal = wid; // don't change this->rpCpl: *this is input record } } } - + } // set up for runtime per report/export type @@ -1066,7 +1070,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp default: if (!errCount()) // avoid repetition - err( PWRN, (char *)MH_S0565, exrp, rpTy); // "cncult:topRp: unexpected %sTy %d" + err( PWRN, MH_S0565, exrp, rpTy); // "cncult:topRp: unexpected %sTy %d" } // switch (rpTy) @@ -1258,7 +1262,7 @@ RC RFI::rf_CkF2( // start-of-run REPORTFILE / EXPORTFILE check // passed to vrPak, so any addl uses append) // note: dir overwrite detected later else // assume C_FILESTATCH_NEW - oer( (char *)MH_S0544, rf_fileName.CStr()); // "File %s exists". Text also used below. Message stops run. + oer( MH_S0544, rf_fileName.CStr()); // "File %s exists". Text also used below. Message stops run. } fileStatChecked++; // say don't repeat: don't issue error due to prior run's output; // don't set overwrite again (would erase prior output). @@ -1300,7 +1304,7 @@ RC RFI::rf_CheckForDupFileName() // make sure this RFI is only user of its file { if (fip->ss >= ss) // only check smaller-subscripted ones vs this -- else get multiple messages break; if (!_stricmp( fip->rf_fileName, rf_fileName)) - return ooer( RFI_FILENAME, (char *)MH_S0441, mbrIdTx( RFI_FILENAME), rf_fileName.CStr(), fip->Name()); + return ooer( RFI_FILENAME, MH_S0441, mbrIdTx( RFI_FILENAME), rf_fileName.CStr(), fip->Name()); // "Duplicate %s '%s' (already used in ReportFile '%s')" } RLUP( XfiB, fip) @@ -1308,7 +1312,7 @@ RC RFI::rf_CheckForDupFileName() // make sure this RFI is only user of its file if (fip->ss >= ss) // only check smaller-subscripted ones vs this -- else get multiple messages break; if (!_stricmp( fip->rf_fileName, rf_fileName)) - return ooer( RFI_FILENAME, (char *)MH_S0442, mbrIdTx( RFI_FILENAME), rf_fileName.CStr(), fip->Name()); + return ooer( RFI_FILENAME, MH_S0442, mbrIdTx( RFI_FILENAME), rf_fileName.CStr(), fip->Name()); // "Duplicate %s '%s' (already used in ExportFile '%s')" } return RCOK; @@ -1430,7 +1434,7 @@ COL::~COL() //--------------------------------------------------------------------------------------------------------------------------- -char* getErrTitleText() // get "ERR" report title text -- public function +const char* getErrTitleText() // get "ERR" report title text -- public function { // caller 11-91: rmkerr.cpp. used when text first put into ERR virtual report @@ -1459,7 +1463,7 @@ char* getErrTitleText() // get "ERR" report title text -- public function return errTitle; // return pointer to buffer with formatted title text } // getErrTitleText //--------------------------------------------------------------------------------------------------------------------------- -char* getLogTitleText() // get "LOG" report title text -- public function +const char* getLogTitleText() // get "LOG" report title text -- public function // called at first addition of text to LOG report { @@ -1486,7 +1490,7 @@ char* getLogTitleText() // get "LOG" report title text -- public function return logTitle; // return pointer to buffer with formatted title text } // getLogTitleText //--------------------------------------------------------------------------------------------------------------------------- -char* getInpTitleText() // get "INP" report title text -- public function +const char* getInpTitleText() // get "INP" report title text -- public function { // caller 11-91: pp.cpp, at first addition of text to INP report (input listing) @@ -1514,7 +1518,7 @@ char* getInpTitleText() // get "INP" report title text -- public function //--------------------------------------------------------------------------------------------------------------------------- const int HFBUFSZ = 2*132 + 6 + 1 + 100; // 2 lines of text up to 132, 3 crlf's, null, insurance //--------------------------------------------------------------------------------------------------------------------------- -char* getHeaderText([[maybe_unused]] int pageN) // get header text -- public function +const char* getHeaderText([[maybe_unused]] int pageN) // get header text -- public function // (currently no page # in header; argument is to localize changes if one is put there) { @@ -1560,7 +1564,7 @@ char* getHeaderText([[maybe_unused]] int pageN) // get header text -- public return header; // return pointer to buffer with 3 lines of formatted header text & TopM. } // getHeaderText //--------------------------------------------------------------------------------------------------------------------------- -char* getFooterText( int pageN) // get footer text for specified page number -- public function +const char* getFooterText( int pageN) // get footer text for specified page number -- public function // caller is expected to print leading blank line before printing this text. @@ -1734,7 +1738,7 @@ RC topPrfHday() // add default HDAY (holiday) records, before input return RCOK; // unexpected memory full errors not returned } // topPrfHday //--------------------------------------------------------------------------------------------------------------------------- -LOCAL void addHdayDate( char *name, DOY date) // add holiday celebrated on specified date or monday after +LOCAL void addHdayDate( const char* name, DOY date) // add holiday celebrated on specified date or monday after { // for topPrfHday HDAY *hdi; @@ -1745,7 +1749,7 @@ LOCAL void addHdayDate( char *name, DOY date) // add holiday celebrated on spe // topHday will set hdDateObs. } // addHdayDate //--------------------------------------------------------------------------------------------------------------------------- -LOCAL void addHdayRule( char *name, HDAYCASECH hdCase, DOWCH dow, int mon) +LOCAL void addHdayRule( const char* name, HDAYCASECH hdCase, DOWCH dow, int mon) // add holiday celbrated on th of { // for topPrfHday @@ -1780,30 +1784,30 @@ RC topHday() // check HDAY input info / build run info { if (hdi->hdCase || hdi->hdDow || hdi->hdMon) { - hdi->oer( (char *)MH_S0566); // "Can't intermix use of hdCase, hdDow, and hdMon\n" + hdi->oer( MH_S0566); // "Can't intermix use of hdCase, hdDow, and hdMon\n" continue; // " with hdDateTrue, hdDateObs, and hdOnMonday for same holiday" } if (!hdi->hdDateTrue) { - hdi->oer( (char *)MH_S0567); // "No hdDateTrue given" + hdi->oer( MH_S0567); // "No hdDateTrue given" continue; } if (hdi->hdDateTrue < 1 || hdi->hdDateTrue > 365) { - hdi->oer( (char *)MH_S0568); // "hdDateTrue not a valid day of year" + hdi->oer( MH_S0568); // "hdDateTrue not a valid day of year" continue; // only 1 err msg per holiday } if (hdi->hdDateObs) { if (hdi->hdDateObs < 1 || hdi->hdDateObs > 365) { - hdi->oer( (char *)MH_S0569); // "hdDateObs not a valid day of year" + hdi->oer( MH_S0569); // "hdDateObs not a valid day of year" continue; } if (hdi->hdOnMonday) { - hdi->oer( (char *)MH_S0570); // "Can't give both hdDateObs and hdOnMonday" + hdi->oer( MH_S0570); // "Can't give both hdDateObs and hdOnMonday" continue; } } @@ -1812,23 +1816,23 @@ RC topHday() // check HDAY input info / build run info { if (!hdi->hdCase || !hdi->hdDow || !hdi->hdMon) { - hdi->oer( (char *)MH_S0571); // "If any of hdCase, hdDow, hdMon are given, all three must be given" + hdi->oer( MH_S0571); // "If any of hdCase, hdDow, hdMon are given, all three must be given" continue; } if (hdi->hdDow < 1 || hdi->hdDow > 7) { - hdi->oer( (char *)MH_S0572); // "hdDow not a valid day of week" + hdi->oer( MH_S0572); // "hdDow not a valid day of week" continue; } if (hdi->hdMon < 1 || hdi->hdMon > 12) { - hdi->oer( (char *)MH_S0572); // "hdDow not a valid month" + hdi->oer( MH_S0572); // "hdDow not a valid month" continue; } } else { - hdi->oer( (char *)MH_S0573); + hdi->oer( MH_S0573); continue; // "Either hdDateTrue or hdCase+hdDow+hdMon must be given" } diff --git a/src/cncult5.cpp b/src/cncult5.cpp index 2a215023c..b0629394e 100644 --- a/src/cncult5.cpp +++ b/src/cncult5.cpp @@ -127,27 +127,27 @@ RC AH::setup() // check / set up one air handler run record TU* tu; for (tu = NULL; nxTu(tu); ) nTus++; // count terminals (re ahCtu default) - if (!nTus) rc |= oer( (char *)MH_S0614); // "Air handler has no terminals!" + if (!nTus) rc |= oer( MH_S0614); // "Air handler has no terminals!" // outside air (do before return fan) rc |= require( AH_SFAN + FAN_VFDS); // be sure supply fan cfm given b4 next checks - if (sstat[AH_OAVFDSMN] & FsSET) // if outside air design min flow given, check it + if (IsSet( AH_OAVFDSMN)) // if outside air design min flow given, check it { - if (sstat[AH_SFAN + FAN_VFDS] & FsVAL) // if sfanVfDs has value (not autoSize -- NAN!) 7-95 + if (IsVal(AH_SFAN + FAN_VFDS)) // if sfanVfDs has value (not autoSize -- NAN!) 7-95 if (oaVfDsMn > sfan.vfDs) - rc |= ooer( AH_OAVFDSMN, AH_SFAN + FAN_VFDS, - (char *)MH_S0615, /* "oaVfDsMn > sfanVfDs: min outside air greater (%g) " + rc |= ooer2( AH_OAVFDSMN, AH_SFAN + FAN_VFDS, + MH_S0615, /* "oaVfDsMn > sfanVfDs: min outside air greater (%g) " "than supply fan capacity (%g)" */ oaVfDsMn, sfan.vfDs ); } else // outside air design min flow not given, default it { float def = 0.15f * area; // .15 cfm per square foot served area - if ( sstat[AH_SFAN + FAN_VFDS] & FsVAL // if sfanVfDs has value (not autoSize -- NAN!) 7-95 + if ( IsVal(AH_SFAN + FAN_VFDS) // if sfanVfDs has value (not autoSize -- NAN!) 7-95 && def > sfan.vfDs ) - rc |= ooer( AH_OAVFDSMN, AH_SFAN + FAN_VFDS, - (char *)MH_S0616, /* "oaVfDsMn required: default (%g) of .15 cfm per sf" + rc |= ooer2( AH_OAVFDSMN, AH_SFAN + FAN_VFDS, + MH_S0616, /* "oaVfDsMn required: default (%g) of .15 cfm per sf" " of served area (%g) \n" " would be greater than supply fan capacity (%g)" */ def, area, sfan.vfDs ); @@ -164,16 +164,16 @@ RC AH::setup() // check / set up one air handler run record if (oaEcoTy==C_ECOTYCH_NONE) // if no economizer (default) { - rc |= disallowN( (char *)MH_S0617, // "when no economizer (oaEcoTy NONE or omitted)" + rc |= disallowN( MH_S0617, // "when no economizer (oaEcoTy NONE or omitted)" AH_OALIMT, AH_OALIME, 0 ); // not allowed when no eco } //else ... eco present float lkSum = oaOaLeak + oaRaLeak; if (lkSum > 1.f) - rc = ooer( AH_OAOALEAK, AH_OARALEAK, - (char *)MH_S0618, // "oaOaLeak + oaRaLeak = %g: leaking %d% of mixed air!" - lkSum, (INT)(lkSum * 100 + .5f) ); + rc = ooer2( AH_OAOALEAK, AH_OARALEAK, + MH_S0618, // "oaOaLeak + oaRaLeak = %g: leaking %d% of mixed air!" + lkSum, (int)(lkSum * 100 + .5f) ); // check fan and coil subrecords @@ -237,10 +237,10 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf if (!dflCtu) // no errmsg for dfl'd ctu: don't know ctu use intended, 4-1-92. // --> runtime must also check ahCtu for having a setpoint. if (!(tu->cmAr & cmStBOTH)) - rc |= tu->ooer( TU_TUTH, TU_TUTC, - (char *)MH_S0619, /* "Control Terminal for air handler %s:\n" - " Must give heating setpoint tuTH and/or cooling setpoint tuTC" */ - name ); + rc |= tu->ooer2( TU_TUTH, TU_TUTC, + MH_S0619, // "Control Terminal for air handler %s:\n" + // " Must give heating setpoint tuTH and/or cooling setpoint tuTC" + Name() ); tu->ctrlsAi = ss; // set .ctrlsAi of terminal that controls this ah } @@ -250,10 +250,10 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf // (changed from RQD 5-8-92 cuz users would give ahTsSp w/o coil then wonder why no heating/cooling occurred) if (oaEcoTy==C_ECOTYCH_NONE && ahhc.coilTy==C_COILTYCH_NONE && ahcc.coilTy==C_COILTYCH_NONE) - rc |= disallow( (char *)MH_S0620, AH_AHTSSP); // "when air handler has no econimizer nor coil\n" + rc |= disallow( MH_S0620, AH_AHTSSP); // "when air handler has no econimizer nor coil\n" // (did you forget to specify your coil?)" else - rc |= require( (char *)MH_S0621, AH_AHTSSP); // "unless air handler has no economizer nor coil" + rc |= require( MH_S0621, AH_AHTSSP); // "unless air handler has no economizer nor coil" // if supply temp setpoint / ctrl method value stored (thus constant), can check now for user convenience. // must REPEAT CHECKS AT RUNTIME in case variable expr given! @@ -265,12 +265,12 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf case C_TSCMNC_ZN2: case C_TSCMNC_ZN: if (!ahCtu) // not if defaulted above - rc |= require( (char *)MH_S0622, AH_AHCTU); // "when ahTsSp is ZN or ZN2 and " + rc |= require( MH_S0622, AH_AHCTU); // "when ahTsSp is ZN or ZN2 and " // "more than one terminal served" break; case C_TSCMNC_RA: - rc |= requireN( (char *)MH_S0623, // "when ahTsSp is RA" + rc |= requireN( MH_S0623, // "when ahTsSp is RA" AH_AHTSMN, AH_AHTSMX, AH_AHTSRAMN, AH_AHTSRAMX, 0 ); break; } @@ -279,24 +279,32 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf // fanCycles setup time checks if inputs constant; must also check at runtime as run-variable +#if 1 + if ( (IsVal( AH_AHTSSP) // if ahTsSp given and not runtime-variable + && ISNCHOICE(ahTsSp) && CHN(ahTsSp)==C_TSCMNC_ZN // and if ahTsSp is ZN (not ZN2) + && !IsSet(AH_AHFANCYCLES)) // and if ahFanCycles NOT given --> defaults yes at runtime + // (yes given... fall thru) + || (IsVal( AH_AHFANCYCLES) && CHN(ahFanCycles)==C_NOYESVC_YES) ) // OR if ahFanCycles is constant YES +#else if ( sstat[AH_AHTSSP] & FsVAL // if ahTsSp given and not runtime-variable && ISNCHOICE(ahTsSp) && CHN(ahTsSp)==C_TSCMNC_ZN // and if ahTsSp is ZN (not ZN2) && !(sstat[AH_AHFANCYCLES] & FsSET) /* and if ahFanCycles NOT given --> defaults yes at runtime (yes given... fall thru) */ - || sstat[AH_AHFANCYCLES] & FsVAL && CHN(ahFanCycles)==C_NOYESVC_YES ) // OR if ahFanCycles is constant YES + || ((sstat[AH_AHFANCYCLES] & FsVAL) && CHN(ahFanCycles)==C_NOYESVC_YES) ) // OR if ahFanCycles is constant YES +#endif { // fanCyles and ZN2 (fan stays on even when ctrl zone is floating) are contradictory if (ISNCHOICE(ahTsSp) && CHN(ahTsSp)==C_TSCMNC_ZN2) - rc |= ooer( AH_AHFANCYCLES, (char *)MH_S0624, Name()); // "ahFanCycles=YES not allowed when ahTsSp is ZN2" + rc |= ooer( AH_AHFANCYCLES, MH_S0624, Name()); // "ahFanCycles=YES not allowed when ahTsSp is ZN2" // only 1 terminal can be used (or would have to force other-tu fraction of full flow to match control tu) // (with ahTsSp=ZN/2 and ahFanCycles=NO we are not yet enforcing single tu as would work even if unreal, 6-92) if (nTus > 1) - rc |= ooer( AH_AHTSSP, (char *)MH_S0625); // "More than one terminal not allowed on air handler when fan cycles" + rc |= ooer( AH_AHTSSP, MH_S0625); // "More than one terminal not allowed on air handler when fan cycles" // control terminal required (redundant insurance, as defaulted above to only tu) if (!ahCtu) - rc |= ooer( AH_AHTSSP, (char *)MH_S0626); // "No control terminal: required when fan cycles." + rc |= ooer( AH_AHTSSP, MH_S0626); // "No control terminal: required when fan cycles." // extra warnings if fanCycles known now (can be runtime variable) @@ -304,14 +312,14 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf if ( oaMnCm==C_OAMNCH_VOL // if outside air spec'd by volume (default) not fraction && (!ISNUM(oaMnFrac) || oaMnFrac != 0.) // if minimum multplier is expression or non-0 (default 1.0) && oaVfDsMn > 0. ) // if outside flow air has not been set to 0 (default .15 area, above) - oWarn( (char *)MH_S0627); /* "When fan cycles, \"constant volume\" outside air works differently than you\n" + oWarn( MH_S0627); /* "When fan cycles, \"constant volume\" outside air works differently than you\n" " may expect: outside air will be supplied only when fan is on per zone\n" " thermostat. To disable outside air use the command \"oaVfDsMn = 0;\"." */ // warn if tu max flows not same as supply fan // Runtime handles differences, but with constant values, difference is probably an error. // Don't know whether system will heat, cool, or both, so just check given non-0 values. - if ( sstat[AH_SFAN+FAN_VFDS] & FsVAL // skip if sfan des flow not set (due to other error or autoSize) + if ( IsVal( AH_SFAN+FAN_VFDS) // skip if sfan des flow not set (due to other error or autoSize) && ahCtu) // skip if no control terminal (messaged just above) { TU *ctu = TuB.p + ahCtu; // point control terminal's TU record. @@ -320,25 +328,25 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf DBL sfanLo = sfanMx * .999 // min supply fan flow avail to terminal, less roundoff allowance, * (1.0 - max( ahROLeak, ahSOLeak)); /* .. less generous allowance for duct leakage (currently AVERAGE of ROLeak, SOLeak used in cnah.cpp, 6-92) */ - if (ctu->sstat[TU_TUVFMXC] & FsVAL) // if constant (not expr) value given for tu max cooling flow + if (ctu->IsVal(TU_TUVFMXC)) // if constant (not expr) value given for tu max cooling flow { float tuMx = ctu->tuVfMxC; // fetch the value. if (tuMx != 0.) // if 0, probably no cooling intended. if (tuMx < sfanLo || tuMx > sfanHi) /* if tu flow clearly different from sfan flow even if user adjusted tu flow for ah duct leakage */ - oWarn( (char *)MH_S0628, /* "Supply fan maximum flow (vfDs x vfMxF) is %g,\n" + oWarn( MH_S0628, /* "Supply fan maximum flow (vfDs x vfMxF) is %g,\n" " but terminal '%s' max cooling air flow (tuVfMxC) is %g.\n" " Usually, these should be equal when fan cycles.\n" " The more limiting value will rule." */ sfanMx, ctu->Name(), tuMx ); } - if (ctu->sstat[TU_TUVFMXH] & FsVAL) // if constant (not expr) value given for tu max heating flow + if (ctu->IsVal(TU_TUVFMXH)) // if constant (not expr) value given for tu max heating flow { float tuMx = ctu->tuVfMxH; // fetch the value. if (tuMx != 0.) // if 0, probably no heating intended. if (tuMx < sfanLo || tuMx > sfanHi) /* if tu flow clearly different from sfan flow even if user adjusted tu flow for ah duct leakage */ - oWarn( (char *)MH_S0629, /* "Supply fan maximum flow (vfDs x vfMxF) is %g,\n" + oWarn( MH_S0629, /* "Supply fan maximum flow (vfDs x vfMxF) is %g,\n" " but terminal '%s' max heating air flow (tuVfMxH) is %g.\n" " Usually, these should be equal when fan cycles.\n" " The more limiting value will rule." */ @@ -351,8 +359,8 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf if (ahCtu) // skip if no control terminal (messaged above) { TU *ctu = TuB.p + ahCtu; - if ((ctu->sstat[TU_TUVFMN] & FsVAL) && ctu->tuVfMn > 0.) // if > 0 constant given for terminal min flow - oer( (char *)MH_S0630, /* "Control terminal '%s':\n" + if (ctu->IsVal(TU_TUVFMN) && ctu->tuVfMn > 0.) // if > 0 constant given for terminal min flow + oer( MH_S0630, /* "Control terminal '%s':\n" " tuVfMn=%g: must be zero or omitted when fan cycles." */ ctu->Name(), ctu->tuVfMn ); @@ -361,7 +369,7 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf AUTOSIZE tuVfMn, no ahFanCycles, variable ahTsSp sometimes ZN: believe no input check 8-28-95. runtime: when fanCycles, autoSized tuVfMn left 0 (cnztu) but error if already non-0 (cnah1). */ - if (ctu->sstat[TU_TUVFMN] & FsAS) + if (ctu->IsAusz(TU_TUVFMN)) ctu->oer( "Can't give AUTOSIZE tuVfMn when air handler fan cycles:\n" " When fan cycles, terminal minimum flow must be zero, but \n" " AUTOSIZE tuVfMn makes minumum flow equal to maximum flow."); // NUMS @@ -392,7 +400,7 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf * } #endif - if (sstat[AH_AHHC+AHHEATCOIL_CAPTRAT] & FsAS) // if AUTOSIZE ahhcCaptRat given + if (IsAusz( AH_AHHC+AHHEATCOIL_CAPTRAT)) // if AUTOSIZE ahhcCaptRat given switch (ahhc.coilTy) { case C_COILTYCH_HW: @@ -409,7 +417,7 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf break; // NUMS } - if (sstat[AH_AHCC+COOLCOIL_CAPTRAT] & FsAS) // if AUTOSIZE ahccCaptRat given + if (IsAusz( AH_AHCC+COOLCOIL_CAPTRAT)) // if AUTOSIZE ahccCaptRat given { switch (ahcc.coilTy) { @@ -427,7 +435,7 @@ x ? sfan.vfDs - oaVfDsMn // default rfan cfm: sf " when air handler has no cool coil."); break; // NUMS } - if (sstat[AH_AHCC+COOLCOIL_CAPSRAT] & FsSET) + if (IsSet( AH_AHCC+COOLCOIL_CAPSRAT)) rc |= oer( "Cannot give 'capsRat' when autoSizing captRat."); // NUMS } @@ -478,7 +486,7 @@ RC CCH::setup( // check/initialize a CRANKCASE HEATER subrecord //uncomment as need found //#define REQUIRESCCH(subFn) r->require( cchFn+CCH_##subFn) // issue error message if field of subrecord not given //#define ERSCCH(subFn) ah->ooer( cchFn+CCH_##subFn, // subrecord field err msg: addl arg(s) and ) must follow -#define ERS2CCH(f1,f2) ah->ooer( cchFn+CCH_##f1, cchFn+CCH_##f2, // subrecord 2-field error message ditto +#define ERS2CCH(f1,f2) ah->ooer2( cchFn+CCH_##f1, cchFn+CCH_##f2, // subrecord 2-field error message ditto #define R ((record *)ah) RC rc=RCOK; @@ -500,7 +508,7 @@ RC CCH::setup( // check/initialize a CRANKCASE HEATER subrecord { if (subFn==CCH_CCHCM && cm==C_CCHCM_NONE) // explicit "none" continue; // always ok - rc = R->cantGiveEr( cchFn+subFn, (char *)MH_S0631); // "when cchCM is NONE" + rc = R->cantGiveEr( cchFn+subFn, MH_S0631); // "when cchCM is NONE" } return rc; } @@ -523,18 +531,18 @@ RC CCH::setup( // check/initialize a CRANKCASE HEATER subrecord break; // cch appropriate with air source heat pump! } if (!cchOk) - ah->oWarn( (char *)MH_S0632); /* "Crankcase heater specifed, but neither heat coil nor cool coil \n" + ah->oWarn( MH_S0632); /* "Crankcase heater specifed, but neither heat coil nor cool coil \n" " is a type for which crankcase heater is appropriate" */ //--- checks for PTC if (cm==C_CCHCM_PTC || cm==C_CCHCM_PTC_CLO) { - if (pMx <= pMn) ERS2CCH(PMX,PMN) (char *)MH_S0633, pMx, pMn); // "cchPMx (%g) must be > cchPMn (%g)" - if (tMx > tMn) ERS2CCH(TMX,TMN) (char *)MH_S0634, tMx, tMn); // "cchTMx (%g) must be <= cchTMn (%g)" - } -else - ah->disallowN( (char *)MH_S0635, // "when cchCM is not PTC nor PTC_CLO" + if (pMx <= pMn) ERS2CCH(PMX,PMN) MH_S0633, pMx, pMn); // "cchPMx (%g) must be > cchPMn (%g)" + if (tMx > tMn) ERS2CCH(TMX,TMN) MH_S0634, tMx, tMn); // "cchTMx (%g) must be <= cchTMn (%g)" + } + else + ah->disallowN( MH_S0635, // "when cchCM is not PTC nor PTC_CLO" cchFn+CCH_PMN, cchFn+CCH_TMX, cchFn+CCH_TMN, cchFn+CCH_DT, 0 ); //--- checks/defaults for TSTAT @@ -542,10 +550,10 @@ else if (cm==C_CCHCM_TSTAT) { if (!(fss[CCH_TOFF])) tOff = tOn; // if tOff not given by user, default it to tOn. - if (tOff < tOn) ERS2CCH(TOFF,TON) (char *)MH_S0636, tOff, tOn); // "cchTOff (%g) must be > cchTOn (%g)" + if (tOff < tOn) ERS2CCH(TOFF,TON) MH_S0636, tOff, tOn); // "cchTOff (%g) must be > cchTOn (%g)" } else - ah->disallowN( (char *)MH_S0637, cchFn+CCH_TOFF, cchFn+CCH_TON, 0 ); // "when cchCM is not TSTAT" + ah->disallowN( MH_S0637, cchFn+CCH_TOFF, cchFn+CCH_TON, 0 ); // "when cchCM is not TSTAT" //--- setup heater energy use during ARI tests (Niles V-K-5-a) @@ -569,10 +577,10 @@ else case C_CCHCM_TSTAT: break; // 0 (preset) when running or cycling. #if 0//looks wrong -x default: return ooer( cchCM, (char *)MH_S0638, (INT)cm); // "Internal error: Bad cchCM %d" +x default: return ooer( cchCM, MH_S0638, cm); // "Internal error: Bad cchCM %d" #else//7-95. untested. default: - return ah->ooer( cchFn+CCH_CCHCM, (char *)MH_S0638, (INT)cm); // "Internal error: Bad cchCM %d" + return ah->ooer( cchFn+CCH_CCHCM, MH_S0638, cm); // "Internal error: Bad cchCM %d" #endif } //convert power to energy for energy members: restore if needed. @@ -599,7 +607,7 @@ RC COIL::setup( // check/set up a base class coil subrecord { #define REQUIRESC(subFn) r->require( coilFn+COIL_##subFn) // issue error message if field of subrecord not given #define ERSC(subFn) r->ooer( coilFn+COIL_##subFn, // subrecord field err msg: addl arg(s) and ) must follow -#define ERS2C(f1,f2) r->ooer( coilFn+COIL_##f1, coilFn+COIL_##f2, // subrecord 2-field error message ditto +#define ERS2C(f1,f2) r->ooer2( coilFn+COIL_##f1, coilFn+COIL_##f2, // subrecord 2-field error message ditto #define IDSC(subFn) r->mbrIdTx( coilFn+COIL_##subFn) // subrecord field name, from CULT search for polymorphism RC rc = RCOK; @@ -621,7 +629,7 @@ RC COIL::setup( // check/set up a base class coil subrecord break; // (ahcc, ahhc: omitted coilTy means absent coil) default: - return r->oer( (char *)MH_S0639, app); // "Internal error: cncult5.cpp:ckCoil: bad coil app 0x%x" + return r->oer( MH_S0639, app); // "Internal error: cncult5.cpp:ckCoil: bad coil app 0x%x" } // return if coil not present or not allowed @@ -633,7 +641,7 @@ RC COIL::setup( // check/set up a base class coil subrecord //--- aux energy drain checks: power without meter accumulates to AHRES pAuxC/H only; meter without power warns here. #define MTRWRN( mtri, pow) if (fss[COIL_##mtri] & FsSET) if (!(fss[COIL_##pow] & FsSET)) \ - r->oWarn( (char *)MH_S0640, IDSC(mtri), IDSC(pow)); + r->oWarn( MH_S0640, IDSC(mtri), IDSC(pow)); // "'%s' given, but no '%s' to charge to it given" MTRWRN( AUXMTRI, AUX); #undef MTRWRN @@ -660,7 +668,7 @@ RC COOLCOIL::setup( // check/set up a cooling coil subrecord: has additional #define AHR ((AH*)r) #define REQUIRESCC(subFn) r->require( coolCoilFn+COOLCOIL_##subFn) // issue error message if field of subrecord not given #define ERSCC(subFn) r->ooer( coolCoilFn+COOLCOIL_##subFn, // subrecord field err msg: addl arg(s) and ) must follow -#define ERS2CC(f1,f2) r->ooer( coolCoilFn+COOLCOIL_##f1, coolCoilFn+COOLCOIL_##f2, // subrecord 2-field error message ditto +#define ERS2CC(f1,f2) r->ooer2( coolCoilFn+COOLCOIL_##f1, coolCoilFn+COOLCOIL_##f2, // subrecord 2-field error message ditto #define IDSCC(subFn) r->mbrIdTx( coolCoilFn+COOLCOIL_##subFn) // subrecord field name, from CULT search for polymorphism // default cubic polynomial coefficients: array of 4 floats. uses r, fss, coolCoilFn. @@ -695,7 +703,7 @@ RC COOLCOIL::setup( // check/set up a cooling coil subrecord: has additional if (subFn != COOLCOIL_COILTY) // don't say "can't give ahccType when ahccType is NONE or omitted" #endif rc = r->cantGiveEr( coolCoilFn + subFn, - (char *)MH_S0641 ); // "when ahccType is NONE or omitted" + MH_S0641 ); // "when ahccType is NONE or omitted" /* <-- generalize above subtext if used for other coils (test app -- for speed, avoid mbrIdTx's & sprintf's executed b4 error detected) */ @@ -716,7 +724,7 @@ RC COOLCOIL::setup( // check/set up a cooling coil subrecord: has additional break; //badCoilTy: default: - rc = ERSCC(COILTY) (char *)MH_S0642, // "Bad coil type '%s' for %s" + rc = ERSCC(COILTY) MH_S0642, // "Bad coil type '%s' for %s" r->getChoiTx( coolCoilFn+COOLCOIL_COILTY, 1, ty), IDSCC(COILTY) ); return rc; // don't continue with bad type @@ -738,7 +746,7 @@ RC COOLCOIL::setup( // check/set up a cooling coil subrecord: has additional capsRat = -fabs(capsRat); // .. // nan not expected for capsRat: constant, not autoSizable, 7-95. if (capsRat < captRat) // negatives! - rc = ERS2CC( CAPSRAT, CAPTRAT) (char *)MH_S0643, // "Sensible capacity '%s' larger than Total capacity '%s'" + rc = ERS2CC( CAPSRAT, CAPTRAT) MH_S0643, // "Sensible capacity '%s' larger than Total capacity '%s'" IDSCC(CAPSRAT), IDSCC(CAPTRAT) ); } } @@ -758,7 +766,7 @@ x : 0.; // else 0 (eg if setup calls rearranged or autoSize) if (ty==C_COILTYCH_CHW) { // inputs required for CHW coil - rc |= r->requireN( (char *)MH_S0644, // "when ahccType is CHW" + rc |= r->requireN( MH_S0644, // "when ahccType is CHW" coolCoilFn + COOLCOIL_CPI, // ahccCoolplant coolCoilFn + COOLCOIL_GPMDS, // ahccGpmDs 0 ); @@ -779,7 +787,7 @@ x : 0.; // else 0 (eg if setup calls rearranged or autoSize) } // inputs NOT allowed with CHW coil - r->disallowN( (char *)MH_S0645, // "when ahccType is CHW" + r->disallowN( MH_S0645, // "when ahccType is CHW" coolCoilFn + COOLCOIL_CAPTRAT, // inputs allowed for most coil types, not CHW coolCoilFn + COOLCOIL_CAPSRAT, coolCoilFn + COOLCOIL_SHRRAT, @@ -789,7 +797,7 @@ x : 0.; // else 0 (eg if setup calls rearranged or autoSize) else /* coilTy != C_COILTYCH_CHW. issue error messages for CHW-specific inputs, last (low priority) as these are relatively uninformative messages. */ { - r->disallowN( (char *)MH_S0646, // "when ahccType is not CHW" + r->disallowN( MH_S0646, // "when ahccType is not CHW" // <--- generalize above type name if this used for other coils! coolCoilFn + COOLCOIL_CPI, coolCoilFn + COOLCOIL_GPMDS, @@ -816,7 +824,7 @@ x : 0.; // else 0 (eg if setup calls rearranged or autoSize) // disallow both ahccVfR and ahccVfRperTon, 8-28-95 if (fss[COOLCOIL_VFR] & FsSET && fss[COOLCOIL_VFRPERTON] & FsSET) - rc = r->oer( (char *)MH_S0652, // "Cannot give both %s and %s" NUMS no, new use. + rc = r->oer( MH_S0652, // "Cannot give both %s and %s" NUMS no, new use. IDSCC(VFR), IDSCC(VFRPERTON) ); // Use same assumptions as RSYS to default if vfRperTon is set. Otherwise, use CULT default (0.77) @@ -864,7 +872,7 @@ x : 0.; // else 0 (eg if setup calls rearranged or autoSize) else /* coilTy != C_COILTYCH_DX. issue error messages for DX-specific inputs, last (low priority) as these are relatively uninformative messages. */ { - r->disallowN( (char *)MH_S0648, // "when ahccType is not DX" + r->disallowN( MH_S0648, // "when ahccType is not DX" // <--- generalize above type member name if this used for other coils! coolCoilFn + COOLCOIL_MINTEVAP, //coolCoilFn + COOLCOIL_K1, disallowed below if not CHW or DX @@ -887,7 +895,7 @@ x : 0.; // else 0 (eg if setup calls rearranged or autoSize) // members disallowed if neither DX nor CHW (ie if ELEC) if (ty != C_COILTYCH_DX && ty != C_COILTYCH_CHW) - r->disallowN( (char *)MH_S0649, // "when ahccType is not DX nor CHW" + r->disallowN( MH_S0649, // "when ahccType is not DX nor CHW" // <--- generalize above type mbr name if other coils get here! coolCoilFn + COOLCOIL_K1, coolCoilFn + COOLCOIL_VFR, @@ -921,7 +929,7 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional //#define AHR ((AH*)r) #define REQUIRESHC(subFn) r->require( heatCoilFn+HEATCOIL_##subFn) // issue error message if field of subrecord not given #define ERSHC(subFn) r->ooer( heatCoilFn+HEATCOIL_##subFn, // subrecord field err msg: addl arg(s) and ) must follow -#define ERS2HC(f1,f2) r->ooer( heatCoilFn+HEATCOIL_##f1, heatCoilFn+HEATCOIL_##f2, // subrecord 2-field error message ditto +#define ERS2HC(f1,f2) r->ooer2( heatCoilFn+HEATCOIL_##f1, heatCoilFn+HEATCOIL_##f2, // subrecord 2-field error message ditto #define IDSHC(subFn) r->mbrIdTx( heatCoilFn+HEATCOIL_##subFn) // subrecord field name, from CULT search for polymorphism // default cubic polynomial coefficients: array of 4 floats. uses r, fss, heatCoilFn. @@ -938,7 +946,7 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional // } RC rc /*=RCOK*/; - char *when = "bug"; // for various error message subtexts per coil application. cannot be MH. + const char* when = "bug"; // for various error message subtexts per coil application. cannot be MH. //--- first setup the general coil which is base class of HEATCOIL @@ -990,7 +998,7 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional if (ty==C_COILTYCH_ELEC) break; badCoilTy: - return ERSHC(COILTY) (char *)MH_S0650, // "Bad coil type '%s' for %s" + return ERSHC(COILTY) MH_S0650, // "Bad coil type '%s' for %s" r->getChoiTx( heatCoilFn+HEATCOIL_COILTY, 1, ty), IDSHC(COILTY) ); } @@ -999,7 +1007,6 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional if (ty != C_COILTYCH_AHP) { - // check for required members given rc |= REQUIRESHC(CAPTRAT); // all heat coils but AHP require total capacity input @@ -1009,15 +1016,17 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional if (fss[COIL_CAPTRAT] & FsVAL) // expression input may be accepted for heating coils if (captRat <= 0.) - rc |= ERSHC(CAPTRAT) (char *)MH_S0651, captRat); // "Heating coil rated capacity 'captRat' %g is not > 0" + { + rc |= ERSHC(CAPTRAT) MH_S0651, captRat); // "Heating coil rated capacity 'captRat' %g is not > 0" // disallow giving both efficiency and eir (could accept if consistent, but eir can be expr, too much bother). if (fss[HEATCOIL_EIRRAT] & FsSET) // if eirRat (ahhcEirR) given (expression allowed) if (fss[HEATCOIL_EFFRAT] & FsSET) // if effRat (ahhcEffR) also given - ERS2HC( EIRRAT, EFFRAT) (char *)MH_S0652, // "Cannot give both %s and %s" - IDSHC(EIRRAT), IDSHC(EFFRAT) ); - } + ERS2HC(EIRRAT, EFFRAT) MH_S0652, // "Cannot give both %s and %s" + IDSHC(EIRRAT), IDSHC(EFFRAT)); + } + } // electric heat coil additional input checks @@ -1035,10 +1044,10 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional if (fss[HEATCOIL_EIRRAT] & FsSET) // error if eirRat given if ( !(fss[HEATCOIL_EIRRAT] & FsVAL) // and value is not constant || eirRat != 1.0 ) // or not 1.0 - ERSHC(EIRRAT) (char *)MH_S0653, when, IDSHC(EIRRAT) ); // "%s, %s must be constant 1.0 or omitted" + ERSHC(EIRRAT) MH_S0653, when, IDSHC(EIRRAT) ); // "%s, %s must be constant 1.0 or omitted" if (fss[HEATCOIL_EFFRAT] & FsSET) // if effRat given (CULT requires constant) if (effRat != 1.0) // error if value not 1.0 - ERSHC(EFFRAT) (char *)MH_S0654, when, IDSHC(EFFRAT) ); // "%s, %s must be 1.0 or omitted" + ERSHC(EFFRAT) MH_S0654, when, IDSHC(EFFRAT) ); // "%s, %s must be 1.0 or omitted" // CULT defaults eirR to 1.0, and code doesn't use it anyway 7-92, so no need to default here. } @@ -1061,7 +1070,7 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional { if (fss[HEATCOIL_EIRRAT] & FsVAL) // if constant given, can check now if (eirRat < 1.0) // (runtime check also needed in case expr given) - ERSHC(EIRRAT) (char *)MH_S0655, IDSHC(EIRRAT) ); // "%s must be >= 1.0" + ERSHC(EIRRAT) MH_S0655, IDSHC(EIRRAT) ); // "%s must be >= 1.0" //if eff also given, error issued above. } else // eir not given @@ -1071,13 +1080,13 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional // use eirR 1.0 defaulted by CULT? // or default eirR to ?? // error message: either eir or eff required: - ERS2HC( EIRRAT, EFFRAT) (char *)MH_S0656, // "%s,\n Either %s or %s must be given" + ERS2HC( EIRRAT, EFFRAT) MH_S0656, // "%s,\n Either %s or %s must be given" when, IDSHC(EIRRAT), IDSHC(EFFRAT) ); } else if (effRat > 1.0) // redundant: field limit should check for <= 1. - ERSHC(EFFRAT) (char *)MH_S0657, IDSHC(EFFRAT) ); // "%s must be <= 1.0" + ERSHC(EFFRAT) MH_S0657, IDSHC(EFFRAT) ); // "%s must be <= 1.0" else if (effRat <= 0.) // /0 insurance: field limits should check for > 0. - ERSHC(EFFRAT) (char *)MH_S0658, IDSHC(EFFRAT) ); // "%s must be > 0." + ERSHC(EFFRAT) MH_S0658, IDSHC(EFFRAT) ); // "%s must be > 0." else eirRat = 1./effRat; } @@ -1109,7 +1118,7 @@ RC HEATCOIL::setup( // check/set up a heating coil subrecord: has additional if (ty==C_COILTYCH_HW) { - char *hpiMbrName = nullptr; + const char *hpiMbrName = nullptr; switch (app) // get subtexts for following error messages { case C_COILAPPCH_AHHC: @@ -1191,7 +1200,7 @@ RC AHHEATCOIL::setup( // check/set up an ah heating coil subrecord, incl inpu #define AHR ((AH*)r) #define REQUIRESAHC(subFn) r->require( ahhCoilFn+AHHEATCOIL_##subFn) // issue error message if field of subrecord not given #define ERSAHC(subFn) r->ooer( ahhCoilFn+AHHEATCOIL_##subFn, // subrecord field err msg: addl arg(s) and ) must follow -#define ERS2AHC(f1,f2) r->ooer( ahhCoilFn+AHHEATCOIL_##f1, ahhCoilFn+AHHEATCOIL_##f2, // subrecord 2-field error message ditto +#define ERS2AHC(f1,f2) r->ooer2( ahhCoilFn+AHHEATCOIL_##f1, ahhCoilFn+AHHEATCOIL_##f2, // subrecord 2-field error message ditto //#define IDSAHC(subFn) r->mbrIdTx( ahhCoilFn+AHHEATCOIL_##subFn) // subrecord field name, from CULT search for polymorphism RC rc /*=RCOK*/; @@ -1213,7 +1222,7 @@ RC AHHEATCOIL::setup( // check/set up an ah heating coil subrecord, incl inpu // for all members of derived class not in base class: start at HEATCOIL_NFIELDs for normal-case speed. for (subFn = HEATCOIL_NFIELDS; subFn < AHHEATCOIL_NFIELDS; subFn++ ) // loop field numbers if (fss[subFn] & FsSET) // if member given in input - rc = r->cantGiveEr( ahhCoilFn + subFn, (char *)MH_S0659); // "when ahhcType is NONE or omitted" + rc = r->cantGiveEr( ahhCoilFn + subFn, MH_S0659); // "when ahhcType is NONE or omitted" return rc; } @@ -1225,7 +1234,7 @@ RC AHHEATCOIL::setup( // check/set up an ah heating coil subrecord, incl inpu // for all members of derived class not in base class: start at HEATCOIL_NFIELDs. for (subFn = HEATCOIL_NFIELDS; subFn < AHHEATCOIL_NFIELDS; subFn++ ) // loop field numbers if (fss[subFn] & FsSET) // if member given in input - rc = r->cantGiveEr( ahhCoilFn + subFn, (char *)MH_S0660); // "when ahhcType is not AHP" + rc = r->cantGiveEr( ahhCoilFn + subFn, MH_S0660); // "when ahhcType is not AHP" #else // use this form when AHP inputs are no longer an identifiable range of field numbers * #define f ahhCoilFn+AHHEATCOIL_## @@ -1241,7 +1250,7 @@ RC AHHEATCOIL::setup( // check/set up an ah heating coil subrecord, incl inpu //------ rest of function sets up AHP (air source heat pump) whose members are in the AHHEATPUMP derived class record only // AHP required members - rc |= r->requireN( (char *)MH_S0661, // "when ahhcType is AHP" + rc |= r->requireN( MH_S0661, // "when ahhcType is AHP" ahhCoilFn+AHHEATCOIL_CAPTRAT, ahhCoilFn+AHHEATCOIL_COP17, ahhCoilFn+AHHEATCOIL_COP47, 0 ); @@ -1252,23 +1261,23 @@ RC AHHEATCOIL::setup( // check/set up an ah heating coil subrecord, incl inpu if (r->IsSet(ahhCoilFn+AHHEATCOIL_CAP17)) rc |= r->disallowN("when ahpCap17 is given", ahhCoilFn+AHHEATCOIL_CAPRAT1747, 0); if (dfrFMx <= dfrFMn) - rc |= ERS2AHC(DFRFMX,DFRFMN) (char *)MH_S0663,dfrFMx,dfrFMn); //"ahpDfrFMx (%g) must be > ahpDfrFMn (%g)" + rc |= ERS2AHC(DFRFMX,DFRFMN) MH_S0663,dfrFMx,dfrFMn); //"ahpDfrFMx (%g) must be > ahpDfrFMn (%g)" if (tOff > tOn) - rc |= ERS2AHC(TOFF,TON) (char *)MH_S0664, tOff, tOn); //"ahpTOff (%g) must be <= ahpTOn (%g)" + rc |= ERS2AHC(TOFF,TON) MH_S0664, tOff, tOn); //"ahpTOff (%g) must be <= ahpTOn (%g)" if (cd >= 1.0) - rc |= ERSAHC(CD) (char *)MH_S0665, cd); // "ahpCd (%g) must be < 1" rob addition + rc |= ERSAHC(CD) MH_S0665, cd); // "ahpCd (%g) must be < 1" rob addition // 3 checks for tFrMn < tFrPk < tFrMx if (tFrMn >= tFrMx) - rc |= ERS2AHC(TFRMN,TFRMX) (char *)MH_S0666, tFrMn,tFrMx); // "ahpTFrMn (%g) must be < ahpTFrMx (%g)" + rc |= ERS2AHC(TFRMN,TFRMX) MH_S0666, tFrMn,tFrMx); // "ahpTFrMn (%g) must be < ahpTFrMx (%g)" if (tFrMn >= tFrPk) - rc |= ERS2AHC(TFRMN,TFRPK) (char *)MH_S0667, tFrMn,tFrPk); // "ahpTFrMn (%g) must be < ahpTFrPk (%g)" + rc |= ERS2AHC(TFRMN,TFRPK) MH_S0667, tFrMn,tFrPk); // "ahpTFrMn (%g) must be < ahpTFrPk (%g)" if (tFrPk >= tFrMx) - rc |= ERS2AHC(TFRPK,TFRMX) (char *)MH_S0668, tFrPk,tFrMx); // "ahpTFrPk (%g) must be < ahpTFrMx (%g)" + rc |= ERS2AHC(TFRPK,TFRMX) MH_S0668, tFrPk,tFrMx); // "ahpTFrPk (%g) must be < ahpTFrMx (%g)" // check tFrMn < 35 < tFrMx cuz of how used with cap35 & to prevent /0. Rob's addition. if (tFrMn >= 35.) - rc |= ERS2AHC(TFRMN,TFRPK) (char *)MH_S0669, tFrMn); // "ahpTFrMn (%g) must be < 35." + rc |= ERS2AHC(TFRMN,TFRPK) MH_S0669, tFrMn); // "ahpTFrMn (%g) must be < 35." if (35. >= tFrMx) - rc |= ERS2AHC(TFRPK,TFRMX) (char *)MH_S0670, tFrMx); // "ahpTFrMx (%g) must be > 35." + rc |= ERS2AHC(TFRPK,TFRMX) MH_S0670, tFrMx); // "ahpTFrMx (%g) must be > 35." //additional members specific to other coil types disallowN'd below. if (rc) return rc; // stop here if any error has been detected @@ -1277,7 +1286,7 @@ RC AHHEATCOIL::setup( // check/set up an ah heating coil subrecord, incl inpu //--- finally, disallow inputs specific to other coil types - rc |= r->disallowN( (char *)MH_S0675, // "when ahhcType is AHP" + rc |= r->disallowN( MH_S0675, // "when ahhcType is AHP" //ahhCoilFn + AHHEATCOIL_CAPTRAT, more specific message above ahhCoilFn + AHHEATCOIL_EIRRAT, ahhCoilFn + AHHEATCOIL_EFFRAT, @@ -1311,7 +1320,7 @@ RC FAN::fn_setup( // check/set up a fan subrecord, including autoSizing stuf { #define REQUIRES(subFn) r->require( fanFn + FAN_##subFn) // issue error message if field of subrecord not given #define ERS(subFn) r->ooer( fanFn + FAN_##subFn, // subrecord field err msg: addl arg(s) and ) must follow -#define ERS2(f1,f2) r->ooer( fanFn + FAN_##f1, fanFn+FAN_##f2, // subrecord 2-field error message ditto +#define ERS2(f1,f2) r->ooer2( fanFn + FAN_##f1, fanFn+FAN_##f2, // subrecord 2-field error message ditto #define IDS(subFn) r->mbrIdTx( fanFn + FAN_##subFn) // subrecord field name, from CULT search for polymorphism #define NOTGZS(subFn) r->notGzEr( fanFn + FAN_##subFn) // error message for field <= 0 // default cubic polynomial coefficients: array of 4 floats. uses r, fss, fanFn. @@ -1335,7 +1344,7 @@ RC FAN::fn_setup( // check/set up a fan subrecord, including autoSizing stuf switch (app) { default: - return r->oer( (char *)MH_S0676, app); // "Internal error: cncult5.cpp:ckFan: bad fan app 0x%x" + return r->oer( MH_S0676, app); // "Internal error: cncult5.cpp:ckFan: bad fan app 0x%x" case C_FANAPPCH_TFAN: break; // terminal fan (not implemented 10-92) @@ -1397,7 +1406,8 @@ RC FAN::fn_setup( // check/set up a fan subrecord, including autoSizing stuf if ( fanTy==C_FANTYCH_NONE // if no fan specified /*|| prohib*/ ) // [if caller said no fan allowed] { - for (SI subFn = 0; subFn < FAN_NFIELDS; subFn++) // for all members of fan subrecord + for (SI subFn = 0; subFn < FAN_NFIELDS; subFn++) // for all members of fan subrecord + { if (fss[subFn] & FsSET) // if member given in input { switch (subFn) // continue if giving this member ok @@ -1415,14 +1425,14 @@ RC FAN::fn_setup( // check/set up a fan subrecord, including autoSizing stuf subFn += 4; // addl bits set if > 1 ARRAY values entered, but no CULT entries continue; // --> mbrIdTx from cantGiveEr might give internal err msg. 6-92. } - char *when = nullptr; // subtext for input that says no fan present + MSGORHANDLE when; // subtext for input that says no fan present switch (app) { case C_FANAPPCH_SFAN: - when = (char *)MH_S0677; + when = MH_S0677; break; // "[internal error: no supply fan]" case C_FANAPPCH_RFAN: - when = (char *)MH_S0678; + when = MH_S0678; break; // "when rfanType is NONE or omitted" case C_FANAPPCH_ZFAN: when = "when izFanVfDs is 0"; @@ -1431,18 +1441,19 @@ RC FAN::fn_setup( // check/set up a fan subrecord, including autoSizing stuf case C_FANAPPCH_DEFAN: continue; // Inputs are ignored instead of issuing an error case C_FANAPPCH_XFAN: - when = (char *)MH_S0679; + when = MH_S0679; break; // "when no exhaust fan (xfanVfDs 0 or omitted)" case C_FANAPPCH_TFAN: - when = (char *)MH_S0680; + when = MH_S0680; break; // "when tfanType is NONE or omitted" /* prohib ? "terminal has no air heat nor cool\n" * " (none of tuTH, tuTC, tuVfMn given)" - * : "when tfanType is NONE or omitted" */ + * : "when tfanType is NONE or omitted" */ } - rc = r->cantGiveEr( fanFn + subFn, when); // cncult2.cpp + rc = r->cantGiveEr(fanFn + subFn, when); // cncult2.cpp } - return rc; + } + return rc; } // fan present, check members @@ -1461,7 +1472,7 @@ RC FAN::fn_setup( // check/set up a fan subrecord, including autoSizing stuf case C_FANAPPCH_XFAN: if (fanTy==C_FANTYCH_EXHAUST) break; badFanTy: - rc = ERS(FANTY) (char *)MH_S0681, // "bad fan type '%s' for %s" + rc = ERS(FANTY) MH_S0681, // "bad fan type '%s' for %s" r->getChoiTx( fanFn+FAN_FANTY, 1, fanTy), IDS(FANTY) ); } @@ -1472,21 +1483,21 @@ RC FAN::fn_setup( // check/set up a fan subrecord, including autoSizing stuf { if (defVfDs > 0.f) vfDs = defVfDs; // if caller gave (calculated) default, use it else - rc = ERS(VFDS) (char *)MH_S0682, IDS(VFDS) ); // else error "'%s' must be given" + rc = ERS(VFDS) MH_S0682, IDS(VFDS) ); // else error "'%s' must be given" } else if (!ausz && vfDs <= 0.f) rc = r->notGzEr( fanFn + FAN_VFDS); // insurance (default/limits shd force) if (vfMxF < 1.f) - rc = ERS(VFMXF) (char *)MH_S0683, IDS(VFMXF) ); // NOT checked elsewhere. "'%s' cannot be less than 1.0" + rc = ERS(VFMXF) MH_S0683, IDS(VFMXF) ); // NOT checked elsewhere. "'%s' cannot be less than 1.0" if (press < 0.f) - rc = ERS(PRESS) (char *)MH_S0684, IDS(PRESS) ); // insurance (default/limits shd force). + rc = ERS(PRESS) MH_S0684, IDS(PRESS) ); // insurance (default/limits shd force). // "'%s' cannot be less than 0" if (fss[FAN_EFF] & fss[FAN_SHAFTPWR] & FsSET) - rc = ERS2( EFF, SHAFTPWR) (char *)MH_S0685, IDS(EFF), IDS(SHAFTPWR) ); // "Cannot give both '%s' and '%s'" + rc = ERS2( EFF, SHAFTPWR) MH_S0685, IDS(EFF), IDS(SHAFTPWR) ); // "Cannot give both '%s' and '%s'" if (fss[FAN_SHAFTPWR] & fss[FAN_ELECPWR] & FsSET) - rc = ERS2( SHAFTPWR, ELECPWR) (char *)MH_S0685, IDS(SHAFTPWR), IDS(ELECPWR) ); // ditto + rc = ERS2( SHAFTPWR, ELECPWR) MH_S0685, IDS(SHAFTPWR), IDS(ELECPWR) ); // ditto if (fss[FAN_EFF] & fss[FAN_ELECPWR] & FsSET) - rc = ERS2( EFF, ELECPWR) (char *)MH_S0685, IDS(EFF), IDS(ELECPWR) ); // ditto + rc = ERS2( EFF, ELECPWR) MH_S0685, IDS(EFF), IDS(ELECPWR) ); // ditto if (motPos != C_MOTPOSCH_INFLO) // motor in air flow ok for all apps { switch (app) // check other motor position per app { @@ -1531,7 +1542,7 @@ x fn_setup2(); // if vfDs not NAN, set outPower, shaftPwr, inPower, airPower " You may give '%s', or let it default.", IDS(SHAFTPWR), IDS(VFDS), IDS(EFF) ); if (outPower > shaftPwr * 1.000001) // (only reason outPower is a member) - return ERS(SHAFTPWR) (char *)MH_S0686, /* "'%s' is less than air-moving output power \n" + return ERS(SHAFTPWR) MH_S0686, /* "'%s' is less than air-moving output power \n" " ( = '%s' times '%s' times units conversion factor)" */ IDS(SHAFTPWR), IDS(VFDS), IDS(PRESS) ); // omit values (else cvin2ex them!) if (shaftPwr <= 0.f) // /0 insurance @@ -1566,7 +1577,7 @@ x fn_setup2(); // if vfDs not NAN, set outPower, shaftPwr, inPower, airPower record *r, // non-sub record containing the poly subrecord -- needed re error message SI fn, // field number of polynomial subrecord in r - char *descrip, // description of argument, eg "relative flow", for use in "at %s = %g" + const char* descrip, // description of argument, eg "relative flow", for use in "at %s = %g" DBL x /*=1.0*/ ) // argument value for which poly should be 1.0: usually 1.0 for a cubic // returns non-RCOK to stop run (error message already issued) @@ -1582,7 +1593,7 @@ x fn_setup2(); // if vfDs not NAN, set outPower, shaftPwr, inPower, airPower #if 1 // omit if normalize warning not desired if (fabs(v - 1.) > .001) // if much wrong, tell user, at least for now 7-14-92 return r->oWarn( // returns RCOK. MH_S0687 text used 4 places! - (char *)MH_S0687, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" + MH_S0687, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" " for %s = %g.\n" " Coefficients will be normalized and execution will continue." */ r->mbrIdTx( fn), // get id text for record/field. slow: do not do til error detected. @@ -1594,17 +1605,17 @@ x fn_setup2(); // if vfDs not NAN, set outPower, shaftPwr, inPower, airPower if (v==0. || fabs(v - 1.) > .001) // zero value is error: cannot normalize (would /0) #endif return r->ooer( fn, // returns RCBAD. MH_S0688 text used 4 places! - (char *)MH_S0688, // "Inconsistent '%s' coefficients: value is %g, not 1.0,\n for %s = %g" + MH_S0688, // "Inconsistent '%s' coefficients: value is %g, not 1.0,\n for %s = %g" r->mbrIdTx( fn), // get id text for record/field. slow: do not do til error detected. v, descrip, x ); return RCOK; } // PYLINEAR::normalize //============================================================================================================================= - RC PYCUBIC::normalize( // if cubic poly coefficients are inconsistent, normalize and/or issue message. +RC PYCUBIC::normalize( // if cubic poly coefficients are inconsistent, normalize and/or issue message. record *r, // non-sub record containing the poly subrecord -- needed re error message SI fn, // field number of polynomial subrecord in r - char *descrip, // description of argument, eg "relative flow", for use in "at %s = %g" + const char* descrip, // description of argument, eg "relative flow", for use in "at %s = %g" DBL x /*=1.0*/ ) // argument value for which poly should be 1.0: usually 1.0 for a cubic // returns non-RCOK to stop run (error message already issued) @@ -1620,7 +1631,7 @@ x fn_setup2(); // if vfDs not NAN, set outPower, shaftPwr, inPower, airPower #if 1 // omit if normalize warning not desired if (fabs(v - 1.) > .001) // if much wrong, tell user, at least for now 7-14-92 return r->oWarn( // returns RCOK 7-92 - (char *)MH_S0687, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" + MH_S0687, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" " for %s = %g.\n" " Coefficients will be normalized and execution will continue." */ r->mbrIdTx( fn), // get id text for record/field. slow: do not do til error detected. @@ -1632,7 +1643,7 @@ x fn_setup2(); // if vfDs not NAN, set outPower, shaftPwr, inPower, airPower if (v==0. || fabs(v - 1.) > .001) // zero value is error: cannot normalize (would /0) #endif return r->ooer( fn, // returns RCBAD - (char *)MH_S0688, // "Inconsistent '%s' coefficients: value is %g, not 1.0,\n for %s = %g" + MH_S0688, // "Inconsistent '%s' coefficients: value is %g, not 1.0,\n for %s = %g" r->mbrIdTx( fn), // get id text for record/field. slow: do not do til error detected. v, descrip, x ); return RCOK; @@ -1642,7 +1653,7 @@ RC PYCUBIC2::normalize( // if cubic-with-x0 poly coefficients are inconsistent record *r, // non-sub record containing the poly subrecord -- needed re error message SI fn, // field number of polynomial subrecord in r - char *descrip, // description of argument, eg "relative flow", for use in "at %s = %g" + const char* descrip, // description of argument, eg "relative flow", for use in "at %s = %g" DBL x /*=1.0*/ ) // argument value for which poly should be 1.0: usually 1.0 for a cubic // returns non-RCOK to stop run (error message already issued) @@ -1658,7 +1669,7 @@ RC PYCUBIC2::normalize( // if cubic-with-x0 poly coefficients are inconsistent #if 1 // omit if normalize warning not desired if (fabs(v - 1.) > .001) // if much wrong, tell user, at least for now 7-14-92 return r->oWarn( // returns RCOK 7-92 - (char *)MH_S0687, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" + MH_S0687, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" " for %s = %g.\n" " Coefficients will be normalized and execution will continue." */ r->mbrIdTx( fn), // get id text for record/field. slow: do not do til error detected. @@ -1670,7 +1681,7 @@ RC PYCUBIC2::normalize( // if cubic-with-x0 poly coefficients are inconsistent if (v==0. || fabs(v - 1.) > .001) // zero value is error: cannot normalize (would /0) #endif return r->ooer( fn, // returns RCBAD - (char *)MH_S0688, // "Inconsistent '%s' coefficients: value is %g, not 1.0,\n for %s = %g" + MH_S0688, // "Inconsistent '%s' coefficients: value is %g, not 1.0,\n for %s = %g" r->mbrIdTx( fn), // get id text for record/field. slow: do not do til error detected. v, descrip, x ); return RCOK; @@ -1690,7 +1701,7 @@ RC PYBIQUAD::normalize( // if biquadratic poly coefficients are inconsistent, record *r, // non-sub record containing the poly subrecord -- needed re error message SI fn, // field number of polynomial subrecord in r - char *descX, char *descY, // descriptive texts, for use in "for %s=%g and %s=%g" + const char* descX, const char* descY, // descriptive texts, for use in "for %s=%g and %s=%g" DBL x, DBL y, // argument value for which poly should be 1.0 BOO noWarn /*=FALSE*/ ) // true to suppress normalization warning (eg if defaulted & coeff known non-normal) // returns non-RCOK to stop run (error message already issued) @@ -1707,7 +1718,7 @@ RC PYBIQUAD::normalize( // if biquadratic poly coefficients are inconsistent, if ( !noWarn // if warning not suppressed && fabs(v - 1.) > .02 ) // if much wrong, tell user, at least for now 7-14-92 return r->oInfo( // returns RCOK 7-92 - (char *)MH_S0689, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" + MH_S0689, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" " for %s=%g and %s=%g.\n" " Coefficients will be normalized and execution will continue." */ r->mbrIdTx( fn), // get id text for record/field. slow: do not do til error detected. @@ -1719,7 +1730,7 @@ RC PYBIQUAD::normalize( // if biquadratic poly coefficients are inconsistent, if (v==0. || fabs(v - 1.) > .001) #endif return r->ooer( fn, // returns RCBAD - (char *)MH_S0690, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" + MH_S0690, /* "Inconsistent '%s' coefficients: value is %g, not 1.0,\n" " for %s=%g and %s=%g\n" */ r->mbrIdTx( fn), // get id text for record/field. slow: do not do til error detected. v, descX, x, descY, y ); diff --git a/src/cncult6.cpp b/src/cncult6.cpp index 6427a36b1..a6442ceda 100644 --- a/src/cncult6.cpp +++ b/src/cncult6.cpp @@ -175,8 +175,8 @@ RC HEATPLANT::setup() // finish checking and initializing one HEATPLANT. // checks - if (!blr1) rc |= oer( (char *)MH_S0700); // "heatPlant has no BOILERs" - if (!ah1 && !tu1 && !hl1) oWarn( (char *)MH_S0701); // "HeatPlant has no loads: no HW coils, no HPLOOP HX's." + if (!blr1) rc |= oer( MH_S0700); // "heatPlant has no BOILERs" + if (!ah1 && !tu1 && !hl1) oWarn( MH_S0701); // "HeatPlant has no loads: no HW coils, no HPLOOP HX's." // ******** wording re hx?? #if 1 // default stages in code, not CULT table, 10-92. Also cncult.c. @@ -213,7 +213,7 @@ x { x TI *stg = hpStage1 + i * HPSTAGESZ; // point hpStage1..hpStage7 for i = 0..6 #endif char stgNm[20]; - sprintf( stgNm, "hpStage%d", INT(i+1) ); // stage variable name text for error messages + sprintf( stgNm, "hpStage%d", i+1 ); // stage variable name text for error messages // skip stage if empty. Used stages need not be contiguous (but they should be in order of increasing power). if (!stg[0]) @@ -232,15 +232,15 @@ x TI *stg = hpStage1 + i * HPSTAGESZ; // point hpStage1..hpStage7 for // ALL or ALLBUT after 1st position: cul.c disallows; if did get here, wd yield ckRefPt internal error message. rc |= ckRefPt( &BlrB, stg[j], stgNm, NULL, (record**)&blr); // check for valid BOILER subscript, access record if (blr->ownTi != ss) // boiler named in stage list must be ours - rc |= oer( (char *)MH_S0702, // "%s: boiler '%s' is not in this heatPlant" + rc |= oer( MH_S0702, // "%s: boiler '%s' is not in this heatPlant" stgNm, blr->Name()); for (SI k = j + 1; k < NHPSTAGES-1 && stg[k]; k++) // loop following part of list if (stg[k]==stg[j]) // check for duplication - rc |= oer( (char *)MH_S0703, // "%s: BOILER '%s' cannot be used twice in same stage" + rc |= oer( MH_S0703, // "%s: BOILER '%s' cannot be used twice in same stage" stgNm, blr->Name() ); } if (stg[j]) // stops at last j whether or not 0 - rc |= oer( (char *)MH_S0704, stgNm); // if not 0, error "Internal error: %s not terminated with 0" + rc |= oer( MH_S0704, stgNm); // if not 0, error "Internal error: %s not terminated with 0" } // accumulate stage power and flag used boilers @@ -257,15 +257,15 @@ x TI *stg = hpStage1 + i * HPSTAGESZ; // point hpStage1..hpStage7 for else // stage not empty and not more powerful than all preceding stages if (i > 0) // don't warn for hpStage1 vs hpStage1, as when no boilers oWarn( - (char *)MH_S0705, // "stage %s is not more powerful than hpStage%d, \n and thus will never be used" - stgNm, INT(stgMxQ+1) ); + MH_S0705, // "stage %s is not more powerful than hpStage%d, \n and thus will never be used" + stgNm, stgMxQ+1 ); } // messages re stage checks if (!stgN) // insurance: "impossible" - rc |= oer( (char *)MH_S0706); // "No non-empty hpStages specified" + rc |= oer( MH_S0706); // "No non-empty hpStages specified" for (blr = NULL; nxBlr(blr); ) // loop HEATPLANT's BOILERS as chained by BOILER::setup. cnhp.c. if (!blr->used) // for each owned boiler used in no stage - blr->oWarn( (char *)MH_S0707); // warn and continue. "Not used in any hpStage of heatPlant". + blr->oWarn( MH_S0707); // warn and continue. "Not used in any hpStage of heatPlant". // other setup @@ -301,8 +301,8 @@ RC BOILER::setup() // check and initialize one BOILER. if (sstat[BOILER_BLREIRR] & FsSET) // if eir given by user { - if (blrEirR < 1.0) oer( (char *)MH_S0708); // "blrEirR must be >= 1.0" - if (sstat[BOILER_BLREFFR] & FsSET) oer( (char *)MH_S0709); // "Can't give both blrEirR and blrEffR" + if (blrEirR < 1.0) oer( MH_S0708); // "blrEirR must be >= 1.0" + if (sstat[BOILER_BLREFFR] & FsSET) oer( MH_S0709); // "Can't give both blrEirR and blrEffR" } else // eir not given; if eff not given, CULT table entry defaulted it. blrEirR = 1./blrEffR; // set eir from efficiency, for runtime use. @@ -316,7 +316,7 @@ RC BOILER::setup() // check and initialize one BOILER. // aux energy drain checks: warn for meter without power #define MTRWRN(a,b,c,d) \ - if (sstat[a] & FsSET && !(sstat[b] & FsSET)) oWarn( (char *)MH_S0710, c, d); + if (sstat[a] & FsSET && !(sstat[b] & FsSET)) oWarn( MH_S0710, c, d); // "'%s' given, but no '%s' to charge to it given" MTRWRN( BOILER_AUXONMTRI , BOILER_AUXON , "blrAuxOnMtr" , "blrAuxOn" ); MTRWRN( BOILER_AUXOFFMTRI , BOILER_AUXOFF , "blrAuxOffMtr" , "blrAuxOff" ); @@ -341,8 +341,8 @@ RC COOLPLANT::setup() // check/init/set up one COOLPLANT record // checks - if (!ch1) rc |= oer( (char *)MH_S0711); // "coolPlant has no CHILLERs" - if (!ah1) oWarn( (char *)MH_S0712); // "CoolPlant has no loads: no CHW coils." + if (!ch1) rc |= oer( MH_S0711); // "coolPlant has no CHILLERs" + if (!ah1) oWarn( MH_S0712); // "CoolPlant has no loads: no CHW coils." // check towerplant / chain coolplants for towerplant @@ -385,7 +385,7 @@ x TI *stg = cpStage1 + i * CPSTAGESZ; // point cpStage1..cpStage7 for stg = cpStage1 + i * CPSTAGESZ; // point cpStage1..cpStage7 for i = 0..6 #endif char stgNm[20]; - sprintf( stgNm, "cpStage%d", INT(i+1) ); // stage variable name text for error messages + sprintf( stgNm, "cpStage%d", i+1 ); // stage variable name text for error messages // skip stage if empty. Used stages need not be contiguous (but they should be in order of increasing power). if (!stg[0]) @@ -404,15 +404,15 @@ x TI *stg = cpStage1 + i * CPSTAGESZ; // point cpStage1..cpStage7 for // ALL or ALLBUT after 1st position: cul.c disallows; if did get here, wd yield ckRefPt internal error message. rc |= ckRefPt( &ChB, stg[j], stgNm, NULL, (record**)&ch); // check for valid CHILLER subscript, access record if (ch->ownTi != ss) // chiller named in stage list must be ours - rc |= oer( (char *)MH_S0713, // "%s: chiller '%s' is not in this coolPlant" + rc |= oer( MH_S0713, // "%s: chiller '%s' is not in this coolPlant" stgNm, ch->Name()); for (SI k = j + 1; k < NCPSTAGES-1 && stg[k]; k++) // loop following part of list if (stg[k]==stg[j]) // check for duplication - rc |= oer( (char *)MH_S0714, // "%s: CHILLER '%s' cannot be used twice in same stage" + rc |= oer( MH_S0714, // "%s: CHILLER '%s' cannot be used twice in same stage" stgNm, ch->Name() ); } if (stg[j]) // stops at last j whether or not 0 - rc |= oer( (char *)MH_S0715, stgNm); // if not 0, error "Internal error: %s not terminated with 0" + rc |= oer( MH_S0715, stgNm); // if not 0, error "Internal error: %s not terminated with 0" } // accumulate stage powers, flows, pump heats, flag used chillers @@ -439,10 +439,10 @@ x TI *stg = cpStage1 + i * CPSTAGESZ; // point cpStage1..cpStage7 for + ch->chcp.q; // condenser pump heat goes to condenser } if (nCh < 1 || nCh >= CPSTAGESZ) // unused stages don't get here; check on nxChStg. - rc |= oer( (char *)MH_S0716, // "Internal error: bad # chillers (%d) found in stage %s" - (INT)nCh, stgNm ); + rc |= oer( MH_S0716, // "Internal error: bad # chillers (%d) found in stage %s" + nCh, stgNm ); else if (capDs >= 0.) // errors in CHILLER::setup, should not get here - rc |= oer( (char *)MH_S0717, // "Internal error: nonNegative total capacity %g of chillers in stage %s" + rc |= oer( MH_S0717, // "Internal error: nonNegative total capacity %g of chillers in stage %s" capDs, stgNm ); // remember most powerful stage @@ -456,9 +456,9 @@ x TI *stg = cpStage1 + i * CPSTAGESZ; // point cpStage1..cpStage7 for if (i > 0) // don't warn for cpStage1 vs cpStage1, as when no chillers // for chillers use weak warning as stage might be more powerful at different ts,tCnd. oWarn( - (char *)MH_S0718, /* "stage %s is not more powerful (under design conditions) than \n" + MH_S0718, /* "stage %s is not more powerful (under design conditions) than \n" " cpStage%d, and thus may never be used" */ - stgNm, INT(stgMxCap+1) ); + stgNm, stgMxCap+1 ); if (condQ > mxCondQ) // remember largest design rejected heat { mxCondQ = condQ; // used in defaulting cooling towers capacity @@ -469,16 +469,16 @@ x TI *stg = cpStage1 + i * CPSTAGESZ; // point cpStage1..cpStage7 for } // messages re stage checks if (!stgN) // insurance: "impossible" cuz stage1 defaults to TI_ALL - rc |= oer( (char *)MH_S0719); // "No non-empty cpStages specified" + rc |= oer( MH_S0719); // "No non-empty cpStages specified" for (ch = NULL; nxCh(ch); ) // loop COOLPLANT's CHILLERs as chained by CHILLER::setup. cncp.c. if (!ch->used) // for each owned chiller used in no stage - ch->oWarn((char *)MH_S0720); // warn "Not used in any cpStage of coolPlant" and continue + ch->oWarn(MH_S0720); // warn "Not used in any cpStage of coolPlant" and continue if (rc) return rc; // return if no chillers, error in staging, etc // error now if connected coils exceed max stage pumping capacity with overrun: can't check during run as flow not simulated. if (mwDsCoils > mxPMwOv) // mwDsCoils: sum of coil design flows, accum by COOLCOIL::setup - oer( (char *)MH_S0721, mwDsCoils, mxPMwOv ); + oer( MH_S0721, mwDsCoils, mxPMwOv ); /* "Total design flow of connected coils, %g lb/hr, is greater than\n" " most powerful stage primary pumping capacity (with overrun), %g lb/hr." */ @@ -507,8 +507,8 @@ RC CHILLER::setup() // check/set up/init one CHILLER record chCapDs = float( -fabs(chCapDs)); // capacity may be entered + or -; make negative internally. if (chMinFsldPlr > chMinUnldPlr) // min plr for false loading must be <= min plr for unloading - ooer( CHILLER_CHMINFSLDPLR, CHILLER_CHMINUNLDPLR, - (char *)MH_S0722, chMinFsldPlr, chMinUnldPlr ); // "chMinFsldPlr (%g) must be <= chMinUnldPlr (%g)" + ooer2( CHILLER_CHMINFSLDPLR, CHILLER_CHMINUNLDPLR, + MH_S0722, chMinFsldPlr, chMinUnldPlr ); // "chMinFsldPlr (%g) must be <= chMinUnldPlr (%g)" if (mtri) // if meter reference given, check it ckRefPt( &MtrB, mtri, "chMtr"); @@ -523,11 +523,11 @@ RC CHILLER::setup() // check/set up/init one CHILLER record if (!rc) // if no error: other error/omission might be cause of following { if (chpp.q >= -chCapDs) // coolplant:setup expects net negative - rc |= oer( (char *)MH_S0723, chpp.q, -chCapDs); // "Primary pump heat (%g) exceeds chCapDs (%g)" + rc |= oer( MH_S0723, chpp.q, -chCapDs); // "Primary pump heat (%g) exceeds chCapDs (%g)" else if (chpp.q > -chCapDs * .25) // intended to help user, rob 10-92. 10%? - oWarn( (char *)MH_S0724, chpp.q, -chCapDs); // "Primary pump heat (%g) exceeds 1/4 of chCapDs (%g)." + oWarn( MH_S0724, chpp.q, -chCapDs); // "Primary pump heat (%g) exceeds 1/4 of chCapDs (%g)." if (chcp.q > -chCapDs * .25) // intended to help user, rob 10-92. 10%? - oWarn( (char *)MH_S0725, chcp.q, -chCapDs); // "Condenser pump heat (%g) exceeds 1/4 of chCapDs (%g)." + oWarn( MH_S0725, chcp.q, -chCapDs); // "Condenser pump heat (%g) exceeds 1/4 of chCapDs (%g)." // note 25% or 25%% printed garbage. } @@ -564,7 +564,7 @@ RC CHILLER::setup() // check/set up/init one CHILLER record if (sstat[CHILLER_CHEIRDS] & FsSET) // if chEirDs entered { - disallow((char *)MH_S0726, CHILLER_CHCOP); // disallow cop entry. "when chEirDs is given" + disallow( MH_S0726, CHILLER_CHCOP); // disallow cop entry. "when chEirDs is given" //any checks for eir? limit range? } else // eir not entered. chCop entered, or defaulted by CULT table. @@ -588,7 +588,7 @@ x normalizing poly @44,85 except re warning message condition // aux energy drain checks: warn for meter without power #define MTRWRN(a,b,c,d) \ - if (sstat[a] & FsSET && !(sstat[b] & FsSET)) oWarn( (char *)MH_S0727, c, d); + if (sstat[a] & FsSET && !(sstat[b] & FsSET)) oWarn( MH_S0727, c, d); // "'%s' given, but no '%s' to charge to it given" MTRWRN( CHILLER_AUXONMTRI , CHILLER_AUXON , "chAuxOnMtr" , "chAuxOn" ); MTRWRN( CHILLER_AUXOFFMTRI , CHILLER_AUXOFF , "chAuxOffMtr" , "chAuxOff" ); @@ -609,7 +609,7 @@ RC TOWERPLANT::setup() // check / default / initialize a TOWERPLANT BOO odGiven=FALSE; if (!cp1 && !hl1) - return oer( (char *)MH_S0728); // "TowerPlant has no loads: no coolPlants, no hpLoop HX's." + return oer( MH_S0728); // "TowerPlant has no loads: no coolPlants, no hpLoop HX's." //******* wording re hx?? /* error return now cuz pumpGpm and qLoadMax will be 0 and might be divided by. (to warn & allow run, flag bad? so RLUP skips it?) */ @@ -636,7 +636,7 @@ RC TOWERPLANT::setup() // check / default / initialize a TOWERPLANT // [return] oer( "Total of connected loads (%g) must be > 0", qLoadMax); if (pumpGpm <= 0.) /* message, and continue, cuz: 1) this message weak since has no imput member name. 2) ctGpmDs, -Od checks below prevent /0 if dflt'd.*/ - oer( (char *)MH_S0729, pumpGpm); // "Total pump gpm of connected loads (%g) must be > 0" + oer( MH_S0729, pumpGpm); // "Total pump gpm of connected loads (%g) must be > 0" // some defaults & checks @@ -656,7 +656,7 @@ RC TOWERPLANT::setup() // check / default / initialize a TOWERPLANT ctVfOd = qLoadMax/(51.f*ctN); // 51: Bruce & Steve got by inspection of a catalog, 10-92. #endif - if (ctTy != C_CTTYCH_TWOSPEED) disallow( (char *)MH_S0730, TOWERPLANT_CTLOSPD); // "when ctTy is not TWOSPEED". cncult2.c. + if (ctTy != C_CTTYCH_TWOSPEED) disallow( MH_S0730, TOWERPLANT_CTLOSPD); // "when ctTy is not TWOSPEED". cncult2.c. if (!(sstat[TOWERPLANT_CTGPMDS] & FsSET)) ctGpmDs = pumpGpm/ctN; // dflt design & off-design water flows per loads if (!(sstat[TOWERPLANT_CTGPMOD] & FsSET)) ctGpmOd = pumpGpm/ctN; // ctN 0-checked above. @@ -667,7 +667,7 @@ RC TOWERPLANT::setup() // check / default / initialize a TOWERPLANT // off-design conditions - char *when; // sprintf insert, don't use MH + const char* when; // sprintf insert, don't use MH if ( ( sstat[TOWERPLANT_CTCAPOD] | sstat[TOWERPLANT_CTVFOD] // if gave any of ctCapOd, ctVfOd, | sstat[TOWERPLANT_CTGPMOD] | sstat[TOWERPLANT_CTTDBOOD] // ctGpmOd, ctTDbOOd, ctTWbOOd, ctTwoOd: | sstat[TOWERPLANT_CTTWBOOD] | sstat[TOWERPLANT_CTTWOOD] ) & FsSET ) // merge 6 status bytes then test bit @@ -694,17 +694,17 @@ x /*TOWERPLANT_CTTWBOOD,*/ /*TOWERPLANT_CTTWOOD,*/ return notGzEr(TOWERPLANT_CTVFOD); // redundant /0 protection (uses ooer) if (ctVfOd==ctVfDs) // must be different. fuzz? - ooer( TOWERPLANT_CTVFOD, TOWERPLANT_CTVFDS, // msg only if no msg yet for either field + ooer2( TOWERPLANT_CTVFOD, TOWERPLANT_CTVFDS, // msg only if no msg yet for either field (sstat[TOWERPLANT_CTVFOD] | sstat[TOWERPLANT_CTVFDS]) & FsSET // if either given, use different text - ? (char *)MH_S0731 // "ctVfOd (%g) is same as ctVfDs.\n These values must differ %s." - : (char *)MH_S0732, // "ctVfOd and ctVfDs are both defaulted to %g.\n These values must differ %s." + ? MH_S0731 // "ctVfOd (%g) is same as ctVfDs.\n These values must differ %s." + : MH_S0732, // "ctVfOd and ctVfDs are both defaulted to %g.\n These values must differ %s." ctVfOd, when ); if (ctGpmOd==ctGpmDs) // must be different. fuzz? - ooer( TOWERPLANT_CTGPMOD, TOWERPLANT_CTGPMDS, // message function in cul.c + ooer2( TOWERPLANT_CTGPMOD, TOWERPLANT_CTGPMDS, // message function in cul.c (sstat[TOWERPLANT_CTGPMOD] | sstat[TOWERPLANT_CTGPMDS]) & FsSET // if either given, use different text - ? (char *)MH_S0733 // "ctGpmOd (%g) is same as ctGpmDs.\n These values must differ %s." - : (char *)MH_S0734, //"ctGpmOd and ctGpmDs are both defaulted to %g.\n These values must differ %s." + ? MH_S0733 // "ctGpmOd (%g) is same as ctGpmDs.\n These values must differ %s." + : MH_S0734, //"ctGpmOd and ctGpmDs are both defaulted to %g.\n These values must differ %s." ctVfOd, when ); } else // no off-design conditions given @@ -716,7 +716,7 @@ x /*TOWERPLANT_CTTWBOOD,*/ /*TOWERPLANT_CTTWOOD,*/ TOWERPLANT_CTGPMOD, TOWERPLANT_CTTDBOOD, // cncult2.c fcn TOWERPLANT_CTTWBOOD, TOWERPLANT_CTTWOOD, 0 ); if (ctK >= 1.) // limits have checked for 0 < ctK <= 1. - ooer( TOWERPLANT_CTK, (char *)MH_S0735); // error msg "ctK must be less than 1.0". cul.c. + ooer( TOWERPLANT_CTK, MH_S0735); // error msg "ctK must be less than 1.0". cul.c. //ctGpmOd may be 0, but ctGpmOd/mwOd not used if !odGiven. } @@ -763,18 +763,18 @@ x /*TOWERPLANT_CTTWBOOD,*/ /*TOWERPLANT_CTTWOOD,*/ #else // this is all we should check in general * if (hi < lo - .0001) // (step rise ok: simulates start-stop overhead.) #endif - ooer( TOWERPLANT_CTFCLO, TOWERPLANT_CTFCHI, // msg if no msg yet for these fields (cul.c) - (char *)MH_S0736, lo, hi ); /* "Inconsistent low and hi speed fan curve polynomials:\n" + ooer2( TOWERPLANT_CTFCLO, TOWERPLANT_CTFCHI, // msg if no msg yet for these fields (cul.c) + MH_S0736, lo, hi ); /* "Inconsistent low and hi speed fan curve polynomials:\n" " ctFcLo(ctLoSpd)=%g, but ctFcHi(ctLoSpd)=%g." */ break; } // disallow inappropriate fan curve polynomials - if (ctTy != C_CTTYCH_ONESPEED) disallow((char*)MH_S0737, TOWERPLANT_CTFCONE); // "when ctType is not ONESPEED" - if (ctTy != C_CTTYCH_TWOSPEED) disallowN( (char *)MH_S0738, TOWERPLANT_CTFCLO, // "when ctType is not TWOSPEED" + if (ctTy != C_CTTYCH_ONESPEED) disallow(MH_S0737, TOWERPLANT_CTFCONE); // "when ctType is not ONESPEED" + if (ctTy != C_CTTYCH_TWOSPEED) disallowN( MH_S0738, TOWERPLANT_CTFCLO, // "when ctType is not TWOSPEED" TOWERPLANT_CTFCHI, 0 ); // cncult2.c fcns. - if (ctTy != C_CTTYCH_VARIABLE) disallow((char*)MH_S0739, TOWERPLANT_CTFCVAR); // "when ctType is not VARIABLE" + if (ctTy != C_CTTYCH_VARIABLE) disallow(MH_S0739, TOWERPLANT_CTFCVAR); // "when ctType is not VARIABLE" // subexpressions and units conversions @@ -801,7 +801,7 @@ x /*TOWERPLANT_CTTWBOOD,*/ /*TOWERPLANT_CTTWOOD,*/ { CSE_E( setupNtuAOd() ) // determine ntuAOd: off-design air side ntu. below. if (fabs(maOverMwDs - maOd/mwOd) < 1.e-10) // prevent divide by 0 (log of 1) in next statement - return oer( (char *)MH_S0740, /* "maOd/mwOd must not equal maDs/mwDs.\n" + return oer( MH_S0740, /* "maOd/mwOd must not equal maDs/mwDs.\n" " maOd=%g mwOd=%g maDs=%g mwDs=%g\n" " maOd/mwOd = maDs/mwDs = %g" */ maOd, mwOd, maDs, mwDs, maOverMwDs ); @@ -809,7 +809,7 @@ x /*TOWERPLANT_CTTWBOOD,*/ /*TOWERPLANT_CTTWOOD,*/ } // this finishes VI-C-3-b. if (ctK <= 0. || ctK >= 1.) // insurance (previously ck'd if input) - ooer( TOWERPLANT_CTK, (char *)MH_S0741); // "ctK (%g) did not come out between 0 and 1 exclusive". + ooer( TOWERPLANT_CTK, MH_S0741); // "ctK (%g) did not come out between 0 and 1 exclusive". // cul.c function. return rc; // more return(s) above, incl E macros and several /0 protections } // TOWERPLANT::setup @@ -817,13 +817,13 @@ x /*TOWERPLANT_CTTWBOOD,*/ /*TOWERPLANT_CTTWOOD,*/ RC TOWERPLANT::setupNtuADs() // compute ntuADs for towerplant setup. # transfer units, air side, design conditions { RC rc=RCOK; - char *design = "design"; // insert for error messages so same message texts can be used re off-design conditions + const char* design = "design"; // insert for error messages so same message texts can be used re off-design conditions // preliminary checks if (ctTWbODs >= ctTwoDs) // can't cool water below outdoor wetbulb. Would make hswoDs <= haiDs. - return ooer( TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // msg if no msg yet for these members - (char *)MH_S0742, /* "%s outdoor wetbulb temperature (ctTWbODs=%g) must be\n" + return ooer2( TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // msg if no msg yet for these members + MH_S0742, /* "%s outdoor wetbulb temperature (ctTWbODs=%g) must be\n" " less than %s leaving water temperature (ctTwoDs=%g)" */ design, ctTWbODs, design, ctTwoDs ); @@ -842,13 +842,13 @@ RC TOWERPLANT::setupNtuADs() // compute ntuADs for towerplant setup. # transfer // errors for impossible design conditions / protect re /0, log(0), log(<0): if (haiDs >= hswoDs) // if sat air enthalpy at exit water temp colder than entering air enth (impossible water cooling) - return ooer( // should have issued "ctTWbODs not < ctTwoDs" above -->no msg here + return ooer2( // should have issued "ctTWbODs not < ctTwoDs" above -->no msg here TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // if no msg yet for these members, give this msg - (char *)MH_S0743, haiDs, hswoDs); // "Internal error in setupNtuaADs: haiDs (%g) not < hswoDs (%g)" + MH_S0743, haiDs, hswoDs); // "Internal error in setupNtuaADs: haiDs (%g) not < hswoDs (%g)" if (haoDs >= hswiDs) // if exiting air enth > enthalpy of sat water at entering water temp (impossible air heating) - return ooer( TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // msg if no msg yet for these members - (char *)MH_S0744, /* "%s conditions produce impossible air heating:\n" + return ooer2( TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // msg if no msg yet for these members + MH_S0744, /* "%s conditions produce impossible air heating:\n" " enthalpy of leaving air (%g) not less than enthalpy of\n" " saturated air (%g) at leaving water temp (ctTWbODs=%g).\n" " Try more air flow (ctVfDs=%g)." */ @@ -882,7 +882,7 @@ x Following /0's if ==; looks like can handle either > (numerator and deno else // normally compute thus ntuADs = -log((haoDs - hswiDs)/(haiDs - hswoDs)) / (1. - cs*maOverMwDs/CPW); // log = natural logarithm. if (ntuADs <= 0.) // prevent /0 (by caller) - rc = oer( (char *)MH_S0745, ntuADs); // "Internal error: ntuADs (%g) not > 0" + rc = oer( MH_S0745, ntuADs); // "Internal error: ntuADs (%g) not > 0" return rc; // also error returns above } // TOWERPLANT::setupNtuADs //------------------------------------------------------------------------------------------------------------------------- @@ -907,13 +907,13 @@ x return rc; #else // 10-14-92 revision with simplifications and more messages, as for setupNtuADs. RC rc=RCOK; DBL maOverMwOd = maOd/mwOd; // (have no -Od member corress to maOverMwDs) - char *design = "off-design"; // insert for error messages so same message texts can be used re design conditions + const char *design = "off-design"; // insert for error messages so same message texts can be used re design conditions // preliminary checks if (ctTWbOOd >= ctTwoOd) // can't cool water below outdoor wetbulb. Would make hswoOd <= haiOd. - return ooer( TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // msg if no msg yet for these members - (char *)MH_S0746, /* "%s outdoor wetbulb temperature (ctTWbOOd=%g) must be\n" + return ooer2( TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // msg if no msg yet for these members + MH_S0746, /* "%s outdoor wetbulb temperature (ctTWbOOd=%g) must be\n" " less than %s leaving water temperature (ctTwoOd=%g)" */ design, ctTWbOOd, design, ctTwoOd ); @@ -932,13 +932,13 @@ x return rc; // errors for impossible off-design conditions / protect re /0, log(0), log(<0): if (haiOd >= hswoOd) // if sat air enthalpy at exit water temp colder than entering air enth (impossible water cooling) - return ooer( // should have issued "ctTWbOOd not < ctTwoOd" above -->no msg here + return ooer2( // should have issued "ctTWbOOd not < ctTwoOd" above -->no msg here TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // if no msg yet for these members, give this msg - (char *)MH_S0747, haiOd, hswoOd); // "Internal error in setupNtuaAOd: haiOd (%g) not < hswoOd (%g)" + MH_S0747, haiOd, hswoOd); // "Internal error in setupNtuaAOd: haiOd (%g) not < hswoOd (%g)" if (haoOd >= hswiOd) // if exiting air enth > enthalpy of sat water at entering water temp (impossible air heating) - return ooer( TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // msg if no msg yet for these members - (char *)MH_S0748, /* "%s conditions produce impossible air heating:\n" + return ooer2( TOWERPLANT_CTTWODS, TOWERPLANT_CTTWBODS, // msg if no msg yet for these members + MH_S0748, /* "%s conditions produce impossible air heating:\n" " enthalpy of leaving air (%g) not less than enthalpy of\n" " saturated air (%g) at leaving water temp (ctTWbOOd=%g).\n" " Try more air flow (ctVfOd=%g)." */ @@ -972,7 +972,7 @@ x Following /0's if ==; looks like can handle either > (numerator and deno else // normally compute thus ntuAOd = -log((haoOd - hswiOd)/(haiOd - hswoOd)) / (1. - cs*maOverMwOd/CPW); // log = natural logarithm. if (ntuAOd <= 0.) // prevent /0 (by caller) - rc = oer( (char *)MH_S0748, ntuAOd); // "Internal error: ntuAOd (%g) not > 0" + rc = oer( MH_S0748, ntuAOd); // "Internal error: ntuAOd (%g) not > 0" return rc; // also error returns above #endif } // TOWERPLANT::setupNtuAOd @@ -988,7 +988,7 @@ RC PUMP::setup( record *r, SI pumpFn) // initialize a PUMP subrecord // checks if (ovrunF < 1.0) - r->oer( (char *)MH_S0749, r->mbrIdTx( pumpFn+PUMP_OVRUNF) ); // "%s must be >= 1.0" + r->oer( MH_S0749, r->mbrIdTx( pumpFn+PUMP_OVRUNF) ); // "%s must be >= 1.0" // initialization #define LBperGAL 8.337 // @ 62 F, CRC handbook. Note cons.c shows 8.3454 -- for 39F?. also in cncult5.c. diff --git a/src/cnglob.h b/src/cnglob.h index f5a9357d4..d49871e57 100644 --- a/src/cnglob.h +++ b/src/cnglob.h @@ -63,6 +63,9 @@ typedef HINSTANCE HMODULE; // tried -Od and -rd compile options at same time, found not necessary. // gave up on trying to change individual FC's only b4 getting cul.cpp to complete imput compilation 3-94. +/*---------------------- return codes / error codes ------------------------*/ + + // forward-ref types struct XFILE; // Extended IO packet set up in dm by xfopen, used as arg to othr xiopak/xiochar calls struct FILEINFO; // file info struct, dospak to xiopak @@ -127,6 +130,43 @@ typedef time_t LDATETIME; // NOTE: < > required re rcdef build #endif +typedef SI RC; // Return Code explenations on the return code section +// RC Return Codes: integers returned by fcns to indicate call outcome +// 0 indicates all OK so RC can be cumulatively or'd +const RC RCOK=0; // fcn succeeded. code assumes 0 value. +const RC RCFATAL = -1; // fcn encountered fatal error; current process should be abandoned. + // note (RCFATAL | x) == RCFATAL, code may assume +const RC RCBAD = -2; // fcn failed -- general +const RC RCBAD2 = -4; // alternate failure return, for use where needed; note RCBAD2|RCBAD == RCBAD. +// values 1 - 16384 reserved, overlap with MH_xxxx definitions (see msghans.h and ...) + +// values > 16384 reserved for local definition and use, e.g. RCUNSET in cueval.h +const RC RCUNSET = 16385; // returned by e.g. cuEvalxx if unset data accessed + // (eg by probe of a RAT member) + // -- caller may want to treat this error differently. +const RC RCCANNOT = 16386; // return code for "cannot do it, try another way" (see tryImInProbe()) +const RC RCNOP = 16390; // fcn did nothing (due to e.g. specific input values) +const RC RCEOF = 16391; // indicates end of input when returned by ppRead, ppM, ppC, etc +#define CSE_E(f) { rc = (f); if (rc) return rc; } // if fcn f returns error, return it to caller. Note RCOK is 0. +#define CSE_EF(f) { if (f) return RCBAD; } // "fast" variant: return RCBAD for any non-RCOK + +// SEC additional system error codes -- in addition to c library errno values. +// must not conflict with errno values. See rmkerr:secMsg and xiopak.cpp. +typedef SI SEC; // system error code data type (matches type of msc c library "errno") +const SEC SECOK = -1; // system error code for no error +const SEC SECEOF = -2; // system error code for EOF (none def by MSC). +const SEC SECOTHER = -3; // system error code indicating that an error + // was signalled but errno was not set +const SEC SECBADFN = -4; // bad file name, detected in our code (not library). + // msc at least has no such msg. added by rob 1-88. */ +const SEC SECBADRV = -5; // bad drv letter (xiopak:chdir, likely other uses) +const SEC SECBADPATH = 2; // No file or directory + +typedef SI MH; // message handle, used in calls to err() and msg(), identifier for msgs in msgtab:msgTbl[] + + + + // min and max (converted to template fcns, 10-12) #undef min #undef max @@ -202,15 +242,14 @@ const int EROMASK = 0xff0000; // mask for application option bits #define FALSE 0 /*--------------------- Definitions for CSE headers ------------------------*/ -typedef SI RC; // Return Code explenations on the return code section typedef void* DMP; // Dynamic memory block pointer: ptr to any type, record struct, etc, of caller's const int defaultCpl = 78; // default chars/line, used when Top.repCpl not available // see getCpl() /*----------------------------- CSE headers --------------------------------*/ #include "dmpak.h" // Uses EROP1, EROP2, RC, DMP, IGN and ABT -#include "strpak.h" #include "rmkerr.h" +#include "strpak.h" #include "psychro.h" #include "vecpak.h" // Uses min and max definitions @@ -373,41 +412,6 @@ template inline NANDAT AsNANDAT(T& v) { return *reinterpret_cast(nck) << 16)) // put in hi word. nck must include 0x7f80. -/*---------------------- return codes / error codes ------------------------*/ - -// RC Return Codes: integers returned by fcns to indicate call outcome -// 0 indicates all OK so RC can be cumulatively or'd -const RC RCOK=0; // fcn succeeded. code assumes 0 value. -const RC RCFATAL = -1; // fcn encountered fatal error; current process should be abandoned. - // note (RCFATAL | x) == RCFATAL, code may assume -const RC RCBAD = -2; // fcn failed -- general -const RC RCBAD2 = -4; // alternate failure return, for use where needed; note RCBAD2|RCBAD == RCBAD. -// values 1 - 16384 reserved, overlap with MH_xxxx definitions (see msghans.h and ...) - -// values > 16384 reserved for local definition and use, e.g. RCUNSET in cueval.h -const RC RCUNSET = 16385; // returned by e.g. cuEvalxx if unset data accessed - // (eg by probe of a RAT member) - // -- caller may want to treat this error differently. -const RC RCCANNOT = 16386; // return code for "cannot do it, try another way" (see tryImInProbe()) -const RC RCNOP = 16390; // fcn did nothing (due to e.g. specific input values) -const RC RCEOF = 16391; // indicates end of input when returned by ppRead, ppM, ppC, etc -#define CSE_E(f) { rc = (f); if (rc) return rc; } // if fcn f returns error, return it to caller. Note RCOK is 0. -#define CSE_EF(f) { if (f) return RCBAD; } // "fast" variant: return RCBAD for any non-RCOK - -// SEC additional system error codes -- in addition to c library errno values. -// must not conflict with errno values. See rmkerr:secMsg and xiopak.cpp. -typedef SI SEC; // system error code data type (matches type of msc c library "errno") -const SEC SECOK = -1; // system error code for no error -const SEC SECEOF = -2; // system error code for EOF (none def by MSC). -const SEC SECOTHER = -3; // system error code indicating that an error - // was signalled but errno was not set -const SEC SECBADFN = -4; // bad file name, detected in our code (not library). - // msc at least has no such msg. added by rob 1-88. */ -const SEC SECBADRV = -5; // bad drv letter (xiopak:chdir, likely other uses) -const SEC SECBADPATH = 2; // No file or directory - - - // ------------------------- Debug aid ASSERT macro ------------------------- // @@ -464,7 +468,6 @@ extern int CheckFP( double v, const char* tag); typedef USI RCT; // record type type. Needed for RATBASE defn below, for ratpak.h, and rccn.h. struct SFIR; // small fields-in-record info table (for basAnc.fir, SRD.fir). struct in srd.h. -typedef SI MH; // message handle, used in calls to err() and msg(), identifier for msgs in msgtab:msgTbl[] #define DMPP( p) ((DMP *)DMP( &(p))) inline void IncP(void** pp, int b) { *pp = (void*)((char*)(*pp) + b); } class record; @@ -513,7 +516,7 @@ int getCpl( class TOPRAT** pTp=NULL); // get chars/line int CheckAbort(); // messages.cpp -const char * CDEC msg( char *mBuf, const char *mOrH, ...); +const char* msg( char* mBuf, MSGORHANDLE mOrH, ...); // commonly used pow variants inline float pow2( float v) { return v*v; } diff --git a/src/cnguts.cpp b/src/cnguts.cpp index dd5c41fa7..93de72bac 100644 --- a/src/cnguts.cpp +++ b/src/cnguts.cpp @@ -71,8 +71,10 @@ LOCAL void FC accumAhr( AHRES_IVL_SUB *res1, AHRES_IVL_SUB *res2, BOO firstflg, LOCAL void FC doIvlPrior(); LOCAL void FC setPriorRes( ZNRES_IVL_SUB* resCurr); LOCAL void FC doIvlReports(); +#if defined( BINRES) LOCAL void FC binResInit( int isAusz); LOCAL void FC binResFinish(); +#endif //----------------------------------------------------------------------------------------------------------- void FC cgClean( // cg overall init/cleanup routine @@ -622,8 +624,8 @@ LOCAL RC FC doBegIvl() // simulation run start-of-interval processing: init, sol if (errCount() > maxErrors) // if too many total errors, msg & ret RCBAD. // errCount(): error count ++'d by calls to err, rer, etc. rmkerr.cpp. return rInfo( // display runtime "Information" message, exman.cpp. returns RCBAD. - (char *)MH_R1251, // "More than %d errors. Terminating run." - (INT)maxErrors ); // maxErrors: cuparse.cpp. Data init, accessible as $maxErrors. + MH_R1251, // "More than %d errors. Terminating run." + maxErrors ); // maxErrors: cuparse.cpp. Data init, accessible as $maxErrors. return RCOK; // many error returns above, including E and CSE_EF macros. } // doBegIvl @@ -850,7 +852,7 @@ LOCAL RC FC doEndIvl() // simulation run end-of-interval processing: results a if (enkichk()) // if ^C pressed (envpak.cpp). Only call in program 1-95. { enkimode( KICLEAR | KIBEEP); // clear ^C / say beep on ^C - return err( WRN, (char *)MH_C0100); // display message " *** Interrupted *** ". + return err( WRN, MH_C0100); // display message " *** Interrupted *** ". // returns MH_C0100 -- callers may test. } } @@ -866,7 +868,7 @@ LOCAL RC FC doEndIvl() // simulation run end-of-interval processing: results a * if (errCount() > maxErrors) // if too many total errors, msg & ret RCBAD. * // errCount(): error count ++'d by calls to rer, err, etc. rmkerr.cpp. * // maxErrors: cuparse.cpp. Data init, accessible as $maxErrors. -* return rInfo( "More than %d errors. Terminating run.", (INT)maxErrors ); // runtime "Information" message, exman.cpp +* return rInfo( "More than %d errors. Terminating run.", maxErrors ); // runtime "Information" message, exman.cpp #endif return RCOK; @@ -1041,7 +1043,7 @@ RC FC cgRddDone( // Perform cleanup done after main sim run and each autoSize de // close any open import files. Redundant calls ok. impf.cpp. 2-94. impfEnd(); -#ifdef BINRES // CMake option +#if defined( BINRES) // CMake option // close binary results files if open // move call to cgDone (and review code) if file is to persist (stay open) thru autosize and main sim run. binResFinish(); // local fcn below. nop if not in use or called redundantly (if local flag brf clear). @@ -1253,14 +1255,14 @@ RC GAIN::gn_CkF( if (IsSet( GAIN_MTRI)) { // meter specified -- gnEndUse required if (!IsSet( GAIN_GNENDUSE)) - oer( (char *)MH_S0489); // "No gnEndUse given" + oer( MH_S0489); // "No gnEndUse given" } else if (IsSet( GAIN_GNENDUSE)) { // gnEndUse w/o gnMeter if (!IsSet( GAIN_GNDLFRPOW)) // and no daylighting fraction power given // (permit end use without meter for daylighting, cuz litDmd/litEu // accumulation to zones only happens if eu=lit, 9-94) - oer( (char *)MH_S0490); // "No gnMeter given (required when gnEndUse is given)" + oer( MH_S0490); // "No gnMeter given (required when gnEndUse is given)" } if (bSetup) { // runtime check of meter reference @@ -1296,7 +1298,7 @@ RC GAIN::gn_CkF( + ((fs[GAIN_GNFRRTN] & (FsSET|FsVAL))==FsSET ? 0.f : gnFrRtn ); // fraction-to-return similarly if (t > 1.f) // if more than all of gain assigned oer( // error message, prevents run - (char *)MH_S0491, /* "More than 100 percent of gnPower distributed:\n" + MH_S0491, /* "More than 100 percent of gnPower distributed:\n" " Total of fractions gnFrZn, gnFrPl, and gnFrRtn exceeds 1.0:\n" " gnFrZn (%g) + gnFrPl (%g) + gnFrRtn (%g) = %g%s" */ gnFrZn, gnFrPl, gnFrRtn, @@ -1323,10 +1325,10 @@ RC GAIN::gn_CkF( if (fs[GAIN_GNDLFRPOW] & FsSET) // if daylighting fraction power given { if (!gnEndUse) // if end use not given - oWarn( (char *)MH_S0507); // No gnEndUse given when gnDlFrPow given.\n" + oWarn( MH_S0507); // No gnEndUse given when gnDlFrPow given.\n" // " gnEndUse=\"Lit\" is usual with gnDlFrPow." else if (gnEndUse != C_ENDUSECH_LIT) // if end use isn't lighting - oWarn( (char *)MH_S0508); // gnEndUse other than \"Lit\" given when gnDlFrPow given.\n" + oWarn( MH_S0508); // gnEndUse other than \"Lit\" given when gnDlFrPow given.\n" // " gnEndUse=\"Lit\" is usual with gnDlFrPow." } return rc; @@ -1339,7 +1341,7 @@ RC GAIN::gn_DoHour() const // derive and apply hourly heat gains // check that not more than 100% of gain is distributed. runtime check needed as hourly expr input accepted. if (gnFrZn + gnFrPl + gnFrRtn > 1.f) // "For GAIN '%s': More than 100 percent of gnPower distributed:\n" - rc |= rer( (char *)MH_C0101, // " Total of fractions gnFrZn, gnFrPl, and gnFrRtn exceeds 1.0:\n" + rc |= rer( MH_C0101, // " Total of fractions gnFrZn, gnFrPl, and gnFrRtn exceeds 1.0:\n" Name(), // " gnFrZn (%g) + gnFrPl (%g) + gnFrRtn (%g) = %g" gnFrZn, gnFrPl, gnFrRtn, gnFrZn + gnFrPl + gnFrRtn ); if (gnFrRad + gnFrLat > 1.f) // 11-95 @@ -2143,7 +2145,7 @@ static RC checkSubMeterList( // helper for input-time checking submeter list { const record* pRSM = pR->b->GetAtSafe(subMeterList[i]); rc |= pR->oer("Submeter '%s' (item %d of %s list): %s", - pRSM ? pRSM->name : "?", i + 1, listArgName, msg); + pRSM ? pRSM->Name() : "?", i + 1, listArgName, msg); } bSeen[subMeterList[i]] = true; @@ -2493,8 +2495,8 @@ RC MTR_IVL::mtr_Validate1( // validity checks w/ message(s) strtprintf( "Tot(% 0.1f) != allEU + pv + bt (% 0.1f), diff = % 0.1f", tot, xTot, diff)); - if (msgs[ 0]) - rc |= mtr->orWarn( msgs); + if (msgs[0]) + rc |= mtr->orWarn(static_cast(msgs)); return rc; } // MTR_IVL::mtr_Validate1 @@ -2616,7 +2618,7 @@ void LOADMTR_IVL::lmt_Copy( // copy void LOADMTR_IVL::lmt_Accum( // accumulate const LOADMTR_IVL* sIvl, // source int firstFlg, // true iff first accum into this (beg of ivl) - int lastFlg, // true iff last accum into this (end of ivl) + [[maybe_unused]] int lastFlg, // true iff last accum into this (end of ivl) int options /*=0*/) // option bits // 1: use sIvl.lmt_count to scale totals // effectively averages by day for annual values @@ -2635,7 +2637,7 @@ void LOADMTR_IVL::lmt_Accum( // accumulate } // LOADMTR contains no averages - lastFlg; // unused + // lastFlg; unused } // LOADMTR_IVL //----------------------------------------------------------------------------- RC LOADMTR::lmt_CkF( // LOADMETER checks @@ -3010,7 +3012,7 @@ RC INVERSE::iv_Calc( } // INVERSE::iv_Calc //============================================================================ -#ifdef BINRES +#if defined( BINRES) //----------------------------------------------------------------------------------------------------------- LOCAL void FC binResInit( int isAusz) // initialize & open binary results (if to be used) at start run diff --git a/src/cnhp.cpp b/src/cnhp.cpp index c8ef532bd..10a7ebfbf 100644 --- a/src/cnhp.cpp +++ b/src/cnhp.cpp @@ -165,7 +165,7 @@ RC HEATPLANT::hpCompute() // conditionally compute heatplant { // handle under/overload: adjust capacity avail to each load if ( q >= stgCap[stgMxQ] * Top.hiTol // if load > largest stage capacity - || capF < 1.0 && q <= stgCap[stgMxQ] * Top.loTol ) // or capacities reduced & load < capac + || (capF < 1.0 && q <= stgCap[stgMxQ] * Top.loTol) ) // or capacities reduced & load < capac { setToMax( qPk, (float)q); // record peak q since fazInit() re autoSize overload check 6-95. adjCapF(); // adjust capF, update q, below. @@ -182,8 +182,8 @@ RC HEATPLANT::hpCompute() // conditionally compute heatplant stgi = stgMxQ; // use most powerful stage // due to tolerance in decrCapF it is normal to get here with "tol" excess load. if (q > stgCap[stgi] * Top.hiTol) // if overload by more than tol, issue message - rer( PWRN, // continue for now; errors end run elsewhere. - (char *)MH_R1350, Name(), q, stgCap[stgi] ); // "heatPlant %s overload failure: q (%g) > stgCap[stgMxQ] (%g)" + rerErOp( PWRN, // continue for now; errors end run elsewhere. + MH_R1350, Name(), q, stgCap[stgi] ); // "heatPlant %s overload failure: q (%g) > stgCap[stgMxQ] (%g)" } } @@ -271,7 +271,7 @@ void HEATPLANT::adjCapF() // adjust load capacities to match load to HEATPLANT c capF = 1.0; // restore full capac's to end loop & prevent recall til overload occurs } while ( q >= stgCap[stgMxQ] * Top.hiTol - || q <= stgCap[stgMxQ] * Top.loTol && capF < 1.0 ); + || (q <= stgCap[stgMxQ] * Top.loTol && capF < 1.0) ); } // HEATPLANT::adjCapF //------------------------------------------------------------------------------------------------------------------------------ #if 0 @@ -415,7 +415,7 @@ BOO HEATPLANT::nxBlrStg( BOILER *&blr, SI _stgi /*=-1*/ ) // first/next boiler if (_stgi < 0) _stgi = this->stgi; // default to current stage if (_stgi < 0 || _stgi >= NHPSTAGES) // if bad arg given or stgi member not yet set { - rer( PWRN, (char *)MH_R1351, Name(), _stgi, NHPSTAGES-1); // "heatPlant %s: bad stage number %d: not in range 0..%d" + rerErOp( PWRN, MH_R1351, Name(), _stgi, NHPSTAGES-1); // "heatPlant %s: bad stage number %d: not in range 0..%d" return FALSE; // NHPSTAGES: rccn.h. } diff --git a/src/cnloads.cpp b/src/cnloads.cpp index 22e84bb30..ecf4ef1c7 100644 --- a/src/cnloads.cpp +++ b/src/cnloads.cpp @@ -529,7 +529,7 @@ x } bool bDbPrint = DbDo( dbdZM); #if defined( _DEBUG) - const ZNR* zp1 = ZrB.GetAtSafe( 1); + [[maybe_unused]] const ZNR* zp1 = ZrB.GetAtSafe( 1); #endif // GLOBAL LOAD CHANGE CHECK: outdoor humidity @@ -1744,7 +1744,7 @@ double ZNR::zn_AirXMoistureBal( // air change rate and zone moisture balance // TODO: HPWH moisture removal? 2-16 - int wCase = 0; // debug aid + [[maybe_unused]] int wCase = 0; // debug aid // 0 = time constant OK, result OK // 1 = short time constant (steady state sln used), result OK // 2 = time constant OK, result limited @@ -2991,7 +2991,7 @@ void RSYS::rs_OAVAirFlow() // OAV air flow calcs #if defined( _DEBUG) // 9-29-2010 model for comparison float tMax = Wthr.d.wd_taDbPvPk; - float afOld = 0.f; + [[maybe_unused]] float afOld = 0.f; if (tMax > .0000001f) { double d = 17.91554 - 3.67538*log( tMax); afOld = 1.f/max( 1.f, float( d)); @@ -3519,7 +3519,7 @@ RC RSYS::rs_EndSubhr() // verify RSYSRES_IVL_SUB layout at compile time // fixed sequence allows array access by rs_mode (see code below) // rsmHEAT/rsmCOOL/rsmOAV definitions must be consistent with member sequences. -#define QZONECHK( m, oDif) static_assert( &((RSYSRES_IVL_SUB *)0)->m-&((RSYSRES_IVL_SUB *)0)->qhZoneSen == oDif, "Bad seq " #m) +#define QZONECHK( m, oDif) static_assert( &(((RSYSRES_IVL_SUB *)0)->m)-&(((RSYSRES_IVL_SUB *)0)->qhZoneSen) == oDif, "Bad seq " #m) QZONECHK(qhZoneSen, (rsmHEAT - 1) * 2); QZONECHK(qhZoneLat, (rsmHEAT - 1) * 2 + 1); QZONECHK(qcZoneSen, (rsmCOOL - 1) * 2); @@ -4624,7 +4624,7 @@ RC RSYS::rs_SetupASHP() // set ASHP defaults and derived parameters rs_COP47 += 0.1f; // try again with higher rs_COP47 } if ((rc1 || iTry==nTry) && !rs_isAuszH) - rc |= err("RSYS '%s': No reasonable value found for rsCOP17 and/or rsCOP47." + rc |= err(ERR, "RSYS '%s': No reasonable value found for rsCOP17 and/or rsCOP47." "\n Check rsHSPF and other heating inputs.", Name()); } } @@ -4646,7 +4646,7 @@ RC RSYS::rs_SetupASHP() // set ASHP defaults and derived parameters #if defined( _DEBUG) // back-calc checks float COP; - float capHt = rs_PerfASHP(0, 47.f, COP); + [[ maybe_unused]] float capHt = rs_PerfASHP(0, 47.f, COP); capHt = rs_PerfASHP(0, 17.f, COP); #endif @@ -5160,7 +5160,7 @@ static double fHrReg4[] = int ashpModel = options & 0x1F; int bDoPrint = (options & 0x100) != 0; - int nHrTot = 0; // total bin hours (s/b 2250 for reg 4) + [[ maybe_unused]] int nHrTot = 0; // total bin hours (s/b 2250 for reg 4) const float tDbIn = 65.f; // indoor design temp const float tDbDes = 5.f; // outdoor design temp const float DHR // design heating requirement per AHRI @@ -5328,7 +5328,7 @@ RC RSYS::rs_SizeHtASHP( // size ASHP cap47, f1, // x1, f1 cap47+100.); // x2 (f2) if (ret != 0) - { rc = err( "RSYS '%s': Cap47 for design load fail (return code=%d)", Name(), ret); + { rc = err( ERR, "RSYS '%s': Cap47 for design load fail (return code=%d)", Name(), ret); cap47 = cap47Est; } rs_cap47 = cap47; // redundant? diff --git a/src/cntp.cpp b/src/cntp.cpp index 91f02ec06..197752415 100644 --- a/src/cntp.cpp +++ b/src/cntp.cpp @@ -258,10 +258,10 @@ RC TOWERPLANT::endSubhr() // towers end-subhour computations: fraction on, # tow RC rc=RCOK; if (tpTs <= 32.) // Farenheight assumed! - rc |= rer( (char *)MH_R1370, Name(), tpTs); // "Frozen towerPlant '%s': supply temp tpTs = %gF" + rc |= rer( MH_R1370, Name(), tpTs); // "Frozen towerPlant '%s': supply temp tpTs = %gF" //check return... no, check returned water in each load. then delete here: if (tpTs >= 212.) // Farenheight assumed! - rc |= rer( (char *)MH_R1371, Name(), tpTs); //"Boiling towerPlant '%s': supply temp tpTs = %gF" + rc |= rer( MH_R1371, Name(), tpTs); //"Boiling towerPlant '%s': supply temp tpTs = %gF" // add any computations or result recording not needed to determine tpTs ... @@ -430,8 +430,8 @@ RC TOWERPLANT::varSpeedF( // determine f needed for one tower to output power q #define NITMAX 10 // increase when need found if (++niter > NITMAX) { - rer( (char *)MH_R1372, Name(), (INT)niter, // "TowerPlant '%s': varSpeedF() convergence failure, %d iterations \n" - qWant, _q, _f ); // " qWant=%g q=%g f=%g" + rer( MH_R1372, Name(), niter, // "TowerPlant '%s': varSpeedF() convergence failure, %d iterations \n" + qWant, _q, _f ); // " qWant=%g q=%g f=%g" break; } #undef NITMAX @@ -470,7 +470,7 @@ RC TOWERPLANT::varSpeedF( // determine f needed for one tower to output power q * #define NITMAX = 10; // increase if need found * if (++niter > NITMAX) * { rer( "TowerPlant '%s': varSpeedF() convergence failure, %d iterations \n qWant=%g q=%g f=%g", -* Name(), (INT)niter, qWant, _q, _f ); +* Name(), niter, qWant, _q, _f ); * break; * } * #undef NITMAX diff --git a/src/cnztu.cpp b/src/cnztu.cpp index 2cfa79399..8af859283 100644 --- a/src/cnztu.cpp +++ b/src/cnztu.cpp @@ -191,7 +191,7 @@ RC FC hvacIterSubhr() // terminate loop after too many iterations if (++Top.iter >= MAXITER) // rer: display runtime message with date/time. errCount++'s. exman.cpp. - { rer( (char *)MH_R1250, Top.iter); + { rer( MH_R1250, Top.iter); break; // "Air handler - Terminals convergence failure: %d iterations" } @@ -199,7 +199,7 @@ RC FC hvacIterSubhr() if (errCount() > maxErrors) // errCount(): error count ++'d by calls to err, rer, etc. rmkerr.cpp. { rc = rInfo( // display runtime "Information" message, exman.cpp. returns RCBAD. - (char *)MH_R1251, // handle for text "More than %d errors. Terminating run." + MH_R1251, // handle for text "More than %d errors. Terminating run." maxErrors ); // maxErrors: cuparse.cpp. Data init, accessible as $maxErrors. goto er; } @@ -385,7 +385,7 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal // no-local-heat checks: errors for lh members given rc |= disallowN( // prohibit entry of list of fields - (char*)MH_S0600, /* "when terminal has no local heat\n" + MH_S0600, /* "when terminal has no local heat\n" " (when neither tuTLh nor tuQMnLh given)" */ TU_TUQMXLH, TU_TUPRILH, TU_TULHNEEDSFLOW, 0); @@ -405,7 +405,7 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal if ((sstat[TU_TUHC + HEATCOIL_CAPTRAT] & (FsSET | FsVAL)) == (FsSET | FsVAL)) // if coil power given and set (constant) if (tuQMxLh > tuhc.captRat) // do the user a favor oWarn( - (char*)MH_S0601, // "tuQMxLh = %g will be ineffective because tuhcCaptRat is less: %g" + MH_S0601, // "tuQMxLh = %g will be ineffective because tuhcCaptRat is less: %g" tuQMxLh, tuhc.captRat); if (cmLh == cmSo) @@ -413,7 +413,7 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal // set output local heat checks - rc |= disallowN((char*)MH_S0603, /* "when local heat is not thermostat controlled\n" + rc |= disallowN(MH_S0603, /* "when local heat is not thermostat controlled\n" " (when tuTLh is not given)" */ TU_TUQMXLH, TU_TUPRILH, 0); @@ -428,7 +428,7 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal /* require max heat spec: else omission yields mysteriously inoperative local heat. wouldn't it be nicer to default it to the coil capacity if given? 12-92. */ - rc |= require((char*)MH_S0604, TU_TUQMXLH); // "when terminal has thermostat-controlled local heat\n" + rc |= require(MH_S0604, TU_TUQMXLH); // "when terminal has thermostat-controlled local heat\n" // " (when tuTLh is given)" // terminal local heat coil autoSizing if (sstat[TU_TUHC + HEATCOIL_CAPTRAT] & FsAS) // if "AUTOSIZE tuhcCaptRat" given @@ -459,13 +459,13 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal if (!(cmAr & cmStH)) // any value but cmStH or cmStBOTH { - rc |= disallowN((char*)MH_S0605, TU_TUVFMXH, TU_TUPRIH, 0); // "when tuTH not given" + rc |= disallowN(MH_S0605, TU_TUVFMXH, TU_TUPRIH, 0); // "when tuTH not given" if (sstat[TU_TUVFMXH] & FsAS) rc |= oer("Cannot autoSize tuVfMxH when tuTH not given."); // NUMS } if (!(cmAr & cmStC)) // any value but cmStC or cmStBOTH { - rc |= disallowN((char*)MH_S0606, TU_TUVFMXC, TU_TUPRIC, 0); // "when tuTC not given" + rc |= disallowN(MH_S0606, TU_TUVFMXC, TU_TUPRIC, 0); // "when tuTC not given" if (sstat[TU_TUVFMXC] & FsAS) rc |= oer("Cannot autoSize tuVfMxC when tuTC not given."); // NUMS } @@ -497,7 +497,7 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal if (cmAr == cmNONE) // no air heat nor air cool { - rc |= disallowN((char*)MH_S0607, // "when terminal has no air heat nor cool\n" + rc |= disallowN(MH_S0607, // "when terminal has no air heat nor cool\n" // " (when none of tuTH, tuTC, or tuVfMn is given)" TU_AI, TU_TUSRLEAK, TU_TUSRLOSS, TU_TFANSCH, TU_TFANOFFLEAK, TU_TFAN + FAN_FANTY, 0); @@ -506,7 +506,7 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal { //=============== check present air heat and/or cool ================ - rc |= requireN((char*)MH_S0608, /* "when terminal has air heat or cool\n" + rc |= requireN(MH_S0608, /* "when terminal has air heat or cool\n" " (when any of tuTH, tuTC, or tuVfMn are given)" */ TU_AI, 0); // member(s) required for air heat //if (!rc)? @@ -573,22 +573,22 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal // require max heating cfm tuVfMxH if heat setpoint tuTH given, else disallow. and tuVfMxC likewise. if (sstat[TU_TUTH] & FsSET) - rc |= require((char*)MH_S0691, TU_TUVFMXH); // "\n when terminal has thermostat-controlled air heat " + rc |= require(MH_S0691, TU_TUVFMXH); // "\n when terminal has thermostat-controlled air heat " // "(when tuTH is given)" else - rc |= disallow((char*)MH_S0605, TU_TUVFMXH); // "when tuTH not given" + rc |= disallow(MH_S0605, TU_TUVFMXH); // "when tuTH not given" if (sstat[TU_TUTC] & FsSET) - rc |= require((char*)MH_S0692, TU_TUVFMXC); // "\n when terminal has thermostat-controlled air cooling " + rc |= require(MH_S0692, TU_TUVFMXC); // "\n when terminal has thermostat-controlled air cooling " // "(when tuTC is given)" else - rc |= disallow((char*)MH_S0606, TU_TUVFMXC); // "when tuTC not given" + rc |= disallow(MH_S0606, TU_TUVFMXC); // "when tuTC not given" // disallow tuSRLoss if return not ducted if (zp) // if zone reference ok if (!zp->i.plenumRet) // if ducted return zone, S to R loss disallowed { - disallow((char*)MH_S0609, TU_TUSRLOSS); // error if given *** check wording when plenums done *** + disallow(MH_S0609, TU_TUSRLOSS); // error if given *** check wording when plenums done *** // "when zone plenumRet is 0" tuSRLoss = 0.f; // set to 0 (is RUN RECORD!) (CULT defaults non-0) } @@ -613,7 +613,7 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal if (cmLh == cmNONE && cmAr == cmNONE) // if useless terminal (and no error if here) { - rc |= disallowN((char*)MH_S0610, /* "when terminal has no capabilities: \n" + rc |= disallowN(MH_S0610, /* "when terminal has no capabilities: \n" " no setpoint (tuTLh, tuTH, tuTC) nor minimum (tuQMnLh, tuVfMn) given"*/ TU_TFANSCH, TU_TFANOFFLEAK, TU_TFAN + FAN_FANTY, 0); // only tfanType checked; if user deletes that, @@ -624,7 +624,7 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal if (tfan.fanTy == C_FANTYCH_NONE) // if no fan specified { - rc |= disallowN((char*)MH_S0611, // "when tfanType = NONE" + rc |= disallowN(MH_S0611, // "when tfanType = NONE" TU_TFANSCH, TU_TFANOFFLEAK, 0); // disallow these variables tfanOffLeak = 0.f; // no fan back-leakage (this is RUN record!)(insurance) CHN(tfanSch) = C_TFANSCHVC_OFF; // schedule of absent fan is OFF (cnah code may assume) @@ -632,14 +632,14 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal else // have fan { // tfanOffLeak is defaulted non-0 by CULT. - rc |= require((char*)MH_S0612, TU_TFANSCH); // schedule required "when tfanType not NONE" + rc |= require(MH_S0612, TU_TFANSCH); // schedule required "when tfanType not NONE" } //=============== useless terminal check =============== if (rc == RCOK && cmLh == cmNONE && cmAr == cmNONE) { - oWarn((char*)MH_S0613); /* "Ignoring terminal with no capabilities: \n" + oWarn(MH_S0613); /* "Ignoring terminal with no capabilities: \n" " no setpoint (tuTLh, tuTH, tuTC) nor minimum (tuQMnLh, tuVfMn) given" */ return rc; } @@ -989,7 +989,7 @@ RC TU::tu_endAutosize() // terminal stuff at end successful autosize 6-95 if (dtLoHAs) // from dtLoH, from dtLoHSh, from ztuMode(). { AH *ah = AhB.p + ai; // point tu's air handler - char * sub /*=""*/; + const char* sub{ ""}; if (ah->ahhc.coilTy==C_COILTYCH_NONE) // if no heat coil sub = "Perhaps this is because airHandler %s has no heat coil."; // NUMS's else if (!(ah->sstat[AH_AHHC+AHHEATCOIL_CAPTRAT] & FsAS)) // if ah's heat coil not autoSized @@ -1010,7 +1010,7 @@ RC TU::tu_endAutosize() // terminal stuff at end successful autosize 6-95 if (dtLoCAs) // from dtLoC, from dtLoCSh, from ztuMode(). { AH *ah = AhB.p + ai; // point tu's air handler - char * sub /*=""*/; + const char* sub{ "" }; if (ah->ahcc.coilTy==C_COILTYCH_NONE) // if no cool coil sub = "Perhaps this is because airHandler %s has no cooling coil."; // NUMS's else if (!(ah->sstat[AH_AHCC+COOLCOIL_CAPTRAT] & FsAS)) // if cool coil not autoSized @@ -1630,7 +1630,7 @@ RC TU::tu_EndSubhr() // terminal stuff done at end subhr: record load; checks a HEATPLANT *hp = HpB.p + tuhc.hpi; if (hp->hpMode != C_OFFONCH_ON) // heatplant must be scheduled OFF, or would have come on from ztuCompute. // rWarn? shd be ok to continue: 0 lh used when plant off. - rer( (char *)MH_R1252, // "heatPlant %s is scheduled OFF, \n" + rer( MH_R1252, // "heatPlant %s is scheduled OFF, \n" hp->Name(), Name(), tuQMnLh, tuQMxLh ); // " but terminal %s's local heat is NOT scheduled off: \n" break; // " tuQMnLh = %g tuQMxLh = %g" } @@ -1642,7 +1642,7 @@ RC TU::tu_EndSubhr() // terminal stuff done at end subhr: record load; checks a if (tuLhNeedsFlow==C_NOYESCH_YES) // and terminal's lh needs flow if ( cz==0.f // if terminal has no air heat/cool flow (in excess of leaks/backflow) && CHN(tfanSch)==C_TFANSCHVC_OFF ) // and fan is off *COMPLETE THIS* TFAN CODE INCOMPLETE .. HEATING,VAV ... - return rer( (char *)MH_R1253, // "Local heat that requires air flow is on without flow\n" + return rer( MH_R1253, // "Local heat that requires air flow is on without flow\n" Name(), Name()); // " for terminal '%s' of zone '%s'.\n" // " Probable internal error, \n" // " but perhaps you can compensate by scheduling local heat off." @@ -1890,7 +1890,7 @@ RC ZNR::ztuMode() // ztuCompute inner fcn: determine zone mode, zone temp, term { // floating modes if (bZn==0.) - return rer((char *)MH_R1254, Name()); // "Internal error: 'b' is 0, cannot determine float temp for zone '%s'" + return rer(MH_R1254, Name()); // "Internal error: 'b' is 0, cannot determine float temp for zone '%s'" t = a/bZn; // zone temp: with no tstat-ctrl'd zhx, there is no q not already in a // change modes if temp out of range. // tFuzz prevents getting stuck in inf loop cuz of accumulated roundoff errors @@ -2526,7 +2526,7 @@ RC ZNR::ztuMode() // ztuCompute inner fcn: determine zone mode, zone temp, term huntCount = 0; // start non-convergence detection over. added 5-97 static SI count2 = 0; if (count2++ < 100) // rer (runtime error) errCount++'s: stops run upon ret to a higher level. - rer( (char *)MH_R1255, tFuzz, int(md)); // "Internal error: ztuMode is increasing tFuzz to %g (mode %d)" + rer( MH_R1255, tFuzz, int(md)); // "Internal error: ztuMode is increasing tFuzz to %g (mode %d)" } } // for ( ; ; ) @@ -2597,7 +2597,7 @@ RC ZNR::ztuMode() // ztuCompute inner fcn: determine zone mode, zone temp, term DBL q2 = zn_bLdSh * t - zn_aqLdSh; // q = b*t - a: I claim this should be same (and its easier) float scale = fabs(zn_bLdSh * t + zn_aqLdSh)+1.; // measure accuracy as fraction of inputs (note '+'), /0 protect if (ABSCHANGE(zn_qsHvac/scale,q2/scale) > 1.e-12) // 1.e-10: no msgs. 1.e-11: no msgs. 1.e-12: no msgs 1992-. - rInfo((char *)MH_R1256, zn_qsHvac, q2); // "Inconsistency in ztuMode: zn_qsHvac (%g) != q2 (%g)" + rInfo(MH_R1256, zn_qsHvac, q2); // "Inconsistency in ztuMode: zn_qsHvac (%g) != q2 (%g)" } #endif @@ -2639,10 +2639,10 @@ RC ZNR::ztuMdSeq() // build zone hvac terminal mode sequence table } else if (x->spPri==nx->spPri) // "Equal setpoints (%g) with equal priorities (%d) in zone '%s' -- \n" { - return rer( (char *)MH_R1257, // " %s and %s" + return rer( MH_R1257, // " %s and %s" x->sp, x->spPri, Name(), - x->ui ? strtprintf( (char *)MH_R1258, TuB.p[x->ui].Name()) : "natvent", // "terminal '%s'" - nx->ui ? strtprintf( (char *)MH_R1258, TuB.p[nx->ui].Name()) : "natvent" ); // ditto + x->ui ? strtprintf( MH_R1258, TuB.p[x->ui].Name()) : "natvent", // "terminal '%s'" + nx->ui ? strtprintf( MH_R1258, TuB.p[nx->ui].Name()) : "natvent" ); // ditto } else if (!xCool) // if both heating { @@ -2669,7 +2669,7 @@ RC ZNR::ztuMdSeq() // build zone hvac terminal mode sequence table ZHX *xArH = ZhxB.p + x->xiArH; // zhx[0] or corress heating zhx for a cooling zhx if ( x->zhxTy==ArStC // if a set temp air cool zhx && x->sp < xArH->sp ) // if terminal also heats (note), with larger setpoint - return rer( (char *)MH_R1259, // "Cooling setpoint temp (%g) is less than heating setpoint (%g)\n" + return rer( MH_R1259, // "Cooling setpoint temp (%g) is less than heating setpoint (%g)\n" x->sp, xArH->sp, // " for terminal '%s' of zone '%s'" TuB.p[x->ui].Name(), ZrB.p[x->zi].Name()); /* note: if terminal does not also heat, x->xiArH will be 0. Zhx record 0 is all 0's. x->sp assumed >= 0 F. */ @@ -2874,7 +2874,7 @@ haveFlow: ; // other air handler cases join here with flow cz set wcO1 = wc; break; // sigma( c * ah_wSup) for calculating wz Rob's way, as aw/bw default: - rer( PWRN, (char *)MH_R1260, Top.humMeth); // "Bad Top.humMeth %d in cnztu.cpp:ZNR::ztuAbs" + rerErOp( PWRN, MH_R1260, Top.humMeth); // "Bad Top.humMeth %d in cnztu.cpp:ZNR::ztuAbs" } // ... So and StO members can now be combined? diff --git a/src/cpgbuild.h b/src/cpgbuild.h index 896855acc..58a0b56a2 100644 --- a/src/cpgbuild.h +++ b/src/cpgbuild.h @@ -299,7 +299,7 @@ struct PB_DATOFF /* code assumes 1st 3 mbrs match PB_TEXT (for PBFILL)*/ struct PB_DATOFFL /* code assumes same as PB_DATOFF + label at end */ { USI pgfmt; SI row; SI col; SI off; USI dt; SI units; SI wid; SI cvfmt; - char* label; // label text: PGRJ'd to left of field data. Include + const char* label; // label text: PGRJ'd to left of field data. Include // any desired separating spaces in label text. }; diff --git a/src/cpnat.cpp b/src/cpnat.cpp index 6fb1d1c09..b8e5397f7 100644 --- a/src/cpnat.cpp +++ b/src/cpnat.cpp @@ -454,7 +454,7 @@ h if (hdPnRow) /* if hdr has a page # for us to set*/ h { pgw( hdPpp, /* write into PAGE, pgpak.c */ h hdPnFmt, hdPnRow, hdPnCol, h strtprintf("Page %d", // printf and return ptr (strpak.c) -h (INT)vrGetPage(pnVrh) ) ); // get virtual page # (vrpak.c) +h vrGetPage(pnVrh) ) ); // get virtual page # (vrpak.c) h } #endif #ifdef FOOTERS @@ -462,7 +462,7 @@ f ?? logic missing here to space down to proper footer position f if (ftPnRow) f { rc |= pgw( ftPpp, ftPnFmt, ftPnRow, ftPnCol, f strtprintf( "%d", -f (INT)vrGetPage(pnVrh) ); +f vrGetPage(pnVrh) ); f } f /* footer is now ready for foot page just started, f including last page where caller prints it */ diff --git a/src/cse.cpp b/src/cse.cpp index b5ab07e6a..ea7c263f1 100644 --- a/src/cse.cpp +++ b/src/cse.cpp @@ -690,7 +690,7 @@ LOCAL int cse3( int argc, const char* argv[]) || strchr( argv[1],'?') ) // or user wants help -- CSE ? or CSE -? { screen( 0, // display msg (rmkerr.cpp) - (char *)MH_C0001, // msg text explains command line, msgtbl.cpp. + MH_C0001, // msg text explains command line, msgtbl.cpp. _strlwr( strpathparts( argv[0], STRPPFNAME)) ); // lower case exe file name in Tmpstr, to insert at %s, 2-95 byebye( errorlevel); // envpak.cpp: clean up and and return to subr pkg caller, @@ -744,7 +744,7 @@ LOCAL int cse3( int argc, const char* argv[]) { // warning for switch after file name, cuz confusing: apply to preceding file only if last file 2-95. Use switch anyway. if (InputFileName) - warn( (char *)MH_C0008, // "C0008: \"%s\":\n it is clearer to always place all switches before the input file name." + warn( MH_C0008, // "C0008: \"%s\":\n it is clearer to always place all switches before the input file name." arg ); char c1 = tolower(*(arg + 1)); @@ -795,7 +795,7 @@ LOCAL int cse3( int argc, const char* argv[]) case 'z': if (!hans) // -z: output bin res's to memory as well as file noHans: - rc |= err( (char *)MH_C0009, c); /* "Can't use switch -%c unless calling program\n" + rc |= err( ERR, MH_C0009, c); /* "Can't use switch -%c unless calling program\n" " gives \"hans\" argument for returning memory handles" */ else brDiscardable++; @@ -803,7 +803,7 @@ LOCAL int cse3( int argc, const char* argv[]) #else case 'm': case 'z': - rc |= err( (char *)MH_C0010, c); // "Switch -%c not available in DOS version" + rc |= err( ERR, MH_C0010, c); // "Switch -%c not available in DOS version" break; #endif #endif @@ -815,38 +815,38 @@ LOCAL int cse3( int argc, const char* argv[]) case 't': // TestOptions: testing-related bits if (strDecode( arg+2, TestOptions) != 1) - rc |= err( "Invalid -t option '%s' (s/b integer)", arg+2); + rc |= err( ERR, "Invalid -t option '%s' (s/b integer)", arg+2); argLenMax = -1; // don't enforce length limit break; case '\0': - rc |= err( // issue error msg, continue for now - (char *)MH_C0005, c0); // "Switch letter required after '%c'" + rc |= err( ERR, // issue error msg, continue for now + MH_C0005, c0); // "Switch letter required after '%c'" break; default: badArg: - rc |= err( // msg, continue for now. rmkerr.cpp - (char *)MH_C0006, arg); // "Unrecognized switch '%s'" + rc |= err( ERR, // msg, continue for now. rmkerr.cpp + MH_C0006, arg); // "Unrecognized switch '%s'" argLenMax = -1; } if (argLenMax > 0 && strlenInt(arg) > argLenMax) - rc |= err((char*)MH_C0006, arg); // "Unrecognized switch '%s'" + rc |= err(ERR, MH_C0006, arg); // "Unrecognized switch '%s'" } else if (InputFileName==NULL) // else if no input file name yet InputFileName = strcpy( inputFileNameBuf, arg); // take this arg as input file name else // dunno what to do with it. Should now be impossible -- see cse1() level 2-95. err( ABT, // issue msg, abort program; does not return - (char *)MH_C0002, // "Too many non-switch arguments on command line: %s ..." + MH_C0002, // "Too many non-switch arguments on command line: %s ..." arg ); } // switch loop if ( !InputFileName // if no filename given && probeNamesFlag < 0 && culDocFlag < 0) // nor anything else to do requested - err( ABT, (char *)MH_C0003); // "No input file name given on command line" and abort + err( ABT, MH_C0003); // "No input file name given on command line" and abort if (rc) // if error(s) in cmd line args, exit now. ppClargIf or code above issued specific msgs. - err( ABT, (char *)MH_C0004); // "Command line error(s) prevent execution" and abort + err( ABT, MH_C0004); // "Command line error(s) prevent execution" and abort /*----- do special switches, exit if no input file to drive runs -----*/ @@ -857,7 +857,7 @@ LOCAL int cse3( int argc, const char* argv[]) cgPreInit(); // preliminary simulator data init needed by showProbeNames (cnguts.cpp) if (cul( 0, NULL, "", cnTopCult, &Topi )) // prelim cul.cpp:cul init: set things needed by showProbeNames err( PABT, // if error, fatal program error message (rmkerr.cpp). no return. - (char *)MH_C0007 ); // "Unexpected cul() preliminary initialization error" + MH_C0007 ); // "Unexpected cul() preliminary initialization error" if (probeNamesFlag >= 0) showProbeNames( probeNamesFlag); // do it, cuprobe.cpp @@ -885,7 +885,7 @@ LOCAL int cse3( int argc, const char* argv[]) Note: for most thorough check, restore xiopak.cpp:xfScanFileName(). */ if (strcspn( InputFileName, "?*") < strlen(InputFileName)) // if an * or ? in pathname - err( ABT, (char *)MH_C0011, InputFileName ); // "\"%s\": \n input file name cannot contain wild cards '?' and '*'." + err( ABT, MH_C0011, InputFileName ); // "\"%s\": \n input file name cannot contain wild cards '?' and '*'." // default input extension -- before path search diff --git a/src/cueval.cpp b/src/cueval.cpp index 174333f7a..302a9eabe 100644 --- a/src/cueval.cpp +++ b/src/cueval.cpp @@ -87,8 +87,8 @@ SI runtrace = 0; // settable as sys var $runtrace (cuparse.cpp) /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ LOCAL RC FC cuEval( void *ip, const char** pmsg, USI *pBadH); LOCAL RC FC cuEvalI( const char** pmsg, USI *pBadH); -LOCAL RC FC cuRmGet( NANDAT& vRet, const char** pms, USI *pBadH); -LOCAL RC FC cuRm2Get( SI *pi, const char** pms, USI *pBadH); +LOCAL RC FC cuRmGet( NANDAT& vRet, MSGORHANDLE* pms, USI *pBadH); +LOCAL RC FC cuRm2Get( SI *pi, MSGORHANDLE* pms, USI *pBadH); LOCAL const char * FC ivlTx( IVLCH ivl); /*lint -e124 "Pointer to void not allowed" when comparing void ptrs */ @@ -109,7 +109,7 @@ RC FC cuEvalTop( void *ip) // evaluate psuedocode at ip, check for empty stack rc = cuEval(ip, NULL, NULL); // evaluate psc at ip. NULL: issue any error message in cuEval. if (evSp != evStkBase) // verify stack empty return err( PWRN, // display internal error msg, ret RCBAD - (char *)MH_R0201, // "cuEvalTop: %d words left on eval stack" + MH_R0201, // "cuEvalTop: %d words left on eval stack" INT( (SI *)evStkBase - SPI) ); return rc; // additional return(s) above @@ -391,9 +391,9 @@ LOCAL RC FC cuEvalI( // expression eval pseudo-code interpreter inner loop - const char **pmsg, // NULL or receives ptr to un-issued Tmpstr error msg. - // CAUTION: msg is in transitory temp string storage: use or strsave promptly. - USI *pBadH ) // NULL or receives 0 (for UNSET, or SI expr) or unevaluated expr # if RCUNSET returned + const char* *pmsg, // NULL or receives ptr to un-issued Tmpstr error msg. + // CAUTION: msg is in transitory temp string storage: use or strsave promptly. + USI* pBadH ) // NULL or receives 0 (for UNSET, or SI expr) or unevaluated expr # if RCUNSET returned // and uses: evIp, evSp, /* returns RCOK if all ok. @@ -403,7 +403,7 @@ LOCAL RC FC cuEvalI( specific error codes include: RCUNSET, unset value or un-evaluated expression accessed (PSRATLODxx), 0 or handle returned *pBadH. */ { - const char *ms = NULL; // init to no error + MSGORHANDLE ms{}; // init to no error RC rc = RCOK; // if error (ms nz), RCBAD will be supplied at exit unless other nz value set. SI idx=0, lo=0, hi=0; // errMsg info, PSDISP_ to PSCHUFAI. @@ -421,12 +421,12 @@ LOCAL RC FC cuEvalI( // eval stack over/underflow checks. NB builds down, top is < base. if (evSp < evStkTop) { - ms = strtprintf( (char *)MH_R0204, evIp); // "cuEvalI internal error: \n eval stack overflow at ps ip=%p" + ms = strtprintf( MH_R0204, evIp); // "cuEvalI internal error: \n eval stack overflow at ps ip=%p" break; } if (evSp > evStkBase) { - ms = strtprintf( (char *)MH_R0205, evIp); // "cuEvalI internal error: \n eval stack underflow at ps ip=%p" + ms = strtprintf( MH_R0205, evIp); // "cuEvalI internal error: \n eval stack underflow at ps ip=%p" break; } @@ -491,7 +491,7 @@ LOCAL RC FC cuEvalI( evFck: if (evFp == NULL) // late no-frame check { - ms = strtprintf((char *)MH_R0206, evIp); /* "cuEvalI internal error: \n" + ms = strtprintf(MH_R0206, evIp); /* "cuEvalI internal error: \n" " arg access thru NULL frame ptr at ip=%p" */ goto breakbreak; } @@ -575,7 +575,7 @@ LOCAL RC FC cuEvalI( case PSSCH: // string (stack) to choice (stack) per data type (inline) 2-92 if (cvS2Choi((char*)*SPP++, *IPU++, (void *)&v, &h, &ms) == RCBAD) // cvpak.cpp goto breakbreak; // if error (ms set) - ms = NULL; // insurance, drop possible info msg + ms.mh_Clear(); // insurance, drop possible info msg if (h == 4) *--SPP = v; // if a 4-byte choice type (choicn), return 4 bytes else @@ -586,16 +586,16 @@ LOCAL RC FC cuEvalI( if (ISNUM(v = *SPP)) break; // if stack top is a number (cnglob.h), ok, done //note that if 2-byte choice gets here (shouldn't) it is taken as a number. if (ISNCHOICE(v)) - ms = strtprintf((char *)MH_R0207, (INT)CHN(v) & ~NCNAN); // "Choice (%d) value used where number needed" + ms = strtprintf(MH_R0207, (int)CHN(v) & ~NCNAN); // "Choice (%d) value used where number needed" else if (ISNANDLE(v)) if (ISUNSET(v)) - ms = (char *)MH_R0208; // "Unexpected UNSET value where number neeeded" + ms = MH_R0208; // "Unexpected UNSET value where number neeeded" else if (ISASING(v)) - ms = (char *)MH_R0231; // "Unexpected being-autosized value where number needed" + ms = MH_R0231; // "Unexpected being-autosized value where number needed" else - ms = strtprintf((char *)MH_R0209, (INT)EXN(v)); // "Unexpected reference to expression #%d" + ms = strtprintf(MH_R0209, EXN(v)); // "Unexpected reference to expression #%d" else - ms = (char *)MH_R0210; // "Unexpected mystery nan" (text retreived below) + ms = MH_R0210; // "Unexpected mystery nan" (text retreived below) goto breakbreak; case PSFINCHES: // combine float inches with float feet @@ -608,7 +608,7 @@ LOCAL RC FC cuEvalI( // inline: # days in month, 1st day of month less 1. if (*SPI < 1 || *SPI > *(SI*)evIp) // check DOM { - ms = strtprintf((char *)MH_R0211, (INT)*SPI, (INT)*(SI*)evIp); // "Day of month %d is out of range 1 to %d" + ms = strtprintf(MH_R0211, *SPI, *(SI*)evIp); // "Day of month %d is out of range 1 to %d" goto breakbreak; } IPI++; // point past # days in month @@ -634,7 +634,7 @@ LOCAL RC FC cuEvalI( case PSIDIV: if (*SPI == 0) { - ms = (char *)MH_R0212; // "Division by 0" + ms = MH_R0212; // "Division by 0" goto breakbreak; } *(SPI + 1) /= *SPI; @@ -730,7 +730,7 @@ LOCAL RC FC cuEvalI( case PSFDIV: if (*SPF == 0.) { - ms = (char *)MH_R0213; // "Division by 0." + ms = MH_R0213; // "Division by 0." goto breakbreak; } *(SPF + 1) /= *SPF; @@ -785,7 +785,7 @@ LOCAL RC FC cuEvalI( //--- float math function case PSFSQRT: if (*SPF < 0.f) - { ms = (char *)MH_R0214; // "SQRT of a negative number" + { ms = MH_R0214; // "SQRT of a negative number" goto breakbreak; } *SPF = sqrt(*SPF); @@ -1002,14 +1002,14 @@ LOCAL RC FC cuEvalI( case PSCHUFAI: // issue fatal "index out of range" error. // uses idx, lo, hi, set in PSDISP_ case. // default default for PSDISP. - ms = strtprintf( (char *)MH_R0215, // "In choose() or similar fcn, \n" - (INT)idx, (INT)lo, (INT)hi ); // " dispatch index %d is not in range %d to %d \n" + ms = strtprintf( MH_R0215, // "In choose() or similar fcn, \n" + idx, lo, hi ); // " dispatch index %d is not in range %d to %d \n" // " and no default given." goto breakbreak; case PSSELFAI: // issue "no true condition" message: default default for select() - ms = (char *)MH_R0216; /* "in select() or similar function, \n" - " all conditions false and no default given." */ + ms = MH_R0216; /* "in select() or similar function, \n" + " all conditions false and no default given." */ goto breakbreak; //--- prints (development aids) @@ -1029,8 +1029,8 @@ LOCAL RC FC cuEvalI( i = *SPI++; // get record number from stack if (i < b->mn || i > b->n) { - ms = strtprintf( (char *)MH_R0217, // "%s subscript %d out of range %d to %d" - (char *)b->what, (INT)i, (INT)b->mn, (INT)b->n); + ms = strtprintf( MH_R0217, // "%s subscript %d out of range %d to %d" + b->what, i, b->mn, b->n); goto breakbreak; } *--SPP = &b->rec(i); // push pointer to record i @@ -1053,10 +1053,10 @@ LOCAL RC FC cuEvalI( { ms = strtprintf( trc==RCBAD2 - ? (char *)MH_R0218 // "%s name '%s' is ambiguous: 2 or more records found.\n" + ? MH_R0218 // "%s name '%s' is ambiguous: 2 or more records found.\n" // " Change to unique names." - : (char *)MH_R0219, // "%s record '%s' not found." - (char *)b->what, pName ); + : MH_R0219, // "%s record '%s' not found." + b->what, pName ); goto breakbreak; } } @@ -1119,13 +1119,13 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign if (exInfo( h, NULL, NULL, reinterpret_cast(&p))) // get expression value / if bad expr # { badExprH: - ms = strtprintf( (char *)MH_R0220, h); // "cuEvalI internal error: bad expression number 0x%x" + ms = strtprintf( MH_R0220, h); // "cuEvalI internal error: bad expression number 0x%x" goto breakbreak; } if (ISNANDLE(p)) // if VALUE of expr is UNSET (other NAN not expected in expr tbl) { unsExprH: - ms = strtprintf( (char *)MH_R0230, // "%s has not been evaluated yet." 11-92 + ms = strtprintf( MH_R0230, // "%s has not been evaluated yet." 11-92 whatEx(h) ); // describes expr origin, exman.cpp rc = RCUNSET; // specific "uneval'd expr" error code, callers test. if (pBadH) // if info return ptr given @@ -1239,7 +1239,7 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign break; default: - ms = strtprintf( (char *)MH_R0221, // "cuEvalI internal error:\n Bad pseudo opcode 0x%x at psip=%p" + ms = strtprintf( MH_R0221, // "cuEvalI internal error:\n Bad pseudo opcode 0x%x at psip=%p" op, IPOP-1 ); case PSEND: // normal terminator printif(runtrace, "\n"); @@ -1250,15 +1250,13 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign ; if (pmsg) // if msg return requested - { - if (msgIsHan(ms)) // if ms is an unretrieved message HANDLE (excludes NULL) (lib\messages.cpp) - ms = strtprintf(ms); // retrieve message text and put in Tmpstr, to get char * ptr to return to caller - *pmsg = ms; // return NULL or ptr to Tmpstr msg text. TRANSITORY! + { // return nullptr or ptr to Tmpstr msg text. may be TRANSITORY! + *pmsg = ms.mh_GetMsg( nullptr); // get msg text (nullptr if none) } else // pmsg==NULL: issue any msg here - if (ms) // if there is a messsage + if (!ms.mh_IsNull()) // if there is a messsage err( WRN, ms); // display error msg - if (ms && !rc) // if no specific error return code already set + if (!ms.mh_IsNull() && !rc) // if no specific error return code already set rc = RCBAD; // supply generic error code return rc; // RCOK if ok } // cuEvalI @@ -1267,7 +1265,7 @@ w case PSRATLOD1S: POINT; *--SPI = (SI)*(CH*)v; break; // 1 byte, extend sign // is it time to put cuEvalI ms and pBadH in file-globals? LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset check and expr fix. NANDAT& vRet, // value returned (non-NAN if success) - const char** pms, // returned: unissued error message if any + MSGORHANDLE* pms, // returned: unissued error message if any USI *pBadH) // pops record pointer from eval stack (evSp); fetches inline field number from instruction stream (evIp). @@ -1290,14 +1288,14 @@ LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset che if (fir->fi_evf & EVXBEGIVL) // if probed field avail only at end ivl (can probe start-ivl flds anytime) { if (!Top.isEndOf) // if not now end of an interval (cnguts.cpp) { - *pms = strtprintf( (char *)MH_R0222, // "Internal Error: mistimed probe: %s varies at end of %s\n" + *pms = strtprintf( MH_R0222, // "Internal Error: mistimed probe: %s varies at end of %s\n" // " but access occurred %s" whatNio( e->b->ancN, e->ss, fir->fi_off), evfTx( fir->fi_evf, 2), Top.isBegOf - ? strtprintf( (char *)MH_R0223, // "at BEGINNING of %s" + ? strtprintf( MH_R0223, // "at BEGINNING of %s" ivlTx(Top.isBegOf) ) // ivlTx: below - : strtprintf( (char *)MH_R0224) ); // use strtprintf to retreive msg to Tmpstr + : strtprintf( MH_R0224) ); // use strtprintf to retreive msg to Tmpstr //"neither at beginning nor end of an interval????" return RCBAD; } @@ -1311,7 +1309,7 @@ LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset che if (Top.isEndOf > minIvl) // if end of too short an interval (C_IVLCH_ increases for shorter times) { - *pms = strtprintf( (char *)MH_R0225, /* "Mistimed probe: %s\n" + *pms = strtprintf( MH_R0225, /* "Mistimed probe: %s\n" " varies at end of %s but accessed at end of %s.\n" " Possibly you combined it in an expression with a faster-varying datum." */ whatNio( e->b->ancN, e->ss, fir->fi_off), @@ -1327,13 +1325,13 @@ LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset che { if (ISUNSET(v)) { - *pms = strtprintf( (char *)MH_R0226, // "Internal error: Unset data for %s" + *pms = strtprintf( MH_R0226, // "Internal error: Unset data for %s" whatNio( e->b->ancN, e->ss, fir->fi_off) ); // describe probed mbr. exman.cpp return RCBAD; } else if (ISASING(v)) { - *pms = strtprintf( (char *)MH_R0232, // "%s probed while being autosized" + *pms = strtprintf( MH_R0232, // "%s probed while being autosized" whatNio( e->b->ancN, e->ss, fir->fi_off) ); // describe probed mbr. exman.cpp return RCBAD; } @@ -1342,8 +1340,8 @@ LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset che USI h = EXN(v); // extract expression number, exman.h macro. if (exInfo( h, NULL, NULL, &v)) // get value / if not valid expr # { - *pms = strtprintf( (char *)MH_R0227, // "Internal error: bad expression number %d found in %s" - (INT)h, whatNio( e->b->ancN, e->ss, fir->fi_off) ); + *pms = strtprintf( MH_R0227, // "Internal error: bad expression number %d found in %s" + h, whatNio( e->b->ancN, e->ss, fir->fi_off) ); return RCBAD; } if (ISNANDLE(v)) // if expr table contains nan, expr is not eval'd yet. @@ -1351,7 +1349,7 @@ LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset che /* DON'T evaluate it now from here without a way to reorder later evaluations, because stale values would be used on iterations after the first (unless constant). **** */ - *pms = strtprintf( (char *)MH_R0228, // "%s has not been evaluated yet." Also used below. + *pms = strtprintf( MH_R0228, // "%s has not been evaluated yet." Also used below. whatEx(h) ); /* whatEx: describes expression origin per exTab, exman.cpp. whatNio produces similar text in cases tried but suspect whatEx may be better in obscure cases. */ @@ -1366,7 +1364,7 @@ LOCAL RC FC cuRmGet( // access 4-byte record member, for cuEvalI, with unset che } // cuRmGet //============================================================================ // is it time to put cuEvalI ms and pBadH in file-globals? -LOCAL RC FC cuRm2Get( SI *pi, const char** pms, USI *pBadH) +LOCAL RC FC cuRm2Get( SI *pi, MSGORHANDLE* pms, USI *pBadH) // access 2-byte record member, for cuEvalI, with partial unset check @@ -1388,7 +1386,7 @@ LOCAL RC FC cuRm2Get( SI *pi, const char** pms, USI *pBadH) if ((fs & (FsSET | FsVAL))==FsSET) /* if "set", but not "value stored", assume is input field with uneval'd expression (if neither flag on, assume is run field -- bits not set.) */ { - *pms = strtprintf( (char *)MH_R0228, // "%s has not been evaluated yet." Also used above. + *pms = strtprintf( MH_R0228, // "%s has not been evaluated yet." Also used above. whatNio( e->b->ancN, e->ss, fir->fi_off) ); // describe probed mbr. exman.cpp if (pBadH) *pBadH = 0; // don't know handle of uneval'd expr for this variable (could search exTab)? @@ -1415,7 +1413,7 @@ LOCAL const char* FC ivlTx( IVLCH ivl) // text for interval. general use functi case C_IVLCH_S: return "subhour"; default: - return strtprintf( (char *)MH_R0229, ivl); // "Bad IVLCH value %d" + return strtprintf( MH_R0229, ivl); // "Bad IVLCH value %d" } } // ivlTx //============================================================================ diff --git a/src/cul.cpp b/src/cul.cpp index f3b63c413..fa145a0a9 100644 --- a/src/cul.cpp +++ b/src/cul.cpp @@ -267,7 +267,7 @@ LOCAL void FC xStkPt( void); LOCAL RC ganame( USI f, const char* what, CULSTR& str); LOCAL RC xpr( SI ty, USI fdTy, USI _evfOk, USI useCl, USI f, const char *what, NANDAT *p, USI *pGotTy, USI *pGotEvf ); LOCAL void FC termnIf( void); -LOCAL RC CDEC perNxE( char *ms, ...); +LOCAL RC CDEC perNxE( MSGORHANDLE ms, ...); LOCAL SI FC skip2end( SI lastCs, SI *pcs); LOCAL RC bFind( SI *pcs, XSTK** px, CULT **pc, int erOp ); LOCAL SI cultFind( CULT *c, CULT **pc); @@ -435,7 +435,7 @@ x trace = 1; // check arguments if (e==NULL) { - err( PWRN, (char *)MH_S0204); // "cul(): NULL RAT entry arg (e)" + err( PWRN, MH_S0204); // "cul(): NULL RAT entry arg (e)" return 1; } if (e->b->validate("cul.cpp:cul",WRN)) return 1; @@ -520,7 +520,7 @@ x trace = 1; rv = 1; if (rv < 1 || rv > 3) - err( PWRN, (char *)MH_S0206, (INT)rv); // display internal error msg + err( PWRN, MH_S0206, rv); // display internal error msg // "cul.cpp:cul(): Unexpected culComp return value %d" if (rv != 2) // unless recall expected cufClose(); // close file(s) (cutok.cpp) @@ -556,7 +556,7 @@ LOCAL SI FC culComp() /* compile cul commands from open input file // maxErrors: cuparse.cpp. Data init, accessible as $maxErrors. if (errCount() > maxErrors) { - pInfol( (char *)MH_S0207, (INT)maxErrors ); // "More than %d errors. Terminating session." + pInfol( MH_S0207, maxErrors ); // "More than %d errors. Terminating session." // issue "Info" message with line number, cuparse.cpp. // xSp = xStk is done by caller return 1; @@ -567,12 +567,12 @@ LOCAL SI FC culComp() /* compile cul commands from open input file { xSp = xStk; // restore for poss recall, eg cul(4) 1-12-91 if (nCmd) // if stmts seen in this culComp - perl( (char *)MH_S0208); // "'RUN' apparently missing" + perl( MH_S0208); // "'RUN' apparently missing" else // nCmd==0 if (culNRuns==0) // if no RUN seen in session - perl( (char *)MH_S0209); // "no commands in file" (does not get here if top table has any REQDs) + perl( MH_S0209); // "no commands in file" (does not get here if top table has any REQDs) else - perl( (char *)MH_S0210); /* "cul.cpp:cul() internal error: no statements in file since 'RUN',\n" + perl( MH_S0210); /* "cul.cpp:cul() internal error: no statements in file since 'RUN',\n" " yet cul() recalled" */ return 1; // end session, no (additional) RUN } @@ -609,7 +609,7 @@ LOCAL SI FC culComp() /* compile cul commands from open input file case CUTEOF: // physical end of file if (errCount()==0) // suppress this msg if other errs, (pp errors can stop file reading) - perl( (char *)MH_S0211); // "'$EOF' not found at end file" + perl( MH_S0211); // "'$EOF' not found at end file" /*lint -e516 fall thru */ case CUTDEOF: // '$eof': expected top-level terminator // assume enuf "end"'s to close any unclosed stmt groups @@ -673,13 +673,13 @@ LOCAL SI FC culComp() /* compile cul commands from open input file // continuing w same table wd make many spurious errors, so make fatal. if (tkIf(CUTEQ)) { - perNx(NULL); // pass input to verb or after ; + perNx( MSGORHANDLE()); // pass input to verb or after ; continue; // resume compile } return 1; // terminate session default: // unrecognized token type: error message - perNx( (char *)MH_S0212); // display msg, pass ';'. cuparse.cpp. + perNx( MH_S0212); // display msg, pass ';'. cuparse.cpp. // "Syntax error. Expecting a word: class name, member name, or verb.". wording?? continue; // continue compiling @@ -759,7 +759,7 @@ LOCAL SI FC culDo( // do one c u l command switch (cs) { default: - perNx( (char *)MH_S0213, (INT)cs); // "culDo() Internal error: unrecognized 'cs' %d" + perNx( MH_S0213, cs); // "culDo() Internal error: unrecognized 'cs' %d" return 1; // fatal error case RUN: // run (execute) command @@ -889,7 +889,7 @@ x exEvEvf( EVEOI, 0xffff); // evaluate end-input exprs, all use classes. er // explanatory message if any errors if (errCount()) // if any errors (just above or anytime during compilation) (pptok.cpp variable) - pInfol( (char *)MH_S0214 ); // "No run due to error(s) above" + pInfol( MH_S0214 ); // "No run due to error(s) above" // be sure input listing report is complete to here, and not farther -- in report file, it is divided by run. // intentionally done before eof check below. @@ -946,7 +946,7 @@ LOCAL SI FC fret( RC rc) // fix/fudge return code if (xSp >= xStk + sizeof(xStk)/sizeof(XSTK) - 1) { - perl( (char *)MH_S0215 ); /* "Context stack overflow: too much nesting in command tables. \n" + perl( MH_S0215 ); /* "Context stack overflow: too much nesting in command tables. \n" " Increase size of xStk[] in cul.cpp." */ return 1; // fatal error } @@ -1009,7 +1009,7 @@ LOCAL RC FC culENDER( // do c u l end cases // error message for top level explicit END if (xSp <= xStk) - return perNx( (char *)MH_S0216); // "Nothing to end (use $EOF at top level to terminate file)" + return perNx( MH_S0216); // "Nothing to end (use $EOF at top level to terminate file)" // look for and check optional basAnc record name after command @@ -1021,8 +1021,8 @@ LOCAL RC FC culENDER( // do c u l end cases if (ganame( 0, NULL, str)==RCOK) // get id, "text", or const string expr (uses xSp->c->id) { if (!((record*)xSp->e)->IsNameMatch( str)) // if name wrong - pWarnlc( (char *)MH_S0217, // warning message "%s name mismatch: '%s' vs '%s'" - (char *)c->id, str.CStr(), ((record*)(xSp->e))->Name()); + pWarnlc( MH_S0217, // warning message "%s name mismatch: '%s' vs '%s'" + c->id, str.CStr(), ((record*)(xSp->e))->Name()); } // else: continue on error. ganame assumed to have perNx'd. } @@ -1126,7 +1126,7 @@ LOCAL RC FC culRATE( // do RATE cult entry c->IFLAGS |= BEEN_SET; // say this command seen } if (c->IFLAGS & (ITFP|PRFP)) - return perNxE( (char *)MH_S0220); // "cul.cpp:culRATE Internal error: bad table: RATE entry contains fcn not cult ptr" + return perNxE( MH_S0220); // "cul.cpp:culRATE Internal error: bad table: RATE entry contains fcn not cult ptr" // more appropropriate err fcn? // get file name index / line # here to put in basAnc record header @@ -1144,12 +1144,12 @@ LOCAL RC FC culRATE( // do RATE cult entry if (defTy) // deftype rq's name { toke(); // to position ^ in errmsg - return perNxE( (char *)MH_S0221, (char *)c->id); // err msg "%s type name required", skip group (?) + return perNxE( MH_S0221, c->id); // err msg "%s type name required", skip group (?) } if (c->f & NM_RQD) // if name required { toke(); // position errMsg ^ - return perNxE( (char *)MH_S0222, (char *)c->id); // err msg "%s name required", skip group (?) + return perNxE( MH_S0222, c->id); // err msg "%s name required", skip group (?) } } else // terminator not next @@ -1173,7 +1173,7 @@ LOCAL RC FC culRATE( // do RATE cult entry copy++; // with likeName, indicates copy if (c->f & NO_LITY) // note 1-12-91 NO_LITY unused, but keep as might want it. - return perNxE( (char *)MH_S0225, cuToktx, (char *)c->id); // "'%s' not permitted with '%s'" ALSO USED JUST BELOW + return perNxE( MH_S0225, cuToktx, c->id); // "'%s' not permitted with '%s'" ALSO USED JUST BELOW // get Identifier, Quoted text, or constant string eXpr for record name to like/copy if ( ganame( 0, // disallow "all" and "sum" @@ -1190,7 +1190,7 @@ LOCAL RC FC culRATE( // do RATE cult entry if (!alter && tkIf(CUTTYPE)) { if (c->f & NO_LITY) // note 1-12-91 NO_LITY unused, but keep as might want it. - return perNxE( (char *)MH_S0225, cuToktx, (char *)c->id); // "'%s' not permitted with '%s'" SECOND USE + return perNxE( MH_S0225, cuToktx, c->id); // "'%s' not permitted with '%s'" SECOND USE // >>> error checks for not USETYPEable can go here @@ -1204,7 +1204,7 @@ LOCAL RC FC culRATE( // do RATE cult entry xprD++; // say terminator already gotten if (likeName.IsSet() || tkIf2(CUTLIKE, CUTCOPY)) // if LIKE b4 or after - return perNxE( (char *)MH_S0226, (char *)c->id ); // "Can't use LIKE or COPY with USETYPE in same %s" + return perNxE( MH_S0226, c->id ); // "Can't use LIKE or COPY with USETYPE in same %s" } // get optional terminator @@ -1233,7 +1233,7 @@ LOCAL RC FC culRATE( // do RATE cult entry // if owner ti can be set != xSp->i, then check again at END.<<<< perlc( // errMsg, show input line and ^. cuparse.cpp. scWrapIf( // strtcat w conditional \n - strtprintf( (char *)MH_S0227, (char *)c->id, name.CStr() ), // "duplicate %s name '%s' in " + strtprintf( MH_S0227, c->id, name.CStr() ), // "duplicate %s name '%s' in " xSp->b->rec(xSp->i).objIdTx( 1 ), // owner class & obj name, etc "\n "), getCpl()); // \n between if wd be longer // and continue here (?) (perlc prevents RUN) @@ -1243,7 +1243,7 @@ LOCAL RC FC culRATE( // do RATE cult entry : b ? b->findRecByNm1( name, NULL, NULL) // else the basAnc itself : RCBAD )==RCOK ) // NULL b ??: unsure while converting code, sometime if possible // if any record with same name found found - perlc( (char *)MH_S0228, (char *)c->id, defTy ? " type" : "", name.CStr()); // "duplicate %s%s name '%s'" + perlc( MH_S0228, c->id, defTy ? " type" : "", name.CStr()); // "duplicate %s%s name '%s'" // and continue here (?) (perlc prevents RUN) // if necessary to avoid (future) ambiguity during defTy, also search regular table (b). } @@ -1283,7 +1283,7 @@ LOCAL RC FC culRATE( // do RATE cult entry { record *typeE; if (b->tyB->findRecByNm1( typeName, NULL, /*VV*/ &typeE) != RCOK) - perlc( (char *)MH_S0229, (char *)c->id, typeName); // "%s type '%s' not found" + perlc( MH_S0229, c->id, typeName); // "%s type '%s' not found" // and continue here with raw record (perlc prevents RUN) else // found { @@ -1580,7 +1580,7 @@ LOCAL RC FC clearRat( CULT *c) if (c->IFLAGS & (ITFP|PRFP) || !c->p2) { - per( (char *)MH_S0200); // "cul.cpp:clearRat internal error: bad tables: RATE entry without CULT ptr" + per( MH_S0200); // "cul.cpp:clearRat internal error: bad tables: RATE entry without CULT ptr" return RCFATAL; } @@ -1589,7 +1589,7 @@ LOCAL RC FC clearRat( CULT *c) // check for full xStk. Keeps an extra space to match test in culDo. if (xSp >= xStk + sizeof(xStk)/sizeof(XSTK) - 1 - 1) { - perl( (char *)MH_S0230); /* "cul.cpp:clearRat Internal error: Too much nesting in tables: \n" + perl( MH_S0230); /* "cul.cpp:clearRat Internal error: Too much nesting in tables: \n" " Increase size of context stack xStk[] in cul.cpp." */ return RCFATAL; // fatal error } @@ -1760,13 +1760,13 @@ LOCAL RC FC culAUTOSZ() // do "AutoSize" non-table command CSE_E( vFind( DAT) ) /* get DAT verb from input stream, look it up, msg if not found, do implicit ENDs, set xSp->c. */ if (!(xSp->c->f & AS_OK)) // error if member not flagged as autosizable in CULT table - return perNx( (char *)MH_S0280, cuToktx); // "'%s' cannot be AUTOSIZEd" + return perNx( MH_S0280, cuToktx); // "'%s' cannot be AUTOSIZEd" termnIf(); // get optional terminating ; // error if previously set if (xSp->c->IFLAGS & BEEN_SET) - return perNx( (char *)MH_S0281, // "Invalid duplicate 'AUTOSIZE %s' or '%s =' command" + return perNx( MH_S0281, // "Invalid duplicate 'AUTOSIZE %s' or '%s =' command" (char *)xSp->c->id, (char *)xSp->c->id ); // point at the member and its flags byte. local. @@ -2067,13 +2067,13 @@ LOCAL RC culDAT() // do cul DAT case per xSp // get '=' next if (tkIf(CUTEQ)==0) // if not = next - return perNx( (char *)MH_S0231); // "'=' expected" + return perNx( MH_S0231); // "'=' expected" // initial checks CULT *c = xSp->c; // pointer to tbl entry for cmd to compile if (c->IFLAGS & BEEN_SET) - return perNx( (char *)MH_S0232, // "Invalid duplicate '%s =' or 'AUTOSIZE %s' command" - (char *)c->id, (char *)c->id); + return perNx( MH_S0232, // "Invalid duplicate '%s =' or 'AUTOSIZE %s' command" + c->id, c->id); /* NOTE THAT current token is now neither beginning nor end of statement, so perNx (eg in datPt) won't skip next statement, yet @@ -2100,7 +2100,7 @@ x UCH *fsj = xSp->fs; // fetch field status byte ptr. Incremented for suc // error if FROZEN. for ARRAY, 1st element FsFROZ bit used for all elements. if (xSp->fs[xSp->j] & FsFROZ) - return perNx( (char *)MH_S0233, (char *)c->id ); // "'%s' cannot be specified here -- previously frozen" + return perNx( MH_S0233, c->id ); // "'%s' cannot be specified here -- previously frozen" USI f = c->f; // fetch flags ALL_OK etc: may be altered after 1st array element @@ -2120,7 +2120,7 @@ x UCH *fsj = xSp->fs; // fetch field status byte ptr. Incremented for suc USI gotEvf; default: - return perNx( (char *)MH_S0234, (INT)c->ty, (char *)c->id, c ); //"cul.cpp:culDAT: Bad .ty %d in CULT for '%s' at %p" + return perNx( MH_S0234, c->ty, c->id, c ); //"cul.cpp:culDAT: Bad .ty %d in CULT for '%s' at %p" case TYREF: { // deferred-resolution reference to basAnc record, or "all"/"sum" per flag bits @@ -2226,8 +2226,8 @@ x UCH *fsj = xSp->fs; // fetch field status byte ptr. Incremented for suc if (ch == 0) // if end string, not found { xSp->fs[xSp->j] |= FsERR; // say ermsg'd for field: suppress "no ___ given". 12-91. - return perNx((char*)MH_S0235, // "Value '%s' for '%s' not one of %s" - p, (char*)c->id, c->b); // errMsg, skip to nxt stmt, cuparse.cpp + return perNx(MH_S0235, // "Value '%s' for '%s' not one of %s" + p, c->id, c->b); // errMsg, skip to nxt stmt, cuparse.cpp } if (isspaceW(ch)) { @@ -2277,7 +2277,7 @@ x UCH *fsj = xSp->fs; // fetch field status byte ptr. Incremented for suc if (ratLuCtx((BP)c->b, refd, c->id, &e) != RCOK) // local. if not found... { xSp->fs[xSp->j] |= FsERR; // say msg issued for field (eg suppress "no ___ given" if RQD) - return perNx(NULL); // skip input to nxt stmt (ratLuCtx issued message). + return perNx( MSGORHANDLE()); // skip input to nxt stmt (ratLuCtx issued message). } *(SI*)xSp->p = e->ss; // found. Store subscript. @@ -2287,8 +2287,8 @@ x UCH *fsj = xSp->fs; // fetch field status byte ptr. Incremented for suc // issue warning if in statement block for another entry of same basAnc for (const XSTK* x = xStk; x < xSp; x++) if ((x->cs == 3 || x->cs == 4) && x->b == c->b && x->e != e) - pWarnlc((char*)MH_S0236, // "Statement says %s '%s', but it is \n" - (char*)c->id, e->Name(), x->e->classObjTx()); // " in statement group for %s." + pWarnlc( MH_S0236, // "Statement says %s '%s', but it is \n" + c->id, e->Name(), x->e->classObjTx()); // " in statement group for %s." } goto setFsVAL; // go say 'value stored' in fld status bytes @@ -2339,7 +2339,7 @@ x break; #endif f &= ~ALL_OK; // "all" and "all_but" (also sum??) only valid at start of list if (xSp->j >= xSp->arSz-1) // check array for full; leave room for terminator - return perNx( (char *)MH_S0237, INT(xSp->arSz-1), (char *)c->id); // "Can't give more than %d values for '%s'" + return perNx( MH_S0237, xSp->arSz-1, c->id); // "Can't give more than %d values for '%s'" } // terminate array input @@ -2379,13 +2379,13 @@ LOCAL RC FC datPt() // point to DAT and KDAT data storage per xSp->c, e, fs0 { ULI arSz = (ULI)c->p2; // fetch array size from multi-use member. keep 32 bits til checked. if (c->f & (ITFP|PRFP)) // this imply other .p2 uses - return perNx( (char *)MH_S0238); /* "Internal error: cul.cpp:datPt(): " + return perNx( MH_S0238); /* "Internal error: cul.cpp:datPt(): " "bad CULT table entry: flags incompatible with ARRAY flag" */ if (arSz <= 0) - return perNx( (char *)MH_S0239 ); /* "Internal error: cul.cpp:datPt(): " + return perNx( MH_S0239 ); /* "Internal error: cul.cpp:datPt(): " "bad CULT table entry: ARRAY flag, but 0 size in .p2" */ if (arSz > 128) // arbitrary limit to catch pointers; increase as needed - return perNx( (char *)MH_S0240, arSz); /* "Internal error: cul.cpp:datPt(): " + return perNx( MH_S0240, arSz); /* "Internal error: cul.cpp:datPt(): " "bad CULT table entry: ARRAY size 0x%lx in p2 is too big" */ xSp->arSz = (USI)arSz; // ok, truncate and store } @@ -2478,12 +2478,12 @@ x } goto badTynDt; // valid TY's for which valid uses don't get to this switch default: - return perNx( (char *)MH_S0241, // "cul.cpp:datPt(): Unrecognized CULT.ty %d in entry '%s' at %p" + return perNx( MH_S0241, // "cul.cpp:datPt(): Unrecognized CULT.ty %d in entry '%s' at %p" ty, c->id, c ); } if (dt != dtMustBe) // if dt not consistent with ty badTynDt: - return perNx( (char *)MH_S0242, ty, dt, c->id, c ); + return perNx( MH_S0242, ty, dt, c->id, c ); // "cul.cpp:datPt(): Bad ty (0x%x) / dtype (0x%x) combination in entry '%s' at %p" } xSp->sz = sz; // ok, store size. @@ -2492,7 +2492,7 @@ x } const DTTAB& dttab = GetDttab(dt); if (dttab.size != sz) // get field's data type's size using srd.h fcn 3-1-94 - return perNx( (char *)MH_S0243, // "Internal error: cul.cpp:datPt(): data size inconsistency: + return perNx( MH_S0243, // "Internal error: cul.cpp:datPt(): data size inconsistency: // size of cul type 0x%x is %d, but size of field data type 0x%x is %d" ty, sz, dt, dttab.size ); @@ -2536,8 +2536,8 @@ LOCAL RC FC ckiCults() // check / initialize CULTs 1-21-91 && !(cc->cs==RATE && c->cs==RATE // ok if RATEs w same cults && cc->CULTP2==c->CULTP2) ) // ...eg print in zone & top err( PWRN, // display internal error msg - (char *)MH_S0244, // "Ambiguity in tables: '%s' is used in '%s' and also '%s'" - (char *)c->id, (char *)(xSp-1)->c->id, + MH_S0244, // "Ambiguity in tables: '%s' is used in '%s' and also '%s'" + c->id, (char *)(xSp-1)->c->id, x > xStk ? (char *)(x-1)->c->id : "top" ); // continue at ambiguity: allow use anyway. @@ -2564,7 +2564,7 @@ LOCAL void FC finalClear() // clear input data, for cul(4). if (xSp != xStk) // nxRat etc work as desired here only at top level. err( PWRN, // display internal error msg - (char *)MH_S0245, // "cul.cpp:finalClear() called with xSp %p not top (%p)" + MH_S0245, // "cul.cpp:finalClear() called with xSp %p not top (%p)" (void *)xSp, (void *)xStk ); // casts are to make far. // free all DM data: TYSTR strings, add any other general DM data types @@ -2650,7 +2650,7 @@ LOCAL void FC xStkPt() // repoint basAnc-record-based items in context stack { default: err( PWRN, // display internal error msg - (char *)MH_S0246, (INT)x->cs ); // "cul.cpp:xStkPt(): bad xStk->cs value %d" + MH_S0246, x->cs ); // "cul.cpp:xStkPt(): bad xStk->cs value %d" break; case 4: // basAnc record for DEFTYPE @@ -2699,11 +2699,11 @@ LOCAL RC ganame( for (int i = 0; i < len; i++) if ( p[i] < ' ') // disallow control chars if (p[i] > 0) // allow 129-255 even if compiler extends sign - return perNx( (char *)MH_S0247, p[i]); // "Illegal character 0x%x in name" + return perNx( MH_S0247, p[i]); // "Illegal character 0x%x in name" // if caret not useful, consider adding to errMsg, before the word "name": "what ? what : xSp->c->id". // require non-0 name length if (len==0) - return perNx( (char *)MH_S0248); // "Zero-length name not allowed" + return perNx( MH_S0248); // "Zero-length name not allowed" // if caret not clear enuf also show what name is of. } return rc; // RCOK, RC_SUM etc per f, error code. Also error returns above. @@ -2788,7 +2788,7 @@ LOCAL RC xpr( // our local expression compiler interface / checker if ( tokTy==CUTCOM && !(f & ARRAY) // comma ok if 'array' flag, 3-92 || tokTy==CUTRPR || tokTy==CUTRB || tokTy==CUTDEFA ) - perNx( (char *)MH_S0249 ); // issue msg, scan to eof, verb, or after ';'. + perNx( MH_S0249 ); // issue msg, scan to eof, verb, or after ';'. // "expected ';' (or class name, member name, or verb)" // check returned value for reserved words 'sum' and 'all' 1-92. rc=RCOK here. @@ -2799,11 +2799,11 @@ LOCAL RC xpr( // our local expression compiler interface / checker if (!cs.IsNANDLE()) // if constant, not expression, found (don't allow exprs and sum/all in same call!) { const char* p = cs.CStr(); if (!_stricmp(p, "sum")) - rc = (f & SUM_OK) ? RC_SUM : perNx((char*)MH_S0250); // "'SUM' cannot be used here" + rc = (f & SUM_OK) ? RC_SUM : perNx(MH_S0250); // "'SUM' cannot be used here" else if (!_stricmp(p, "all")) - rc = (f & ALL_OK) ? RC_ALL : perNx((char*)MH_S0251); // "'ALL' cannot be used here" + rc = (f & ALL_OK) ? RC_ALL : perNx(MH_S0251); // "'ALL' cannot be used here" else if (!_stricmp(p, "all_but")) - rc = (f & ALL_OK && f & ARRAY) ? RC_ALLBUT : perNx((char*)MH_S0252); // "'ALL_BUT' cannot be used here" + rc = (f & ALL_OK && f & ARRAY) ? RC_ALLBUT : perNx(MH_S0252); // "'ALL_BUT' cannot be used here" if (rc) // if sum or all (whether error or ok) cs.Release(); // discard the string } @@ -2835,8 +2835,8 @@ LOCAL void FC termnIf() issue message and skip past next ; or to verb or eof */ perNx( // msg and pass input to ; or b4 verb or eof (cuparse.cpp) tokTy==CUTID // unidentified word gets different msg text - ? (char *)MH_S0254 // "Misspelled word? Expected class name, member name, command, or ';'." - : (char *)MH_S0255 ); // "expected ';' (or class name, member name, or command)" + ? MH_S0254 // "Misspelled word? Expected class name, member name, command, or ';'." + : MH_S0255 ); // "expected ';' (or class name, member name, or command)" // 2 additional returns above } // termnIf //=========================================================================== @@ -2877,7 +2877,7 @@ LOCAL RC bFind( if (cs) // reg verb (cs==0) already gotten if (tkIf(CUTVRB)==0) // all class & member names are "verbs" { - ms = strtprintf( (char *)MH_S0256, whatDoTx); // "Expected name of class to %s" + ms = strtprintf( MH_S0256, whatDoTx); // "Expected name of class to %s" goto badToWhat; } @@ -2886,7 +2886,7 @@ LOCAL RC bFind( switch (cs) // cases goto found with x, c, cs set to return. { default: - perlc( (char *)MH_S0257, (INT)cs ); // "Internal error in cul.cpp:bFind() call: bad cs %d" + perlc( MH_S0257, cs ); // "Internal error in cul.cpp:bFind() call: bad cs %d" return RCFATAL; @@ -2909,7 +2909,7 @@ LOCAL RC bFind( else // not in tables invoked in DEFTYPE if (deftyFind( x->cult, &c)) // search given & nestED tbls (recursive; below) goto found; // x, c set. - ms = strtprintf( (char *)MH_S0258, cuToktx); // "Can't define types for '%s'" + ms = strtprintf( MH_S0258, cuToktx); // "Can't define types for '%s'" goto badToWhat; @@ -2921,7 +2921,7 @@ LOCAL RC bFind( for ( ; x >= xStk; x--) // loop curr & callING tables, outward if (csFind( x->cult, RATE, &c)) // search table / if found goto found; // x, c set. - ms = strtprintf( (char *)MH_S0259, cuToktx, whatDoTx); // "'%s' is not %s-able (here)" ALSO USED in vFind below + ms = strtprintf( MH_S0259, cuToktx, whatDoTx); // "'%s' is not %s-able (here)" ALSO USED in vFind below badToWhat: // Error re class name after DEFTY/ALTER, 'ms' set if (erOp != IGN) // suppress messages for skip2end() @@ -2949,9 +2949,9 @@ LOCAL RC bFind( } // unrecognized plain verb if (erOp != IGN) - perlc( (char *)MH_S0260, cuToktx ); // "'%s' cannot be given here" + perlc( MH_S0260, cuToktx ); // "'%s' cannot be given here" if (tkIf(CUTEQ)) // if = next: setting a member - return perNx(NULL); // skip past ; and continue compile + return perNx(MSGORHANDLE()); // skip past ; and continue compile else // no = next, may be context change return RCFATAL; /* confused, so make fatal: don't know if starts stmt block (requiring skip2end -- and don't have CULT for skipping anyway). */ @@ -3030,7 +3030,7 @@ LOCAL RC FC vFind( SI cs) // next token is name of member or object to require/freeze/[alter/]delete if (tkIf(CUTVRB)==0) // all member names are "verbs" - return perNx( (char *)MH_S0261, id); // "Expected name of member to %s" + return perNx( MH_S0261, id); // "Expected name of member to %s" // search for a DAT entry for member (cuTokTx). // Look in current table, then, if not found, @@ -3045,7 +3045,7 @@ LOCAL RC FC vFind( SI cs) } // not found - return perNx( (char *)MH_S0259, cuToktx, id); // "'%s' is not %s-able (here)" SECOND USE -- also used in bFind + return perNx( MH_S0259, cuToktx, id); // "'%s' is not %s-able (here)" SECOND USE -- also used in bFind } // vFind //=========================================================================== LOCAL SI csFind( // special CULT search for Freeze/Require @@ -3071,7 +3071,7 @@ LOCAL SI csFind( // special CULT search for Freeze/Require } // csFind //=========================================================================== -LOCAL RC CDEC perNxE( char *ms, ...) +LOCAL RC CDEC perNxE( MSGORHANDLE ms, ...) /* parse error message and SKIP STATEMENT BLOCK: @@ -3173,7 +3173,7 @@ LOCAL SI FC skip2end( case RCSKIP2END: // (unexpected) case RCFATAL: // irrecoverable error #ifdef DEBUG2 //cnglob.h. Message mainly helps debug skip2end; otherwise appropriate to exit with no addl msg. - perlc( (char *)MH_S0262, cuToktx ); // "Confused at '%s' after error(s) above."" Terminating session." + perlc( MH_S0262, cuToktx ); // "Confused at '%s' after error(s) above."" Terminating session." #endif goto retBad; // fatal error return @@ -3224,7 +3224,7 @@ LOCAL SI FC skip2end( case END: case ENDER: // stmt group enders - perNx(NULL); // skip rest of cmd, ';' + perNx(MSGORHANDLE()); // skip rest of cmd, ';' // >>>> check perNx re DEFTY and other new tokens. // pop an xStk level, return or continue scan if (xSp->cs==4) // if xStk level was for DEFTY @@ -3375,9 +3375,9 @@ LOCAL RC FC cuf( // call CULT user fcn if any, handle err ret if (rc != RCOK) // if user fcn returned error { - // printf( " (cuf: fcn returned %d) \n", (INT)rc); // debug aid + // printf( " (cuf: fcn returned %d) \n", rc); // debug aid if (skie) // if input skip on error requested - perNx(NULL); // skip rest of this input statement + perNx(MSGORHANDLE()); // skip rest of this input statement if (errCount() <= errCountSave) // if fcn ++'d error count, don't repeat incrErrCount(); // incr global err count (in rmkerr.cpp): tested by RUN to stop execution } @@ -3432,11 +3432,11 @@ LOCAL RC FC msgMissReq() watIn = xSp->e->classObjTx(); // 'zone "Z1"', 'sgdist', etc, below. // message text for member assignment or for RATE group - const char* ms = c->cs==DAT ? (char *)MH_S0263 // "No %s given in %s" - : (char *)MH_S0264; // "No %s in %s" + MSGORHANDLE ms = c->cs==DAT ? MH_S0263 // "No %s given in %s" + : MH_S0264; // "No %s in %s" // issue message with name of item and what it is missing from. - rc |= perlc( ms, (char *)c->id, watIn ); /* [no caret:] item missing somewhere in preceding statement group. + rc |= perlc( ms, c->id, watIn ); /* [no caret:] item missing somewhere in preceding statement group. Line is that of ENDER, or eof if top level. */ // add perl( feature to not repeat preamble of multiple error messages for same file line? } @@ -3462,7 +3462,7 @@ LOCAL RC ratPutTy( record *e, CULT *c) // require record to be LAST in basAnc -- else have no way to delete ( <<<< believe no longer true 1-92, fix if need found) if (e->ss != b->n) - return err( PWRN, (char *)MH_S0266); // "cul.cpp:ratPutTy(): basAnc record to be made a TYPE must be last" + return err( PWRN, MH_S0266); // "cul.cpp:ratPutTy(): basAnc record to be made a TYPE must be last" // if this basAnc does not already have secondary basAnc for types, make one CSE_E(ratTyR(b)) // below. return if error. @@ -3602,7 +3602,7 @@ LOCAL RC rateDuper( adjOwTi( ownB, c, srcOti+1, -1); // fix ownTi in basAnc records owned by entries whose subscr was changed in squeeze else { - err( PWRN, (char *)MH_S0201); // display internal error msg + err( PWRN, MH_S0201); // display internal error msg /* "cul.cpp:rateDuper(): move or delete request without CULT:\n" " can't adjust ownTi in owned RAT entries" */ return RCFATAL; // 1-8-91 @@ -3654,7 +3654,7 @@ LOCAL RC FC ratTyR( BP b) // if basAnc does not have secondary basAnc for types int flags = RFTYS | RFNOEX; // say is "types" anchor, disable expression expansion - char *_what = strsave( strtcat( (char *)b->what, " type", NULL) ); // form record type name + char *_what = strsave( strtcat( b->what, " type", NULL) ); // form record type name if (!_what) // if failed (strsave issued msg, right?) return RCFATAL; // out of memory: end session. BP _ownB = 0; @@ -3672,7 +3672,7 @@ LOCAL RC FC ratTyR( BP b) // if basAnc does not have secondary basAnc for types { // (known inconsistency: out of memory messages from // memfullerr: ; // ancrec, dmpak, etc do not appear in input listing.) - cuEr( 0, (char *)MH_S0267); // display message and echo in input listing 1-8-92. + cuEr( 0, MH_S0267); // display message and echo in input listing 1-8-92. // "Out of near heap memory (cul:ratTyr)" return RCFATAL; // out of memory: end session. } @@ -3889,7 +3889,7 @@ LOCAL SI FC nxRat( // first/next basAnc in current+nested tables ((CULT *)xSp->c->CULTP2)->IFLAGS |= BEEN_HERE; // say done. CAUTION: ratCultO may clear this bit // where rescan desired. Coordinate changes. if (xSp >= xStk + sizeof(xStk)/sizeof(XSTK) - 1 - 1) - perl((char *)MH_S0270); //"cul.cpp:nxRat: Too much nesting in tables: Increase size of context stack xStk[] in cul.cpp" + perl(MH_S0270); //"cul.cpp:nxRat: Too much nesting in tables: Increase size of context stack xStk[] in cul.cpp" else // room for another xStk entry { ++xSp; // push xStk @@ -4049,7 +4049,7 @@ LOCAL RC ratLuDefO( // look up basAnc record by name, resolving ambiguities usin { rc = b->findRecByNm1( name, NULL, /*VV*/ &e); // find first record with given name, ancrec.cpp if (rc) - ms = strtprintf( (char *)MH_S0278, what, name); // format ms "%s '%s' not found" to Tmpstr. Also used below. + ms = strtprintf( MH_S0278, what, name); // format ms "%s '%s' not found" to Tmpstr. Also used below. } else { @@ -4057,11 +4057,11 @@ LOCAL RC ratLuDefO( // look up basAnc record by name, resolving ambiguities usin if (rc) // (RCBAD not found, RCBAD2 ambiguous 1-92) { if (e) // if bad and entrie(s) returned, is ambiguous match - ms = strtprintf( (char *)MH_S0279, // "ambiguous name: \n" + ms = strtprintf( MH_S0279, // "ambiguous name: \n" what, name, e->whatIn(), // " %s '%s' exists in %s\n" e2->whatIn() ); // " and also in %s" */ else - ms = strtprintf( (char *)MH_S0278, what, name); // "%s '%s' not found" also used above + ms = strtprintf( MH_S0278, what, name); // "%s '%s' not found" also used above } } if (ms) // if have unissued error message (rc also set) @@ -4119,7 +4119,7 @@ LOCAL void FC ratCultO( void) BP ownB = (xSp-1)->b; // owner here is embedding basAnc if (b->ownB != 0 // if owner already set && b->ownB != ownB ) // to another owner - per( (char *)MH_S0202, // error message, cuparse.cpp + per( MH_S0202, // error message, cuparse.cpp //"cul.cpp:ratCultO: internal error: bad tables: \n" //" '%s' rat at %p is 'owned' by '%s' rat at %p and also '%s' rat at %p", b->what, b, b->ownB->what, b->ownB, ownB->what, ownB ); @@ -4358,7 +4358,7 @@ LOCAL void FC drefRes() continue; // .. (yet the dref entries ARE needed, to propogate at USETYPE) record* e = b->GetAtSafe( drfp->i); // record location if (!e) - { per( (char *)MH_S0203, b->what, (INT)drfp->i ); // "cul.cpp:drefRes() internal error: bad %s RAT index %d" + { per( MH_S0203, b->what, drfp->i ); // "cul.cpp:drefRes() internal error: bad %s RAT index %d" continue; } TI* p = (TI *)((char *)e // field location: where to store reference subscript: record location, @@ -4474,12 +4474,12 @@ LOCAL void FC clrBeenHeres( CULT *c) // primarily for use from check-functions and run code, eg in cncult.cpp. // Also error functions in cuparse.cpp and cutok.cpp are called directly. */ //----------------------------------------------------------------------------- -RC CDEC record::ooer( int fn, const char* message, ... ) // addl args like printf +RC CDEC record::ooer( int fn, MSGORHANDLE message, ... ) // addl args like printf { va_list ap; va_start( ap, message); return ooerV( fn, message, ap); } // record::ooer //----------------------------------------------------------------------------- -RC CDEC record::ooerV( int fn, const char* message, va_list ap) +RC CDEC record::ooerV( int fn, MSGORHANDLE message, va_list ap) // error message ONCE pertaining to a member (fn) of an object (rat record r): // sets field's FsERR status bit and issues message (see oer, next), or nop's if bit already set. 12-91. @@ -4497,12 +4497,12 @@ RC CDEC record::ooerV( int fn, const char* message, va_list ap) return rc; // RCBAD } // record::ooerV //----------------------------------------------------------------------------- -RC CDEC record::ooer( int fn1, int fn2, const char* message, ... ) +RC CDEC record::ooer2( int fn1, int fn2, MSGORHANDLE message, ... ) { va_list ap; va_start( ap, message); - return ooerV( fn1, fn2, message, ap); -} // record::ooer + return ooer2V( fn1, fn2, message, ap); +} // record::ooer2 //----------------------------------------------------------------------------- -RC CDEC record::ooerV( int fn1, int fn2, const char* message, va_list ap) +RC CDEC record::ooer2V( int fn1, int fn2, MSGORHANDLE message, va_list ap) // error message ONCE pertaining to TWO members (fn1, fn2) of an object (rat record r): // sets fields' FsERR status bits and issues message (see oer, next), or nop's if either bit already set. 3-92. @@ -4524,9 +4524,9 @@ RC CDEC record::ooerV( int fn1, int fn2, const char* message, va_list ap) fStat( fn2) |= FsERR; // if field # 2 given, say have issued an error message about field } return rc; // RCBAD -} // record::ooerV +} // record::ooer2V //----------------------------------------------------------------------------- -RC CDEC record::oer( const char* message, ... ) const // addl args like printf +RC CDEC record::oer( MSGORHANDLE message, ... ) const // addl args like printf // error message pertaining to an object // puts eg 'surface "fum" of zone "north"' in front of caller's message; // shows input file line text, caret, file name, line in INPUT phase; @@ -4539,7 +4539,7 @@ RC CDEC record::oer( const char* message, ... ) const // addl args like printf return oerI( 1, 1, 0, message, ap); } // oer //----------------------------------------------------------------------------- -RC CDEC record::oWarn( const char* message, ... ) const +RC CDEC record::oWarn( MSGORHANDLE message, ... ) const // warning message pertaining to an object (rat record r) // returns RCOK { @@ -4548,7 +4548,7 @@ RC CDEC record::oWarn( const char* message, ... ) const return oerI( 1, 1, 1, message, ap); } // oWarn //----------------------------------------------------------------------------- -RC CDEC record::oInfo( const char *message, ... ) const +RC CDEC record::oInfo( MSGORHANDLE message, ... ) const // info message pertaining to an object (rat record r) // returns RCOK { @@ -4557,7 +4557,7 @@ RC CDEC record::oInfo( const char *message, ... ) const return oerI( 1, 1, 2, message, ap); } // oInfo //----------------------------------------------------------------------------- -RC CDEC record::orer(const char* message, ...) const // addl args like printf +RC CDEC record::orer(MSGORHANDLE message, ...) const // addl args like printf // runtime error message pertaining to an object // puts eg 'surface "fum" of zone "north"' in front of caller's message; // shows date / time of simulation @@ -4568,7 +4568,7 @@ RC CDEC record::orer(const char* message, ...) const // addl args like printf return oerI(1, 0, 0 | RTMSG, message, ap); } // orer //----------------------------------------------------------------------------- -RC CDEC record::orWarn(const char* message, ...) const +RC CDEC record::orWarn(MSGORHANDLE message, ...) const // runtime warning message pertaining to an object (rat record r) // returns RCOK { @@ -4577,7 +4577,7 @@ RC CDEC record::orWarn(const char* message, ...) const return oerI(1, 0, 1 | RTMSG, message, ap); } // orWarn //----------------------------------------------------------------------------- -RC CDEC record::orInfo(const char *message, ...) const +RC CDEC record::orInfo(MSGORHANDLE message, ...) const // info message pertaining to an object (rat record r) // returns RCOK { @@ -4588,7 +4588,7 @@ RC CDEC record::orInfo(const char *message, ...) const //----------------------------------------------------------------------------- RC record::orMsg( // flexible object-specific msg int erOp, // - const char *message, ... ) const + MSGORHANDLE message, ... ) const // puts eg 'surface "fum" of zone "north"' in front of caller's message; // optionally shows input file line text, caret, file name, line in INPUT phase; @@ -4618,7 +4618,7 @@ RC record::oerI( // object error message, inner function int isWarn, // 1 for Warning, 2 for Info, 0 for Error // + RTMSG = report as runtime error (via rerIV) // shows date/time in simulation - const char* fmt, // body of error message (a la printf format)(CSE message handle ok) + MSGORHANDLE fmt, // body of error message (a la printf format)(CSE message handle ok) va_list ap) const // ptr to argument ptrs if any (as for vprintf) // puts object identification before message; @@ -4632,7 +4632,7 @@ RC record::oerI( // object error message, inner function // verify basAnc record arg if (b->rt != rt) - err( PWRN, (char *)MH_S0272); // display internal error msg + err( PWRN, MH_S0272); // display internal error msg // "*** cul.cpp:oerI(); probable non-RAT record arg ***" // determine file info to show @@ -4693,7 +4693,7 @@ const char* FC culMbrId( BP b, unsigned int fn) // return record field name from #if 0 //2-95 check only on failure, below, so can be used for members of the nested cult for nested-object error messages. x if (xSp != xStk) // xnxC, nxRat etc work as desired here only at top level. x err( PWRN, // display internal error msg -x (char *)MH_S0275, // "cul.cpp:culMbrId called with xSp %p not top (%p)" +x MH_S0275, // "cul.cpp:culMbrId called with xSp %p not top (%p)" x (void *)xSp, (void *)xStk ); // casts are to make far. #endif @@ -4722,7 +4722,7 @@ x xSp->b->rt==b->rt // (match rt not b so run basAncs, types basAncs work) if (!tx) // if first match tx = c->id; // remember it else if (_stricmp( tx, c->id)) // additional match: ignore if same name - return strtprintf( (char *)MH_S0276, tx, (char *)c->id); + return strtprintf( MH_S0276, tx, c->id); // "[%s or %s: table ambiguity: recode this error message to not use cul.cpp:culMbrId]" if (tx) // if name found @@ -4734,10 +4734,10 @@ x xSp->b->rt==b->rt // (match rt not b so run basAncs, types basAncs work) if (xSp != xStk) // xnxC, nxRat etc work as desired here only at top level. err( PWRN, // display internal error msg - (char *)MH_S0275, // "cul.cpp:culMbrId called with xSp %p not top (%p)" + MH_S0275, // "cul.cpp:culMbrId called with xSp %p not top (%p)" (void *)xSp, (void *)xStk ); // casts are to make far. - return strtprintf( (char *)MH_S0277, // not found. "[%s not found by cul.cpp:culMbrId]". + return strtprintf( MH_S0277, // not found. "[%s not found by cul.cpp:culMbrId]". MNAME( b->fir + fn) ); // punt, using name of member of record structure. } // culMbrId //=========================================================================== diff --git a/src/cuparse.cpp b/src/cuparse.cpp index 73264fc72..1e7ad68c0 100644 --- a/src/cuparse.cpp +++ b/src/cuparse.cpp @@ -84,11 +84,7 @@ AGENDA items decided to defer, 10-5-90: #undef EMIKONFIX // define (and remove *'s) for change in emiKon() to fix // apparent bug in konstize() found reading code 2-94. - ///Leave unchanged till code tests out bad. - -#define FLWANT // define for changes 2-95 to do intermediate calcs in floating point if wanTy is TYFL, - // to eliminate user problems with 2/3 = 0 (integer divide) and 2400*300 = 6464 (truncation). - // Code out defined when working & satisfactory & accepted in use. + // Leave unchanged till code tests out bad. #undef LOKSV // define to restore little-used historical code for assignment to system variables, 2-95 @@ -295,7 +291,7 @@ static RWST itRws[] = struct SFST : public STBK // symbol table for each function { -// char* id; // fcn name text (in base class) +// const char* id; // fcn name text (in base class) USI f; // flag bits: [LOK, ROK,] SA, MA, VA, VC (above) USI evf; // evaluation frequency, 0 if no effect SI cs; // FCREG, FCCHU, FCIMPORT, or other (future) parse case @@ -669,8 +665,8 @@ LOCAL RC FC sysVar( SVST *v, USI wanTy); LOCAL RC FC uFcn( UFST *stb ); LOCAL SI FC dumVar( SI toprec, USI wanTy, RC *prc); LOCAL RC FC var( UVST *v, USI wanTy); -LOCAL RC FC expSi( SI toprec, SI *pisKon, SI *pv, char *tx, SI aN); -LOCAL RC FC convSi( SI* pisKon, SI *pv, SI b4, char *tx, SI aN); +LOCAL RC FC expSi( SI toprec, SI *pisKon, SI *pv, const char *tx, SI aN); +LOCAL RC FC convSi( SI* pisKon, SI *pv, SI b4, const char *tx, SI aN); LOCAL RC FC tconv( SI n, USI *pWanTy); LOCAL RC FC utconvN( SI n, char *tx, SI aN); LOCAL SI FC isKonExp( void **ppv); @@ -702,7 +698,7 @@ LOCAL const char* FC before( const char* tx, int aN); LOCAL const char* FC after( const char* tx, int aN); LOCAL const char* FC asArg( const char* tx, int aN); LOCAL const char* FC datyTx( USI ty); -LOCAL RC FC perI( int showTx, int showFnLn, int isWarn, const char* ms, va_list ap); +LOCAL RC FC perI( int showTx, int showFnLn, int isWarn, MSGORHANDLE ms, va_list ap); //=========================================================================== @@ -754,7 +750,7 @@ RC FC fov() // compile function or variable definition //else if (tokTy==CUTWDVAR) // if "variable" next // // future variable declaration code here else - return perNx( (char *)MH_S0001); // "Syntax error. 'FUNCTION' or 'VARIABLE' expected" + return perNx( MH_S0001); // "Syntax error. 'FUNCTION' or 'VARIABLE' expected" } // fov //=========================================================================== LOCAL RC FC funcDef( // compile function definition @@ -790,12 +786,12 @@ LOCAL RC FC funcDef( // compile function definition /* function name */ if (tokeNot(CUTID)) // if not undeclared unreserved identifier nxt return isWord // non-0 if a word even if reserved - ? perNx( (char *)MH_S0002, // "%s '%s' cannot be used as function name" + ? perNx( MH_S0002, // "%s '%s' cannot be used as function name" tokTy==CUTUF || tokTy==CUTUV ? "previously defined name" : "reserved word", cuToktx ) - : perNx( (char *)MH_S0003 ); // "Expected identifier (name for function)" + : perNx( MH_S0003 ); // "Expected identifier (name for function)" // make errors here fatal when multi-line fcns accepted?? stb.id = strsave(cuToktx); @@ -804,9 +800,9 @@ LOCAL RC FC funcDef( // compile function definition if (tokeNot(CUTLPR)) // if not '(' next { if (tokTy==CUTEQ) // if correct thing to follow arg list - return perNx((char *)MH_S0004); /* "'(' required. \n" + return perNx(MH_S0004); /* "'(' required. \n" " If function has no arguments, empty () must nevertheless be present." */ - return perNx( (char *)MH_S0005); // "Syntax error: '(' expected" + return perNx( MH_S0005); // "Syntax error: '(' expected" } inFlist = 1; // say between ()'s of arg list: tell perNx() not to resume at type word b4 closing ) if (tokeIf(CUTRPR)==0) // unless ) next: empty argList. passes the ). @@ -814,31 +810,31 @@ LOCAL RC FC funcDef( // compile function definition do // args loop head { if (aN >= MAXNARG) - return perNx( (char *)MH_S0006); // "Too many arguments" + return perNx( MH_S0006); // "Too many arguments" // type word toke(); if (prec != PRTY) - return perNx( (char *)MH_S0007 ); // "Syntax error: expected a type such as 'FLOAT' or 'INTEGER'" + return perNx( MH_S0007 ); // "Syntax error: expected a type such as 'FLOAT' or 'INTEGER'" arg[aN].ty = opp->v1; // argument type code (TYSI etc) arg[aN].sz = opp->v2; // size in bytes // argument identifier (dummy name) if (tokeNot(CUTID)) // get token / if not identifier return isWord - ? perNx( (char *)MH_S0008, // "%s '%s' cannot be used as argument name" + ? perNx( MH_S0008, // "%s '%s' cannot be used as argument name" tokTy==CUTUF || tokTy==CUTUV ? "previously defined name" : "reserved word", cuToktx ) - : perNx( (char *)MH_S0009); // "Expected identifier (name for argument)" + : perNx( MH_S0009); // "Expected identifier (name for argument)" arg[aN].id = strsave(cuToktx); // name to dm / ptr to struct aN++; // count args } while (tokeTest(CUTCOM)); // args loop endtest if (tokTy != CUTRPR) - return perNx( (char *)MH_S0010); // "Syntax error: ',' or ')' expected" + return perNx( MH_S0010); // "Syntax error: ',' or ')' expected" } stb.nA = aN; // store # args inFlist = 0; // tell perNx not parsing arg list: type word = start of statement = recovery point @@ -863,7 +859,7 @@ LOCAL RC FC funcDef( // compile function definition /* get separating = */ if (tokeNot(CUTEQ)) - return perNx( (char *)MH_S0011 ); // "'=' expected" + return perNx( MH_S0011 ); // "'=' expected" /* init to compile code */ CSE_E( itPile( ps, sizeof(ps) ) ) // below. Put code in stack for now. CAUTION defaults evfOk, ermTx. @@ -1177,7 +1173,7 @@ RC FC expTy( // types valid in calls only: TYID (returns TYSTR). combinations: TYFLSTR TYNUM TYANY and any combo. default: - rc = perNx( (char *)MH_S0012, gotTy, datyTx(gotTy) ); // "cuparse:expTy: bad return type 0x%x (%s) from expr" + rc = perNx( MH_S0012, gotTy, datyTx(gotTy) ); // "cuparse:expTy: bad return type 0x%x (%s) from expr" goto er; } @@ -1272,7 +1268,7 @@ RC FC expTy( got = ", number/choice value found,"; // extra explanation: error might be obscure, or bug in new code else if (gotTy==TYCH) got = ", choice value found,"; - rc = perNx( (char *)MH_S0013, datyTx(cWanTy), after(tx,aN), got); // "%s expected%s%s". use caller's wanTy for msg. + rc = perNx( MH_S0013, datyTx(cWanTy), after(tx,aN), got); // "%s expected%s%s". use caller's wanTy for msg. goto er; // (label in ERREX macro) } @@ -1307,16 +1303,16 @@ LOCAL RC expr( // parse/compile inner recursive fcn { static const char * pCuToktx = cuToktx; // for when ptr to ptr to cuToktx needed -#define EXPECT(ty,str) if (tokeNot(ty)) { rc = perNx( (char *)MH_S0015, (str) ); goto er; } // "'%s' expected" -#define NOVALUECHECK if (lastPrec >= PROP) { rc = perNx( (char *)MH_S0014, cuToktx ); goto er; } +#define EXPECT(ty,str) if (tokeNot(ty)) { rc = perNx( MH_S0015, (str) ); goto er; } // "'%s' expected" +#define NOVALUECHECK if (lastPrec >= PROP) { rc = perNx( MH_S0014, cuToktx ); goto er; } // "Syntax error: probably operator missing before '%s'" ERVARS ERSAVE - printif( trace," expr(%d,%d) ", (INT)toprec, (INT)wanTy ); // cueval.cpp + printif( trace," expr(%d,%d) ", toprec, wanTy ); // cueval.cpp if (wanTy & TYLLI) // debug aid - perl( (char *)MH_S0016); // "Internal error in cuparse.cpp:expr: TYLLI not suppored in cuparse.cpp" + perl( MH_S0016); // "Internal error in cuparse.cpp:expr: TYLLI not suppored in cuparse.cpp" prec = 0; // nothing yet: prevent "operator missing before" msg if expr starts with operand EE( newSf()) // start new parse stack frame for this expr. EE (cuparsex.h) restores vbls and rets on error. @@ -1332,7 +1328,7 @@ LOCAL RC expr( // parse/compile inner recursive fcn // done if token's precedence <= "toprec" arg if (prec <= toprec) // if < this expr() call's goal { - printif( trace," exprDone %d ", (INT)prec); + printif( trace," exprDone %d ", prec); break; // stop b4 this token } @@ -1345,17 +1341,17 @@ LOCAL RC expr( // parse/compile inner recursive fcn // every case must update as needed: parSp->ty, evf, did; and prec = operand if not always covered. case CSUNI: - EE( unOp( prec-1, TYSI, wanTy, opp->v1, opp->v2, ttTx)) break; // unary integer operator, e.g. '!' + EE(unOp(prec-1, TYSI, wanTy, opp->v1, opp->v2, ttTx)) break; // unary integer operator, e.g. '!' case CSUNN: - EE( unOp( prec-1, TYNUM, wanTy, opp->v1, opp->v2, ttTx)) break; // unary numeric ops. + EE(unOp(prec-1, TYNUM, wanTy, opp->v1, opp->v2, ttTx)) break; // unary numeric ops. // prec-1 used for toprec to do r to l. case CSBII: - EE( biOp( prec, TYSI, wanTy, opp->v1, opp->v2, ttTx)) break; // binary int op'rs | & ^ >> << % + EE(biOp(prec, TYSI, wanTy, opp->v1, opp->v2, ttTx)) break; // binary int op'rs | & ^ >> << % case CSBIF: - EE( biOp( prec, TYFL, wanTy, opp->v1, opp->v2, ttTx)) break; // binary float operator: ' (feet-inches) + EE(biOp(prec, TYFL, wanTy, opp->v1, opp->v2, ttTx)) break; // binary float operator: ' (feet-inches) /* feet-inches notes 2-91: 1) implemented as binary operator, with binding power hier than unary ops so -5'6 comes out right. 2) wanna check inches for 0 to 12? always (cueval) or only if constant (konstize here & test)? @@ -1363,176 +1359,173 @@ LOCAL RC expr( // parse/compile inner recursive fcn 3) later enable only if addl arg to exOrk/expTy/expr/parSp says looking for a length? */ case CSBIN: - EE( biOp( prec, TYNUM, wanTy, opp->v1, opp->v2, ttTx)) break; // bi numer (float / int, result same) ops + EE(biOp(prec, TYNUM, wanTy, opp->v1, opp->v2, ttTx)) break; // bi numer (float / int, result same) ops case CSCMP: - EE( biOp( prec, TYNUM, wanTy, opp->v1, opp->v2, ttTx)) // comparisons: binary numeric ops, - parSp->ty = TYSI; // int result + EE(biOp(prec, TYNUM, wanTy, opp->v1, opp->v2, ttTx)) // comparisons: binary numeric ops, + parSp->ty = TYSI; // int result break; /* && or ||: two int args, one int result left on stack. do not eval 2nd arg (branch around it) if first is conclusive; eliminate unneeded code when args are constant. */ case CSLEO: - { + { SI isK1, isK2, v1, v2; OPTBL* svOpp; EE(convSi(&isK1, &v1, 1, ttTx, 0)) // check/konstize value b4 & convert to int - EE(emit(opp->v1)) // PSJZP for &&, PSJNZP for || - EE(emit(0xffff)) // offset (displacment) space - svOpp = opp; // save thru expTy + EE(emit(opp->v1)) // PSJZP for &&, PSJNZP for || + EE(emit(0xffff)) // offset (displacment) space + svOpp = opp; // save thru expTy EE(expSi(prec, &isK2, &v2, ttTx, 0)) // value after: get int expr, konstize - if (isK1) // if 1st expr was constant - { - /* get rid of non-significant argument: - * if arg 1 is && || - * 0 drop arg 2 drop arg 1 - * nz drop arg 1 drop arg 2 */ - EE(dropSfs( /* delete parStk frame(s)+code */ - (v1 != 0) ^ svOpp->v2 /*&&:0 ||:1*/, /* 0: drop top frame (arg 2), */ - /* 1: drop top-1 frame (arg 1) */ - 1)) // drop 1 frame - EE(dropJmpIf()) // delete arg 1 trailJmp - } - else if (isK2) // if 2nd expr contant - { - /* get rid of non-significant argument: - * if arg 2 is && || - * 0 drop arg 1 drop arg 2 - * nz drop arg 2 drop arg 1 */ - EE(dropSfs( /* delete parStk frame(s)+code */ - (v2 == 0) ^ svOpp->v2 /*&&:0 ||:1*/, /* 0: drop top frame (arg 2) */ - /* 1: drop top-1 frame (arg 1) */ - 1)) // drop 1 frame - EE(dropJmpIf()) // delete arg 1 trailJmp - } - else // neither arg constant, keep both - { - EE(fillJmp(1)) // set offset of jmp (end PREV parStk frame) to jmp here - EE(combSf()) // combine code after & b4 - } + if (isK1) // if 1st expr was constant + { + /* get rid of non-significant argument: + * if arg 1 is && || + * 0 drop arg 2 drop arg 1 + * nz drop arg 1 drop arg 2 */ + EE(dropSfs( /* delete parStk frame(s)+code */ + (v1 != 0) ^ svOpp->v2 /*&&:0 ||:1*/, /* 0: drop top frame (arg 2), */ + /* 1: drop top-1 frame (arg 1) */ + 1)) // drop 1 frame + EE(dropJmpIf()) // delete arg 1 trailJmp + } + else if (isK2) // if 2nd expr contant + { + /* get rid of non-significant argument: + * if arg 2 is && || + * 0 drop arg 1 drop arg 2 + * nz drop arg 2 drop arg 1 */ + EE(dropSfs( /* delete parStk frame(s)+code */ + (v2 == 0) ^ svOpp->v2 /*&&:0 ||:1*/, /* 0: drop top frame (arg 2) */ + /* 1: drop top-1 frame (arg 1) */ + 1)) // drop 1 frame + EE(dropJmpIf()) // delete arg 1 trailJmp + } + else // neither arg constant, keep both + { + EE(fillJmp(1)) // set offset of jmp (end PREV parStk frame) to jmp here + EE(combSf()) // combine code after & b4 + } EE(emit(PSIBOO)) // make any nz a 1 - EE(konstize(NULL, NULL, 0)) // constize to combine PSIBOO - } - break; - - // grouping operators: (, [ + EE(konstize(NULL, NULL, 0)) // constize to combine PSIBOO + } + break; + // grouping operators: (, [ case CSGRP: { char ss[2]; NOVALUECHECK; svOpp = opp; // save opp thru unOp - EE( unOp( PRRGR, TYANY, wanTy, 0, 0, ttTx) ) - ss[0] = (char)svOpp->v2; + EE(unOp(PRRGR, TYANY, wanTy, 0, 0, ttTx)) + ss[0] = (char)svOpp->v2; ss[1] = '\0'; // char to string for msg - EXPECT( svOpp->v1, ss); + EXPECT(svOpp->v1, ss); prec = PROP; /* say have a value last: (expr) is a value even tho ')' is not: - effects interpretation of unary/binary ops and syntax checks */ + effects interpretation of unary/binary ops and syntax checks */ } break; // unexpected: improper use or token with no valid use yet - /*lint -e616 falls into case */ case CSU: // believed usually impossible for terminators due to low prec's - rc = perNx( (char *)MH_S0017, cuToktx); // "Unexpected '%s'" + rc = perNx(MH_S0017, cuToktx); // "Unexpected '%s'" goto er; default: - rc = perNx( (char *)MH_S0018, (INT)opp->cs, cuToktx, (INT)prec, (INT)tokTy ); + rc = perNx(MH_S0018, opp->cs, cuToktx, prec, tokTy); /* "Internal error in cuparse.cpp:expr: Unrecognized opTbl .cs %d" " for token='%s' prec=%d, tokTy=%d." */ goto er; - // additional cases by token type - + // additional cases by token type case CSCUT: + { void* v{ nullptr }; + USI sz{ 0 }; + MSGORHANDLE ms; // choice value,size,msg as from cvS2Choi( cuToktx, choiDt, (void *)&v, &sz, &ms), + // for CUTID (choice subcase), CUTMONTH, . switch (tokTy) { - void *v; - USI sz; - const char *ms; // choice value,size,msg as from cvS2Choi( cuToktx, choiDt, (void *)&v, &sz, &ms), - // for CUTID (choice subcase), CUTMONTH, . default: - rc = perNx( (char *)MH_S0019, (INT)tokTy, cuToktx, (INT)prec ); // "Internal error in cuparse.cpp:expr: " ... + rc = perNx(MH_S0019, tokTy, cuToktx, prec); // "Internal error in cuparse.cpp:expr: " ... goto er; // " Unrecognized tokTy %d for token='%s' prec=%d." case CUTSI: // integer, value in cuIntval NOVALUECHECK; - EE( emiKon( TYSI, &cuIntval, 0, NULL) ) // local, below - parSp->ty = TYSI; // have value; type integer + EE(emiKon(TYSI, &cuIntval, 0, NULL)) // local, below + parSp->ty = TYSI; // have value; type integer // parSp->evf: no change for constant // prec >= PROP already true break; case CUTFLOAT: // float number, value in cuFlval NOVALUECHECK; - EE( emiKon( TYFL, &cuFlval, 0, NULL) ) // local, below - parSp->ty = TYFL; // have value; type = float + EE(emiKon(TYFL, &cuFlval, 0, NULL)) // local, below + parSp->ty = TYFL; // have value; type = float break; case CUTQUOT: // quoted text, text in cuToktx NOVALUECHECK; - EE( emiKon( TYSTR, &pCuToktx, 0, NULL ) ) /* 0: put text inline, not in dm: minimize - fragmentation; make code self-contained */ - parSp->ty = TYSTR; // have string value + EE(emiKon(TYSTR, &pCuToktx, 0, NULL)) /* 0: put text inline, not in dm: minimize + fragmentation; make code self-contained */ + parSp->ty = TYSTR; // have string value break; case CUTMONTH: // month name reserved words NOVALUECHECK; { - MOST *most = (MOST *)stbk; // save thru toke/untoke for monOp call + MOST* most = (MOST*)stbk; // save thru toke/untoke for monOp call // take month name as month choice value under strict context conditions. result TYCH/DTMONCH 1-12. -#ifdef DTMONCH // undefining month choice type deletes code - if ( wanTy==TYCH && choiDt==DTMONCH // if looking for a month name choice - && cvS2Choi(cuToktx,choiDt,(void *)&v,&sz,&ms)==RCOK // look up b4 toke() overwrites cuToktx / if found - && ( toke(), unToke(), nextPrec < prec ) ) // if no operand expr for day of month follows + #ifdef DTMONCH // undefining month choice type deletes code + if (wanTy==TYCH && choiDt==DTMONCH // if looking for a month name choice + && cvS2Choi(cuToktx, choiDt, (void*)&v, &sz, &ms)==RCOK // look up b4 toke() overwrites cuToktx / if found + && (toke(), unToke(), nextPrec < prec)) // if no operand expr for day of month follows goto oopsAchoice; // jump into case CUTID. -#endif + #endif // note cvS2Choi() RCBAD2 return comes here (=use of choide alias), not expected? 8-14-2012 - ms = NULL; // insurance, drop possible info msg from cvS2Choi + ms.mh_Clear(); // insurance, drop possible info msg from cvS2Choi // usually take month as unary operator, followed by SI day of month expr, result DOY (day of year, SI) - EE( monOp(most)); // just below + EE(monOp(most)); // just below } break; case CUTSF: // system function, set or use NOVALUECHECK; -#ifdef LOKFCN -* EE( fcn( (SFST*)stbk, toprec, wanTy) ) // do it -#else - EE( fcn( (SFST*)stbk, wanTy) ) // do it -#endif - break; + #ifdef LOKFCN + * EE(fcn((SFST*)stbk, toprec, wanTy)) // do it + #else + EE(fcn((SFST*)stbk, wanTy)) // do it + #endif + break; case CUTSV: // system variable, set or use NOVALUECHECK; -#ifdef LOKSV -* EE( sysVar( (SVST*)stbk, toprec, wanTy) ) -#else - EE( sysVar( (SVST*)stbk, wanTy) ) -#endif - break; + #ifdef LOKSV + * EE(sysVar((SVST*)stbk, toprec, wanTy)) + #else + EE(sysVar((SVST*)stbk, wanTy)) + #endif + break; case CUTUF: // user-defined function NOVALUECHECK; - EE( uFcn( (UFST*)stbk ) ) - break; + EE(uFcn((UFST*)stbk)) + break; case CUTUV: // already-declared user variable NOVALUECHECK; - EE( var( (UVST*)stbk, wanTy) ) // do it - break; + EE(var((UVST*)stbk, wanTy)) // do it + break; case CUTAT: // @ []. NOVALUECHECK; - EE( probe()); // cuprobe.cpp + EE(probe()); // cuprobe.cpp break; case CUTID: // identifier not yet in symbol table NOVALUECHECK; // added 2-92: always missing ?? - if (dumVar( toprec, wanTy, &rc)) // false if not dummy vbl in fcn, else do, set rc + if (dumVar(toprec, wanTy, &rc)) // false if not dummy vbl in fcn, else do, set rc { if (rc) goto er; // error compiling dummy vbl use @@ -1540,79 +1533,79 @@ LOCAL RC expr( // parse/compile inner recursive fcn } else if (wanTy & TYID) // if caller wants identifier (for record name) { - EE( emiKon( TYSTR, &pCuToktx, 0, NULL ) ) // he's got it. convert to string constant. - parSp->ty = TYSTR; // have string value. + EE(emiKon(TYSTR, &pCuToktx, 0, NULL)) // he's got it. convert to string constant. + parSp->ty = TYSTR; // have string value. break; } else if (wanTy & TYCH && choiDt) // if looking for a choice value { #if 0 // unrun draft rejected 2-92: if string operand intended, quote it! -x if ( ) // check if is a choice for choiDt, else issue message +x if () // check if is a choice for choiDt, else issue message x goto er; -x EE( emiKon( TYSTR, &pCuToktx, 0, NULL ) ) // convert it now to a STRING constant +x EE(emiKon(TYSTR, &pCuToktx, 0, NULL)) // convert it now to a STRING constant x parSp->ty = TYSTR; // have string value x break; // caller expTy, or runtime, will convert to choice value #else - rc = cvS2Choi( cuToktx, choiDt, (void *)&v, &sz, &ms); // for choiDt choice text get value and size, - // or err ms text if not found, cvpak.cpp. + rc = cvS2Choi(cuToktx, choiDt, (void*)&v, &sz, &ms); // for choiDt choice text get value and size, + // or err ms text if not found, cvpak.cpp. if (rc == RCBAD) - { rc = perNx((char *)MH_S0020, ms); // "%s\n (OR mispelled word or omitted quotes)" + { + rc = perNx(MH_S0020, ms); // "%s\n (OR mispelled word or omitted quotes)" goto er; } else if (rc == RCBAD2) - rc = pInfolc( ms); // info re use of deprecated choice alias, RCOK -oopsAchoice: // come here with v, sz, ms set as from cvS2Choi call to take (reserved) word as choice constant + rc = pInfolc(ms); // info re use of deprecated choice alias, RCOK + oopsAchoice: // come here with v, sz, ms set as from cvS2Choi call to take (reserved) word as choice constant // eg from case CUTCOM - EE( emiKon( TYCH, (void *)&v, 0, NULL) ) // emit 2 or 4-byte choice value constant, uses choiDt - parSp->ty = TYCH; // now have a choice value + EE(emiKon(TYCH, (void*)&v, 0, NULL)) // emit 2 or 4-byte choice value constant, uses choiDt + parSp->ty = TYCH; // now have a choice value break; #endif } else // none of the above, form error message { - char **xstbk; - const char *sub; - if (syLu( &symtab, cuToktx,1,NULL,(void**)&xstbk)==RCOK) // search symtab again, case-insensitive - sub = strtprintf( (char *)MH_S0021, // ":\n perhaps you intended '%s'." + char** xstbk; + const char* sub; + if (syLu(&symtab, cuToktx, 1, NULL, (void**)&xstbk)==RCOK) // search symtab again, case-insensitive + sub = strtprintf(MH_S0021, // ":\n perhaps you intended '%s'." *xstbk); // 1st mbr of all symtab blox is char* id else if (wanTy==TYSTR) sub = ",\n or possibly omitted quotes."; - else if ( wanTy & TYANY // if value desired (not whole statement) - && basAnc::findAnchorByNm(cuToktx,NULL)==RCOK ) // if a rat name + else if (wanTy & TYANY // if value desired (not whole statement) + && basAnc::findAnchorByNm(cuToktx, NULL)==RCOK) // if a rat name sub = ",\n or possibly omitted '@'."; else sub = ""; - rc = perNx( (char *)MH_S0022, // "Misspelled word or undeclared function or variable name '%s'%s" - cuToktx, sub ); + rc = perNx(MH_S0022, // "Misspelled word or undeclared function or variable name '%s'%s" + cuToktx, sub); //dumpDefines(); // ppcmd.cpp. possible #define debug aid display. goto er; } case CUTQM: // C "?:" conditional expression operator: ? : - EE( condExpr(wanTy) ) // do it, below - break; + EE(condExpr(wanTy)) // do it, below + break; case CUTCOM: // comma: C sequential evaluation operator - if ( parSp < parStk - || parSp->ty==TYNONE ) + if (parSp < parStk + || parSp->ty==TYNONE) { - rc = perNx( (char *)MH_S0023); // "Value expected before ','" + rc = perNx(MH_S0023); // "Value expected before ','" goto er; } - EE( emiPop() ) // discard run value to here, errmsg if has no side effect nor store - // continue parsing with same toprec, wanTy ... - parSp->ty = TYNONE; // what else? + EE(emiPop()) // discard run value to here, errmsg if has no side effect nor store + // continue parsing with same toprec, wanTy ... + parSp->ty = TYNONE; // what else? break; - // case CUTDEF: preprocessor token, "cannot" get here. - - /*lint +e616 */ + // case CUTDEF: preprocessor token, "cannot" get here. } // switch (tokTy) + } // case CUTUT scope } // switch (case) if (parSp < parStk) { - rc = perNx( (char *)MH_S0024); + rc = perNx( MH_S0024); goto er; // "Internal error in cuparse.cpp:expr: parse stack underflow" } @@ -1626,7 +1619,7 @@ x break; // caller expTy, or runtime, will convert to choice value USI bb = evfC & ~evfOk; // bad bits: 1 in evfC, 0 in evfOk if (bb) // if any bad bits { if (bb & EVXBEGIVL) - { rc = perNx( (char *)MH_S0025, /* "Value is available later in %s \n" + { rc = perNx( MH_S0025, /* "Value is available later in %s \n" " than is required%s.\n" " You may need to use a .prior in place of a .res" */ evfTx( evfC, 2), // 2: noun: eg "each hour" @@ -1636,12 +1629,12 @@ x break; // caller expTy, or runtime, will convert to choice value const char* insert = // to insert between "where" and "permitted" evfOk==0 ? "only non-varying values" // avoid "at most no variation". "only constant values" ? : bb > evfOk // if bb varying than any evfOk, - ? strtprintf( (char *)MH_S0026, // "at most %s variation" + ? strtprintf( MH_S0026, // "at most %s variation" evfTx( evfOk, 0)) // ... we can be more specific : evfOk==VMHLY ? "only monthly and hourly variation" // (M+H combined only when with no others) - : strtprintf( (char *)MH_S0027, evfTx( bb, 0)); // "%s variation not" + : strtprintf( MH_S0027, evfTx( bb, 0)); // "%s variation not" - rc = perNx( (char *)MH_S0128, // "Value varies %s\n where %s permitted%s." extracted 6-95 + rc = perNx( MH_S0128, // "Value varies %s\n where %s permitted%s." extracted 6-95 evfTx( bb, 1), // 1: adverb: eg "hourly" insert, ermTx ? strtprintf( "\n for '%s'", ermTx) : "" ); @@ -1654,9 +1647,9 @@ x break; // caller expTy, or runtime, will convert to choice value if (parSp->ty==TYNONE) // indicates no operand done { if (wanTy==TYDONE) - rc = perNx( (char *)MH_S0028, after( tx, aN) ); // "Statement expected%s" + rc = perNx( MH_S0028, after( tx, aN) ); // "Statement expected%s" else - rc = perNx( (char *)MH_S0029, // "Value expected %s%s" + rc = perNx( MH_S0029, // "Value expected %s%s" after( tx, aN), (wanTy & TYANY && prec==PRVRB @@ -1673,7 +1666,7 @@ x break; // caller expTy, or runtime, will convert to choice value #if 1 // devel aid 10-29-90 // check that exactly one parStk frame produced if (parSp != parSpSv+1) - perNx( (char *)MH_S0030, (INT)(parSp - parSpSv)); // "Internal error: cuparse.cpp:expr produced %d not 1 parStk frames" + perNx( MH_S0030, (parSp - parSpSv)); // "Internal error: cuparse.cpp:expr produced %d not 1 parStk frames" #endif return RCOK; // added parStk entry remains, to return info to caller. @@ -1730,7 +1723,6 @@ LOCAL RC FC unOp( // parse arg to unary operator, emit code. ERVARS1 ERSAVE NOVALUECHECK; -#ifdef FLWANT//at top of file 2-95 if (argTy != TYNUM) opFl = opSi; // if (unmodified) argTy != float, all types use opSi arg. if ( (wanTy & TYNUM)==TYFL // when compiling a float expression (incl TYNC, TYFLSTR), @@ -1740,11 +1732,6 @@ LOCAL RC FC unOp( // parse arg to unary operator, emit code. EE( expTy( toprec, argTy, tx, 0) ) // get expression. always returns prec >= PROP, right? EE( emit( (parSp->ty==TYFL) ? opFl : opSi ) ) // emit operation code for type EE( combSf() ) // combine 2 parStk frames -#else -* EE( expTy( toprec, argTy, tx, 0) ) // get expression. always returns prec >= PROP, right? -* EE( emit( (argTy==TYNUM && parSp->ty==TYFL) ? opFl : opSi ) ) // emit operation code for type -* EE( combSf() ) // combine 2 parStk frames -#endif // prec is >= PROP from expTy return RCOK; ERREX(unOp) @@ -1765,12 +1752,10 @@ LOCAL RC FC biOp( // parse 2nd arg to binary operator, emit conversions and op ERSAVE if (argTy != TYNUM) opFl = opSi; // if (unmodified) argTy != float, all types use opSi arg. -#ifdef FLWANT//above 2-95 if ( (wanTy & TYNUM)==TYFL // when compiling a float expression (incl TYNC, TYFLSTR), && argTy & TYFL ) // for numeric operators (typically argTy==TYNUM), argTy &= ~(TYSI|TYINT); // float arguments ASAP to not truncate 2400*300 to 16 bits nor 2/3 to 0 -- // too much user confusion occurred from C-like integer operations. -#endif if (parSp < parStk || (parSp->ty & argTy)==0) // if no preceding value or if preceding value wrong type { if (parSp >= parStk && parSp->ty==TYSI && argTy==TYFL) // if have int and want float @@ -1785,8 +1770,8 @@ LOCAL RC FC biOp( // parse 2nd arg to binary operator, emit conversions and op } else { - rc = perNx( tx==NULL ? (char *)MH_S0031 : // "Preceding %s expected" - (char *)MH_S0032, // "%s expected%s" + rc = perNx( tx==NULL ? MH_S0031 : // "Preceding %s expected" + MH_S0032, // "%s expected%s" datyTx(argTy), before(tx,0) ); goto er; // (label in ERREX macro) } @@ -1832,11 +1817,7 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? // then-expr. Any type value ok. NB prec of ':' is prec of '?' - 1. -#ifdef FLWANT USI aWanTy = (wanTy & (TYID|TYCH|TYSI|TYINT)) | (TYANY & ~(TYID|TYCH|TYSI|TYINT)); // messy type bits feed thru to then-expr and else-expr -#else -* USI aWanTy = (wanTy & (TYID|TYCH)) | (TYANY & ~(TYID|TYCH)); // messy type bits feed thru to then-expr and else-expr -#endif EE( expTy( prec-1, aWanTy, ttTx, 0)) // get value, new parStk frame. EXPECT( CUTCLN, ":") // error if colon not next if (!isKon) @@ -1859,7 +1840,7 @@ LOCAL RC FC condExpr( // finish parsing C conditional expression: ? USI ty2 = parSp->ty; if (ty1 != ty2 && (ty1|ty2) != TYNC) // types must be same or combined type must be TYNC -- only 2-bit type allowed { - rc = perNx( (char *)MH_S0033, // "Incompatible expressions before and after ':' -- \n cannot combine '%s' and '%s'" + rc = perNx( MH_S0033, // "Incompatible expressions before and after ':' -- \n cannot combine '%s' and '%s'" datyTx(ty1), datyTx(ty2) ); goto er; // in ERREX macro } @@ -1956,40 +1937,40 @@ LOCAL RC FC fcnImport( SFST *f) // argument list. Both arguments are constant arguments whose values are used now. if (tokeNot(CUTLPR)) // get '(' after fcn name - return perNx( (char *)MH_S0034, (char *)f->id ); // "'(' missing after built-in function name '%s'". cast to far. + return perNx( MH_S0034, f->id ); // "'(' missing after built-in function name '%s'". cast to far. // first argument: name of ImportFile object. // cuparse seems to have no intended support for contants, but expTy then konstize should work. 2-94. - CSE_E( expTy( PRCOM, TYID, (char *)f->id, 1) ) // get TYID (similar to TYSTR) expr for 1st argument. makes parStk frame. + CSE_E( expTy( PRCOM, TYID, f->id, 1) ) // get TYID (similar to TYSTR) expr for 1st argument. makes parStk frame. SI isKon; // receives TRUE if konstize detects or makes constant void *pv; // receives pointer to const value (ptr to ptr for TYSTR) // (search EMIKONFIX re correcting apparent bug in ptr ptr return 2-94) CSE_E( konstize( &isKon, &pv, 0) ) /* test expression just compiled: detect constant value; else evaluate now to make constant value if possible. */ if (!isKon) // if not contant (and could not be make constant) - return perNx( (char *)MH_S0123, /* "S0123: %s argument %d must be constant,\n" + return perNx( MH_S0123, /* "S0123: %s argument %d must be constant,\n" " but given value varies %s" */ - (char *)f->id, // cast near ptr to far - (INT)1, + f->id, // cast near ptr to far + 1, parSp->evf ? evfTx(parSp->evf,1) : ""); // evf bit expected, but if none, omit explanation. const char* impfName = *(char **)pv; // fetch pointer to import file name text in code frame // parse stack frame must be retained till impfName used in impFcn call, then dropped. if (tokeNot(CUTCOM)) // get comma between args - return perNx( (char *)MH_S0015, "," ); // issue error "'%s' expected" + return perNx( MH_S0015, "," ); // issue error "'%s' expected" // second argument: field name or number. #if 0 -* CSE_E( expTy( PRCOM, TYSI|TYSTR, (char *)f->id, 2) ) // get integer or string expr for 2nd argument +* CSE_E( expTy( PRCOM, TYSI|TYSTR, f->id, 2) ) // get integer or string expr for 2nd argument #else // 2-94 believe this will allow unquoted field names - CSE_E( expTy( PRCOM, TYSI|TYID, (char *)f->id, 2) ) // get integer, identifier (returns TYSTR) or string expr for 2nd argument + CSE_E( expTy( PRCOM, TYSI|TYID, f->id, 2) ) // get integer, identifier (returns TYSTR) or string expr for 2nd argument #endif BOO byName = parSp->ty==TYSTR; // TYSI is by field number. Others should not return. CSE_E( konstize( &isKon, &pv, 0) ) // detect or make constant value if possible if (!isKon) // if not constant - return perNx( (char *)MH_S0123, /* "S0123: %s argument %d must be constant,\n" + return perNx( MH_S0123, /* "S0123: %s argument %d must be constant,\n" " but given value varies %s" */ - (char *)f->id, // cast near ptr to far + f->id, // cast near ptr to far 2, parSp->evf ? evfTx(parSp->evf,1) : ""); // evf bit expected, but if none, omit explanation. char *fieldName = NULL; SI fnr = 0; @@ -1999,12 +1980,12 @@ LOCAL RC FC fcnImport( SFST *f) { fnr = *(SI *)pv; // else must be TYSI. retrieve field number value. if (fnr <= 0 || fnr > FNRMAX) // check range. FNRMAX: impf.h. - return perNx( (char *)MH_S0124, (INT)fnr, (INT)FNRMAX); // "Import field number %d not in range 1 to %d" + return perNx( MH_S0124, fnr, FNRMAX); // "Import field number %d not in range 1 to %d" } // parse stack frame must be retained till fieldName moved elsewhere, then dropped (text may be inline in code). if (tokeNot(CUTRPR)) // get right paren after args - return perNx( (char *)MH_S0015, ")" ); // issue error "'%s' expected" + return perNx( MH_S0015, ")" ); // issue error "'%s' expected" // error if = next: can't be used on left side @@ -2012,7 +1993,7 @@ LOCAL RC FC fcnImport( SFST *f) #ifdef LOKFCN //if (!(f->f & LOK)) // never ok with Import fcns #endif - return perNx( (char *)MH_S0035, (char *)f->id); // "Built-in function '%s' may not be assigned a value". + return perNx( MH_S0035, f->id); // "Built-in function '%s' may not be assigned a value". // have: impfName, fieldName, fnr, fileIx, line @@ -2079,32 +2060,32 @@ LOCAL RC FC fcnReg( SFST *f, USI wanTy) // parse most functions, for fcn() // argument list in ( )'s if (tokeNot(CUTLPR)) // get '(' after fcn name - return perNx( (char *)MH_S0034, (char *)f->id ); // "'(' missing after built-in function name '%s'". cast to far. + return perNx( MH_S0034, f->id ); // "'(' missing after built-in function name '%s'". cast to far. CSE_E( fcnArgs( f, 0, wanTy, 0, &aTy, NULL, NULL, NULL, NULL) ) // parse args, ret bad if err // if '=' next in input, value is being ASSIGNED TO function #ifndef LOKFCN if (tokeIf(CUTEQ)) - return perNx( (char *)MH_S0035, (char *)f->id); // "Built-in function '%s' may not be assigned a value". + return perNx( MH_S0035, f->id); // "Built-in function '%s' may not be assigned a value". // cast f->id to make (char far *). #else * SI onLeft = tokeIf(CUTEQ); // = next? else unToke. onLeft = 1 if fcn being assigned value. * if (onLeft) // if yes * { if (!(f->f & LOK)) // ok for this fcn? -* return perNx( (char *)MH_S0035, (char *)f->id); // "Built-in function '%s' may not be assigned a value". +* return perNx( MH_S0035, f->id); // "Built-in function '%s' may not be assigned a value". * // cast f->id to make (char far *). * // get value of fcn's type to be assigned to function * * char tx[50]; // must be in stack -* sprintf( tx, "%s(...)=", (char *)f->id); // for "after ___" in errmsgs +* sprintf( tx, "%s(...)=", f->id); // for "after ___" in errmsgs * CSE_E( expTy( /* get expr. sets nextPrec. */ * max( toprec, PRASS-1), /* parse to current toprec except stop b4 , or ) */ * f->resTy, /* type: fcn's result type */ * tx, 0) ) * if (wanTy != TYDONE) // if context is "expression desired" * if (nextPrec > PRCOM) // if not , ) ] ; verb EOF next -* pWarnlc( (char *)MH_S0036); // "Nested assignment should be enclosed in ()'s to avoid ambiguity" +* pWarnlc( MH_S0036); // "Nested assignment should be enclosed in ()'s to avoid ambiguity" * // CAUTION: MH_S0036 also used in sysVar() and dumVar(). * // warning message, keep compiling, do not suppress execution * // re code for fcn assignment @@ -2124,7 +2105,7 @@ LOCAL RC FC fcnReg( SFST *f, USI wanTy) // parse most functions, for fcn() #ifdef LOKFCN // else all have ROK, don't check. 2-95. * if (!(f->f & ROK)) // check if ok for this fcn -* return perNx( (char *)MH_S0037, (char *)f->id ); /* "Built-in function '%s' may only be used left of '=' --\n" +* return perNx( MH_S0037, f->id ); /* "Built-in function '%s' may only be used left of '=' --\n" * " it can be assigned a value but does not have a value" */ #else // former MH_S0037 probably unused. @@ -2165,7 +2146,7 @@ LOCAL RC FC fcnChoose( SFST *f, USI wanTy) // do choose-type fcns for fcn() (f- USI aTy, optn; SI nA0=0, haveIx=0, isKon=0, v, nA, defa, nAnDef, base, i; RC rc; if (tokeNot(CUTLPR)) // pass '(' after fcn name - return perNx( (char *)MH_S0038, (char *)f->id ); // "'(' missing after built-in function name '%s'". cast f->id to far. + return perNx( MH_S0038, f->id ); // "'(' missing after built-in function name '%s'". cast f->id to far. optn = 1 // options for fcnArgs call: 1: append JMPs | 2 // 2: accept "default" b4 last arg @@ -2199,7 +2180,7 @@ LOCAL RC FC fcnChoose( SFST *f, USI wanTy) // do choose-type fcns for fcn() (f- haveIx = 1; // have index expr in parStk nA0 = 1; // 1 arg already parsed (for fcnArgs) if (tokeNot(CUTCOM)) // pass comma after arg - return perNx( (char *)MH_S0039); // "',' expected" CAUTION multiply-used message handle + return perNx( MH_S0039); // "',' expected" CAUTION multiply-used message handle } // get value expressions and ')' @@ -2214,14 +2195,14 @@ LOCAL RC FC fcnChoose( SFST *f, USI wanTy) // do choose-type fcns for fcn() (f- nAnDef = nA - (defa != 0); // compute # args less default // error message for left side use if (tokeIf(CUTEQ)) // "=" after ")" (else unget) ? - return perNx( (char *)MH_S0040, (char *)f->id); // "Built-in function '%s' may not be assigned a value" + return perNx( MH_S0040, f->id); // "Built-in function '%s' may not be assigned a value" // messages if wrong # values for hourval if (f->f & F1) // if hourval if (nAnDef < 24 && defa != 1) // < 24 args w/o user default is error - return perNx( (char *)MH_S0041); // "hourval() requires values for 24 hours" + return perNx( MH_S0041); // "hourval() requires values for 24 hours" else if (nAnDef > 24) // > 24 args gets warning - pWarnlc( (char *)MH_S0042); // "hourval() arguments in excess of 24 will be ignored" + pWarnlc( MH_S0042); // "hourval() arguments in excess of 24 will be ignored" if (isKon) // if constant index (1) or select all cond false (-1) { @@ -2242,10 +2223,10 @@ o v = nAnDef; // use default (nA-1) if (defa) // if have a default v = nAnDef; // use default (nA-1) else if (f->f & F2) - return perNx( (char *)MH_S0043, (char *)f->id ); // "All conditions in '%s' call false and no default given" + return perNx( MH_S0043, f->id ); // "All conditions in '%s' call false and no default given" else - return perNx( (char *)MH_S0044, // "Index out of range and no default: \n" ... - (char *)f->id, INT(v+base), (INT)base, INT(nA-1+base) ); // " argument 1 to '%s' is %d, not in range %d to %d" + return perNx( MH_S0044, // "Index out of range and no default: \n" ... + f->id, v+base, base, nA-1+base ); // " argument 1 to '%s' is %d, not in range %d to %d" /* These errMsgs better than cueval msgs as now (10-90, 2-91) occur out of konstize: cueval does not show fcn name, and shows range limits as 0 since unused exprs deleted. So we suppress def def when choose() index constant (above) or all select() cond-exprs const 0 (fcnArgs). */ @@ -2345,8 +2326,8 @@ LOCAL RC FC fcnArgs( // parse args for regular-case built-in function, and som { CSE_E( expSi( PRCOM, &tisK, &tv, f->id, uAN+nA0) ) // int expr if (tokeNot(CUTCOM)) - return perNx( (char *)MH_S0045, // "',' expected. '%s' arguments must be in pairs." - (char *)f->id ); + return perNx( MH_S0045, // "',' expected. '%s' arguments must be in pairs." + f->id ); CSE_E( emit( PSPJZ) ) // pop and branch (around val) if 0 CSE_E( emit( 0xffff) ) // filled after val-expr parsed uAN++; // count an arg for errMsg display @@ -2384,7 +2365,6 @@ LOCAL RC FC fcnArgs( // parse args for regular-case built-in function, and som if (aWanTy==TYANY) // if "any type arg" aWanTy = (wanTy & (TYID|TYCH)) | (TYANY & ~(TYID|TYCH)); // feed messy type bits thru.. -#ifdef FLWANT//top of file 2-95 // for function returning arg type (min,brkt,hourly,...) and accepting numeric args, float args early 2-95. if (aWanTy & TYFL) // if arg type can be float (expect TYANY or TYNUM) @@ -2392,7 +2372,6 @@ LOCAL RC FC fcnArgs( // parse args for regular-case built-in function, and som if ((wanTy & TYNUM)==TYFL) // if compiling a float expression (incl TYNC, TYFLSTR), aWanTy &= ~(TYSI|TYINT); // float args ASAP to not truncate 2400*300 to 16 bits nor 2/3 to 0 -- // too much user confusion occurred from C-like integer operations. -#endif // parse argument expression (value-expr for choose or select) @@ -2418,7 +2397,7 @@ LOCAL RC FC fcnArgs( // parse args for regular-case built-in function, and som #endif ); else // issue err msg - return perNx( (char *)MH_S0046, // "Syntax error: expected '%s'" + return perNx( MH_S0046, // "Syntax error: expected '%s'" uAN < f->nA ? "," : (f->f & VA && !defa) ? ",' or ')" : ")" ); @@ -2499,9 +2478,9 @@ x } SI an1 = (optn & 8) ? ann - 2*i : ann - i; // arg # of other arg that failed the check // optn & 8: condexpr b4 each arg. done right here? if so, why copped out in TYNUM case (next)? 2-92 char *anTx = (nSF < aN) ? "" // if code already generated (VC), arg #'s unknown - : strtprintf(" %d and %d",(INT)an1,(INT)ann); // arg # subtext eg " 1 and 3" - return perNx( (char *)MH_S0047, // "Incompatible arguments%s to '%s':\n".. - anTx, (char *)f->id, // " can't mix '%s' and '%s'" + : strtprintf(" %d and %d",an1,ann); // arg # subtext eg " 1 and 3" + return perNx( MH_S0047, // "Incompatible arguments%s to '%s':\n".. + anTx, f->id, // " can't mix '%s' and '%s'" datyTx(argType), datyTx(anTy)); } } @@ -2532,7 +2511,7 @@ x break; #ifdef LOCFCN * // VC can't work on both sides as onLeft not known (by caller) til after arg list done * if ( (f->f & (LOK|ROK))==(LOK|ROK) ) // "Internal error in cuparse.cpp:fcnArgs:\n" ... -* return perNx( (char *)MH_S0048, (char *)f->id ); // " bad fcn table entry for '%s': VC, LOK, ROK all on" +* return perNx( MH_S0048, f->id ); // " bad fcn table entry for '%s': VC, LOK, ROK all on" #else // MH_S0048 probably no longer used 2-95. #endif @@ -2554,12 +2533,12 @@ x break; // check # args if (uAN < f->nA) - return perNx( (char *)MH_S0049, // "Too few arguments to built-in function '%s': %d not %d%s" - (char *)f->id, INT(uAN+nA0), INT(f->nA+nA0), + return perNx( MH_S0049, // "Too few arguments to built-in function '%s': %d not %d%s" + f->id, uAN+nA0, f->nA+nA0, (f->f & VA) ? " or more" : "" ); else if (uAN > f->nA && !(f->f & VA) ) - return perNx( (char *)MH_S0050, // "Too many arguments to built-in function '%s': %d not %d" - (char *)f->id, INT(uAN+nA0), INT(f->nA+nA0) ); + return perNx( MH_S0050, // "Too many arguments to built-in function '%s': %d not %d" + f->id, uAN+nA0, f->nA+nA0 ); // if no default, optionally generate one using .op2 @@ -2619,7 +2598,7 @@ LOCAL RC FC emiFcn( // emit code for FCREG built-in function with given arg 1 * if (f->f & ROK) * if (f->f & LOK) * if (f->a1Ty==TYNUM) -* return perNx( (char *)MH_S0051, (char *)f->id ); // "Internal error in cuparse.cpp:emiFcn: bad function table entry for '%s'" +* return perNx( MH_S0051, f->id ); // "Internal error in cuparse.cpp:emiFcn: bad function table entry for '%s'" #endif // emit appropropriate code @@ -2687,9 +2666,9 @@ LOCAL RC FC sysVar( SVST *v, USI wanTy) ERVARS1 ERSAVE #ifndef LOKSV - printif( trace," sysVar(%s,%d) ", v->id, (INT)wanTy); + printif( trace," sysVar(%s,%d) ", v->id, wanTy); #else - * printif( trace," sysVar(%s,%d,%d) ", v->id, (INT)toprec, (INT)wanTy); + * printif( trace," sysVar(%s,%d,%d) ", v->id, toprec, wanTy); #endif switch (v->cs) { @@ -2701,14 +2680,14 @@ LOCAL RC FC sysVar( SVST *v, USI wanTy) #ifndef LOKSV if (tokeIf(CUTEQ)) // if '=' follows the variable name { - rc = perNx( (char *)MH_S0052, v->id); // "System variable '%s' may not be assigned a value" + rc = perNx( MH_S0052, v->id); // "System variable '%s' may not be assigned a value" goto er; } #else * SI onLeft = tokeIf(CUTEQ); // '=' next? else unToke. Get 1 if sys var being assigned a value. * if (onLeft) // if yes * { if (!(v->f & LOK)) // ok for this fcn? -* { rc = perNx( (char *)MH_S0052, v->id); // "System variable '%s' may not be assigned a value" +* { rc = perNx( MH_S0052, v->id); // "System variable '%s' may not be assigned a value" * goto er; * } * // get value of var's type to be assigned to function @@ -2718,7 +2697,7 @@ LOCAL RC FC sysVar( SVST *v, USI wanTy) * v->id, 0 ) ) * if (wanTy != TYDONE) // if context is "expression desired" * if (nextPrec > PRCOM) // if not , ) ] ; verb EOF next -* perlc( (char *)MH_S0036); // "Nested assignment should be enclosed in ()'s to avoid ambiguity" +* perlc( MH_S0036); // "Nested assignment should be enclosed in ()'s to avoid ambiguity" * // CAUTION: MH_S0036 also used in fcnReg() and dumVar(). * // message but keep compiling at same place * // code for sys var assignment @@ -2739,7 +2718,7 @@ LOCAL RC FC sysVar( SVST *v, USI wanTy) // "right side use" -- sys var value used in expression #ifdef LOKSV // else all have ROK, skip check 2-95 * if (!(v->f & ROK)) // check if ok for this fcn -* { rc = perNx( (char *)MH_S0053, (char *)v->id ); // "System variable '%s' may only be used left of '=' --\n" ... +* { rc = perNx( MH_S0053, (char *)v->id ); // "System variable '%s' may only be used left of '=' --\n" ... * goto er; // " it can be assigned a value but does not have a value" * } // cast v->id to insure far ptr in variable arg list #else @@ -2774,9 +2753,9 @@ LOCAL RC FC uFcn( UFST *stb ) // compile call to user function aN = 0; // arg counter if (tokeNot(CUTLPR)) // ( required return perNx( stb->nA==0 // special errMsg for 0 arg fcn - ? (char *)MH_S0054 // "'(' expected: functions '%s' takes no arguments \n" ... + ? MH_S0054 // "'(' expected: functions '%s' takes no arguments \n" ... // " but nevertheless requires empty '()'" - : (char *)MH_S0055, // "'(' expected after function name '%s'" + : MH_S0055, // "'(' expected after function name '%s'" stb->id ); if (tokeIf(CUTRPR)==0) // unless ) next: empty argList. ')' gobbled. { @@ -2791,13 +2770,13 @@ LOCAL RC FC uFcn( UFST *stb ) // compile call to user function } while (tokeTest(CUTCOM)); // get separator / args loop endtest if (tokTy != CUTRPR) - return perNx( aN >= stb->nA ? (char *)MH_S0056 // "')' expected" - : (char *)MH_S0039 ); // "',' expected" CAUTION multiply used msg handle + return perNx( aN >= stb->nA ? MH_S0056 // "')' expected" + : MH_S0039 ); // "',' expected" CAUTION multiply used msg handle } if (aN != stb->nA) - return perNx( (char *)MH_S0057, // "Too %s arguments to '%s': %d not %d" + return perNx( MH_S0057, // "Too %s arguments to '%s': %d not %d" aN > stb->nA ? "many" : "few", - stb->id, (INT)aN, (INT)stb->nA ); + stb->id, aN, stb->nA ); /* code has now been emitted to stack argument values, in order. PSCALA sets up stack frame whereby code in fcn (generated by dumVar) accesses values; @@ -2861,7 +2840,7 @@ x if (strcmp( p->id, cuToktx)==0) if (wanTy != TYDONE) // if context is "expression desired" { if (nextPrec > PRCOM) // if not , ) ] ; verb type EOF next - pWarnlc( (char *)MH_S0036 ); // "Nested assignment should be enclosed in ()'s to avoid ambiguity" 3-use MH! + pWarnlc( MH_S0036 ); // "Nested assignment should be enclosed in ()'s to avoid ambiguity" 3-use MH! #if 0//rc lost at next EE macro x rc |= emiDup(); // duplicate stack top #else//12-14-94 @@ -2895,7 +2874,7 @@ x rc |= emiDup(); // duplicate stack top break; default: - rc = perNx( (char *)MH_S0058); + rc = perNx( MH_S0058); goto er; // "Internal error: bug in cuparse.cpp:dumVar switch" } /*lint +e616 */ if (rc==RCOK) @@ -2926,7 +2905,7 @@ LOCAL RC FC var([[maybe_unused]] UVST *f, [[maybe_unused]] USI wanTy) // parse see fcn() -- largely similar, but no arg list (subscripts: save for later) */ - return perNx( (char *)MH_S0059); // "User variables not implemented" + return perNx( MH_S0059); // "User variables not implemented" /* ... remember that DECLARE should disallow $ as 1st char user variable */ /* ... remember to add to symbol table case-sensitive (casi arg 0) */ @@ -2938,7 +2917,7 @@ LOCAL RC FC expSi( // get an integer expression for a condition. accepts & fix SI toprec, // precedence to which to parse -- eg PRCOM SI *pisKon, // NULL or receives non-0 if is constant SI *pv, // NULL or receives value if constant - char *tx, // text of preceding operator or fcn name, for errMsgs + const char *tx, // text of preceding operator or fcn name, for errMsgs SI aN ) // 0 or fcn argument number, for errMsgs // *pisKon and *pv receive info for code optimization by elminating conditional code when condition is constant. @@ -2958,7 +2937,7 @@ LOCAL RC FC convSi( // convert last expr to int, else issue error. konstizes. SI* pisKon, // NULL or receives non-0 if is constant SI *pvPar, // NULL or receives value if constant SI b4, // for errMsgs: 1 if expr b4 ; 0 expr after; moot if aN. - char *tx, // text of preceding operator or fcn name, for errMsgs + const char *tx, // text of preceding operator or fcn name, for errMsgs SI aN ) // 0 or fcn argument number, for errMsgs // *pisKon and *pv receive info for code optimization by eliminating conditional code when condition is constant @@ -2978,7 +2957,7 @@ LOCAL RC FC convSi( // convert last expr to int, else issue error. konstizes. break; // already integer, ok. default: - return perNx( (char *)MH_S0060, b4 ? before(tx,aN) : after(tx,aN) ); // "Integer value required%s" + return perNx( MH_S0060, b4 ? before(tx,aN) : after(tx,aN) ); // "Integer value required%s" } SI isKon; @@ -3113,7 +3092,7 @@ LOCAL RC FC utconvN( // do "usual type conversions" to match last n NUMERIC ex case TYSI: break; default: - rc = perNx( (char *)MH_S0061, // "Numeric expression required%s". suspect can't now occur ('90..2-92) + rc = perNx( MH_S0061, // "Numeric expression required%s". suspect can't now occur ('90..2-92) aN==0 ? i==0 ? after(tx,0) : before(tx,0) // operator: args b4 and after : asArg(tx, aN > i ? aN-i : -1 ) ); // fcn: use arg # aN-i @@ -3214,7 +3193,7 @@ RC FC konstize( // if possible, evaluate current (sub)expression (parSp) now an #endif } // if ms==NULL assume cuEvalR issued message (unexpected). - perNx(NULL); // skip input to next statement. ** believe perNx appropriate, but not here til 2-91. + perNx(MSGORHANDLE()); // skip input to next statement. ** believe perNx appropriate, but not here til 2-91. goto er; // error exit like EE macro } @@ -3404,7 +3383,7 @@ LOCAL USI FC cleanEvf( // clean up eval frequency bits #if 0 /* 11-25-95 make functions work: EVFDUMMY normally gets here. x Rest of this fcn appears to pass EVFDUMMY thruough; cleanEvf changed to do so; also changes in expr, exOrk. */ x if (evf & EVFDUMMY) -x perlc( (char *)MH_S0062); // "Internal error in cuparse.cpp:cleanEvf: Unexpected 'EVFDUMMY' flag" +x perlc( MH_S0062); // "Internal error in cuparse.cpp:cleanEvf: Unexpected 'EVFDUMMY' flag" #endif #if 0 // historical. problem: converted MON|HR to MH in context where HR was appropriate (BUG0066). @@ -3474,9 +3453,9 @@ LOCAL RC FC cnvPrevSf( // append (conversion) operation to ith previous express { if (!ISNUM(*(void **)(pspe-2))) // test the constant value: if any non-number (cnglob.h macro) if (ISNCHOICE(*(void **)(pspe-2))) // conversion fails NOW - return perNx( (char *)MH_S0063); // "Expected numeric value, found choice value". Explain to user. + return perNx( MH_S0063); // "Expected numeric value, found choice value". Explain to user. else - return perNx( (char *)MH_S0064); // "Numeric value required". (unexpected) NANDLE or bug. + return perNx( MH_S0064); // "Numeric value required". (unexpected) NANDLE or bug. return RCOK; // its already a number, needn't store conversion } // else: LATER 2-92 consider looking for single probe in stack frame, @@ -3518,10 +3497,10 @@ LOCAL RC FC cnvPrevSf( // append (conversion) operation to ith previous express { ULI v; // rcvs value, including special choicn hi bits USI sz; // rcvs size, 2 or 4 - const char *ms; // rcvs msg insert: "'%s' not one of x y z ..." + MSGORHANDLE ms; // rcvs msg insert: "'%s' not one of x y z ..." if (cvS2Choi( (char *)(psp1+2), choiDt, (void *)&v, &sz, &ms)==RCBAD) // get choice value for string, cvpak.cpp - return perNx( (char *)MH_S0065, ms); // "%s\n (or perhaps invalid mixing of string and numeric values)" - ms = NULL; // insurance, drop possible info msg from cvS2Choi + return perNx( MH_S0065, ms); // "%s\n (or perhaps invalid mixing of string and numeric values)" + ms.mh_Clear(); // insurance, drop possible info msg from cvS2Choi // code to output (on fallthru); matches emiKon. op1 = PSKON2; // op code for 2-byte constant op2 = (USI)v; // 2 bytes of choice value @@ -3549,7 +3528,7 @@ LOCAL RC FC cnvPrevSf( // append (conversion) operation to ith previous express { SI make = -xspace; // positive # PSOP spaces to make: less confusing if (i && parSpe->psp2 != (parSpe+1)->psp1) - return perNx( (char *)MH_S0066); // "Internal error in cuparse.cpp:cnvPrevSf: expressions not consecutive" + return perNx( MH_S0066); // "Internal error in cuparse.cpp:cnvPrevSf: expressions not consecutive" // don't know what to move where CSE_E( movPsLastN( i, make) ) /* move last i exprs (parSp-(0..i-1)) to make space for 'make' PSOPs b4 them. terminates. */ @@ -3586,7 +3565,7 @@ LOCAL RC FC cnvPrevSf( // append (conversion) operation to ith previous express && !i ) // save to compress if is last frame (jmp poss in other frame? may be unnec restriction 2-92) { if (pspe+xspace+sizeJmp != parSpe->psp2) - perlc( (char *)MH_S0067, pspe+xspace, parSpe->psp2 ); // "Internal error in cuparse.cpp:cnvPrevSf:\n pspe+.. %p != psp2 %p" + perlc( MH_S0067, pspe+xspace, parSpe->psp2 ); // "Internal error in cuparse.cpp:cnvPrevSf:\n pspe+.. %p != psp2 %p" *pspe++ = PSNOP; *pspe++ = PSNOP; // leave 2 nops 2-92 (insurance ?? any need for this) @@ -3615,7 +3594,7 @@ RC FC newSf() // start new parse stack frame: call at start statement or (sub)e { // overflow check if ((char *)parSp >= (char *)parStk + sizeof(parStk) - sizeof(PARSTK) ) - return perNx( (char *)MH_S0068 ); // "Parse stack overflow error: expression probably too complex" + return perNx( MH_S0068 ); // "Parse stack overflow error: expression probably too complex" // terminate current frame if any /* .psp2 is used to append conversions and for consistency checks. @@ -3650,7 +3629,7 @@ RC FC combSf() // combine top two parStk frames, with second frame dominant if (parSp1->psp2 != parSp->psp1) { /* 2nd expr not right after 1st --> don't know what to move */ - return perNx( (char *)MH_S0069); // "Internal Error in cuparse.cpp:combSf: expressions not consecutive" + return perNx( MH_S0069); // "Internal Error in cuparse.cpp:combSf: expressions not consecutive" } parSp1->evf |= parSp->evf; // eval frequency: most frequent parSp1->did |= parSp->did; // merge "did something" flags @@ -3677,7 +3656,7 @@ RC FC dropSfs( // discard parse stack frame(s) PARSTK * d1, * dn, * k1, * p; USI psMove; if (n < 0 || k < 0) // devel aid - return perNx( (char *)MH_S0070, (INT)k, (INT)n); // "Internal error: bad call to cuparse.cpp:dropSfs( %d, %d)" + return perNx( MH_S0070, k, n); // "Internal error: bad call to cuparse.cpp:dropSfs( %d, %d)" if (n==0) // rif nothing to drop return RCOK; // (but k=0 is valid) //kn = parSp; // last frame being kept: just use parSp @@ -3686,7 +3665,7 @@ RC FC dropSfs( // discard parse stack frame(s) d1 = k1-n; // first parStk frame being dropped psMove = (USI)(dn->psp2 - d1->psp1); // - how far code moves if (k > 0 && dn->psp2 != k1->psp1) - err( PWRN, (char *)MH_S0071); // display internal err msg "confusion (1) in dropSfs" + err( PWRN, MH_S0071); // display internal err msg "confusion (1) in dropSfs" // move stuff being retained into space of dropped stuff memmove( d1->psp1, dn->psp2, // move code AND TERMINATOR @@ -3704,7 +3683,7 @@ RC FC dropSfs( // discard parse stack frame(s) if (parSp->psp2 + psMove == psp) psp -= psMove; // free space of dropped code else // bug or non-contiguous code - err( PWRN, (char *)MH_S0072); // display internal err msg "confusion (2) in dropSfs" + err( PWRN, MH_S0072); // display internal err msg "confusion (2) in dropSfs" return RCOK; } // dropSfs @@ -3722,11 +3701,11 @@ LOCAL RC FC movPsLastN( // checks if (psp != parSp->psp2) - return perNx( (char *)MH_S0073); // "Internal error in cuparse.cpp:movPsLast: expression not last in ps." + return perNx( MH_S0073); // "Internal error in cuparse.cpp:movPsLast: expression not last in ps." for (i = 1; i < nFrames; i++) // nFrames-1 checks if ((parSp-i)->psp2 != (parSp-i+1)->psp1) - return perNx( (char *)MH_S0074); // "Internal error in cuparse.cpp:movPsLast: expressions not consecutive" + return perNx( MH_S0074); // "Internal error in cuparse.cpp:movPsLast: expressions not consecutive" while (psp + nPsc >= pspMax) // if will overflow buffer CSE_E( emiBufFull() ) // reallocate (future) or issue msg; if failed to enlarge, ret bad. @@ -3782,7 +3761,7 @@ LOCAL RC FC fillJmp( SI i) // fill jmp address where = (parSp-i)->psp2 - 1; // last PSOP of prior block if (*where != 0xffff) // 0xffff was emitted to hold space - return perNx( (char *)MH_S0075 ); // "Internal error in cuparse.cpp:fillJmp: address place holder not found in Jump" + return perNx( MH_S0075 ); // "Internal error in cuparse.cpp:fillJmp: address place holder not found in Jump" *where = (PSOP)(psp - where); // offset from own location to location of NEXT op emitted return RCOK; @@ -3800,7 +3779,7 @@ LOCAL RC FC dropJmpIf() // delete unfilled trailing jmp in top parStk frame, if if (psp==pspe) // != unexpected psp -= 2; // free global code space else - err( PWRN, (char *)MH_S0076); // display internal err msg "confusion in dropJmpIf" + err( PWRN, MH_S0076); // display internal err msg "confusion in dropJmpIf" } return RCOK; } // dropJmpIf @@ -3842,7 +3821,7 @@ RC CDEC emiKon( // emit code to load constant w/o calling here, when const string conv to choice.*/ if (choiDt & DTBCHOICN) goto fourBytes; // determine choice size FROM FILE-GLOBAL choiDt if (choiDt & DTBCHOICB) goto twoBytes; // .. - rc = perNx( (char *)MH_S0077, choiDt); // "Internal Error in cuparse.cpp:emiKon:\n" ... + rc = perNx( MH_S0077, choiDt); // "Internal Error in cuparse.cpp:emiKon:\n" ... goto er; // " no recognized bit in choiDt value 0x%x" case TYSI: @@ -3892,7 +3871,7 @@ RC CDEC emiKon( // emit code to load constant break; default: - rc = perNx( (char *)MH_S0078); + rc = perNx( MH_S0078); goto er; // "Bug in cuparse.cpp:emiKon switch" } /*lint -e616 */ @@ -3918,7 +3897,7 @@ LOCAL RC FC emiLod( USI ty, void *p) // emit code to load datum of type ty from EE( emit(PSLOD4) ) break; default: - rc = perNx( (char *)MH_S0079); + rc = perNx( MH_S0079); goto er; // "Bug in cuparse.cpp:emiLod switch" } /*lint +e616 */ @@ -3935,7 +3914,7 @@ LOCAL RC FC emiLod( USI ty, void *p) // emit code to load datum of type ty from * ERVARS1 * * ERSAVE -* printif( trace," emiSto(%d,%p) ", (INT)dup1st, p); +* printif( trace," emiSto(%d,%p) ", dup1st, p); * * if (dup1st) // on flag, first dup value on stack * EE( emiDup() ) // ... for nested sets @@ -3948,7 +3927,7 @@ LOCAL RC FC emiLod( USI ty, void *p) // emit code to load datum of type ty from * /*lint -e616 case falls in*/ * case TYFL: EE( emit(PSSTO4) ) break; * -* default: rc = perNx( (char *)MH_S0080); goto er; // "Bug in cuparse.cpp:emiSto switch" +* default: rc = perNx( MH_S0080); goto er; // "Bug in cuparse.cpp:emiSto switch" *} /*lint -e616 */ * * EE( emit4( &p) ) // address of variable follows op code @@ -3979,7 +3958,7 @@ LOCAL RC FC emiDup() // emit code to dup run stack top value EE( emit(PSDUP4) ) break; default: - rc = perNx( (char *)MH_S0081); + rc = perNx( MH_S0081); goto er; // "Bug in cuparse.cpp:emiDup switch" } /*lint -e616 */ return RCOK; @@ -4005,11 +3984,11 @@ LOCAL RC FC emiPop() // emit additional code to discard any value left on run s EE( emit(PSPOP4) ) doesit: if (parSp->did==0) // if no store nor side effect - pWarnlc( (char *)MH_S0082); // "Preceding code has no effect" + pWarnlc( MH_S0082); // "Preceding code has no effect" break; default: - rc = perNx( (char *)MH_S0083); + rc = perNx( MH_S0083); goto er; // "Bug in cuparse.cpp:emiPop switch" } /*lint -e616 */ parSp->ty = TYDONE; // now have complete statement @@ -4116,7 +4095,7 @@ LOCAL RC FC emiBufFull( void) // pseudo-code buffer full handler psFull++; // set full flag, tested in statement(). flag important because ERREX may restore psp. - return perl( (char *)MH_S0084); // "Compiled code buffer full, ceasing compilation" + return perl( MH_S0084); // "Compiled code buffer full, ceasing compilation" } // emiBufFull @@ -4414,14 +4393,14 @@ LOCAL const char* FC asArg( // errMsg subtext: " as argument[ n][ to 'f']" int aN ) // argument number, or -1 to omit { return strtprintf( " as argument%s%s", - aN < 0 ? "" : strtprintf(" %d", (INT)aN), // -1: unspecified arg# + aN < 0 ? "" : strtprintf(" %d", aN), // -1: unspecified arg# tx==NULL ? "" : strtprintf(" to '%s'", tx) ); } // asArg //========================================================================== LOCAL const char* FC datyTx( USI ty) // return text for data type { - MH mh; // handle for disk text. see h\msghans.h, lib\messages.cpp. + MH mh; switch (ty) { case TYNONE: @@ -4478,7 +4457,7 @@ LOCAL const char* FC datyTx( USI ty) // return text for data type break; // "" //MH_S0101,MH_S0102 avail for additions 10-92. } - return msg( NULL, (char *)mh); // fetch text for handler from disk to tmpStr, lib\messages.cpp. 10-92. + return msg( NULL, mh); // fetch text for handler from disk to tmpStr, lib\messages.cpp. 10-92. } // datyTx //========================================================================== const char* FC evfTx( // text for eval freq bits, to insert in message @@ -4531,12 +4510,12 @@ x // handle EVFDUMMY here if found necessary else if (evf==0) mh = adverb ? MH_S0121 // "never" (Use unexpected) : MH_S0122; // "no" .. } - return msg( NULL, (char *)mh, evf); // get text from disk, 10-92. + return msg( NULL, mh, evf); // get text from disk, 10-92. // evf is for %x in bad-value msg to whose handle mh was init. } // evfTx //========================================================================== -RC CDEC per( const char *ms, ...) // basic error message: No input line display nor file name/line # display. +RC CDEC per( MSGORHANDLE ms, ...) // basic error message: No input line display nor file name/line # display. // Also see following fcns: perl(),perNx(),perlc(),pWarn(),pWarnlc(),pInfol, etc. @@ -4547,7 +4526,7 @@ RC CDEC per( const char *ms, ...) // basic error message: No input line display return perI( 0, 0, 0, ms, ap); // message, ret RCBAD } // per //========================================================================== -RC CDEC perl( const char *ms, ...) // Error message with input file name and line #. No line text display. +RC CDEC perl( MSGORHANDLE ms, ...) // Error message with input file name and line #. No line text display. // returns RCBAD { @@ -4556,7 +4535,7 @@ RC CDEC perl( const char *ms, ...) // Error message with input file name and li return perI( 0, 1, 0, ms, ap); // message, ret RCBAD } // perl //========================================================================== -RC CDEC perlc( const char *ms, ...) // issue parse ERROR message with input line text, ^, file name & line # +RC CDEC perlc( MSGORHANDLE ms, ...) // issue parse ERROR message with input line text, ^, file name & line # // returns RCBAD { va_list ap; @@ -4564,7 +4543,7 @@ RC CDEC perlc( const char *ms, ...) // issue parse ERROR message with input lin return perI( 1, 1, 0, ms, ap); // message, ret RCBAD } // perlc //========================================================================== -RC CDEC pWarn( const char *ms, ...) // issue plain parse WARNING message WITHOUT input line text, caret, file name, line # +RC CDEC pWarn( MSGORHANDLE ms, ...) // issue plain parse WARNING message WITHOUT input line text, caret, file name, line # // returns RCOK { va_list ap; @@ -4572,7 +4551,7 @@ RC CDEC pWarn( const char *ms, ...) // issue plain parse WARNING message WITHOU return perI( 0, 0, 1, ms, ap); // message, ret RCOK } // pWarn //========================================================================== -RC CDEC pWarnlc( const char *ms, ...) // issue parse WARNING message with input line text, ^, file name & line # +RC CDEC pWarnlc( MSGORHANDLE ms, ...) // issue parse WARNING message with input line text, ^, file name & line # // returns RCOK { va_list ap; @@ -4580,7 +4559,7 @@ RC CDEC pWarnlc( const char *ms, ...) // issue parse WARNING message with input return perI( 1, 1, 1, ms, ap); // message, ret RCOK } // pWarnlc //========================================================================== -RC CDEC pInfo( const char *ms, ...) // issue parse INFO message WITHOUT input line text, caret, file name, line #. +RC CDEC pInfo( MSGORHANDLE ms, ...) // issue parse INFO message WITHOUT input line text, caret, file name, line #. // returns RCOK { va_list ap; @@ -4588,7 +4567,7 @@ RC CDEC pInfo( const char *ms, ...) // issue parse INFO message WITHOUT input l return perI( 0, 0, 2, ms, ap); // message, ret RCOK } // pInfo //========================================================================== -RC CDEC pInfol( const char *ms, ...) // issue parse INFO message with file name & line #. no input line display. +RC CDEC pInfol( MSGORHANDLE ms, ...) // issue parse INFO message with file name & line #. no input line display. // returns RCOK { va_list ap; @@ -4597,7 +4576,7 @@ RC CDEC pInfol( const char *ms, ...) // issue parse INFO message with file name } // pInfol //========================================================================== -RC CDEC pInfolc( const char *ms, ...) // issue parse INFO message with file name & line #, line, and caret +RC CDEC pInfolc( MSGORHANDLE ms, ...) // issue parse INFO message with file name & line #, line, and caret // returns RCOK { va_list ap; @@ -4605,7 +4584,7 @@ RC CDEC pInfolc( const char *ms, ...) // issue parse INFO message with file name return perI( 1, 1, 2, ms, ap); // message, ret RCOK } // pInfolc //============================================================================== -RC CDEC perNx( const char *ms, ...) +RC CDEC perNx( MSGORHANDLE ms, ...) // issue parse Error message with input line text, ^, file name & line #, and/or SKIP INPUT TO NEXT STATEMENT. Uses "inFlist". @@ -4616,7 +4595,7 @@ RC CDEC perNx( const char *ms, ...) return perNxV( 0, ms, ap); } // perNx //========================================================================== -RC CDEC pWarnNx( const char *ms, ...) +RC CDEC pWarnNx( MSGORHANDLE ms, ...) // issue parse Warning message with input line text, ^, file name & line #, and/or SKIP INPUT TO NEXT STATEMENT. Uses "inFlist". @@ -4629,7 +4608,7 @@ RC CDEC pWarnNx( const char *ms, ...) //========================================================================== RC FC perNxV( int isWarn, // 0=error, 1=warning, 2=info - const char *ms, va_list ap) + MSGORHANDLE ms, va_list ap) // ptr to arg list versn: parse err msg w input text, ^, file name & line #, // and/or SKIP INPUT TO NEXT STATEMENT. Uses "inFlist". @@ -4639,7 +4618,7 @@ RC FC perNxV( RC rc; /* issue message if given */ - if (ms != NULL) + if (!ms.mh_IsNull()) rc = perI( 1, 1, isWarn, ms, ap); // message, ret RCBAD else // just skipping to ';' after error msg'd elsewhere rc = !isWarn ? RCBAD : RCOK; // no-msg return value @@ -4706,7 +4685,7 @@ RC FC perNxV( return rc; } // perNxV //========================================================================== -LOCAL RC FC perI( int showTx, int showFnLn, int isWarn, const char* ms, va_list ap) // parse error message inner fcn +LOCAL RC FC perI( int showTx, int showFnLn, int isWarn, MSGORHANDLE ms, va_list ap) // parse error message inner fcn // counts errors (not warnings/infos) in rmkerr.cpp error counter. diff --git a/src/cuparse.h b/src/cuparse.h index b39c36ef4..52c253043 100644 --- a/src/cuparse.h +++ b/src/cuparse.h @@ -28,17 +28,17 @@ RC FC cuAddItSyms( SI tokTyPar, SI casi, STBK *tbl, USI entLen, int op); const char * FC evfTx( USI evf, SI adverb); -RC CDEC per( const char* msg, ...); -RC CDEC perl( const char* msg, ...); -RC CDEC perlc( const char* msg, ...); -RC CDEC pWarn( const char* msg, ...); -RC CDEC pWarnlc( const char* msg, ...); -RC CDEC pInfo( const char* msg, ...); -RC CDEC pInfol( const char* msg, ...); -RC CDEC pInfolc( const char* msg, ...); -RC CDEC perNx( const char* msg, ...); -RC CDEC pWarnNx( const char* msg, ...); -RC FC perNxV( int isWarn, const char* msg, va_list ap); +RC CDEC per( MSGORHANDLE msg, ...); +RC CDEC perl( MSGORHANDLE msg, ...); +RC CDEC perlc( MSGORHANDLE msg, ...); +RC CDEC pWarn( MSGORHANDLE msg, ...); +RC CDEC pWarnlc( MSGORHANDLE msg, ...); +RC CDEC pInfo( MSGORHANDLE msg, ...); +RC CDEC pInfol( MSGORHANDLE msg, ...); +RC CDEC pInfolc( MSGORHANDLE msg, ...); +RC CDEC perNx( MSGORHANDLE msg, ...); +RC CDEC pWarnNx( MSGORHANDLE msg, ...); +RC FC perNxV( int isWarn, MSGORHANDLE msg, va_list ap); void FC curLine( int retokPar, int* pFileIx, int* pline, int* pcol, char *s, size_t sSize); diff --git a/src/cuprobe.cpp b/src/cuprobe.cpp index 4daa16d76..893ae2b80 100644 --- a/src/cuprobe.cpp +++ b/src/cuprobe.cpp @@ -35,7 +35,7 @@ struct PROBEOBJECT // info probe() shares with callees: pass single pointer { BP inB; // 0 or input basAnc found with given name, 0'd if member name not found (0 is "near NULL") BP runB; // 0 or run basAnc found with given name, 0'd if member name not found - char* what; // name (.what) of basAnc(s) whose records being probed + const char* what; // name (.what) of basAnc(s) whose records being probed SFIR* inF, * runF; // pointers to "fields-in-record" tables (srfd.cpp) for input and run rats const char* mName; // name of member being probed USI inFn, runFn; // input and run basAnc field numbers @@ -66,7 +66,7 @@ RC FC probe() toke(); // get token if (!isWord) // accept any word even if predefined or reserved - return perNx( (char *)MH_U0001); // "U0001: Expected word for class name after '@'" + return perNx( MH_U0001); // "U0001: Expected word for class name after '@'" BP b = nullptr; PROBEOBJECT o; // contains local variables passed to callees. CAUTION: recursion possible, don't use statics. @@ -74,22 +74,22 @@ RC FC probe() { if (b->ba_flags & RFTYS) // if a "types" basAnc continue; // accept no probes; keep looking for input & run rats with same name - if (!_stricmp( (char *)b->what, cuToktx)) // will probably need to take _'s as spaces ... 12-91 + if (!_stricmp( b->what, cuToktx)) // will probably need to take _'s as spaces ... 12-91 { if (b->ba_flags & RFINP ? o.inB : o.runB) - return perNx( (char *)MH_U0002, + return perNx( MH_U0002, // "U0002: Internal error: Ambiguous class name '%s':\n" // " there are TWO %s rats with that .what. Change one of them.", - (char *)b->what, b->ba_flags & RFINP ? "input" : "run" ); + b->what, b->ba_flags & RFINP ? "input" : "run" ); if (b->ba_flags & RFINP) o.inB = b; else o.runB = b; - o.what = (char *)b->what; // for many error messages + o.what = b->what; // for many error messages } } if (!o.runB && !o.inB) - return perNx( (char *)MH_U0003, cuToktx); // "U0003: Unrecognized class name '%s'" + return perNx( MH_U0003, cuToktx); // "U0003: Unrecognized class name '%s'" // parse & emit record identifier in []'s: unquoted identifier, string name expression, numeric subscript expression @@ -102,7 +102,7 @@ RC FC probe() CSE_E( konstize( &o.ssIsK, &o.pSsV, 0 ) ) // determine if constant/get value, re immediate input probes, below. // evals if evaluable and un-eval'd, rets flag and pointer if (tokeNot(CUTRB)) - return perNx( (char *)MH_U0004, // "U0004: Expected ']' after object %s" + return perNx( MH_U0004, // "U0004: Expected ']' after object %s" o.ssTy==TYSI ? "subscript" : "name"); } else @@ -122,14 +122,14 @@ RC FC probe() unToke(); // unget the . and fall thru } else - return perNx( (char *)MH_U0005); // "U0005: Expected '[' after @ and class name" + return perNx( MH_U0005); // "U0005: Expected '[' after @ and class name" o.ssTy = parSp->ty; // save type of subscript expression: TYSI or TYSTR // get . and composite field 'name'. 'name' can be: abc, abc.def, abc[0], abc[0].def, etc. - if (tokeNot(CUTPER)) return perNx( (char *)MH_U0006); // "U0006: Expected '.' after ']'" require . + if (tokeNot(CUTPER)) return perNx( MH_U0006); // "U0006: Expected '.' after ']'" require . if (findMember(&o)) // get & look up composite member name (below) / ret if not found or other err. return RCBAD; // ... sets o.inF and/or o.runF; clears o.inB/o.runB if input does not match. @@ -144,18 +144,18 @@ RC FC probe() if (o.inB) inDt = sFdtab[o.inF->fi_fdTy].dtype; // fetch recdef DT_____ data type for input record member if (o.runB) runDt = sFdtab[o.runF->fi_fdTy].dtype; // ... run record member if (o.inB && o.runB && inDt != runDt) // error if inconsistent - return perNx( (char *)MH_U0007, + return perNx( MH_U0007, //"U0007: Internal error: %s member '%s'\n" //" has data type (dt) %d in input rat but %d in run rat.\n" //" It cannot be probed until tables are made consistent.\n", - o.what, o.mName, (INT)inDt, (INT)runDt ); + o.what, o.mName, inDt, runDt ); o.dt = o.inB ? inDt : runDt; // get a single data type value PSOP lop; const char* errSub; if (lopNty4dt( o.dt, &o.ty, &o.sz, &lop, &errSub)) // get ty, size, and instruction for dt, below / if bad - return perNx( (char *)MH_U0008, // "U0007: %s member '%s' has %s data type (dt) %d" - o.what, o.mName, errSub, (INT)o.dt ); + return perNx( MH_U0008, // "U0007: %s member '%s' has %s data type (dt) %d" + o.what, o.mName, errSub, o.dt ); // decide probe method to use // nb giving input time probes priority assumes run member @@ -261,7 +261,7 @@ LOCAL RC FC findMember( PROBEOBJECT *o) // parse and look up probe member name i // get (first token of) member name. Allow duplication of reserved words. toke(); // 1st token of name - if (!isWord) return perNx( (char *)MH_U0010, + if (!isWord) return perNx( MH_U0010, // "U0010: Expected a word for object member name, found '%s'" cuToktx ); @@ -318,11 +318,11 @@ LOCAL RC FC findMember( PROBEOBJECT *o) // parse and look up probe member name i if (!o->inB && !o->runB) // if found in neither input nor run records basAnc if (!m) // if first token of name - return perNx( (char *)MH_U0011, o->what, cuToktx); // "U0011: %s member '%s' not found" + return perNx( MH_U0011, o->what, cuToktx); // "U0011: %s member '%s' not found" else // fancier error message for partial match { char* foundPart = strncpy0( NULL, MNAME( f1), m+1); // truncate to Tmpstr, lib\strpak.cpp - return perNx( (char *)MH_U0012, + return perNx( MH_U0012, //"U0012: %s member '%s%s' not found: \n" //" matched \"%s\" but could not match \"%s\"." o->what, foundPart, cuToktx, foundPart, cuToktx ); @@ -337,7 +337,7 @@ LOCAL RC FC findMember( PROBEOBJECT *o) // parse and look up probe member name i or could enhance following code to use whichever one matches input. Not expected frequently -- in and run usually use same fir table or have common substruct for similar parts. */ - return perNx( (char *)MH_U0013, + return perNx( MH_U0013, //"U0013: Internal error: inconsistent %s member naming: \n" //" input member name %s vs run member name %s. \n" //" member will be un-probe-able until tables corrected or \n" @@ -361,7 +361,7 @@ LOCAL RC FC findMember( PROBEOBJECT *o) // parse and look up probe member name i case '[': case ']': if (c != cuToktx[0]) - return perNx( (char *)MH_U0014, //"U0014: Expected '%c' next in %s member specification,\n" + return perNx( MH_U0014, //"U0014: Expected '%c' next in %s member specification,\n" c, o->what, cuToktx ); //" found '%s'" break; @@ -369,19 +369,19 @@ LOCAL RC FC findMember( PROBEOBJECT *o) // parse and look up probe member name i if (isalphaW(c)) { case '_': - if (!isWord) return perNx( (char *)MH_U0015, //"U0015: Expected word next in %s member specification,\n" + if (!isWord) return perNx( MH_U0015, //"U0015: Expected word next in %s member specification,\n" o->what, cuToktx); //" found '%s'" } else if (isdigitW(c)) { if (tokTy != CUTSI) - return perNx( (char *)MH_U0016, //"U0016: Expected number (subscript) next in %s \n" + return perNx( MH_U0016, //"U0016: Expected number (subscript) next in %s \n" o->what, cuToktx ); //" member specification, found '%s'" /* probably will want to add a (constant) numeric expression parse then canonicalize the value into cuToktx before continuing to text match */ } else - return perNx( (char *)MH_U0017, //"U0017: Internal error: unexpected next character '%c'" + return perNx( MH_U0017, //"U0017: Internal error: unexpected next character '%c'" c, o->what); //" in %s fir table member name", break; @@ -425,7 +425,7 @@ LOCAL RC FC tryImInProbe( PROBEOBJECT *o) i = *(SI*)o->pSsV; if (i > 0 && i <= b->n) // if subscript in range, e = &b->rec(*(SI*)o->pSsV); // point to record by number, else leave e NULL. - sprintf( iBuf, "[%d]", (INT)i); + sprintf( iBuf, "[%d]", i); name = iBuf; // make 'name' text for error messages break; @@ -442,7 +442,7 @@ LOCAL RC FC tryImInProbe( PROBEOBJECT *o) /*if (!evfOk) as below; add if found ambiguity error occurs here when caller fallthru to runtime probe could work */ if (trc==RCBAD2) // if ambiguity (not resolved by defO) - return perNx( (char *)MH_U0020, // "U0020: %s name '%s' is ambiguous: 2 or more records found.\n" + return perNx( MH_U0020, // "U0020: %s name '%s' is ambiguous: 2 or more records found.\n" b->what, name ); // " Change to unique names." // fall thru not found check or return for caller to try other methods @@ -453,12 +453,12 @@ LOCAL RC FC tryImInProbe( PROBEOBJECT *o) if (!evfOk) /* if constant req'd in this expr's context (not even EVEOI/EVFFAZ allowed), do our own errMsg here, now, cuz for this case, expr's msg, with its implicit start-of-run variability, is confusing. Also, no other cases will work with evfOk==0. */ - return perNx( (char *)MH_U0021, //"U0021: %s '%s' has not been defined yet.\n" + return perNx( MH_U0021, //"U0021: %s '%s' has not been defined yet.\n" //" A constant value is required %s a forward reference cannot be used.\n" //" Try reordering your input.", o->what, name, ermTx // context per global if nonNULL - ? strtprintf((char *)MH_U0021a, ermTx) // "for '%s' --\n " + ? strtprintf(MH_U0021a, ermTx) // "for '%s' --\n " : "--" ); return RCCANNOT; /* record not found and evfOk not 0. A non-immediate probe method may work, and expr's msg isn't so bad for other variabilities, so let caller fall thru. */ @@ -473,12 +473,12 @@ LOCAL RC FC tryImInProbe( PROBEOBJECT *o) errMsg here & now, cuz for this case, expr's msg, with its implicit start-of-run variability, is confusing, and no other probe method will be applicable. */ - return perNx( (char *) MH_U0022, //"U0022: %s '%s' member %s has not been set yet.\n" + return perNx( MH_U0022, //"U0022: %s '%s' member %s has not been set yet.\n" //" A constant value is required %s a forward reference cannot be used.\n" //" Try reordering your input." o->what, name, o->mName, ermTx // context per global if nonNULL - ? strtprintf((char *)MH_U0021a, ermTx) // "for '%s' --\n " + ? strtprintf(MH_U0021a, ermTx) // "for '%s' --\n " : "--" ); return RCCANNOT; /* record not found and evfOk not 0. A non-immediate probe method may work, and expr's msg isn't so bad for other variabilities, so let caller fall thru. */ @@ -512,7 +512,7 @@ LOCAL RC FC tryImInProbe( PROBEOBJECT *o) if (exInfo( h, &exEvf, &exTy, NULL)) // get expr's type and variability / if h bad (no msg done)(exman.cpp) { // debug aid msg; shd be ok to continue to other cases - return perNx( (char *)MH_U0023, // "U0023: Internal error: %s '%s' member '%s' \n" + return perNx( MH_U0023, // "U0023: Internal error: %s '%s' member '%s' \n" o->what, name, o->mName, h ); // " contains reference to bad expression # (0x%x)" } else if (exTy != o->ty) // if expression type does not match member type @@ -520,9 +520,9 @@ LOCAL RC FC tryImInProbe( PROBEOBJECT *o) // here add code to resolve any resolvable differences as they become understood // msg mainly as debug aid -- shd be ok to continue to other cases (return RCCANNOT): - return perNx( (char *)MH_U0024, // "U0024: Internal error: %s '%s' member '%s', \n" - o->what, name, o->mName, (INT)h, // " containing expression (#%d):\n" - (INT)o->ty, (INT)exTy ); // " member type (ty), %d and expression type, %d, do not match.", + return perNx( MH_U0024, // "U0024: Internal error: %s '%s' member '%s', \n" + o->what, name, o->mName, h, // " containing expression (#%d):\n" + o->ty, exTy ); // " member type (ty), %d and expression type, %d, do not match.", } // generate code to reference same expression as member is already set to @@ -735,11 +735,11 @@ void FC showProbeNames(int showAll) for (size_t ancN2 = ancN; basAnc::ancNext( ancN2, &b2); ) // look for additional basAncs of same name { - if (_stricmp( (char *)b->what, (char *)b2->what)) + if (_stricmp( b->what, b2->what)) continue; // name different, skip it if (b2->ba_flags & RFINP ? inB : runB) // same; ok if 1st input basAnc or 1st run basAnc with name - printf( msg( NULL, (char *)MH_U0025, //"\nInternal error: Ambiguous class name '%s':\n" - (char *)b->what, //" there are TWO %s rats with that .what. Change one of them.\n" + printf( msg( NULL, MH_U0025, //"\nInternal error: Ambiguous class name '%s':\n" + b->what, //" there are TWO %s rats with that .what. Change one of them.\n" b->ba_flags & RFINP ? "input" : "run" ) ); // msg() gets disk text (and formats) -- printf does not. else { @@ -757,11 +757,11 @@ void FC showProbeNames(int showAll) : b->n < 1 ? ". " // static single-entry (Top, Topi): no subscript needed : "[0..]."; // static multi-entry (not expected): subscript 0 up - const char* nssSub = strtprintf( "@%s%s", (char *)b->what, subSub ); // @[1..]. etc + const char* nssSub = strtprintf( "@%s%s", b->what, subSub ); // @[1..]. etc char *ownSub = b->ownB && b->ownB != (BP)&TopiR // show non-top ownership && b->ownB != (BP)&TopR - ? strtprintf( " owner: %s", (char *)b->ownB->what ) + ? strtprintf( " owner: %s", b->ownB->what ) : ""; printf( "\n%-20s %s %s %s\n", nssSub, inB ? "I" : " ", runB ? "R" : " ", ownSub); diff --git a/src/cutok.cpp b/src/cutok.cpp index d4c57e569..1e9b35dff 100644 --- a/src/cutok.cpp +++ b/src/cutok.cpp @@ -198,7 +198,7 @@ int cuTok() // get next cu token, return type cuUntc(); // unget last (non-digit) char if (tem > 65535L) // if hex/octal # too big // user beware of - with 0x, 0o - cuEr( 0, (char *)MH_S0150); // "Number too big, truncated" & continue. + cuEr( 0, MH_S0150); // "Number too big, truncated" & continue. // integer done, but check if actually start of a float if (base != 10 // 0x and 0o cannot begin floats @@ -240,7 +240,7 @@ int cuTok() // get next cu token, return type RC rc = cvatof( cuToktx, &dval); // convert, cvatoxxx.cpp if (rc) // message error cuEr( // errmsg with line # and file name - 0, msg( NULL, (char *)rc)); // Tmpstr text for cvatof return code, messages.cpp + 0, msg( NULL, rc)); // Tmpstr text for cvatof return code, messages.cpp // no error indication returned to caller? cuFlval = (float)dval; // double-->float cuTokty = CUTFLOAT; // say token is a float @@ -325,7 +325,7 @@ int cuTok() // get next cu token, return type // reject random non-whitespace, non-printing characters now if (c < ' ' || c > '~') { - cuEr( 0, (char *)MH_S0151, c); // "Ignoring illegal char 0x%x" + cuEr( 0, MH_S0151, c); // "Ignoring illegal char 0x%x" goto reget; } single: // 1-char cases may here or fall in @@ -348,8 +348,8 @@ int cuTok() // get next cu token, return type if (cuToklen > CUTOKMAX) cuEr( 0, // errmsg w file name, tok line # cuTokty==CUTQUOT - ? (char *)MH_S0152 // "Overlong quoted text truncated: \"%s...\"": Specific msg for most likely case - : (char *)MH_S0153, // "Overlong token truncated: '%s...'" + ? MH_S0152 // "Overlong quoted text truncated: \"%s...\"": Specific msg for most likely case + : MH_S0153, // "Overlong token truncated: '%s...'" cuToktx ); return cuTokty; @@ -369,13 +369,13 @@ LOCAL void cuQuoTx() // do quoted text case for cuTok { eofInqErr: case EOF: - cuEr( 0, (char *)MH_S0154); + cuEr( 0, MH_S0154); return; // "Unexpected end of file in quoted text" //newlInqErr: case '\r': case '\n': - cuEr( 0, (char *)MH_S0155); + cuEr( 0, MH_S0155); return; // "Newline in quoted text" case '"': @@ -868,7 +868,7 @@ LOCAL void cufCline( // get current input file line text and col # to caller's // (error variables: see errCount() in rmkerr.cpp.) //=========================================================================== -RC CDEC cuEr( int retokPar, const char* message, ...) +RC CDEC cuEr( int retokPar, MSGORHANDLE message, ...) // errmsg with file line text, caret, file name & line #, text retrieval for handle, printf formatting @@ -884,7 +884,7 @@ RC CDEC cuEr( // non-va_list interface to cuErv, next, for error message with a int shoTx, int shoCaret, int shoFnLn, int retokPar, // see descriptions for cuErv, just below int fileIx, int line, int isWarn, - char *fmt, ... ) // message (or handle) and args to insert like sprintf + MSGORHANDLE fmt, ... ) // message (or handle) and args to insert like sprintf // returns RCBAD for convenience if isWarn is 0, else RCOK { @@ -903,7 +903,7 @@ RC cuErv( // errmsg with optional preprocessed file line text, caret, file name int fileIx, // 0 or input file name index whose name to show int line, // line # to show with fname int isWarn, // 0: "Error" (errCount++'s), 1: "Warning" (display suppressible), 2: "Info" - const char *fmt, va_list ap ) // message (or handle) and vsprintf args to insert + MSGORHANDLE fmt, va_list ap ) // message (or handle) and vsprintf args to insert // returns RCBAD for convenience if isWarn is 0, else RCOK (a CHANGE 7-14-92) { @@ -931,7 +931,7 @@ RC cuErv( // errmsg with optional preprocessed file line text, caret, file name char where[ULIBUFSZ + 2] = { 0 }; if (shoFnLn||fileIx) snprintf( where, sizeof(where), "%s(%d): %s: ", - getFileName(fileIx), (INT)line, + getFileName(fileIx), line, isWarn==1 ? "Warning" : isWarn==2 ? "Info" : "Error" ); // make up line with caret spaced over to error column diff --git a/src/cutok.h b/src/cutok.h index 093e41ddf..4eea1fab2 100644 --- a/src/cutok.h +++ b/src/cutok.h @@ -112,9 +112,9 @@ void cuUntok( void); // unget token int cuTok( void); // get token RC cufOpen( const char* fname, char *dflExt); // open file void cufClose( void); // close file -RC CDEC cuEr( int retokPar, const char* message, ...); -RC CDEC cuEr( int shoTx, int shoCaret, int shoFnLn, int retokPar, int fileIx, int line, int isWarn, char *fmt, ... ); -RC cuErv( int shoTx, int shoCaret, int shoFnLn, int re, int fileIx, int line, int isWarning, const char* msf, va_list ap=NULL); +RC CDEC cuEr( int retokPar, MSGORHANDLE message, ...); +RC CDEC cuEr( int shoTx, int shoCaret, int shoFnLn, int retokPar, int fileIx, int line, int isWarn, MSGORHANDLE fmt, ... ); +RC cuErv( int shoTx, int shoCaret, int shoFnLn, int re, int fileIx, int line, int isWarning, MSGORHANDLE msf, va_list ap=NULL); void cuCurLine( int retokPar, int* pFileIx, int* pline, int* pcol, char *s, size_t sSize); // end of cutok.h diff --git a/src/cvpak.cpp b/src/cvpak.cpp index 88c78329d..30d3b2856 100644 --- a/src/cvpak.cpp +++ b/src/cvpak.cpp @@ -123,7 +123,7 @@ LOCAL int FC sepFtInch( double d, int& inch); // unmaintained test code is at end //====================================================================== -char * FC cvin2sBuf( char *buf, void *data, USI dt, SI units, USI _mfw, USI _fmt) +char * FC cvin2sBuf( char *buf, const void *data, USI dt, SI units, USI _mfw, USI _fmt) // Convert internal format data to external format string in caller's buffer @@ -573,7 +573,7 @@ p Cvnchars = sprintf( str, sif[lj][ipv], wid, ppos, 0); ew++; // requires extra column // so why ++ at 9 ??? rob 10-88 } - sprintf( str+Cvnchars, "e%d", (INT)i); // add exponent i + sprintf( str+Cvnchars, "e%d", i); // add exponent i Cvnchars += ew; } // additional returns above @@ -1313,7 +1313,7 @@ const char* getChoiTxI( // text for choice of choice data type chan &= ~NCNAN; // remove them for check. But leave improper bits to evoke error msg. if (chan <= 0 || chan > GetDttab(dt).nchoices) // check that choice is in range 1 to # choices for dt. GetDttab: srd.h. { - err( PWRN, (char *)MH_V0036, chan, dt ); // display program error err msg + err( PWRN, MH_V0036, chan, dt ); // display program error err msg // "cvpak:getChoiTx(): choice %d out of range for dt 0x%x" return "bad choice"; } @@ -1334,7 +1334,7 @@ const char* getChoiTxI( // text for choice of choice data type *pTyX = tyX; return chtx; } - err( PWRN, (char *)MH_V0037, dt ); // program (internal) err msg + err( PWRN, MH_V0037, dt ); // program (internal) err msg // "cvpak:getChoiTx(): given data type 0x%x not a choice type" return "bad dt"; } // getChoiTxI @@ -1344,7 +1344,7 @@ RC FC cvS2Choi( // convert string to choice value for given data type else for USI dt, // choicb or choicn data type (dtypes.h) to convert: specifies choice strings in Dttab[]. void* pv, // NULL or receives choice value: 2 bytes for choicb, 4 bytes (hi 2 significant) for choicn. USI* pSz, // NULL or receives size: 2 or 4 - const char** pms ) // if non-NULL + MSGORHANDLE* pms ) // if non-NULL // string not found: receives ptr to Tmpstr message insert: "%s not one of xxx yyy zzz ..." // string=alias: receives ptr to deprecation Tmpstr message // else receives NULL @@ -1354,7 +1354,7 @@ RC FC cvS2Choi( // convert string to choice value for given data type else for // RCBAD2 with *pms set on info/warning (use of alias,) { if (pms) - *pms = NULL; // init to no message + *pms = nullptr; // init to no message if (dt & (DTBCHOICB|DTBCHOICN)) // if a choice type { // search this choice data type's strings for a match, using getChoiTxI (just above). @@ -1405,7 +1405,7 @@ RC FC cvS2Choi( // convert string to choice value for given data type else for { USI maxll = getCpl() - 5; // -5: leave some space for adding punctuation, indent, final " ...", etc. - const char* ms = strtprintf( (char *)MH_V0039, s); // start assembling string "'%s' is not one of choice1 choice2 ..." + const char* ms = strtprintf( MH_V0039, s); // start assembling string "'%s' is not one of choice1 choice2 ..." for (v = 1; v <= GetDttab(dt).nchoices; v++) // loop data type's choices, concatenate each to ms { int tyX; const char* chtx = getChoiTxI( dt, v, &tyX ); // get vth choice @@ -1426,7 +1426,7 @@ RC FC cvS2Choi( // convert string to choice value for given data type else for return RCBAD; // bad value for data type return } if (pms) - *pms = strtprintf( (char *)MH_V0038, dt ); // "cvpak:cvS2Choi(): given data type 0x%x not a choice type" + *pms = strtprintf( MH_V0038, dt ); // "cvpak:cvS2Choi(): given data type 0x%x not a choice type" return RCBAD; // bad data type. 2+ other returns above } // cvS2Choi @@ -1515,7 +1515,7 @@ t if (dbuf != Pgb) t ??? t cvin2sBuf(buf,Pgb,dt,un,7,FMTSQ+dfw); t if (rc == RCOK) -t printf("Cvnchars=%d Gbsize=%d %s\n",(INT)Cvnchars,(INT)Gbsize,buf); +t printf("Cvnchars=%d Gbsize=%d %s\n",Cvnchars,Gbsize,buf); t } t #endif /* INTEST */ t @@ -1528,22 +1528,22 @@ t mfw = 6; t for (iv = 0; iv < NV; iv++) t { i = vallist[iv]; t cvin2sBuf(buf,(char *)&i,dt,UNNONE,mfw,f); -t printf("Plus ... [%s] %d\n",buf,(INT)Cvnchars); +t printf("Plus ... [%s] %d\n",buf,Cvnchars); t /* t cvin2sBuf(buf,(char *)&i,dt,UNNONE,mfw,FMTPVPLUS+f); -t printf("Plus ... [%s] %d ",buf,(INT)Cvnchars); +t printf("Plus ... [%s] %d ",buf,Cvnchars); t cvin2sBuf(buf,(char *)&i,dt,UNNONE,mfw,FMTPVNULL+f); -t printf("Null ... [%s] %d ",buf,(INT)Cvnchars); +t printf("Null ... [%s] %d ",buf,Cvnchars); t cvin2sBuf(buf,(char *)&i,dt,UNNONE,mfw,FMTPVSPACE+f); -t printf("Space ... [%s] %d\n",buf,(INT)Cvnchars); +t printf("Space ... [%s] %d\n",buf,Cvnchars); t */ t } t /* t i = 100; t cvin2sBuf(buf,(char *)&i,dt,UNNONE,mfw,FMTPVNULL+FMTLJ); -t printf("Left just [%s] %d\n",buf,(INT)Cvnchars); +t printf("Left just [%s] %d\n",buf,Cvnchars); t cvin2sBuf(buf,(char *)&i,dt,UNNONE,mfw,FMTPVNULL+FMTRJ); -t printf("Right just [%s] %d\n",buf,(INT)Cvnchars); +t printf("Right just [%s] %d\n",buf,Cvnchars); t */ t #endif /* TESTINT */ t @@ -1551,22 +1551,22 @@ t #ifdef TESTVAR t f = FMTRJ; t mfw = VARWIDTH*Vardisp; t cvin2sBuf(buf,(char *)vallist,DTVAR,UNNONE,mfw,FMTPVNULL+f); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t #endif /* TESTVAR */ t t /* #define TESTSTR */ t #ifdef TESTSTR t dt = DTSTRING; t cvin2sBuf(buf,"Hello test",dt,UNNONE,7,0); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t cvin2sBuf(buf,"Hello test",dt,UNNONE,11,0); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t cvin2sBuf(buf,"Hello test",dt,UNNONE,15,0); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t cvin2sBuf(buf,"Hello test",dt,UNNONE,15,FMTRJ); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t cvin2sBuf(buf,"Hello test",dt,UNNONE,256,FMTSQ); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t #endif /* TESTSTR */ t t #undef TESTDATE @@ -1603,11 +1603,11 @@ t i = 4; t p = (char *)&i; t t cvin2sBuf(buf,p,dt,UNNONE,mfw,FMTLJ); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t cvin2sBuf(buf,p,dt,UNNONE,mfw,FMTRJ); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t cvin2sBuf(buf,p,dt,UNNONE,mfw,FMTSQ); -t printf("[%s] %d\n",buf,(INT)Cvnchars); +t printf("[%s] %d\n",buf,Cvnchars); t #endif /* TESTDATE */ t t /* #define TESTFL */ @@ -1620,11 +1620,11 @@ t dfw = 2; t f = FMTLJ; t printf("%12.3f ",val); t cvin2sBuf(buf,(char *)&val,dt,UNNONE,mfw,FMTPVPLUS+dfw+f); -t printf("Plus [%s] %d\t",buf,(INT)Cvnchars); +t printf("Plus [%s] %d\t",buf,Cvnchars); t cvin2sBuf(buf,(char *)&val,dt,UNNONE,mfw,FMTPVNULL+dfw+f); -t printf("Null [%s] %d\t",buf,(INT)Cvnchars); +t printf("Null [%s] %d\t",buf,Cvnchars); t cvin2sBuf(buf,(char *)&val,dt,UNNONE,mfw,FMTPVSPACE+dfw+f); -t printf("Space [%s] %d\n",buf,(INT)Cvnchars); +t printf("Space [%s] %d\n",buf,Cvnchars); t } t #endif /* TESTFL */ t @@ -1661,7 +1661,7 @@ t { cvcf2init( m, mfw, m+20, mfw+1); t for (dfw = 0; dfw < 3; dfw++) t { p = cvcf2( buf, "Dog", &testf, 1, FMTRJ+FMTUNITS+dfw, t &testf, 1, FMTRJ+FMTUNITS+FMTNODATA+dfw ); -t printf("[%s] Len=%d\n",p,(INT)strlen(p)); +t printf("[%s] Len=%d\n",p,strlen(p)); t } t } t #endif /* TESTCF */ @@ -1729,7 +1729,7 @@ t if (printFlg) t printf("d = %f", d ); t } t if (printFlg) -t printf(" rc = %d\n", (INT)rc ); +t printf(" rc = %d\n", rc ); t } t } t return 0; /* keep compiler happy */ diff --git a/src/cvpak.h b/src/cvpak.h index 963f169fa..814ee89a2 100644 --- a/src/cvpak.h +++ b/src/cvpak.h @@ -69,7 +69,7 @@ x // FTMNOQUINCH FMTRTZ and FMTSQ all on --> omit 0 inch values with feet. /*------------------------- FUNCTION DECLARATIONS -------------------------*/ // cvpak.cpp functions -char* FC cvin2sBuf( char *buf, void *data, USI dt, SI units, USI mfw, USI fmt); +char* FC cvin2sBuf( char *buf, const void* data, USI dt, SI units, USI mfw, USI fmt); char* FC cvin2s( const void *data, USI dt, SI units, USI mfw, USI fmt, USI xfw=0); RC FC cvLmCk( SI dt, SI limit, void *p); double FC cvExtoIn( double f, int units); @@ -78,7 +78,7 @@ double FC cvstdangle( double ang ); enum CHOITXTY { chtyNORMAL, chtyHIDDEN, chtyALIAS, chtyALIASDEP }; int getChoiTxTyX( const char* chtx); const char* getChoiTxI( USI dt, SI chan, int* pTyX=NULL, int options=0); -RC FC cvS2Choi( const char *s, USI dt, void *pv, USI *pSz, const char** pms); +RC FC cvS2Choi( const char *s, USI dt, void *pv, USI *pSz, MSGORHANDLE* pms); RC FC cvatof( const char *_str, double *vp, bool percent=false ); #if 0 diff --git a/src/dhwcalc.cpp b/src/dhwcalc.cpp index e61fbf20c..ac39febf9 100644 --- a/src/dhwcalc.cpp +++ b/src/dhwcalc.cpp @@ -4823,7 +4823,7 @@ RC DHWHEATER::wh_DoSubhrStart() : -1.f; if (wh_effSh <= 0.f) - rc |= err("%s, %s: Invalid water heater efficiency %0.3f", + rc |= err( ERR, "%s, %s: Invalid water heater efficiency %0.3f", objIdTx(), Top.When(C_IVLCH_S), wh_effSh); } diff --git a/src/envpak.cpp b/src/envpak.cpp index ef3382130..7b57a1adb 100644 --- a/src/envpak.cpp +++ b/src/envpak.cpp @@ -48,7 +48,7 @@ t { if (enkichk()) t { printf("\n\nInterrupt...."); t gcne(); t } -t printf("Hi %d\n",(INT)i); +t printf("Hi %d\n",i); t } t enkimode(KILEAVEHIT); t if (enkichk()) @@ -430,7 +430,7 @@ void CDEC fpeErr( // Handle floating point error exceptions errCrit( PABT, // display critical msg "X0103: floating point exception %d:\n %s", - (INT)code, // show code for unknown cases 1-31-94 + code, // show code for unknown cases 1-31-94 lookws( code, table)); #endif // no return diff --git a/src/exman.cpp b/src/exman.cpp index acc86e046..879569506 100644 --- a/src/exman.cpp +++ b/src/exman.cpp @@ -141,7 +141,7 @@ NANDAT* RECREF::rr_pRecRef() const return NULL; // (no msg) if (rr_i > b->n) { - err(PWRN, (char*)MH_E0106); // "exman.cpp:pRecRef: record subscript out of range" + err(PWRN, MH_E0106); // "exman.cpp:pRecRef: record subscript out of range" return NULL; } return (NANDAT*)b->recMbr(rr_i, rr_o); // return pointer to record member @@ -521,7 +521,7 @@ void EXTAB::ext_Efree() // free heap stuff used by this expression /* exman.cpp DATA TYPES at user level, for use in calls to exPile: -TYSTR string: char * in user storage, private dm copy ?? +TYSTR string: char* in user storage, private dm copy ?? TYFL float. TYFLSTR float or string 11-91 TYLLI limited long integer: LI user storage but user interface and exman @@ -652,17 +652,17 @@ RC FC exPile( // compile an expression from current input if (wanTy==TYSI || wanTy==TYCH && choiDt & DTBCHOICB) // 16-bit ints and choicb choices cannot hold NANDLEs { - perlc( (char *)MH_E0090, _evfOk ); // devel aid. perlc: issue parse errMsg w line # & caret, cuparse.cpp + perlc( MH_E0090, _evfOk ); // devel aid. perlc: issue parse errMsg w line # & caret, cuparse.cpp // "exman.cpp:exPile: Internal error: bad table entry: \n" // " bad evfOk 0x%x for 16-bit quantity" _evfOk &= (EVEOI|EVFFAZ); // fix & continue } if (wanTy & TYCH && !(choiDt & (DTBCHOICB|DTBCHOICN))) - return perlc( (char *)MH_E0091, wanTy, choiDt); /* "exman.cpp:exPile: Internal error: \n" + return perlc( MH_E0091, wanTy, choiDt); /* "exman.cpp:exPile: Internal error: \n" " called with TYCH wanTy 0x%x but non-choice choiDt 0x%x" */ if ((wanTy & (TYCH|TYFL))==(TYCH|TYFL)) if (!(choiDt & DTBCHOICN)) - return perlc( (char *)MH_E0092, wanTy, choiDt); /* "exman.cpp:exPile: Internal error: \n" + return perlc( MH_E0092, wanTy, choiDt); /* "exman.cpp:exPile: Internal error: \n" " called with TYNC wanTy 0x%x but 2-byte choiDt 0x%x" */ // compile expression from current input file to pseudocode OR constant value @@ -699,7 +699,7 @@ RC FC exPile( // compile an expression from current input SI iV = static_cast(v); *(SI*)pDest = iV; // return lo 16 bits of value if (ISNCHOICE(v)) // redundantly check for not a 4-byte choice value (cnglob.h macro) - perlc((char*)MH_E0093); // "exman.cpp:exPile: Internal error:\n" + perlc(MH_E0093); // "exman.cpp:exPile: Internal error:\n" // " 4-byte choice value returned by exOrk for 2-byte type". devel aid } else if (gotTy == TYSTR) @@ -730,7 +730,7 @@ RC FC exPile( // compile an expression from current input ex->ext_useCl = useCl; ex->ext_ty = (wanTy==TYLLI && gotTy==TYSI) ? TYLLI : gotTy; if ((fdTy & 0xff00) != 0) - err( PWRN, (char *)MH_E0094); // display internal error msg "exman.cpp:expile: fdTy > 255, change UCH to USI", + err( PWRN, MH_E0094); // display internal error msg "exman.cpp:expile: fdTy > 255, change UCH to USI", // Note fdTy still UCH in srd.h ex->ext_fdTy = (UCH)fdTy; // next 4 members identify bad thing in runtime errMsg (eg limits), also used to store value at end-of-input eval: @@ -785,18 +785,16 @@ RC FC uniLimCt( // check limits & apply units, with errMsg suitable for compile return RCOK; // else error - /* uniLim rets lib\cvpak.cpp code for no-arg msg for limit error. - Its text says what the limits are but does not show the bad value nor identify it - (and cannot readily change and still share the code with TK/CR). + /* uniLim rets cvpak.cpp code for no-arg msg for limit error. + Its text says what the limits are but does not show the bad value nor identify it. Generate a msg showing value, identification, AND cvpak's explanation. */ - return perNx( /* format msg like printf, and add input text, ^ under error, file name, line #. - Gobbles input to start next statement. returns RCBAD. cuparse.cpp */ - (char *)MH_E0095, // "Bad %s: %s: %s" + return perNx( // format msg like printf, and add input text, ^ under error, file name, line #. + // Gobbles input to start next statement. returns RCBAD. cuparse.cpp + MH_E0095, // "Bad %s: %s: %s" _ermTx ? _ermTx : "", // in case _ermTx is NULL (unexpected/fix call if found) - txVal( ty, p), // text for the bad value (below) - msg( NULL, // text for MH (in rc) to Tmpstr (messages.cpp) SHD BE OK TO pass han to perNx now 3-92. - (char *)rc)); // MH in low byte of char * + txVal(ty, p), // text for the bad value (below) + msg(NULL, rc)); // text for MH (in rc) to Tmpstr (messages.cpp) SHD BE OK TO pass han to perNx now 3-92. } // uniLimCt //=========================================================================== LOCAL RC FC uniLim( @@ -984,7 +982,7 @@ RC FC exWalkRecs() if (oi >= sizeof(os)/sizeof(os[0])) { err( PWRN, // disp internal err msg - (char *)MH_E0096); // "exman.cpp:exWalkRecs: os[] overflow" + MH_E0096); // "exman.cpp:exWalkRecs: os[] overflow" break; } os[oi++] = b->fir[f].fi_off; // save field's offset @@ -1014,7 +1012,7 @@ RC FC exWalkRecs() w.rr_o = o; // offset to addStore arg if (ISUNSET(v)) { - err(PWRN, (char*)MH_E0097, w.rr_What()); // "exman.cpp:exWalkRecs: unset data for %s" + err(PWRN, MH_E0097, w.rr_What()); // "exman.cpp:exWalkRecs: unset data for %s" // do something to stop run? } else if (ISASING(v)) // if value is to be determined by AUTOSIZE 6-95 @@ -1053,7 +1051,7 @@ o o w.ancN = ancN; w.i = i; w.o = o; // combine into single thing o v = *w.rr_pRecRef(); // fetch contents of member o if (ISUNSET(v)) -o return err( PWRN, (char *)MH_E0098, w.rr_What() ); // "exman.cpp:exReg: Unset data for %s" +o return err( PWRN, MH_E0098, w.rr_What() ); // "exman.cpp:exReg: Unset data for %s" o else if ISNANDLE(v) o return addStore( EXN(v), w); // register place to put value of expr EXN(v). o return RCOK; @@ -1157,7 +1155,7 @@ RC FC exEvEvf( // evaluate expressions and do their updates if (exN) // if there are any registered expressions if (exTab==NULL) // debug aid check -- could delete later - return err( PWRN, (char *)MH_E0100, (INT)exN); // "exman.cpp:exEvEvf: exTab=NULL but exN=%d" + return err( PWRN, MH_E0100, exN); // "exman.cpp:exEvEvf: exTab=NULL but exN=%d" /* test for "end of input" etc evaluation call */ @@ -1264,12 +1262,12 @@ RC FC exEvEvf( // evaluate expressions and do their updates { if (nuerr) // if nan's encountered in data, end run: avoid FPE crash! // (but 12-5-91 when it continued it didn't crash. why?) - return rer( (char *)MH_E0101); // "Unset data or unevaluated expression error(s) have occurred.\n" + return rer( MH_E0101); // "Unset data or unevaluated expression error(s) have occurred.\n" // " Terminating run." */ if (errCount() > maxErrors) // if too many total errors, msg & ret RCBAD. // errCount: gets error count ++'d by calls to rer, err, etc. rmkerr.cpp. // maxErrors: cuparse.cpp. Data init, accessible as $maxErrors. - return rInfo( (char *)MH_E0102, (INT)maxErrors ); /* runtime "Information" message, exman.cpp + return rInfo( MH_E0102, maxErrors ); /* runtime "Information" message, exman.cpp "More than %d errors. Terminating run." */ #if 1 // 6-95. case: probed record name not found when setting tuQMxLh. // 6-95 stop run on ANY expr evaluation error cuz unstored result might have left a NAN in target --> crash. @@ -1299,7 +1297,7 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre EXTAB *ex = exTab + h; if (ex->ext_ip==NULL) - return err( PWRN, (char *)MH_E0103, h ); // "exman.cpp:exEv: expr %d has NULL ip" + return err( PWRN, MH_E0103, h ); // "exman.cpp:exEv: expr %d has NULL ip" #if 0 if (ex->ext_ty == TYSTR) @@ -1316,7 +1314,7 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre return rc; // return the specific error code now. cuEvalR set *pBadH. if (ms) // if ms ret'd for us to complete and issue { - const char* part1 = strtprintf( (char *)MH_E0104, // "While determining %s: ". pre-do start of msg to get its length + const char* part1 = strtprintf( MH_E0104, // "While determining %s: ". pre-do start of msg to get its length whatEx(h) ); // what expr originally set (local) rer( // runtime errMsg: prefix the following with simulation date & time // (as opposed to perNx's input file line). This file. @@ -1336,7 +1334,7 @@ LOCAL RC FC exEvUp( // evaluate expression. If ok and changed, store and incre // message giving cvpak's explanation and showing value AND identifying what expr was for return rer( // issue runtime errMsg: shows simulation data & time // rather than input file line. this file. - (char *)MH_E0105, // "Bad value, %s, for %s: %s" + MH_E0105, // "Bad value, %s, for %s: %s" txVal( ex->ext_ty, pv), // convert value to text (local) whatEx(h), // what this expr orginally set (local) msg( NULL, // text for MH to Tmpstr, messages.cpp SHD BE OK TO PASS han to rer now, 3-92. @@ -1545,7 +1543,7 @@ LOCAL const char* FC txVal( default: err( PWRN, // display intrnl err msg - (char *)MH_E0107, ty ); // "exman.cpp:txVal: unexpected 'ty' 0x%x" + MH_E0107, ty ); // "exman.cpp:txVal: unexpected 'ty' 0x%x" return "?"; } } // txVal @@ -1559,12 +1557,12 @@ const char* FC whatEx( USI h) BP b = ex->ext_srcB; if (b) // if baseAnc specified in exTab: insurance return strtprintf( "%s of %s%s %s", - MNAME(b->fir + ex->ext_srcFn), // field member name in record (srd.h macro may access special segment) - (char *)b->what, // rat name: ZONE etc - ex->ext_srcIsType ? " type" : "", // "type" if pertinent - b->ptr() // note 1 - ? strtprintf( "'%s'", b->rec(ex->ext_srcI).Name()) // record name - : strtprintf( "[%d]", (INT)ex->ext_srcI) ); // else subscript + MNAME(b->fir + ex->ext_srcFn), // field member name in record (srd.h macro may access special segment) + b->what, // rat name: ZONE etc + ex->ext_srcIsType ? " type" : "", // "type" if pertinent + b->ptr() // note 1 + ? strtprintf( "'%s'", b->rec(ex->ext_srcI).Name()) // record name + : strtprintf( "[%d]", ex->ext_srcI) ); // else subscript else // no b (currently not expected 2-91) return ""; @@ -1582,7 +1580,7 @@ const char* FC whatNio( USI ancN, TI i, USI off) // error message insert descri // basAnc BP b = basAnc::anc4n( ancN, WRN); // point base for given anchor number, ancrec.cpp if (!b) - return strtprintf( (char *)MH_E0108, (INT)ancN); // "" + return strtprintf( MH_E0108, ancN); // "" // field name const char* mName = nullptr; @@ -1590,13 +1588,13 @@ const char* FC whatNio( USI ancN, TI i, USI off) // error message insert descri if (fir->fi_off==off) mName = MNAME(fir); // srd.h macro points to name text, possibly in special segment if (!mName) - mName = strtprintf( (char *)MH_E0109, (INT)off); // if member not found, show offset in msg "member at offset %d" + mName = strtprintf( MH_E0109, off); // if member not found, show offset in msg "member at offset %d" // record name const char* rName; if ( b->ptr() // if anchor's record block allocated: insurance, and && !b->rec(i).name.IsBlank() ) // and if name is non-"" - rName = strtprintf( (char *)MH_E0110, b->rec(i).Name(), i); // show name, + subscr in parens. "'%s' (subscript [%d])" + rName = strtprintf( MH_E0110, b->rec(i).Name(), i); // show name, + subscr in parens. "'%s' (subscript [%d])" else rName = strtprintf( "[%d]", i); // [unnamed or] null name or not alloc'd, show subscipt only @@ -1604,12 +1602,12 @@ const char* FC whatNio( USI ancN, TI i, USI off) // error message insert descri return strtprintf( "%s of %s%s %s", mName, - (char *)b->what, + b->what, b->ba_flags & RFTYS ? " type" : "", rName ); } // whatNio //=========================================================================== -RC CDEC rer( char *ms, ...) +RC CDEC rer( MSGORHANDLE ms, ...) // issue runtime error msg with simulation hr & date, disk msg retrieval, and printf formatting. @@ -1620,7 +1618,7 @@ RC CDEC rer( char *ms, ...) return rerIV( WRN, 0, ms, ap); // use inner fcn. WRN: not input error; report & continue; 0: error, not warning or info. } // rer //=========================================================================== -RC CDEC rer( int erOp /*eg PWRN*/, char *ms, ...) +RC CDEC rerErOp( int erOp /*eg PWRN*/, MSGORHANDLE ms, ...) // issue runtime error msg with simulation hr & date, disk msg retrieval, printf formatting, and given error action. @@ -1629,9 +1627,9 @@ RC CDEC rer( int erOp /*eg PWRN*/, char *ms, ...) va_list ap; va_start( ap, ms); // point variable arg list return rerIV( erOp, 0, ms, ap); // use inner fcn. 0: error, not warning or info. -} // rer +} // rerErOp //=========================================================================== -RC CDEC rWarn( char *ms, ...) +RC CDEC rWarn( MSGORHANDLE ms, ...) // issue runtime warning msg with simulation hr & date @@ -1642,7 +1640,7 @@ RC CDEC rWarn( char *ms, ...) return rerIV( REG, 1, ms, ap); // use inner fcn. REG: regular message: report & continue; 1: warning, not error or info. } // rWarn //=========================================================================== -RC CDEC rWarn( int erOp /*eg PWRN*/, char *ms, ...) +RC CDEC rWarnErOp( int erOp /*eg PWRN*/, MSGORHANDLE ms, ...) // issue runtime warning msg with simulation hr & date, disk msg retrieval, and printf formatting, and given error action. @@ -1653,7 +1651,7 @@ RC CDEC rWarn( int erOp /*eg PWRN*/, char *ms, ...) return rerIV( erOp, 1, ms, ap); // use inner fcn. 1: warning, not error or info. } // rWarn //=========================================================================== -RC CDEC rInfo( char *ms, ...) +RC CDEC rInfo( MSGORHANDLE ms, ...) // issue runtime "Info" msg with simulation hr & date, disk msg retrieval, and printf formatting. @@ -1667,7 +1665,7 @@ RC CDEC rInfo( char *ms, ...) RC rerIV( // inner fcn to issue runtime error message; msg handle ok for fmt; takes ptr to variable arg list. int erOp, // error action: WRN or PWRN int isWarn, // 0: error (increment errCount); 1: warning (display suppressible); 2: info. - const char* fmt, // message text + MSGORHANDLE fmt, // message text va_list ap /*=NULL*/) // message argument list // increments error count if isWarn==0. returns RCBAD for convenience. @@ -1675,7 +1673,7 @@ RC rerIV( // inner fcn to issue runtime error message; msg handle ok for fmt; t // format time & date preliminary string // say "Program Error" like err() 2-94 cuz comments show use of PWRN intended & many existing calls use it. - char *isWhat = isWarn==1 ? "Warning" : isWarn==2 ? "Info" : erOp & PROGERR ? "Program Error" : "Error"; + char* isWhat = isWarn==1 ? "Warning" : isWarn==2 ? "Info" : erOp & PROGERR ? "Program Error" : "Error"; char when[120]; if (Top.dateStr.IsBlank()) // if blank, still input time (eg end-of-input eval call). otta formalize this ??? @@ -1726,7 +1724,7 @@ RC rerIV( // inner fcn to issue runtime error message; msg handle ok for fmt; t 0 USI ancN, // rat number (if don't have it, use ratReg(&RATBASE) 0 TI i, // rat entry subscript 1.. 0 USI o, // rat member offset -0 char *name ) // NULL or name text for unset error message. If NULL, message is an "internal error". +0 char* name ) // NULL or name text for unset error message. If NULL, message is an "internal error". 0 0{ 0NANDAT v; @@ -1753,7 +1751,7 @@ RC rerIV( // inner fcn to issue runtime error message; msg handle ok for fmt; t 0 0 NANDAT *pv, /* ptr to location to replace (later) with expression 0 value if now contains NANDLE (nop if not NANDLE) */ -0 char *name ) /* NULL or name text for unset error message. +0 char* name ) /* NULL or name text for unset error message. 0 If NULL, message is an "internal error" */ 0 0 // use this ONLY for data that won't move; see also exRegRat. @@ -1820,7 +1818,7 @@ RC rerIV( // inner fcn to issue runtime error message; msg handle ok for fmt; t 0 { err( PWRN, "pRat: RAT entry subscript out of range"); 0 return NULL; 0 } -0 return (NANDAT *)( (char *)b->p // access table +0 return (NANDAT *)( (char* )b->p // access table 0 + b->eSz * i // access entry 0 + o ); // access member 0} /* pRat */ diff --git a/src/exman.h b/src/exman.h index 70f273b28..3e58af1f9 100644 --- a/src/exman.h +++ b/src/exman.h @@ -50,12 +50,12 @@ RC FC exEvEvf( USI evf, USI useCl); RC FC exInfo( USI h, USI *pEvf, USI *pTy, NANDAT *pv ); const char* FC whatEx( USI h); const char* FC whatNio( USI ratN, TI i, USI off); -RC CDEC rer( char *msg, ...); -RC CDEC rer( int erOp, char *msg, ...); -RC CDEC rWarn( char *msg, ...); -RC CDEC rWarn( int erOp, char *msg, ...); -RC CDEC rInfo( char *msg, ...); -RC rerIV( int erOp, int isWarn, const char *fmt, va_list ap=NULL); +RC CDEC rer( MSGORHANDLE msg, ...); +RC CDEC rerErOp( int erOp, MSGORHANDLE msg, ...); +RC CDEC rWarn( MSGORHANDLE msg, ...); +RC CDEC rWarnErOp( int erOp, MSGORHANDLE msg, ...); +RC CDEC rInfo( MSGORHANDLE msg, ...); +RC rerIV( int erOp, int isWarn, MSGORHANDLE fmt, va_list ap=NULL); // end of exman.h diff --git a/src/foundation.h b/src/foundation.h index eafcefeca..e39d520fc 100644 --- a/src/foundation.h +++ b/src/foundation.h @@ -15,7 +15,7 @@ inline Kiva::Material kivaMat(float k, float rho, float cp) { if (rho == 0.f || cp == 0.f) { - err("Materials used in Kiva must have specific heat and density greater than zero."); // TODO KIVA improve? + err( ERR, "Materials used in Kiva must have specific heat and density greater than zero."); // TODO KIVA improve? } return Kiva::Material(KIPtoSI(k), DIPtoSI(rho), SHIPtoSI(cp)); } diff --git a/src/impf.cpp b/src/impf.cpp index 3a8f3c231..dc597ebda 100644 --- a/src/impf.cpp +++ b/src/impf.cpp @@ -107,9 +107,9 @@ class ImpFldDcdr const char* srcFile; // text for fileIx: "" or CSE source file in which import() occurred int inputLineNo; // line # in cse source file const char* fieldName; // field name text for error messages, when known (no names if no file header) - const char** pms; // c'tor arg: where to return TmpStr error msg pointer, so caller can embed in msg giving context. + MSGORHANDLE* pms; // c'tor arg: where to return TmpStr error msg pointer, so caller can embed in msg giving context. public: - ImpFldDcdr( int fileIx, int inputLineNo, const char** pms); // c'tor. *pms receives TmpStr error submessage pointer. + ImpFldDcdr( int fileIx, int inputLineNo, MSGORHANDLE* pms); // c'tor. *pms receives TmpStr error submessage pointer. // usage: call axFile, then axscanFnr or -Fnm, then decNum if numeric RC FC axFile(int iffnmi); // access import file, set .iffnm and .impf RC FC axscanFnm(int fnmi); // access and scan field by name: for field name idx, set .fnr, .fnrt, .fieldName @@ -126,7 +126,7 @@ class ImpFldDcdr ImpFldDcdr::ImpFldDcdr( // constructor: initializes int fileIx, // cse input file name index for file in which import() occurred, for use in error messages int _inputLineNo, // line number in ditto - const char** pms ) // receives message pointer on error, to let caller insert in message giving context. + MSGORHANDLE* pms ) // receives message pointer on error, to let caller insert in message giving context. { iffnm = NULL; impf = NULL; @@ -148,27 +148,27 @@ RC FC ImpFldDcdr::axFile( int iffnmi) // access import file, set .iffnmi, .iffn // errors store message pointer via .pms (set by c'tor), leave rc1 RCBAD, and return RCBAD. { if (iffnmi <= 0 || iffnmi > IffnmB.n) - return IMPERR(( (char *)MH_R1905, /* "%s(%d): Internal error:\n" + return IMPERR(( MH_R1905, /* "%s(%d): Internal error:\n" " Import file names table record subscript %d out of range 1 to %d." */ srcFile, inputLineNo, iffnmi, IffnmB.n )); iffnm = IffnmB.p + iffnmi; // set member pointer to names table record TI impfi = iffnm->impfi; // get IMPORTFILE record subscript from names table record if (impfi <= 0 || impfi > ImpfB.n) - return IMPERR(( (char *)MH_R1906, /* "%s(%d): Internal error:\n" + return IMPERR(( MH_R1906, /* "%s(%d): Internal error:\n" " Import file subscript %d out of range 1 to %d." */ srcFile, inputLineNo, impfi, ImpfB.n )); impf = &ImpfB.p[impfi]; // point Import File record impfName = impf->im_fileName.CStrIfNotBlank(impf->name); // name for error messages: pathName if present, // else object name, which is "" if not given if (!impf->isOpen) // unless file is open and buffer allocated ok - return IMPERR(( (char *)MH_R1907, /* "%s(%d): Internal error:\n" + return IMPERR(( MH_R1907, /* "%s(%d): Internal error:\n" " Import file %s was not opened successfully." */ srcFile, inputLineNo, impfName )); // unexpected: run should have been stopped if (impf->eof) - return IMPERR(( (char *)MH_R1908, // "%s(%d): End of import file %s: data previously used up.%s" + return IMPERR(( MH_R1908, // "%s(%d): End of import file %s: data previously used up.%s" srcFile, inputLineNo, impfName, Top.isWarmup - ? msg( NULL, (char *)MH_R1909) /* "\n File must contain enough data for CSE warmup days (default 7)."*/ + ? msg( NULL, MH_R1909) /* "\n File must contain enough data for CSE warmup days (default 7)."*/ : "")); rc1 = RCOK; // say axFile completed ok @@ -181,24 +181,24 @@ RC FC ImpFldDcdr::axscanFnm(int fnmi) // access field by name: set fieldName, f // ERRORs store message pointer via .pms (set by c'tor), leave rc2 RCBAD, and return RCBAD. { if (rc1) // if file not accessed ok, don't attempt to access field - return IMPERR(( (char *)MH_R1910 )); /* "Internal error: ImpfldDcdr::axscanFnm():\n" + return IMPERR(( MH_R1910 )); /* "Internal error: ImpfldDcdr::axscanFnm():\n" " called w/o preceding successful file access" */ if (!iffnm->fnmt) // prevent GP fault - return IMPERR(( (char *)MH_R1911, /* "%s(%d): Internal error:\n" + return IMPERR(( MH_R1911, /* "%s(%d): Internal error:\n" " no IFFNM.fnmt pointer for Import file %s" */ srcFile, inputLineNo, impf->Name() )); // fetch and check field number for given field name index if (fnmi < 1 || fnmi > iffnm->fnmiN) // should be 1 to max value seen during compile - return IMPERR(( (char *)MH_R1912, /* "%s(%d): Internal error: in IMPORT() from file %s\n" + return IMPERR(( MH_R1912, /* "%s(%d): Internal error: in IMPORT() from file %s\n" " field name index %d out of range 1 to %d." */ srcFile, inputLineNo, impfName, fnmi, iffnm->fnmiN )); if (iffnm->fnmt[fnmi].fieldName) // insurance: for NULL leave "" stored by c'tor fieldName = iffnm->fnmt[fnmi].fieldName; // field name text, for error messages, eg in decNum int tfnr = iffnm->fnmt[fnmi].fnr; // 1-based field number for this field name index, to local til validated. if (tfnr <= 0 || tfnr > FNRMAX) // FNRMAX: impf.h - return IMPERR(( (char *)MH_R1913, /* "%s(%d): Internal error:\n" + return IMPERR(( MH_R1913, /* "%s(%d): Internal error:\n" " in IMPORT() from file %s field %s (name index %d),\n" " field number %d out of range 1 to %d." */ srcFile, inputLineNo, @@ -208,7 +208,7 @@ RC FC ImpFldDcdr::axscanFnm(int fnmi) // access field by name: set fieldName, f // scan record thru requested field if not already done while (impf->nFieldsScanned < tfnr) // until enough fields scanned in current record, if not already done if (!impf->scanNextField()) // scan field: delimit, dequote, do \ codes, null-terminate, etc in place - return IMPERR(( (char *)MH_R1914, /* "%s(%d): Too few fields in line %d of import file %s:\n" + return IMPERR(( MH_R1914, /* "%s(%d): Too few fields in line %d of import file %s:\n" " looking for field %s (field # %d), found only %d fields." */ srcFile, inputLineNo, impf->lineNo, impfName, fieldName, tfnr, impf->nFieldsScanned )); @@ -226,10 +226,10 @@ RC FC ImpFldDcdr::axscanFnr(int _fnr) // access and scan field by number, set .f // ERRORs store message pointer via .pms (set by c'tor), leave rc2 RCBAD, and return RCBAD. { if (rc1) // if file not accessed ok, don't attempt to access field - return IMPERR(( (char *)MH_R1915)); /* "Internal error: ImpfldDcdr::axscanFnr():\n" + return IMPERR(( MH_R1915)); /* "Internal error: ImpfldDcdr::axscanFnr():\n" " called w/o preceding successful file access" */ if (_fnr <= 0 || _fnr > FNRMAX) - return IMPERR(( (char *)MH_R1916, /* "%s(%d): Internal error: in IMPORT() from file %s, \n" + return IMPERR(( MH_R1916, /* "%s(%d): Internal error: in IMPORT() from file %s, \n" " field number %d out of range 1 to %d." */ srcFile, inputLineNo, impfName, _fnr, FNRMAX )); @@ -237,7 +237,7 @@ RC FC ImpFldDcdr::axscanFnr(int _fnr) // access and scan field by number, set .f while (impf->nFieldsScanned < _fnr) // until enough fields scanned in current record if (!impf->scanNextField()) // scan field: delimit, dequote, do \ codes, null-terminate, etc in place - return IMPERR(( (char *)MH_R1917, /* "%s(%d): Too few fields in line %d of import file %s:\n" + return IMPERR(( MH_R1917, /* "%s(%d): Too few fields in line %d of import file %s:\n" " looking for field %d, found only %d fields." */ srcFile, inputLineNo, impf->lineNo, impfName, _fnr, impf->nFieldsScanned )); @@ -259,7 +259,7 @@ RC FC ImpFldDcdr::decNum() // decode field's numeric value, set fnrt->fnv if ( rc2 // if no success code from axscanFnm or Fnr || !fnrt // GP fault insurance: no field table entry pointer in our object || !fnrt->fp ) // .. or no scanned field ptr in the table entry - return IMPERR(( (char *)MH_R1918)); /* "Internal error: ImpfldDcdr::decNum():\n" + return IMPERR(( MH_R1918)); /* "Internal error: ImpfldDcdr::decNum():\n" " called w/o preceding successful field scan" */ if (fnrt->nDecoded) return RCOK; // if this field of this record already decoded, don't repeat #if 0 // moved below so DOES DECODE each use & repeat error msg & bad return, as opposed to using 0. 2-94. @@ -268,13 +268,13 @@ x // (if error, later calls get 0 without repeating message) #endif #define SUBERR(text) { sub = text; goto subErr; } - char *sub /*="bug"*/; // (redundant init removed 12-94 when BCC32 4.5 warned) + MSGORHANDLE sub{ "bug" }; // (redundant init removed 12-94 when BCC32 4.5 warned) // decode number const char* start = fnrt->fp; // point to scanned field text start += strspn( start, " \t"); // pass spaces and tabs for chars consumed test if (strcspn(start,"0123456789") >= strlen(start)) // if no digits then syntax is bad - SUBERR((char *)MH_R1919) // go to end fcn and issue err msg "non-numeric value" + SUBERR(MH_R1919) // go to end fcn and issue err msg "non-numeric value" //else { // { }: 'v' scope, 12-94 @@ -282,12 +282,12 @@ x // (if error, later calls get 0 without repeating message) double v = strtod( start, &endptr); // convert string to double, return end pointer. C library fcn. // returns +- HUGE_VAL on overflow. if (endptr <= start) // if strtod used no characters then syntax is bad - SUBERR((char *)MH_R1919) // go issue err msg "non-numeric value" + SUBERR(MH_R1919) // go issue err msg "non-numeric value" endptr += strspn( endptr, " \t"); // pass spaces and tabs after value to check for end field if (*endptr) // if does not point to \0 that impFld put at end field - SUBERR((char *)MH_R1920); // go issue error msg "garbage after numeric value" + SUBERR(MH_R1920); // go issue error msg "garbage after numeric value" if (v < -FLT_MAX || v > FLT_MAX) // if overflow or too big to convert to float - SUBERR((char *)MH_R1921); // "number out of range" + SUBERR(MH_R1921); // "number out of range" // have valid numeric value fnrt->fnv = float(v); // convert to float and store value for caller & later references @@ -302,7 +302,7 @@ x // (if error, later calls get 0 without repeating message) " Import file %s, line %d, field %s:\n" " %s:\n" // SUBERR macro arg text " \"%s\"" // field text */ - return IMPERR(( (char *)MH_R1922, /* text just above */ + return IMPERR(( MH_R1922, /* text just above */ srcFile, inputLineNo, impfName, impf->lineNo, fldSub, msg( NULL, sub), /* gets text for msg handle, 6-95 */ @@ -491,7 +491,7 @@ RC topImpf() // check/process ImportFiles at end of input // return is RCBAD not found, RCBAD2 ambiguous, but latter not expected. // note: don't use oer cuz it would show IFFNM object type name "ImpFileFldNames". cuEr( 0, 0, 0, 1, iffnm->fileIx, iffnm->inputLineNo, 0, // cutok.cpp - (char *)MH_S0574, // "No IMPORTFILE \"\s\" found for IMPORT(%s,...)" + MH_S0574, // "No IMPORTFILE \"\s\" found for IMPORT(%s,...)" iffnm->Name(), iffnm->Name() ); continue; // error message prevents run. // iffnm->impfi remains 0 to indicate no ImportFile for Import()(s) that created this IFFNM. @@ -519,7 +519,7 @@ RC topImpf() // check/process ImportFiles at end of input // warn if unused (no Imports) if (!iimpf->iffnmi) // if no IFFNM found above for this IMPF, then it has no IMPORTs. { - iimpf->oWarn( (char *)MH_S0575); // "Unused IMPORTFILE: there are no IMPORT()s from it." + iimpf->oWarn( MH_S0575); // "Unused IMPORTFILE: there are no IMPORT()s from it." continue; // need no run record if unused } @@ -530,7 +530,7 @@ RC topImpf() // check/process ImportFiles at end of input if (iimpf->hasHeader != C_NOYESCH_YES) // if user said no header on file if (iffnm->fnmiN) // if have name table entries --> IMPORT()s by name seen { - iimpf->oer( (char *)MH_S0576); // "imHeader=NO but IMPORT()s by field name (not number) used" + iimpf->oer( MH_S0576); // "imHeader=NO but IMPORT()s by field name (not number) used" continue; } } @@ -591,7 +591,7 @@ RC FC impfStart() // import files stuff done at start run impf->fh = fopen( impf->im_fileName, "rb"); if (!impf->fh) { rc = err( WRN, // general error msg, errCount++. - (char *)MH_R1901, // "Cannot open import file %s. No run." + MH_R1901, // "Cannot open import file %s. No run." impf->im_fileName.CStr() ); continue; } @@ -608,7 +608,7 @@ RC FC impfStart() // import files stuff done at start run int temPos = int( ftell(impf->fh)); // get file position if (temPos < 0) // -1 if error { rc = err( PWRN, // general error message (rmkerr.cpp), count error (errCount++), return RCBAD. - (char *)MH_R1902, // "Tell error (%ld) on import file %s. No run." + MH_R1902, // "Tell error (%ld) on import file %s. No run." impf->im_fileName.CStr() ); continue; } @@ -633,7 +633,7 @@ RC FC impfAfterWarmup() // import files stuff done after CSE warmup and after e int newPos = fseek( impf->fh, impf->posEndHdr, SEEK_SET); // seek to end header / return 0 or non-zero if error if (newPos != 0) // if got wrong position or error rc |= err( WRN, // <--- apparently missing WRN added, rob 5-97 - (char *)MH_R1903, // "Seek error (%ld) on import file %s, handle %d" + MH_R1903, // "Seek error (%ld) on import file %s, handle %d" newPos, impf->im_fileName.CStr(), impf->fh ); impf->bufI1 = impf->bufI2 = impf->bufN = 0; // set buffer empty -- force reread @@ -674,7 +674,7 @@ void FC impfEnd() // import files stuff done at end run } if (1 || impf->lineNo >= nlnfwud) // if more data used than warmup could require if (impf->readRec()) // read next record from file / true if successful - impf->oInfo( (char *)MH_R1904, // "Import File %s has too many lines. \n" + impf->oInfo( MH_R1904, // "Import File %s has too many lines. \n" impf->im_fileName.CStr(), // " Text at at/after line %d not used." */ impf->lineNo ); // use warn to display message without incrementing error counter @@ -710,7 +710,7 @@ RC impFldNmN( // import numeric value of named field float *pv, // receives float value int fileIx, // CSE input file name index for use in error messages int inputLineNo, // CSE input source file line number for use in error messages - const char** pms ) // receives transitory submessage string pointer (Tmpstr) if error occurs + MSGORHANDLE* pms ) // receives transitory submessage string pointer (Tmpstr) if error occurs { ImpFldDcdr fd( fileIx, inputLineNo, pms); // object for decoding field. local class. c'tor inits. RC rc = fd.axFile(iffnmi); // check/access file @@ -727,7 +727,7 @@ RC impFldNmS( // import string value of named field char **pv, // receives pointer to string value in heap int fileIx, // CSE input file name index for use in error messages int inputLineNo, // CSE input source file line number for use in error messages - const char** pms ) // receives transitory submessage string pointer (Tmpstr) if error occurs + MSGORHANDLE* pms ) // receives transitory submessage string pointer (Tmpstr) if error occurs { ImpFldDcdr fd( fileIx, inputLineNo, pms); // object for decoding field. local class. c'tor inits. RC rc = fd.axFile(iffnmi); // check/access file @@ -742,7 +742,7 @@ RC impFldNrN( // import numeric value of field by number float *pv, // receives float value int fileIx, // CSE input file name index for use in error messages int inputLineNo, // CSE input source file line number for use in error messages - const char** pms ) // receives transitory submessage string pointer (Tmpstr) if error occurs + MSGORHANDLE* pms ) // receives transitory submessage string pointer (Tmpstr) if error occurs { ImpFldDcdr fd( fileIx, inputLineNo, pms); // object for decoding field. local class. c'tor inits. RC rc = fd.axFile(iffnmi); // check/access file @@ -759,7 +759,7 @@ RC impFldNrS( // import string value of field by number char **pv, // receives ptr to string value in heap int fileIx, // CSE input file name index for use in error messages int inputLineNo, // CSE input source file line number for use in error messages - const char **pms ) // receives transitory submessage string pointer (Tmpstr) if error occurs + MSGORHANDLE* pms ) // receives transitory submessage string pointer (Tmpstr) if error occurs { ImpFldDcdr fd( fileIx, inputLineNo, pms); // object for decoding field. local class. c'tor inits. RC rc = fd.axFile(iffnmi); // check/access file @@ -790,7 +790,7 @@ IFFNM::~IFFNM() // record destructor /*virtual*/ void IFFNM::Copy( const record* pSrc, int options/*=0*/) // overrides record::Copy. declaration must be same. // IFFNM = believed unused 2-94, but should be defined for link as is virtual fcn in base class. { - err( PWRN, (char *)MH_S0578); // "Unexpected call to IFFNM::Copy". if occurs, add code to do .fnmt or verify NULL. + err( PWRN, MH_S0578); // "Unexpected call to IFFNM::Copy". if occurs, add code to do .fnmt or verify NULL. // free (or decr ref count for) derived class heap pointer(s) in record about to be overwritten. dmfree: lib\dmpak.cpp. //#define THIS ((IFFNM *)this) @@ -837,7 +837,7 @@ IMPF::~IMPF() // IMPORTFILE destructor // IMPF = beleived used only to copy input records to run, before .fnrt[] allocated in heap, 2-94. { if (fnrt || buf) // if pointers expected to be NULL are not - err( PWRN, (char *)MH_S0577); // "Unexpected call to IMPF::Copy". if msg occurs, complete code re .fnrt, .buf + err( PWRN, MH_S0577); // "Unexpected call to IMPF::Copy". if msg occurs, complete code re .fnrt, .buf // free (or decr ref count for) derived class heap pointer(s) in record about to be overwritten. dmfree: lib\dmpak.cpp. im_fileName.Release(); @@ -895,7 +895,7 @@ RC FC IMPF::scanHdr() // read and decode import file header goto bad; if (!im_title.IsBlank()) // if title given in input file if (_stricmp( im_title, fnrt[nFieldsScanned].fp)) // if title in import file is different - warn( (char *)MH_R1923, // "Import file %s: title is %s not %s." + warn( MH_R1923, // "Import file %s: title is %s not %s." im_fileName.CStr(), fnrt[nFieldsScanned].fp, im_title.CStr() ); // use warn to not ++errCount for warning. rmkerr.cpp. // continue scanning header: format was ok. if (!scanNextField()) // scan frequency field / if eor or error @@ -903,7 +903,7 @@ RC FC IMPF::scanHdr() // read and decode import file header bad: return err( // gen'l error on screen, err file, ERR report. ++errCount's. rmkerr.cpp. WRN, - (char *)MH_R1924, // "Import file %s: bad header format. No Run." + MH_R1924, // "Import file %s: bad header format. No Run." im_fileName.CStr() ); } @@ -943,7 +943,7 @@ RC FC IMPF::scanHdr() // read and decode import file header if (_stricmp( fileFreq, freqTx) // if frequency different in file, warn and continue execution && _stricmp( fileFreq, ivlTx)) // issue message, do not ++errCount (the error count) - warn( (char *)MH_R1925, // "Import file %s: \n File header says frequency is %s, not %s." + warn( MH_R1925, // "Import file %s: \n File header says frequency is %s, not %s." im_fileName.CStr(), fileFreq, strtprintf( "%s or %s", freqTx, ivlTx)); @@ -953,7 +953,7 @@ RC FC IMPF::scanHdr() // read and decode import file header // issue warning: do on flag to issue only once // and not if function terminates with (more serious) error b4 getting here if (imperfect) - warn( (char *)MH_R1926, // "Import file %s: Incorrect header format." + warn( MH_R1926, // "Import file %s: Incorrect header format." im_fileName.CStr() ); // issue message, rmkerr.cpp. continue execution. // line 4: field names list: get field numbers for named fields from position of names in list @@ -1007,7 +1007,7 @@ x } else if (fnmt[ fnmi].fnr != ifn) // if different column already found { // note: duplicate header scans occur if autosize or multiple RUNs // so re-find of same column is OK - rc = err( "Import file %s:" + rc = err( ERR, "Import file %s:" "\n IMPORT()s refer to ambiguous (non-unique) field '%s'" "\n found in columns %d and %d.", im_fileName.CStr(), nm, fnmt[ fnmi].fnr, ifn); @@ -1045,7 +1045,7 @@ x } // bad header record read common error exit eof: - return err( WRN, (char *)MH_R1928, // "Import file %s: \n" + return err( WRN, MH_R1928, // "Import file %s: \n" im_fileName.CStr() ); // " Premature end-of-file or error while reading header. No Run." } // IMPF::scanHdr //--------------------------------------------------------------------------- @@ -1132,7 +1132,7 @@ bool FC IMPF::readRec() // get next import file record in buffer and init to sc //encountering \0 at end buffer when not end file means record bigger than buffer, or bug. // remainder of record will be used as next record, causing errors; error count will end run. ASSERT(!bufI1); // start record is at start buffer or something wrong - err( WRN, (char *)MH_R1929, /* "Import file %s, line %d: \n" + err( WRN, MH_R1929, /* "Import file %s, line %d: \n" " record longer than %d characters" */ im_fileName.CStr(), lineNo, BUFSZ ); // err: general error displayer 2-94 that ++errCount's, rmkerr.cpp. @@ -1210,7 +1210,7 @@ bool IMPF::scanField( // find end of field, null-terminate, dequote, translat q2m: // issue "second quote missing" error message showing file name and line of error, and continue. // don't use rer: don't need to show time in run, and can get here b4 run (header). err( WRN, // issue general msg, ++errCount - (char *)MH_R1930, // "Import file %s, line %d: second quote missing" + MH_R1930, // "Import file %s, line %d: second quote missing" im_fileName.CStr(), lineNo); eorScanned = true; // no fields in this record after this one goto breakBreak; // return ok for this field, using all text to end line @@ -1279,7 +1279,7 @@ bool FC IMPF::readBuf() // read import file buffer full size_t nRead = fread(where, sizeof(char), toRead, fh); if (nRead== -1) { - err( WRN, (char *)MH_R1931, im_fileName.CStr()); // "Read error on import file %s" + err( WRN, MH_R1931, im_fileName.CStr()); // "Read error on import file %s" return false; } if (nRead==0) // if end of file with 0 characters left @@ -1310,7 +1310,7 @@ void FC IMPF::close() // close import file & free buffer if (tfh) // if open successful - insurance if (fclose(tfh) < 0) // close file err( WRN, // rmkerr.cpp general error msg with errCount++. - (char *)MH_R1932, im_fileName.CStr()); // "Close error on import file %s" + MH_R1932, im_fileName.CStr()); // "Close error on import file %s" } // free buffer diff --git a/src/impf.h b/src/impf.h index 51ca9d14c..b75dbdc3e 100644 --- a/src/impf.h +++ b/src/impf.h @@ -20,9 +20,9 @@ void FC impfEnd(); void FC impfIvl(IVLCH ivl); // runtime import-field functions in impf.cpp, used from cueval.cpp. -RC impFldNmN( int iffnmi, int fnmi, float *pv, int fileIx, int line, const char** pms); -RC impFldNmS( int iffnmi, int fnmi, char **pv, int fileIx, int line, const char** pms); -RC impFldNrN( int iffnmi, int fnr, float *pv, int fileIx, int line, const char** pms); -RC impFldNrS( int iffnmi, int fnr, char **pv, int fileIx, int line, const char** pms); +RC impFldNmN( int iffnmi, int fnmi, float *pv, int fileIx, int line, MSGORHANDLE* pms); +RC impFldNmS( int iffnmi, int fnmi, char **pv, int fileIx, int line, MSGORHANDLE* pms); +RC impFldNrN( int iffnmi, int fnr, float *pv, int fileIx, int line, MSGORHANDLE* pms); +RC impFldNrS( int iffnmi, int fnr, char **pv, int fileIx, int line, MSGORHANDLE* pms); // end of impf.h diff --git a/src/libstubs.cpp b/src/libstubs.cpp index 93ea89bf2..077b319ce 100644 --- a/src/libstubs.cpp +++ b/src/libstubs.cpp @@ -9,19 +9,17 @@ // provide only bare-bones definitions //------------------------------------------------------------------------------------------ -int getCpl( class TOPRAT** pTp /*=NULL*/) // get chars/line (stub fcn, allows linking w/o full CSE runtime) +int getCpl( class TOPRAT** /*pTp=NULL*/) // get chars/line (stub fcn, allows linking w/o full CSE runtime) { - pTp; return 78; } //--------------------------------------------------------------------------------------------------------------------------- -char* getErrTitleText() - +const char* getErrTitleText() { return ""; } //--------------------------------------------------------------------------------------------------------------------------- -char* getLogTitleText() +const char* getLogTitleText() { return ""; @@ -32,12 +30,12 @@ int getBodyLpp() return 66; } //--------------------------------------------------------------------------------------------------------------------------- -char* getFooterText([[maybe_unused]] int pageN) +const char* getFooterText([[maybe_unused]] int pageN) { return ""; } //--------------------------------------------------------------------------------------------------------------------------- -char* getHeaderText([[maybe_unused]] int pageN) +const char* getHeaderText([[maybe_unused]] int pageN) { return ""; } diff --git a/src/messages.cpp b/src/messages.cpp index 4b539a39e..5122baa34 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -13,7 +13,7 @@ in msghans.h). Examples: msg( NULL, "Bad value: %d", x) returns ptr to Tmpstr formatted string msg( myBuf, "Bad value: %d", x) returns ptr to fmtd msg in myBuf - msg( myBuf, (char *)MH_U0003, x) retrieves string having handle + msg( myBuf, MH_U0003, x) retrieves string having handle MH_U0003 (as defined in msgtbl.cpp), fmts into myBuf, returns ptr See also rmkerr.cpp for remark display and error handling functions @@ -44,13 +44,24 @@ extern SI msgTblCount; // number of messages in msgTbl[] /*-------------------------------- VARIABLES -------------------------------*/ LOCAL SI msgIsinit = 0; // non-0 after message world initialized this session /*----------------------- LOCAL FUNCTION DECLARATIONS ----------------------*/ -LOCAL void FC msgSort( void); -LOCAL const char * FC msgFind( int erOp, MH mh); -LOCAL INT CDEC msgCompare( const void *m1, const void *m2); // for qsort, not FC NEAR -LOCAL RC FC msgCheck( int erOp, const char *pMsg); +LOCAL void msgSort( void); +LOCAL const char* msgFind( MH mh); +LOCAL int msgCompare( const void *m1, const void *m2); // for qsort +LOCAL RC msgCheck( int erOp, const char *pMsg); //============================================================================== -void FC msgClean() // cleanup function: DLL version must release ALL memory. rob 12-93. +const char* MSGORHANDLE::mh_GetMsg( // resolve to text + const char* nullMsg /*=""*/) const // returned when mh_IsNull +// returns nullMsg if mh_IsNull, else pointer to text +{ + const char* msg = + mh_IsNull() ? nullMsg + : mh_IsHandle() ? msgFind( mh_GetHandle()) + : mh_msgOrHandle; + return msg; +} // MSGORHANDLE::mh_GetMsg +//============================================================================== +void msgClean() // cleanup function: DLL version must release ALL memory. rob 12-93. { if (!msgIsinit) // if has not been initialized @@ -80,7 +91,7 @@ RC msgInit( // message world (auto) initialization for (int i=-1; ++i < msgTblCount; ) // scan/check msgTbl { if (i && msgTbl[i-1].msgHan == msgTbl[i].msgHan) - rc = errCrit( erOp, "X0001: msgInit(): duplicate message handle '%d' found in msgTbl[]", (INT)msgTbl[i].msgHan); + rc = errCrit( erOp, "X0001: msgInit(): duplicate message handle '%d' found in msgTbl[]", msgTbl[i].msgHan); rc |= msgCheck( erOp, msgTbl[i].msg); // check msg length, below; merge errors } msgIsinit++; // say message world intialization completed @@ -88,12 +99,12 @@ RC msgInit( // message world (auto) initialization return rc; } // msgInit //============================================================================== -const char* CDEC msg( // retrieve message text, format args +const char* msg( // retrieve message text, format args char *mBuf, // ptr to buffer into which to format, NULL for TMPSTR // buffer dim = [MSG_MAXLEN] is PROBABLY large enough - const char *mOrH, // ptr to printf fmt message (e.g. "Bad value: %d") - // OR message handle (e.g. (char *)MH_X1002); message + MSGORHANDLE mOrH, // ptr to printf fmt message (e.g. "Bad value: %d") + // OR message handle (e.g. MH_X1002); message // handles are defined in msghan.h and are associated with // text in msgtab:msgTbl[] ...) // values as required by message @@ -132,7 +143,6 @@ const char* CDEC msg( // retrieve message text, format args return p; // return pt to caller's mBuf or to Tmpstr } // msg - //============================================================================== RC msgI( // retrieve message text, format args: inner function @@ -141,7 +151,8 @@ RC msgI( // retrieve message text, format args: inner function // (messages.h MSG_MAXLEN is probably large enough) size_t mBufSz, // sizeof( *mBuf) int* pMLen, // NULL or ptr for return of message strlen - const char* mOrH, // ptr to msg text OR message handle + MSGORHANDLE mOrH, // msg text OR message handle + // mOrH.IsNull(): return "" va_list ap/*=NULL*/) // printf-style values are reqd by msg text // NULL: no formatting (vsprintf not called) @@ -157,26 +168,17 @@ RC msgI( // retrieve message text, format args: inner function *mBuf = '\0'; // insurance: return "" for exceptions if (pMLen) *pMLen = 0; - if (!mOrH) // insurance + if (mOrH.mh_IsNull()) // insurance return RCOK; // NULL mOrH: NOP - const char *pMsg; - MH mh; - if (msgIsHan(mOrH)) // if mOrH is a char pointer to text, not a handle (local fcn, below) - { - mh = msgGetHan( mOrH); // handle value is value of mOrH with 0 HIWORD - pMsg = msgFind( erOp, mh); // find or read msg txt for handle, below. - // on error, issues message per erOp, then returns explanatory message. - } - else - { mh = RCBAD; // return value sez mOrH was not handle - pMsg = mOrH; - } + const char* pMsg = mOrH.mh_GetMsg(); + RC rc = mOrH.mh_GetRC(); + // here with: pMsg pointing to useable message text - // mh suitable for return as RC + // rc suitable for return - size_t mLen; - int tooLong; + size_t mLen{ 0 }; + bool tooLong; if (ap) { mLen = vsnprintf (mBuf, mBufSz - 1, pMsg, ap); // format final msg in mBuf tooLong = mLen < 0; @@ -195,17 +197,17 @@ RC msgI( // retrieve message text, format args: inner function "X0002: msgI(): Message '%1.15s ...' is too long\n" " (max length is %d)", mBuf, mBufSz); - mh = RCFATAL; + rc = RCFATAL; } if (pMLen) // if pointer given (rob 11-91) *pMLen = static_cast(mLen); // return message length - return mh; + return rc; } // msgI //=========================================================================== -const char* FC msgSec( // get sub-msg text for system error code +const char* msgSec( // get sub-msg text for system error code SEC sec ) // "System" Error Code: c library codes 0 - sys_nerr, or our SECOK, SECEOF, SECOTHER (defined in cnglob.h). @@ -242,26 +244,11 @@ const char* FC msgSec( // get sub-msg text for system error code *pText // if non-"" corresponding text ? pText // use it : "undefined SEC", // otherwise, admit ignorance - (INT)sec ); // sec value + sec ); // sec value } // msgSec //============================================================================== -bool FC msgIsHan( const char *mOrH) // return true iff arg is msg handle (requiring retrieval) not char* pointer -{ - return mOrH != NULL && reinterpret_cast(mOrH) <= 0xffff; - // ASSUMES PROGRAMS DATA NOT LOADED AT LOW ADDRESS! -} // msgIsHan -//----------------------------------------------------------------------------- -MH msgGetHan(const char* mOrH) -{ -#if defined( _DEBUG) - if (!msgIsHan( mOrH)) - err(PERR, "msgGetHan() called for non-handle mOrH"); -#endif - return (reinterpret_cast(mOrH) & 0xffff); -} // msgGetHan -//============================================================================== -LOCAL void FC msgSort() // sort msgTbl[] by message handle +LOCAL void msgSort() // sort msgTbl[] by message handle { qsort( // quick-sort, msc lib msgTbl, // base table, defnd in msgtab.cpp @@ -271,19 +258,17 @@ LOCAL void FC msgSort() // sort msgTbl[] by message handle } // msgSort //============================================================================== -LOCAL const char * FC msgFind( // find/read from disk full text for a message handle +LOCAL const char* msgFind( // retrieve text for a message handle - int erOp, // error reporting control, typically PWRN MH mh ) // message handle of message being sought // returns ptr to MASTER COPY of message (dup b4 modifying). // message should be copied before next call here as disk text is volatile. -// on error, issues msg (erOp) then returns error message text. { // find table entry for handle - MSGTBL *p = (MSGTBL *)bsearch( // binary search, C library + const MSGTBL* p = (const MSGTBL *)bsearch( // binary search, C library &mh, // key msgTbl, // base table, defnd in msgTbl.cpp msgTblCount, // number of entries in msgTbl @@ -292,7 +277,7 @@ LOCAL const char * FC msgFind( // find/read from disk full text for a message ha if (!p) // if match not found { - errCrit( erOp, "X0005: No message for message handle '%d'", (INT)mh); // report error per erOp, + errCrit( WRN, "X0005: No message for message handle '%d'", mh); // report error per erOp, return "Bad message handle"; // return a message (3-92) } else // message handle found @@ -301,8 +286,7 @@ LOCAL const char * FC msgFind( // find/read from disk full text for a message ha } // msgFind //============================================================================== -LOCAL INT CDEC msgCompare( // compare messages (for qsort and bsearch) - // NOT near, NOT FC: fcns ptr passed to msc lib fcns +LOCAL int msgCompare( // compare messages (for qsort and bsearch) const void *m1, // ptrs to msgTbl[] entries to be compared const void *m2 ) // .. (actual type const MSGTBL * but C++ requires void * to match library fcn decls) @@ -310,13 +294,13 @@ LOCAL INT CDEC msgCompare( // compare messages (for qsort and bsearch) // compares MSGTBL mh values // returns <0 (mh10 (mh1>mh2) { - return ((MSGTBL *)m1)->msgHan < ((MSGTBL *)m2)->msgHan + return ((const MSGTBL *)m1)->msgHan < ((const MSGTBL *)m2)->msgHan ? -1 // mh1 < mh2 - : ((MSGTBL *)m1)->msgHan > ((MSGTBL *)m2)->msgHan; // else 0 if ==, 1 if > + : ((const MSGTBL *)m1)->msgHan > ((const MSGTBL *)m2)->msgHan; // else 0 if ==, 1 if > } // msgCompare //============================================================================== -LOCAL RC FC msgCheck( // check an unformatted message +LOCAL RC msgCheck( // check an unformatted message int erOp, // error reporting control const char *pMsg ) // message to be checked @@ -334,7 +318,7 @@ LOCAL RC FC msgCheck( // check an unformatted message rc = errCrit( len > 3*MSG_MAXLEN/4 ? ABT : erOp, // if 3/4 buffer size, abort -- else crash likely "X0002: msgCheck(): Message '%1.15s ...' is too long \n" " (max length is %d)", - pMsg, (INT)chkLen); + pMsg, chkLen); //pMsg[chkLen] = '\0'; // truncate: to do this we'd need to remove lots of "const"s including on strpak fcns, 3-92. } return rc; diff --git a/src/messages.h b/src/messages.h index e5de4de4d..0e67881be 100644 --- a/src/messages.h +++ b/src/messages.h @@ -34,10 +34,8 @@ struct MSGTBL // messages.cpp void FC msgClean(); RC msgInit( int erOp); -const char* CDEC msg( char *mBuf, const char *mOrH, ...); // ALSO DECL IN cnglob.h -RC msgI( int erOp, char* mBuf, size_t mBufSz, int* pMLen, const char* mOrH, va_list ap=NULL); -const char* FC msgSec( SEC sec); -bool FC msgIsHan( const char* mOrH); -MH msgGetHan(const char* mOrH); +const char* msg( char *mBuf, MSGORHANDLE mOrH, ...); // ALSO DECL IN cnglob.h +RC msgI( int erOp, char* mBuf, size_t mBufSz, int* pMLen, MSGORHANDLE mOrH, va_list ap=NULL); +const char* msgSec( SEC sec); // messages.h end diff --git a/src/mspak.cpp b/src/mspak.cpp index d25e2d4dc..0feea0948 100644 --- a/src/mspak.cpp +++ b/src/mspak.cpp @@ -20,7 +20,7 @@ #include "mspak.h" #if defined( _DEBUG) -static const char* trapName = "WallS"; // debug aid -- do DbPrint etc for this surface +[[maybe_unused]] static const char* trapName = "WallS"; // debug aid -- do DbPrint etc for this surface #endif /*-------------------------------- DEFINES --------------------------------*/ @@ -447,11 +447,11 @@ float FC msrsurf( float h, float rsurf) // return series conductivity of a cond MASSLAYER& MASSLAYER::ml_Set( // extract layer from input LR object int iLSrc, // idx of source layer const LR* pLR, // layer info as input (from e.g. CON) - int options /*=0*/) // options - // 1: extract info for framing (else cavity) - // (no effect if LR not framed) + [[maybe_unused]] int options /*=0*/) // options + // 1: extract info for framing (else cavity) + // (no effect if LR not framed) { - options; // TODO: implement framed scheme, 8-10 + // options; TODO: implement framed scheme, 8-10 const MAT* pMat = MatiB.GetAt( pLR->lr_mati); return ml_Set( iLSrc, pLR->lr_thk, pLR->lr_vhc, pLR->lr_uvy, pMat->mt_condTRat, pMat->mt_condCT); @@ -1355,8 +1355,11 @@ RC MASSMODEL::mm_FromLayers( // base init from physical layers return MH_R0122; // "R0122: no layers in mass" mm_layers.clear(); // no layers yet (insurance) - float thkcomb, rcomb = 0; - double mushthick, mushr, mushhc; + [[maybe_unused]] float thkcomb = 0.f; + float rcomb = 0.f; + [[maybe_unused]] double mushthick = 0.f; + double mushr = 0.f; + double mushhc = 0.f; // Loop over layers with several vhc massiveness thresholds to try to // limit number of layers but also make sure we get some. End loop @@ -1556,7 +1559,7 @@ RC MASSMATRIX::mx_Setup( // set up matrix for central difference model if (n <= 1) { rc = MH_R0120; // "R0120: Mass '%s': no layers" err( PWRN, // display program error msg - (char *)rc, Name()); // arg for msg + rc, Name()); // arg for msg mx_SetSize( 0); return rc; } @@ -1658,7 +1661,7 @@ RC MASSMATRIX::mx_Setup( // set up matrix for central difference model if (gaussjb( &A0.front(), n, &B0.front(), n+2, invflag)) // solve/invert, return nz on error. { rc = MH_R0121; // "R0121: %s(): mass matrix too large or singular, cannot invert" err( PWRN, // display program error msg - (char *)rc, "mx_Setup"); // arg for msg + rc, "mx_Setup"); // arg for msg // not necessarily an internal error; rework to issue input error if actually tends to occur. // delete massmxp; // and set massmxp NULL for return // massmxp = NULL; @@ -1837,8 +1840,8 @@ void MASSFD::mf_SetSize( int n) { MASSMODEL::Copy( mmSrc, options); // base class [[maybe_unused]] const MASSFD& mf = (MASSFD&)mmSrc; - mf_nd = mf_nd; - mf_tOld = mf_tOld; + mf_nd = mf.mf_nd; + mf_tOld = mf.mf_tOld; return *this; } // MASSFD::Copy //----------------------------------------------------------------------------- @@ -1870,7 +1873,7 @@ RC MASSFD::mf_Setup() // set up forward difference model from mm_layers if (rc) err( PWRN, // display program error msg - (char *)rc, "mf_Setup"); // arg for msg + rc, "mf_Setup"); // arg for msg return RCOK; } // MASSFD::mf_Setup diff --git a/src/mspak.h b/src/mspak.h index 15bf7c951..bac1d1bcc 100644 --- a/src/mspak.h +++ b/src/mspak.h @@ -140,7 +140,7 @@ x // Set by mm_FromLayers.*/ MASSMODEL( MSRAT* pMSRAT=NULL, int model=0) : mm_pMSRAT( pMSRAT), mm_model( model), mm_layers(), mm_rsurfi( 0.f), mm_rsurfo( 0.f), - mm_hcTot( 0.), mm_flags( 0), mm_qBal( 0.), mm_qIE( 0.), mm_qIEDelta( 0.) + mm_hcTot( 0.), mm_qIE( 0.), mm_qIEDelta( 0.), mm_qBal( 0.), mm_flags( 0) { VZero( mm_tSrf, 2); VZero( mm_qSrf, 2); } MASSMODEL( const MASSMODEL& mm) { Copy( mm); } virtual ~MASSMODEL() { } diff --git a/src/pp.cpp b/src/pp.cpp index 6fda5c923..db14c0b2b 100644 --- a/src/pp.cpp +++ b/src/pp.cpp @@ -60,10 +60,10 @@ /*--- #defines SYMBOL TABLE */ struct DEFINE : public STBK // DEFINE: an defSytb value { - // char *id; // name of macro (id after #define) (in base class) - char* text; // text of macro - SI nA; // number of arguments - char* argId[1]; // nA dummy arg ids, NULL after last one + // char *id; // name of macro (id after #define) (in base class) + const char* text; // text of macro + SI nA; // number of arguments + char* argId[1]; // nA dummy arg ids, NULL after last one // actual size nA+1. nb sizeofs in code assumes the [1]. }; static SYTBH defSytb = { 0 }; // contains DEFINEs, manipulated by sytb.cpp fcns. @@ -74,7 +74,7 @@ struct INSTK { enum ISTY ty; // indicates file or macro/arg USI fileIx; // input file name index for use with ancrec.cpp:getFileName() - char* mName; // macro name (or arg name )text: NULL or pointer into theDef. Used? + const char* mName; // macro name (or arg name )text: NULL or pointer into theDef. Used? FILE* file; // NULL or FILE pointer for fopen/fread/fclose SI nlsNotRet; // # \n's skipped (in mac ref), macArgs() to ppC() int line; // line # in file at char isf->i (ppC()) (file only) @@ -91,7 +91,7 @@ struct INSTK USI j; // last+1 byte avail to ppC(), next byte for ppM() USI ech; // subscr of 1st byte NOT yet echoed to input listing char *buf; // NULL or buffer location (in heap): file buffer, theDef->text, or argV[i]. - int echLine; // line # in file at buf[ech]===line # (of incomplete line) at end of lisBuf + int echLine; // line # in file at buf[ech]===line # (of incomplete line) at end of lisBuf void /*DEFINE*/ *theDef; // NULL or macro DEFINE block, from symol table, in heap (for arg names) char **argV; // NULL or ptr to nA macro arg value ptrs + NULL }; @@ -186,9 +186,9 @@ static SI FC ppCDc(); static void FC ppUncDc(); static SI FC ppCNdc(); -static RC CDEC ppErr( char *message, ...); -static RC CDEC ppWarn( char *message, ...); -static RC CDEC ppErn( char *message, ...); +static RC CDEC ppErr( MSGORHANDLE message, ...); +static RC CDEC ppWarn( MSGORHANDLE message, ...); +static RC CDEC ppErn( MSGORHANDLE message, ...); // cleanup fcns called from ppClean() static void FC ppCmdClean( CLEANCASE cs); @@ -288,7 +288,7 @@ LOCAL void FC macArgUnc( SI c); LOCAL RC FC macArgC( SI *pC); LOCAL RC FC macArgCi( SI *pC); LOCAL RC FC ppmScan( void); -LOCAL RC FC macOpen( char *id, char *text, DEFINE *theDef, char **argV, enum ISTY ty); +LOCAL RC FC macOpen( const char *id, const char *text, DEFINE *theDef, char **argV, enum ISTY ty); LOCAL RC FC ppRead( void); // input listing @@ -396,7 +396,7 @@ LOCAL RC FC ppClDefine() else if (c==EOF) // nothing after identifier is ok ; // or strcpy( val, "1") ? check msc. else // garbage after id: bad syntax - rc = ppErr( (char *)MH_P0025); // issue error message "'=' expected" and define and continue + rc = ppErr( MH_P0025); // issue error message "'=' expected" and define and continue *p = '\0'; // enter in symbol table as 0-argument macro (or error if a redefinition). @@ -421,7 +421,7 @@ LOCAL RC FC ppClUndefine() c = ppCDc(); // get char, decommented. Decomment may be necessary cuz ppcId decomments then ungets. while (isspaceW(c)); // pass whitespace, expect end if (c != EOF) - return ppErr((char *)MH_P0026); // "Unexpected stuff after -U" + return ppErr(MH_P0026); // "Unexpected stuff after -U" // remove definition if any ppDelDefine(); // uses ppIdTx. ignore return: not defined is not an error. @@ -534,7 +534,7 @@ RC FC ppOpen( const char* fname, char *defex) // open and init cal non-res user // if file already open, message and continue: insurance if (is && inDepth) { - err( PWRN, (char *)MH_P0001); // internal error msg "ppOpen(): cn ul input file already open" + err( PWRN, MH_P0001); // internal error msg "ppOpen(): cn ul input file already open" ppClose(); // conditionally close } @@ -564,7 +564,7 @@ RC FC ppOpI( const char* fname, char *defex) // inner pp file opener: adds an i // check for excessive nesting if (inDepth >= INDEPTH) - return ppErr( (char *)MH_P0002, fname ); // "Cannot open '%s': already at maximum \n include nesting depth" + return ppErr( MH_P0002, fname ); // "Cannot open '%s': already at maximum \n include nesting depth" // initialize next nested input file level isi = inStk + inDepth; // locally point next inStk entry (inDepth not yet incremented) @@ -578,7 +578,7 @@ RC FC ppOpI( const char* fname, char *defex) // inner pp file opener: adds an i // open file isi->file = fopen( fname, "r"); // open to read (c library) if (isi->file==NULL) // if open failed - return ppErr( (char *)MH_P0003, fname); // format & display msg "Cannot open file '%s'" (local), return bad + return ppErr( MH_P0003, fname); // format & display msg "Cannot open file '%s'" (local), return bad // allocate file buffer CSE_E( dmal( DMPP( isi->buf), BUFSZ, WRN|DMZERO) ) // allocate dm, dmpak.cpp @@ -630,7 +630,7 @@ LOCAL void FC ppClI() // inner pp input closer: closes last file/macro/arg leve lisToChar( isi, isi->n, LtyNul, 1); /* list any remaining text in file's buffer, and flush the list buffer to prevent mixing list lines from multiple files. */ if (fclose(isi->file) != 0) // close FILE (c lib) - ppErr( (char *)MH_P0004, // error message "Close error, file '%s'" if failed + ppErr( MH_P0004, // error message "Close error, file '%s'" if failed getFileName(isi->fileIx) ); isi->file = NULL; // say no file open } @@ -656,7 +656,7 @@ x cupfree( DMPP( isi->buf)); // did not fix crashes // do not dmfree .mName: not heap block. } else - err( PWRN, (char *)MH_P0005); // display internal error msg "ppClI: bad is->ty" + err( PWRN, MH_P0005); // display internal error msg "ppClI: bad is->ty" } } // ppClI //========================================================================== @@ -912,7 +912,7 @@ const int PPCMAX = 16383; // max preprocessor command length else // m < ni: command too long { if (ppCppc++ ==1) // exactly 1 1st time: one msg only - ppErn( (char *)MH_P0006 ); // errMsg "Overlong preprocessor command truncated" with no text echo + ppErn( MH_P0006 ); // errMsg "Overlong preprocessor command truncated" with no text echo // put only m chars in ppcBuf, but remove all from input. } memcpyPass( ppcP, pi, m); @@ -952,7 +952,7 @@ const int PPCMAX = 16383; // max preprocessor command length pi += ni; // point after chars used USI i = (USI)(pi - is->buf); // convert back to subscript for is->i if (i > is->n) - ppErr( (char *)MH_P0007); // " Internal error: ppC: read off the end of buffer " + ppErr( MH_P0007); // " Internal error: ppC: read off the end of buffer " if (*(pi-1)!='\n') // if newline not transferred is->i = i; // store new is->i: pass text used @@ -1005,7 +1005,7 @@ const int PPCMAX = 16383; // max preprocessor command length is->buf[--i] = ' '; // spc b4 / * so can't paste } else - ppErr( (char *)MH_P0008); // "ppC internal err: buf space not avail for / and * " + ppErr( MH_P0008); // "ppC internal err: buf space not avail for / and * " // if can occur, fix, eg ?? reserve 3 bytes b4 buf. } is->i = i; // store new is->i (buf subscr of nxt char) @@ -1228,7 +1228,7 @@ LOCAL RC FC macArgs( // '(' begins argument list if (c != '(') { - ppErr( (char *)MH_P0009, theDef->id); // "'(' expected after macro name '%s'" + ppErr( MH_P0009, theDef->id); // "'(' expected after macro name '%s'" macArgUnc(c); // unget char c return RCOK; // let compilation continue with null args } @@ -1245,7 +1245,7 @@ LOCAL RC FC macArgs( if (c != ',') // comma separates args break; // on other character, stop if (i > theDef->nA + 10) // if more than 10 too many args !!?? - return ppErn( (char *)MH_P0010, theDef->id ); /* "Argument list to macro '%s' far too long: \n" + return ppErn( MH_P0010, theDef->id ); /* "Argument list to macro '%s' far too long: \n" " ')' probably missing or misplaced" */ // fatal error as probably beyond intended position of ) } @@ -1253,11 +1253,11 @@ LOCAL RC FC macArgs( // check termination and number of arguments if (c != ')') // can this happen? - return ppErr( (char *)MH_P0011); // "comma or ')' expected". fatal as posn end arg list unknown. + return ppErr( MH_P0011); // "comma or ')' expected". fatal as posn end arg list unknown. if (i > theDef->nA) - ppErr( (char *)MH_P0012, theDef->id); // "Too many arguments to macro '%s'" + ppErr( MH_P0012, theDef->id); // "Too many arguments to macro '%s'" else if (i < theDef->nA) - ppErr( (char *)MH_P0013, theDef->id); // "Too few arguments to macro '%s'" + ppErr( MH_P0013, theDef->id); // "Too few arguments to macro '%s'" // note macro reference code substitutes "" for missing arg (null argV) return RCOK; // good return @@ -1306,7 +1306,7 @@ LOCAL RC FC macArg( DEFINE *theDef, char *arg, SI *pC) if (n < ARGMAX) // if not too long *arg++ = (char)c; else if (n==ARGMAX) // only once per arg. msg w no file line: - ppErn( (char *)MH_P0014, theDef->id); // "Overlong argument to macro '%s' truncated" + ppErn( MH_P0014, theDef->id); // "Overlong argument to macro '%s' truncated" n++; } @@ -1402,7 +1402,7 @@ LOCAL RC FC macArgC( SI *pC) if (is->inCmt== -1) // if in "text" (set by ppmScan from macArgCi) { // message newline in quotes in arg list now, and fix it - ppErr( (char *)MH_P0015); // "newline in quoted text" + ppErr( MH_P0015); // "newline in quoted text" c = '"'; // close quotes so no cutok.cpp msg. note msc 6.0 does this -- tried it. } else // newline not in quotes @@ -1442,11 +1442,11 @@ LOCAL RC FC macArgCi( SI *pC) if (rc) // if error (messaged) or eof (unMessaged) { if (rc==RCEOF) // here, eof is error - ppErr( (char *)MH_P0016 ); // "Unexpected end of file in macro reference" + ppErr( MH_P0016 ); // "Unexpected end of file in macro reference" return rc; } if (is->i >= is->j) // debug aid - return ppErr( (char *)MH_P0017); // "macArgCi internal error: is->i >= is->j" + return ppErr( MH_P0017); // "macArgCi internal error: is->i >= is->j" // return 1 space for each comment if (is->inCmt > 0) // if text is->i..j-1 is comment @@ -1502,7 +1502,7 @@ LOCAL RC FC ppmScan() switch (is->inCmt) // 2 */ comment, 1 // comment, 0 none, -1 "" { default: - ppErr( (char *)MH_P0018, (INT)is->inCmt); // "ppmScan(): garbage .inCmt %d" + ppErr( MH_P0018, is->inCmt); // "ppmScan(): garbage .inCmt %d" /*lint -e616 */ case 0: // base case: not in a comment, not in "text" @@ -1616,7 +1616,7 @@ LOCAL RC FC ppmScan() SI isave; isave = is->i; is->i = is->j = (USI)(p - is->buf); // advance to position caret in msg - ppWarn( (char *)MH_P0019); // "Comment within comment" + ppWarn( MH_P0019); // "Comment within comment" is->i = isave; // restore i so caller gets start of cmt } } // for ( ; ; ) scan / * comment @@ -1628,7 +1628,7 @@ LOCAL RC FC ppmScan() /* to always get here, ppRead() must always return once with is->eofRead set and >=1 char in buf b4 popping to including file/macro. Currently adding \n at end file 8-90 and space at end macro 9-90 insures this. */ - ppErn( (char *)MH_P0020); // "Unexpected end of file or macro in comment" + ppErn( MH_P0020); // "Unexpected end of file or macro in comment" *p++ = '*'; // terminate comment so #line seen *p++ = '/'; // .. is->n += 2; // .. @@ -1649,21 +1649,21 @@ LOCAL RC FC ppmScan() //========================================================================== LOCAL RC FC macOpen( // initiate expansion of macro or argument - char *id, // macro or arg name, pointer into another heap block. - char *text, // macro or arg body/value, heap block dmIncRef'd by caller, decref'd by ppClI. + const char* id, // macro or arg name, pointer into another heap block. + const char* text, // macro or arg body/value, heap block dmIncRef'd by caller, decref'd by ppClI. DEFINE *theDef, // NULL or macro definition block pointer, dmIncRef'd by caller, decref'd by ppClI. char **argV, // NULL or macro arg value pointers array, free'd by ppClI. enum ISTY ty ) // tyMacro (or as changed) { if (inDepth >= INDEPTH) - return ppErr( (char *)MH_P0021 ); // "Too many nested macros and #includes" + return ppErr( MH_P0021 ); // "Too many nested macros and #includes" // continues, OMITTING macro or arg //>>> does it really CONTINUE 9-90?? <--- yes, 6-92, and it makes a mess. otta change. ******** INSTK * isi = is + 1; // temp local ptr to nxt inStk[] level memset( isi, 0, sizeof(INSTK)); // inits many members isi->ty = ty; // type: macro or arg, not incl file isi->mName = id; // macro/arg name. is it used? - isi->buf = text; // macro body text is "buffer". + isi->buf = (char *)text; // macro body text is "buffer". isi->theDef = theDef; // macro definition, for arg names isi->argV = argV; // macro arg info or NULL isi->bufSz = // need we set buffer size? @@ -1738,7 +1738,7 @@ LOCAL RC FC ppRead() // Get some input in current level file input buffer, for /* Issue error msg. Stops run via errCount. Line # in msg is too small cuz ahead of tokenizer here. ppErn as opposed to ppErr: do not show file line & caret & msg in input listing cuz a) wrong line, b) wrong place to use ppErr: gets lisFind program error cuz some line # not sync'd, 8-92. */ - ppErn( (char *)MH_P0024); /* "Replacing illegal null character ('\\0') with space\n" + ppErn( MH_P0024); /* "Replacing illegal null character ('\\0') with space\n" " in or after input file line number shown" 10-92 */ *q = ' '; // replace \0 with space to not terminate buffer b4 end } // iterate to rescan to see if another null @@ -2130,8 +2130,8 @@ int FC lisFind( // find matching file listing line return 1; #if 1 // debug else - err( PWRN, (char *)MH_P0022, // "pp.cpp:lisFind: matching buffer line is %d but requested line is %d\n" - INT(tLine+nl-1), (INT)line); + err( PWRN, MH_P0022, // "pp.cpp:lisFind: matching buffer line is %d but requested line is %d\n" + tLine+nl-1, line); #endif } @@ -2289,7 +2289,7 @@ LOCAL SI FC ppScanto( char *set); LOCAL void FC ppUncNdc( void); // error messages -LOCAL RC FC ppErv( SI shoTx, SI shoCaret, SI shoFnLn, SI isWarn, char *fmt, va_list ap); +LOCAL RC FC ppErv( SI shoTx, SI shoCaret, SI shoFnLn, SI isWarn, MSGORHANDLE fmt, va_list ap); /*============ CHAR FETCH & TOKENIZE for preprocessor commands ============*/ @@ -2424,7 +2424,7 @@ SI FC ppTok() ppTokty = CUTSI; // say is integer, value in ppSival if ( base==10 && tem > 32767L // decimal: +- 32767 (no -32768) || tem > 65535L ) // 0x or 0o: user beware of - - ppErr( (char *)MH_P0070 ); // error message: "Number too large, truncated" + ppErr( MH_P0070 ); // error message: "Number too large, truncated" } // if isidigit(c) @@ -2495,7 +2495,7 @@ SI FC ppTok() // reject random non-whitespace, non-printing characters now if (c < ' ' || c > '~') { - ppErr( (char *)MH_P0071, c); // "Ignoring illegal char 0x%x" + ppErr( MH_P0071, c); // "Ignoring illegal char 0x%x" goto reget; } // single: // 1-char cases may here or fall in @@ -2540,7 +2540,7 @@ RC FC ppcId( int erOp) // first char must be letter, _, $ if (!(isalphaW(c) || strchr( "$_", c)) ) - return erOp==IGN ? RCBAD : ppErr( (char *)MH_P0072); // "Identifier expected" + return erOp==IGN ? RCBAD : ppErr( MH_P0072); // "Identifier expected" // scan to end identifier. following chars may also be digits USI n = 0; @@ -2629,7 +2629,7 @@ SI FC ppCNdc() { /* possible bug, as ppCDc passes comments and there is no provision to back up over the comment so ppCNdc can return comment chars */ - ppWarn( (char *)MH_P0073); /* "Internal warning: possible bug detected in pp.cpp:ppCNdc(): \n" + ppWarn( MH_P0073); /* "Internal warning: possible bug detected in pp.cpp:ppCNdc(): \n" " Character gotten with decomment, ungotten, \n" " then gotten again without decomment. " */ ppRechar = 0; @@ -2655,7 +2655,7 @@ LOCAL void FC ppUncNdc() // unget char gotten with ppCNdc /*======================== ERROR MESSAGE INTERFACES ========================*/ //=========================================================================== -RC CDEC ppErr( char *message, ...) +RC CDEC ppErr( MSGORHANDLE message, ...) // preprocessor error message - most used style { va_list ap; @@ -2663,7 +2663,7 @@ RC CDEC ppErr( char *message, ...) return ppErv( 255, 1, 1, 0, message, ap); } // ppErr //=========================================================================== -RC CDEC ppWarn( char *message, ...) +RC CDEC ppWarn( MSGORHANDLE message, ...) // preprocessor warning - does not delete execution { va_list ap; @@ -2671,7 +2671,7 @@ RC CDEC ppWarn( char *message, ...) return ppErv( 255, 1, 1, 1, message, ap); } // ppWarn //=========================================================================== -RC CDEC ppErn( char *message, ...) +RC CDEC ppErn( MSGORHANDLE message, ...) // preprocessor error message with no file line text echo { va_list ap; @@ -2690,9 +2690,9 @@ LOCAL RC FC ppErv( bit priority: 4 if possible, else 2, else 1. */ SI shoCaret, // show caret at position (only if text shown) SI shoFnLn, // show file name and line number - SI isWarn, // 0 for error (errCount++), 1 warning (display suppressible), 2 info. - char *fmt, // message text or handle (see messages.cpp) - va_list ap ) // vprintf-style arg list + SI isWarn, // 0 for error (errCount++), 1 warning (display suppressible), 2 info. + MSGORHANDLE fmt, // message text or handle (see messages.cpp) + va_list ap ) // vprintf-style arg list // rets RCBAD for convenience, even if isWarn. { @@ -2803,7 +2803,7 @@ x isWarn ? "Warning" : "Error" ); x else if (inDepth > 0 && isf) // if a file is open x sprintf( where, "%s at line %d of file '%s': ", x isWarn ? "Warning" : "Error", -x (INT)isf->line, isf->Name() ); +x isf->line, isf->Name() ); #else // try microsoft-like format, 2-91 // make up 'where': "(): Error/Warning: " text @@ -2814,7 +2814,7 @@ x (INT)isf->line, isf->Name() ); isWarn ? "Warning" : "Error" ); else if (inDepth > 0 && isf) // if a file is open sprintf( where, "%s(%d): %s: ", - getFileName(isf->fileIx), (INT)isf->line, + getFileName(isf->fileIx), isf->line, isWarn ? "Warning" : "Error" ); #endif @@ -2975,12 +2975,12 @@ LOCAL RC FC ppcDoI( // decode/execute preprocessor command inner. call ppctIni( if (ppCDc()!='#') // pass # ppUncDc(); // unless caller didn't transmit it if (ppcId(IGN)) // scan word to ppIdtx[] - return ppErr( (char *)MH_P0030); // errMsg "Invalid preprocessor command: word required immediately after '#'" + return ppErr( MH_P0030); // errMsg "Invalid preprocessor command: word required immediately after '#'" strcpy( ppcWord, "#"); strcpy( ppcWord+1, ppIdtx); // save word for errMsgs if (ppCase == 0) // if ppC did not find id in table { if (ifOn) - return ppErr((char*)MH_P0031, ppcWord); // "unrecognized preprocessor command '%s'" + return ppErr(MH_P0031, ppcWord); // "unrecognized preprocessor command '%s'" // else #if-out unrecognized #cmd, fall thru / ignored below } @@ -2994,11 +2994,11 @@ LOCAL RC FC ppcDoI( // decode/execute preprocessor command inner. call ppctIni( case PPCELSE: if (ifDepth <= 1) // if not under #if/ifdef - return ppErr( (char *)MH_P0032 ); // "#else not preceded by #if" + return ppErr( MH_P0032 ); // "#else not preceded by #if" if (ifDepth < IFDEPTH) // compile stays off if excess nesting { if (iff->elSeen) - return ppErr( (char *)MH_P0033, // "More than one #else for same #if (#if is at line %d of file %s)" + return ppErr( MH_P0033, // "More than one #else for same #if (#if is at line %d of file %s)" iff->line, getFileName(iff->fileIx) ); iff->elSeen = 1; // say 'else' seen for this 'if' value = (iff->thisOn | iff->hasBeenOn) == 0; // goes on if off & has not been on @@ -3016,7 +3016,7 @@ elifJoins: ; // set compile on or off per 'value' case PPCENDIF: if (ifDepth <= 1) // note depth 1 when no #if's - return ppErr( (char *)MH_P0034 ); // "#endif not preceded by #if" + return ppErr( MH_P0034 ); // "#endif not preceded by #if" // close out a #if level ifDepth--; // pop a level // use next outer level @@ -3041,7 +3041,7 @@ elifJoins: ; // set compile on or off per 'value' ifDepth++; // count #if nesting level if (ifDepth >= IFDEPTH) { - ppErr( (char *)MH_P0035); // "Too many nested #if's, skipping to #endif" + ppErr( MH_P0035); // "Too many nested #if's, skipping to #endif" ifOn = 0; // program continues with compilation off till nest count not excessive isf->lineSent = 0; // say send #line next time compile is on } @@ -3071,14 +3071,14 @@ elifJoins: ; // set compile on or off per 'value' /*lint -e616 */ case PPCELIF: if (ifDepth <= 1) // if not under #if/ifdef - return ppErr( (char *)MH_P0036); // "#elif not preceded by #if" + return ppErr( MH_P0036); // "#elif not preceded by #if" if (ifDepth >= IFDEPTH) // compile stays off if excess nesting { noCheckEnd++; // suppress end check: expr not parsed break; } if (iff->elSeen) - return ppErr( (char *)MH_P0037, // "#elif after #else (for #if at line %d of file %s )" + return ppErr( MH_P0037, // "#elif after #else (for #if at line %d of file %s )" iff->line, getFileName(iff->fileIx) ); if ( ifOn // if compile on, it goes off || iff->hasBeenOn // if has been on, stays off @@ -3109,7 +3109,7 @@ elifJoins: ; // set compile on or off per 'value' case PPCINCLUDE: DEBLC(c1); // char b4 filename: < or " if (strchr( "<\"", c1)==NULL) - return ppErr( (char *)MH_P0038); // "'<' or '\"' expected" + return ppErr( MH_P0038); // "'<' or '\"' expected" c2 = (c1 == '<') ? '>' : c1; for (q = fnBuf; ; ) // scan/copy file name { @@ -3117,7 +3117,7 @@ elifJoins: ; // set compile on or off per 'value' if (c==c2) // if expected terminator break; if (c==EOF) // if end of input - return ppErr( (char *)MH_P0045, c2); // "Closing '%c' not found" + return ppErr( MH_P0045, c2); // "Closing '%c' not found" if (q < fnBuf + sizeof(fnBuf)-1) // truncate at bufSize *q++ = (char)c; // copy name so can terminate } @@ -3149,7 +3149,7 @@ elifJoins: ; // set compile on or off per 'value' case PPCCEX: // eval/print const expr at compile time: // development aid CSE_E( ppCex( &value, ppcWord) ) // eval const expr - printf( " %d ", (INT)value); // display value now + printf( " %d ", value); // display value now break; case PPCSAY: // display rest of line at compile time: @@ -3189,7 +3189,7 @@ elifJoins: ; // set compile on or off per 'value' break; default: - return ppErr( (char *)MH_P0039); // "Internal error in ppcDoI: bad 'ppCase'" + return ppErr( MH_P0039); // "Internal error in ppcDoI: bad 'ppCase'" } } // inner switch (ppCase) /*lint +e616*/ @@ -3203,7 +3203,7 @@ elifJoins: ; // set compile on or off per 'value' while (isspaceW(c)); // pass whitespace if (c != EOF) // expect end of line unex: // CHECKEND macro comes here - return ppErr((char *)MH_P0040); // "Unexpected stuff after preprocessor command" + return ppErr(MH_P0040); // "Unexpected stuff after preprocessor command" } return RCOK; @@ -3254,7 +3254,7 @@ const int MAXVAL = 16384; // max #define value size. continue; // get next arg if (c==')') // ) terminates arg list break; // done args - return ppErr( (char *)MH_P0041); // "Comma or ')' expected" + return ppErr( MH_P0041); // "Comma or ')' expected" } } @@ -3292,11 +3292,11 @@ const int MAXVAL = 16384; // max #define value size. if (n <= MAXVAL) // unless too long theVal[n] = (char)c; // store char else if (n==MAXVAL) // msg once per define only - ppErn( (char *)MH_P0042); // "Overlong #define truncated" + ppErn( MH_P0042); // "Overlong #define truncated" n++; } // for ( ; ; ): value loop if (inQuotes) // newline even in quotes terminates define - ppWarn( (char *)MH_P0043); // "Unbalanced quotes in #define" + ppWarn( MH_P0043); // "Unbalanced quotes in #define" /* and continue, later getting whatever error "text causes?? what does c compiler do in such a case? no msg at define? */ @@ -3364,7 +3364,7 @@ RC FC addDefine( // enter definition in preprocessor symbol table if ( nA != defp->nA || _stricmp(id,defp->id) // case-insensitive tentative 11-94 (also pp.cpp, cuparse.cpp, etc) || strcmp(text, defp->text) ) - rc = ppErr((char *)MH_P0046, ppIdtx); // "Redefinition of '%s'" + rc = ppErr(MH_P0046, ppIdtx); // "Redefinition of '%s'" // delete dm items of rejected definition for (i = 0; i < nA; i++) @@ -3430,7 +3430,7 @@ LOCAL SI FC isDefined( // non-0 if id is already #defined void FC msgOpenIfs() // issue diagnostic messages for any unclosed #if's { for (SI i = ifDepth; --i >= 1; ) - ppErn( (char *)MH_P0044, // "'#endif' corresponding to #if at line %d of file %s not found" + ppErn( MH_P0044, // "'#endif' corresponding to #if at line %d of file %s not found" ifStk[i].line, getFileName(ifStk[i].fileIx) ); } // msgOpenIfs @@ -3440,7 +3440,7 @@ t void FC dumpDefines() // display all defines t{ t for (STAE *pp = defSytb.p; pp < defSytb.p + defSytb.n; pp++) t { DEFINE *p = (DEFINE *)pp->stbk; -t printf( " %d %16s", (INT)pp->iTokTy, p->id); +t printf( " %d %16s", pp->iTokTy, p->id); t if (p->nA) t { printf("("); t for (SI i = 0; i < p->nA; i++) @@ -3532,8 +3532,8 @@ LOCAL RC FC cex( SI *pValue, char *tx) // evaluate preprocessor const expr to ppParSp = ppParStk-1; // init evaluation stack CSE_E( ceval( PREOF, tx) ) // evaluate expression if (ppParSp != ppParStk + 0) // check ppParStk level: devel aid - return ppErr( (char *)MH_P0050, // "Internal error:\n parse stack level %d not 1 after constant expression" - INT((ppParSp-ppParStk) + 1) ); + return ppErr( MH_P0050, // "Internal error:\n parse stack level %d not 1 after constant expression" + (ppParSp-ppParStk) + 1 ); *pValue = ppParSp->value; // return result return RCOK; // other returns above (CSE_E macros) @@ -3549,12 +3549,12 @@ LOCAL RC FC ceval( SI toprec, char *tx) // interpret (parse/execute) consta on good return: terminating token ungotten but ppPrec & ppTokety set for it. ppParSp ++'d, ppParStk frame has info on expression. */ { -#define NOVALUECHECK if (ppLsPrec >= PROP) return ppErr( (char *)MH_P0051, ppToktx ) +#define NOVALUECHECK if (ppLsPrec >= PROP) return ppErr( MH_P0051, ppToktx ) // "Syntax error: probably operator missing before '%s'" -#define EXPECT(ty,str) if (ppToke() != (ty)) return ppErr( (char *)MH_P0052, (str) ); // "'%s' expected" +#define EXPECT(ty,str) if (ppToke() != (ty)) return ppErr( MH_P0052, (str) ); // "'%s' expected" RC rc; - printif( ppTrace," ceval(%d) ", (INT)toprec ); // cueval.c + printif( ppTrace," ceval(%d) ", toprec ); // cueval.c ppPrec = 0; // nothing yet: prevent "operator missing before" message if expression starts with operand CSE_E( ppNewSf()) // start new parse stack frame for this expression @@ -3569,7 +3569,7 @@ LOCAL RC FC ceval( SI toprec, char *tx) // interpret (parse/execute) consta // done if token's precedence <= "toprec" arg if (ppPrec <= toprec) // if < this ceval() call's goal { - printif( ppTrace," exprDone %d ", (INT)ppPrec); + printif( ppTrace," exprDone %d ", ppPrec); break; // stop b4 this token } @@ -3621,11 +3621,11 @@ LOCAL RC FC ceval( SI toprec, char *tx) // interpret (parse/execute) consta // unexpected: improper use or token with no valid use yet //csu: case CSU: // believed usually impossible for terminators due to low ppPrec's - return ppErr( (char *)MH_P0053, ppToktx); // "Unexpected '%s'" + return ppErr( MH_P0053, ppToktx); // "Unexpected '%s'" default: - return ppErr( (char *)MH_P0054, // "Unrecognized opTbl .cs %d for token='%s' ppPrec=%d, ppTokety=%d." - (INT)ppOpp->cs, ppToktx, (INT)ppPrec, (INT)ppTokety ); + return ppErr( MH_P0054, // "Unrecognized opTbl .cs %d for token='%s' ppPrec=%d, ppTokety=%d." + ppOpp->cs, ppToktx, ppPrec, ppTokety ); // additional cases by token type: case CSCUT: @@ -3637,8 +3637,8 @@ LOCAL RC FC ceval( SI toprec, char *tx) // interpret (parse/execute) consta goto notInPp; // above default: - return ppErr( (char *)MH_P0055, // "Unrecognized ppTokety %d for token='%s' ppPrec=%d." - (INT)ppTokety, ppToktx, (INT)ppPrec ); + return ppErr( MH_P0055, // "Unrecognized ppTokety %d for token='%s' ppPrec=%d." + ppTokety, ppToktx, ppPrec ); case CUTSI: // integer constant, value in ppSIval NOVALUECHECK; @@ -3651,7 +3651,7 @@ LOCAL RC FC ceval( SI toprec, char *tx) // interpret (parse/execute) consta // condition-expr precedes '?' if ( ppParSp < ppParStk || ppParSp->ty != TYSI ) // if no preceding value - return ppErr( (char *)MH_P0056, ppOpp->tx ); // "Preceding constant integer value expected before %s" + return ppErr( MH_P0056, ppOpp->tx ); // "Preceding constant integer value expected before %s" // then-expr. NB prec of ':' is prec of '?' - 1. CSE_E( ceval( ppPrec-1, ppOpp->tx) ) // get a value, new ppParStk frame. EXPECT( CUTCLN, ":") // err if : not next @@ -3682,13 +3682,13 @@ LOCAL RC FC ceval( SI toprec, char *tx) // interpret (parse/execute) consta } // switch (case) if (ppParSp < ppParStk) - return ppErr( (char *)MH_P0057); // "Internal error: parse stack underflow" + return ppErr( MH_P0057); // "Internal error: parse stack underflow" } // for ( ; ; ) // check that something was parsed if (ppParSp->ty==TYNONE) // indicates no operand done - return ppErr( (char *)MH_P0058, tx); // "Value expected after %s" + return ppErr( MH_P0058, tx); // "Value expected after %s" // unget terminating token and return ppUnToke(); // unget token, local, only call @@ -3727,7 +3727,7 @@ LOCAL RC ppUnOp( // parse arg to unary operator and execute case PSNUL: break; // do nothing (unary +) default: - ppErr( (char *)MH_P0059, (INT)opSi ); // "ppUnOp() internal error: unrecognized 'opSi' value %d" + ppErr( MH_P0059, opSi ); // "ppUnOp() internal error: unrecognized 'opSi' value %d" } ppParSp->value = v; // put result back ppParSp->ty = TYSI; // have integer value @@ -3746,7 +3746,7 @@ LOCAL RC FC ppBiOp( // parse 2nd arg to binary operator and execute if ( ppParSp < ppParStk || ppParSp->ty != TYSI ) // if preceding value wrong type - return ppErr( (char *)MH_P0060, tx ); // "Preceding constant integer value expected before %s" + return ppErr( MH_P0060, tx ); // "Preceding constant integer value expected before %s" CSE_E( ceval( toprec, tx) ) // get following expression (v) u = (ppParSp-1)->value; // fetch operands to shorten cases v = ppParSp->value; // .. @@ -3803,7 +3803,7 @@ LOCAL RC FC ppBiOp( // parse 2nd arg to binary operator and execute case 0: break; default: - ppErr( (char *)MH_P0061, (INT)opSi ); // "ppBiOp() internal error: unrecognized 'opSi' value %d" + ppErr( MH_P0061, opSi ); // "ppBiOp() internal error: unrecognized 'opSi' value %d" } CSE_E( ppPopSf() ) // pop 2nd ppParStk frame (discard v) ppParSp->value = u; // store result in 1st frame @@ -3815,7 +3815,7 @@ LOCAL RC FC ppNewSf() // start new parse stack frame: call at start (sub)expres { // overflow check if ((char *)ppParSp >= (char *)ppParStk + sizeof(ppParStk) - sizeof(PPPARSTK) ) - return ppErr( (char *)MH_P0062); /* "Preprocessor parse stack overflow error: \n" + return ppErr( MH_P0062); /* "Preprocessor parse stack overflow error: \n" " preprocessor constant expression probably too complex" */ // allocate and init new frame ppParSp++; // point next frame diff --git a/src/rmkerr.cpp b/src/rmkerr.cpp index 5ff3c42de..6c63dffa3 100644 --- a/src/rmkerr.cpp +++ b/src/rmkerr.cpp @@ -90,7 +90,10 @@ static int screenQuiet = 0; // suppress screen messages if op&QUIETIF && screen /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ LOCAL RC errCritV( int erOp, int isWarn, const char* msTx, va_list ap); -LOCAL int presskey( int erAction); +#if 0 +0 out of service +0 LOCAL int presskey( int erAction); +#endif // ================================================================================ void errClean() // cleanup function: DLL version should release ALL memory. rob 12-93. @@ -366,7 +369,7 @@ int errCount() // get error count. Rob 5-97. } // errCount // ================================================================================ -void ourAssertFail( char * condition, char * file, int line) // assertion failure fatal error message +void ourAssertFail( const char* condition, const char* file, int line) // assertion failure fatal error message /* for ASSERT macro (cnglob.h): same as compiler library "assert" debugging macro except exits our way so DDE is properly terminated, etc. @@ -446,7 +449,7 @@ RC CDEC issueMsg( // general info/warn/error msg issuer // 1: warn // 2: info // + hi bits: NOSCRN, NOERRFILE, NOREPORT - const char* mOrH, // ptr to printf fmt message or message handle + MSGORHANDLE mOrH, // ptr to printf fmt message or message handle ... ) // args as reqd by mOrH // difference from error message: error count not incremented; "Info: " not "Error: " prefixed. @@ -456,25 +459,25 @@ RC CDEC issueMsg( // general info/warn/error msg issuer { va_list ap; va_start( ap, mOrH); - return errV( REG/*erOp*/, isWarn, mOrH, ap); + return errV( REG, isWarn, mOrH, ap); } // info //-------------------------------------------------------------------------------- RC CDEC info( // issue information message - const char* mOrH, // ptr to printf fmt message or message handle + MSGORHANDLE mOrH, // ptr to printf fmt message or message handle ...) // args as reqd by mOrH // difference from error message: error count not incremented; "Info: " not "Error: " prefixed. // difference from warning message: displayed on screen even if setWarnNoScrn(1) called. -// returns caller's mOrH, or RCBAD if mOrH is char * +// returns caller's mOrH, or RCBAD if mOrH is not handle { va_list ap; va_start(ap, mOrH); - return errV(REG/*erOp*/, 2/*isWarn*/, mOrH, ap); + return errV( REG, 2/*isWarn*/, mOrH, ap); } // info // ================================================================================ RC CDEC warn( // issue warning message, rob 5-97 - const char* mOrH, // ptr to printf fmt message or message handle + MSGORHANDLE mOrH, // ptr to printf fmt message or message handle ... ) // args as reqd by mOrH // differences from error message: @@ -482,30 +485,17 @@ RC CDEC warn( // issue warning message, rob 5-97 // text is prefixed with "Warning: " not "Error: "; // if setWarnNoScrn(1) has been called, message not displayed on screen (still in file, vr). -// returns caller's mOrH, or RCBAD if mOrH is char * +// returns caller's mOrH, or RCBAD if mOrH is not handle { va_list ap; va_start( ap, mOrH); - return errV( REG/*erOp*/, 1/*isWarn*/, mOrH, ap); + return errV( REG, 1/*isWarn*/, mOrH, ap); } // warn -// ================================================================================ -RC CDEC err( // issue error message, variant without 'erOp' arg - const char* mOrH, // ptr to printf fmt message (e.g. "Bad value: %d") or message handle (e.g. (char *)MH_X1002) - ...) // args as reqd by mOrH - -// implicit error action "REG": output msg, return to caller, no termination of program. - -// returns caller's mOrH, or RCBAD if mOrH is char * -{ - va_list ap; - va_start( ap, mOrH); - return errV( REG/*erOp*/, 0, mOrH, ap); // use variable arg list version -} // err -// ================================================================================ +// =============================================================================== RC CDEC err( // issue error message int erOp, // error action: IGN, (REG), WRN, ABT, PWRN, PABT, NOPREF: cnglob.h, more comments in errI(). - const char* mOrH, // ptr to printf fmt message (e.g. "Bad value: %d") - // OR message handle (e.g. (char *)MH_X1002); message handles are + MSGORHANDLE mOrH, // ptr to printf fmt message (e.g. "Bad value: %d") + // OR message handle (e.g. MH_X1002); message handles are // defined in msghan.h and are associated with text in msgtab:msgTbl[] ...) // args as reqd by mOrH @@ -525,8 +515,8 @@ RC errV( // report error, variable arg list version // 1: warning: no errCount++; don't display on screen if setWarnNoScrn(1) has been called. // 2: info: no errCount++. // + hi bits NOSCRN, NOERRFILE, NOREPORT - const char* mOrH, /* ptr to printf fmt message (e.g. "Bad value: %d") - OR message handle (e.g. (char *)MH_X1002); message handles are + MSGORHANDLE mOrH, /* ptr to printf fmt message (e.g. "Bad value: %d") + OR message handle (e.g. MH_X1002); message handles are defined in msghan.h and are associated with text in msgtab:msgTbl[] */ va_list ap ) // ptr to variable arg list containing args as reqd by mOrH @@ -748,8 +738,8 @@ RC logit( // put remark in log report and display on screen (NOT FC, var args) // off: move to beg of next line if needed, then display rmk // DASHES on: separate from preceding and following remarks with ----------- lines rob 11-20-91 // NOSCRN on: do not display on screen - const char* mOrH, // ptr to printf fmt message (e.g. "Bad value: %d") - // OR message handle (e.g. (char *)MH_X1002); message handles are + MSGORHANDLE mOrH, // ptr to printf fmt message (e.g. "Bad value: %d") + // OR message handle (e.g. MH_X1002); message handles are // defined in msghan.h and are associated with text in msgtab:msgTbl[] ... ) // args as reqd by mOrH @@ -852,8 +842,8 @@ RC screen( // display remark on display on screen only // off: move to beg of next line if needed, then display rmk // DASHES on: separate from preceding and following remarks with ----------- lines // QUIETIF: suppress display if screenQuiet - const char* mOrH, // ptr to printf format message (e.g. "Bad value: %d") - // OR message handle (e.g. (char *)MH_X1002); message handles are + MSGORHANDLE mOrH, // ptr to printf format message (e.g. "Bad value: %d") + // OR message handle (e.g. MH_X1002); message handles are // defined in msghan.h and are associated with text in msgtab:msgTbl[] ...) // args as reqd by mOrH @@ -1056,9 +1046,7 @@ LOCAL int presskey( // prompt user after error message display /////////////////////////////////////////////////////////////////////////////// #define VR_DEBUGPRINT -#if defined( VR_DEBUGPRINT) && defined( VRR) -static int dbgVrh = 0; // virtual report handle for debug report -#else +#if !defined( VR_DEBUGPRINT) static FILE* dbgFile = NULL; // FILE to receive dbg printing (or NULL) #endif static DWORD dbgMsk = 0; // mask (allows selective printing) diff --git a/src/rmkerr.h b/src/rmkerr.h index 779167824..ee5ed7069 100644 --- a/src/rmkerr.h +++ b/src/rmkerr.h @@ -8,7 +8,7 @@ #define _RMKERR_H #include "vecpak.h" -/*-------------------------------- DEFINES --------------------------------*/ + // see cnglob.h for MANY rmkerr-related defines // including IGN, WRN, ABT, NONL, DASHES, NOSCRN ... @@ -19,14 +19,57 @@ enum LINESTAT dashed // at start of a line and preceding line is known to be ---------------. }; - -/*--------------------------- PUBLIC VARIABLES ----------------------------*/ - // virtual report handles (see vrpak.cpp) for reports generated in rmkerr.cpp extern int VrErr; // set/used/cleared in rmkerr.cpp and cse.cpp. extern int VrLog; // .. -/*------------------------- FUNCTION DECLARATIONS -------------------------*/ +/////////////////////////////////////////////////////////////////////////////// +// MSGORHANDLE: Generalized message text +// holds either a pointer to a message or handle for MsgFind() +/////////////////////////////////////////////////////////////////////////////// +struct MSGORHANDLE +{ + MSGORHANDLE() : mh_msgOrHandle(nullptr) {} + MSGORHANDLE(const char* msg) : mh_msgOrHandle(msg) {} + MSGORHANDLE(char* msg) = delete; + MSGORHANDLE(MH mh) + : mh_msgOrHandle(reinterpret_cast(static_cast(mh))) {} + MSGORHANDLE operator=(MH mh) + { mh_msgOrHandle = reinterpret_cast(static_cast(mh)); + return *this; + } + MSGORHANDLE operator=(const char* msg) + { + mh_msgOrHandle = msg; + return *this; + } + + void mh_Clear() { mh_msgOrHandle = nullptr; } + bool mh_IsNull() const { return mh_msgOrHandle == nullptr; } + bool mh_IsSet() const { return mh_msgOrHandle != nullptr; } + bool mh_IsHandle() const + { + return reinterpret_cast(mh_msgOrHandle) <= 0xffff; + } + + RC mh_GetRC() const + { + return mh_IsHandle() ? mh_GetHandle() : RCBAD; + } + + MH mh_GetHandle() const + { + return static_cast(reinterpret_cast(mh_msgOrHandle)); + } + const char* mh_GetMsg( const char* nullMsg="") const; + +private: + const char* mh_msgOrHandle; // point to message + // OR integer MH cast to const char* + // (if < 16 bits, assume MH) + +}; // struct MSGORHANDLE + void errClean(); #ifdef WINorDLL @@ -52,20 +95,19 @@ void clearErrCount(); void incrErrCount(); int errCount(); -void ourAssertFail( char * condition, char * file, int line); +void ourAssertFail( const char* condition, const char* file, int line); RC CDEC warnCrit( int erOp, const char* msg, ...); RC CDEC errCrit( int erOp, const char* msg, ...); -RC CDEC issueMsg(int isWarn, const char* mOrH, ...); -RC CDEC info( const char* mOrH, ...); -RC CDEC warn( const char* mOrH, ...); -RC CDEC err( const char* mOrH, ...); -RC CDEC err( int erOp, const char* mOrH, ...); -RC errV( int erOp, int isWarn, const char* mOrH, va_list ap); +RC CDEC issueMsg(int isWarn, MSGORHANDLE mOrH, ...); +RC CDEC info( MSGORHANDLE mOrH, ...); +RC CDEC warn( MSGORHANDLE mOrH, ...); +RC CDEC err( int erOp, MSGORHANDLE mOrH, ...); +RC errV( int erOp, int isWarn, MSGORHANDLE mOrH, va_list ap); RC errI( int erOp, int isWarn, const char* text); const char* GetSystemMsg( DWORD lastErr=0xffffffff); -RC logit( int op, const char* mOrH, ...); +RC logit( int op, MSGORHANDLE mOrH, ...); int logitNF( const char* text, int op=0); -RC screen( int op, const char* mOrH, ...); +RC screen( int op, MSGORHANDLE mOrH, ...); void screenNF(const char* text, int op = 0); int setScreenQuiet( int sq); bool mbIErr( const char* fcn, const char* fmt, ...); diff --git a/src/solar.cpp b/src/solar.cpp index 611e138a2..747b9fbb9 100644 --- a/src/solar.cpp +++ b/src/solar.cpp @@ -196,14 +196,14 @@ t UNMAINTAINED 8 - 9 - 90 t main() t t for (doy = jd1; doy < jd2; doy += jdinc) t { t #if 0 t sldaydat(doy, &dec, &eqtime, &extbm); - t printf("Day %d Decl = %f\n", (INT)doy, DEG(dec)); - t #elseif 0 t printf("\n%d \n", (INT)doy); + t printf("Day %d Decl = %f\n", doy, DEG(dec)); + t #elseif 0 t printf("\n%d \n", doy); t slday(doy, sltmSLR); t for (i = 0; i < 24; i++) t { cq = slcoshr(sdcos, i); t ci = slcosinc(sdcos, (float)i + .5); - t printf(" %d %f %f\n", (INT)i, cq, ci); + t printf(" %d %f %f\n", i, cq, ci); t } t #else t while (1) t @@ -643,7 +643,7 @@ void FC sldec(/* Set declination-related data in current SLLOCDAT struct */ } /* for ihr 0 to 23 */ #ifdef PRINTSTUFF x for (ihr = 0; ihr < 24; ihr++) x printf("\n%d %f %f %f %f %f", - (INT)ihr, + ihr, slloccur->sunupf[ihr], x slloccur->dircos[ihr][0], slloccur->dircos[ihr][1], @@ -758,7 +758,7 @@ int slsurfhr( // Calculate solar values for a surface for an hour + faz2 * slloccur->dircos[ihx][2]; #ifdef PRINTSTUFF - x printf("\n%d %f %f %f", (INT)ihr, *pCosi, *pAzm, *pCosz); + x printf("\n%d %f %f %f", ihr, *pCosi, *pAzm, *pCosz); #endif return TRUE; } // slsurfhr diff --git a/src/srd.h b/src/srd.h index e10f41974..60b79da3f 100644 --- a/src/srd.h +++ b/src/srd.h @@ -169,7 +169,7 @@ struct VALNDT USI vt_dt; // data type; initially TYFL/TYSTR // DTFLOAT/DTCULSTR at runtime - VALNDT() : vt_dt( DTNONE), vt_val( 0) {} + VALNDT() : vt_val( 0), vt_dt( DTNONE) {} ~VALNDT() { vt_ReleaseIfString(); diff --git a/src/strpak.cpp b/src/strpak.cpp index 70539bb4a..bef452f5a 100644 --- a/src/strpak.cpp +++ b/src/strpak.cpp @@ -18,7 +18,7 @@ #if defined( _DEBUG) #define new DEBUG_NEW #undef THIS_FILE -static char THIS_FILE[] = __FILE__; +// static char THIS_FILE[] = __FILE__; #endif // === Tmpstr === @@ -44,7 +44,7 @@ struct CULSTREL { enum { uslEMPTY, uslDM, uslOTHER}; - CULSTREL() : usl_str( nullptr), usl_freeChainNext( 0), usl_status( uslEMPTY) + CULSTREL() : usl_str( nullptr), usl_status( uslEMPTY), usl_freeChainNext( 0) { } CULSTREL(const char* str) : CULSTREL() @@ -53,8 +53,8 @@ struct CULSTREL } CULSTREL(CULSTREL&& src) noexcept - : usl_str{ src.usl_str }, usl_freeChainNext{ src.usl_freeChainNext }, - usl_status{ src.usl_status } + : usl_str{ src.usl_str }, usl_status{ src.usl_status }, + usl_freeChainNext{ src.usl_freeChainNext } { src.usl_str = nullptr; // prevent dmfree of string in moved-out-of source } @@ -520,19 +520,16 @@ char* strSpacePad( // Pad a string with spaces (e.g. for FORTRAN) // ==================================================================== const char* FC strffix( // put a filename in canonical form - const char *name, // input filname - const char *ext ) // default extension including period + const char* name, // input filname + const char* ext ) // default extension including period // returns uppercase filename with extension in Tmpstr[] { - char *nu, *lastslsh; - - lastslsh = strrchr( (char *)name, '\\'); - if (strrchr( name, '.') <= lastslsh) - nu = strtcat( name, ext, NULL); - else - nu = strtcat( name, NULL); - strTrim( nu, _strupr(nu)); + const char* lastslsh = strrchr( name, '\\'); + char* nu = (strrchr( name, '.') <= lastslsh) + ? strtcat( name, ext, NULL) + : strtcat( name, NULL); + strTrim( nu, _strupr(nu)); // trim in place (in Tmpstr) return nu; } // strffix //------------------------------------------------------------------- @@ -565,7 +562,7 @@ const char* FC strtPathCat( // concatenate file name onto path, adding interve // returns assembled file pathname in Tmpstr[] { - char *addMe; + const char* addMe; int len = strlenInt(path); char pathLast = path[len-1]; @@ -875,7 +872,7 @@ const char* FC scWrapIf( // concatenate strings with wrap if needed } // scWrapIf // ====================================================================== const char* CDEC strtprintf( // make like sprintf and return pointer to result in tmpstr - const char* mOrH, ...) // format string or message handle + MSGORHANDLE mOrH, ...) // format string or message handle { va_list ap; va_start( ap, mOrH); @@ -883,7 +880,9 @@ const char* CDEC strtprintf( // make like sprintf and return pointer to result } // strtprintf // ====================================================================== const char* FC strtvprintf( // make like vsprintf and return pointer to result in tmpstr. - const char * mOrH, va_list ap) // format string or message handle + MSGORHANDLE mOrH, // format string or message handle + // mOrH.IsNull(): return "" + va_list ap) // args { char buf[ MSG_MAXLEN]; @@ -893,7 +892,7 @@ const char* FC strtvprintf( // make like vsprintf and return pointer to result } // strtvprintf // ====================================================================== WStr WStrPrintf( // make like sprintf and return pointer to result in XSTR - const char* mOrH, ...) // format string or message hangle + MSGORHANDLE mOrH, ...) // format string or message hangle { va_list ap; va_start( ap, mOrH); @@ -901,7 +900,7 @@ WStr WStrPrintf( // make like sprintf and return pointer to result in XSTR } // WStrPrintf // ====================================================================== WStr WStrVprintf( // make like vsprintf and return pointer to result in tmpstr. - const char* mOrH, // format string or message handle + MSGORHANDLE mOrH, // format string or message handle va_list ap /*=NULL*/) // arg list { char buf[ MSG_MAXLEN]; @@ -1258,7 +1257,7 @@ char* strCatIf( // conditional concatenation return d; } // strCatIf //------------------------------------------------------------------------- -char* strMakeTextList( // combine strings into text list (for msgs) +const char* strMakeTextList( // combine strings into text list (for msgs) const std::vector< const char*>& strs, // string pointers const char* brkLast, // final separator, typically "and" or "or" const char* brk /*=","*/, // separator @@ -1313,12 +1312,12 @@ char* strPluralize( // form plural of a word const char* wordPlural; } excpTbl[] = { - "goose", "geese", - "mouse", "mice", - "is", "are", - "has", "have", + { "goose", "geese"}, + { "mouse", "mice"}, + { "is", "are"}, + { "has", "have"}, // add add'l exceptions here here - NULL + { NULL, NULL } }; if (!word || !word[ 0]) *d = '\0'; @@ -1513,20 +1512,20 @@ int strReplace( // replace variant return count; } // strReplace2 //---------------------------------------------------------------------------- -char* stristr( // case-insensitive string find +const char* stristr( // case-insensitive string find const char * str1, // string in which to search const char * str2) // string to search for -// returns pointer within str1 of 1st char of substring matching str2 +// returns pointer within str1 to 1st char of substring matching str2 // NULL if not found { if (!str1 || !str2 || !*str2) - return (char *)str1; // empty, immediate match + return str1; // empty, immediate match - for (char* cp = (char *)str1; *cp; cp++) + for (const char* cp = str1; *cp; cp++) { if (toupper( *cp) == toupper( *str2)) { - char* s1 = cp; + const char* s1 = cp; const char* s2 = str2; while ( *s1 && *s2 && toupper( *s1) == toupper( *s2)) s1++, s2++; diff --git a/src/strpak.h b/src/strpak.h index d93793960..875d09f7a 100644 --- a/src/strpak.h +++ b/src/strpak.h @@ -93,8 +93,8 @@ char * FC strtmp( const char *s); char * CDEC strtcat( const char *s, ... ); char * CDEC strntcat( int n, ...); const char* scWrapIf( const char* s1, const char* s2, const char* tween, int lineLength=defaultCpl); -const char* strtprintf( const char *format, ...); -const char* strtvprintf( const char *format, va_list ap=NULL); +const char* strtprintf( MSGORHANDLE mOrH, ...); +const char* strtvprintf( MSGORHANDLE mOrH, va_list ap=NULL); int FC strlstin( const char *list, const char *str); const char* strOrdinal( int number); @@ -113,8 +113,8 @@ x char tolowerx( char *p ); // WStr variants WStr& WStrUpper( WStr& s); WStr& WStrLower( WStr& s); -WStr WStrPrintf( const char* mOrH, ...); -WStr WStrVprintf( const char* mOrH, va_list ap=NULL); +WStr WStrPrintf( MSGORHANDLE mOrH, ...); +WStr WStrVprintf( MSGORHANDLE mOrH, va_list ap=NULL); WStr WStrFmtFloatDTZ( double v, int maxPrec, int minPrec=0); WStr WStrDTZ( const WStr& s, int minPrec=0); @@ -141,7 +141,7 @@ char* strFill( char* d, const char* s, int len=-1); const char* strSuffix(int n, int options = 0); char* strTranslateEscapes( char* d, const char* s=NULL); char* strCatIf( char* d, size_t dSize, const char* brk, const char* s, int options=0); -char* strMakeTextList(const std::vector< const char*>& strs, const char* brkLast, +const char* strMakeTextList(const std::vector< const char*>& strs, const char* brkLast, const char* brk = ",", const char* brkPad = " "); char* strDeBar( char* d, const char* s=NULL); char* strDeQuote( char* d, const char* s=NULL); @@ -153,7 +153,7 @@ char* strRemoveCRLF(char* str); int strReplace( char* s, char cFrom, char sTo, int options=0); int strReplace(char* d, size_t dSize, const char* str, const char* sOld, const char* sNew, bool bCaseSens = false); -char* stristr( const char* str1, const char* str2); +const char* stristr( const char* str1, const char* str2); BOOL strMatch( const char* s1, const char* s2); #if CSE_COMPILER != CSE_COMPILER_MSVC int _stricmp(const char* char1, const char* char2); diff --git a/src/sytb.cpp b/src/sytb.cpp index acf89506c..6b8235141 100644 --- a/src/sytb.cpp +++ b/src/sytb.cpp @@ -103,15 +103,15 @@ RC FC syAdd( SYTBH *st, SI tokTy, BOO casi, STBK* stbk, int op) USI iTokTy, nAl; RC rc; - char* id = stbk->ID(); + const char* id = stbk->ID(); iTokTy = (tokTy & TOKTYMASK) | (casi ? SYTBCASI : 0); // checks if (st==NULL || id==NULL || *id=='\0') - return err( PWRN, (char *)MH_P0080); // display internal error msg "Sytb.cpp: bad call to syAdd" + return err( PWRN, MH_P0080); // display internal error msg "Sytb.cpp: bad call to syAdd" // returns RCBAD if (tokTy & ~TOKTYMASK) - return err( PWRN, (char *)MH_P0081, tokTy); // "Sytb.cpp: syAdd: tokTy 0x%x has disallowed hi bits" + return err( PWRN, MH_P0081, tokTy); // "Sytb.cpp: syAdd: tokTy 0x%x has disallowed hi bits" // enlarge allocation if nec (does initial alloc if st->p is NULL) if (st->n >= st->nAl) @@ -138,11 +138,11 @@ RC FC syAdd( SYTBH *st, SI tokTy, BOO casi, STBK* stbk, int op) if (op & DUPOK && p->iTokTy==iTokTy) return RCOK; // no msg, no duplicate add // report duplicate entry and ? continue - char * dupdId = stbk->ID(); + const char* dupdId = stbk->ID(); err( PWRN, // display internal error msg - (char *)MH_P0082, // "sytb.cpp:syAdd(): Adding symbol table entry '%s' (%d) \n that duplicates '%s' (%d)" - id, (INT)tokTy, - dupdId, INT(p->iTokTy & TOKTYMASK) ); + MH_P0082, // "sytb.cpp:syAdd(): Adding symbol table entry '%s' (%d) \n that duplicates '%s' (%d)" + id, tokTy, + dupdId, p->iTokTy & TOKTYMASK ); } ASSERT( p >= st->p); // 3-2-94. 8-95: ASSERT macro is in cnglob.h. ASSERT( p <= st->p + st->n); // .. @@ -192,7 +192,7 @@ RC FC syDel( SYTBH *st, SI tokTy, BOO casi, [[maybe_unused]] BOO nearId, char *i ; if (undefBad) err( PWRN, // display internal error msg - (char *)MH_P0083, // "sytb.cpp:syDel(): symbol '%s' not found in table" + MH_P0083, // "sytb.cpp:syDel(): symbol '%s' not found in table" id ); return RCBAD; } @@ -203,7 +203,7 @@ RC FC syDel( SYTBH *st, SI tokTy, BOO casi, [[maybe_unused]] BOO nearId, char *i { // always issue message for this? err( PWRN, // display internal error msg - (char *)MH_P0084, // "sytb.cpp:syDel(): bad call: token type / casi / nearId is 0x%x not 0x%x" + MH_P0084, // "sytb.cpp:syDel(): bad call: token type / casi / nearId is 0x%x not 0x%x" p->iTokTy, iTokTy ); return RCBAD; } diff --git a/src/sytb.h b/src/sytb.h index 74c101ebb..08c3939be 100644 --- a/src/sytb.h +++ b/src/sytb.h @@ -10,11 +10,11 @@ /*------------------------ SYMBOL TABLE STRUCTURES ------------------------*/ struct STBK // symbol table block base class // (actual *stbk structs are up to appl but always have id 1st) -{ char* id; +{ const char* id; STBK() : id( NULL) {} STBK( char* _id) : id( _id) {} STBK( const char* _id) : id( const_cast(_id)) {} - char* ID() const { return id; } + const char* ID() const { return id; } }; struct STAE // sym table array struct: SYTBH.p points to array of these { @@ -24,7 +24,7 @@ struct STAE // sym table array struct: SYTBH.p points to array of these USI iTokTy; // SYTBCASI bit: on if case-insensitive symbol. // lo bits (TOKTYMASK): appl's token type etc for symbol // CUTxxx define) */ - char* ID() const { return stbk->ID(); } + const char* ID() const { return stbk->ID(); } }; // struct STAE const USI SYTBCASI = 0x8000; // bit in iTokTy indicating case-insensitive entry const USI SYTBRES = 0x4000; // bit reserved for next feature to be added diff --git a/src/tdpak.cpp b/src/tdpak.cpp index 56f51699c..5bbb29e3c 100644 --- a/src/tdpak.cpp +++ b/src/tdpak.cpp @@ -107,12 +107,12 @@ t t for (year = 86; year < 93; year++) t { eday = year >= 0 && !(year%4) ? 366 : 365; t eday = 65; -t printf("\n%d %d", (INT)year, (INT)eday); +t printf("\n%d %d", year, eday); t for (jday = 1; jday <= eday; jday++) t { tddyi( jday, year, &idate); t if (tddiy(&idate) != jday) t ???; -t printf("\n%d %s", (INT)jday, tddis(&idate,buff)); +t printf("\n%d %s", jday, tddis(&idate,buff)); t } t} t #endif @@ -435,7 +435,7 @@ const char* tdtis( // Convert integer format time to string apchar = (hour < 12) ? " am" : " pm"; // get am or pm to append hour = (hour+11)%12 + 1; // convert 0..23 to 1..12 } - s += sprintf( s, "%d:%2.2d", (INT)hour, (INT)itm->min); // format hour:min, point to end + s += sprintf( s, "%d:%2.2d", hour, itm->min); // format hour:min, point to end if (itm->sec != -1) // seconds -1 --> no display sprintf( s, ":%2.2d", itm->sec); // format & append :seconds return strcat( sbeg, apchar); // append am/pm if any and return diff --git a/src/vrpak.cpp b/src/vrpak.cpp index 1027105f1..a5d5bb248 100644 --- a/src/vrpak.cpp +++ b/src/vrpak.cpp @@ -105,10 +105,10 @@ static SPL spl = { 0 }; // info about spool file, etc; points to VRI vr[] in dm /*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/ LOCAL RC vrPut( const char* s, int n, int incl); LOCAL RC vrCkHan( int vrh, VRI **pvr); -LOCAL RC vrErr( const char* fcn, const char* mOrH, ...); +LOCAL RC vrErr( const char* fcn, MSGORHANDLE mOrH, ...); static void vrpak2Clean(); -static RC vrErrIV( const char* file, const char* fcn, const char* mOrH, va_list ap=NULL); +static RC vrErrIV( const char* file, const char* fcn, MSGORHANDLE mOrH, va_list ap=NULL); static RC vrBufAl(); static RC vrBufLoad(); @@ -145,7 +145,7 @@ RC vrInit( const char* splFName) // initialize virtual report scheme if (!spl.isInit) // flag data-init 0 memset( &spl, 0, sizeof(spl)); // zero all members. probably redundant; insurance. if (spl.isOpen) // vrErr: program err msg fcn, below, interfaces to "err(" - vrErr( "vrInit", (char *)MH_R1201 ); // msg handle for "Ignoring redundant or late call" + vrErr( "vrInit", MH_R1201 ); // msg handle for "Ignoring redundant or late call" spl.splFName = strsave( splFName); spl.isInit = true; // say spl is initialized, don't 0 it again. @@ -553,7 +553,7 @@ LOCAL RC vrPut( // transmit n bytes to virtual report -- writes to vr spool fil dropFront( spl.p - spl.p1); // write/discard bytes from front of buffer if (!spl.p // if p not set -- buf was not alloc'd at start item -- nb 2+++ shd fit || n > spl.buf2 - spl.p2 ) // or still too little free space in buffer - return spl.vrRc = vrErr( "vrPut", (char *)MH_R1202); // "Too little buffer space and can't write: deadlock" + return spl.vrRc = vrErr( "vrPut", MH_R1202); // "Too little buffer space and can't write: deadlock" } // move bytes to buffer @@ -572,16 +572,16 @@ LOCAL RC vrCkHan( int vrh, VRI **pvr) // internal fcn to check handle, set point { // general checks if (!spl.isInit) - return vrErr( "vrCkHan", (char *)MH_R1203); // "Virtual reports not initialized" + return vrErr( "vrCkHan", MH_R1203); // "Virtual reports not initialized" if (spl.vrRc) // if there has been a previous serious error (already reported) return spl.vrRc; // silent bad return: nop any further calls if (!spl.isOpen) // unexpected after preceding checks (?) - return vrErr( "vrCkHan", (char *)MH_R1204); // "Virtual reports spool file not open" + return vrErr( "vrCkHan", MH_R1204); // "Virtual reports spool file not open" // check handle if (vrh <= 0 || vrh > spl.sp_nVrh) { - return vrErr( "vrCkHan", (char *)MH_R1205, vrh); // "Out of range virtual report handle %d" + return vrErr( "vrCkHan", MH_R1205, vrh); // "Out of range virtual report handle %d" } // point to table entry for handle @@ -590,7 +590,7 @@ LOCAL RC vrCkHan( int vrh, VRI **pvr) // internal fcn to check handle, set point // check vr table entry // always desired? if not caller must do: if (!vr->spooling) - return vrErr( "vrCkHan", (char *)MH_R1206, vrh); // "Virtual report %d not open to receive text" + return vrErr( "vrCkHan", MH_R1206, vrh); // "Virtual report %d not open to receive text" *pvr = vr; return spl.vrRc; // RCOK expected here @@ -600,14 +600,14 @@ LOCAL RC vrCkHan( int vrh, VRI **pvr) // internal fcn to check handle, set point //--------------------------------------------------------------------------------------------------------------------------- // local error message fcns //--------------------------------------------------------------------------------------------------------------------------- -LOCAL RC vrErr( const char* fcn, const char* mOrH, ...) // internal error fcn for vrpak.cpp only +LOCAL RC vrErr( const char* fcn, MSGORHANDLE mOrH, ...) // internal error fcn for vrpak.cpp only { va_list ap; va_start( ap, mOrH); return vrErrIV( "vrpak.cpp", fcn, mOrH, ap); // next } // vrErr //--------------------------------------------------------------------------------------------------------------------------- -static RC vrErrIV( const char* file, const char* fcn, const char* mOrH, va_list ap/*=NULL*/) +static RC vrErrIV( const char* file, const char* fcn, MSGORHANDLE mOrH, va_list ap/*=NULL*/) { char buf[MSG_MAXLEN]; @@ -623,7 +623,7 @@ static RC vrErrIV( const char* file, const char* fcn, const char* mOrH, va_list // issue message with caller's msg embedded. Uses another MSG_MAXLEN bytes of stack. err( PWRN, // PWRN: is program (internal) error - (char *)MH_R1200, // "[Internal error ]re virtual reports, file '%s', function '%s':\n%s" + MH_R1200, // "[Internal error ]re virtual reports, file '%s', function '%s':\n%s" file, fcn, buf); // err(PWRN) now supplies "Internal error: ", 1-92 return rc; } // vrErrIV @@ -776,7 +776,7 @@ RC vrUnspool( VROUTINFO* voInfo) return RCOK; // exit now if (!spl.isInit || spl.sp_nVrh==0) #ifdef DEVAIDS // else don't bother the user -- possible consequence of other errors. - return vrErr( "vrUspool", (char *)MH_R1210); // "Unspool called but nothing has been spooled" + return vrErr( "vrUspool", MH_R1210); // "Unspool called but nothing has been spooled" #else return RCBAD; // silent bad? #endif @@ -802,7 +802,7 @@ RC vrUnspool( VROUTINFO* voInfo) // default reports but not Primary report file, 11-91, // or other errors made all vr's empty 11-20-91. */ if (spl.uN==0) - vrErr( "vrUnspool", (char *)MH_R1211); // "After initial setup, 'spl.uN' is 0". Bug, or call with empty files only + vrErr( "vrUnspool", MH_R1211); // "After initial setup, 'spl.uN' is 0". Bug, or call with empty files only #endif // do passes (runs) over spooled data until all requested reports completely written @@ -826,12 +826,12 @@ RC vrUnspool( VROUTINFO* voInfo) if (!u->fStat) // if file being written (0), not complete, handle status... if (u->hStat) // shd be 0 (looking for start) not 1 (unspooling) or 2 (ended & failed to set up next) vrErr( "vrUnspool", - (char *)MH_R1212, // "At end pass, uns[%d] hStat is %d not 0" + MH_R1212, // "At end pass, uns[%d] hStat is %d not 0" u - uns, u->hStat ); } if (!did) { - vrErr( "vrUnspool", (char *)MH_R1213); // "At end of pass, all uns[].did's are 0" + vrErr( "vrUnspool", MH_R1213); // "At end of pass, all uns[].did's are 0" break; // don't loop forever after error 12-5-94 } } @@ -842,18 +842,18 @@ RC vrUnspool( VROUTINFO* voInfo) if (!spl.vrRc) // omit if error { if (spl.voInfo->fName != NULL) - vrErr( "vrUnspool", (char *)MH_R1214); // "Unspool did not use all its arguments" + vrErr( "vrUnspool", MH_R1214); // "Unspool did not use all its arguments" for (u = uns; u < unsMax; u++) { if (u->fStat != -2) // shd be -2 (ready for next, but aren't any), // not -1: ready to open, 0 open, nor 1 done, ready to close). vrErr( "vrUnspool", - (char *)MH_R1215, // "At end of Unspool, uns[%d] fStat is %d not -2" + MH_R1215, // "At end of Unspool, uns[%d] fStat is %d not -2" u - uns, u->fStat ); if (u->hStat != 2) // shd be 2, ready for next (but aren't any more) vrErr( "vrUnspool", - (char *)MH_R1216, // "At end of Unspool, uns[%d] hStat is %d not 2" + MH_R1216, // "At end of Unspool, uns[%d] hStat is %d not 2" u - uns, u->hStat ); } } @@ -997,7 +997,7 @@ LOCAL int vruNuHan( UNS* u) // get next input vr handle in uns entry // check handle if (vrh <= 0 || vrh > spl.sp_nVrh) // check for valid handle - vrErr( "vruNuHan", (char *)MH_R1217, // "Out of range vr handle %d for output file %s in vrUnspool call" + vrErr( "vruNuHan", MH_R1217, // "Out of range vr handle %d for output file %s in vrUnspool call" vrh, u->fName ); // ... and iterate to try next handle else if (vr->o2 <= vr->o1) // check that vr contains data ; // continue; no msg: empty vr's can normally occur. @@ -1023,7 +1023,7 @@ LOCAL int vruNuHan( UNS* u) // get next input vr handle in uns entry if ( u->optn & VR_FMT && !(vr->optn & VR_FMT) ) vrErr( "vruNuHan", - (char *)MH_R1218, // "Unformatted virtual report, handle %d, name '%s' \n" + MH_R1218, // "Unformatted virtual report, handle %d, name '%s' \n" vrh, vr->vrName, u->fName ); // "in formatted output file '%s'. Will continue." #endif return 0; // expected good return with next handle @@ -1140,7 +1140,7 @@ LOCAL int vruNuf( UNS* u) // open next caller's report file in uns entry, at st { spl.voInfo = voInfoWas; // put back arg to use when next handle avail even if in a different u #ifdef DEVAIDS // debug aid, remove. Not an error, just likely to have bugs at first. - logit( DASHES, (char *)MH_R1223, // "Debugging Information: Number of simultaneous report/export output \n" + logit( DASHES, MH_R1223, // "Debugging Information: Number of simultaneous report/export output \n" spl.nFo ); // " files limited to %d by # available DOS file handles. Expect bugs." #endif if (spl.nFo >= 2) // if opened only 0 or 1 files don't set limit: so few we need to push @@ -1236,7 +1236,7 @@ x if (onlyU) x logit( // msg to screen & log report, rmkerr.cpp (may not appear in log report since issued during unspool) x DASHES, "Debugging Information: using virtual report catch-up run \n" x " for vr %d, '%s', to file '%s'. Expect bugs.", -x (INT)onlyU->vrh, spl.vr[onlyU->vrh].vrName, onlyU->fName ); +x onlyU->vrh, spl.vr[onlyU->vrh].vrName, onlyU->fName ); #endif if (onlyU) // set limits for inner loop below: @@ -1263,7 +1263,7 @@ x (INT)onlyU->vrh, spl.vr[onlyU->vrh].vrName, onlyU->fName break; // on spool i/o error, terminate run. vrRc set. if (spl.p2 - spl.p <= 0 && spl.bufO2 < spl.spO) { - spl.vrRc = vrErr( "unsRun", (char *)MH_R1219); // "Unexpected empty unspool buffer" + spl.vrRc = vrErr( "unsRun", MH_R1219); // "Unexpected empty unspool buffer" break; } } @@ -1311,7 +1311,7 @@ x (INT)onlyU->vrh, spl.vr[onlyU->vrh].vrName, onlyU->fName default: vrErr( "unsRun", - (char *)MH_R1220, // "Invalid type %d in spool file at offset %ld" + MH_R1220, // "Invalid type %d in spool file at offset %ld" ty, spl.bufO1 + (spl.p-spl.p1) ); while (spl.p < spl.p2 && *spl.p < static_cast(vrBody)) // skip to a probable type byte (or to end buf) spl.p++; @@ -1464,13 +1464,13 @@ LOCAL int getWholeText( UNS* onlyU ) // read entire text into buffer, return it break; if (spl.bufO2 >= spl.spO) // if there is no more text to read { - vrErr( "getWholeText", (char *)MH_R1221); // "text runs off end spool file" + vrErr( "getWholeText", MH_R1221); // "text runs off end spool file" txLen = (spl.p2 - spl.p) - 1; // termination problem. truncate & continue. break; } if ( UINT(spl.p2 - spl.p) > spl.bufSz - 1024) // min buf size - 1024 would be better -- uniformity { - vrErr( "getWholeText", (char *)MH_R1222); // "text too long for spool file buffer" + vrErr( "getWholeText", MH_R1222); // "text too long for spool file buffer" txLen = (spl.p2 - spl.p) - 1; // truncate break; // expect "bad type" errors during recovery } diff --git a/src/wfpak.cpp b/src/wfpak.cpp index e41fe2e42..f498f6d40 100644 --- a/src/wfpak.cpp +++ b/src/wfpak.cpp @@ -88,14 +88,14 @@ t ptr=NULL; t wthrfp = wfOpen( fName, ptr); t if (wthrfp->wferror) t traceback(wthrfp->wferror); -t printf("dynflg = %d\n", (INT)wthrfp->dynflg); -t printf("nhdszwf = %d\n", (INT)wthrfp->nhdszwf); +t printf("dynflg = %d\n", wthrfp->dynflg); +t printf("nhdszwf = %d\n", wthrfp->nhdszwf); t printf("wflat = %f\n", wthrfp->wflat); t printf("wflong = %f\n", wthrfp->wflong); -t printf("itzhwf = %d\n", (INT)wthrfp->itzhwf); -t printf("solflgwf = %d\n", (INT)wthrfp->solflgwf); -t printf("jhroffwr = %d\n", (INT)wthrfp->jhroffwr); -t printf("wferror = %d\n", (INT)wthrfp->wferror); +t printf("itzhwf = %d\n", wthrfp->itzhwf); +t printf("solflgwf = %d\n", wthrfp->solflgwf); +t printf("jhroffwr = %d\n", wthrfp->jhroffwr); +t printf("wferror = %d\n", wthrfp->wferror); t for ( ; ; ) t { printf("\nenter jday, ihr : "); t j = sscanf(gets(buffer),"%hd%h", &jday, &ihr); @@ -114,7 +114,7 @@ t printf("ccov = %f\n",wthrfp->ccov); t printf("barpres = %f\n",wthrfp->barpres); t printf("bmrad = %f\n",wthrfp->bmrad); t printf("dfrad = %f\n",wthrfp->dfrad); -t printf("wferror = %d\n",(INT)wthrfp->wferror); +t printf("wferror = %d\n",wthrfp->wferror); t } t error = wfClose(wthrfp); t if (wthrfp->wferror) @@ -1784,8 +1784,8 @@ RC WFILE::wf_Open( // Open existing weather file and initialize WFILE structure if (rc) // if error { err( erOp, // display msg per erOp, rmkerr.cpp rc==RCBAD2 - ? (char *)MH_R0101 // "R0101: %s file '%s': bad format or header" - : (char *)MH_R0100, // "R0100: %s file '%s': open failed" + ? MH_R0101 // "R0101: %s file '%s': bad format or header" + : MH_R0100, // "R0100: %s file '%s': open failed" "Weather", wfName); } @@ -1796,8 +1796,8 @@ RC WFILE::wf_Open( // Open existing weather file and initialize WFILE structure if (rcTDV) { err( erOp, // display msg per erOp, rmkerr.cpp rcTDV==RCBAD2 - ? (char *)MH_R0101 // "R0101: %s file '%s': bad format or header" - : (char *)MH_R0100, // "R0100: %s file '%s': open failed" + ? MH_R0101 // "R0101: %s file '%s': bad format or header" + : MH_R0100, // "R0100: %s file '%s': open failed" "TDV", TDVfName); rc |= rcTDV; } @@ -1906,7 +1906,7 @@ RC WFILE::wf_PackedOpen( // open BSGS or BSGSdemo or ET or ... packed weather fi { // insure validity of header and program by checking 2nd formatCode near end of header if (memcmp( ((ET1Hdr *)hdr)->formatCode2, "ET1!", 4)) - return err( erOp, (char *)MH_R1101, wfName); // "Corrupted header in ET1 weather file \"%s\"." + return err( erOp, MH_R1101, wfName); // "Corrupted header in ET1 weather file \"%s\"." if (wf_EtDecodeHdr( hdr, erOp, clrnss, turbid, atmois)==RCOK) // decode hdr (below) / if ok return RCOK; @@ -2086,7 +2086,7 @@ LOCAL RC FC decodeFld( // decode one by-column-number field to internal -- pot if (strchr( "+-", *pNext)) pNext++; // if sign present, pass it if (!isdigitW(*pNext)) // if no digit, it is not a valid number rc |= err( erOp, // conditionally issue message. prefixes "Error:\n ". - (char *)MH_R1102, // "Missing or invalid number at offset %d in %s %s" + MH_R1102, // "Missing or invalid number at offset %d in %s %s" (int)srcOff, what, which ); else // has digit, finish decoding { @@ -2104,13 +2104,13 @@ LOCAL RC FC decodeFld( // decode one by-column-number field to internal -- pot else { rc |= err( PWRN, // bad table. unconditional error. - (char *)MH_R1103, what ); // "Bad decoding table for %s in wfpak.cpp" + MH_R1103, what ); // "Bad decoding table for %s in wfpak.cpp" pNext = ""; // suppress error message just below } } if (*pNext) // if number did not use all of input rc |= err( erOp, - (char *)MH_R1104, // "Unrecognized characters after number at offset %d in %s %s" + MH_R1104, // "Unrecognized characters after number at offset %d in %s %s" "Unrecognized characters after number at offset %d in %s %s", (int)srcOff, what, which ); } @@ -2243,24 +2243,24 @@ int WFILE::wf_PackedHrOffset( // determine file offset of an hour's packed data { if (wFileFormat==BSGS || wFileFormat==BSGSdemo) { - err( erOp, (char *)MH_R0107); // "Design Days not supported in BSGS (aka TMP or PC) weather files" + err( erOp, MH_R0107); // "Design Days not supported in BSGS (aka TMP or PC) weather files" return 0; } // assume ET1 or later format if (jDay < 1 || jDay > 12) { - err( erOp, (char *)MH_R0108, (int) jDay); /* "Program error in use of function wfPackedhrRead\n\n" + err( erOp, MH_R0108, (int) jDay); /* "Program error in use of function wfPackedhrRead\n\n" " Invalid Month (%d) in \"jDay\" argument: not in range 1 to 12." */ return 0; } if (firstDdm > lastDdm || lastDdm < 1) { - err( erOp, (char *)MH_R0109, yac->pathName() ); // "Weather file \"%s\" contains no design days" + err( erOp, MH_R0109, yac->pathName() ); // "Weather file \"%s\" contains no design days" return 0; } if (jDay < firstDdm || jDay > lastDdm) { - err( erOp, (char *)MH_R0110, jDay, // "Weather file contains no design day for month %d\n\n" + err( erOp, MH_R0110, jDay, // "Weather file contains no design day for month %d\n\n" yac->pathName(), // " (Weather file \"%s\" contains design day data only for months %d to %d)" firstDdm, lastDdm ); diff --git a/src/xiopak.cpp b/src/xiopak.cpp index d30fdde11..3b14cd8ef 100644 --- a/src/xiopak.cpp +++ b/src/xiopak.cpp @@ -32,10 +32,6 @@ namespace filesys = std::experimental::filesystem; /*-------------------------------- OPTIONS --------------------------------*/ // #define TEST // define to include main() which includes test code for many fcns. See #ifs below. Ancient, 2-95 -#define MESSAGESC // define to link with messages.cpp and accept message handles in xfprintf. - // undefine to link without messages.cpp - - /*------------------------------- INCLUDES --------------------------------*/ #include // reqd b4 stat.h (defines dev_t) @@ -81,8 +77,8 @@ SEC FC xfdelete( // delete a file { sec = errno; err( erOp, // display msg per erOp, rmkerr.cpp - (char *)MH_I0010, // "I0010: unable to delete '%s':\n %s" - f, // filename + MH_I0010, // "I0010: unable to delete '%s':\n %s" + f, // filename msgSec(sec) ); // sec text, messages.cpp } return sec; @@ -101,9 +97,9 @@ SEC FC xfrename( // Rename a file { sec = errno; err( erOp, // display message per erOp, rmkerr.cpp - (char *)MH_I0021, // "I0021: Unable to rename file '%s' to '%s':\n %s" - f1, f2, // filenames for message - msgSec(sec)); // sec text for message (messages.cpp) + MH_I0021, // "I0021: Unable to rename file '%s' to '%s':\n %s" + f1, f2, // filenames for message + msgSec(sec)); // sec text for message (messages.cpp) } return sec; } // xfrename @@ -339,8 +335,8 @@ SEC FC xfread( // Read from file } // xfread //====================================================================== SEC CDEC xfprintf( // fprintf to an XFILE (via xfwrite) - XFILE *xf, // file to be written to - const char *format, // printf-style format string, or message handle if MESSAGESC + XFILE *xf, // file to be written to + MSGORHANDLE mOrH, // printf-style format string (or handle thereto) ... ) // values as required by format // max length of formatted string is 500 (7-3-89) @@ -351,12 +347,8 @@ SEC CDEC xfprintf( // fprintf to an XFILE (via xfwrite) int nbytes; char buf[501]; // 1 for '\0' - va_start( ap, format ); // arg list ptr for vsprintf -#ifdef MESSAGESC - msgI( WRN, buf, sizeof( buf), &nbytes, format, ap); // retrieve text for handle, if given, and build fmtd str in buf -#else//3-92 - nbytes = vsprintf( buf, format, ap ); // build fmtd str in buf -#endif + va_start( ap, mOrH); // arg list ptr + msgI( WRN, buf, sizeof( buf), &nbytes, mOrH, ap); // retrieve text for handle, if given, and build fmtd str in buf return xfwrite( xf, buf, nbytes ); // NOP if nbytes == 0 } // xfprintf //====================================================================== @@ -780,27 +772,23 @@ RC FC xfcopy( // Copy a file The RC codes returned by xfcopy() are message handles for msgs with args. Best to use erOp=WRN and let msg reporting happen here */ { - XFILE *xfs, *xfd; - SEC sec; - uintmax_t reqspace, availspace; - RC rc; + SI eraMasked; - const char *erArg; - const char* mOrH; - //rc = RCOK; all paths set rc and BCC32 warns unused, 12-94 - erArg = NULL; + RC rc = RCOK; + const char* erArg = NULL; eraMasked = erOp & ~EROMASK; // don't pass options to wrong fcns // mask leaves only bits significant // to error:errI. cnglob.h - sec = SECOK; /* Used for error reporting below. - Bad I/O action sets sec to non-SECOK value */ - xfd = NULL; - xfs = xfopen( fns, O_RB, IGN, FALSE, &sec); // IGN: we handle errs here + SEC sec = SECOK; // Used for error reporting below. + // Bad I/O action sets sec to non-SECOK value + XFILE* xfd = NULL; + XFILE* xfs = xfopen( fns, O_RB, IGN, FALSE, &sec); // IGN: we handle errs here + MSGORHANDLE mOrH; if (xfs==NULL) { rc = MH_I0022; // "I0022: file '%s' does not exist" - mOrH = (char *)rc; + mOrH = rc; erArg = fns; } else @@ -812,28 +800,33 @@ RC FC xfcopy( // Copy a file strchr(accd, 'w')) // Check for a create file mode on ? MH_I0023 // "I0023: Unable to create file '%s'" : MH_I0024; // "I0024: File '%s' does not exist, cannot copy onto it" - mOrH = (char *)rc; + mOrH = rc; erArg = fnd; } else { + uintmax_t reqspace; xfsize( xfs, &reqspace); // required disk space - availspace = xdisksp(); // available disk space + uintmax_t availspace = xdisksp(); // available disk space if (availspace < reqspace + 2048) { rc = MH_I0025; // "I0025: not enough disk space to copy file '%s'" - mOrH = (char *)rc; + mOrH = rc; erArg = fns; } else - rc = xfcopy2( xfs, xfd, erOp, &mOrH); + { + const char* msg = nullptr; + rc = xfcopy2(xfs, xfd, erOp, &msg); + mOrH = msg; + } } } xfclose( &xfs, NULL); /* close files, ignore errors */ xfclose( &xfd, NULL); if (rc != RCOK) err( eraMasked, // disp msg, rmkerr.cpp - mOrH, // MH for msg or ptr to msg text from xfcopy2 + mOrH, // MH for msg or ptr to msg text from xfcopy2 erArg); // msg arg, typically name of file w/ err; // not used in all cases but harmless @@ -856,7 +849,6 @@ RC FC xfcopy2( // copy bytes from one file to another (inner xfcopy loop) /* returns RCOK if transfer completed successfully else nz RC, *pMsg pointing to UNISSUED Tmpstr error msg */ { - RC rc; char *buf; const char *ebuf, *fName = nullptr; SEC sec; @@ -866,7 +858,7 @@ RC FC xfcopy2( // copy bytes from one file to another (inner xfcopy loop) dmal( DMPP( buf), bufsize, ABT); /* loop, reading and writing buffer loads */ - rc = RCOK; + RC rc = RCOK; do { sec = xfread( xfs, buf, (USI)bufsize); @@ -901,8 +893,8 @@ RC FC xfcopy2( // copy bytes from one file to another (inner xfcopy loop) if (rc && pMsg) // if err and caller wants msg *pMsg = msg( NULL, // retrieve msg w/ args in Tmpstr, messages.cpp - (char *)rc, // MH for err - fName, // arg: name of file w/ error + rc, // MH for err + fName, // arg: name of file w/ error msgSec(sec)); // arg: sec text, messages.cpp return rc; /* one other return above */ diff --git a/src/yacam.cpp b/src/yacam.cpp index 6a4249e91..c836217fc 100644 --- a/src/yacam.cpp +++ b/src/yacam.cpp @@ -87,7 +87,7 @@ RC YACAM::open( // open file for reading, return RCOK if ok mFh = fopen( mPathName, // C library function wrAccess ? "rb+" : "rb"); // + adds write access, file must exists. if (!mFh) // returns -1 if failed - return errFl((const char *)MH_I0101); // issue message with "Cannot open" (or not) per mErOp, return RCBAD + return errFl(MH_I0101); // issue message with "Cannot open" (or not) per mErOp, return RCBAD return RCOK; // successful } // YACAM::open @@ -106,7 +106,7 @@ RC YACAM::close( int erOp /*=WRN*/) // close file, nop if not opened, RCOK if ok rc = clrBufIf(); // if open for write, if buffer dirty, write buffer contents if (fclose(mFh) != 0) // close file -- C library function - rc = errFl((const char *)MH_I0103); // conditional message containing "Close error on" / return RCBAD + rc = errFl(MH_I0103); // conditional message containing "Close error on" / return RCBAD } // free pathname storage in heap @@ -145,11 +145,11 @@ RC YACAM::clrBufIf() // write buffer contents if 'dirty'. if ( mFilO >= 0 // if have file offset for buffer contents ? fseek( mFh, mFilO, SEEK_SET) != 0 // seek to file postition : fseek( mFh, 0, SEEK_END) != 0 ) // else seek to end file - rc = errFl((const char *)MH_I0104); // seek failed, conditionally issue error msg containing "Seek error on" + rc = errFl(MH_I0104); // seek failed, conditionally issue error msg containing "Seek error on" int nw = int( fwrite( yc_buf, sizeof(char), bufN, mFh)); // write buffer contents, return # bytes written. C library function. if (nw < bufN ) // if too few bytes written = error - rc = errFl((const char *)MH_I0105); // conditionally issue message. "Write error on". + rc = errFl(MH_I0105); // conditionally issue message. "Write error on". dirty = FALSE; // say buffer now "clean" (if write failed, data is lost) } @@ -178,7 +178,7 @@ int YACAM::read( // read to caller's buffer if (filO >= 0L) if (fseek( mFh, filO, SEEK_SET) != 0) { - errFl((const char *)MH_I0104); // conditional msg. "Seek error on" 2nd use. + errFl(MH_I0104); // conditional msg. "Seek error on" 2nd use. return -1; } @@ -186,12 +186,12 @@ int YACAM::read( // read to caller's buffer int cr = int( fread( buf, sizeof(char), count, mFh)); // read bytes. C library function. if (cr != count && !feof(mFh)) // returns byte count, if cr and count mismatch and { // eof is not reach then - errFl((const char *)MH_I0106); // "Read error on" + errFl(MH_I0106); // "Read error on" return -1; } if (cr < count) // if got fewer bytes than requested if (!(erOp & YAC_EOFOK)) // if caller wants end file message - errFl((const char *)MH_I0107); // issue message for 0 or partial count. "Unexpected end of file in". + errFl(MH_I0107); // issue message for 0 or partial count. "Unexpected end of file in". // caller must check for enuf bytes read. return cr; // return # bytes read, 0 if already at EOF. } // YACAM::read @@ -240,7 +240,7 @@ char* YACAM::getBytes( // random access using buffer in object -- use for sh bufN = nKeep + cr; // # bytes in buffer if (bufN < count) // if don't have enough bytes (file ends b4 or in middle of caller's request) { - errFl((const char *)MH_I0107); // cnd'l msg containing "Unexpected end of file in" (2nd use) + errFl(MH_I0107); // cnd'l msg containing "Unexpected end of file in" (2nd use) return NULL; } return yc_buf; // ok, desired bytes start at front of buffer. Another good return above. @@ -257,7 +257,7 @@ RC YACAM::putBytes( // random access using buffer in object -- use for short { mErOp = erOp; // communicate error action to errFl/errFlLn if (!mWrAccess) - return errFl((const char *)MH_I0108); // cnd'l msg with "Writing to file not opened for writing:" (2nd use) + return errFl(MH_I0108); // cnd'l msg with "Writing to file not opened for writing:" (2nd use) int i = 0; // buffer offset at which to put new data @@ -519,12 +519,12 @@ state -------- -------- -------- -------- -------- -------- -------- ------- case efo: *(tok + toki) = '\0'; // ok EOF, before start of token. store terminull. if (!(erOp & YAC_EOFOK)) // option bit suppresses this error message only - errFlLn((const char *)MH_I0109,srcTy); // cond'l msg per erOp (via mErOp), with "Unexpected end of line/file." + errFlLn(MH_I0109,srcTy); // cond'l msg per erOp (via mErOp), with "Unexpected end of line/file." return RCEOF; // unique return code for clean eof case efr: *(tok + toki) = '\0'; // premature EOF. store terminull. - errFlLn((const char *)MH_I0109,srcTy); // cond'l error message with "Unexpected end of line/file." + errFlLn(MH_I0109,srcTy); // cond'l error message with "Unexpected end of line/file." return RCBAD; // error return case pcx: @@ -545,7 +545,7 @@ state -------- -------- -------- -------- -------- -------- -------- ------- *(tok + toki) = '\0'; // exit. store terminull. if (!overrun) // if ok return RCOK; // good return - return errFlLn((char *)MH_I0110); // conditional error message with "Token too long.", return RCBAD + return errFlLn( MH_I0110); // conditional error message with "Token too long.", return RCBAD default: ; } @@ -673,16 +673,16 @@ static const unsigned char asTab[ 5][9] = // [state][ct] case efo: tok[ tokiEnd] = '\0'; // ok EOF, before start of token. store terminull. if (!(erOp & YAC_EOFOK)) // option bit suppresses this error message only - errFlLn((const char *)MH_I0109, srcTy); // cond'l msg per erOp (via mErOp), with "Unexpected end of file." + errFlLn(MH_I0109, srcTy); // cond'l msg per erOp (via mErOp), with "Unexpected end of file." return RCEOF; // unique return code for clean eof case efr: tok[ tokiEnd] = '\0'; // premature EOF. store terminull. - errFlLn( (const char *)MH_I0109, srcTy); // cond'l error message with "Unexpected end of file." + errFlLn( MH_I0109, srcTy); // cond'l error message with "Unexpected end of file." return RCBAD; // error return case xit: tok[ tokiEnd] = '\0'; // exit. store terminull. if (overrun) // if overrun - return errFlLn( (const char *)MH_I0110); // Token too long + return errFlLn( MH_I0110); // Token too long return RCOK; // good return default: ; } @@ -884,7 +884,7 @@ x char *pNext = tok; // pointer to input text. Note already deblanked by t x if (strchr( "+-", *pNext)) x pNext++; // if sign present, pass it x if (!isdigitW(*pNext)) // if no digit, it is not a valid number -x rc= errFlLn( (char *)MH_I0114, tok); // cnd'l msg. "Missing or invalid number \"%s\".". +x rc= errFlLn( MH_I0114, tok); // cnd'l msg. "Missing or invalid number \"%s\".". x else // has digit #endif { // decode @@ -896,7 +896,7 @@ x else // has digit { long v = strtol( tok, &pNext, 0); // convert to long. radix 0 --> respond to 0, 0x. if (cc=='I') { if (v < -32768L || v > 32767L) - rc = errFlLn( (char *)MH_I0115, tok); // cnd'l msg including "Integer too large: \"%s\"." + rc = errFlLn( MH_I0115, tok); // cnd'l msg including "Integer too large: \"%s\"." *(SI*)p = SI(v); size = sizeof(SI); } @@ -907,7 +907,7 @@ x else // has digit } // final syntax check: check for all input used if (*pNext) - rc = errFlLn( (char *)MH_I0116, // "Unrecognized character(s) after %snumber \"%s\"." + rc = errFlLn( MH_I0116, // "Unrecognized character(s) after %snumber \"%s\"." cc=='F' ? "" : "integer ", tok ); } @@ -940,7 +940,7 @@ RC YACAM::checkExpected( // check match to expected item return rc; } // YACAM::checkExpected //----------------------------------------------------------------------------- -RC YACAM::errFl( const char *s, ...) // error message "%s ". returns RCBAD. +RC YACAM::errFl( MSGORHANDLE s, ...) // error message "%s ". returns RCBAD. { va_list ap; va_start( ap, s); @@ -951,7 +951,7 @@ RC YACAM::errFl( const char *s, ...) // error message "%s ". buf, mWhat, mPathName ? mPathName : "bug") ; } //---------------------------------------------------------------------------- -RC YACAM::errFlLn( const char *s, ...) // error message "%s in near line ". returns RCBAD. +RC YACAM::errFlLn( MSGORHANDLE s, ...) // error message "%s in near line ". returns RCBAD. { va_list ap; va_start( ap, s); @@ -960,7 +960,7 @@ RC YACAM::errFlLn( const char *s, ...) // error message "%s in ". returns RCBAD. - RC errFlLn( const char *s, ...); // cond'l message "Error in near line : %s". rets RCBAD. + RC errFl( MSGORHANDLE s, ...); // conditional error message "Error: %s ". returns RCBAD. + RC errFlLn( MSGORHANDLE s, ...); // cond'l message "Error in near line : %s". rets RCBAD. int mErOp; // communicates erOp from entry points to error fcns // note need a data mbr at end due to rcdef.exe deficiency 10-94. diff --git a/vendor/HPWHsim b/vendor/HPWHsim index b3e2507c0..583d4dd9d 160000 --- a/vendor/HPWHsim +++ b/vendor/HPWHsim @@ -1 +1 @@ -Subproject commit b3e2507c084c8914bc8ee4ce85cb4856b5bc472b +Subproject commit 583d4dd9d58086a226907bc20805bc786abcd1bf