Skip to content

Commit

Permalink
yet another fix attempt, restore original AddExt, use strcat where po…
Browse files Browse the repository at this point in the history
…ssible
  • Loading branch information
rochus-keller committed May 12, 2024
1 parent c17d77a commit b19fc94
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/occopt/optmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void SaveFile(std::string& name, SharedMemory* optimizerMem)
char buf[260];
strcpy(buf, name.c_str());
Utils::StripExt(buf);
Utils::AddExt(buf, ".icd2");
strcat(buf, ".icd2");
icdFile = fopen(buf, "w");
if (!icdFile)
return;
Expand Down Expand Up @@ -495,7 +495,7 @@ int main(int argc, char* argv[])
strcpy(buf, files[1].c_str());
Utils::StripExt(buf);
strcat(buf, "_1");
Utils::AddExt(buf, ".icf");
strcat(buf, ".icf");
outputFile = buf;
}
FILE* fil = fopen(files[1].c_str(), "rb");
Expand Down
8 changes: 4 additions & 4 deletions src/occparse/occparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ int main(int argc, char* argv[])
else
{
Utils::StripExt(buffer);
Utils::AddExt(buffer, ".i");
strcat(buffer, ".i");
}
strcpy(cppfile, buffer);

Expand All @@ -673,7 +673,7 @@ int main(int argc, char* argv[])
if (Optimizer::cparams.prm_errfile)
{
Utils::StripExt(buffer);
Utils::AddExt(buffer, ".err");
strcat(buffer, ".err");
errFile = fopen(buffer, "w");
if (!errFile)
{
Expand All @@ -685,7 +685,7 @@ int main(int argc, char* argv[])
if (Optimizer::cparams.prm_icdfile)
{
Utils::StripExt(buffer);
Utils::AddExt(buffer, ".icd");
strcat(buffer, ".icd");
Optimizer::icdFile = fopen(buffer, "w");
if (!Optimizer::icdFile)
{
Expand Down Expand Up @@ -716,7 +716,7 @@ int main(int argc, char* argv[])
// compile to file
strcpy(realOutFile, (const char*)clist->data);
Utils::StripExt(realOutFile);
Utils::AddExt(realOutFile, ".icf");
strcat(realOutFile, ".icf");
FILE* fil = fopen(realOutFile, "wb");
if (!fil)
Utils::Fatal("Cannot open '%s' for write", realOutFile);
Expand Down
8 changes: 3 additions & 5 deletions src/occparse/osutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ void InsertOneFile(const char* filename, char* path, int drive)
strcpy(temp, p);
Utils::StripExt(temp);
if (!Optimizer::cparams.prm_compileonly && !Optimizer::cparams.prm_assemble)
Utils::AddExt(temp, ".exe");
strcat(temp, ".exe");
firstFile = temp;
}
inserted = insert_noncompile_file(buffer);
Expand Down Expand Up @@ -1100,14 +1100,12 @@ void outputfile(char* buf, const char* orgbuf, const char* ext)
p = orgbuf;
strcat(buf, p);
Utils::StripExt(buf);
Utils::AddExt(buf, ext);
strcat(buf, ext);
}
else if (prm_output.GetExists() && !MakeStubsContinue.GetValue() && !MakeStubsContinueUser.GetValue())
{
#if TARGET_OS_WINDOWS
char* pos = (char*)strrchr(buf, '.');
if (!pos || (*(pos - 1) == '.') || (*(pos + 1) == '\\'))
strcat(buf, ext);
Utils::AddExt(buf, ext);
#else
if( !Utils::HasExt(buf, ext) )
Utils::AddExt(buf, ext);
Expand Down
6 changes: 3 additions & 3 deletions src/util/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ FILE* Utils::TempName(std::string& name)
*/
void Utils::AddExt(char* buffer, const char* ext)
{
//char* pos = (char*)strrchr(buffer, '.');
//if (!pos || strcmp(pos,ext) != 0 )
// NOTE: the strcmp gives no added value; AddExt is always preceded by StripExt
// RK: back to the original code
char* pos = (char*)strrchr(buffer, '.');
if (!pos || (*(pos - 1) == '.') || (*(pos + 1) == '\\'))
strcat(buffer, ext);
}

Expand Down

0 comments on commit b19fc94

Please sign in to comment.