23 #include <libdjvu/miniexp.h>
39 if (source->
x1 < target->
x1)
40 target->
x1 = source->
x1;
41 if (source->
x2 > target->
x2)
42 target->
x2 = source->
x2;
43 if (source->
y1 < target->
y1)
44 target->
y1 = source->
y1;
45 if (source->
y2 > target->
y2)
46 target->
y2 = source->
y2;
67 box.
x1 = miniexp_to_int (miniexp_nth (1, p));
68 box.
y1 = miniexp_to_int (miniexp_nth (2, p));
69 box.
x2 = miniexp_to_int (miniexp_nth (3, p));
70 box.
y2 = miniexp_to_int (miniexp_nth (4, p));
72 if (!(delimit & 2) && page->
results != NULL) {
104 char *token_text = (
char *) miniexp_to_str (miniexp_nth (5, p));
107 g_strjoin (delimit & 2 ?
"\n" :
108 delimit & 1 ?
" " : NULL,
109 page->
text, token_text,
112 page->
text = new_text;
114 page->
text = g_strdup (token_text);
141 g_return_val_if_fail (miniexp_consp (p) && miniexp_symbolp
142 (miniexp_car (p)),
FALSE);
145 delimit |= miniexp_car (p) == page->
word_symbol ? 1 : 2;
147 deeper = miniexp_cddr (miniexp_cdddr (p));
148 while (deeper != miniexp_nil) {
149 miniexp_t str = miniexp_car (deeper);
150 if (miniexp_stringp (str)) {
163 deeper = miniexp_cdr (deeper);
175 current.
x1 = miniexp_to_int (miniexp_nth (1, p));
176 current.
y1 = miniexp_to_int (miniexp_nth (2, p));
177 current.
x2 = miniexp_to_int (miniexp_nth (3, p));
178 current.
y2 = miniexp_to_int (miniexp_nth (4, p));
179 if (current.
x2 >= rect->
x1 && current.
y1 <= rect->
y2 &&
180 current.
x1 <= rect->
x2 && current.
y2 >= rect->
y1) {
181 if (page->
start == miniexp_nil)
195 g_return_if_fail (miniexp_consp (p) &&
196 miniexp_symbolp (miniexp_car (p)));
198 deeper = miniexp_cddr (miniexp_cdddr (p));
199 while (deeper != miniexp_nil) {
200 miniexp_t str = miniexp_car (deeper);
201 if (miniexp_stringp (str))
206 deeper = miniexp_cdr (deeper);
221 page->
start = miniexp_nil;
222 page->
end = miniexp_nil;
230 return g_list_reverse (page->
results);
239 page->
start = miniexp_nil;
240 page->
end = miniexp_nil;
266 GArray *links = page->
links;
268 int hi = links->len - 1;
271 g_return_val_if_fail (hi >= 0, miniexp_nil);
277 mid = (low + hi) >> 1;
309 new_rectangle->
x1 = miniexp_to_int (miniexp_nth (1, p));
310 new_rectangle->
y1 = miniexp_to_int (miniexp_nth (2, p));
311 new_rectangle->
x2 = miniexp_to_int (miniexp_nth (3, p));
312 new_rectangle->
y2 = miniexp_to_int (miniexp_nth (4, p));
316 g_free (new_rectangle);
345 g_return_val_if_fail (miniexp_consp (p) && miniexp_symbolp
346 (miniexp_car (p)),
FALSE);
348 deeper = miniexp_cddr (miniexp_cdddr (p));
349 while (deeper != miniexp_nil) {
350 miniexp_t str = miniexp_car (deeper);
351 if (miniexp_stringp (str)) {
353 (page, p, start, end))
357 (page, str, start, end))
360 deeper = miniexp_cdr (deeper);
395 gboolean case_sensitive,
401 g_return_if_fail (miniexp_consp (p) &&
402 miniexp_symbolp (miniexp_car (p)));
406 deeper = miniexp_cddr (miniexp_cdddr (p));
407 while (deeper != miniexp_nil) {
408 miniexp_t data = miniexp_car (deeper);
409 if (miniexp_stringp (data)) {
414 g_array_append_val (page->
links, link);
416 token_text = (
char *) miniexp_to_str (data);
418 token_text = g_utf8_casefold (token_text, -1);
419 if (page->
text == NULL)
420 page->
text = g_strdup (token_text);
423 g_strjoin (delimit ?
" " : NULL,
424 page->
text, token_text,
427 page->
text = new_text;
433 case_sensitive, delimit);
435 deeper = miniexp_cdr (deeper);
451 char *haystack = page->
text;
454 if (page->
links->len == 0)
457 search_len = strlen (text);
458 while ((haystack = strstr (haystack, text)) != NULL) {
459 int start_p = haystack - page->
text;
461 int end_p = start_p + search_len - 1;
466 haystack = haystack + search_len;
481 gboolean case_sensitive)
484 case_sensitive,
FALSE);