size_t fixes, thanks Semushin Slava aka php-coder
jump to
@@ -127,7 +127,7 @@
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 @@ } else {
// 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 @@ */
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 @@ case LEFT:
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 @@ }
void Container::for_each(std::mem_fun_t<void, FbTk::FbWindow> function) { std::for_each(m_item_list.begin(), - m_item_list.end(), - function); + m_item_list.end(), + function); } void Container::setAlpha(unsigned char alpha) {
@@ -258,7 +258,7 @@ tmp->pixel2 = 0l;
cache.push_back(tmp); - if ((unsigned) cache.size() > cache_max) + if (cache.size() > cache_max) cleanCache(); return pixmap;
@@ -59,7 +59,7 @@ virtual void restack();
/// @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
@@ -29,7 +29,7 @@ void MacroCommand::add(RefCount<Command> &com) {
m_commandlist.push_back(com); } -unsigned int MacroCommand::size() const { +size_t MacroCommand::size() const { return m_commandlist.size(); }
@@ -35,7 +35,7 @@ /// executes a list of commands
class MacroCommand:public Command { public: void add(RefCount<Command> &com); - unsigned int size() const; + size_t size() const; virtual void execute(); private:
@@ -577,13 +577,13 @@ menu.title.clear();
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()) {
@@ -147,7 +147,7 @@ inline int x() const { return menu.window.x(); }
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;
@@ -168,8 +168,8 @@ selh);
// 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); } }
@@ -180,8 +180,8 @@ delete [] winlist;
} int MultLayers::size() { - int i = 0, num = 0; - for (; i < static_cast<signed>(m_layers.size()); i++) { + int num = 0; + for (size_t i = 0; i < m_layers.size(); i++) { num += m_layers[i]->countWindows(); } return num;
@@ -123,7 +123,7 @@
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);
@@ -144,7 +144,7 @@ drawText(0, 0, &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();
@@ -205,12 +205,12 @@ }
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 @@ XFree(text.value);
} // 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]; }
@@ -189,7 +189,7 @@ t_key *current_key=0, *last_key=0;
_FB_USES_NLS; // for each argument - for (unsigned int argc=0; argc<val.size(); argc++) { + for (size_t argc = 0; argc < val.size(); argc++) { if (val[argc][0] != ':') { // parse key(s) keyarg++;@@ -289,7 +289,7 @@ static struct t_key* next_key = 0;
if (!next_key) { - for (unsigned int i=0; i<m_keylist.size(); i++) { + for (size_t i = 0; i < m_keylist.size(); i++) { if (*m_keylist[i] == ke) { if (m_keylist[i]->keylist.size()) { next_key = m_keylist[i];@@ -335,8 +335,8 @@ Merges two chains and binds new keys
@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_i<m_keylist.size(); baselist_i++) { if (m_keylist[baselist_i]->mod == newtree->mod && m_keylist[baselist_i]->key == newtree->key) {@@ -357,7 +357,6 @@ return true;
} } else { - unsigned int baselist_i = 0; for (; baselist_i<basetree->keylist.size(); baselist_i++) { if (basetree->keylist[baselist_i]->mod == newtree->mod && basetree->keylist[baselist_i]->key == newtree->key) {
@@ -86,14 +86,14 @@ t_key(t_key *k);
~t_key(); inline t_key *find(unsigned int key_, unsigned int mod_) { - for (unsigned int i=0; i<keylist.size(); i++) { + for (size_t i = 0; i < keylist.size(); i++) { if (keylist[i]->key == 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; i<keylist.size(); i++) { + for (size_t i = 0; i < keylist.size(); i++) { if (keylist[i]->key == ke.keycode && keylist[i]->mod == FbTk::KeyUtil::instance().isolateModifierMask(ke.state)) return keylist[i];
@@ -68,11 +68,10 @@ void FbTk::Resource<std::vector<WinButton::Type> >::
setFromString(char const *strval) { vector<std::string> val; StringUtil::stringtok(val, strval); - int size=val.size(); //clear old values m_value.clear(); - for (int i=0; i<size; i++) { + for (size_t i = 0; i < val.size(); i++) { if (strcasecmp(val[i].c_str(), "Maximize")==0) m_value.push_back(WinButton::MAXIMIZE); else if (strcasecmp(val[i].c_str(), "Minimize")==0)@@ -138,8 +137,7 @@ template<>
std::string FbTk::Resource<std::vector<WinButton::Type> >:: getString() const { string retval; - int size=m_value.size(); - for (int i=0; i<size; i++) { + for (size_t i = 0; i < m_value.size(); i++) { switch (m_value[i]) { case WinButton::SHADE: retval.append("Shade");
@@ -158,7 +158,9 @@
class TabPlacementMenuItem: public FbTk::MenuItem { public: - TabPlacementMenuItem(const char * label, BScreen &screen, FbWinFrame::TabPlacement place, FbTk::RefCount<FbTk::Command> &cmd): + TabPlacementMenuItem(const char * label, BScreen &screen, + FbWinFrame::TabPlacement place, + FbTk::RefCount<FbTk::Command> &cmd): FbTk::MenuItem(label, cmd), m_screen(screen), m_place(place) { }@@ -853,7 +855,7 @@
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;
@@ -175,7 +175,7 @@ inline unsigned int height() const { return rootWindow().height(); }
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; }
@@ -3947,7 +3947,7 @@
- for (char c = 0; c < 2 ; c++) { + for (size_t c = 0; c < 2 ; c++) { // get titlebar configuration for current side const std::vector<WinButton::Type> &dir = *(*titlebar_side[c]);
@@ -264,7 +264,7 @@ (*it)->reconfigure();
} } -int Workspace::numberOfWindows() const { +size_t Workspace::numberOfWindows() const { return m_windowlist.size(); }
@@ -144,7 +144,7 @@ if (screen == 0)
return; Workspace *space = screen->currentWorkspace(); - unsigned int win_count = space->windowList().size(); + size_t win_count = space->windowList().size(); if (win_count == 0) return;
@@ -360,7 +360,7 @@ }
} // 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 @@ if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
&value) && value.addr) { std::vector<std::string> paths; StringUtil::stringtok(paths, value.addr, ", "); - for (unsigned int i=0; i<paths.size(); ++i) + for (size_t i = 0; i < paths.size(); ++i) FbTk::Image::addSearchPath(paths[i]); }