Skip to content

Commit 9388704

Browse files
committed
Clean up Strfnd
Changes: * Fix indentation. * Pass strings by const reference. * Merge Strfnd and WStrfnd into one class instead of copying them. * Remove trailing spaces. * Fix variable names. * Move to util. * Other miscellaneous style fixes.
1 parent eb7db21 commit 9388704

File tree

14 files changed

+103
-198
lines changed

14 files changed

+103
-198
lines changed

src/ban.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2222
#include "threading/mutex_auto_lock.h"
2323
#include <sstream>
2424
#include <set>
25-
#include "strfnd.h"
25+
#include "util/strfnd.h"
2626
#include "util/string.h"
2727
#include "log.h"
2828
#include "filesys.h"

src/chat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
1919

2020
#include "chat.h"
2121
#include "debug.h"
22-
#include "strfnd.h"
22+
#include "util/strfnd.h"
2323
#include <cctype>
2424
#include <sstream>
2525
#include "util/string.h"
@@ -684,7 +684,7 @@ void ChatBackend::addMessage(std::wstring name, std::wstring text)
684684

685685
// Note: A message may consist of multiple lines, for example the MOTD.
686686
WStrfnd fnd(text);
687-
while (!fnd.atend())
687+
while (!fnd.at_end())
688688
{
689689
std::wstring line = fnd.next(L"\n");
690690
m_console_buffer.addLine(name, line);

src/client/tile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3131
#include "mesh.h"
3232
#include "log.h"
3333
#include "gamedef.h"
34-
#include "strfnd.h"
34+
#include "util/strfnd.h"
3535
#include "util/string.h" // for parseColorString()
3636
#include "imagefilters.h"
3737
#include "guiscalingfilter.h"
@@ -1242,7 +1242,7 @@ bool TextureSource::generateImagePart(std::string part_of_name,
12421242
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
12431243
baseimg->fill(video::SColor(0,0,0,0));
12441244
}
1245-
while (sf.atend() == false) {
1245+
while (sf.at_end() == false) {
12461246
u32 x = stoi(sf.next(","));
12471247
u32 y = stoi(sf.next("="));
12481248
std::string filename = sf.next(":");

src/craftdef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2929
#include "util/serialize.h"
3030
#include "util/string.h"
3131
#include "util/numeric.h"
32-
#include "strfnd.h"
32+
#include "util/strfnd.h"
3333
#include "exceptions.h"
3434

3535
inline bool isGroupRecipeStr(const std::string &rec_name)
@@ -90,7 +90,7 @@ static bool inputItemMatchesRecipe(const std::string &inp_name,
9090
all_groups_match = false;
9191
break;
9292
}
93-
} while (!f.atend());
93+
} while (!f.at_end());
9494
if (all_groups_match)
9595
return true;
9696
}

src/guiFormSpecMenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2828
#include "constants.h"
2929
#include "gamedef.h"
3030
#include "keycode.h"
31-
#include "strfnd.h"
31+
#include "util/strfnd.h"
3232
#include <IGUICheckBox.h>
3333
#include <IGUIEditBox.h>
3434
#include <IGUIButton.h>

src/inventory.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2323
#include <sstream>
2424
#include "log.h"
2525
#include "itemdef.h"
26-
#include "strfnd.h"
26+
#include "util/strfnd.h"
2727
#include "content_mapnode.h" // For loading legacy MaterialItems
2828
#include "nameidmapping.h" // For loading legacy MaterialItems
2929
#include "util/serialize.h"
@@ -218,7 +218,7 @@ void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
218218
Strfnd fnd(all);
219219
fnd.next("\"");
220220
// If didn't skip to end, we have ""s
221-
if(!fnd.atend()){
221+
if(!fnd.at_end()){
222222
name = fnd.next("\"");
223223
} else { // No luck, just read a word then
224224
fnd.start(all);
@@ -246,7 +246,7 @@ void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
246246
Strfnd fnd(all);
247247
fnd.next("\"");
248248
// If didn't skip to end, we have ""s
249-
if(!fnd.atend()){
249+
if(!fnd.at_end()){
250250
name = fnd.next("\"");
251251
} else { // No luck, just read a word then
252252
fnd.start(all);

src/inventorymanager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2525
#include "settings.h"
2626
#include "craftdef.h"
2727
#include "rollback_interface.h"
28-
#include "strfnd.h"
28+
#include "util/strfnd.h"
2929

3030
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
3131

src/mods.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2121
#include <fstream>
2222
#include "mods.h"
2323
#include "filesys.h"
24-
#include "strfnd.h"
24+
#include "util/strfnd.h"
2525
#include "log.h"
2626
#include "subgame.h"
2727
#include "settings.h"
28-
#include "strfnd.h"
28+
#include "util/strfnd.h"
2929
#include "convert_json.h"
3030
#include "exceptions.h"
3131

src/network/clientpackethandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2828
#include "nodedef.h"
2929
#include "serialization.h"
3030
#include "server.h"
31-
#include "strfnd.h"
31+
#include "util/strfnd.h"
3232
#include "network/clientopcodes.h"
3333
#include "util/serialize.h"
3434
#include "util/srp.h"
@@ -641,7 +641,7 @@ void Client::handleCommand_AnnounceMedia(NetworkPacket* pkt)
641641
*pkt >> str;
642642

643643
Strfnd sf(str);
644-
while(!sf.atend()) {
644+
while(!sf.at_end()) {
645645
std::string baseurl = trim(sf.next(","));
646646
if (baseurl != "")
647647
m_media_downloader->addRemoteServer(baseurl);

src/settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2121
#include "irrlichttypes_bloated.h"
2222
#include "exceptions.h"
2323
#include "threading/mutex_auto_lock.h"
24-
#include "strfnd.h"
24+
#include "util/strfnd.h"
2525
#include <iostream>
2626
#include <fstream>
2727
#include <sstream>

0 commit comments

Comments
 (0)