Mercurial > pidgin
comparison plugins/spellchk.c @ 12600:e856f985a0b9
[gaim-migrate @ 14934]
Enable the extra warnings regardless of --enable-debug.
Enable FORTIFY_SOURCE regardless of --enable-debug, adding a --disable-fortify flag to configure.
Enable (well, stop disabling) the missing initializer warnings.
This leads to warnings with: GValue v = {0,}; that must be worked around.
Basically, instead of:
GValue v = {0,};
...
g_value_init(&v, G_TYPE_FOO); /* or other use of the GValue */
We'd need to do:
GValue v;
...
v.g_type = 0;
g_value_init(&v, G_TYPE_FOO); /* or other use of the GValue */
Fix several cases of missing initializers. I don't think any of these are bugs, but having this warning seems like a good idea. It might prevent us from making a mistake in the future.
While I was fixing missing initializers, I optimized substitute_simple_word in plugins/spellchk.c, in the same way as I did substitute_word before. Yes, I'm bad for committing these together.
Added a --enable-fatal-asserts flag to configure. As the name implies, this makes g_return_... guards fatal. This is a useful flag to run on a debug copy of Gaim. It will make it very clear if your changes have triggered one of these guards. It's also useful in detecting g_return_... abuse, which helps prevent crashes if Gaim is compiled with G_DISABLE_ASSERT defined.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 21 Dec 2005 18:36:19 +0000 |
parents | b7a72fc48f62 |
children | 317d1dfedeed |
comparison
equal
deleted
inserted
replaced
12599:e94c33909aa6 | 12600:e856f985a0b9 |
---|---|
140 gtk_text_iter_forward_to_end(&end); | 140 gtk_text_iter_forward_to_end(&end); |
141 | 141 |
142 text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); | 142 text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); |
143 | 143 |
144 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &treeiter) && text) { | 144 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &treeiter) && text) { |
145 do{ | 145 do { |
146 GValue val0 = {0, }; | 146 GValue val1; |
147 GValue val1 = {0, }; | |
148 GValue val2 = {0, }; | |
149 const gchar *bad; | 147 const gchar *bad; |
150 const gchar *good; | |
151 gchar *cursor; | 148 gchar *cursor; |
152 gboolean word_only; | |
153 glong char_pos; | 149 glong char_pos; |
154 | 150 |
155 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &treeiter, BAD_COLUMN, &val0); | 151 val1.g_type = 0; |
156 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &treeiter, GOOD_COLUMN, &val1); | 152 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &treeiter, WORD_ONLY_COLUMN, &val1); |
157 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &treeiter, WORD_ONLY_COLUMN, &val2); | 153 if (g_value_get_boolean(&val1)) |
158 | 154 { |
159 bad = g_value_get_string(&val0); | 155 g_value_unset(&val1); |
160 good = g_value_get_string(&val1); | 156 continue; |
161 word_only = g_value_get_boolean(&val2); | 157 } |
158 g_value_unset(&val1); | |
159 | |
160 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &treeiter, BAD_COLUMN, &val1); | |
161 bad = g_value_get_string(&val1); | |
162 | 162 |
163 /* using g_utf8_* to get /character/ offsets instead of byte offsets for buffer */ | 163 /* using g_utf8_* to get /character/ offsets instead of byte offsets for buffer */ |
164 if (!word_only && (cursor = g_strrstr(text, bad))) | 164 if ((cursor = g_strrstr(text, bad))) |
165 { | 165 { |
166 GValue val2; | |
167 const gchar *good; | |
168 | |
169 val2.g_type = 0; | |
170 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &treeiter, GOOD_COLUMN, &val2); | |
171 good = g_value_get_string(&val2); | |
172 | |
166 char_pos = g_utf8_pointer_to_offset(text, cursor); | 173 char_pos = g_utf8_pointer_to_offset(text, cursor); |
167 gtk_text_buffer_get_iter_at_offset(buffer, &start, char_pos); | 174 gtk_text_buffer_get_iter_at_offset(buffer, &start, char_pos); |
168 gtk_text_buffer_get_iter_at_offset(buffer, &end, char_pos + g_utf8_strlen(bad, -1)); | 175 gtk_text_buffer_get_iter_at_offset(buffer, &end, char_pos + g_utf8_strlen(bad, -1)); |
169 gtk_text_buffer_delete(buffer, &start, &end); | 176 gtk_text_buffer_delete(buffer, &start, &end); |
170 | 177 |
171 gtk_text_buffer_get_iter_at_offset(buffer, &start, char_pos); | 178 gtk_text_buffer_get_iter_at_offset(buffer, &start, char_pos); |
172 gtk_text_buffer_insert(buffer, &start, good, -1); | 179 gtk_text_buffer_insert(buffer, &start, good, -1); |
173 | 180 |
174 g_value_unset(&val0); | |
175 g_value_unset(&val1); | |
176 g_value_unset(&val2); | 181 g_value_unset(&val2); |
177 g_free(text); | 182 g_free(text); |
178 | 183 |
184 g_value_unset(&val1); | |
179 return TRUE; | 185 return TRUE; |
180 } | 186 } |
181 | 187 |
182 g_value_unset(&val0); | |
183 g_value_unset(&val1); | 188 g_value_unset(&val1); |
184 g_value_unset(&val2); | |
185 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &treeiter)); | 189 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &treeiter)); |
186 } | 190 } |
187 | 191 |
188 g_free(text); | 192 g_free(text); |
189 return FALSE; | 193 return FALSE; |
203 lowerword = g_utf8_strdown(word, -1); | 207 lowerword = g_utf8_strdown(word, -1); |
204 foldedword = g_utf8_casefold(word, -1); | 208 foldedword = g_utf8_casefold(word, -1); |
205 | 209 |
206 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { | 210 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { |
207 do { | 211 do { |
208 GValue val1 = {0, }; | 212 GValue val1; |
209 const char *bad; | 213 const char *bad; |
210 gchar *tmpbad = NULL; | 214 gchar *tmpbad = NULL; |
211 gboolean word_only; | 215 |
212 | 216 val1.g_type = 0; |
213 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, WORD_ONLY_COLUMN, &val1); | 217 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, WORD_ONLY_COLUMN, &val1); |
214 if (!g_value_get_boolean(&val1)) { | 218 if (!g_value_get_boolean(&val1)) { |
215 g_value_unset(&val1); | 219 g_value_unset(&val1); |
216 continue; | 220 continue; |
217 } | 221 } |
222 | 226 |
223 if (!strcmp(bad, lowerword) || | 227 if (!strcmp(bad, lowerword) || |
224 (!is_word_lowercase(bad) && | 228 (!is_word_lowercase(bad) && |
225 !strcmp((tmpbad = g_utf8_casefold(bad, -1)), foldedword))) | 229 !strcmp((tmpbad = g_utf8_casefold(bad, -1)), foldedword))) |
226 { | 230 { |
227 GValue val2 = {0, }; | 231 GValue val2; |
228 const char *good; | 232 const char *good; |
229 | 233 |
230 g_free(tmpbad); | 234 g_free(tmpbad); |
231 | 235 |
236 val2.g_type = 0; | |
232 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GOOD_COLUMN, &val2); | 237 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GOOD_COLUMN, &val2); |
233 good = g_value_get_string(&val2); | 238 good = g_value_get_string(&val2); |
234 | 239 |
235 if (is_word_lowercase(bad) && is_word_lowercase(good)) | 240 if (is_word_lowercase(bad) && is_word_lowercase(good)) |
236 { | 241 { |
1743 | 1748 |
1744 static void on_edited(GtkCellRendererText *cellrenderertext, | 1749 static void on_edited(GtkCellRendererText *cellrenderertext, |
1745 gchar *path, gchar *arg2, gpointer data) | 1750 gchar *path, gchar *arg2, gpointer data) |
1746 { | 1751 { |
1747 GtkTreeIter iter; | 1752 GtkTreeIter iter; |
1748 GValue val = {0, }; | 1753 GValue val; |
1749 | 1754 |
1750 if (arg2[0] == '\0') { | 1755 if (arg2[0] == '\0') { |
1751 gdk_beep(); | 1756 gdk_beep(); |
1752 return; | 1757 return; |
1753 } | 1758 } |
1754 | 1759 |
1755 g_return_if_fail(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(model), &iter, path)); | 1760 g_return_if_fail(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(model), &iter, path)); |
1761 val.g_type = 0; | |
1756 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GPOINTER_TO_INT(data), &val); | 1762 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GPOINTER_TO_INT(data), &val); |
1757 | 1763 |
1758 if (strcmp(arg2, g_value_get_string(&val))) { | 1764 if (strcmp(arg2, g_value_get_string(&val))) { |
1759 gtk_list_store_set(model, &iter, GPOINTER_TO_INT(data), arg2, -1); | 1765 gtk_list_store_set(model, &iter, GPOINTER_TO_INT(data), arg2, -1); |
1760 save_list(); | 1766 save_list(); |
1786 | 1792 |
1787 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { | 1793 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { |
1788 char *tmpword = g_utf8_casefold(gtk_entry_get_text(GTK_ENTRY(bad_entry)), -1); | 1794 char *tmpword = g_utf8_casefold(gtk_entry_get_text(GTK_ENTRY(bad_entry)), -1); |
1789 | 1795 |
1790 do { | 1796 do { |
1791 GValue val0 = {0, }; | 1797 GValue val0; |
1792 char *bad; | 1798 char *bad; |
1793 | 1799 |
1800 val0.g_type = 0; | |
1794 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, BAD_COLUMN, &val0); | 1801 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, BAD_COLUMN, &val0); |
1795 bad = g_utf8_casefold(g_value_get_string(&val0), -1); | 1802 bad = g_utf8_casefold(g_value_get_string(&val0), -1); |
1796 | 1803 |
1797 if (!strcmp(bad, tmpword)) { | 1804 if (!strcmp(bad, tmpword)) { |
1798 g_value_unset(&val0); | 1805 g_value_unset(&val0); |
1875 | 1882 |
1876 data = g_string_new(""); | 1883 data = g_string_new(""); |
1877 | 1884 |
1878 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { | 1885 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { |
1879 do { | 1886 do { |
1880 GValue val0 = {0, }; | 1887 GValue val0; |
1881 GValue val1 = {0, }; | 1888 GValue val1; |
1882 GValue val2 = {0, }; | 1889 GValue val2; |
1890 | |
1891 val0.g_type = 0; | |
1892 val1.g_type = 0; | |
1893 val2.g_type = 0; | |
1883 | 1894 |
1884 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, BAD_COLUMN, &val0); | 1895 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, BAD_COLUMN, &val0); |
1885 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GOOD_COLUMN, &val1); | 1896 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GOOD_COLUMN, &val1); |
1886 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, WORD_ONLY_COLUMN, &val2); | 1897 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, WORD_ONLY_COLUMN, &val2); |
1887 | 1898 |
2113 return ret; | 2124 return ret; |
2114 } | 2125 } |
2115 | 2126 |
2116 static GaimGtkPluginUiInfo ui_info = | 2127 static GaimGtkPluginUiInfo ui_info = |
2117 { | 2128 { |
2118 get_config_frame | 2129 get_config_frame, |
2130 0 /* page_num (Reserved) */ | |
2119 }; | 2131 }; |
2120 | 2132 |
2121 static GaimPluginInfo info = | 2133 static GaimPluginInfo info = |
2122 { | 2134 { |
2123 GAIM_PLUGIN_MAGIC, | 2135 GAIM_PLUGIN_MAGIC, |