democlient.cpp: apply astyle

This commit is contained in:
XhmikosR 2012-09-15 16:32:59 +03:00 committed by Daniel Marjamäki
parent 2794d3dfd2
commit 2acda0854b
1 changed files with 22 additions and 30 deletions

View File

@ -7,25 +7,23 @@
static void unencode(const char *src, char *dest) static void unencode(const char *src, char *dest)
{ {
for(; *src; src++, dest++) { for (; *src; src++, dest++) {
if(*src == '+') if (*src == '+')
*dest = ' '; *dest = ' ';
else if(*src == '%') { else if (*src == '%') {
int code; int code;
if (sscanf(src+1, "%2x", &code) != 1) if (sscanf(src+1, "%2x", &code) != 1)
code = '?'; code = '?';
*dest = code; *dest = code;
src += 2; src += 2;
} } else
else
*dest = *src; *dest = *src;
} }
*dest = '\0'; *dest = '\0';
} }
class CppcheckExecutor : public ErrorLogger class CppcheckExecutor : public ErrorLogger {
{
private: private:
const std::time_t stoptime; const std::time_t stoptime;
CppCheck cppcheck; CppCheck cppcheck;
@ -34,14 +32,12 @@ public:
CppcheckExecutor() CppcheckExecutor()
: ErrorLogger() : ErrorLogger()
, stoptime(std::time(NULL)+2U) , stoptime(std::time(NULL)+2U)
, cppcheck(*this,false) , cppcheck(*this,false) {
{
cppcheck.settings().addEnabled("all"); cppcheck.settings().addEnabled("all");
cppcheck.settings().inconclusive = true; cppcheck.settings().inconclusive = true;
} }
void run(const char code[]) void run(const char code[]) {
{
printf("%s\n", ErrorLogger::ErrorMessage::getXMLHeader(2).c_str()); printf("%s\n", ErrorLogger::ErrorMessage::getXMLHeader(2).c_str());
cppcheck.check("test.c", code); cppcheck.check("test.c", code);
printf("%s\n", ErrorLogger::ErrorMessage::getXMLFooter(2).c_str()); printf("%s\n", ErrorLogger::ErrorMessage::getXMLFooter(2).c_str());
@ -49,8 +45,7 @@ public:
} }
void reportOut(const std::string &outmsg) { } void reportOut(const std::string &outmsg) { }
void reportErr(const ErrorLogger::ErrorMessage &msg) void reportErr(const ErrorLogger::ErrorMessage &msg) {
{
const std::string str(msg.toXML(true,2U)); const std::string str(msg.toXML(true,2U));
printf("%s\n", str.c_str()); printf("%s\n", str.c_str());
} }
@ -58,10 +53,8 @@ public:
void reportProgress(const void reportProgress(const
std::string &filename, std::string &filename,
const char stage[], const char stage[],
const unsigned int value) const unsigned int value) {
{ if (std::time(NULL) >= stoptime) {
if (std::time(NULL) >= stoptime)
{
printf("time to analyse the " printf("time to analyse the "
"code is more than 1 " "code is more than 1 "
"second. terminating." "second. terminating."
@ -89,4 +82,3 @@ int main()
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }