Write text files with unix file endings

The old LineFeed constant caused problems with Qt. Using \n directly is
easier and I don't think there's a reason left to use \r\n anyways.
We've always converted the files in the repository. Nowadays, even
notepad.exe works with unix file endings.
master
Lukas Werling 2019-02-19 15:28:12 +01:00
parent a00566ca9e
commit 60841c1d96
9 changed files with 22 additions and 27 deletions

View File

@ -239,7 +239,7 @@ bool C4GameSave::SaveDesc(C4Group &hToGroup)
// Scenario title
sBuffer.Append(Game.ScenarioTitle.getData());
sBuffer.Append(LineFeed LineFeed);
sBuffer.Append("\n\n");
// OK; each specializations has its own desc format
WriteDesc(sBuffer);
@ -256,7 +256,7 @@ bool C4GameSave::SaveDesc(C4Group &hToGroup)
void C4GameSave::WriteDescLineFeed(StdStrBuf &sBuf)
{
// paragraph end + cosmetics
sBuf.Append(LineFeed LineFeed);
sBuf.Append("\n\n");
}
void C4GameSave::WriteDescDate(StdStrBuf &sBuf, bool fRecord)

View File

@ -22,7 +22,6 @@
#ifdef WITH_QT_EDITOR
// Avoid some name conflicts
#undef LineFeed
#undef new
#undef delete
// disable OPENGL_ES

View File

@ -528,7 +528,6 @@ bool CStdGLCtx::PageFlip()
#endif // USE_*
#ifdef WITH_QT_EDITOR
#undef LineFeed // conflicts with Qt
#undef new
#undef delete
#include <QOpenGLWidget>

View File

@ -575,11 +575,11 @@ bool C4MaterialMap::SaveEnumeration(C4Group &hGroup)
{
char *mapbuf = new char [1000];
mapbuf[0]=0;
SAppend("[Enumeration]",mapbuf); SAppend(LineFeed,mapbuf);
SAppend("[Enumeration]",mapbuf); SAppend("\n",mapbuf);
for (int32_t cnt=0; cnt<Num; cnt++)
{
SAppend(Map[cnt].Name,mapbuf);
SAppend(LineFeed,mapbuf);
SAppend("\n",mapbuf);
}
return hGroup.Add(C4CFN_MatMap,mapbuf,SLen(mapbuf),false,true);
}

View File

@ -311,19 +311,19 @@ bool C4TextureMap::SaveMap(C4Group &hGroup, const char *szEntryName)
// build file in memory
StdStrBuf sTexMapFile;
// add desc
sTexMapFile.Append("# Automatically generated texture map" LineFeed);
sTexMapFile.Append("# Contains material-texture-combinations added at runtime" LineFeed);
sTexMapFile.Append("# Automatically generated texture map\n");
sTexMapFile.Append("# Contains material-texture-combinations added at runtime\n");
// add overload-entries
if (fOverloadMaterials) sTexMapFile.Append("# Import materials from global file as well" LineFeed "OverloadMaterials" LineFeed);
if (fOverloadTextures) sTexMapFile.Append("# Import textures from global file as well" LineFeed "OverloadTextures" LineFeed);
sTexMapFile.Append(LineFeed);
if (fOverloadMaterials) sTexMapFile.Append("# Import materials from global file as well\nOverloadMaterials\n");
if (fOverloadTextures) sTexMapFile.Append("# Import textures from global file as well\nOverloadTextures\n");
sTexMapFile.Append("\n");
// add entries
for (auto i : Order)
{
if (!Entry[i].isNull())
{
// compose line
sTexMapFile.AppendFormat("%d=%s-%s" LineFeed, i, Entry[i].GetMaterialName(), Entry[i].GetTextureName());
sTexMapFile.AppendFormat("%d=%s-%s\n", i, Entry[i].GetMaterialName(), Entry[i].GetTextureName());
}
}
// create new buffer allocated with new [], because C4Group cannot handle StdStrBuf-buffers

View File

@ -144,8 +144,6 @@ int SLineGetCharacters(const char *szText, const char *cpPosition);
// can match strings like "*Cl?nk*vour" to "Clonk Endeavour"
bool SWildcardMatchEx(const char *szString, const char *szWildcard);
#define LineFeed "\x00D\x00A"
// sprintf wrapper
#ifdef _WIN32

View File

@ -234,7 +234,7 @@ void StdCompilerINIWrite::NameEnd(bool fBreak)
{
// Append newline
if (!fPutName && !fInSection)
Buf.Append("\r\n");
Buf.Append("\n");
fPutName = false;
// Note this makes it impossible to distinguish an empty name section from
// a non-existing name section.
@ -432,11 +432,11 @@ void StdCompilerINIWrite::WriteIndent(bool fSection)
void StdCompilerINIWrite::PutName(bool fSection)
{
if (fSection && Buf.getLength())
Buf.Append("\r\n");
Buf.Append("\n");
WriteIndent(fSection);
// Put name
if (fSection)
Buf.AppendFormat("[%s]\r\n", pNaming->Name.getData());
Buf.AppendFormat("[%s]\n", pNaming->Name.getData());
else
Buf.AppendFormat("%s=", pNaming->Name.getData());
// Set flag

View File

@ -1633,38 +1633,38 @@ StdStrBuf C4Object::GetDataString()
// Owner
if (ValidPlr(Owner))
{
Output.Append(LineFeed);
Output.Append("\n");
Output.AppendFormat(LoadResStr("IDS_CNS_OWNER"),::Players.Get(Owner)->GetName());
}
// Contents
if (Contents.ObjectCount())
{
Output.Append(LineFeed);
Output.Append("\n");
Output.Append(LoadResStr("IDS_CNS_CONTENTS"));
Output.Append(Contents.GetNameList(::Definitions));
}
// Action
if (GetAction())
{
Output.Append(LineFeed);
Output.Append("\n");
Output.Append(LoadResStr("IDS_CNS_ACTION"));
Output.Append(GetAction()->GetName());
}
// Properties
Output.Append(LineFeed);
Output.Append("\n");
Output.Append(LoadResStr("IDS_CNS_PROPERTIES"));
Output.Append(LineFeed " ");
AppendDataString(&Output, LineFeed " ");
Output.Append("\n ");
AppendDataString(&Output, "\n ");
// Effects
if (pEffects)
{
Output.Append(LineFeed);
Output.Append("\n");
Output.Append(LoadResStr("IDS_CNS_EFFECTS"));
Output.Append(": ");
}
for (C4Effect *pEffect = pEffects; pEffect; pEffect = pEffect->pNext)
{
Output.Append(LineFeed);
Output.Append("\n");
// Effect name
Output.AppendFormat(" %s: Priority %d, Interval %d", pEffect->GetName(), pEffect->iPriority, pEffect->iInterval);
}
@ -1674,7 +1674,7 @@ StdStrBuf C4Object::GetDataString()
DecompileToBuf_Log<StdCompilerINIWrite>(mkNamingAdapt(mkInsertAdapt(mkParAdapt(*this, &numbers),
mkNamingAdapt(numbers, "Values"), false),
"Object"), &Output2, "C4Object::GetDataString");
Output.Append(LineFeed);
Output.Append("\n");
Output.Append(Output2);
return Output;
}

View File

@ -65,7 +65,6 @@ bool EraseItemSafe(const char *szFilename)
}
#if defined(WITH_QT_EDITOR)
#undef LineFeed
#include <QDesktopServices>
#include <QUrl>
bool OpenURL(char const* url)