Skip to content
Permalink
Browse files

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.
  • Loading branch information
ShadowNinja committed Mar 19, 2016
1 parent eb7db21 commit 93887043d9443ba6627fea68921994d0f1896517
@@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "threading/mutex_auto_lock.h"
#include <sstream>
#include <set>
#include "strfnd.h"
#include "util/strfnd.h"
#include "util/string.h"
#include "log.h"
#include "filesys.h"
@@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

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

// Note: A message may consist of multiple lines, for example the MOTD.
WStrfnd fnd(text);
while (!fnd.atend())
while (!fnd.at_end())
{
std::wstring line = fnd.next(L"\n");
m_console_buffer.addLine(name, line);
@@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mesh.h"
#include "log.h"
#include "gamedef.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include "util/string.h" // for parseColorString()
#include "imagefilters.h"
#include "guiscalingfilter.h"
@@ -1242,7 +1242,7 @@ bool TextureSource::generateImagePart(std::string part_of_name,
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
baseimg->fill(video::SColor(0,0,0,0));
}
while (sf.atend() == false) {
while (sf.at_end() == false) {
u32 x = stoi(sf.next(","));
u32 y = stoi(sf.next("="));
std::string filename = sf.next(":");
@@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/serialize.h"
#include "util/string.h"
#include "util/numeric.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include "exceptions.h"

inline bool isGroupRecipeStr(const std::string &rec_name)
@@ -90,7 +90,7 @@ static bool inputItemMatchesRecipe(const std::string &inp_name,
all_groups_match = false;
break;
}
} while (!f.atend());
} while (!f.at_end());
if (all_groups_match)
return true;
}
@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "constants.h"
#include "gamedef.h"
#include "keycode.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
@@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sstream>
#include "log.h"
#include "itemdef.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include "content_mapnode.h" // For loading legacy MaterialItems
#include "nameidmapping.h" // For loading legacy MaterialItems
#include "util/serialize.h"
@@ -218,7 +218,7 @@ void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
Strfnd fnd(all);
fnd.next("\"");
// If didn't skip to end, we have ""s
if(!fnd.atend()){
if(!fnd.at_end()){
name = fnd.next("\"");
} else { // No luck, just read a word then
fnd.start(all);
@@ -246,7 +246,7 @@ void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
Strfnd fnd(all);
fnd.next("\"");
// If didn't skip to end, we have ""s
if(!fnd.atend()){
if(!fnd.at_end()){
name = fnd.next("\"");
} else { // No luck, just read a word then
fnd.start(all);
@@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "craftdef.h"
#include "rollback_interface.h"
#include "strfnd.h"
#include "util/strfnd.h"

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

@@ -21,11 +21,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <fstream>
#include "mods.h"
#include "filesys.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include "log.h"
#include "subgame.h"
#include "settings.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include "convert_json.h"
#include "exceptions.h"

@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h"
#include "serialization.h"
#include "server.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include "network/clientopcodes.h"
#include "util/serialize.h"
#include "util/srp.h"
@@ -641,7 +641,7 @@ void Client::handleCommand_AnnounceMedia(NetworkPacket* pkt)
*pkt >> str;

Strfnd sf(str);
while(!sf.atend()) {
while(!sf.at_end()) {
std::string baseurl = trim(sf.next(","));
if (baseurl != "")
m_media_downloader->addRemoteServer(baseurl);
@@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes_bloated.h"
#include "exceptions.h"
#include "threading/mutex_auto_lock.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include <iostream>
#include <fstream>
#include <sstream>
@@ -35,7 +35,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "EShaderTypes.h"
#include "log.h"
#include "gamedef.h"
#include "strfnd.h" // trim()
#include "client/tile.h"

/*

This file was deleted.

@@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "settings.h"
#include "log.h"
#include "strfnd.h"
#include "util/strfnd.h"
#include "defaultsettings.h" // for override_default_settings
#include "mapgen.h" // for MapgenParams
#include "util/string.h"
@@ -79,7 +79,7 @@ SubgameSpec findSubgame(const std::string &id)

Strfnd search_paths(getSubgamePathEnv());

while (!search_paths.atend()) {
while (!search_paths.at_end()) {
std::string path = search_paths.next(PATH_DELIM);
find_paths.push_back(GameFindPath(
path + DIR_DELIM + id, false));
@@ -153,7 +153,7 @@ std::set<std::string> getAvailableGameIds()

Strfnd search_paths(getSubgamePathEnv());

while (!search_paths.atend())
while (!search_paths.at_end())
gamespaths.insert(search_paths.next(PATH_DELIM));

for (std::set<std::string>::const_iterator i = gamespaths.begin();
@@ -230,7 +230,7 @@ std::vector<WorldSpec> getAvailableWorlds()

Strfnd search_paths(getWorldPathEnv());

while (!search_paths.atend())
while (!search_paths.at_end())
worldspaths.insert(search_paths.next(PATH_DELIM));

worldspaths.insert(porting::path_user + DIR_DELIM + "worlds");

0 comments on commit 9388704

Please sign in to comment.
You can’t perform that action at this time.