From 890d6b3299a65c28fe9236223a2286c5909b55d3 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sun, 26 Dec 2010 01:12:20 +0100 Subject: [PATCH] Update coding standard --- callbacks.c | 3 +-- ft/document.c | 17 +++++++++++++---- ft/pdf/pdf.c | 46 +++++++++++++++++++++++++--------------------- shortcuts.c | 3 +-- utils.c | 14 +++++++------- 5 files changed, 47 insertions(+), 36 deletions(-) diff --git a/callbacks.c b/callbacks.c index 8c299a6..07c0f5e 100644 --- a/callbacks.c +++ b/callbacks.c @@ -26,8 +26,7 @@ buffer_changed(girara_session_t* session) if(buffer) { girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, buffer); free(buffer); - } - else { + } else { girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, ""); } } diff --git a/ft/document.c b/ft/document.c index a0dacad..b0b1b91 100644 --- a/ft/document.c +++ b/ft/document.c @@ -302,24 +302,33 @@ zathura_page_render(zathura_page_t* page) zathura_index_element_t* zathura_index_element_new(const char* title) { - if (!title) + if(!title) { return NULL; + } zathura_index_element_t* res = g_malloc0(sizeof(zathura_index_element_t)); - if (!res) + + if(!res) { return NULL; + } + res->title = g_strdup(title); + return res; } void zathura_index_element_free(zathura_index_element_t* index) { - if (!index) + if(!index) { return; + } g_free(index->title); - if (index->type == ZATHURA_LINK_EXTERNAL) + + if(index->type == ZATHURA_LINK_EXTERNAL) { g_free(index->target.uri); + } + g_free(index); } diff --git a/ft/pdf/pdf.c b/ft/pdf/pdf.c index 0673015..2c89879 100644 --- a/ft/pdf/pdf.c +++ b/ft/pdf/pdf.c @@ -89,63 +89,67 @@ pdf_document_free(zathura_document_t* document) static void build_index(pdf_document_t* pdf, girara_tree_node_t* root, PopplerIndexIter* iter) { - if (!root || !iter) + if(!root || !iter) { return; + } do { PopplerAction* action = poppler_index_iter_get_action(iter); - if (!action) + + if(!action) { continue; + } gchar* markup = g_markup_escape_text(action->any.title, -1); zathura_index_element_t* indexelement = zathura_index_element_new(markup); - if (action->type == POPPLER_ACTION_URI) - { + + if(action->type == POPPLER_ACTION_URI) { indexelement->type = ZATHURA_LINK_EXTERNAL; indexelement->target.uri = g_strdup(action->uri.uri); - } - else if (action->type == POPPLER_ACTION_GOTO_DEST) - { + } else if (action->type == POPPLER_ACTION_GOTO_DEST) { indexelement->type = ZATHURA_LINK_TO_PAGE; - if (action->goto_dest.dest->type == POPPLER_DEST_NAMED) - { + + if(action->goto_dest.dest->type == POPPLER_DEST_NAMED) { PopplerDest* dest = poppler_document_find_dest(pdf->document, action->goto_dest.dest->named_dest); - if (dest) - { + if(dest) { indexelement->target.page_number = dest->page_num - 1; poppler_dest_free(dest); } - } - else + } else { indexelement->target.page_number = action->goto_dest.dest->page_num - 1; - } - else - { + } + } else { poppler_action_free(action); zathura_index_element_free(indexelement); continue; } + poppler_action_free(action); girara_tree_node_t* node = girara_node_append_data(root, indexelement); - PopplerIndexIter* child = poppler_index_iter_get_child(iter); - if (child) + PopplerIndexIter* child = poppler_index_iter_get_child(iter); + + if(child) { build_index(pdf, node, child); + } + poppler_index_iter_free(child); + } while (poppler_index_iter_next(iter)); } girara_tree_node_t* pdf_document_index_generate(zathura_document_t* document) { - if (!document || !document->data) { + if(!document || !document->data) { return NULL; } pdf_document_t* pdf_document = (pdf_document_t*) document->data; - PopplerIndexIter* iter = poppler_index_iter_new(pdf_document->document); - if (!iter) { + PopplerIndexIter* iter = poppler_index_iter_new(pdf_document->document); + + if(!iter) { // XXX: error message? return NULL; } diff --git a/shortcuts.c b/shortcuts.c index ac1429f..db0ef77 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -81,8 +81,7 @@ sc_navigate(girara_session_t* session, girara_argument_t* argument) if(argument->n == NEXT) { new_page = (new_page + 1) % number_of_pages; - } - else if(argument->n == PREVIOUS) { + } else if(argument->n == PREVIOUS) { new_page = (new_page + number_of_pages - 1) % number_of_pages; } diff --git a/utils.c b/utils.c index 5737152..c03a5c9 100644 --- a/utils.c +++ b/utils.c @@ -31,10 +31,11 @@ file_get_extension(const char* path) unsigned int i = strlen(path); for(; i > 0; i--) { - if(*(path + i) != '.') + if(*(path + i) != '.') { continue; - else + } else { break; + } } if(!i) { @@ -52,23 +53,22 @@ execute_command(char* const argv[], char** output) } int p[2]; - if(pipe(p)) + if(pipe(p)) { return -1; + } pid_t pid = fork(); if(pid == -1) { // failure return false; - } - else if(pid == 0) { // child + } else if(pid == 0) { // child dup2(p[1], 1); close(p[0]); if(execvp(argv[0], argv) == -1) { return false; } - } - else { // parent + } else { // parent dup2(p[0], 0); close(p[1]);