GNOME Bugzilla – Bug 655185
[patch] Add string.get_prev_char ()
Last modified: 2012-07-18 09:51:34 UTC
Created attachment 192539 [details] [review] Patch v1 Sometimes I need to traverse a string in the reverse order. Since the method string.get_next_char () already exists and is easy to use, I've made a patch to add the opposite: string.get_prev_char ().
Created attachment 218046 [details] [review] glib-2.0: add string.get_prev_char() This is the opposite of string.get_next_char().
Review of attachment 218046 [details] [review]: Shouldn't get_prev_char() decrement the index before calling utf8_get_char()? Otherwise you have to ignore the first codepoint returned and false is returned one iteration early.
(In reply to comment #2) > Review of attachment 218046 [details] [review]: > > Shouldn't get_prev_char() decrement the index before calling utf8_get_char()? > Otherwise you have to ignore the first codepoint returned and false is returned > one iteration early. Yes, indeed it would be more convenient.
Created attachment 218963 [details] [review] glib-2.0: add string.get_prev_char() This is the opposite of string.get_next_char(). There is a difference though, to be more convenient in a loop: get_next_char() returns the current chararcter, and the next index. get_prev_char() returns the previous character, and the previous index.
commit b4e884c150100d56636d5cf6be4e5311d62bb718 Author: Sébastien Wilmet <swilmet@src.gnome.org> Date: Wed Jul 4 21:39:01 2012 +0200 glib-2.0: add string.get_prev_char() This is the opposite of string.get_next_char(). There is a difference though, to be more convenient in a loop: get_next_char() returns the current chararcter, and the next index. get_prev_char() returns the previous character, and the previous index. Fixes bug 655185.