From 3c69a2cafb22b783f4c1981d689d390bcb72d7af Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 10 Oct 2012 11:54:57 +0400 Subject: [PATCH] (book_mark_clear): return gboolean instead of int. (book_mark_query_color): likewise. Signed-off-by: Andrew Borodin --- src/editor/bookmark.c | 51 ++++++++++++++++++++++++++---------------- src/editor/edit-impl.h | 5 ++--- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/editor/bookmark.c b/src/editor/bookmark.c index 3c399e4ee..dce00ab33 100644 --- a/src/editor/bookmark.c +++ b/src/editor/bookmark.c @@ -139,24 +139,32 @@ book_mark_find (WEdit * edit, long line) /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ -/** returns true if a bookmark exists at this line of color c */ +/** + * Check if bookmark bookmark exists at this line of this color + * + * @param edit editor object + * @param line line where book mark is + * @param c color of book mark + * @returns TRUE if bookmark exists at this line of color c, FALSE otherwise + */ -int +gboolean book_mark_query_color (WEdit * edit, long line, int c) { - edit_book_mark_t *p; - - if (edit->book_mark == NULL) - return 0; - - for (p = book_mark_find (edit, line); p != NULL; p = p->prev) + if (edit->book_mark != NULL) { - if (p->line != line) - return 0; - if (p->c == c) - return 1; + edit_book_mark_t *p; + + for (p = book_mark_find (edit, line); p != NULL; p = p->prev) + { + if (p->line != line) + return FALSE; + if (p->c == c) + return TRUE; + } } - return 0; + + return FALSE; } /* --------------------------------------------------------------------------------------------- */ @@ -195,15 +203,20 @@ book_mark_insert (WEdit * edit, long line, int c) } /* --------------------------------------------------------------------------------------------- */ -/** remove a bookmark if there is one at this line matching this color - c of -1 clear all - * @returns non-zero on not-found +/** + * Remove a bookmark if there is one at this line matching this color - c of -1 clear all + * + * @param edit editor object + * @param line line where book mark is + * @param c color of book mark or -1 to clear all book marks on this line + * @returns FALSE if not found, TRUE otherwise */ -int +gboolean book_mark_clear (WEdit * edit, long line, int c) { edit_book_mark_t *p, *q; - int r = 1; + gboolean r = FALSE; if (edit->book_mark == NULL) return r; @@ -213,7 +226,7 @@ book_mark_clear (WEdit * edit, long line, int c) q = p->prev; if (p->line == line && (p->c == c || c == -1)) { - r = 0; + r = TRUE; edit->book_mark = p->prev; p->prev->next = p->next; if (p->next != NULL) @@ -224,7 +237,7 @@ book_mark_clear (WEdit * edit, long line, int c) } } /* if there is only our dummy book mark left, clear it for speed */ - if (edit->book_mark->line == -1 && !edit->book_mark->next) + if (edit->book_mark->line == -1 && edit->book_mark->next == NULL) { g_free (edit->book_mark); edit->book_mark = NULL; diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h index 1d35971ca..82f276902 100644 --- a/src/editor/edit-impl.h +++ b/src/editor/edit-impl.h @@ -308,10 +308,9 @@ void edit_free_syntax_rules (WEdit * edit); void edit_get_syntax_color (WEdit * edit, off_t byte_index, int *color); void book_mark_insert (WEdit * edit, long line, int c); -int book_mark_query_color (WEdit * edit, long line, int c); -int book_mark_query_all (WEdit * edit, long line, int *c); +gboolean book_mark_query_color (WEdit * edit, long line, int c); struct edit_book_mark_t *book_mark_find (WEdit * edit, long line); -int book_mark_clear (WEdit * edit, long line, int c); +gboolean book_mark_clear (WEdit * edit, long line, int c); void book_mark_flush (WEdit * edit, int c); void book_mark_inc (WEdit * edit, long line); void book_mark_dec (WEdit * edit, long line);