From 894a7148be8ac88f7f1e98917f33088ab301bf60 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 2 Apr 2006 21:37:44 +0000 Subject: size_t fixes, thanks Semushin Slava aka php-coder --- src/Container.cc | 17 ++++++++--------- src/FbTk/ImageControl.cc | 2 +- src/FbTk/Layer.hh | 2 +- src/FbTk/MacroCommand.cc | 2 +- src/FbTk/MacroCommand.hh | 2 +- src/FbTk/Menu.cc | 7 ++++--- src/FbTk/Menu.hh | 2 +- src/FbTk/MenuItem.cc | 4 ++-- src/FbTk/MultLayers.cc | 4 ++-- src/FbTk/StringUtil.cc | 2 +- src/FbTk/TextButton.cc | 2 +- src/Gnome.cc | 6 +++--- src/Keys.cc | 7 +++---- src/Keys.hh | 4 ++-- src/Resources.cc | 6 ++---- src/Screen.cc | 6 ++++-- src/Screen.hh | 2 +- src/Window.cc | 2 +- src/Workspace.cc | 2 +- src/WorkspaceCmd.cc | 2 +- src/fluxbox.cc | 4 ++-- 21 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/Container.cc b/src/Container.cc index 1a7ea34..6f811ef 100644 --- a/src/Container.cc +++ b/src/Container.cc @@ -127,7 +127,7 @@ void Container::insertItem(Item item, int pos) { void Container::moveItem(Item item, int movement) { int index = find(item); - const int size = m_item_list.size(); + const size_t size = m_item_list.size(); if (index < 0 || (movement % size) == 0) { return; @@ -286,7 +286,7 @@ void Container::setMaxTotalSize(unsigned int size) { // this is a bit of duplication from repositionItems // for when we are allowed to grow ourself Alignment align = alignment(); - unsigned int num_items = m_item_list.size(); + size_t num_items = m_item_list.size(); if (m_max_total_size && (align == RIGHT || align == LEFT) && num_items) { unsigned int max_width_per_client = maxWidthPerClient(); @@ -377,7 +377,7 @@ void Container::repositionItems() { unsigned int max_width_per_client = maxWidthPerClient(); unsigned int borderW = m_item_list.front()->borderWidth(); - unsigned int num_items = m_item_list.size(); + size_t num_items = m_item_list.size(); unsigned int total_width; unsigned int cur_width; @@ -480,18 +480,17 @@ unsigned int Container::maxWidthPerClient() const { return m_max_size_per_client; break; case RELATIVE: - int count = size(); - if (count == 0) + if (size() == 0) return width(); else { int borderW = m_item_list.front()->borderWidth(); // there're count-1 borders to fit in with the windows // -> 1 per window plus end unsigned int w = width(); - if (w < (count-1)*borderW) + if (w < (size()-1)*borderW) return 1; else - return (w - (count - 1) * borderW) / count; + return (w - (size() - 1) * borderW) / size(); } break; } @@ -502,8 +501,8 @@ unsigned int Container::maxWidthPerClient() const { void Container::for_each(std::mem_fun_t function) { std::for_each(m_item_list.begin(), - m_item_list.end(), - function); + m_item_list.end(), + function); } void Container::setAlpha(unsigned char alpha) { diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index 902bd55..7fe9154 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc @@ -258,7 +258,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height, cache.push_back(tmp); - if ((unsigned) cache.size() > cache_max) + if (cache.size() > cache_max) cleanCache(); return pixmap; diff --git a/src/FbTk/Layer.hh b/src/FbTk/Layer.hh index 3e206b2..5c0c566 100644 --- a/src/FbTk/Layer.hh +++ b/src/FbTk/Layer.hh @@ -59,7 +59,7 @@ public: /// @return layer item on specific position, on failure 0 ItemType *getItem(unsigned int position); /// @return number of elements in layer - unsigned int size() const { return m_list.size(); } + size_t size() const { return m_list.size(); } /// @return layer list const ListType &itemList() const { return m_list; } /// @return layer list diff --git a/src/FbTk/MacroCommand.cc b/src/FbTk/MacroCommand.cc index 84794e1..adee9cb 100644 --- a/src/FbTk/MacroCommand.cc +++ b/src/FbTk/MacroCommand.cc @@ -29,7 +29,7 @@ void MacroCommand::add(RefCount &com) { m_commandlist.push_back(com); } -unsigned int MacroCommand::size() const { +size_t MacroCommand::size() const { return m_commandlist.size(); } diff --git a/src/FbTk/MacroCommand.hh b/src/FbTk/MacroCommand.hh index 97cc5d5..f29e05c 100644 --- a/src/FbTk/MacroCommand.hh +++ b/src/FbTk/MacroCommand.hh @@ -35,7 +35,7 @@ namespace FbTk { class MacroCommand:public Command { public: void add(RefCount &com); - unsigned int size() const; + size_t size() const; virtual void execute(); private: diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 5687be1..0616906 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -577,13 +577,13 @@ void Menu::clearWindow() { menu.frame.clear(); // clear foreground bits of frame items - for (unsigned int i = 0; i < menuitems.size(); i++) { + for (size_t i = 0; i < menuitems.size(); i++) { clearItem(i, false); // no clear } } void Menu::redrawFrame(FbDrawable &drawable) { - for (unsigned int i = 0; i < menuitems.size(); i++) { + for (size_t i = 0; i < menuitems.size(); i++) { drawItem(drawable, i); } @@ -636,7 +636,8 @@ void Menu::redrawTitle(FbDrawable &drawable) { const char *text = menu.label.c_str(); const FbTk::Font &font = theme().titleFont(); - int dx = theme().bevelWidth(), len = menu.label.size(); + int dx = theme().bevelWidth(); + size_t len = menu.label.size(); unsigned int l = font.textWidth(text, len) + theme().bevelWidth()*2; switch (theme().titleFontJustify()) { diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index bec76ac..fceec67 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -147,7 +147,7 @@ public: inline int y() const { return menu.window.y(); } inline unsigned int width() const { return menu.window.width(); } inline unsigned int height() const { return menu.window.height(); } - inline unsigned int numberOfItems() const { return menuitems.size(); } + inline size_t numberOfItems() const { return menuitems.size(); } inline int currentSubmenu() const { return m_which_sub; } bool hasSubmenu(unsigned int index) const; bool isItemSelected(unsigned int index) const; diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index 93adc44..f39d03c 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -168,8 +168,8 @@ void MenuItem::draw(FbDrawable &draw, // disable clip mask XSetClipMask(disp, gc, None); } else if (isSelected()) { - draw.fillRectangle(theme.hiliteGC().gc(), - sel_x+item_pm_height/4, sel_y+item_pm_height/4, item_pm_height/2, item_pm_height/2); + draw.fillRectangle(theme.hiliteGC().gc(), + sel_x+item_pm_height/4, sel_y+item_pm_height/4, item_pm_height/2, item_pm_height/2); } } diff --git a/src/FbTk/MultLayers.cc b/src/FbTk/MultLayers.cc index 6a6dc18..439201a 100644 --- a/src/FbTk/MultLayers.cc +++ b/src/FbTk/MultLayers.cc @@ -180,8 +180,8 @@ void MultLayers::restack() { } int MultLayers::size() { - int i = 0, num = 0; - for (; i < static_cast(m_layers.size()); i++) { + int num = 0; + for (size_t i = 0; i < m_layers.size(); i++) { num += m_layers[i]->countWindows(); } return num; diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index d8b64c9..1a6814c 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc @@ -123,7 +123,7 @@ string findExtension(const string &filename) { string replaceString(const string &original, const char *findthis, const char *replace) { - int i=0; + size_t i = 0; const int size_of_replace = strlen(replace); const int size_of_find = strlen(findthis); string ret_str(original); diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc index 1d5936c..ad9de09 100644 --- a/src/FbTk/TextButton.cc +++ b/src/FbTk/TextButton.cc @@ -144,7 +144,7 @@ void TextButton::renderForeground(FbWindow &win, FbDrawable &drawable) { } void TextButton::drawText(int x_offset, int y_offset, FbDrawable *drawable) { - unsigned int textlen = text().size(); + size_t textlen = text().size(); // do text alignment unsigned int textw = width(), texth = height(); diff --git a/src/Gnome.cc b/src/Gnome.cc index 95cf08e..96bf2fd 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -205,12 +205,12 @@ void Gnome::updateClientList(BScreen &screen) { void Gnome::updateWorkspaceNames(BScreen &screen) { - int number_of_desks = screen.getWorkspaceNames().size(); + size_t number_of_desks = screen.getWorkspaceNames().size(); const BScreen::WorkspaceNames &workspace_names = screen.getWorkspaceNames(); // convert our desktop names to a char * so we can send it char *names[number_of_desks]; - for (int i = 0; i < number_of_desks; i++) { + for (size_t i = 0; i < number_of_desks; i++) { names[i] = new char[workspace_names[i].size() + 1]; strcpy(names[i], workspace_names[i].c_str()); } @@ -223,7 +223,7 @@ void Gnome::updateWorkspaceNames(BScreen &screen) { } // destroy name buffers - for (int i = 0; i < number_of_desks; i++) + for (size_t i = 0; i < number_of_desks; i++) delete [] names[i]; } diff --git a/src/Keys.cc b/src/Keys.cc index ed134e5..4ef08e9 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -189,7 +189,7 @@ bool Keys::addBinding(const std::string &linebuffer) { _FB_USES_NLS; // for each argument - for (unsigned int argc=0; argckeylist.size()) { next_key = m_keylist[i]; @@ -335,8 +335,8 @@ bool Keys::reconfigure(const char *filename) { @return true on success else false. */ bool Keys::mergeTree(t_key *newtree, t_key *basetree) { + size_t baselit_i = 0; if (basetree==0) { - unsigned int baselist_i=0; for (; baselist_imod == newtree->mod && m_keylist[baselist_i]->key == newtree->key) { @@ -357,7 +357,6 @@ bool Keys::mergeTree(t_key *newtree, t_key *basetree) { } } else { - unsigned int baselist_i = 0; for (; baselist_ikeylist.size(); baselist_i++) { if (basetree->keylist[baselist_i]->mod == newtree->mod && basetree->keylist[baselist_i]->key == newtree->key) { diff --git a/src/Keys.hh b/src/Keys.hh index f83f6e8..3463795 100644 --- a/src/Keys.hh +++ b/src/Keys.hh @@ -86,14 +86,14 @@ private: ~t_key(); inline t_key *find(unsigned int key_, unsigned int mod_) { - for (unsigned int i=0; ikey == key_ && keylist[i]->mod == FbTk::KeyUtil::instance().isolateModifierMask(mod_)) return keylist[i]; } return 0; } inline t_key *find(XKeyEvent &ke) { - for (unsigned int i=0; ikey == ke.keycode && keylist[i]->mod == FbTk::KeyUtil::instance().isolateModifierMask(ke.state)) return keylist[i]; diff --git a/src/Resources.cc b/src/Resources.cc index c6ddf3c..feab9ea 100644 --- a/src/Resources.cc +++ b/src/Resources.cc @@ -68,11 +68,10 @@ void FbTk::Resource >:: setFromString(char const *strval) { vector val; StringUtil::stringtok(val, strval); - int size=val.size(); //clear old values m_value.clear(); - for (int i=0; i std::string FbTk::Resource >:: getString() const { string retval; - int size=m_value.size(); - for (int i=0; i &cmd): + TabPlacementMenuItem(const char * label, BScreen &screen, + FbWinFrame::TabPlacement place, + FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_screen(screen), m_place(place) { } @@ -853,7 +855,7 @@ void BScreen::reconfigure() { if (restore_menus) { // restore submenus, no timestamp changed FbTk::Menu *menu = m_rootmenu.get(); - for (unsigned int i = 0; i < remember_sub.size(); i++ ) { + for (size_t i = 0; i < remember_sub.size(); i++ ) { int sub = remember_sub[i]; if (!menu || sub < 0) break; diff --git a/src/Screen.hh b/src/Screen.hh index 2d20efd..13f2fb9 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -175,7 +175,7 @@ public: inline int screenNumber() const { return rootWindow().screenNumber(); } /// @return number of workspaces - unsigned int numberOfWorkspaces() const { return m_workspaces_list.size(); } + size_t numberOfWorkspaces() const { return m_workspaces_list.size(); } inline const Icons &iconList() const { return m_icon_list; } inline Icons &iconList() { return m_icon_list; } diff --git a/src/Window.cc b/src/Window.cc index a275e43..0fd9d8c 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -3947,7 +3947,7 @@ void FluxboxWindow::setupWindow() { - for (char c = 0; c < 2 ; c++) { + for (size_t c = 0; c < 2 ; c++) { // get titlebar configuration for current side const std::vector &dir = *(*titlebar_side[c]); diff --git a/src/Workspace.cc b/src/Workspace.cc index b874391..343772a 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -264,7 +264,7 @@ void Workspace::reconfigure() { } } -int Workspace::numberOfWindows() const { +size_t Workspace::numberOfWindows() const { return m_windowlist.size(); } diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc index e50913f..3673e17 100644 --- a/src/WorkspaceCmd.cc +++ b/src/WorkspaceCmd.cc @@ -144,7 +144,7 @@ void ArrangeWindowsCmd::execute() { return; Workspace *space = screen->currentWorkspace(); - unsigned int win_count = space->windowList().size(); + size_t win_count = space->windowList().size(); if (win_count == 0) return; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 061bf1f..fbb4203 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -360,7 +360,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile } // init all "screens" - for(unsigned int s = 0; s < screens.size(); s++) + for(size_t s = 0; s < screens.size(); s++) initScreen(screens[s]); XAllowEvents(disp, ReplayPointer, CurrentTime); @@ -1593,7 +1593,7 @@ void Fluxbox::load_rc(BScreen &screen) { &value) && value.addr) { std::vector paths; StringUtil::stringtok(paths, value.addr, ", "); - for (unsigned int i=0; i