replaced sprintf -> snprintf throughout.
This commit is contained in:
parent
44aacfca50
commit
f3414f687c
@ -1,7 +1,7 @@
|
||||
# - musrfit
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
project(musrfit VERSION 1.8.0 LANGUAGES C CXX)
|
||||
project(musrfit VERSION 1.8.1 LANGUAGES C CXX)
|
||||
|
||||
#--- musrfit specific options -------------------------------------------------
|
||||
option(nexus "build optional NeXus support. Needed for ISIS" OFF)
|
||||
|
@ -3863,7 +3863,7 @@ Bool_t PMsrHandler::FilterNumber(TString str, const Char_t *filter, Int_t offset
|
||||
Char_t *cstr, filterStr[32];
|
||||
cstr = new Char_t[str.Sizeof()];
|
||||
strncpy(cstr, str.Data(), str.Sizeof());
|
||||
sprintf(filterStr, "%s%%d", filter);
|
||||
snprintf(filterStr, sizeof(filterStr), "%s%%d", filter);
|
||||
|
||||
// get number if present
|
||||
found = sscanf(cstr, filterStr, &no_found);
|
||||
@ -6609,7 +6609,7 @@ UInt_t PMsrHandler::LastSignificant(Double_t dval, UInt_t precLimit)
|
||||
|
||||
char str[128];
|
||||
|
||||
sprintf(str, "%lf", dval);
|
||||
snprintf(str, sizeof(str), "%lf", dval);
|
||||
|
||||
// find decimal point
|
||||
for (UInt_t i=0; i<strlen(str); i++) {
|
||||
|
@ -543,7 +543,7 @@ void PMusrCanvas::UpdateParamTheoryPad()
|
||||
for (UInt_t i=0; i<param.size(); i++) {
|
||||
str = "";
|
||||
accuracy = GetNeededAccuracy(param[i]);
|
||||
sprintf(accStr, "%%.%dlf", accuracy);
|
||||
snprintf(accStr, sizeof(accStr), "%%.%dlf", accuracy);
|
||||
// parameter no
|
||||
str += param[i].fNo;
|
||||
if (param[i].fNo<10)
|
||||
@ -556,9 +556,9 @@ void PMusrCanvas::UpdateParamTheoryPad()
|
||||
str += " ";
|
||||
// parameter value
|
||||
if (round(param[i].fValue)-param[i].fValue==0)
|
||||
sprintf(cnum, "%.1lf", param[i].fValue);
|
||||
snprintf(cnum, sizeof(cnum), "%.1lf", param[i].fValue);
|
||||
else
|
||||
sprintf(cnum, accStr, param[i].fValue);
|
||||
snprintf(cnum, sizeof(cnum), accStr, param[i].fValue);
|
||||
str += cnum;
|
||||
for (Int_t j=0; j<9-(Int_t)strlen(cnum); j++) // fill spaces
|
||||
str += " ";
|
||||
@ -572,22 +572,22 @@ void PMusrCanvas::UpdateParamTheoryPad()
|
||||
if ((fabs(fabs(param[i].fStep) - param[i].fPosError) < 0.1*fabs(param[i].fStep)) &&
|
||||
(fabs(fabs(param[i].fStep) - param[i].fPosError) < 0.1*param[i].fPosError)) {
|
||||
if (round(err)-err==0)
|
||||
sprintf(cnum, "%.1lf", err);
|
||||
snprintf(cnum, sizeof(cnum), "%.1lf", err);
|
||||
else
|
||||
sprintf(cnum, accStr, err);
|
||||
snprintf(cnum, sizeof(cnum), accStr, err);
|
||||
} else {
|
||||
sprintf(accStr, "%%.%dlf!!", accuracy);
|
||||
snprintf(accStr, sizeof(accStr), "%%.%dlf!!", accuracy);
|
||||
if (round(err)-err==0)
|
||||
sprintf(cnum, "%.1lf!!", err);
|
||||
snprintf(cnum, sizeof(cnum), "%.1lf!!", err);
|
||||
else
|
||||
sprintf(cnum, accStr, err);
|
||||
snprintf(cnum, sizeof(cnum), accStr, err);
|
||||
}
|
||||
str += cnum;
|
||||
} else { // minos was not used
|
||||
if (round(param[i].fStep)-param[i].fStep==0)
|
||||
sprintf(cnum, "%.1lf", param[i].fStep);
|
||||
snprintf(cnum, sizeof(cnum), "%.1lf", param[i].fStep);
|
||||
else
|
||||
sprintf(cnum, accStr, param[i].fStep);
|
||||
snprintf(cnum, sizeof(cnum), accStr, param[i].fStep);
|
||||
str += cnum;
|
||||
}
|
||||
ypos = 0.98-i*yoffset;
|
||||
@ -936,13 +936,13 @@ void PMusrCanvas::UpdateInfoPad()
|
||||
tstr += TString("??,");
|
||||
} else if (ddvec->size() == 1){
|
||||
tstr += TString("T=");
|
||||
sprintf(sval, "%0.2lf", ddvec->at(0).first);
|
||||
snprintf(sval, sizeof(sval), "%0.2lf", ddvec->at(0).first);
|
||||
tstr += TString(sval) + TString("K,");
|
||||
} else {
|
||||
for(UInt_t i(0); i<ddvec->size(); ++i){
|
||||
sprintf(sval, "T%u=", i);
|
||||
snprintf(sval, sizeof(sval), "T%u=", i);
|
||||
tstr += TString(sval);
|
||||
sprintf(sval, "%0.2lf", ddvec->at(i).first);
|
||||
snprintf(sval, sizeof(sval), "%0.2lf", ddvec->at(i).first);
|
||||
tstr += TString(sval) + TString("K,");
|
||||
}
|
||||
}
|
||||
@ -953,10 +953,10 @@ void PMusrCanvas::UpdateInfoPad()
|
||||
tstr += TString("??,");
|
||||
} else {
|
||||
if (dval < 1.0e4) { // Gauss makes sense as a unit
|
||||
sprintf(sval, "%0.2lf", dval);
|
||||
snprintf(sval, sizeof(sval), "%0.2lf", dval);
|
||||
tstr += TString(sval) + TString("G,");
|
||||
} else { // Tesla makes sense as a unit
|
||||
sprintf(sval, "%0.2lf", dval/1.0e4);
|
||||
snprintf(sval, sizeof(sval), "%0.2lf", dval/1.0e4);
|
||||
tstr += TString(sval) + TString("T,");
|
||||
}
|
||||
}
|
||||
@ -967,10 +967,10 @@ void PMusrCanvas::UpdateInfoPad()
|
||||
tstr += TString("??,");
|
||||
} else {
|
||||
if (dval < 1.0e3) { // keV makes sense as a unit
|
||||
sprintf(sval, "%0.2lf", dval);
|
||||
snprintf(sval, sizeof(sval), "%0.2lf", dval);
|
||||
tstr += TString(sval) + TString("keV,");
|
||||
} else { // MeV makes sense as a unit
|
||||
sprintf(sval, "%0.2lf", dval/1.0e3);
|
||||
snprintf(sval, sizeof(sval), "%0.2lf", dval/1.0e3);
|
||||
tstr += TString(sval) + TString("MeV,");
|
||||
}
|
||||
}
|
||||
@ -1579,13 +1579,13 @@ void PMusrCanvas::SaveGraphicsAndQuit(Char_t *fileName, Char_t *graphicsFormat)
|
||||
}
|
||||
|
||||
if (fStartWithFourier)
|
||||
sprintf(ext, "_%d_F", fPlotNumber);
|
||||
snprintf(ext, sizeof(ext), "_%d_F", fPlotNumber);
|
||||
else
|
||||
sprintf(ext, "_%d", fPlotNumber);
|
||||
snprintf(ext, sizeof(ext), "_%d", fPlotNumber);
|
||||
str.Replace(idx, size, ext, strlen(ext));
|
||||
idx += strlen(ext);
|
||||
size = strlen(ext);
|
||||
sprintf(ext, ".%s", graphicsFormat);
|
||||
snprintf(ext, sizeof(ext), ".%s", graphicsFormat);
|
||||
str.Replace(idx, size, ext, strlen(ext));
|
||||
|
||||
std::cout << std::endl << ">> SaveGraphicsAndQuit: " << str.Data() << std::endl;
|
||||
@ -6539,7 +6539,7 @@ UInt_t PMusrCanvas::GetNeededAccuracy(PMsrParamStructure param)
|
||||
if (param.fStep == 0.0) { // check if fit parameter is a constant, i.e. step==0
|
||||
char str[128];
|
||||
|
||||
sprintf(str, "%lf", param.fValue);
|
||||
snprintf(str, sizeof(str), "%lf", param.fValue);
|
||||
|
||||
// find decimal point
|
||||
for (UInt_t i=0; i<strlen(str); i++) {
|
||||
|
@ -823,9 +823,9 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
else // bzip2
|
||||
fln += TString(".tar.bz2");
|
||||
if (fAny2ManyInfo->compressionTag == 1) // gzip
|
||||
sprintf(cmd, "tar -zcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data());
|
||||
snprintf(cmd, sizeof(cmd), "tar -zcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data());
|
||||
else // bzip2
|
||||
sprintf(cmd, "tar -jcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data());
|
||||
snprintf(cmd, sizeof(cmd), "tar -jcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data());
|
||||
if (system(cmd) == -1) {
|
||||
std::cerr << "**ERROR** cmd: " << cmd << " failed." << std::endl;
|
||||
}
|
||||
@ -833,19 +833,19 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
|
||||
fln += TString(".tar");
|
||||
for (UInt_t i=0; i<fAny2ManyInfo->outPathFileName.size(); i++) {
|
||||
if (i==0) {
|
||||
sprintf(cmd, "tar -cf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[i].Data());
|
||||
snprintf(cmd, sizeof(cmd), "tar -cf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[i].Data());
|
||||
} else {
|
||||
sprintf(cmd, "tar -rf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[i].Data());
|
||||
snprintf(cmd, sizeof(cmd), "tar -rf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[i].Data());
|
||||
}
|
||||
if (system(cmd) == -1) {
|
||||
std::cerr << "**ERROR** cmd: " << cmd << " failed." << std::endl;
|
||||
}
|
||||
}
|
||||
if (fAny2ManyInfo->compressionTag == 1) { // gzip
|
||||
sprintf(cmd, "gzip %s", fln.Data());
|
||||
snprintf(cmd, sizeof(cmd), "gzip %s", fln.Data());
|
||||
fln += ".gz";
|
||||
} else {
|
||||
sprintf(cmd, "bzip2 -z %s", fln.Data());
|
||||
snprintf(cmd, sizeof(cmd), "bzip2 -z %s", fln.Data());
|
||||
fln += ".bz2";
|
||||
}
|
||||
if (system(cmd) == -1) {
|
||||
@ -1642,7 +1642,7 @@ Bool_t PRunDataHandler::ReadRootFile()
|
||||
// get all the data
|
||||
Char_t histoName[32];
|
||||
for (Int_t i=0; i<noOfHistos; i++) {
|
||||
sprintf(histoName, "hDecay%02d", i);
|
||||
snprintf(histoName, sizeof(histoName), "hDecay%02d", i);
|
||||
TH1F *histo = dynamic_cast<TH1F*>(folder->FindObjectAny(histoName));
|
||||
if (!histo) {
|
||||
std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName;
|
||||
@ -1671,14 +1671,14 @@ Bool_t PRunDataHandler::ReadRootFile()
|
||||
histoData.clear();
|
||||
}
|
||||
// check if any post pileup histos are present at all (this is not the case for LEM data 2006 and earlier)
|
||||
sprintf(histoName, "hDecay%02d", POST_PILEUP_HISTO_OFFSET);
|
||||
snprintf(histoName, sizeof(histoName), "hDecay%02d", POST_PILEUP_HISTO_OFFSET);
|
||||
if (!folder->FindObjectAny(histoName)) {
|
||||
std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **WARNING** Couldn't get histo " << histoName;
|
||||
std::cerr << std::endl << ">> most probably this is an old (2006 or earlier) LEM file without post pileup histos.";
|
||||
std::cerr << std::endl;
|
||||
} else {
|
||||
for (Int_t i=0; i<noOfHistos; i++) {
|
||||
sprintf(histoName, "hDecay%02d", i+POST_PILEUP_HISTO_OFFSET);
|
||||
snprintf(histoName, sizeof(histoName), "hDecay%02d", i+POST_PILEUP_HISTO_OFFSET);
|
||||
TH1F *histo = dynamic_cast<TH1F*>(folder->FindObjectAny(histoName));
|
||||
if (!histo) {
|
||||
std::cerr << std::endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName;
|
||||
@ -4676,7 +4676,7 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln)
|
||||
return false;
|
||||
}
|
||||
size = dataSet->GetData()->size();
|
||||
sprintf(str, "hDecay%02d", static_cast<Int_t>(i));
|
||||
snprintf(str, sizeof(str), "hDecay%02d", static_cast<Int_t>(i));
|
||||
histo = new TH1F(str, str, size+1, -0.5, static_cast<Double_t>(size)+0.5);
|
||||
for (UInt_t j=0; j<size; j++) {
|
||||
histo->SetBinContent(j+1, dataSet->GetData()->at(j));
|
||||
@ -4694,7 +4694,7 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln)
|
||||
return false;
|
||||
}
|
||||
size = dataSet->GetData()->size();
|
||||
sprintf(str, "hDecay%02d", static_cast<Int_t>(i));
|
||||
snprintf(str, sizeof(str), "hDecay%02d", static_cast<Int_t>(i));
|
||||
histo = new TH1F(str, str, static_cast<UInt_t>(size/fAny2ManyInfo->rebin)+1, -0.5, static_cast<Double_t>(size)/static_cast<Double_t>(fAny2ManyInfo->rebin)+0.5);
|
||||
dataCount = 0;
|
||||
for (UInt_t j=0; j<size; j++) {
|
||||
@ -5558,9 +5558,9 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln)
|
||||
MUD_setOrient(fd, (char *)fData[0].GetOrientation()->Data());
|
||||
MUD_setDas(fd, dummy);
|
||||
MUD_setExperimenter(fd, dummy);
|
||||
sprintf(info, "%lf+-%lf (K)", fData[0].GetTemperature(0), fData[0].GetTempError(0));
|
||||
snprintf(info, sizeof(info), "%lf+-%lf (K)", fData[0].GetTemperature(0), fData[0].GetTempError(0));
|
||||
MUD_setTemperature(fd, info);
|
||||
sprintf(info, "%lf", fData[0].GetField());
|
||||
snprintf(info, sizeof(info), "%lf", fData[0].GetField());
|
||||
MUD_setField(fd, info);
|
||||
|
||||
// generate the histograms
|
||||
@ -6219,7 +6219,7 @@ TString PRunDataHandler::FileNameFromTemplate(TString &fileNameTemplate, Int_t r
|
||||
if (idx == str.Length()) { // 'r' only
|
||||
TString runStr("");
|
||||
char fmt[128];
|
||||
sprintf(fmt , "%%0%dd", str.Length());
|
||||
snprintf(fmt, sizeof(fmt), "%%0%dd", str.Length());
|
||||
runStr.Form(fmt, run);
|
||||
result += runStr;
|
||||
} else { // not only 'r'
|
||||
|
@ -114,7 +114,7 @@ PStartupHandler::PStartupHandler()
|
||||
// check if the startup file is found under $HOME/.musrfit
|
||||
home = getenv("HOME");
|
||||
if (home != nullptr) {
|
||||
sprintf(startup_path_name, "%s/.musrfit/musrfit_startup.xml", home);
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/musrfit_startup.xml", home);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
@ -125,7 +125,7 @@ PStartupHandler::PStartupHandler()
|
||||
// check if the MUSRFITPATH system variable is set
|
||||
pmusrpath = getenv("MUSRFITPATH");
|
||||
if (pmusrpath != nullptr) {
|
||||
sprintf(startup_path_name, "%s/musrfit_startup.xml", pmusrpath);
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/musrfit_startup.xml", pmusrpath);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
@ -135,9 +135,9 @@ PStartupHandler::PStartupHandler()
|
||||
if (!fStartupFileFound) { // MUSRFITPATH not set or empty, will try $ROOTSYS/bin
|
||||
home = getenv("ROOTSYS");
|
||||
if (home != nullptr) {
|
||||
sprintf(musrpath, "%s/bin", home);
|
||||
snprintf(musrpath, sizeof(musrpath), "%s/bin", home);
|
||||
std::cerr << std::endl << "**WARNING** MUSRFITPATH environment variable not set will try " << musrpath << std::endl;
|
||||
sprintf(startup_path_name, "%s/musrfit_startup.xml", musrpath);
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/musrfit_startup.xml", musrpath);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
@ -153,7 +153,7 @@ PStartupHandler::PStartupHandler()
|
||||
} else {
|
||||
home = getenv("HOME");
|
||||
if (home != nullptr) {
|
||||
sprintf(startup_path_name, "%s/.musrfit/musrfit_startup.xml", home);
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/musrfit_startup.xml", home);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
@ -620,7 +620,7 @@ Bool_t PStartupHandler::WriteDefaultStartupFile()
|
||||
// first check that $HOME/.musrfit exists and if NOT create it
|
||||
struct stat info;
|
||||
|
||||
sprintf(startup_path_name, "%s/.musrfit", home);
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit", home);
|
||||
if (!stat(startup_path_name, &info)) {
|
||||
if (!(info.st_mode & S_IFDIR))
|
||||
return false;
|
||||
@ -632,7 +632,7 @@ Bool_t PStartupHandler::WriteDefaultStartupFile()
|
||||
}
|
||||
|
||||
// set path-name for musrfit_startup.xml
|
||||
sprintf(startup_path_name, "%s/.musrfit/musrfit_startup.xml", home);
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/musrfit_startup.xml", home);
|
||||
|
||||
std::ofstream fout(startup_path_name, std::ofstream::out);
|
||||
if (!fout.is_open()) {
|
||||
|
@ -841,12 +841,12 @@ void PTheory::MakeCleanAndTidyTheoryBlock(PMsrLines *fullTheoryBlock)
|
||||
if (static_cast<UInt_t>(tokens->GetEntries()) < fgTheoDataBase[idx].fNoOfParam + 1)
|
||||
return;
|
||||
// make tidy string
|
||||
sprintf(substr, "%-10s", fgTheoDataBase[idx].fName.Data());
|
||||
snprintf(substr, sizeof(substr), "%-10s", fgTheoDataBase[idx].fName.Data());
|
||||
tidy = TString(substr);
|
||||
for (Int_t j=1; j<tokens->GetEntries(); j++) {
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(j));
|
||||
str = ostr->GetString();
|
||||
sprintf(substr, "%6s", str.Data());
|
||||
snprintf(substr, sizeof(substr), "%6s", str.Data());
|
||||
tidy += TString(substr);
|
||||
}
|
||||
if (fgTheoDataBase[idx].fComment.Length() != 0) {
|
||||
@ -913,7 +913,7 @@ void PTheory::MakeCleanAndTidyPolynom(UInt_t i, PMsrLines *fullTheoryBlock)
|
||||
for (Int_t j=1; j<max; j++) {
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(j));
|
||||
str = ostr->GetString();
|
||||
sprintf(substr, "%6s", str.Data());
|
||||
snprintf(substr, sizeof(substr), "%6s", str.Data());
|
||||
tidy += TString(substr);
|
||||
}
|
||||
|
||||
|
2
src/external/BMWtools/BMWStartupHandler.cpp
vendored
2
src/external/BMWtools/BMWStartupHandler.cpp
vendored
@ -403,7 +403,7 @@ void BMWStartupHandler::CheckLists()
|
||||
<< "BMWStartupHandler::CheckLists: Most probably this will go wrong and should therefore be fixed in the xml-file!" << std::endl;
|
||||
char eChar[5];
|
||||
for(unsigned int i(0); i<fEnergyList.size(); i++) {
|
||||
sprintf(eChar, "%02.1f", fEnergyList[i]);
|
||||
snprintf(eChar, sizeof(eChar), "%02.1f", fEnergyList[i]);
|
||||
fEnergyLabelList.push_back(std::string(eChar));
|
||||
}
|
||||
}
|
||||
|
40
src/external/TLemRunHeader/TLemRunHeader.cxx
vendored
40
src/external/TLemRunHeader/TLemRunHeader.cxx
vendored
@ -91,7 +91,7 @@ void TLemRunHeader::SetStopTimeString(const Char_t *stop){
|
||||
void TLemRunHeader::SetModeratorHV(Float_t modHV, Float_t error){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s, "05 Moderator HV: %8.2f(%5.2f)", modHV, error);
|
||||
snprintf(s, sizeof(s), "05 Moderator HV: %8.2f(%5.2f)", modHV, error);
|
||||
str = s;
|
||||
fModeratorHVString.SetString(str);
|
||||
fModeratorHV = modHV;
|
||||
@ -101,7 +101,7 @@ void TLemRunHeader::SetModeratorHV(Float_t modHV, Float_t error){
|
||||
void TLemRunHeader::SetSampleHV(Float_t value, Float_t error){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"06 Sample HV: %8.2f(%5.2f)", value, error);
|
||||
snprintf(s, sizeof(s), "06 Sample HV: %8.2f(%5.2f)", value, error);
|
||||
str = s;
|
||||
fSampleHVString.SetString(str);
|
||||
fSampleHV = value;
|
||||
@ -111,7 +111,7 @@ void TLemRunHeader::SetSampleHV(Float_t value, Float_t error){
|
||||
void TLemRunHeader::SetImpEnergy(Float_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"07 Impl. Energy: %8.2f", value);
|
||||
snprintf(s, sizeof(s), "07 Impl. Energy: %8.2f", value);
|
||||
str = s;
|
||||
fImpEnergyString.SetString(str);
|
||||
fImpEnergy = value;
|
||||
@ -120,7 +120,7 @@ void TLemRunHeader::SetImpEnergy(Float_t value){
|
||||
void TLemRunHeader::SetSampleTemperature(Float_t value, Float_t error){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"08 Sample T: %8.2f(%5.2f)", value, error);
|
||||
snprintf(s, sizeof(s), "08 Sample T: %8.2f(%5.2f)", value, error);
|
||||
str = s;
|
||||
fSampleTemperatureString.SetString(str);
|
||||
fSampleTemperature = value;
|
||||
@ -130,7 +130,7 @@ void TLemRunHeader::SetSampleTemperature(Float_t value, Float_t error){
|
||||
void TLemRunHeader::SetSampleBField(Float_t value, Float_t error){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"09 Sample B: %8.2f(%5.2f)", value, error);
|
||||
snprintf(s, sizeof(s), "09 Sample B: %8.2f(%5.2f)", value, error);
|
||||
str = s;
|
||||
fSampleBFieldString.SetString(str);
|
||||
fSampleBField = value;
|
||||
@ -140,7 +140,7 @@ void TLemRunHeader::SetSampleBField(Float_t value, Float_t error){
|
||||
void TLemRunHeader::SetTimeResolution(Float_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"10 Time Res.: %10.7f", value);
|
||||
snprintf(s, sizeof(s), "10 Time Res.: %10.7f", value);
|
||||
str = s;
|
||||
fTimeResolutionString.SetString(str);
|
||||
fTimeResolution = value;
|
||||
@ -149,7 +149,7 @@ void TLemRunHeader::SetTimeResolution(Float_t value){
|
||||
void TLemRunHeader::SetNChannels(Int_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"11 N Channels: %8d", value);
|
||||
snprintf(s, sizeof(s), "11 N Channels: %8d", value);
|
||||
str = s;
|
||||
fNChannelsString.SetString(str);
|
||||
fNChannels = value;
|
||||
@ -158,7 +158,7 @@ void TLemRunHeader::SetNChannels(Int_t value){
|
||||
void TLemRunHeader::SetNHist(Int_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"12 N Histograms: %6d", value);
|
||||
snprintf(s, sizeof(s), "12 N Histograms: %6d", value);
|
||||
str = s;
|
||||
fNHistString.SetString(str);
|
||||
fNHist = value;
|
||||
@ -168,7 +168,7 @@ void TLemRunHeader::SetNHist(Int_t value){
|
||||
void TLemRunHeader::SetOffsetPPCHistograms(UInt_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"13 Offset PPC Histograms: %6d", value);
|
||||
snprintf(s, sizeof(s), "13 Offset PPC Histograms: %6d", value);
|
||||
str = s;
|
||||
fOffsetPPCHistogramsString.SetString(str);
|
||||
fOffsetPPCHistograms = value;
|
||||
@ -364,25 +364,25 @@ void TLemRunHeader::DrawHeader() const {
|
||||
strcpy(str, "Run Stop: ");
|
||||
strcat(str, runStop);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Run Number: %10d", GetRunNumber());
|
||||
snprintf(str, sizeof(str), "Run Number: %10d", GetRunNumber());
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Moderator HV: %10.2f kV", fModeratorHV);
|
||||
snprintf(str, sizeof(str), "Moderator HV: %10.2f kV", fModeratorHV);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Sample HV: %10.2f kV", fSampleHV);
|
||||
snprintf(str, sizeof(str), "Sample HV: %10.2f kV", fSampleHV);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Impl. Energy: %10.2f keV", fImpEnergy);
|
||||
snprintf(str, sizeof(str), "Impl. Energy: %10.2f keV", fImpEnergy);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Sample T: %10.2f K", fSampleTemperature);
|
||||
snprintf(str, sizeof(str), "Sample T: %10.2f K", fSampleTemperature);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Sample B: %10.2f G", fSampleBField);
|
||||
snprintf(str, sizeof(str), "Sample B: %10.2f G", fSampleBField);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Time Res.: %10.7f ns", fTimeResolution);
|
||||
snprintf(str, sizeof(str), "Time Res.: %10.7f ns", fTimeResolution);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "N Channels: %10d", fNChannels);
|
||||
snprintf(str, sizeof(str), "N Channels: %10d", fNChannels);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "N Histograms: %10d", fNHist);
|
||||
snprintf(str, sizeof(str), "N Histograms: %10d", fNHist);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Offset PPC Histograms: %10d", fOffsetPPCHistograms);
|
||||
snprintf(str, sizeof(str), "Offset PPC Histograms: %10d", fOffsetPPCHistograms);
|
||||
text = pt->AddText(str);
|
||||
strcpy(str, "Cuts: ");
|
||||
strcat(str, cuts);
|
||||
@ -393,7 +393,7 @@ void TLemRunHeader::DrawHeader() const {
|
||||
|
||||
strcpy(str,"t0: ");
|
||||
for (Int_t i=0; i<fNHist; i++){
|
||||
sprintf(helpstr, " %7.2f ", fTimeZero[i]);
|
||||
snprintf(helpstr, sizeof(helpstr), " %7.2f ", fTimeZero[i]);
|
||||
strcat(str, helpstr);
|
||||
}
|
||||
text = pt->AddText(str);
|
||||
|
2
src/external/libCuba/src/common/Fork.c
vendored
2
src/external/libCuba/src/common/Fork.c
vendored
@ -75,7 +75,7 @@ Extern void SUFFIX(cubafork)(Spin **pspin)
|
||||
}
|
||||
|
||||
if( cubaverb_ ) {
|
||||
sprintf(out, "using %d cores %d accelerators via "
|
||||
snprintf(out, sizeof(out), "using %d cores %d accelerators via "
|
||||
#ifdef HAVE_SHMGET
|
||||
"shared memory",
|
||||
#else
|
||||
|
2
src/external/libCuba/src/common/Parallel.c
vendored
2
src/external/libCuba/src/common/Parallel.c
vendored
@ -47,7 +47,7 @@ static inline void DoSampleParallel(This *t, number n, creal *x, real *f
|
||||
t->neval += n;
|
||||
|
||||
if( VERBOSE > 2 ) {
|
||||
sprintf(out, "sampling " NUMBER " points each on %d cores",
|
||||
snprintf(out, sizeof(out), "sampling " NUMBER " points each on %d cores",
|
||||
pcores, ncores);
|
||||
Print(out);
|
||||
}
|
||||
|
6
src/external/libCuba/src/common/stddecl.h
vendored
6
src/external/libCuba/src/common/stddecl.h
vendored
@ -94,7 +94,7 @@ enum { uninitialized = 0x61627563 };
|
||||
var = atoi(env); \
|
||||
if( cubaverb_ ) { \
|
||||
char out[64]; \
|
||||
sprintf(out, "env " name " = %d", (int)var); \
|
||||
snprintf(out, sizeof(out), "env " name " = %d", (int)var); \
|
||||
Print(out); \
|
||||
} \
|
||||
} \
|
||||
@ -280,7 +280,7 @@ enum { signature = 0x41425543 };
|
||||
} \
|
||||
if( ini | statemsg ) { \
|
||||
char s[512]; \
|
||||
sprintf(s, ini ? \
|
||||
snprintf(s, sizeof(s), ini ? \
|
||||
"\nError restoring state from %s, starting from scratch." : \
|
||||
"\nRestored state from %s.", (t)->statefile); \
|
||||
Print(s); \
|
||||
@ -307,7 +307,7 @@ enum { signature = 0x41425543 };
|
||||
} \
|
||||
if( fail | statemsg ) { \
|
||||
char s[512]; \
|
||||
sprintf(s, fail ? \
|
||||
snprintf(s, sizeof(s), fail ? \
|
||||
"\nError saving state to %s." : \
|
||||
"\nSaved state to %s.", (t)->statefile); \
|
||||
Print(s); \
|
||||
|
22
src/external/libCuba/src/divonne/Integrate.c
vendored
22
src/external/libCuba/src/divonne/Integrate.c
vendored
@ -36,7 +36,7 @@ static int Integrate(This *t, real *integral, real *error, real *prob)
|
||||
int fail;
|
||||
|
||||
if( VERBOSE > 1 ) {
|
||||
sprintf(out, "Divonne input parameters:\n"
|
||||
snprintf(out, sizeof(out), "Divonne input parameters:\n"
|
||||
" ndim " COUNT "\n ncomp " COUNT "\n"
|
||||
ML_NOT(" nvec " NUMBER "\n")
|
||||
" epsrel " REAL "\n epsabs " REAL "\n"
|
||||
@ -189,7 +189,7 @@ if( StateWriteTest(t) ) { \
|
||||
WriteState(t);
|
||||
|
||||
if( VERBOSE ) {
|
||||
char *oe = out + sprintf(out, "\n"
|
||||
char *oe = out + snprintf(out, sizeof(out), "\n"
|
||||
"Iteration " COUNT " (pass " COUNT "): " COUNT " regions\n"
|
||||
NUMBER7 " integrand evaluations so far,\n"
|
||||
NUMBER7 " in optimizing regions,\n"
|
||||
@ -197,7 +197,7 @@ if( StateWriteTest(t) ) { \
|
||||
state->iter, state->pass, t->nregions,
|
||||
t->neval, t->neval_opt, t->neval_cut);
|
||||
for( comp = 0; comp < t->ncomp; ++comp )
|
||||
oe += sprintf(oe, "\n[" COUNT "] "
|
||||
oe += snprintf(oe, sizeof(out), "\n[" COUNT "] "
|
||||
REAL " +- " REAL,
|
||||
comp + 1, SHOW(integral[comp]), SHOW(error[comp]));
|
||||
Print(out);
|
||||
@ -255,7 +255,7 @@ if( StateWriteTest(t) ) { \
|
||||
SamplesAlloc(t, &t->samples[1]);
|
||||
|
||||
if( VERBOSE ) {
|
||||
sprintf(out, "\nMain integration on " COUNT
|
||||
snprintf(out, sizeof(out), "\nMain integration on " COUNT
|
||||
" regions with " NUMBER " samples per region.",
|
||||
t->nregions, t->samples[1].neff);
|
||||
Print(out);
|
||||
@ -325,7 +325,7 @@ refine:
|
||||
can_adjust = false;
|
||||
|
||||
if( VERBOSE > 2 ) {
|
||||
sprintf(out, "Sampling remaining " COUNT
|
||||
snprintf(out, sizeof(out), "Sampling remaining " COUNT
|
||||
" regions with " NUMBER " points per region.",
|
||||
t->nregions, t->samples[1].neff);
|
||||
Print(out);
|
||||
@ -369,7 +369,7 @@ refine:
|
||||
if( VERBOSE > 2 ) {
|
||||
cchar *msg = "\nRegion (" REALF ") - (" REALF ")";
|
||||
for( B = (b = region->bounds) + t->ndim; b < B; ++b ) {
|
||||
oe += sprintf(oe, msg, b->lower, b->upper);
|
||||
oe += snprintf(oe, sizeof(out), msg, b->lower, b->upper);
|
||||
msg = "\n (" REALF ") - (" REALF ")";
|
||||
}
|
||||
}
|
||||
@ -408,12 +408,12 @@ refine:
|
||||
if( VERBOSE > 2 ) {
|
||||
#define Out2(f, r) SHOW((r)->avg), SHOW(res->spread/t->samples[f].neff), SHOW((r)->err)
|
||||
#define Out(f) Out2(f, &tot->phase[f])
|
||||
oe += sprintf(oe, "\n[" COUNT "] "
|
||||
oe += snprintf(oe, sizeof(out), "\n[" COUNT "] "
|
||||
REAL " +- " REAL "(" REAL ")\n "
|
||||
REAL " +- " REAL "(" REAL ")", ++comp, Out(0), Out(1));
|
||||
if( todo == 3 ) oe += sprintf(oe, "\n "
|
||||
if( todo == 3 ) oe += snprintf(oe, sizeof(out), "\n "
|
||||
REAL " +- " REAL "(" REAL ")", Out2(2, res));
|
||||
oe += sprintf(oe, " \tchisq " REAL, SHOW(chisq));
|
||||
oe += snprintf(oe, sizeof(out), " \tchisq " REAL, SHOW(chisq));
|
||||
}
|
||||
|
||||
tot->integral += avg;
|
||||
@ -440,9 +440,9 @@ refine:
|
||||
}
|
||||
|
||||
if( VERBOSE > 2 ) {
|
||||
char *oe = out + sprintf(out, "\nTotals:");
|
||||
char *oe = out + snprintf(out, sizeof(out), "\nTotals:");
|
||||
for( tot = state->totals, comp = 0; tot < Tot; ++tot, ++comp )
|
||||
oe += sprintf(oe, "\n[" COUNT "] "
|
||||
oe += snprintf(oe, sizeof(out), "\n[" COUNT "] "
|
||||
REAL " +- " REAL " \tchisq " REAL " (" COUNT " df)",
|
||||
comp + 1, SHOW(integral[comp]), SHOW(error[comp]),
|
||||
SHOW(tot->chisq), df);
|
||||
|
@ -317,7 +317,7 @@ void TPofBCalc::Calculate(const TBofZCalc *BofZ, const TTrimSPData *dataTrimSP,
|
||||
seconds = time (NULL);
|
||||
|
||||
char debugfile[50];
|
||||
int n = sprintf (debugfile, "test_Bz_%ld_%f.dat", seconds, fBmin);
|
||||
int n = snprintf (debugfile, sizeof(debugfile), "test_Bz_%ld_%f.dat", seconds, fBmin);
|
||||
|
||||
if (n > 0) {
|
||||
ofstream of(debugfile);
|
||||
@ -330,10 +330,10 @@ void TPofBCalc::Calculate(const TBofZCalc *BofZ, const TTrimSPData *dataTrimSP,
|
||||
}
|
||||
|
||||
char debugfile1[50];
|
||||
int n1 = sprintf (debugfile1, "test_NZ_%ld_%f.dat", seconds, para[2]);
|
||||
int n1 = snprintf (debugfile1, sizeof(debugfile1), "test_NZ_%ld_%f.dat", seconds, para[2]);
|
||||
|
||||
char debugfile2[50];
|
||||
int n2 = sprintf (debugfile2, "test_NZgss_%ld_%f.dat", seconds, para[2]);
|
||||
int n2 = snprintf (debugfile2, sizeof(debugfile2), "test_NZgss_%ld_%f.dat", seconds, para[2]);
|
||||
|
||||
if (n1 > 0) {
|
||||
ofstream of1(debugfile1);
|
||||
|
@ -357,7 +357,7 @@ void TPofTCalc::FakeData(const string &rootOutputFileName, const std::vector<dou
|
||||
// create run info folder and content
|
||||
TFolder *runInfoFolder = new TFolder("RunInfo", "Run Info");
|
||||
TLemRunHeader *runHeader = new TLemRunHeader();
|
||||
//sprintf(str, "Fake Data generated from %s", pBFileName.Data());
|
||||
//snprintf(str, sizeof(str), "Fake Data generated from %s", pBFileName.Data());
|
||||
runHeader->SetRunTitle("Fake Data");
|
||||
if (optPar && (optPar->size() > 1)) { // set energy and field if they were specified
|
||||
runHeader->SetImpEnergy((*optPar)[1]);
|
||||
|
@ -163,7 +163,7 @@ int generateRgeFln(const string prefix, const string elist, vector<string> &rgeF
|
||||
}
|
||||
ival = start;
|
||||
do {
|
||||
sprintf(istr, "%d", ival);
|
||||
snprintf(istr, sizeof(istr), "%d", ival);
|
||||
str = prefix + istr + ".rge";
|
||||
rgeFln.push_back(str);
|
||||
ival += step;
|
||||
|
@ -78,8 +78,9 @@ void msr2msr_syntax()
|
||||
* - false otherwise
|
||||
*
|
||||
* \param str msr-file line
|
||||
* \param size size of str
|
||||
*/
|
||||
bool msr2msr_run(char *str)
|
||||
bool msr2msr_run(char *str, const std::size_t size)
|
||||
{
|
||||
// not the RUN line itself, hence nothing to be done
|
||||
if (!strstr(str, "RUN"))
|
||||
@ -109,27 +110,27 @@ bool msr2msr_run(char *str)
|
||||
}
|
||||
|
||||
if (tokens->GetEntries() == 5) { // already a new msr file, do only add the proper run comment
|
||||
sprintf(str, "%s (name beamline institute data-file-format)", line.Data());
|
||||
snprintf(str, size, "%s (name beamline institute data-file-format)", line.Data());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (run.Contains("NEMU")) {
|
||||
ostr[0] = dynamic_cast<TObjString*>(tokens->At(1)); // file name
|
||||
sprintf(str, "RUN %s MUE4 PSI WKM (name beamline institute data-file-format)", ostr[0]->GetString().Data());
|
||||
snprintf(str, size, "RUN %s MUE4 PSI WKM (name beamline institute data-file-format)", ostr[0]->GetString().Data());
|
||||
} else if (run.Contains("PSI")) {
|
||||
ostr[0] = dynamic_cast<TObjString*>(tokens->At(1)); // file name
|
||||
ostr[1] = dynamic_cast<TObjString*>(tokens->At(2)); // beamline
|
||||
sprintf(str, "RUN %s %s PSI PSI-BIN (name beamline institute data-file-format)",
|
||||
snprintf(str, size, "RUN %s %s PSI PSI-BIN (name beamline institute data-file-format)",
|
||||
ostr[0]->GetString().Data(), ostr[1]->GetString().Data());
|
||||
} else if (run.Contains("TRIUMF")) {
|
||||
ostr[0] = dynamic_cast<TObjString*>(tokens->At(1)); // file name
|
||||
ostr[1] = dynamic_cast<TObjString*>(tokens->At(2)); // beamline
|
||||
sprintf(str, "RUN %s %s TRIUMF MUD (name beamline institute data-file-format)",
|
||||
snprintf(str, size, "RUN %s %s TRIUMF MUD (name beamline institute data-file-format)",
|
||||
ostr[0]->GetString().Data(), ostr[1]->GetString().Data());
|
||||
} else if (run.Contains("RAL")) {
|
||||
ostr[0] = dynamic_cast<TObjString*>(tokens->At(1)); // file name
|
||||
ostr[1] = dynamic_cast<TObjString*>(tokens->At(2)); // beamline
|
||||
sprintf(str, "RUN %s %s RAL NEXUS (name beamline institute data-file-format)",
|
||||
snprintf(str, size, "RUN %s %s RAL NEXUS (name beamline institute data-file-format)",
|
||||
ostr[0]->GetString().Data(), ostr[1]->GetString().Data());
|
||||
}
|
||||
|
||||
@ -175,7 +176,7 @@ bool msr2msr_param(char *str)
|
||||
for (unsigned int i=0; i<4; i++)
|
||||
ostr[i] = dynamic_cast<TObjString*>(tokens->At(i));
|
||||
// number
|
||||
sprintf(sstr, "%10s", ostr[0]->GetString().Data());
|
||||
snprintf(sstr, sizeof(sstr), "%10s", ostr[0]->GetString().Data());
|
||||
// name
|
||||
strcat(sstr, " ");
|
||||
strcat(sstr, ostr[1]->GetString().Data());
|
||||
@ -206,7 +207,7 @@ bool msr2msr_param(char *str)
|
||||
for (unsigned int i=0; i<6; i++)
|
||||
ostr[i] = dynamic_cast<TObjString*>(tokens->At(i));
|
||||
// number
|
||||
sprintf(sstr, "%10s", ostr[0]->GetString().Data());
|
||||
snprintf(sstr, sizeof(sstr), "%10s", ostr[0]->GetString().Data());
|
||||
// name
|
||||
strcat(sstr, " ");
|
||||
strcat(sstr, ostr[1]->GetString().Data());
|
||||
@ -480,7 +481,7 @@ void msr2msr_replace(char *str, int paramNo)
|
||||
|
||||
memset(temp, 0, sizeof(temp));
|
||||
|
||||
sprintf(no, "%d", paramNo);
|
||||
snprintf(no, sizeof(no), "%d", paramNo);
|
||||
|
||||
int j=0;
|
||||
for (unsigned int i=0; i<strlen(str); i++) {
|
||||
@ -573,7 +574,7 @@ bool msr2msr_finalize_theory(char *fln, int theoryTag, int noOfAddionalParams)
|
||||
|
||||
|
||||
// cp __temp.msr fln
|
||||
sprintf(str, "cp __temp.msr %s", fln);
|
||||
snprintf(str, sizeof(str), "cp __temp.msr %s", fln);
|
||||
if (system(str) == -1) {
|
||||
std::cerr << "**ERROR** cmd: " << str << " failed." << std::endl;
|
||||
return false;
|
||||
@ -598,8 +599,9 @@ bool msr2msr_finalize_theory(char *fln, int theoryTag, int noOfAddionalParams)
|
||||
* - false otherwise
|
||||
*
|
||||
* \param str msr-file statistic block line
|
||||
* \param size size of str
|
||||
*/
|
||||
bool msr2msr_statistic(char *str) {
|
||||
bool msr2msr_statistic(char *str, const std::size_t size) {
|
||||
bool success = true;
|
||||
|
||||
char *pstr;
|
||||
@ -621,7 +623,7 @@ bool msr2msr_statistic(char *str) {
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
sprintf(str, " chisq = %lf, NDF = %d, chisq/NDF = %lf", chisq, static_cast<int>(chisq/chisqred), chisqred);
|
||||
snprintf(str, size, " chisq = %lf, NDF = %d, chisq/NDF = %lf", chisq, static_cast<int>(chisq/chisqred), chisqred);
|
||||
}
|
||||
}
|
||||
|
||||
@ -691,10 +693,10 @@ int main(int argc, char *argv[])
|
||||
success = msr2msr_theory(str, theoryTag, noOfAddionalParams);
|
||||
break;
|
||||
case MSR_TAG_RUN:
|
||||
success = msr2msr_run(str);
|
||||
success = msr2msr_run(str, sizeof(str));
|
||||
break;
|
||||
case MSR_TAG_STATISTIC:
|
||||
success = msr2msr_statistic(str);
|
||||
success = msr2msr_statistic(str, sizeof(str));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -709,7 +711,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// check if conversion seems to be OK
|
||||
if (!success) {
|
||||
sprintf(str, "rm -rf %s", argv[2]);
|
||||
snprintf(str, sizeof(str), "rm -rf %s", argv[2]);
|
||||
if (system(str) == -1) {
|
||||
std::cerr << "**ERROR** cmd: " << str << " failed." << std::endl;
|
||||
return 0;
|
||||
|
@ -103,7 +103,7 @@ PMuppStartupHandler::PMuppStartupHandler()
|
||||
// check if the startup file is found under $HOME/.musrfit/mupp
|
||||
home = getenv("HOME");
|
||||
if (home != 0) {
|
||||
sprintf(startup_path_name, "%s/.musrfit/mupp/mupp_startup.xml", home);
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/mupp/mupp_startup.xml", home);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
|
@ -62,7 +62,7 @@ namespace mupp
|
||||
Iterator line_start = get_pos(err_pos, line);
|
||||
const char *homeStr = getenv("HOME");
|
||||
char fln[1024];
|
||||
sprintf(fln, "%s/.musrfit/mupp/mupp_err.log", homeStr);
|
||||
snprintf(fln, sizeof(fln), "%s/.musrfit/mupp/mupp_err.log", homeStr);
|
||||
std::ofstream fout(fln, std::ofstream::app);
|
||||
if (err_pos != last) {
|
||||
fout << message << what << ':' << std::endl;
|
||||
|
@ -103,7 +103,7 @@ PMuppStartupHandler::PMuppStartupHandler()
|
||||
// check if the startup file is found under $HOME/.musrfit/mupp
|
||||
home = getenv("HOME");
|
||||
if (home != 0) {
|
||||
sprintf(startup_path_name, "%s/.musrfit/mupp/mupp_startup.xml", home);
|
||||
snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/mupp/mupp_startup.xml", home);
|
||||
if (StartupFileExists(startup_path_name)) {
|
||||
fStartupFilePath = TString(startup_path_name);
|
||||
fStartupFileFound = true;
|
||||
|
@ -62,7 +62,7 @@ namespace mupp
|
||||
Iterator line_start = get_pos(err_pos, line);
|
||||
const char *homeStr = getenv("HOME");
|
||||
char fln[1024];
|
||||
sprintf(fln, "%s/.musrfit/mupp/mupp_err.log", homeStr);
|
||||
snprintf(fln, sizeof(fln), "%s/.musrfit/mupp/mupp_err.log", homeStr);
|
||||
std::ofstream fout(fln, std::ofstream::app);
|
||||
if (err_pos != last) {
|
||||
fout << message << what << ':' << std::endl;
|
||||
|
@ -283,10 +283,10 @@ void musrfit_write_root(TFile &f, TString fln, PRunData *data, int runCounter)
|
||||
char name[128];
|
||||
|
||||
TString title = fln.Copy();
|
||||
sprintf(name, "_%d", runCounter);
|
||||
snprintf(name, sizeof(name), "_%d", runCounter);
|
||||
title.ReplaceAll(".root", name);
|
||||
|
||||
sprintf(name, "c%d", runCounter);
|
||||
snprintf(name, sizeof(name),"c%d", runCounter);
|
||||
|
||||
TCanvas *c = new TCanvas(name, title.Data(), 10, 10, 800, 600);
|
||||
|
||||
|
@ -85,7 +85,7 @@ PDumpOutputHandler::~PDumpOutputHandler()
|
||||
}
|
||||
if (fProc->isRunning()) { // try low level kill
|
||||
char cmd[128];
|
||||
sprintf(cmd, "kill -9 %ld", fProcPID);
|
||||
snprintf(cmd, sizeof(cnd), "kill -9 %ld", fProcPID);
|
||||
system(cmd);
|
||||
}
|
||||
if (fProc) {
|
||||
|
@ -88,7 +88,7 @@ PFitOutputHandler::~PFitOutputHandler()
|
||||
}
|
||||
if (fProc->isRunning()) { // try low level kill
|
||||
char cmd[128];
|
||||
sprintf(cmd, "kill -9 %ld", fProcPID);
|
||||
snprintf(cmd, sizeof(cmd), "kill -9 %ld", fProcPID);
|
||||
system(cmd);
|
||||
}
|
||||
if (fProc) {
|
||||
|
@ -396,7 +396,7 @@ int main(int argc, char *argv[])
|
||||
char canvasName[32];
|
||||
for (unsigned int i=0; i<canvasVector.size(); i++) {
|
||||
// check if canvas is still there before calling the destructor **TO BE DONE**
|
||||
sprintf(canvasName, "fMainCanvas%d", i);
|
||||
snprintf(canvasName, sizeof(canvasName), "fMainCanvas%d", i);
|
||||
if (gROOT->GetListOfCanvases()->FindObject(canvasName) != nullptr) {
|
||||
canvasVector[i]->~PMusrCanvas();
|
||||
}
|
||||
|
@ -168,9 +168,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
char fln[128];
|
||||
if (gaussian)
|
||||
sprintf(fln, "dynKT_LF_w0_%1.1f_width%1.1f_nu%1.1f_N%d_G.dat", param[0], param[1], param[2], N);
|
||||
snprintf(fln, sizeof(fln), "dynKT_LF_w0_%1.1f_width%1.1f_nu%1.1f_N%d_G.dat", param[0], param[1], param[2], N);
|
||||
else
|
||||
sprintf(fln, "dynKT_LF_w0_%1.1f_width%1.1f_nu%1.1f_N%d_L.dat", param[0], param[1], param[2], N);
|
||||
snprintf(fln, sizeof(fln), "dynKT_LF_w0_%1.1f_width%1.1f_nu%1.1f_N%d_L.dat", param[0], param[1], param[2], N);
|
||||
|
||||
const double H = Tmax/N;
|
||||
|
||||
|
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
||||
// get data histo
|
||||
char histoName[32];
|
||||
// read first the data which are NOT post pileup corrected
|
||||
sprintf(histoName, "hDecay%02d", histoNo);
|
||||
snprintf(histoName, sizeof(histoName), "hDecay%02d", histoNo);
|
||||
TH1F *histo = dynamic_cast<TH1F*>(folder->FindObjectAny(histoName));
|
||||
if (!histo) {
|
||||
cout << endl << "PRunDataHandler::ReadRootFile: Couldn't get histo " << histoName;
|
||||
|
@ -5,8 +5,6 @@
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
$Id$
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
@ -443,7 +441,7 @@ int main(int argc, char *argv[])
|
||||
// create run info folder and content
|
||||
TFolder *runInfoFolder = new TFolder("RunInfo", "Run Info");
|
||||
TLemRunHeader *runHeader = new TLemRunHeader();
|
||||
sprintf(str, "Fake Data generated from %s", pBFileName.Data());
|
||||
snprintf(str, sizeof(str), "Fake Data generated from %s", pBFileName.Data());
|
||||
runHeader->SetRunTitle(str);
|
||||
Float_t fval = timeResolution;
|
||||
runHeader->SetTimeResolution(fval);
|
||||
|
Loading…
x
Reference in New Issue
Block a user