diff options
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/FbString.cc | 14 | ||||
-rw-r--r-- | src/FbTk/Layer.hh | 2 | ||||
-rw-r--r-- | src/FbTk/MenuSearch.cc | 37 | ||||
-rw-r--r-- | src/FbTk/MenuSearch.hh | 5 | ||||
-rw-r--r-- | src/FbTk/StringUtil.hh | 4 | ||||
-rw-r--r-- | src/FbTk/TextBox.hh | 2 |
6 files changed, 35 insertions, 29 deletions
diff --git a/src/FbTk/FbString.cc b/src/FbTk/FbString.cc index 2bc7516..9c7fca7 100644 --- a/src/FbTk/FbString.cc +++ b/src/FbTk/FbString.cc | |||
@@ -168,6 +168,10 @@ void init() { | |||
168 | s_inited = true; | 168 | s_inited = true; |
169 | setlocale(LC_CTYPE, ""); | 169 | setlocale(LC_CTYPE, ""); |
170 | 170 | ||
171 | for (int i = 0; i < CONVSIZE; i++) { | ||
172 | s_iconv_convs[i] = ICONV_NULL; | ||
173 | } | ||
174 | |||
171 | #ifdef HAVE_ICONV | 175 | #ifdef HAVE_ICONV |
172 | #if defined(CODESET) && !defined(_WIN32) | 176 | #if defined(CODESET) && !defined(_WIN32) |
173 | s_locale_codeset = nl_langinfo(CODESET); | 177 | s_locale_codeset = nl_langinfo(CODESET); |
@@ -186,8 +190,6 @@ void init() { | |||
186 | s_iconv_convs[X2FB] = iconv_open("UTF-8", "ISO8859-1"); | 190 | s_iconv_convs[X2FB] = iconv_open("UTF-8", "ISO8859-1"); |
187 | s_iconv_convs[FB2LOCALE] = iconv_open(s_locale_codeset.c_str(), "UTF-8"); | 191 | s_iconv_convs[FB2LOCALE] = iconv_open(s_locale_codeset.c_str(), "UTF-8"); |
188 | s_iconv_convs[LOCALE2FB] = iconv_open("UTF-8", s_locale_codeset.c_str()); | 192 | s_iconv_convs[LOCALE2FB] = iconv_open("UTF-8", s_locale_codeset.c_str()); |
189 | #else | ||
190 | memset(s_iconv_convs, 0, sizeof(s_iconv_convs)); | ||
191 | #endif // HAVE_ICONV | 193 | #endif // HAVE_ICONV |
192 | 194 | ||
193 | } | 195 | } |
@@ -195,11 +197,13 @@ void init() { | |||
195 | void shutdown() { | 197 | void shutdown() { |
196 | #ifdef HAVE_ICONV | 198 | #ifdef HAVE_ICONV |
197 | int i; | 199 | int i; |
198 | for (i = 0; i < CONVSIZE; ++i) | 200 | for (i = 0; i < CONVSIZE; ++i) { |
199 | if (s_iconv_convs[i] != ICONV_NULL) | 201 | if (s_iconv_convs[i] != ICONV_NULL) { |
200 | iconv_close(s_iconv_convs[i]); | 202 | iconv_close(s_iconv_convs[i]); |
203 | s_iconv_convs[i] = ICONV_NULL; | ||
204 | } | ||
205 | } | ||
201 | 206 | ||
202 | memset(s_iconv_convs, 0, sizeof(s_iconv_convs)); | ||
203 | s_inited = false; | 207 | s_inited = false; |
204 | #endif // HAVE_ICONV | 208 | #endif // HAVE_ICONV |
205 | } | 209 | } |
diff --git a/src/FbTk/Layer.hh b/src/FbTk/Layer.hh index 536ce00..ed28ec6 100644 --- a/src/FbTk/Layer.hh +++ b/src/FbTk/Layer.hh | |||
@@ -43,7 +43,7 @@ public: | |||
43 | //typedef std::list<LayerItem *>::reverse_iterator reverse_iterator; | 43 | //typedef std::list<LayerItem *>::reverse_iterator reverse_iterator; |
44 | 44 | ||
45 | void setLayerNum(int layernum) { m_layernum = layernum; }; | 45 | void setLayerNum(int layernum) { m_layernum = layernum; }; |
46 | int getLayerNum() { return m_layernum; }; | 46 | int getLayerNum() const { return m_layernum; }; |
47 | // Put all items on the same layer (called when layer item added to) | 47 | // Put all items on the same layer (called when layer item added to) |
48 | void alignItem(LayerItem &item); | 48 | void alignItem(LayerItem &item); |
49 | int countWindows(); | 49 | int countWindows(); |
diff --git a/src/FbTk/MenuSearch.cc b/src/FbTk/MenuSearch.cc index d87bfaf..689323c 100644 --- a/src/FbTk/MenuSearch.cc +++ b/src/FbTk/MenuSearch.cc | |||
@@ -19,7 +19,7 @@ size_t search_str_textstart(const std::string& text, const std::string& pattern) | |||
19 | 19 | ||
20 | size_t i; | 20 | size_t i; |
21 | for (i = l; i > 0; i--) { | 21 | for (i = l; i > 0; i--) { |
22 | if (std::tolower(text[i-1]) != std::tolower(pattern[i-1])) { | 22 | if (std::tolower(text[i-1]) != pattern[i-1]) { |
23 | return std::string::npos; | 23 | return std::string::npos; |
24 | } | 24 | } |
25 | } | 25 | } |
@@ -40,12 +40,13 @@ size_t search_str_bmh(const std::string& text, const std::string& pattern) { | |||
40 | return std::string::npos; | 40 | return std::string::npos; |
41 | } | 41 | } |
42 | 42 | ||
43 | size_t t; | 43 | const size_t tlen = text.size(); |
44 | size_t tlen = text.size(); | 44 | const size_t plen = pattern.size(); |
45 | size_t t; // index in text | ||
45 | 46 | ||
46 | // simple case, no need to be too clever | 47 | // simple case, no need to be too clever |
47 | if (pattern.size() == 1) { | 48 | if (plen == 1) { |
48 | int b = std::tolower(pattern[0]); | 49 | int b = pattern[0]; |
49 | for (t = 0; t < tlen; t++) { | 50 | for (t = 0; t < tlen; t++) { |
50 | if (b == std::tolower(text[t])) { | 51 | if (b == std::tolower(text[t])) { |
51 | return t; | 52 | return t; |
@@ -54,28 +55,28 @@ size_t search_str_bmh(const std::string& text, const std::string& pattern) { | |||
54 | return std::string::npos; | 55 | return std::string::npos; |
55 | } | 56 | } |
56 | 57 | ||
57 | |||
58 | size_t plast = pattern.size() - 1; | ||
59 | size_t p; | ||
60 | |||
61 | // prepare skip-table | 58 | // prepare skip-table |
62 | // | 59 | // |
63 | size_t skip[256]; | 60 | size_t skip[256]; |
61 | const size_t pe = plen - 1; // end index in pattern | ||
62 | size_t p; // index in pattern | ||
63 | |||
64 | for (p = 0; p < sizeof(skip)/sizeof(skip[0]); p++) { | 64 | for (p = 0; p < sizeof(skip)/sizeof(skip[0]); p++) { |
65 | skip[p] = plast + 1; | 65 | skip[p] = plen; |
66 | } | 66 | } |
67 | for (p = 0; p < plast; p++) { | 67 | for (p = 0; p < pe; p++) { |
68 | skip[std::tolower(pattern[p])] = plast - p; | 68 | skip[pattern[p]] = pe - p; |
69 | } | 69 | } |
70 | 70 | ||
71 | // match | 71 | // match |
72 | for (t = 0; t + plast < tlen; ) { | 72 | // |
73 | for (p = plast; std::tolower(text[t+p]) == std::tolower(pattern[p]); p--) { | 73 | for (t = 0; (t+pe) < tlen; ) { |
74 | for (p = pe; std::tolower(text[t+p]) == pattern[p]; p--) { | ||
74 | if (p == 0) { | 75 | if (p == 0) { |
75 | return t+p; | 76 | return t; |
76 | } | 77 | } |
77 | } | 78 | } |
78 | t += skip[std::tolower(text[t+p])]; | 79 | t += skip[std::tolower(text[t+pe])]; |
79 | } | 80 | } |
80 | 81 | ||
81 | return std::string::npos; | 82 | return std::string::npos; |
@@ -117,7 +118,7 @@ void MenuSearch::clear() { | |||
117 | } | 118 | } |
118 | 119 | ||
119 | void MenuSearch::add(char c) { | 120 | void MenuSearch::add(char c) { |
120 | pattern.push_back(c); | 121 | pattern.push_back(std::tolower(c)); |
121 | } | 122 | } |
122 | 123 | ||
123 | void MenuSearch::backspace() { | 124 | void MenuSearch::backspace() { |
diff --git a/src/FbTk/MenuSearch.hh b/src/FbTk/MenuSearch.hh index d642929..e06b39b 100644 --- a/src/FbTk/MenuSearch.hh +++ b/src/FbTk/MenuSearch.hh | |||
@@ -13,9 +13,10 @@ class MenuItem; | |||
13 | // a small helper which applies search operations on a list of MenuItems*. | 13 | // a small helper which applies search operations on a list of MenuItems*. |
14 | // the former incarnation of this class was FbTk::TypeAhead in combination with | 14 | // the former incarnation of this class was FbTk::TypeAhead in combination with |
15 | // the now non-existent FbTk::SearchResults, but the complexity of these | 15 | // the now non-existent FbTk::SearchResults, but the complexity of these |
16 | // are not needed for our use case. as a bonus we have less lose parts | 16 | // are not needed for our use case. as a bonus, we have less lose parts |
17 | // flying around. | 17 | // flying around. |
18 | 18 | // | |
19 | // MenuSearch is case insensitive. | ||
19 | class MenuSearch { | 20 | class MenuSearch { |
20 | public: | 21 | public: |
21 | 22 | ||
diff --git a/src/FbTk/StringUtil.hh b/src/FbTk/StringUtil.hh index b3908d8..2f7c6fc 100644 --- a/src/FbTk/StringUtil.hh +++ b/src/FbTk/StringUtil.hh | |||
@@ -98,10 +98,10 @@ static void stringTokensBetween(Container &container, const std::string &in, | |||
98 | const char *ok_chars = " \t\n", bool allow_nesting = true) { | 98 | const char *ok_chars = " \t\n", bool allow_nesting = true) { |
99 | 99 | ||
100 | std::string token; | 100 | std::string token; |
101 | int err = 0, pos = 0; | 101 | int pos = 0; |
102 | 102 | ||
103 | while (true) { | 103 | while (true) { |
104 | err = getStringBetween(token, in.c_str() + pos, first, last, ok_chars, | 104 | int err = getStringBetween(token, in.c_str() + pos, first, last, ok_chars, |
105 | allow_nesting); | 105 | allow_nesting); |
106 | if (err <= 0) | 106 | if (err <= 0) |
107 | break; | 107 | break; |
diff --git a/src/FbTk/TextBox.hh b/src/FbTk/TextBox.hh index 7b42bd1..40a7c3c 100644 --- a/src/FbTk/TextBox.hh +++ b/src/FbTk/TextBox.hh | |||
@@ -63,7 +63,7 @@ public: | |||
63 | const Font &font() const { return *m_font; } | 63 | const Font &font() const { return *m_font; } |
64 | GC gc() const { return m_gc; } | 64 | GC gc() const { return m_gc; } |
65 | int cursorPosition() const { return m_cursor_pos; } | 65 | int cursorPosition() const { return m_cursor_pos; } |
66 | int textStartPos(){ return m_start_pos; } | 66 | int textStartPos() const { return m_start_pos; } |
67 | 67 | ||
68 | unsigned int findEmptySpaceLeft(); | 68 | unsigned int findEmptySpaceLeft(); |
69 | unsigned int findEmptySpaceRight(); | 69 | unsigned int findEmptySpaceRight(); |