diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-12 18:39:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-12 18:39:00 +0300 |
commit | 351821c1f18f9285be58df0a05339936311f6490 (patch) | |
tree | 47a60cad4f61f63c5ac2faf98dcae24760d7fe11 /src/utils | |
parent | e50632a83a3c679cffd372656277a304d5d853f8 (diff) | |
download | manaplus-351821c1f18f9285be58df0a05339936311f6490.tar.gz manaplus-351821c1f18f9285be58df0a05339936311f6490.tar.bz2 manaplus-351821c1f18f9285be58df0a05339936311f6490.tar.xz manaplus-351821c1f18f9285be58df0a05339936311f6490.zip |
first part of style fixed after cpplint checks.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/copynpaste.cpp | 29 | ||||
-rw-r--r-- | src/utils/paths.cpp | 2 | ||||
-rw-r--r-- | src/utils/perfomance.cpp | 3 | ||||
-rw-r--r-- | src/utils/physfstools.cpp | 2 | ||||
-rw-r--r-- | src/utils/process.cpp | 18 | ||||
-rw-r--r-- | src/utils/stringutils.cpp | 2 | ||||
-rw-r--r-- | src/utils/xml.cpp | 4 |
7 files changed, 20 insertions, 40 deletions
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index da3d40afb..22867e29c 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -146,10 +146,6 @@ bool getDataFromPasteboard(PasteboardRef inPasteboard, ItemCount itemCount; syncFlags = PasteboardSynchronize(inPasteboard); - - //require_action( syncFlags & kPasteboardModified, PasteboardOutOfSync, - // err = badPasteboardSyncErr ); - OSStatus err = PasteboardGetItemCount(inPasteboard, &itemCount); require_noerr(err, CantGetPasteboardItemCount); @@ -204,7 +200,7 @@ bool getDataFromPasteboard(PasteboardRef inPasteboard, flavorText[flavorDataSize] = '\0'; flavorText[flavorDataSize + 1] = '\n'; - CFRelease (flavorData); + CFRelease(flavorData); return true; } @@ -213,7 +209,7 @@ CantCopyFlavorData: fprintf(stderr, "Cannot copy clipboard, CantCopyFlavorData!\n"); } - CFRelease (flavorTypeArray); + CFRelease(flavorTypeArray); continue; CantCopyPasteboardItemFlavors: @@ -237,7 +233,7 @@ CantGetPasteboardItemCount: // return false; } -bool getClipBoard(char* text /* out */, const int bufSize) +bool getClipBoard(char* text /* out */, const int bufSize) { PasteboardRef theClipboard; OSStatus err = PasteboardCreate(kPasteboardClipboard, &theClipboard); @@ -294,12 +290,9 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, Window owner = XGetSelectionOwner(dpy, selection); int ret; - //printf("XConvertSelection on %s\n", XGetAtomName(dpy, selection)); if (owner == None) - { - //printf("No owner\n"); return nullptr; - } + XConvertSelection(dpy, selection, request_target, XA_PRIMARY, us, CurrentTime); XFlush(dpy); @@ -311,14 +304,8 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, XNextEvent(dpy, &e); if (e.type == SelectionNotify) { -// printf("Received %s, %s, %s\n", XGetAtomName(dpy, selection), -// XGetAtomName(dpy, e.xselection.selection), -// XGetAtomName(dpy, request_target)); if (e.xselection.property == None) - { - //printf("Couldn't convert\n"); return nullptr; - } long unsigned len, left, dummy; int format; @@ -339,13 +326,8 @@ static char* getSelection2(Display *dpy, Window us, Atom selection, &dummy, &data); if (ret != Success) - { - //printf("Failed to get property: %p on %lu\n", data, len); return nullptr; - } - //printf(">>> Got %s: len=%lu left=%lu (event %i)\n", data, - // len, left, 50-max_events); return reinterpret_cast<char*>(data); } } @@ -368,7 +350,6 @@ bool retrieveBuffer(std::string& text, size_t& pos) { SDL_SysWMinfo info; - //printf("Retrieving buffer...\n"); SDL_VERSION(&info.version); if (SDL_GetWMInfo(&info)) { @@ -376,7 +357,7 @@ bool retrieveBuffer(std::string& text, size_t& pos) Window us = info.info.x11.window; char *data = nullptr; - requestAtom = XInternAtom (dpy, "UTF8_STRING", true); + requestAtom = XInternAtom(dpy, "UTF8_STRING", true); if (!data) data = getSelection(dpy, us, XA_PRIMARY); diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index f9c5cc5a8..4c0637bd5 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -48,7 +48,7 @@ std::string getRealPath(const std::string &str) { std::string path; #if defined(__OpenBSD__) || defined(__ANDROID__) - char *realPath = (char*)calloc(PATH_MAX, sizeof(char)); + char *realPath = reinterpret_cast<char*>(calloc(PATH_MAX, sizeof(char))); realpath(str.c_str(), realPath); #else char *realPath = realpath(str.c_str(), nullptr); diff --git a/src/utils/perfomance.cpp b/src/utils/perfomance.cpp index c73b271c0..6f4d128cc 100644 --- a/src/utils/perfomance.cpp +++ b/src/utils/perfomance.cpp @@ -36,7 +36,6 @@ #include "debug.h" -//static const clockid_t clockType = CLOCK_PROCESS_CPUTIME_ID; static const clockid_t clockType = CLOCK_MONOTONIC; #define timeData ((static_cast<long long int>(time.tv_sec) * 1000000000LL \ @@ -81,6 +80,6 @@ namespace Perfomance clock_gettime(clockType, &time); file << (timeData - startTime) << " end: " << name << std::endl; } -} +} // namespace Perfomance #endif diff --git a/src/utils/physfstools.cpp b/src/utils/physfstools.cpp index 1fcb8fb1b..93f677ca0 100644 --- a/src/utils/physfstools.cpp +++ b/src/utils/physfstools.cpp @@ -105,4 +105,4 @@ namespace PhysFs { return PHYSFS_mkdir(dirname); } -} +} // namespace PhysFs diff --git a/src/utils/process.cpp b/src/utils/process.cpp index 538d7274e..ec9eea548 100644 --- a/src/utils/process.cpp +++ b/src/utils/process.cpp @@ -49,15 +49,15 @@ int execFileWait(std::string pathName, std::string name A_UNUSED, PROCESS_INFORMATION piProcessInfo; memset(&siStartupInfo, 0, sizeof(siStartupInfo)); memset(&piProcessInfo, 0, sizeof(piProcessInfo)); - siStartupInfo.cb = sizeof(siStartupInfo); + siStartupInfo.cb = sizeof(siStartupInfo); DWORD ret = -1; std::string args(std::string(pathName).append(" ").append(arg1)); if (!arg2.empty()) args.append(" ").append(arg2); - if (CreateProcess(pathName.c_str(), (char*)args.c_str(), nullptr, nullptr, - false, CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr, &siStartupInfo, - &piProcessInfo) != false) + if (CreateProcess(pathName.c_str(), static_cast<char*>(args.c_str()), + nullptr, nullptr, false, CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr, + &siStartupInfo, &piProcessInfo) != false) { if (!WaitForSingleObject(piProcessInfo.hProcess, timeOut * 1000)) { @@ -83,7 +83,7 @@ bool execFile(std::string pathName, std::string name A_UNUSED, PROCESS_INFORMATION piProcessInfo; memset(&siStartupInfo, 0, sizeof(siStartupInfo)); memset(&piProcessInfo, 0, sizeof(piProcessInfo)); - siStartupInfo.cb = sizeof(siStartupInfo); + siStartupInfo.cb = sizeof(siStartupInfo); std::string args(std::string(pathName).append(" ").append(arg1)); if (!arg2.empty()) args.append(" ").append(arg2); @@ -149,8 +149,7 @@ int execFileWait(std::string pathName, std::string name, } else if (!sleep_pid) { // sleep pid - sleep (waitTime); -// printf ("time out\n"); + sleep(waitTime); execl("/bin/true", "/bin/true", static_cast<char *>(nullptr)); _exit(-1); } @@ -232,8 +231,9 @@ bool execFile(std::string pathName, std::string name, #ifdef WIN32 bool openBrowser(std::string url) { - return (int)ShellExecute(nullptr, "open", replaceAll(url, " ", "").c_str(), - nullptr, nullptr, SW_SHOWNORMAL) > 32; + return static_cast<int>(ShellExecute(nullptr, "open", + replaceAll(url, " ", "").c_str(), + nullptr, nullptr, SW_SHOWNORMAL)) > 32; } #elif defined ANDROID #include <SDL_screenkeyboard.h> diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index bd95ec2d7..dc85d8157 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -644,7 +644,7 @@ std::string getDateString() time_t rawtime; struct tm *timeinfo; - time (&rawtime); + time(&rawtime); timeinfo = localtime(&rawtime); strftime(buffer, 79, "%Y-%m-%d", timeinfo); diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 1d26f0388..b090df6d9 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -61,7 +61,7 @@ namespace XML if (file.is_open()) { // Get length of file - file.seekg (0, std::ios::end); + file.seekg(0, std::ios::end); size = static_cast<int>(file.tellg()); file.seekg(0, std::ios::beg); @@ -218,4 +218,4 @@ namespace XML xmlCleanupParser(); } -} // namespace XML +} // namespace XML |