diff options
author | simonb <simonb> | 2006-06-27 08:54:24 (GMT) |
---|---|---|
committer | simonb <simonb> | 2006-06-27 08:54:24 (GMT) |
commit | 6dc5ca4e60b80a1d900f87a4e70954cd29cfcee4 (patch) | |
tree | 772fa725f48f376a627670ded338a78363302dd9 /src | |
parent | b79d7ee745256eb14d664dcc1a6dac8520c9f490 (diff) | |
download | fluxbox_paul-6dc5ca4e60b80a1d900f87a4e70954cd29cfcee4.zip fluxbox_paul-6dc5ca4e60b80a1d900f87a4e70954cd29cfcee4.tar.bz2 |
some minor code cleanups thanks Slava Semushin (php-coder), who also thanks Mikhail Gusarov
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/StringUtil.cc | 12 | ||||
-rw-r--r-- | src/FbTk/StringUtil.hh | 1 | ||||
-rw-r--r-- | src/Remember.cc | 26 |
3 files changed, 11 insertions, 28 deletions
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index 1a6814c..11bd87d 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc | |||
@@ -58,18 +58,6 @@ namespace FbTk { | |||
58 | namespace StringUtil { | 58 | namespace StringUtil { |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Takes a pointer to string *s as an argument, | ||
62 | creates a new string n, copies s to n and | ||
63 | returns a pointer to n. | ||
64 | */ | ||
65 | char *strdup(const char *s) { | ||
66 | int l = strlen(s) + 1; | ||
67 | char *n = new char[l]; | ||
68 | strncpy(n, s, l); | ||
69 | return n; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | Tries to find a string in another and | 61 | Tries to find a string in another and |
74 | ignoring the case of the characters | 62 | ignoring the case of the characters |
75 | Returns 0 on success else pointer to str. | 63 | Returns 0 on success else pointer to str. |
diff --git a/src/FbTk/StringUtil.hh b/src/FbTk/StringUtil.hh index c9f6818..b45d6a2 100644 --- a/src/FbTk/StringUtil.hh +++ b/src/FbTk/StringUtil.hh | |||
@@ -30,7 +30,6 @@ namespace FbTk { | |||
30 | 30 | ||
31 | namespace StringUtil { | 31 | namespace StringUtil { |
32 | 32 | ||
33 | char *strdup(const char *); | ||
34 | 33 | ||
35 | /// Similar to `strstr' but this function ignores the case of both strings | 34 | /// Similar to `strstr' but this function ignores the case of both strings |
36 | const char *strcasestr(const char *str, const char *ptn); | 35 | const char *strcasestr(const char *str, const char *ptn); |
diff --git a/src/Remember.cc b/src/Remember.cc index 99a0d1d..eace6bc 100644 --- a/src/Remember.cc +++ b/src/Remember.cc | |||
@@ -61,7 +61,7 @@ using namespace std; | |||
61 | namespace { | 61 | namespace { |
62 | 62 | ||
63 | bool getuint(const char *val, unsigned int &ret) { | 63 | bool getuint(const char *val, unsigned int &ret) { |
64 | return (sscanf(val, "%ui", &ret) == 1); | 64 | return (sscanf(val, "%u", &ret) == 1); |
65 | } | 65 | } |
66 | 66 | ||
67 | class RememberMenuItem : public FbTk::MenuItem { | 67 | class RememberMenuItem : public FbTk::MenuItem { |
@@ -263,9 +263,8 @@ Remember::~Remember() { | |||
263 | } | 263 | } |
264 | 264 | ||
265 | std::set<Application *>::iterator ait = all_apps.begin(); // no duplicates | 265 | std::set<Application *>::iterator ait = all_apps.begin(); // no duplicates |
266 | while (ait != all_apps.end()) { | 266 | for (; ait != all_apps.end(); ++ait) { |
267 | delete (*ait); | 267 | delete (*ait); |
268 | ++ait; | ||
269 | } | 268 | } |
270 | 269 | ||
271 | s_instance = 0; | 270 | s_instance = 0; |
@@ -380,7 +379,7 @@ int Remember::parseApp(std::ifstream &file, Application &app, std::string *first | |||
380 | app.rememberLayer(l); | 379 | app.rememberLayer(l); |
381 | } else if (strcasecmp(str_key.c_str(), "Dimensions") == 0) { | 380 | } else if (strcasecmp(str_key.c_str(), "Dimensions") == 0) { |
382 | unsigned int h,w; | 381 | unsigned int h,w; |
383 | if (sscanf(str_label.c_str(), "%i %i", &w, &h) == 2) | 382 | if (sscanf(str_label.c_str(), "%u %u", &w, &h) == 2) |
384 | app.rememberDimensions(w, h); | 383 | app.rememberDimensions(w, h); |
385 | else | 384 | else |
386 | had_error = true; | 385 | had_error = true; |
@@ -404,7 +403,7 @@ int Remember::parseApp(std::ifstream &file, Application &app, std::string *first | |||
404 | } | 403 | } |
405 | } | 404 | } |
406 | 405 | ||
407 | if (!had_error && sscanf(str_label.c_str(), "%i %i", &x, &y) == 2) | 406 | if (!had_error && sscanf(str_label.c_str(), "%u %u", &x, &y) == 2) |
408 | app.rememberPosition(x, y, r); | 407 | app.rememberPosition(x, y, r); |
409 | else | 408 | else |
410 | had_error = true; | 409 | had_error = true; |
@@ -501,12 +500,11 @@ Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlis | |||
501 | } | 500 | } |
502 | 501 | ||
503 | // forward | 502 | // forward |
504 | while (it != it_end && it->second == ret) { | 503 | for(; it != it_end && it->second == ret; ++it) { |
505 | tmpit = it; | 504 | delete it->first; |
506 | ++it; | ||
507 | delete tmpit->first; | ||
508 | patlist->erase(tmpit); | ||
509 | } | 505 | } |
506 | patlist->erase(patlist->begin(), it); | ||
507 | |||
510 | return ret; | 508 | return ret; |
511 | } | 509 | } |
512 | } | 510 | } |
@@ -643,9 +641,8 @@ void Remember::reconfigure() { | |||
643 | } | 641 | } |
644 | 642 | ||
645 | std::set<Application *>::iterator ait = old_apps.begin(); // no duplicates | 643 | std::set<Application *>::iterator ait = old_apps.begin(); // no duplicates |
646 | while (ait != old_apps.end()) { | 644 | for (; ait != old_apps.end(); ++ait) { |
647 | delete (*ait); | 645 | delete (*ait); |
648 | ++ait; | ||
649 | } | 646 | } |
650 | 647 | ||
651 | delete old_pats; | 648 | delete old_pats; |
@@ -1062,7 +1059,7 @@ void Remember::updateClientClose(WinClient &winclient) { | |||
1062 | 1059 | ||
1063 | if (app && (app->save_on_close_remember && app->save_on_close)) { | 1060 | if (app && (app->save_on_close_remember && app->save_on_close)) { |
1064 | 1061 | ||
1065 | for (int attrib = 0; attrib <= REM_LASTATTRIB; attrib++) { | 1062 | for (int attrib = 0; attrib < REM_LASTATTRIB; attrib++) { |
1066 | if (isRemembered(winclient, (Attribute) attrib)) { | 1063 | if (isRemembered(winclient, (Attribute) attrib)) { |
1067 | rememberAttrib(winclient, (Attribute) attrib); | 1064 | rememberAttrib(winclient, (Attribute) attrib); |
1068 | } | 1065 | } |
@@ -1091,9 +1088,8 @@ void Remember::initForScreen(BScreen &screen) { | |||
1091 | void Remember::updateFrameClose(FluxboxWindow &win) { | 1088 | void Remember::updateFrameClose(FluxboxWindow &win) { |
1092 | // scan all applications and remove this fbw if it is a recorded group | 1089 | // scan all applications and remove this fbw if it is a recorded group |
1093 | Patterns::iterator it = m_pats->begin(); | 1090 | Patterns::iterator it = m_pats->begin(); |
1094 | while (it != m_pats->end()) { | 1091 | for (; it != m_pats->end(); ++it) { |
1095 | if (&win == it->second->group) | 1092 | if (&win == it->second->group) |
1096 | it->second->group = 0; | 1093 | it->second->group = 0; |
1097 | ++it; | ||
1098 | } | 1094 | } |
1099 | } | 1095 | } |