use empty to check string

This commit is contained in:
Jacek Jendrzej
2015-01-09 17:15:11 +01:00
parent aea7e1f772
commit 2b5e7b5ba3
34 changed files with 170 additions and 170 deletions

View File

@@ -54,7 +54,7 @@ CyParser::~CyParser(void) {
}
//-----------------------------------------------------------------------------
void CyParser::init(CyhookHandler *hh) {
if (HTML_DIRS[0] == "") {
if (HTML_DIRS[0].empty()) {
CyParser::HTML_DIRS[0] = hh->WebserverConfigList["WebsiteMain.override_directory"];
HTML_DIRS[1] = hh->WebserverConfigList["WebsiteMain.directory"];
PLUGIN_DIRS[0]=PLUGIN_DIRS[1] = HTML_DIRS[0];
@@ -133,10 +133,10 @@ void CyParser::Execute(CyhookHandler *hh) {
}
// send header
if (std::string(yCgiCallList[index].mime_type) == "") // set by self
if (std::string(yCgiCallList[index].mime_type).empty()) // set by self
;
else if (std::string(yCgiCallList[index].mime_type) == "+xml") // Parameter xml?
if (hh->ParamList["xml"] != "")
if (!hh->ParamList["xml"].empty())
hh->SetHeader(HTTP_OK, "text/xml");
else
hh->SetHeader(HTTP_OK, "text/plain");
@@ -162,22 +162,22 @@ void CyParser::cgi(CyhookHandler *hh) {
std::string htmlfilename, yresult, ycmd;
if ( !hh->ParamList.empty() ) {
if (hh->ParamList["tmpl"] != "") // for GET and POST
if (!hh->ParamList["tmpl"].empty()) // for GET and POST
htmlfilename = hh->ParamList["tmpl"];
else
htmlfilename = hh->ParamList["1"];
bool ydebug = false;
if (hh->ParamList["debug"] != "") // switch debug on
if (!hh->ParamList["debug"].empty()) // switch debug on
ydebug = true;
if (hh->ParamList["execute"] != "") // execute done first!
if (!hh->ParamList["execute"].empty()) // execute done first!
{
ycmd = hh->ParamList["execute"];
ycmd = YPARSER_ESCAPE_START + ycmd + YPARSER_ESCAPE_END;
yresult = cgi_cmd_parsing(hh, ycmd, ydebug); // parsing engine
}
// parsing given file
if (htmlfilename != "")
if (!htmlfilename.empty())
yresult = cgi_file_parsing(hh, htmlfilename, ydebug);
} else
printf("[CyParser] Y-cgi:no parameter given\n");
@@ -237,9 +237,9 @@ void CyParser::ParseAndSendFile(CyhookHandler *hh) {
hh->SetHeader(HTTP_OK, "text/html; charset=UTF-8");
if (hh->Method == M_HEAD)
return;
if (hh->ParamList["debug"] != "") // switch debug on
if (!hh->ParamList["debug"].empty()) // switch debug on
ydebug = true;
if (hh->ParamList["execute"] != "") // execute done first!
if (!hh->ParamList["execute"].empty()) // execute done first!
{
ycmd = hh->ParamList["execute"];
ycmd = YPARSER_ESCAPE_START + ycmd + YPARSER_ESCAPE_END;
@@ -391,7 +391,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) {
else if (ycmd_type == "comment") {
std::string comment_y, comment_html;
if (ySplitString(ycmd_name, "~", comment_y, comment_html)) {
if (comment_html != "")
if (!comment_html.empty())
yresult = "<!-- " + comment_html + " -->";
}
} else if (ycmd_type == "script")
@@ -400,7 +400,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) {
std::string if_value, if_then, if_else;
if (ySplitString(ycmd_name, "~", if_value, if_then)) {
ySplitString(if_then, "~", if_then, if_else);
yresult = (if_value == "") ? if_then : if_else;
yresult = (if_value.empty()) ? if_then : if_else;
}
} else if (ycmd_type == "if-equal") {
std::string if_left_value, if_right_value, if_then, if_else;
@@ -451,7 +451,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) {
if (ySplitString(filename, ";", filename, tmp)) {
ySplitString(tmp, ";", varname, ydefault);
yresult = YWeb_cgi_get_ini(hh, filename, varname, yaccess);
if (yresult == "" && ydefault != "")
if (yresult.empty() && !ydefault.empty())
yresult = ydefault;
} else
yresult = "ycgi: ini-get: no ; found";
@@ -501,7 +501,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) {
}
} else
yresult = "ycgi-type unknown";
} else if (hh->ParamList[ycmd] != "") {
} else if (!hh->ParamList[ycmd].empty()) {
if ((hh->ParamList[ycmd]).find("script") == std::string::npos)
yresult = hh->ParamList[ycmd];
else
@@ -518,7 +518,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) {
std::string CyParser::YWeb_cgi_get_ini(CyhookHandler *, std::string filename,
std::string varname, std::string yaccess) {
std::string result;
if ((yaccess == "open") || (yaccess == "")) {
if ((yaccess == "open") || (yaccess.empty())) {
yConfig->clear();
yConfig->loadConfig(filename);
}
@@ -532,12 +532,12 @@ std::string CyParser::YWeb_cgi_get_ini(CyhookHandler *, std::string filename,
//-------------------------------------------------------------------------
void CyParser::YWeb_cgi_set_ini(CyhookHandler *, std::string filename,
std::string varname, std::string varvalue, std::string yaccess) {
if ((yaccess == "open") || (yaccess == "")) {
if ((yaccess == "open") || (yaccess.empty())) {
yConfig->clear();
yConfig->loadConfig(filename);
}
yConfig->setString(varname, varvalue);
if ((yaccess == "save") || (yaccess == ""))
if ((yaccess == "save") || (yaccess.empty()))
yConfig->saveConfig(filename);
}
@@ -732,7 +732,7 @@ std::string CyParser::func_do_reload_httpd_config(CyhookHandler *, std::string)
// y-func : Change httpd (process image) on the fly
//-------------------------------------------------------------------------
std::string CyParser::func_change_httpd(CyhookHandler *hh, std::string para) {
if (para != "" && access(para, R_OK) == 0) {
if (!para.empty() && access(para, R_OK) == 0) {
hh->status = HANDLED_ABORT;
char * argv[2] = { (char *)para.c_str(), NULL };
int err = execvp(argv[0], argv); // no return if successful
@@ -771,7 +771,7 @@ std::string CyParser::func_get_languages_as_dropdown(CyhookHandler *,
// y-func : get_header_data
//-------------------------------------------------------------------------
std::string CyParser::func_set_language(CyhookHandler *, std::string para) {
if (para != "") {
if (!para.empty()) {
CConfigFile *Config = new CConfigFile(',');
Config->loadConfig(HTTPD_CONFIGFILE);
Config->setString("Language.selected", para);