[gnome-builder] auto-indent: cleanup backward_to_first_char()



commit c7905671e52f5ca32e2484db8bff56848da1e971
Author: Christian Hergert <christian hergert me>
Date:   Wed Oct 15 18:18:01 2014 -0700

    auto-indent: cleanup backward_to_first_char()
    
    Just make this a bit more readable.

 src/editor/gb-source-auto-indenter-c.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/editor/gb-source-auto-indenter-c.c b/src/editor/gb-source-auto-indenter-c.c
index 6af20dc..70b9697 100644
--- a/src/editor/gb-source-auto-indenter-c.c
+++ b/src/editor/gb-source-auto-indenter-c.c
@@ -277,15 +277,18 @@ backward_to_line_first_char (GtkTextIter *iter)
                                     &tmp,
                                     gtk_text_iter_get_line (iter));
 
-  for (;
-       gtk_text_iter_compare (&tmp, iter) < 0;
-       gtk_text_iter_forward_char (&tmp))
+  while (gtk_text_iter_compare (&tmp, iter) <= 0)
     {
-      if (!g_unichar_isspace (gtk_text_iter_get_char (&tmp)))
+      gunichar ch = gtk_text_iter_get_char (&tmp);
+
+      if (!g_unichar_isspace (ch))
         {
           gtk_text_iter_assign (iter, &tmp);
           return TRUE;
         }
+
+      if (!gtk_text_iter_forward_char (&tmp))
+        break;
     }
 
   return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]