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

View File

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

View File

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

View File

@ -575,11 +575,11 @@ bool C4MaterialMap::SaveEnumeration(C4Group &hGroup)
{ {
char *mapbuf = new char [1000]; char *mapbuf = new char [1000];
mapbuf[0]=0; mapbuf[0]=0;
SAppend("[Enumeration]",mapbuf); SAppend(LineFeed,mapbuf); SAppend("[Enumeration]",mapbuf); SAppend("\n",mapbuf);
for (int32_t cnt=0; cnt<Num; cnt++) for (int32_t cnt=0; cnt<Num; cnt++)
{ {
SAppend(Map[cnt].Name,mapbuf); SAppend(Map[cnt].Name,mapbuf);
SAppend(LineFeed,mapbuf); SAppend("\n",mapbuf);
} }
return hGroup.Add(C4CFN_MatMap,mapbuf,SLen(mapbuf),false,true); 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 // build file in memory
StdStrBuf sTexMapFile; StdStrBuf sTexMapFile;
// add desc // add desc
sTexMapFile.Append("# Automatically generated texture map" LineFeed); sTexMapFile.Append("# Automatically generated texture map\n");
sTexMapFile.Append("# Contains material-texture-combinations added at runtime" LineFeed); sTexMapFile.Append("# Contains material-texture-combinations added at runtime\n");
// add overload-entries // add overload-entries
if (fOverloadMaterials) sTexMapFile.Append("# Import materials from global file as well" LineFeed "OverloadMaterials" 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" LineFeed "OverloadTextures" LineFeed); if (fOverloadTextures) sTexMapFile.Append("# Import textures from global file as well\nOverloadTextures\n");
sTexMapFile.Append(LineFeed); sTexMapFile.Append("\n");
// add entries // add entries
for (auto i : Order) for (auto i : Order)
{ {
if (!Entry[i].isNull()) if (!Entry[i].isNull())
{ {
// compose line // 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 // 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" // can match strings like "*Cl?nk*vour" to "Clonk Endeavour"
bool SWildcardMatchEx(const char *szString, const char *szWildcard); bool SWildcardMatchEx(const char *szString, const char *szWildcard);
#define LineFeed "\x00D\x00A"
// sprintf wrapper // sprintf wrapper
#ifdef _WIN32 #ifdef _WIN32

View File

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

View File

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

View File

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