regedit: Improve the while loop.
authorAndreas Schneider <asn@samba.org>
Fri, 26 Oct 2012 17:21:50 +0000 (19:21 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 29 Apr 2013 11:08:24 +0000 (13:08 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/utils/regedit.c

index 86e367f94e25a7d179068dab2dacb1e283669d00..824bc3f86f347df78054c5d137a2f1ff34a82f3f 100644 (file)
@@ -438,7 +438,7 @@ static void display_window(TALLOC_CTX *mem_ctx, struct registry_context *ctx)
 {
        struct regedit *regedit;
        struct tree_node *root;
-       int c;
+       int key;
 
        initscr();
        start_color();
@@ -479,15 +479,14 @@ static void display_window(TALLOC_CTX *mem_ctx, struct registry_context *ctx)
 
        update_panels();
        doupdate();
-       while (1) {
-               c = regedit_getch();
-               if (c == 'q' || c == 'Q') {
-                       break;
-               }
-               handle_main_input(regedit, c);
+
+       do {
+               key = regedit_getch();
+
+               handle_main_input(regedit, key);
                update_panels();
                doupdate();
-       }
+       } while (key != 'q' || key == 'Q');
 
        endwin();
 }