format **/*.c with clang-format-3.5
This has multiple effects: 1) The i3 codebase is now consistently formatted. clang-format uncovered plenty of places where inconsistent code made it into our code base. 2) When writing code, you don’t need to think or worry about our coding style. Write it in yours, then run clang-format-3.5 3) When submitting patches, we don’t need to argue about coding style. The basic idea is that we don’t want to care about _how_ we write the code, but _what_ it does :). The coding style that we use is defined in the .clang-format config file and is based on the google style, but adapted in such a way that the number of modifications to the i3 code base is minimal.
This commit is contained in:
@ -20,10 +20,10 @@
|
||||
/* A datatype to pass through the callbacks to save the state */
|
||||
struct outputs_json_params {
|
||||
struct outputs_head *outputs;
|
||||
i3_output *outputs_walk;
|
||||
char *cur_key;
|
||||
char *json;
|
||||
bool in_rect;
|
||||
i3_output *outputs_walk;
|
||||
char *cur_key;
|
||||
char *json;
|
||||
bool in_rect;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -31,7 +31,7 @@ struct outputs_json_params {
|
||||
*
|
||||
*/
|
||||
static int outputs_null_cb(void *params_) {
|
||||
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||
struct outputs_json_params *params = (struct outputs_json_params *)params_;
|
||||
|
||||
FREE(params->cur_key);
|
||||
|
||||
@ -43,7 +43,7 @@ static int outputs_null_cb(void *params_) {
|
||||
*
|
||||
*/
|
||||
static int outputs_boolean_cb(void *params_, int val) {
|
||||
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||
struct outputs_json_params *params = (struct outputs_json_params *)params_;
|
||||
|
||||
if (!strcmp(params->cur_key, "active")) {
|
||||
params->outputs_walk->active = val;
|
||||
@ -65,34 +65,34 @@ static int outputs_boolean_cb(void *params_, int val) {
|
||||
*
|
||||
*/
|
||||
static int outputs_integer_cb(void *params_, long long val) {
|
||||
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||
struct outputs_json_params *params = (struct outputs_json_params *)params_;
|
||||
|
||||
if (!strcmp(params->cur_key, "current_workspace")) {
|
||||
params->outputs_walk->ws = (int) val;
|
||||
params->outputs_walk->ws = (int)val;
|
||||
FREE(params->cur_key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(params->cur_key, "x")) {
|
||||
params->outputs_walk->rect.x = (int) val;
|
||||
params->outputs_walk->rect.x = (int)val;
|
||||
FREE(params->cur_key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(params->cur_key, "y")) {
|
||||
params->outputs_walk->rect.y = (int) val;
|
||||
params->outputs_walk->rect.y = (int)val;
|
||||
FREE(params->cur_key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(params->cur_key, "width")) {
|
||||
params->outputs_walk->rect.w = (int) val;
|
||||
params->outputs_walk->rect.w = (int)val;
|
||||
FREE(params->cur_key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(params->cur_key, "height")) {
|
||||
params->outputs_walk->rect.h = (int) val;
|
||||
params->outputs_walk->rect.h = (int)val;
|
||||
FREE(params->cur_key);
|
||||
return 1;
|
||||
}
|
||||
@ -105,11 +105,11 @@ static int outputs_integer_cb(void *params_, long long val) {
|
||||
*
|
||||
*/
|
||||
static int outputs_string_cb(void *params_, const unsigned char *val, size_t len) {
|
||||
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||
struct outputs_json_params *params = (struct outputs_json_params *)params_;
|
||||
|
||||
if (!strcmp(params->cur_key, "current_workspace")) {
|
||||
char *copy = smalloc(sizeof(const unsigned char) * (len + 1));
|
||||
strncpy(copy, (const char*) val, len);
|
||||
strncpy(copy, (const char *)val, len);
|
||||
copy[len] = '\0';
|
||||
|
||||
char *end;
|
||||
@ -128,7 +128,7 @@ static int outputs_string_cb(void *params_, const unsigned char *val, size_t len
|
||||
}
|
||||
|
||||
char *name = smalloc(sizeof(const unsigned char) * (len + 1));
|
||||
strncpy(name, (const char*) val, len);
|
||||
strncpy(name, (const char *)val, len);
|
||||
name[len] = '\0';
|
||||
|
||||
params->outputs_walk->name = name;
|
||||
@ -143,7 +143,7 @@ static int outputs_string_cb(void *params_, const unsigned char *val, size_t len
|
||||
*
|
||||
*/
|
||||
static int outputs_start_map_cb(void *params_) {
|
||||
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||
struct outputs_json_params *params = (struct outputs_json_params *)params_;
|
||||
i3_output *new_output = NULL;
|
||||
|
||||
if (params->cur_key == NULL) {
|
||||
@ -176,7 +176,7 @@ static int outputs_start_map_cb(void *params_) {
|
||||
*
|
||||
*/
|
||||
static int outputs_end_map_cb(void *params_) {
|
||||
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||
struct outputs_json_params *params = (struct outputs_json_params *)params_;
|
||||
if (params->in_rect) {
|
||||
params->in_rect = false;
|
||||
/* Ignore the end of a rect */
|
||||
@ -225,11 +225,11 @@ static int outputs_end_map_cb(void *params_) {
|
||||
*
|
||||
*/
|
||||
static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
|
||||
struct outputs_json_params *params = (struct outputs_json_params*) params_;
|
||||
struct outputs_json_params *params = (struct outputs_json_params *)params_;
|
||||
FREE(params->cur_key);
|
||||
|
||||
params->cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1));
|
||||
strncpy(params->cur_key, (const char*) keyVal, keyLen);
|
||||
strncpy(params->cur_key, (const char *)keyVal, keyLen);
|
||||
params->cur_key[keyLen] = '\0';
|
||||
|
||||
return 1;
|
||||
@ -269,9 +269,9 @@ void parse_outputs_json(char *json) {
|
||||
|
||||
yajl_handle handle;
|
||||
yajl_status state;
|
||||
handle = yajl_alloc(&outputs_callbacks, NULL, (void*) ¶ms);
|
||||
handle = yajl_alloc(&outputs_callbacks, NULL, (void *)¶ms);
|
||||
|
||||
state = yajl_parse(handle, (const unsigned char*) json, strlen(json));
|
||||
state = yajl_parse(handle, (const unsigned char *)json, strlen(json));
|
||||
|
||||
/* FIXME: Propper errorhandling for JSON-parsing */
|
||||
switch (state) {
|
||||
@ -296,7 +296,7 @@ i3_output *get_output_by_name(char *name) {
|
||||
if (name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
SLIST_FOREACH(walk, outputs, slist) {
|
||||
SLIST_FOREACH (walk, outputs, slist) {
|
||||
if (!strcmp(walk->name, name)) {
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user