Wed, 18 Sep 2013 12:57:43 +0530
Merged soc.2013.gobjectification branch
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
2 | * gtksourceiter.c |
| 7358 | 3 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7358 | 7 | * |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
8 | * The following copyright notice applies to this file: |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
9 | * |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
10 | * Copyright (C) 2000 - 2005 Paolo Maggi |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
11 | * Copyright (C) 2002, 2003 Jeroen Zwartepoorte |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
12 | * |
| 7358 | 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU Library General Public License as published by | |
| 15 | * the Free Software Foundation; either version 2 of the License, or | |
| 16 | * (at your option) any later version. | |
| 17 | * | |
| 18 | * This program is distributed in the hope that it will be useful, | |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 | * GNU Library General Public License for more details. | |
| 22 | * | |
| 23 | * You should have received a copy of the GNU Library General Public License | |
| 24 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15931
diff
changeset
|
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. |
| 7358 | 26 | */ |
| 27 | ||
| 28 | /* | |
| 29 | * Parts of this file are copied from the gedit and glimmer project. | |
| 30 | */ | |
| 31 | ||
| 32 | #ifdef HAVE_CONFIG_H | |
| 33 | #include <config.h> | |
| 34 | #endif | |
| 35 | ||
| 36 | #include <string.h> | |
| 37 | #include "gtksourceiter.h" | |
| 38 | ||
| 39 | #define GTK_TEXT_UNKNOWN_CHAR 0xFFFC | |
| 40 | ||
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
41 | /* this function acts like g_utf8_offset_to_pointer() except that if it finds a |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
42 | * decomposable character it consumes the decomposition length from the given |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
43 | * offset. So it's useful when the offset was calculated for the normalized |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
44 | * version of str, but we need a pointer to str itself. */ |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
45 | static const gchar * |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
46 | pointer_from_offset_skipping_decomp (const gchar *str, gint offset) |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
47 | { |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
48 | gchar *casefold, *normal; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
49 | const gchar *p, *q; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
50 | |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
51 | p = str; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
52 | while (offset > 0) |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
53 | { |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
54 | q = g_utf8_next_char (p); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
55 | casefold = g_utf8_casefold (p, q - p); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
56 | normal = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
57 | offset -= g_utf8_strlen (normal, -1); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
58 | g_free (casefold); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
59 | g_free (normal); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
60 | p = q; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
61 | } |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
62 | return p; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
63 | } |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
64 | |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
65 | static const gchar * |
| 7358 | 66 | g_utf8_strcasestr (const gchar *haystack, const gchar *needle) |
| 67 | { | |
| 68 | gsize needle_len; | |
| 69 | gsize haystack_len; | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
70 | const gchar *ret = NULL; |
| 7358 | 71 | gchar *p; |
| 72 | gchar *casefold; | |
| 73 | gchar *caseless_haystack; | |
| 74 | gint i; | |
| 75 | ||
| 76 | g_return_val_if_fail (haystack != NULL, NULL); | |
| 77 | g_return_val_if_fail (needle != NULL, NULL); | |
| 78 | ||
| 79 | casefold = g_utf8_casefold (haystack, -1); | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
80 | caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); |
| 7358 | 81 | g_free (casefold); |
| 82 | ||
| 83 | needle_len = g_utf8_strlen (needle, -1); | |
| 84 | haystack_len = g_utf8_strlen (caseless_haystack, -1); | |
| 85 | ||
| 86 | if (needle_len == 0) | |
| 87 | { | |
| 88 | ret = (gchar *)haystack; | |
| 89 | goto finally_1; | |
| 90 | } | |
| 91 | ||
| 92 | if (haystack_len < needle_len) | |
| 93 | { | |
| 94 | ret = NULL; | |
| 95 | goto finally_1; | |
| 96 | } | |
| 97 | ||
| 98 | p = (gchar*)caseless_haystack; | |
| 99 | needle_len = strlen (needle); | |
| 100 | i = 0; | |
| 101 | ||
| 102 | while (*p) | |
| 103 | { | |
| 104 | if ((strncmp (p, needle, needle_len) == 0)) | |
| 105 | { | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
106 | ret = pointer_from_offset_skipping_decomp (haystack, i); |
| 7358 | 107 | goto finally_1; |
| 108 | } | |
| 109 | ||
| 110 | p = g_utf8_next_char (p); | |
| 111 | i++; | |
| 112 | } | |
| 113 | ||
| 114 | finally_1: | |
| 115 | g_free (caseless_haystack); | |
| 116 | ||
| 117 | return ret; | |
| 118 | } | |
| 119 | ||
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
120 | static const gchar * |
| 7358 | 121 | g_utf8_strrcasestr (const gchar *haystack, const gchar *needle) |
| 122 | { | |
| 123 | gsize needle_len; | |
| 124 | gsize haystack_len; | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
125 | const gchar *ret = NULL; |
| 7358 | 126 | gchar *p; |
| 127 | gchar *casefold; | |
| 128 | gchar *caseless_haystack; | |
| 129 | gint i; | |
| 130 | ||
| 131 | g_return_val_if_fail (haystack != NULL, NULL); | |
| 132 | g_return_val_if_fail (needle != NULL, NULL); | |
| 133 | ||
| 134 | casefold = g_utf8_casefold (haystack, -1); | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
135 | caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); |
| 7358 | 136 | g_free (casefold); |
| 137 | ||
| 138 | needle_len = g_utf8_strlen (needle, -1); | |
| 139 | haystack_len = g_utf8_strlen (caseless_haystack, -1); | |
| 140 | ||
| 141 | if (needle_len == 0) | |
| 142 | { | |
| 143 | ret = (gchar *)haystack; | |
| 144 | goto finally_1; | |
| 145 | } | |
| 146 | ||
| 147 | if (haystack_len < needle_len) | |
| 148 | { | |
| 149 | ret = NULL; | |
| 150 | goto finally_1; | |
| 151 | } | |
| 152 | ||
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
153 | i = haystack_len - needle_len; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
154 | p = g_utf8_offset_to_pointer (caseless_haystack, i); |
| 7358 | 155 | needle_len = strlen (needle); |
| 156 | ||
|
31306
f316b0972e0f
gtksourceiter: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
Nader Morshed <morshed.nader@gmail.com>
parents:
25888
diff
changeset
|
157 | while (1) |
| 7358 | 158 | { |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
159 | if (strncmp (p, needle, needle_len) == 0) |
| 7358 | 160 | { |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
161 | ret = pointer_from_offset_skipping_decomp (haystack, i); |
| 7358 | 162 | goto finally_1; |
| 163 | } | |
| 164 | ||
|
31306
f316b0972e0f
gtksourceiter: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
Nader Morshed <morshed.nader@gmail.com>
parents:
25888
diff
changeset
|
165 | if (p > caseless_haystack) |
|
f316b0972e0f
gtksourceiter: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
Nader Morshed <morshed.nader@gmail.com>
parents:
25888
diff
changeset
|
166 | p = g_utf8_prev_char (p); |
|
f316b0972e0f
gtksourceiter: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
Nader Morshed <morshed.nader@gmail.com>
parents:
25888
diff
changeset
|
167 | else |
|
f316b0972e0f
gtksourceiter: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
Nader Morshed <morshed.nader@gmail.com>
parents:
25888
diff
changeset
|
168 | goto finally_1; |
|
f316b0972e0f
gtksourceiter: Fix a few memory leaks in our bundled copy of this widget. Refs #13162.
Nader Morshed <morshed.nader@gmail.com>
parents:
25888
diff
changeset
|
169 | |
| 7358 | 170 | i--; |
| 171 | } | |
| 172 | ||
| 173 | finally_1: | |
| 174 | g_free (caseless_haystack); | |
| 175 | ||
| 176 | return ret; | |
| 177 | } | |
| 178 | ||
| 179 | static gboolean | |
| 180 | g_utf8_caselessnmatch (const char *s1, const char *s2, | |
| 181 | gssize n1, gssize n2) | |
| 182 | { | |
| 183 | gchar *casefold; | |
| 184 | gchar *normalized_s1; | |
| 185 | gchar *normalized_s2; | |
| 186 | gint len_s1; | |
| 187 | gint len_s2; | |
| 188 | gboolean ret = FALSE; | |
| 189 | ||
| 190 | g_return_val_if_fail (s1 != NULL, FALSE); | |
| 191 | g_return_val_if_fail (s2 != NULL, FALSE); | |
| 192 | g_return_val_if_fail (n1 > 0, FALSE); | |
| 193 | g_return_val_if_fail (n2 > 0, FALSE); | |
| 194 | ||
| 195 | casefold = g_utf8_casefold (s1, n1); | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
196 | normalized_s1 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); |
| 7358 | 197 | g_free (casefold); |
| 198 | ||
| 199 | casefold = g_utf8_casefold (s2, n2); | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
200 | normalized_s2 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); |
| 7358 | 201 | g_free (casefold); |
| 202 | ||
| 203 | len_s1 = strlen (normalized_s1); | |
| 204 | len_s2 = strlen (normalized_s2); | |
| 205 | ||
| 206 | if (len_s1 < len_s2) | |
| 207 | goto finally_2; | |
| 208 | ||
| 209 | ret = (strncmp (normalized_s1, normalized_s2, len_s2) == 0); | |
| 210 | ||
| 211 | finally_2: | |
| 212 | g_free (normalized_s1); | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
213 | g_free (normalized_s2); |
| 7358 | 214 | |
| 215 | return ret; | |
| 216 | } | |
| 217 | ||
| 218 | static void | |
| 219 | forward_chars_with_skipping (GtkTextIter *iter, | |
| 220 | gint count, | |
| 221 | gboolean skip_invisible, | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
222 | gboolean skip_nontext, |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
223 | gboolean skip_decomp) |
| 7358 | 224 | { |
| 225 | gint i; | |
| 226 | ||
| 227 | g_return_if_fail (count >= 0); | |
| 228 | ||
| 229 | i = count; | |
| 230 | ||
| 231 | while (i > 0) | |
| 232 | { | |
| 233 | gboolean ignored = FALSE; | |
| 234 | ||
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
235 | /* minimal workaround to avoid the infinite loop of bug #168247. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
236 | * It doesn't fix the problemjust the symptom... |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
237 | */ |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
238 | if (gtk_text_iter_is_end (iter)) |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
239 | return; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
240 | |
| 7358 | 241 | if (skip_nontext && gtk_text_iter_get_char (iter) == GTK_TEXT_UNKNOWN_CHAR) |
| 242 | ignored = TRUE; | |
| 243 | ||
|
12205
1b0471533cf5
[gaim-migrate @ 14507]
Richard Laager <rlaager@pidgin.im>
parents:
10297
diff
changeset
|
244 | #if 0 |
| 7358 | 245 | if (!ignored && skip_invisible && |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
246 | /* _gtk_text_btree_char_is_invisible (iter)*/ FALSE) |
| 7358 | 247 | ignored = TRUE; |
|
12205
1b0471533cf5
[gaim-migrate @ 14507]
Richard Laager <rlaager@pidgin.im>
parents:
10297
diff
changeset
|
248 | #endif |
| 7358 | 249 | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
250 | if (!ignored && skip_decomp) |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
251 | { |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
252 | /* being UTF8 correct sucks; this accounts for extra |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
253 | offsets coming from canonical decompositions of |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
254 | UTF8 characters (e.g. accented characters) which |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
255 | g_utf8_normalize() performs */ |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
256 | gchar *normal; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
257 | gchar buffer[6]; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
258 | gint buffer_len; |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
259 | |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
260 | buffer_len = g_unichar_to_utf8 (gtk_text_iter_get_char (iter), buffer); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
261 | normal = g_utf8_normalize (buffer, buffer_len, G_NORMALIZE_NFD); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
262 | i -= (g_utf8_strlen (normal, -1) - 1); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
263 | g_free (normal); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
264 | } |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
265 | |
| 7358 | 266 | gtk_text_iter_forward_char (iter); |
| 267 | ||
| 268 | if (!ignored) | |
| 269 | --i; | |
| 270 | } | |
| 271 | } | |
| 272 | ||
| 273 | static gboolean | |
| 274 | lines_match (const GtkTextIter *start, | |
| 275 | const gchar **lines, | |
| 276 | gboolean visible_only, | |
| 277 | gboolean slice, | |
| 278 | GtkTextIter *match_start, | |
| 279 | GtkTextIter *match_end) | |
| 280 | { | |
| 281 | GtkTextIter next; | |
| 282 | gchar *line_text; | |
| 283 | const gchar *found; | |
| 284 | gint offset; | |
| 285 | ||
| 286 | if (*lines == NULL || **lines == '\0') | |
| 287 | { | |
| 288 | if (match_start) | |
| 289 | *match_start = *start; | |
| 290 | if (match_end) | |
| 291 | *match_end = *start; | |
| 292 | return TRUE; | |
| 293 | } | |
| 294 | ||
| 295 | next = *start; | |
| 296 | gtk_text_iter_forward_line (&next); | |
| 297 | ||
| 298 | /* No more text in buffer, but *lines is nonempty */ | |
| 299 | if (gtk_text_iter_equal (start, &next)) | |
| 300 | return FALSE; | |
| 301 | ||
| 302 | if (slice) | |
| 303 | { | |
| 304 | if (visible_only) | |
| 305 | line_text = gtk_text_iter_get_visible_slice (start, &next); | |
| 306 | else | |
| 307 | line_text = gtk_text_iter_get_slice (start, &next); | |
| 308 | } | |
| 309 | else | |
| 310 | { | |
| 311 | if (visible_only) | |
| 312 | line_text = gtk_text_iter_get_visible_text (start, &next); | |
| 313 | else | |
| 314 | line_text = gtk_text_iter_get_text (start, &next); | |
| 315 | } | |
| 316 | ||
| 317 | if (match_start) /* if this is the first line we're matching */ | |
| 318 | { | |
| 319 | found = g_utf8_strcasestr (line_text, *lines); | |
| 320 | } | |
| 321 | else | |
| 322 | { | |
| 323 | /* If it's not the first line, we have to match from the | |
| 324 | * start of the line. | |
| 325 | */ | |
| 326 | if (g_utf8_caselessnmatch (line_text, *lines, strlen (line_text), | |
| 327 | strlen (*lines))) | |
| 328 | found = line_text; | |
| 329 | else | |
| 330 | found = NULL; | |
| 331 | } | |
| 332 | ||
| 333 | if (found == NULL) | |
| 334 | { | |
| 335 | g_free (line_text); | |
| 336 | return FALSE; | |
| 337 | } | |
| 338 | ||
| 339 | /* Get offset to start of search string */ | |
| 340 | offset = g_utf8_strlen (line_text, found - line_text); | |
| 341 | ||
| 342 | next = *start; | |
| 343 | ||
| 344 | /* If match start needs to be returned, set it to the | |
| 345 | * start of the search string. | |
| 346 | */ | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
347 | forward_chars_with_skipping (&next, offset, visible_only, !slice, FALSE); |
| 7358 | 348 | if (match_start) |
| 349 | { | |
| 350 | *match_start = next; | |
| 351 | } | |
| 352 | ||
| 353 | /* Go to end of search string */ | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
354 | forward_chars_with_skipping (&next, g_utf8_strlen (*lines, -1), visible_only, !slice, TRUE); |
| 7358 | 355 | |
| 356 | g_free (line_text); | |
| 357 | ||
| 358 | ++lines; | |
| 359 | ||
| 360 | if (match_end) | |
| 361 | *match_end = next; | |
| 362 | ||
| 363 | /* pass NULL for match_start, since we don't need to find the | |
| 364 | * start again. | |
| 365 | */ | |
| 366 | return lines_match (&next, lines, visible_only, slice, NULL, match_end); | |
| 367 | } | |
| 368 | ||
| 369 | static gboolean | |
| 370 | backward_lines_match (const GtkTextIter *start, | |
| 371 | const gchar **lines, | |
| 372 | gboolean visible_only, | |
| 373 | gboolean slice, | |
| 374 | GtkTextIter *match_start, | |
| 375 | GtkTextIter *match_end) | |
| 376 | { | |
| 377 | GtkTextIter line, next; | |
| 378 | gchar *line_text; | |
| 379 | const gchar *found; | |
| 380 | gint offset; | |
| 381 | ||
| 382 | if (*lines == NULL || **lines == '\0') | |
| 383 | { | |
| 384 | if (match_start) | |
| 385 | *match_start = *start; | |
| 386 | if (match_end) | |
| 387 | *match_end = *start; | |
| 388 | return TRUE; | |
| 389 | } | |
| 390 | ||
| 391 | line = next = *start; | |
| 392 | if (gtk_text_iter_get_line_offset (&next) == 0) | |
| 393 | { | |
| 394 | if (!gtk_text_iter_backward_line (&next)) | |
| 395 | return FALSE; | |
| 396 | } | |
| 397 | else | |
| 398 | gtk_text_iter_set_line_offset (&next, 0); | |
| 399 | ||
| 400 | if (slice) | |
| 401 | { | |
| 402 | if (visible_only) | |
| 403 | line_text = gtk_text_iter_get_visible_slice (&next, &line); | |
| 404 | else | |
| 405 | line_text = gtk_text_iter_get_slice (&next, &line); | |
| 406 | } | |
| 407 | else | |
| 408 | { | |
| 409 | if (visible_only) | |
| 410 | line_text = gtk_text_iter_get_visible_text (&next, &line); | |
| 411 | else | |
| 412 | line_text = gtk_text_iter_get_text (&next, &line); | |
| 413 | } | |
| 414 | ||
| 415 | if (match_start) /* if this is the first line we're matching */ | |
| 416 | { | |
| 417 | found = g_utf8_strrcasestr (line_text, *lines); | |
| 418 | } | |
| 419 | else | |
| 420 | { | |
| 421 | /* If it's not the first line, we have to match from the | |
| 422 | * start of the line. | |
| 423 | */ | |
| 424 | if (g_utf8_caselessnmatch (line_text, *lines, strlen (line_text), | |
| 425 | strlen (*lines))) | |
| 426 | found = line_text; | |
| 427 | else | |
| 428 | found = NULL; | |
| 429 | } | |
| 430 | ||
| 431 | if (found == NULL) | |
| 432 | { | |
| 433 | g_free (line_text); | |
| 434 | return FALSE; | |
| 435 | } | |
| 436 | ||
| 437 | /* Get offset to start of search string */ | |
| 438 | offset = g_utf8_strlen (line_text, found - line_text); | |
| 439 | ||
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
440 | forward_chars_with_skipping (&next, offset, visible_only, !slice, FALSE); |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
441 | |
| 7358 | 442 | /* If match start needs to be returned, set it to the |
| 443 | * start of the search string. | |
| 444 | */ | |
| 445 | if (match_start) | |
| 446 | { | |
| 447 | *match_start = next; | |
| 448 | } | |
| 449 | ||
| 450 | /* Go to end of search string */ | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
451 | forward_chars_with_skipping (&next, g_utf8_strlen (*lines, -1), visible_only, !slice, TRUE); |
| 7358 | 452 | |
| 453 | g_free (line_text); | |
| 454 | ||
| 455 | ++lines; | |
| 456 | ||
| 457 | if (match_end) | |
| 458 | *match_end = next; | |
| 459 | ||
| 460 | /* try to match the rest of the lines forward, passing NULL | |
| 461 | * for match_start so lines_match will try to match the entire | |
| 462 | * line */ | |
| 463 | return lines_match (&next, lines, visible_only, | |
| 464 | slice, NULL, match_end); | |
| 465 | } | |
| 466 | ||
| 467 | /* strsplit () that retains the delimiter as part of the string. */ | |
| 468 | static gchar ** | |
| 469 | strbreakup (const char *string, | |
| 470 | const char *delimiter, | |
| 471 | gint max_tokens) | |
| 472 | { | |
| 473 | GSList *string_list = NULL, *slist; | |
| 474 | gchar **str_array, *s, *casefold, *new_string; | |
| 475 | guint i, n = 1; | |
| 476 | ||
| 477 | g_return_val_if_fail (string != NULL, NULL); | |
| 478 | g_return_val_if_fail (delimiter != NULL, NULL); | |
| 479 | ||
| 480 | if (max_tokens < 1) | |
| 481 | max_tokens = G_MAXINT; | |
| 482 | ||
| 483 | s = strstr (string, delimiter); | |
| 484 | if (s) | |
| 485 | { | |
| 486 | guint delimiter_len = strlen (delimiter); | |
| 487 | ||
| 488 | do | |
| 489 | { | |
| 490 | guint len; | |
| 491 | ||
| 492 | len = s - string + delimiter_len; | |
| 493 | new_string = g_new (gchar, len + 1); | |
| 494 | strncpy (new_string, string, len); | |
| 495 | new_string[len] = 0; | |
| 496 | casefold = g_utf8_casefold (new_string, -1); | |
| 497 | g_free (new_string); | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
498 | new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); |
| 7358 | 499 | g_free (casefold); |
| 500 | string_list = g_slist_prepend (string_list, new_string); | |
| 501 | n++; | |
| 502 | string = s + delimiter_len; | |
| 503 | s = strstr (string, delimiter); | |
| 504 | } while (--max_tokens && s); | |
| 505 | } | |
| 506 | ||
| 507 | if (*string) | |
| 508 | { | |
| 509 | n++; | |
| 510 | casefold = g_utf8_casefold (string, -1); | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
511 | new_string = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD); |
| 7358 | 512 | g_free (casefold); |
| 513 | string_list = g_slist_prepend (string_list, new_string); | |
| 514 | } | |
| 515 | ||
| 516 | str_array = g_new (gchar*, n); | |
| 517 | ||
| 518 | i = n - 1; | |
| 519 | ||
| 520 | str_array[i--] = NULL; | |
| 521 | for (slist = string_list; slist; slist = slist->next) | |
| 522 | str_array[i--] = slist->data; | |
| 523 | ||
| 524 | g_slist_free (string_list); | |
| 525 | ||
| 526 | return str_array; | |
| 527 | } | |
| 528 | ||
| 529 | /** | |
| 530 | * gtk_source_iter_forward_search: | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
531 | * @iter: start of search. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
532 | * @str: a search string. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
533 | * @flags: flags affecting how the search is done. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
534 | * @match_start: return location for start of match, or %%NULL. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
535 | * @match_end: return location for end of match, or %%NULL. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
536 | * @limit: bound for the search, or %%NULL for the end of the buffer. |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
537 | * |
|
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
538 | * Searches forward for @str. Any match is returned by setting |
|
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
539 | * @match_start to the first character of the match and @match_end to the |
| 7358 | 540 | * first character after the match. The search will not continue past |
| 541 | * @limit. Note that a search is a linear or O(n) operation, so you | |
| 542 | * may wish to use @limit to avoid locking up your UI on large | |
| 543 | * buffers. | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
544 | * |
| 7358 | 545 | * If the #GTK_SOURCE_SEARCH_VISIBLE_ONLY flag is present, the match may |
| 546 | * have invisible text interspersed in @str. i.e. @str will be a | |
| 547 | * possibly-noncontiguous subsequence of the matched range. similarly, | |
| 548 | * if you specify #GTK_SOURCE_SEARCH_TEXT_ONLY, the match may have | |
| 549 | * pixbufs or child widgets mixed inside the matched range. If these | |
| 550 | * flags are not given, the match must be exact; the special 0xFFFC | |
| 551 | * character in @str will match embedded pixbufs or child widgets. | |
| 552 | * If you specify the #GTK_SOURCE_SEARCH_CASE_INSENSITIVE flag, the text will | |
| 553 | * be matched regardless of what case it is in. | |
| 554 | * | |
| 555 | * Same as gtk_text_iter_forward_search(), but supports case insensitive | |
| 556 | * searching. | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
557 | * |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
558 | * Return value: whether a match was found. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
559 | **/ |
| 7358 | 560 | gboolean |
| 561 | gtk_source_iter_forward_search (const GtkTextIter *iter, | |
| 562 | const gchar *str, | |
| 563 | GtkSourceSearchFlags flags, | |
| 564 | GtkTextIter *match_start, | |
| 565 | GtkTextIter *match_end, | |
| 566 | const GtkTextIter *limit) | |
| 567 | { | |
| 568 | gchar **lines = NULL; | |
| 569 | GtkTextIter match; | |
| 570 | gboolean retval = FALSE; | |
| 571 | GtkTextIter search; | |
| 572 | gboolean visible_only; | |
| 573 | gboolean slice; | |
| 574 | ||
| 575 | g_return_val_if_fail (iter != NULL, FALSE); | |
| 576 | g_return_val_if_fail (str != NULL, FALSE); | |
| 577 | ||
| 578 | if ((flags & GTK_SOURCE_SEARCH_CASE_INSENSITIVE) == 0) | |
| 579 | return gtk_text_iter_forward_search (iter, str, flags, | |
| 580 | match_start, match_end, | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
581 | limit); |
| 7358 | 582 | |
| 583 | if (limit && gtk_text_iter_compare (iter, limit) >= 0) | |
| 584 | return FALSE; | |
| 585 | ||
| 586 | if (*str == '\0') | |
| 587 | { | |
| 588 | /* If we can move one char, return the empty string there */ | |
| 589 | match = *iter; | |
| 590 | ||
| 591 | if (gtk_text_iter_forward_char (&match)) | |
| 592 | { | |
| 593 | if (limit && gtk_text_iter_equal (&match, limit)) | |
| 594 | return FALSE; | |
| 595 | ||
| 596 | if (match_start) | |
| 597 | *match_start = match; | |
| 598 | if (match_end) | |
| 599 | *match_end = match; | |
| 600 | return TRUE; | |
| 601 | } | |
| 602 | else | |
| 603 | { | |
| 604 | return FALSE; | |
| 605 | } | |
| 606 | } | |
| 607 | ||
| 608 | visible_only = (flags & GTK_SOURCE_SEARCH_VISIBLE_ONLY) != 0; | |
| 609 | slice = (flags & GTK_SOURCE_SEARCH_TEXT_ONLY) == 0; | |
| 610 | ||
| 611 | /* locate all lines */ | |
| 612 | lines = strbreakup (str, "\n", -1); | |
| 613 | ||
| 614 | search = *iter; | |
| 615 | ||
| 616 | do | |
| 617 | { | |
| 618 | /* This loop has an inefficient worst-case, where | |
| 619 | * gtk_text_iter_get_text () is called repeatedly on | |
| 620 | * a single line. | |
| 621 | */ | |
| 622 | GtkTextIter end; | |
| 623 | ||
| 624 | if (limit && gtk_text_iter_compare (&search, limit) >= 0) | |
| 625 | break; | |
| 626 | ||
| 627 | if (lines_match (&search, (const gchar**)lines, | |
| 628 | visible_only, slice, &match, &end)) | |
| 629 | { | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
630 | if (limit == NULL || |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
631 | (limit && gtk_text_iter_compare (&end, limit) <= 0)) |
| 7358 | 632 | { |
| 633 | retval = TRUE; | |
| 634 | ||
| 635 | if (match_start) | |
| 636 | *match_start = match; | |
| 637 | if (match_end) | |
| 638 | *match_end = end; | |
| 639 | } | |
| 640 | break; | |
| 641 | } | |
| 642 | } while (gtk_text_iter_forward_line (&search)); | |
| 643 | ||
| 644 | g_strfreev ((gchar**)lines); | |
| 645 | ||
| 646 | return retval; | |
| 647 | } | |
| 648 | ||
| 649 | /** | |
| 650 | * gtk_source_iter_backward_search: | |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
651 | * @iter: a #GtkTextIter where the search begins. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
652 | * @str: search string. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
653 | * @flags: bitmask of flags affecting the search. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
654 | * @match_start: return location for start of match, or %%NULL. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
655 | * @match_end: return location for end of match, or %%NULL. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
656 | * @limit: location of last possible @match_start, or %%NULL for start of buffer. |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
657 | * |
| 7358 | 658 | * Same as gtk_text_iter_backward_search(), but supports case insensitive |
| 659 | * searching. | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
660 | * |
|
12465
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
661 | * Return value: whether a match was found. |
|
59859abbe998
[gaim-migrate @ 14775]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12205
diff
changeset
|
662 | **/ |
| 7358 | 663 | gboolean |
| 664 | gtk_source_iter_backward_search (const GtkTextIter *iter, | |
| 665 | const gchar *str, | |
| 666 | GtkSourceSearchFlags flags, | |
| 667 | GtkTextIter *match_start, | |
| 668 | GtkTextIter *match_end, | |
| 669 | const GtkTextIter *limit) | |
| 670 | { | |
| 671 | gchar **lines = NULL; | |
| 672 | GtkTextIter match; | |
| 673 | gboolean retval = FALSE; | |
| 674 | GtkTextIter search; | |
| 675 | gboolean visible_only; | |
| 676 | gboolean slice; | |
| 677 | ||
| 678 | g_return_val_if_fail (iter != NULL, FALSE); | |
| 679 | g_return_val_if_fail (str != NULL, FALSE); | |
| 680 | ||
| 681 | if ((flags & GTK_SOURCE_SEARCH_CASE_INSENSITIVE) == 0) | |
| 682 | return gtk_text_iter_backward_search (iter, str, flags, | |
| 683 | match_start, match_end, | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
684 | limit); |
| 7358 | 685 | |
| 686 | if (limit && gtk_text_iter_compare (iter, limit) <= 0) | |
| 687 | return FALSE; | |
| 688 | ||
| 689 | if (*str == '\0') | |
| 690 | { | |
| 691 | /* If we can move one char, return the empty string there */ | |
| 692 | match = *iter; | |
| 693 | ||
| 694 | if (gtk_text_iter_backward_char (&match)) | |
| 695 | { | |
| 696 | if (limit && gtk_text_iter_equal (&match, limit)) | |
| 697 | return FALSE; | |
| 698 | ||
| 699 | if (match_start) | |
| 700 | *match_start = match; | |
| 701 | if (match_end) | |
| 702 | *match_end = match; | |
| 703 | return TRUE; | |
| 704 | } | |
| 705 | else | |
| 706 | { | |
| 707 | return FALSE; | |
| 708 | } | |
| 709 | } | |
| 710 | ||
| 711 | visible_only = (flags & GTK_SOURCE_SEARCH_VISIBLE_ONLY) != 0; | |
| 712 | slice = (flags & GTK_SOURCE_SEARCH_TEXT_ONLY) == 0; | |
| 713 | ||
| 714 | /* locate all lines */ | |
| 715 | lines = strbreakup (str, "\n", -1); | |
| 716 | ||
| 717 | search = *iter; | |
| 718 | ||
| 719 | while (TRUE) | |
| 720 | { | |
| 721 | /* This loop has an inefficient worst-case, where | |
| 722 | * gtk_text_iter_get_text () is called repeatedly on | |
| 723 | * a single line. | |
| 724 | */ | |
| 725 | GtkTextIter end; | |
| 726 | ||
| 727 | if (limit && gtk_text_iter_compare (&search, limit) <= 0) | |
| 728 | break; | |
| 729 | ||
| 730 | if (backward_lines_match (&search, (const gchar**)lines, | |
| 731 | visible_only, slice, &match, &end)) | |
| 732 | { | |
| 733 | if (limit == NULL || (limit && | |
| 734 | gtk_text_iter_compare (&end, limit) > 0)) | |
| 735 | { | |
| 736 | retval = TRUE; | |
| 737 | ||
| 738 | if (match_start) | |
| 739 | *match_start = match; | |
| 740 | if (match_end) | |
| 741 | *match_end = end; | |
| 742 | } | |
| 743 | break; | |
| 744 | } | |
| 745 | ||
| 746 | if (gtk_text_iter_get_line_offset (&search) == 0) | |
| 747 | { | |
| 748 | if (!gtk_text_iter_backward_line (&search)) | |
| 749 | break; | |
| 750 | } | |
| 751 | else | |
| 752 | { | |
| 753 | gtk_text_iter_set_line_offset (&search, 0); | |
| 754 | } | |
| 755 | } | |
| 756 | ||
| 757 | g_strfreev ((gchar**)lines); | |
| 758 | ||
| 759 | return retval; | |
| 760 | } | |
| 761 | ||
| 762 | /* | |
| 763 | * gtk_source_iter_find_matching_bracket is implemented in gtksourcebuffer.c | |
| 764 | */ |