static inline void format_this (unsigned char *t, off_t size, long indent, gboolean utf8) { off_t q = 0, ww; strip_newlines (t, size); ww = option_word_wrap_line_length * FONT_MEAN_WIDTH - indent; if (ww < FONT_MEAN_WIDTH * 2) ww = FONT_MEAN_WIDTH * 2; while (TRUE) { off_t p; q = line_pixel_length (t, q, ww, utf8); if (q > size) break; if (t[q] == '\n') break; p = word_start (t, q, size); if (p == -1) q = next_word_start (t, q, size); /* Return the end of the word if the beginning of the word is at the beginning of a line (i.e. a very long word) */ else q = p; if (q == -1) /* end of paragraph */ break; if (q != 0) t[q - 1] = '\n'; } }
/* replaces ' ' with '\n' to properly format a paragraph */ static void format_this (unsigned char *t, int size, int indent) { int q = 0, ww; strip_newlines (t, size); ww = option_word_wrap_line_length * FONT_MEAN_WIDTH - indent; if (ww < FONT_MEAN_WIDTH * 2) ww = FONT_MEAN_WIDTH * 2; for (;;) { int p; q = line_pixel_length (t, q, ww); if (q > size) break; if (t[q] == '\n') break; p = word_start (t, q, size); if (p == -1) q = next_word_start (t, q, size); /* Return the end of the word if the beginning of the word is at the beginning of a line (i.e. a very long word) */ else q = p; if (q == -1) /* end of paragraph */ break; if (q) t[q - 1] = '\n'; } }
gboolean ide_pattern_spec_match (IdePatternSpec *self, const gchar *haystack) { gsize i; g_return_val_if_fail (self, FALSE); g_return_val_if_fail (haystack, FALSE); for (i = 0; (haystack != NULL) && self->parts [i]; i++) { if (self->parts [i][0] == '\0') continue; if (self->case_sensitive) haystack = strstr (haystack, self->parts [i]); else haystack = strcasestr (haystack, self->parts [i]); if (haystack == NULL) return FALSE; if (self->parts [i + 1] != NULL) haystack = next_word_start (haystack + strlen (self->parts [i])); } return TRUE; }
/* find the start of a word */ static int word_start (unsigned char *t, int q, int size) { int i = q; if (t[q] == ' ' || t[q] == '\t') return next_word_start (t, q, size); for (;;) { int c; if (!i) return -1; c = t[i - 1]; if (c == '\n') return -1; if (c == ' ' || c == '\t') return i; i--; } }
static inline int word_start (unsigned char *t, off_t q, off_t size) { off_t i; if (t[q] == ' ' || t[q] == '\t') return next_word_start (t, q, size); for (i = q;; i--) { unsigned char c; if (i == 0) return (-1); c = t[i - 1]; if (c == '\n') return (-1); if (c == ' ' || c == '\t') return i; } }