From f123da938575a329f35fd274eae802e74caf3ea9 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 12 Nov 2016 11:07:39 +0100 Subject: [PATCH 1/5] - Fixed GCC warnings with new history code. --- src/c_console.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index 8292624cb..f5265cf40 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -613,7 +613,7 @@ void C_DeinitConsole () while (hist != NULL) { History *next = hist->Newer; - free (hist); + delete hist; hist = next; } HistTail = HistHead = HistPos = NULL; @@ -1659,7 +1659,7 @@ CCMD (history) while (hist) { - Printf (" %s\n", hist->String); + Printf (" %s\n", hist->String.GetChars()); hist = hist->Newer; } } From 104030697ff6c04aa1d4b99b860531bfe6e02a3b Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 12 Nov 2016 11:08:33 +0100 Subject: [PATCH 2/5] - Rename con_numnotify to con_notifylines. Zandronum 1.1 added an option with the same purpose. Use it to avoid duplicates. --- src/c_console.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index f5265cf40..7cde25c57 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -404,9 +404,9 @@ private: }; static FNotifyBuffer NotifyStrings; -CUSTOM_CVAR(Int, con_numnotify, NUMNOTIFIES, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) +CUSTOM_CVAR(Int, con_notifylines, NUMNOTIFIES, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) { - NotifyStrings.Shift(con_numnotify); + NotifyStrings.Shift(self); } @@ -711,7 +711,7 @@ void FNotifyBuffer::AddString(int printlevel, FString source) source.IsEmpty() || gamestate == GS_FULLCONSOLE || gamestate == GS_DEMOSCREEN || - con_numnotify == 0) + con_notifylines == 0) return; if (ConsoleDrawing) @@ -755,9 +755,9 @@ void FNotifyBuffer::AddString(int printlevel, FString source) newline.PrintLevel = printlevel; if (AddType == NEWLINE || Text.Size() == 0) { - if (con_numnotify > 0) + if (con_notifylines > 0) { - Shift(con_numnotify - 1); + Shift(con_notifylines - 1); } Text.Push(newline); } From ffea457d81d6f1f920f02dea5cec7847e28ab1ad Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 12 Nov 2016 11:18:17 +0100 Subject: [PATCH 3/5] - Fixed GCC/Clang warnings with serializer Unicode parser. --- src/serializer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/serializer.cpp b/src/serializer.cpp index dec81e86f..8875b61f9 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -162,7 +162,7 @@ static const char *StringToUnicode(const char *cc, int size = -1) int count = 0; int count1 = 0; out.Clear(); - while (ch = (*c++) & 255) + while ((ch = (*c++) & 255)) { count1++; if (ch >= 128) @@ -180,7 +180,7 @@ static const char *StringToUnicode(const char *cc, int size = -1) out.Last() = 0; c = cc; int i = 0; - while (ch = (*c++) & 255) + while ((ch = (*c++) & 255)) { utf8_encode(ch, &out[i], &count1); i += count1; From 32e0123e1bdf7910849e35ae7c2c82576caa2c88 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Nov 2016 14:01:34 +0100 Subject: [PATCH 4/5] - fixed: FResourceLump::LumpNameSetup passed negative numbers to FString::Truncate for extension-less lump names. --- src/resourcefiles/resourcefile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index 912998d9a..603606341 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -95,7 +95,8 @@ void FResourceLump::LumpNameSetup(FString iname) { long slash = iname.LastIndexOf('/'); FString base = (slash >= 0) ? iname.Mid(slash + 1) : iname; - base.Truncate(base.LastIndexOf('.')); + auto dot = base.LastIndexOf('.'); + if (dot >= 0) base.Truncate(dot); uppercopy(Name, base); Name[8] = 0; FullName = iname; From 0c0cb6d69c79a5d06498a1b10595587f029bdeb1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Nov 2016 15:36:36 +0100 Subject: [PATCH 5/5] - fixed warnings. --- src/c_console.cpp | 12 ++++++------ src/zstring.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index 7cde25c57..3064abb0d 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -282,7 +282,7 @@ struct FCommandBuffer void CursorEnd() { - CursorPos = Text.Len(); + CursorPos = (unsigned)Text.Len(); StartPos = 0; MakeStartPosGood(); } @@ -358,7 +358,7 @@ struct FCommandBuffer { Text.Insert(CursorPos, clip); } - CursorPos += clip.Len(); + CursorPos += (unsigned)clip.Len(); MakeStartPosGood(); } } @@ -366,7 +366,7 @@ struct FCommandBuffer void SetString(FString str) { Text = str; - CursorPos = Text.Len(); + CursorPos = (unsigned)Text.Len(); MakeStartPosGood(); } }; @@ -1862,7 +1862,7 @@ static void C_TabComplete (bool goForward) } TabStart = i; - TabSize = CmdLine.Text.Len() - TabStart; + TabSize = (int)CmdLine.Text.Len() - TabStart; if (!FindTabCommand(&CmdLine.Text[TabStart], &TabPos, TabSize)) return; // No initial matches @@ -1922,7 +1922,7 @@ static void C_TabComplete (bool goForward) CmdLine.Text << TabCommands[TabPos].TabName << ' '; } } - CmdLine.CursorPos = CmdLine.Text.Len(); + CmdLine.CursorPos = (unsigned)CmdLine.Text.Len(); CmdLine.MakeStartPosGood(); } @@ -1996,7 +1996,7 @@ static bool C_TabCompleteList () TabSize = commonsize; CmdLine.Text.Truncate(TabStart); CmdLine.Text.AppendCStrPart(TabCommands[TabPos].TabName.GetChars(), commonsize); - CmdLine.CursorPos = CmdLine.Text.Len(); + CmdLine.CursorPos = (unsigned)CmdLine.Text.Len(); } return false; } diff --git a/src/zstring.cpp b/src/zstring.cpp index 29270b970..b6e5b4b8d 100644 --- a/src/zstring.cpp +++ b/src/zstring.cpp @@ -397,7 +397,7 @@ void FString::Remove(size_t index, size_t remlen) if (Data()->RefCount == 1) { // Can do this in place memmove(Chars + index, Chars + index + remlen, Len() - index - remlen); - Data()->Len -= remlen; + Data()->Len -= (unsigned)remlen; } else { // Must do it in a copy