summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonb <simonb>2006-06-27 08:54:24 (GMT)
committersimonb <simonb>2006-06-27 08:54:24 (GMT)
commit6dc5ca4e60b80a1d900f87a4e70954cd29cfcee4 (patch)
tree772fa725f48f376a627670ded338a78363302dd9
parentb79d7ee745256eb14d664dcc1a6dac8520c9f490 (diff)
downloadfluxbox_lack-6dc5ca4e60b80a1d900f87a4e70954cd29cfcee4.zip
fluxbox_lack-6dc5ca4e60b80a1d900f87a4e70954cd29cfcee4.tar.bz2
some minor code cleanups thanks Slava Semushin (php-coder), who also thanks Mikhail Gusarov
-rw-r--r--ChangeLog2
-rw-r--r--src/FbTk/StringUtil.cc12
-rw-r--r--src/FbTk/StringUtil.hh1
-rw-r--r--src/Remember.cc26
4 files changed, 13 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index c19e33b..8f7b251 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.0rc2: 2Changes for 1.0rc2:
3*06/06/27: 3*06/06/27:
4 * Some minor cleaning (thanks Slava Semushin + Mikhail Gusarov)
5 FbTk/StringUtil.hh/cc Remember.cc
4 * Fix slit menu so it closes when you press escape (Mark) 6 * Fix slit menu so it closes when you press escape (Mark)
5 Slit.cc 7 Slit.cc
6*06/06/26: 8*06/06/26:
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 {
58namespace StringUtil { 58namespace 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*/
65char *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
31namespace StringUtil { 31namespace StringUtil {
32 32
33char *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
36const char *strcasestr(const char *str, const char *ptn); 35const 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;
61namespace { 61namespace {
62 62
63bool getuint(const char *val, unsigned int &ret) { 63bool 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
67class RememberMenuItem : public FbTk::MenuItem { 67class 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) {
1091void Remember::updateFrameClose(FluxboxWindow &win) { 1088void 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}