Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/RCDEF/rcdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,7 @@ LOCAL RC recs( // do records
rcderr("Bad name after *file.");
rchFileNm = stashSval(0); // store name for rec type definition and for have-file check below
char rchFileNmX[CSE_MAX_FILENAME]; // rchFileNm variable with a x at the end
sprintf(rchFileNmX,"%sx", rchFileNm); // Add x
snprintf(rchFileNmX, CSE_MAX_FILENAME, "%sx", rchFileNm); // Add x
xfjoinpath(incdir, rchFileNmX, dbuff);
printf( "\n %s ... ", dbuff);
if (CFILESOUT) // if outputting tables to compile & link
Expand Down
2 changes: 1 addition & 1 deletion src/ashwface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ RC FENAW::fa_SetupBare( // FENAW init glazing alone
}
if (!rc)
{ // description of reference glazing
sprintf( fa_refDesc, "%s (SHGC=%.3f U=%.3f)",
snprintf( fa_refDesc, sizeof(fa_refDesc), "%s (SHGC=%.3f U=%.3f)",
FCGET( fa_CFS.ID), fa_CFS.SHGCcogNFRC, fa_CFS.UcogNFRC);

// adjustment factors
Expand Down
2 changes: 1 addition & 1 deletion src/cgdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ SI j;
w char b[200]; /* buffers formatted line before writing */
w
w for (j = 0; j < 2; j++) /* loop over 12-hour rows */
w { bx = sprintf( b, "%-7s", tag ); /* start line / init offset */
w { bx = snprintf( b, sizeof(b), "%-7s", tag ); /* start line / init offset */
w tag = ""; /* no tag on 2nd line */
w for (i = -1; ++i < 12; ) /* loop over 12 hours */
w { *(b + bx++) = ' '; /* inter-column space */
Expand Down
8 changes: 4 additions & 4 deletions src/cgresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,17 +617,17 @@ void FC vpRxports( // virtual print reports and exports of given frequency for
switch (rxt.fq)
{
case C_IVLCH_S:
sprintf(rxt.col1, "%2d%s", Top.iHr + 1, strSuffix( Top.iSubhr));
snprintf(rxt.col1, sizeof(rxt.col1), "%2d%s", Top.iHr + 1, strSuffix( Top.iSubhr));
reHead = (Top.isBegDay && Top.iSubhr == 0); // subhrly and HS rpts get title/colHeads once day
doFoot0 = (Top.isEndDay && Top.isEndHour); // .. and termination (blank line) at end each day
break;
case C_IVLCH_H:
sprintf( rxt.col1, "%2d", Top.iHr+1);
snprintf( rxt.col1, sizeof(rxt.col1), "%2d", Top.iHr+1);
reHead = Top.isBegDay; // hourly rpts get title/colHeads each day
doFoot0 = Top.isEndDay; // .. and termination (blank line) at end each day
break;
case C_IVLCH_D:
sprintf( rxt.col1, "%2d", Top.tp_date.mday);
snprintf( rxt.col1, sizeof(rxt.col1), "%2d", Top.tp_date.mday);
reHead = Top.isBegMonth;
doFoot0 = Top.isEndMonth;
break;
Expand Down Expand Up @@ -1417,7 +1417,7 @@ LOCAL void FC vpEbStRow( // virtual print zone ZEB or ZST row for zone or su
if (rxt->flags & 32) // if zone mode is to show (else skip sprintf for speed)
{
xMode = zp->zn_md; // ZEB export CSE zone mode: integer
sprintf( mode, "%2d", zp->zn_md); // ZEB report CSE zone mode: text
snprintf( mode, sizeof(mode), "%2d", zp->zn_md); // ZEB report CSE zone mode: text
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cncult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3318,7 +3318,7 @@ std::string CULT::cu_MakeDoc( // documentation string for this CULT
if (ckf)
sCkf = bAll ? strtprintf("%x", ckf) : "nz";

sprintf( buf,"%-20s %-2d %-3d %-5d %-2d %-4d %-5d %-17s %-8s %-10g %-8s %-8s",
snprintf( buf, sizeof(buf),"%-20s %-2d %-3d %-5d %-2d %-4d %-5d %-17s %-8s %-10g %-8s %-8s",
id, cs, fn, f, uc, evf, ty, bName, sDfpi, dff, sP2, sCkf);
doc += buf;
}
Expand Down
25 changes: 14 additions & 11 deletions src/cncult4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ RC RI::ri_oneRxp() // process one report or export for topRxp
break; // C_RPTYCH_ZEB
}
char buf[300];
sprintf( buf, "%s %s %s", sname, exrePort, Name()); // eg "Statistics report userName1", for errmsgs
snprintf( buf, sizeof(buf), "%s %s %s", sname, exrePort, Name()); // eg "Statistics report userName1", for errmsgs
vrOpen( &vrh, buf, optn); // open virtual report, get handle (vrh).
if (DvriB.add( &dvrip, WRN)==RCOK) // add record to DVRI / if ok (fail unlikely after al above)
{
Expand Down Expand Up @@ -1446,11 +1446,12 @@ const char* getErrTitleText() // get "ERR" report title text -- public functi
TOPRAT* tp;
int repCpl = bracket( 78, getCpl( &tp), 132); // chars per line: get best value yet avail
// default if Top.repCpl unset. below.
// format title text
const int repCpl_ext = repCpl + 11;
// format title text

if (dmal( DMPP( errTitle), repCpl + 11, PWRN)) // +11 for up to 5 crlf's, and \0
if (dmal( DMPP( errTitle), repCpl_ext, PWRN)) // +11 for up to 5 crlf's, and \0
return ""; // if failed, return value that will fall thru code
int m = sprintf( errTitle, "\n\nError Messages for Run %03d:", // title
int m = snprintf( errTitle, repCpl_ext, "\n\nError Messages for Run %03d:", // title
tp ? tp->runSerial : 0 ); // run serial number, or 000 early in session
// (or cd default to cnRunSerial & init that sooner?
// note 3 more uses in this file. 7-92) */
Expand All @@ -1474,11 +1475,12 @@ const char* getLogTitleText() // get "LOG" report title text -- public functi
TOPRAT* tp;
int repCpl = bracket( 78, getCpl( &tp), 132); // chars per line: get best value yet avail
// default if Top.repCpl unset. below.
const int repCpl_ext = repCpl + 11;

// format title text
if (dmal( DMPP( logTitle), repCpl + 11, PWRN)) // +11 for up to 5 crlf's, and \0
if (dmal( DMPP( logTitle), repCpl_ext, PWRN)) // +11 for up to 5 crlf's, and \0
return ""; // if failed, return value that will fall thru code
int m = sprintf( logTitle, "\n\n%sLog for Run %03d:",
int m = snprintf( logTitle, repCpl_ext, "\n\n%sLog for Run %03d:",
tp ? tp->tp_RepTestPfx() : "", // test prefix (hides runDateTime re testing text compare)
tp ? tp->runSerial : 0 ); // run serial number, or 000 early in session (unexpected here).
char* p = logTitle + m;
Expand All @@ -1502,10 +1504,11 @@ const char* getInpTitleText() // get "INP" report title text -- public functi
TOPRAT* tp;
int repCpl = bracket( 78, getCpl( &tp), 132); // chars per line: get best value yet avail
// default if Top.repCpl unset. below.
// format title text
if (dmal( DMPP( inpTitle), repCpl + 11, PWRN)) // +11 for up to 5 crlf's, and \0
const int repCpl_ext = repCpl + 11;
// format title text
if (dmal( DMPP( inpTitle), repCpl_ext, PWRN)) // +11 for up to 5 crlf's, and \0
return ""; // if failed, return value that will fall thru code
int m = sprintf( inpTitle, "\n\nInput for Run %03d:", // title
int m = snprintf( inpTitle, repCpl_ext, "\n\nInput for Run %03d:", // title
tp ? tp->runSerial : 0 ); // run serial number, or 000 early in session (unexpected here).
char* p = inpTitle + m;
int r = repCpl - m + 2; // remaining space on line after the 2 \n's
Expand Down Expand Up @@ -1602,7 +1605,7 @@ const char* getFooterText( int pageN) // get footer text for specified page n
// or InputFilePath if full path and defaulted extension desired
if (tp)
{ if (r > 5)
{ int m = sprintf( p, " %03d", tp->runSerial); // run serial number
{ int m = snprintf( p, repCpl, " %03d", tp->runSerial); // run serial number
p += m;
r -= m;
}
Expand All @@ -1620,7 +1623,7 @@ const char* getFooterText( int pageN) // get footer text for specified page n
// note that footer[] has 3 extra bytes in case page # is 32767 not the expected 1-99.
}
if (footerPageN && footer && *footer) // insurance
sprintf( footerPageN, "%2d\r\n", pageN); // generate text for page number and final \r\n\0 in place in footer
snprintf( footerPageN, HFBUFSZ - 7, "%2d\r\n", pageN); // generate text for page number and final \r\n\0 in place in footer
// CAUTION fix this code if page # no longer at end of footer.
return footer; // return pointer to buffer with 2 lines of formatted header text
} // getFooterText
Expand Down
4 changes: 2 additions & 2 deletions src/cncult6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", i+1 ); // stage variable name text for error messages
snprintf( stgNm, sizeof(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])
Expand Down Expand Up @@ -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", i+1 ); // stage variable name text for error messages
snprintf( stgNm, sizeof(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])
Expand Down
2 changes: 1 addition & 1 deletion src/cnguts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ RC MTR_IVL::mtr_Validate1( // validity checks w/ message(s)
double xTot = VSum<decltype( clg), double>(&clg, NENDUSES);
double fDiff = frDiff(double( tot), xTot, 1.);
if (fDiff > 0.0001)
sprintf( msgs, "Tot (%0.1f) != VSum() (%0.1f), fDiff = %0.5f",
snprintf( msgs, sizeof(msgs), "Tot (%0.1f) != VSum() (%0.1f), fDiff = %0.5f",
tot, xTot, fDiff);

// test that allEU is consistent
Expand Down
6 changes: 3 additions & 3 deletions src/cnloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4176,18 +4176,18 @@ RC RSYS::rs_ExportCorrelationValues() // write CSV file containing values from R
{
rs_vfPerTon = vfPerTonNom * fAF[iAF];
char sVf[20];
sprintf(sVf, "%.f", rs_vfPerTon);
snprintf(sVf, sizeof(sVf), "%.f", rs_vfPerTon);
for (int idbO = 0; tdbO[idbO] > 0.f; idbO++)
{ // outdoor conditions
rs_tdbOut = tdbO[idbO];
char sDbO[20];
sprintf(sDbO, "%.f", rs_tdbOut);
snprintf(sDbO, sizeof(sDbO), "%.f", rs_tdbOut);

for (int idbI = 0; tdbI[idbI] > 0.f; idbI++)
{ // entering dry bulb
rs_tdbCoilIn = tdbI[idbI];
char sDbI[20];
sprintf(sDbI, "%.f", rs_tdbCoilIn);
snprintf(sDbI, sizeof(sDbI), "%.f", rs_tdbCoilIn);
for (int iwbI = 0; twbI[iwbI] > 0.f; iwbI++)
{ // entering wet bulb conditions
rs_twbCoilIn = twbI[iwbI];
Expand Down
6 changes: 3 additions & 3 deletions src/cse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ LOCAL void ourGlobalFree( // Windows GlobalFree plus checks & messages
char buf[200];
if (GlobalFlags(*pHan) & GMEM_LOCKCOUNT) // test for 0 lock count, to facilitate explicit error message
{
sprintf( buf, "Error in cneHansFree():\n\n" // lock count non-0. format message.
snprintf( buf, sizeof(buf), "Error in cneHansFree():\n\n" // lock count non-0. format message.
"Global handle 0x%x (%s) is locked",
(unsigned)*pHan, desc );
MessageBox( 0, buf, MBoxTitle, MB_ICONSTOP | MB_OK ); // display message
}
else // not locked
if (GlobalFree(*pHan)) // free the memory, return value 0 if ok
{
sprintf( buf, "Error in cneHansFree():\n\n" // GlobalFree error (unexpected). format message.
snprintf( buf, sizeof(buf), "Error in cneHansFree():\n\n" // GlobalFree error (unexpected). format message.
"GlobalFree() failed, handle 0x%x (%s)",
(unsigned)*pHan, desc );
MessageBox( 0, buf, MBoxTitle, MB_ICONSTOP | MB_OK ); // display message.
Expand Down Expand Up @@ -342,7 +342,7 @@ _DLLImpExp int cse( // CSE main function, called by console main(), Windows Wi
if (!IsWindow(_hPar))
{
char buf[100];
sprintf( buf, "Error in call to cse():\n\n"
snprintf( buf, sizeof(buf), "Error in call to cse():\n\n"
"Parent window handle 0x%x is invalid.",
(int)_hPar );
MessageBox( 0, buf, MBoxTitle, MB_ICONSTOP | MB_OK );
Expand Down
2 changes: 1 addition & 1 deletion src/cuparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ LOCAL RC FC fcnReg( SFST *f, USI wanTy) // parse most functions, for fcn()
* // get value of fcn's type to be assigned to function
*
* char tx[50]; // must be in stack
* sprintf( tx, "%s(...)=", f->id); // for "after ___" in errmsgs
* snprintf( tx, sizeof(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 */
Expand Down
2 changes: 1 addition & 1 deletion src/cuprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]", i);
snprintf( iBuf, sizeof(iBuf), "[%d]", i);
name = iBuf; // make 'name' text for error messages
break;

Expand Down
4 changes: 2 additions & 2 deletions src/cutok.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ RC cuErv( // errmsg with optional preprocessed file line text, caret, file name

// assemble complete text
char whole[MSG_MAXLEN];
sprintf( whole,
snprintf( whole, MSG_MAXLEN,
"%s" // line text (or not)
"%s" // ^ (or not, or with 'where')
"%s%s" // where (or not) and possible newline
Expand All @@ -1013,7 +1013,7 @@ RC cuErv( // errmsg with optional preprocessed file line text, caret, file name
&& lisFind( fileIx, line, tex, &place) ) // and matching place found in listing spool buffer (pp.cpp)
{
// reassemble message without file line(s) text
sprintf( whole,
snprintf( whole, MSG_MAXLEN,
"%s" // ^ (or not, or with 'where')
"%s%s" // where (or not) and possible newline
"%s", // caller's message (or with where)
Expand Down
Loading
Loading