summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@gnugeneration.com>2017-03-25 02:04:37 -0700
committerVito Caputo <vcaputo@gnugeneration.com>2017-03-25 02:04:37 -0700
commitb5e095e57232731b0c4bc93b33c7d78406ec3b1d (patch)
tree8a656b159fdd7fd149c3c87f073d693e8ab0fc51 /src
parent7ab5a513926846a3e20ef12d2888c5d2aea501a6 (diff)
*: restore old indentation of switch cases
In the course of applying the new style over the rest of the code I decided it's obnoxiouos and prefer the old way of indenting the cases one level from the switch. I know it wastes horizontal space and can see the value of flattening the cases with the switch, but once you start having variables at the start of the switch body, and blocked cases, it just starts becoming quite unattractive without the indentation.
Diffstat (limited to 'src')
-rw-r--r--src/libvmon/defs/_begin.def310
-rw-r--r--src/libvmon/vmon.c80
-rw-r--r--src/vmon.c20
-rw-r--r--src/window.c14
-rw-r--r--src/xwindow.c24
5 files changed, 224 insertions, 224 deletions
diff --git a/src/libvmon/defs/_begin.def b/src/libvmon/defs/_begin.def
index f6b441a..c8be434 100644
--- a/src/libvmon/defs/_begin.def
+++ b/src/libvmon/defs/_begin.def
@@ -175,27 +175,27 @@
*/
#define vmon_datum_str(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case VMON_PARSER_DELIM:\
- /* store accumulated string, reset tmp, and advance */\
- if ((*store)->_name) {\
- if ( strncmp((*store)->name, _array, var_array_len) ||\
- (*store)->name[var_array_len] != '\0') {\
- BITSET((*store)->changed, VMON_ ## _sym);\
- changes++;\
+ case VMON_PARSER_DELIM:\
+ /* store accumulated string, reset tmp, and advance */\
+ if ((*store)->_name) {\
+ if ( strncmp((*store)->name, _array, var_array_len) ||\
+ (*store)->name[var_array_len] != '\0') {\
+ BITSET((*store)->changed, VMON_ ## _sym);\
+ changes++;\
+ }\
+ free((*store)->name);\
+ } else {\
+ BITSET((*store)->changed, VMON_ ## _sym);\
+ changes++;\
}\
- free((*store)->name);\
- } else {\
- BITSET((*store)->changed, VMON_ ## _sym);\
- changes++;\
- }\
- (*store)->_name = strndup(var_array, var_array_len);\
- var_array_len = 0;\
- state++;\
- break;\
- default:\
- /* accumulate string */\
- var_array[var_array_len++] = input;\
- break;\
+ (*store)->_name = strndup(var_array, var_array_len);\
+ var_array_len = 0;\
+ state++;\
+ break;\
+ default:\
+ /* accumulate string */\
+ var_array[var_array_len++] = input;\
+ break;\
}\
break;
@@ -219,27 +219,27 @@
#define vmon_datum_int(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '-':\
- /* TODO: we don't verify the '-' is leading... */\
- var_isneg = 1;\
- break;\
- case '0' ... '9':\
- var_int *= 10;\
- var_int += input - '0';\
- break;\
- default:\
- if (var_isneg) {\
- var_int = -var_int;\
- var_isneg = 0;\
- }\
- if ((*store)->_name != var_int) {\
- BITSET((*store)->changed, VMON_ ## _sym);\
- changes++;\
- (*store)->_name = var_int;\
- }\
- var_int = 0;\
- state++;\
- break;\
+ case '-':\
+ /* TODO: we don't verify the '-' is leading... */\
+ var_isneg = 1;\
+ break;\
+ case '0' ... '9':\
+ var_int *= 10;\
+ var_int += input - '0';\
+ break;\
+ default:\
+ if (var_isneg) {\
+ var_int = -var_int;\
+ var_isneg = 0;\
+ }\
+ if ((*store)->_name != var_int) {\
+ BITSET((*store)->changed, VMON_ ## _sym);\
+ changes++;\
+ (*store)->_name = var_int;\
+ }\
+ var_int = 0;\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -247,19 +247,19 @@
#define vmon_datum_uint(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- var_uint *= 10;\
- var_uint += input - '0';\
- break;\
- default:\
- if ((*store)->_name != var_uint) {\
- BITSET((*store)->changed, VMON_ ## _sym);\
- changes++;\
- (*store)->_name = var_uint;\
- }\
- var_uint = 0;\
- state++;\
- break;\
+ case '0' ... '9':\
+ var_uint *= 10;\
+ var_uint += input - '0';\
+ break;\
+ default:\
+ if ((*store)->_name != var_uint) {\
+ BITSET((*store)->changed, VMON_ ## _sym);\
+ changes++;\
+ (*store)->_name = var_uint;\
+ }\
+ var_uint = 0;\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -267,19 +267,19 @@
#define vmon_datum_ulong(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- var_ulong *= 10;\
- var_ulong += input - '0';\
- break;\
- default:\
- if ((*store)->_name != var_ulong) {\
- BITSET((*store)->changed, VMON_ ## _sym);\
- changes++;\
- (*store)->_name = var_ulong;\
- }\
- var_ulong = 0;\
- state++;\
- break;\
+ case '0' ... '9':\
+ var_ulong *= 10;\
+ var_ulong += input - '0';\
+ break;\
+ default:\
+ if ((*store)->_name != var_ulong) {\
+ BITSET((*store)->changed, VMON_ ## _sym);\
+ changes++;\
+ (*store)->_name = var_ulong;\
+ }\
+ var_ulong = 0;\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -287,19 +287,19 @@
#define vmon_datum_ulonglong(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- var_ulonglong *= 10;\
- var_ulonglong += input - '0';\
- break;\
- default:\
- if ((*store)->_name != var_ulonglong) {\
- BITSET((*store)->changed, VMON_ ## _sym);\
- changes++;\
- (*store)->_name = var_ulonglong;\
- }\
- var_ulonglong = 0;\
- state++;\
- break;\
+ case '0' ... '9':\
+ var_ulonglong *= 10;\
+ var_ulonglong += input - '0';\
+ break;\
+ default:\
+ if ((*store)->_name != var_ulonglong) {\
+ BITSET((*store)->changed, VMON_ ## _sym);\
+ changes++;\
+ (*store)->_name = var_ulonglong;\
+ }\
+ var_ulonglong = 0;\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -307,27 +307,27 @@
#define vmon_datum_long(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '-':\
- /* TODO: we dont verify the '-' is leading... */\
- var_isneg = 1;\
- break;\
- case '0' ... '9':\
- var_long *= 10;\
- var_long += input - '0';\
- break;\
- default:\
- if (var_isneg) {\
- var_long = -var_long;\
- var_isneg = 0;\
- }\
- if ((*store)->_name != var_long) {\
- BITSET((*store)->changed, VMON_ ## _sym);\
- changes++;\
- (*store)->_name = var_long;\
- }\
- var_long = 0;\
- state++;\
- break;\
+ case '-':\
+ /* TODO: we dont verify the '-' is leading... */\
+ var_isneg = 1;\
+ break;\
+ case '0' ... '9':\
+ var_long *= 10;\
+ var_long += input - '0';\
+ break;\
+ default:\
+ if (var_isneg) {\
+ var_long = -var_long;\
+ var_isneg = 0;\
+ }\
+ if ((*store)->_name != var_long) {\
+ BITSET((*store)->changed, VMON_ ## _sym);\
+ changes++;\
+ (*store)->_name = var_long;\
+ }\
+ var_long = 0;\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -335,27 +335,27 @@
#define vmon_datum_longlong(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '-':\
- /* TODO: we dont verify the '-' is leading... */\
- var_isneg = 1;\
- break;\
- case '0' ... '9':\
- var_longlong *= 10;\
- var_longlong += input - '0';\
- break;\
- default:\
- if (var_isneg) {\
- var_longlong = -var_longlong;\
- var_isneg = 0;\
- }\
- if ((*store)->_name != var_longlong) {\
- BITSET((*store)->changed, VMON_ ## _sym);\
- changes++;\
- (*store)->_name = var_longlong;\
- }\
- var_longlong = 0;\
- state++;\
- break;\
+ case '-':\
+ /* TODO: we dont verify the '-' is leading... */\
+ var_isneg = 1;\
+ break;\
+ case '0' ... '9':\
+ var_longlong *= 10;\
+ var_longlong += input - '0';\
+ break;\
+ default:\
+ if (var_isneg) {\
+ var_longlong = -var_longlong;\
+ var_isneg = 0;\
+ }\
+ if ((*store)->_name != var_longlong) {\
+ BITSET((*store)->changed, VMON_ ## _sym);\
+ changes++;\
+ (*store)->_name = var_longlong;\
+ }\
+ var_longlong = 0;\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -415,12 +415,12 @@
#define vmon_omit_int(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- case '-':\
- break;\
- default:\
- state++;\
- break;\
+ case '0' ... '9':\
+ case '-':\
+ break;\
+ default:\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -428,11 +428,11 @@
#define vmon_omit_uint(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- break;\
- default:\
- state++;\
- break;\
+ case '0' ... '9':\
+ break;\
+ default:\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -440,11 +440,11 @@
#define vmon_omit_ulong(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- break;\
- default:\
- state++;\
- break;\
+ case '0' ... '9':\
+ break;\
+ default:\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -452,11 +452,11 @@
#define vmon_omit_ulonglong(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- break;\
- default:\
- state++;\
- break;\
+ case '0' ... '9':\
+ break;\
+ default:\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -464,12 +464,12 @@
#define vmon_omit_long(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- case '-':\
- break;\
- default:\
- state++;\
- break;\
+ case '0' ... '9':\
+ case '-':\
+ break;\
+ default:\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
@@ -477,12 +477,12 @@
#define vmon_omit_longlong(_name, _sym, _label, _desc) case VMON_PARSER_STATE_ ## _sym:\
switch (input) {\
- case '0' ... '9':\
- case '-':\
- break;\
- default:\
- state++;\
- break;\
+ case '0' ... '9':\
+ case '-':\
+ break;\
+ default:\
+ state++;\
+ break;\
}\
if (state == VMON_PARSER_STATE_ ## _sym)\
/* we want to fall-through when the state advances */\
diff --git a/src/libvmon/vmon.c b/src/libvmon/vmon.c
index 73afd17..fead0a8 100644
--- a/src/libvmon/vmon.c
+++ b/src/libvmon/vmon.c
@@ -341,9 +341,9 @@ _retry:
#define VMON_PARSER_DELIM ' ' /* TODO XXX eliminate the need for this, I want the .def's to include all the data format knowledge */
#define VMON_IMPLEMENT_PARSER
#include "defs/proc_stat.def"
- default:
- /* we're finished parsing once we've fallen off the end of the symbols */
- goto _out; /* this saves us the EOF read syscall */
+ default:
+ /* we're finished parsing once we've fallen off the end of the symbols */
+ goto _out; /* this saves us the EOF read syscall */
}
}
}
@@ -402,37 +402,37 @@ static int proc_follow_children(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_follo
for (i = 0; i < len; i++) {
switch (vmon->buf[i]) {
- case '0' ... '9':
- /* PID component, accumulate it */
- child_pid *= 10;
- child_pid += (vmon->buf[i] - '0');
- break;
+ case '0' ... '9':
+ /* PID component, accumulate it */
+ child_pid *= 10;
+ child_pid += (vmon->buf[i] - '0');
+ break;
- case ' ':
- /* separator, terminates a PID, search for it in the childrens list */
- found = 0;
- list_for_each(cur, start) {
- if (list_entry(cur, vmon_proc_t, siblings)->pid == child_pid) {
- /* found the child already monitored, update its generation number and stop searching */
- tmp = list_entry(cur, vmon_proc_t, siblings);
- tmp->generation = vmon->generation;
- found = 1;
- tmp->is_new = 0;
- break;
+ case ' ':
+ /* separator, terminates a PID, search for it in the childrens list */
+ found = 0;
+ list_for_each(cur, start) {
+ if (list_entry(cur, vmon_proc_t, siblings)->pid == child_pid) {
+ /* found the child already monitored, update its generation number and stop searching */
+ tmp = list_entry(cur, vmon_proc_t, siblings);
+ tmp->generation = vmon->generation;
+ found = 1;
+ tmp->is_new = 0;
+ break;
+ }
}
- }
- if (found || (tmp = vmon_proc_monitor(vmon, proc, child_pid, proc->wants, NULL, NULL))) {
- /* position the process in the siblings list, and update the start */
- /* move to front breaks vwm, we rely on the stale processes maintaining their position! maybe make it an option to vmon_init() since it can be a useful optimization. */
+ if (found || (tmp = vmon_proc_monitor(vmon, proc, child_pid, proc->wants, NULL, NULL))) {
+ /* position the process in the siblings list, and update the start */
+ /* move to front breaks vwm, we rely on the stale processes maintaining their position! maybe make it an option to vmon_init() since it can be a useful optimization. */
#ifdef _MOVE_STALE_TO_FRONT
- list_move_tail(&tmp->siblings, start);
+ list_move_tail(&tmp->siblings, start);
#endif
- start = &tmp->siblings;
- } /* else { vmon_proc_monitor failed just move on } */
+ start = &tmp->siblings;
+ } /* else { vmon_proc_monitor failed just move on } */
- child_pid = 0;
- break;
+ child_pid = 0;
+ break;
}
}
}
@@ -815,9 +815,9 @@ static sample_ret_t proc_sample_vm(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_vm
switch (state) {
#define VMON_IMPLEMENT_PARSER
#include "defs/proc_vm.def"
- default:
- /* we're finished parsing once we've fallen off the end of the symbols */
- goto _out; /* this saves us the EOF read syscall */
+ default:
+ /* we're finished parsing once we've fallen off the end of the symbols */
+ goto _out; /* this saves us the EOF read syscall */
}
}
}
@@ -872,9 +872,9 @@ static sample_ret_t proc_sample_io(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_io
switch (state) {
#define VMON_IMPLEMENT_PARSER
#include "defs/proc_io.def"
- default:
- /* we're finished parsing once we've fallen off the end of the symbols */
- goto _out; /* this saves us the EOF read syscall */
+ default:
+ /* we're finished parsing once we've fallen off the end of the symbols */
+ goto _out; /* this saves us the EOF read syscall */
}
}
}
@@ -919,9 +919,9 @@ static sample_ret_t sys_sample_stat(vmon_t *vmon, vmon_sys_stat_t **store)
#define VMON_PARSER_DELIM ' ' /* TODO XXX eliminate the need for this, I want the .def's to include all the data format knowledge */
#define VMON_IMPLEMENT_PARSER
#include "defs/sys_stat.def"
- default:
- /* we're finished parsing once we've fallen off the end of the symbols */
- goto _out; /* this saves us the EOF read syscall */
+ default:
+ /* we're finished parsing once we've fallen off the end of the symbols */
+ goto _out; /* this saves us the EOF read syscall */
}
}
}
@@ -969,9 +969,9 @@ static sample_ret_t sys_sample_vm(vmon_t *vmon, vmon_sys_vm_t **store)
#define VMON_PARSER_DELIM ' ' /* TODO XXX eliminate the need for this, I want the .def's to include all the data format knowledge */
#define VMON_IMPLEMENT_PARSER
#include "defs/sys_vm.def"
- default:
- /* we're finished parsing once we've fallen off the end of the symbols */
- goto _out; /* this saves us the EOF read syscall */
+ default:
+ /* we're finished parsing once we've fallen off the end of the symbols */
+ goto _out; /* this saves us the EOF read syscall */
}
}
}
diff --git a/src/vmon.c b/src/vmon.c
index c554a50..d31af2d 100644
--- a/src/vmon.c
+++ b/src/vmon.c
@@ -383,16 +383,16 @@ static void vmon_process_event(vmon_t *vmon)
XNextEvent(vmon->xserver->display, &ev);
switch (ev.type) {
- case ConfigureNotify:
- vmon_resize(vmon, ev.xconfigure.width, ev.xconfigure.height);
- vwm_overlay_compose(vmon->overlays, vmon->overlay, NULL);
- vwm_overlay_render(vmon->overlays, vmon->overlay, PictOpSrc, vmon->picture, 0, 0, vmon->width, vmon->height);
- break;
- case Expose:
- vwm_overlay_render(vmon->overlays, vmon->overlay, PictOpSrc, vmon->picture, 0, 0, vmon->width, vmon->height);
- break;
- default:
- VWM_TRACE("unhandled event: %x\n", ev.type);
+ case ConfigureNotify:
+ vmon_resize(vmon, ev.xconfigure.width, ev.xconfigure.height);
+ vwm_overlay_compose(vmon->overlays, vmon->overlay, NULL);
+ vwm_overlay_render(vmon->overlays, vmon->overlay, PictOpSrc, vmon->picture, 0, 0, vmon->width, vmon->height);
+ break;
+ case Expose:
+ vwm_overlay_render(vmon->overlays, vmon->overlay, PictOpSrc, vmon->picture, 0, 0, vmon->width, vmon->height);
+ break;
+ default:
+ VWM_TRACE("unhandled event: %x\n", ev.type);
}
}
diff --git a/src/window.c b/src/window.c
index 4d4463b..ba8d0b4 100644
--- a/src/window.c
+++ b/src/window.c
@@ -83,15 +83,15 @@ vwm_window_t * vwm_win_lookup(vwm_t *vwm, Window win)
vwm_window_t * vwm_win_focused(vwm_t *vwm)
{
switch (vwm->focused_context) {
- case VWM_CONTEXT_SHELF:
- return vwm->focused_shelf;
+ case VWM_CONTEXT_SHELF:
+ return vwm->focused_shelf;
- case VWM_CONTEXT_DESKTOP:
- return vwm->focused_desktop->focused_window;
+ case VWM_CONTEXT_DESKTOP:
+ return vwm->focused_desktop->focused_window;
- default:
- VWM_BUG("Unsupported context");
- assert(0);
+ default:
+ VWM_BUG("Unsupported context");
+ assert(0);
}
}
diff --git a/src/xwindow.c b/src/xwindow.c
index 1564cfe..3812ff2 100644
--- a/src/xwindow.c
+++ b/src/xwindow.c
@@ -72,18 +72,18 @@ int vwm_xwin_is_mapped(vwm_t *vwm, vwm_xwindow_t *xwin)
return xwin->client_mapped;
switch (vwm->focused_context) {
- case VWM_CONTEXT_SHELF:
- if (vwm->focused_shelf == vwin)
- ret = 1;
- break;
-
- case VWM_CONTEXT_DESKTOP:
- if (vwm->focused_desktop == vwin->desktop && !vwin->shelved)
- ret = 1;
- break;
-
- default:
- VWM_BUG("Unsupported context");
+ case VWM_CONTEXT_SHELF:
+ if (vwm->focused_shelf == vwin)
+ ret = 1;
+ break;
+
+ case VWM_CONTEXT_DESKTOP:
+ if (vwm->focused_desktop == vwin->desktop && !vwin->shelved)
+ ret = 1;
+ break;
+
+ default:
+ VWM_BUG("Unsupported context");
}
return ret;
© All Rights Reserved