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

[PATCH] Always use "output" in IPC commands



In the IPC command functions, sometimes the GString for the output is
called "output", sometimes "result". This patch changes it all to
"output", meaning I can wrap my errormessage-functions in a nice
macro. (And also, it's more consistent)

Florian

-- 
() ascii ribbon campaign - stop html mail    www.asciiribbon.org
/\ www.the-compiler.org  | I love long mails http://email.is-not-s.ms/
The distinction between Freedom and Liberty is not accurately known; 
naturalists have been unable to find a living specimen of either. -- Ambrose 
Bierce 
>From 28502c9b24e6e06a2d74cfbf70f75aa93f0eb713 Mon Sep 17 00:00:00 2001
From: Florian Bruhin <git _at_ the _minus_ compiler _dot_ org>
Date: Thu, 15 Nov 2012 06:19:53 +0100
Subject: [PATCH] Use "output" for all IPC commands, not "result"

---
 src/main.c    | 42 +++++++++++++++++++++---------------------
 src/monitor.c |  4 ++--
 src/monitor.h |  2 +-
 src/stack.c   | 12 ++++++------
 src/stack.h   |  2 +-
 src/tag.c     |  4 ++--
 src/tag.h     |  2 +-
 7 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/main.c b/src/main.c
index 17de3f6..86f7eac 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,10 +49,10 @@ typedef void (*HandlerTable[LASTEvent]) (XEvent*);
 
 int quit();
 int reload();
-int version(int argc, char* argv[], GString* result);
-int print_layout_command(int argc, char** argv, GString* result);
-int load_command(int argc, char** argv, GString* result);
-int print_tag_status_command(int argc, char** argv, GString* result);
+int version(int argc, char* argv[], GString* output);
+int print_layout_command(int argc, char** argv, GString* output);
+int load_command(int argc, char** argv, GString* output);
+int print_tag_status_command(int argc, char** argv, GString* output);
 void execute_autostart_file();
 int raise_command(int argc, char** argv);
 int spawn(int argc, char** argv);
@@ -60,7 +60,7 @@ int wmexec(int argc, char** argv);
 static void remove_zombies(int signal);
 int custom_hook_emit(int argc, char** argv);
 int jumpto_command(int argc, char** argv);
-int getenv_command(int argc, char** argv, GString* result);
+int getenv_command(int argc, char** argv, GString* output);
 int setenv_command(int argc, char** argv);
 int unsetenv_command(int argc, char** argv);
 
@@ -171,16 +171,16 @@ int reload() {
     return 0;
 }
 
-int version(int argc, char* argv[], GString* result) {
+int version(int argc, char* argv[], GString* output) {
     (void) argc;
     (void) argv;
-    g_string_append(result, HERBSTLUFT_VERSION_STRING);
+    g_string_append(output, HERBSTLUFT_VERSION_STRING);
     return 0;
 }
 
 // prints or dumps the layout of an given tag
 // first argument tells whether to print or to dump
-int print_layout_command(int argc, char** argv, GString* result) {
+int print_layout_command(int argc, char** argv, GString* output) {
     HSTag* tag = NULL;
     if (argc >= 2) {
         tag = find_tag(argv[1]);
@@ -192,14 +192,14 @@ int print_layout_command(int argc, char** argv, GString* result) {
     }
     assert(tag != NULL);
     if (argc > 0 && !strcmp(argv[0], "dump")) {
-        dump_frame_tree(tag->frame, result);
+        dump_frame_tree(tag->frame, output);
     } else {
-        print_tag_tree(tag, result);
+        print_tag_tree(tag, output);
     }
     return 0;
 }
 
-int load_command(int argc, char** argv, GString* result) {
+int load_command(int argc, char** argv, GString* output) {
     // usage: load TAG LAYOUT
     HSTag* tag = NULL;
     if (argc < 2) {
@@ -216,7 +216,7 @@ int load_command(int argc, char** argv, GString* result) {
         tag = m->tag;
     }
     assert(tag != NULL);
-    char* rest = load_frame_tree(tag->frame, layout_string, result);
+    char* rest = load_frame_tree(tag->frame, layout_string, output);
     tag_set_flags_dirty(); // we probably changed some window positions
     // arrange monitor
     HSMonitor* m = find_monitor_with_tag(tag);
@@ -233,16 +233,16 @@ int load_command(int argc, char** argv, GString* result) {
         return HERBST_INVALID_ARGUMENT;
     }
     if (rest[0] != '\0') { // if string was not parsed completely
-        g_string_append_printf(result,
+        g_string_append_printf(output,
             "%s: layout description was too long\n", argv[0]);
-        g_string_append_printf(result,
+        g_string_append_printf(output,
             "%s: \"%s\" has not been parsed\n", argv[0], rest);
         return HERBST_INVALID_ARGUMENT;
     }
     return 0;
 }
 
-int print_tag_status_command(int argc, char** argv, GString* result) {
+int print_tag_status_command(int argc, char** argv, GString* output) {
     int monitor_index = g_cur_monitor;
     if (argc >= 2) {
         monitor_index = atoi(argv[1]);
@@ -250,7 +250,7 @@ int print_tag_status_command(int argc, char** argv, GString* result) {
     monitor_index = CLAMP(monitor_index, 0, monitor_count());
     tag_update_flags();
     HSMonitor* monitor = monitor_with_index(monitor_index);
-    g_string_append_c(result, '\t');
+    g_string_append_c(output, '\t');
     for (int i = 0; i < g_tags->len; i++) {
         HSTag* tag = g_array_index(g_tags, HSTag*, i);
         // print flags
@@ -273,9 +273,9 @@ int print_tag_status_command(int argc, char** argv, GString* result) {
         if (tag->flags & TAG_FLAG_URGENT) {
             c = '!';
         }
-        g_string_append_c(result, c);
-        g_string_append(result, tag->name->str);
-        g_string_append_c(result, '\t');
+        g_string_append_c(output, c);
+        g_string_append(output, tag->name->str);
+        g_string_append_c(output, '\t');
     }
     return 0;
 }
@@ -358,7 +358,7 @@ int jumpto_command(int argc, char** argv) {
     return 0;
 }
 
-int getenv_command(int argc, char** argv, GString* result) {
+int getenv_command(int argc, char** argv, GString* output) {
     if (argc < 2) {
         return HERBST_INVALID_ARGUMENT;
     }
@@ -366,7 +366,7 @@ int getenv_command(int argc, char** argv, GString* result) {
     if (envvar == NULL) {
         return HERBST_ENV_UNSET;
     }
-    g_string_append_printf(result, "%s\n", envvar);
+    g_string_append_printf(output, "%s\n", envvar);
     return 0;
 }
 
diff --git a/src/monitor.c b/src/monitor.c
index d83b923..ee2ea0a 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -430,7 +430,7 @@ int move_monitor_command(int argc, char** argv) {
     return 0;
 }
 
-int monitor_rect_command(int argc, char** argv, GString* result) {
+int monitor_rect_command(int argc, char** argv, GString* output) {
     // usage: monitor_rect [[-p] INDEX]
     char* index_str = NULL;
     HSMonitor* m = NULL;
@@ -474,7 +474,7 @@ int monitor_rect_command(int argc, char** argv, GString* result) {
         rect.y += m->pad_up;
         rect.height -= m->pad_up + m->pad_down;
     }
-    g_string_append_printf(result, "%d %d %d %d",
+    g_string_append_printf(output, "%d %d %d %d",
                     rect.x, rect.y, rect.width, rect.height);
     return 0;
 }
diff --git a/src/monitor.h b/src/monitor.h
index 53b8b3e..98cd24d 100644
--- a/src/monitor.h
+++ b/src/monitor.h
@@ -65,7 +65,7 @@ int set_monitor_rects_command(int argc, char** argv, GString* output);
 int disjoin_rects_command(int argc, char** argv, GString* output);
 int set_monitor_rects(XRectangle* templates, size_t count);
 int move_monitor_command(int argc, char** argv);
-int monitor_rect_command(int argc, char** argv, GString* result);
+int monitor_rect_command(int argc, char** argv, GString* output);
 HSMonitor* get_current_monitor();
 int monitor_count();
 void monitor_set_tag(HSMonitor* monitor, struct HSTag* tag);
diff --git a/src/stack.c b/src/stack.c
index bd7f4a9..549b04a 100644
--- a/src/stack.c
+++ b/src/stack.c
@@ -105,20 +105,20 @@ void stack_remove_slice(HSStack* s, HSSlice* elem) {
     s->dirty = true;
 }
 
-static void slice_append_caption(HSTree root, GString* result) {
+static void slice_append_caption(HSTree root, GString* output) {
     HSSlice* slice = (HSSlice*)root;
     switch (slice->type) {
         case SLICE_WINDOW:
-            g_string_append_printf(result, "Window 0x%lx",
+            g_string_append_printf(output, "Window 0x%lx",
                                    slice->data.window);
             break;
         case SLICE_CLIENT:
-            g_string_append_printf(result, "Client 0x%lx \"%s\"",
+            g_string_append_printf(output, "Client 0x%lx \"%s\"",
                                    slice->data.client->window,
                                    slice->data.client->title->str);
             break;
         case SLICE_MONITOR:
-            g_string_append_printf(result, "Monitor %d with tag \"%s\"",
+            g_string_append_printf(output, "Monitor %d with tag \"%s\"",
                                    monitor_index_of(slice->data.monitor),
                                    slice->data.monitor->tag->name->str);
             break;
@@ -192,7 +192,7 @@ static void monitor_stack_append_caption(HSTree root, GString* output) {
     // g_string_append_printf(*output, "Stack of all monitors");
 }
 
-int print_stack_command(int argc, char** argv, GString* result) {
+int print_stack_command(int argc, char** argv, GString* output) {
     struct TmpLayer tl = {
         .stack = get_monitor_stack(),
         .layer = LAYER_NORMAL,
@@ -204,7 +204,7 @@ int print_stack_command(int argc, char** argv, GString* result) {
         .data           = &tl,
         .destructor     = NULL,
     };
-    tree_print_to(&intface, result);
+    tree_print_to(&intface, output);
     return 0;
 }
 
diff --git a/src/stack.h b/src/stack.h
index a4934b8..fd29b33 100644
--- a/src/stack.h
+++ b/src/stack.h
@@ -66,7 +66,7 @@ void stack_slice_remove_layer(HSStack* s, HSSlice* slice, HSLayer layer);
 bool stack_is_layer_empty(HSStack* s, HSLayer layer);
 void stack_clear_layer(HSStack* s, HSLayer layer);
 
-int print_stack_command(int argc, char** argv, GString* result);
+int print_stack_command(int argc, char** argv, GString* output);
 
 // returns the number of windows in this stack
 int stack_window_count(HSStack* stack);
diff --git a/src/tag.c b/src/tag.c
index 3445d85..65b85f7 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -225,7 +225,7 @@ int tag_remove_command(int argc, char** argv) {
     return 0;
 }
 
-int tag_set_floating_command(int argc, char** argv, GString* result) {
+int tag_set_floating_command(int argc, char** argv, GString* output) {
     // usage: floating [[tag] on|off|toggle]
     HSTag* tag = get_current_monitor()->tag;
     if (argc < 2) {
@@ -248,7 +248,7 @@ int tag_set_floating_command(int argc, char** argv, GString* result) {
 
     if (!strcmp(action, "status")) {
         // just print status
-        g_string_append(result, tag->floating ? "on" : "off");
+        g_string_append(output, tag->floating ? "on" : "off");
     } else {
         // assign new value and rearrange if needed
         tag->floating = new_value;
diff --git a/src/tag.h b/src/tag.h
index 9b6c6d4..d066f67 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -43,7 +43,7 @@ int tag_move_window_by_index_command(int argc, char** argv);
 void tag_move_focused_client(HSTag* target);
 void tag_move_client(struct HSClient* client,HSTag* target);
 int tag_remove_command(int argc, char** argv);
-int tag_set_floating_command(int argc, char** argv, GString* result);
+int tag_set_floating_command(int argc, char** argv, GString* output);
 void tag_update_focus_layer(HSTag* tag);
 void tag_foreach(void (*action)(HSTag*));
 void tag_update_each_focus_layer();
-- 
1.8.0