Skip to content

Commit

Permalink
new fix attempt, original suffix logic unless defined ORANGE_NAMES_WI…
Browse files Browse the repository at this point in the history
…TH_DOTS
  • Loading branch information
rochus-keller committed May 12, 2024
1 parent b19fc94 commit 329342d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion BUSY
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let config : Config {

let config2 : Config {
.include_dirs += [ . ./src/occopt ./src/util ./src/ocpp ]
.defines += [ "ORANGE_NO_MSIL" "ORANGE_NO_INASM" ]
.defines += [ "ORANGE_NO_MSIL" "ORANGE_NO_INASM" "ORANGE_NAMES_WITH_DOTS" ]
}

let common : SourceSet {
Expand Down
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);
strcat(buf, ".icd2");
Utils::AddExt(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");
strcat(buf, ".icf");
Utils::AddExt(buf, ".icf");
outputFile = buf;
}
FILE* fil = fopen(files[1].c_str(), "rb");
Expand Down
11 changes: 7 additions & 4 deletions src/occparse/occparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ int main(int argc, char* argv[])
{
CompletionCompiler::ccNewFile(buffer, true);
}
#ifndef ORANGE_NAMES_WITH_DOTS
Utils::AddExt(buffer, ".c");
#endif
if (prm_std.GetExists())
{
if (prm_std.GetValue() == "c89")
Expand Down Expand Up @@ -659,7 +662,7 @@ int main(int argc, char* argv[])
else
{
Utils::StripExt(buffer);
strcat(buffer, ".i");
Utils::AddExt(buffer, ".i");
}
strcpy(cppfile, buffer);

Expand All @@ -673,7 +676,7 @@ int main(int argc, char* argv[])
if (Optimizer::cparams.prm_errfile)
{
Utils::StripExt(buffer);
strcat(buffer, ".err");
Utils::AddExt(buffer, ".err");
errFile = fopen(buffer, "w");
if (!errFile)
{
Expand All @@ -685,7 +688,7 @@ int main(int argc, char* argv[])
if (Optimizer::cparams.prm_icdfile)
{
Utils::StripExt(buffer);
strcat(buffer, ".icd");
Utils::AddExt(buffer, ".icd");
Optimizer::icdFile = fopen(buffer, "w");
if (!Optimizer::icdFile)
{
Expand Down Expand Up @@ -716,7 +719,7 @@ int main(int argc, char* argv[])
// compile to file
strcpy(realOutFile, (const char*)clist->data);
Utils::StripExt(realOutFile);
strcat(realOutFile, ".icf");
Utils::AddExt(realOutFile, ".icf");
FILE* fil = fopen(realOutFile, "wb");
if (!fil)
Utils::Fatal("Cannot open '%s' for write", realOutFile);
Expand Down
14 changes: 6 additions & 8 deletions src/occparse/osutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,16 +1010,17 @@ void InsertOneFile(const char* filename, char* path, int drive)
strcpy(temp, p);
Utils::StripExt(temp);
if (!Optimizer::cparams.prm_compileonly && !Optimizer::cparams.prm_assemble)
strcat(temp, ".exe");
Utils::AddExt(temp, ".exe");
firstFile = temp;
}
inserted = insert_noncompile_file(buffer);
if (a)
buffer[0] = a;
if (!inserted)
{
// RK: why should filenames without extension be supported and default to .c? What about .cpp?
// Utils::AddExt(buffer, ".c");
#ifndef ORANGE_NAMES_WITH_DOTS
Utils::AddExt(buffer, ".c");
#endif
newbuffer = (char*)malloc(strlen(buffer) + 1);
if (!newbuffer)
return;
Expand Down Expand Up @@ -1100,15 +1101,12 @@ void outputfile(char* buf, const char* orgbuf, const char* ext)
p = orgbuf;
strcat(buf, p);
Utils::StripExt(buf);
strcat(buf, ext);
Utils::AddExt(buf, ext);
}
else if (prm_output.GetExists() && !MakeStubsContinue.GetValue() && !MakeStubsContinueUser.GetValue())
{
#if TARGET_OS_WINDOWS
#ifndef ORANGE_NAMES_WITH_DOTS
Utils::AddExt(buf, ext);
#else
if( !Utils::HasExt(buf, ext) )
Utils::AddExt(buf, ext);
#endif
}
else
Expand Down
5 changes: 3 additions & 2 deletions src/util/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,14 @@ FILE* Utils::TempName(std::string& name)
}

/*
* Add ext to buffer
* If no extension, add the one specified
*/
void Utils::AddExt(char* buffer, const char* ext)
{
// RK: back to the original code
#ifndef ORANGE_NAMES_WITH_DOTS
char* pos = (char*)strrchr(buffer, '.');
if (!pos || (*(pos - 1) == '.') || (*(pos + 1) == '\\'))
#endif
strcat(buffer, ext);
}

Expand Down

0 comments on commit 329342d

Please sign in to comment.