Use strlower() instead of tolower() and strcasecmp() where possible.
This commit is contained in:
parent
df9a03f416
commit
326d609675
@ -9,6 +9,7 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
class ColorTable : public std::map<std::string, Color>
|
class ColorTable : public std::map<std::string, Color>
|
||||||
{
|
{
|
||||||
@ -57,9 +58,7 @@ Color::Color(std::string color, int alpha)
|
|||||||
colormod = color.substr(pos);
|
colormod = color.substr(pos);
|
||||||
do {
|
do {
|
||||||
if (basecolor[0] != '#') {
|
if (basecolor[0] != '#') {
|
||||||
int l = basecolor.length();
|
basecolor = strlower(basecolor);
|
||||||
for (int i = 0; i < l; i++)
|
|
||||||
basecolor[i] = tolower(basecolor[i]);
|
|
||||||
if (colorTable.count(basecolor) > 0) {
|
if (colorTable.count(basecolor) > 0) {
|
||||||
*this = colorTable[basecolor];
|
*this = colorTable[basecolor];
|
||||||
break;
|
break;
|
||||||
|
18
mapper.cpp
18
mapper.cpp
@ -22,6 +22,7 @@
|
|||||||
#include "TileGenerator.h"
|
#include "TileGenerator.h"
|
||||||
#include "PixelAttributes.h"
|
#include "PixelAttributes.h"
|
||||||
#include "db-postgresql.h"
|
#include "db-postgresql.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -218,8 +219,7 @@ void parseDataFile(TileGenerator &generator, const string &input, string dataFil
|
|||||||
size_t binpos = executablePath.find_last_of(PATH_SEPARATOR);
|
size_t binpos = executablePath.find_last_of(PATH_SEPARATOR);
|
||||||
if (binpos != string::npos) {
|
if (binpos != string::npos) {
|
||||||
string lastDir = executablePath.substr(binpos + 1);
|
string lastDir = executablePath.substr(binpos + 1);
|
||||||
for (size_t i=0; i < lastDir.size(); i++)
|
lastDir = strlower(lastDir);
|
||||||
lastDir[i] = tolower(lastDir[i]);
|
|
||||||
if (lastDir == "bin") {
|
if (lastDir == "bin") {
|
||||||
colorPaths.push_back(executablePath.substr(0, binpos) + PATH_SEPARATOR + "colors");
|
colorPaths.push_back(executablePath.substr(0, binpos) + PATH_SEPARATOR + "colors");
|
||||||
colorPaths.push_back(executablePath.substr(0, binpos));
|
colorPaths.push_back(executablePath.substr(0, binpos));
|
||||||
@ -769,10 +769,7 @@ int main(int argc, char *argv[])
|
|||||||
heightMap = true;
|
heightMap = true;
|
||||||
if (optarg && *optarg) {
|
if (optarg && *optarg) {
|
||||||
loadHeightMapColorsFile = false;
|
loadHeightMapColorsFile = false;
|
||||||
std::string color = optarg;
|
std::string color = strlower(optarg);
|
||||||
int l = color.length();
|
|
||||||
for (int i = 0; i < l; i++)
|
|
||||||
color[i] = tolower(color[i]);
|
|
||||||
if (color == "grey" || color == "gray")
|
if (color == "grey" || color == "gray")
|
||||||
generator.setHeightMapColor(Color(0, 0, 0), Color(255, 255, 255));
|
generator.setHeightMapColor(Color(0, 0, 0), Color(255, 255, 255));
|
||||||
else if (color == "black")
|
else if (color == "black")
|
||||||
@ -832,13 +829,14 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
if (optarg && *optarg) {
|
if (optarg && *optarg) {
|
||||||
if (0 == strcasecmp(optarg,"left"))
|
std::string opt = strlower(optarg);
|
||||||
|
if (opt == "left")
|
||||||
generator.setDrawScale(DRAWSCALE_LEFT);
|
generator.setDrawScale(DRAWSCALE_LEFT);
|
||||||
else if (0 == strcasecmp(optarg,"top"))
|
else if (opt == "top")
|
||||||
generator.setDrawScale(DRAWSCALE_TOP);
|
generator.setDrawScale(DRAWSCALE_TOP);
|
||||||
else if (0 == strcasecmp(optarg,"left,top"))
|
else if (opt == "left,top")
|
||||||
generator.setDrawScale(DRAWSCALE_LEFT | DRAWSCALE_TOP);
|
generator.setDrawScale(DRAWSCALE_LEFT | DRAWSCALE_TOP);
|
||||||
else if (0 == strcasecmp(optarg,"top,left"))
|
else if (opt == "top,left")
|
||||||
generator.setDrawScale(DRAWSCALE_LEFT | DRAWSCALE_TOP);
|
generator.setDrawScale(DRAWSCALE_LEFT | DRAWSCALE_TOP);
|
||||||
else {
|
else {
|
||||||
std::cerr << "Invalid parameter to '" << long_options[option_index].name
|
std::cerr << "Invalid parameter to '" << long_options[option_index].name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user