From: Fletcher T. Penney Date: Sat, 22 Jul 2017 14:22:46 +0000 (-0400) Subject: UPDATED: Tweak astyle settings X-Git-Tag: 6.2.0^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3f2b90a1d00b4dfa8c3898be4072bc32d7607fc;p=multimarkdown UPDATED: Tweak astyle settings --- diff --git a/.astylerc b/.astylerc index 9d6d34a..e90f01d 100644 --- a/.astylerc +++ b/.astylerc @@ -1,3 +1,7 @@ +# astyle configuration file +# http://astyle.sourceforge.net/astyle.html + + # Brace style --style=java @@ -5,28 +9,40 @@ # Indents --indent=tab=4 + # Switch statements --indent-switches + # Break long conditionals --break-after-logical + # Indent pre-processor directives --indent-preproc-block --indent-preproc-define --indent-preproc-cond + # Line endings --lineend=linux + # Add brackets to one-liners --add-brackets + # Pad with blank lines --break-blocks -# Pad around operators + +# Pad with spaces --pad-oper +--pad-header + + +# Pointers/References +--align-reference=name # Excludes diff --git a/Sources/libMultiMarkdown/aho-corasick.c b/Sources/libMultiMarkdown/aho-corasick.c index c08c2d9..35744c2 100644 --- a/Sources/libMultiMarkdown/aho-corasick.c +++ b/Sources/libMultiMarkdown/aho-corasick.c @@ -244,7 +244,7 @@ void Test_trie_search(CuTest* tc) { CuAssertIntEquals(tc, 40, trie_search_match_type(a, "food")); CuAssertIntEquals(tc, -1, trie_search(a, "foot")); - CuAssertIntEquals(tc, (unsigned short) -1, trie_search_match_type(a, "foot")); + CuAssertIntEquals(tc, (unsigned short) - 1, trie_search_match_type(a, "foot")); trie_free(a); } diff --git a/Sources/libMultiMarkdown/d_string.c b/Sources/libMultiMarkdown/d_string.c index f40aca6..1dd17eb 100644 --- a/Sources/libMultiMarkdown/d_string.c +++ b/Sources/libMultiMarkdown/d_string.c @@ -181,7 +181,7 @@ static void ensureStringBufferCanHold(DString * baseString, size_t newStringSize if (temp == NULL) { /* realloc failed */ - fprintf(stderr, "Error reallocating memory for d_string. Current buffer size %lu.\n",baseString->currentStringBufferSize); + fprintf(stderr, "Error reallocating memory for d_string. Current buffer size %lu.\n", baseString->currentStringBufferSize); exit(1); } @@ -223,7 +223,7 @@ void d_string_append_c_array(DString * baseString, const char * appendedChars, s size_t newSizeNeeded = baseString->currentStringLength + bytes; ensureStringBufferCanHold(baseString, newSizeNeeded); - memcpy(baseString->str + baseString->currentStringLength,appendedChars, bytes); + memcpy(baseString->str + baseString->currentStringLength, appendedChars, bytes); baseString->currentStringLength = newSizeNeeded; baseString->str[baseString->currentStringLength] = '\0'; diff --git a/Sources/libMultiMarkdown/epub.c b/Sources/libMultiMarkdown/epub.c index bb6c43b..1dbf7ff 100644 --- a/Sources/libMultiMarkdown/epub.c +++ b/Sources/libMultiMarkdown/epub.c @@ -169,7 +169,7 @@ char * epub_package_document(scratch_pad * scratch) { mmd_print_string_html(out, m->value, false); print_const("\n"); } else { - switch(scratch->language) { + switch (scratch->language) { case LC_ES: print_const("es\n"); break; @@ -547,7 +547,7 @@ DString * epub_create(const char * body, mmd_engine * e, const char * directory) // Finalize zip archive and extract data free(result->str); - status = mz_zip_writer_finalize_heap_archive(&zip, (void **) &(result->str), (size_t *) &(result->currentStringLength)); + status = mz_zip_writer_finalize_heap_archive(&zip, (void **) & (result->str), (size_t *) & (result->currentStringLength)); if (!status) { fprintf(stderr, "Error adding asset to zip.\n"); diff --git a/Sources/libMultiMarkdown/fodt.c b/Sources/libMultiMarkdown/fodt.c index a279158..54ffd7f 100644 --- a/Sources/libMultiMarkdown/fodt.c +++ b/Sources/libMultiMarkdown/fodt.c @@ -273,8 +273,8 @@ static char * correct_dimension_units(char *original) { result[i] = tolower(result[i]); } - if (strstr(&result[strlen(result)-2],"px")) { - result[strlen(result)-2] = '\0'; + if (strstr(&result[strlen(result) - 2], "px")) { + result[strlen(result) - 2] = '\0'; strcat(result, "pt"); } diff --git a/Sources/libMultiMarkdown/html.c b/Sources/libMultiMarkdown/html.c index 78db2b9..db1e365 100644 --- a/Sources/libMultiMarkdown/html.c +++ b/Sources/libMultiMarkdown/html.c @@ -253,7 +253,7 @@ static char * strip_dimension_units(char *original) { result[i] = tolower(result[i]); } - if (strstr(&result[strlen(result)-2],"px")) { + if (strstr(&result[strlen(result) - 2], "px")) { // Leave 'px' alone return result; } @@ -2131,7 +2131,7 @@ void mmd_start_complete_html(DString * out, const char * source, scratch_pad * s if (m) { printf(" lang=\"%s\"", m->value); } else { - switch(scratch->language) { + switch (scratch->language) { case LC_ES: print_const(" lang=\"es\""); break; @@ -2257,7 +2257,7 @@ void mmd_export_footnote_list_html(DString * out, const char * source, scratch_p scratch->footnote_para_counter = 0; // We need to know which block is the last one in the footnote - while(content) { + while (content) { if (content->type == BLOCK_PARA) { scratch->footnote_para_counter++; } @@ -2310,7 +2310,7 @@ void mmd_export_glossary_list_html(DString * out, const char * source, scratch_p scratch->footnote_para_counter = 0; // We need to know which block is the last one in the footnote - while(content) { + while (content) { if (content->type == BLOCK_PARA) { scratch->footnote_para_counter++; } @@ -2358,7 +2358,7 @@ void mmd_export_citation_list_html(DString * out, const char * source, scratch_p scratch->footnote_para_counter = 0; // We need to know which block is the last one in the footnote - while(content) { + while (content) { if (content->type == BLOCK_PARA) { scratch->footnote_para_counter++; } diff --git a/Sources/libMultiMarkdown/latex.c b/Sources/libMultiMarkdown/latex.c index 9b1bdb9..efa32f2 100644 --- a/Sources/libMultiMarkdown/latex.c +++ b/Sources/libMultiMarkdown/latex.c @@ -309,8 +309,8 @@ static char * correct_dimension_units(char *original) { result[i] = tolower(result[i]); } - if (strstr(&result[strlen(result)-2],"px")) { - result[strlen(result)-2] = '\0'; + if (strstr(&result[strlen(result) - 2], "px")) { + result[strlen(result) - 2] = '\0'; strcat(result, "pt"); } @@ -359,7 +359,7 @@ void mmd_export_image_latex(DString * out, const char * source, token * text, li // specified as percent width[strlen(width) - 1] = '\0'; temp_float = strtod(width, NULL); - temp_float = temp_float/100.0f; + temp_float = temp_float / 100.0f; printf("width=%.4f\\textwidth,", temp_float); } else { printf("width=%s,", width); @@ -377,7 +377,7 @@ void mmd_export_image_latex(DString * out, const char * source, token * text, li // specified as percent height[strlen(height) - 1] = '\0'; temp_float = strtod(height, NULL); - temp_float = temp_float/100.0f; + temp_float = temp_float / 100.0f; printf("height=%.4f\\textheight", temp_float); } else { printf("height=%s", height); @@ -1839,7 +1839,7 @@ parse_citation: case TABLE_CELL: if (t->next && t->next->type == TABLE_DIVIDER) { if (t->next->len > 1) { - printf("\\multicolumn{%lu}{",t->next->len); + printf("\\multicolumn{%lu}{", t->next->len); switch (scratch->table_alignment[scratch->table_cell_count]) { case 'l': diff --git a/Sources/libMultiMarkdown/mmd.c b/Sources/libMultiMarkdown/mmd.c index 4251009..634451c 100644 --- a/Sources/libMultiMarkdown/mmd.c +++ b/Sources/libMultiMarkdown/mmd.c @@ -540,7 +540,7 @@ void mmd_assign_line_type(mmd_engine * e, token * line) { break; case TEXT_NUMBER_POSS_LIST: - switch(source[line->child->next->start]) { + switch (source[line->child->next->start]) { case ' ': case '\t': line->type = LINE_LIST_ENUMERATED; @@ -562,9 +562,9 @@ void mmd_assign_line_type(mmd_engine * e, token * line) { case NON_INDENT_SPACE: t = line->child; - while(t->next && ((t->next->type == INDENT_SPACE) || - (t->next->type == INDENT_TAB) || - (t->next->type == NON_INDENT_SPACE))) { + while (t->next && ((t->next->type == INDENT_SPACE) || + (t->next->type == INDENT_TAB) || + (t->next->type == NON_INDENT_SPACE))) { tokens_prune(t->next, t->next); } @@ -686,7 +686,7 @@ void mmd_assign_line_type(mmd_engine * e, token * line) { // TODO: Should this be an empty list item instead?? line->type = LINE_PLAIN; } else { - switch(source[line->child->next->start]) { + switch (source[line->child->next->start]) { case ' ': case '\t': line->type = LINE_LIST_BULLETED; @@ -708,9 +708,9 @@ void mmd_assign_line_type(mmd_engine * e, token * line) { case NON_INDENT_SPACE: t = line->child; - while(t->next && ((t->next->type == INDENT_SPACE) || - (t->next->type == INDENT_TAB) || - (t->next->type == NON_INDENT_SPACE))) { + while (t->next && ((t->next->type == INDENT_SPACE) || + (t->next->type == INDENT_TAB) || + (t->next->type == NON_INDENT_SPACE))) { tokens_prune(t->next, t->next); } @@ -969,8 +969,8 @@ token * mmd_tokenize_string(mmd_engine * e, size_t start, size_t len, bool stop_ int type; // TOKEN type token * t; // Create tokens for incorporation - token * root = token_new(0,start,0); // Store the final parse tree here - token * line = token_new(0,start,0); // Store current line here + token * root = token_new(0, start, 0); // Store the final parse tree here + token * line = token_new(0, start, 0); // Store current line here const char * last_stop = &e->dstr->str[start]; // Remember where last token ended @@ -1039,7 +1039,7 @@ token * mmd_tokenize_string(mmd_engine * e, size_t start, size_t len, bool stop_ } } - line = token_new(0,s.cur - e->dstr->str,0); + line = token_new(0, s.cur - e->dstr->str, 0); break; default: @@ -1572,7 +1572,7 @@ void mmd_assign_ambidextrous_tokens_in_block(mmd_engine * e, token * block, size offset++; } - t->len = offset-t->start; + t->len = offset - t->start; t->can_close = 0; // Shift next token right and move those characters as child node @@ -1618,7 +1618,7 @@ void pair_emphasis_tokens(token * t) { (t->next->mate == closer->prev) && (t->type == t->next->type) && (t->next->mate != t) && - (t->start+t->len == t->next->start) && + (t->start + t->len == t->next->start) && (closer->start == closer->prev->start + closer->prev->len)) { // We have a strong pair @@ -1647,7 +1647,7 @@ void pair_emphasis_tokens(token * t) { } if (t->child != NULL) { - switch(t->type) { + switch (t->type) { case PAIR_BACKTICK: case PAIR_MATH: break; diff --git a/Sources/libMultiMarkdown/opendocument-content.c b/Sources/libMultiMarkdown/opendocument-content.c index 5017d05..18ac45f 100644 --- a/Sources/libMultiMarkdown/opendocument-content.c +++ b/Sources/libMultiMarkdown/opendocument-content.c @@ -398,8 +398,8 @@ static char * correct_dimension_units(char *original) { result[i] = tolower(result[i]); } - if (strstr(&result[strlen(result)-2],"px")) { - result[strlen(result)-2] = '\0'; + if (strstr(&result[strlen(result) - 2], "px")) { + result[strlen(result) - 2] = '\0'; strcat(result, "pt"); } diff --git a/Sources/libMultiMarkdown/opendocument.c b/Sources/libMultiMarkdown/opendocument.c index 0fe921f..c257175 100644 --- a/Sources/libMultiMarkdown/opendocument.c +++ b/Sources/libMultiMarkdown/opendocument.c @@ -954,7 +954,7 @@ DString * opendocument_core_file_create(const char * body, mmd_engine * e, const // Clean up free(result->str); - status = mz_zip_writer_finalize_heap_archive(zip, (void **) &(result->str), (size_t *) &(result->currentStringLength)); + status = mz_zip_writer_finalize_heap_archive(zip, (void **) & (result->str), (size_t *) & (result->currentStringLength)); if (!status) { fprintf(stderr, "Error finalizing zip archive.\n"); diff --git a/Sources/libMultiMarkdown/rng.c b/Sources/libMultiMarkdown/rng.c index fb78581..b725966 100644 --- a/Sources/libMultiMarkdown/rng.c +++ b/Sources/libMultiMarkdown/rng.c @@ -26,29 +26,29 @@ long ran_x[KK]; /* the generator state */ #ifdef __STDC__ - void ran_array(long aa[],int n) + void ran_array(long aa[], int n) #else - void ran_array(aa,n) /* put n new random numbers in aa */ + void ran_array(aa, n) /* put n new random numbers in aa */ long *aa; /* destination */ int n; /* array length (must be at least KK) */ #endif { - register int i,j; + register int i, j; - for (j=0; j=MM) { - ss-=MM-2; /* cyclic shift 29 bits */ + if (ss >= MM) { + ss -= MM - 2; /* cyclic shift 29 bits */ } } x[1]++; /* make x[1] (and only x[1]) odd */ - for (ss=seed&(MM-1),t=TT-1; t; ) { - for (j=KK-1; j>0; j--) { - x[j+j]=x[j], x[j+j-1]=0; /* "square" */ + for (ss = seed & (MM - 1), t = TT - 1; t; ) { + for (j = KK - 1; j > 0; j--) { + x[j + j] = x[j], x[j + j - 1] = 0; /* "square" */ } - for (j=KK+KK-2; j>=KK; j--) - x[j-(KK-LL)]=mod_diff(x[j-(KK-LL)],x[j]), - x[j-KK]=mod_diff(x[j-KK],x[j]); + for (j = KK + KK - 2; j >= KK; j--) + x[j - (KK - LL)] = mod_diff(x[j - (KK - LL)], x[j]), + x[j - KK] = mod_diff(x[j - KK], x[j]); if (is_odd(ss)) { /* "multiply by z" */ - for (j=KK; j>0; j--) { - x[j]=x[j-1]; + for (j = KK; j > 0; j--) { + x[j] = x[j - 1]; } - x[0]=x[KK]; /* shift the buffer cyclically */ - x[LL]=mod_diff(x[LL],x[KK]); + x[0] = x[KK]; /* shift the buffer cyclically */ + x[LL] = mod_diff(x[LL], x[KK]); } if (ss) { - ss>>=1; + ss >>= 1; } else { t--; } } - for (j=0; j=0? *ran_arr_ptr++: ran_arr_cycle()) long ran_arr_cycle() { - if (ran_arr_ptr==&ran_arr_dummy) { + if (ran_arr_ptr == &ran_arr_dummy) { ran_start(314159L); /* the user forgot to initialize */ } - ran_array(ran_arr_buf,QUALITY); - ran_arr_buf[KK]=-1; - ran_arr_ptr=ran_arr_buf+1; + ran_array(ran_arr_buf, QUALITY); + ran_arr_buf[KK] = -1; + ran_arr_ptr = ran_arr_buf + 1; return ran_arr_buf[0]; } diff --git a/Sources/libMultiMarkdown/textbundle.c b/Sources/libMultiMarkdown/textbundle.c index 916f45d..59adad1 100644 --- a/Sources/libMultiMarkdown/textbundle.c +++ b/Sources/libMultiMarkdown/textbundle.c @@ -268,7 +268,7 @@ void traverse_for_images(token * t, DString * text, mmd_engine * e, long * offse link * l; while (t) { - switch(t->type) { + switch (t->type) { case PAIR_BRACKET_IMAGE: if (t->next && t->next->type == PAIR_PAREN) { t = t->next; @@ -426,7 +426,7 @@ DString * textbundle_create(const char * body, mmd_engine * e, const char * dire // Finalize zip archive and extract data free(result->str); - status = mz_zip_writer_finalize_heap_archive(&zip, (void **) &(result->str), (size_t *) &(result->currentStringLength)); + status = mz_zip_writer_finalize_heap_archive(&zip, (void **) & (result->str), (size_t *) & (result->currentStringLength)); if (!status) { fprintf(stderr, "Error finalizing zip.\n"); diff --git a/Sources/libMultiMarkdown/transclude.c b/Sources/libMultiMarkdown/transclude.c index c32cd8f..d92da71 100644 --- a/Sources/libMultiMarkdown/transclude.c +++ b/Sources/libMultiMarkdown/transclude.c @@ -367,7 +367,7 @@ void mmd_transclude_source(DString * source, const char * search_path, const cha text[stop - start - 2] = '\0'; // Is this just {{TOC}} - if (strcmp("TOC",text) == 0) { + if (strcmp("TOC", text) == 0) { start = strstr(stop, "{{"); continue; } @@ -465,7 +465,7 @@ void mmd_transclude_source(DString * source, const char * search_path, const cha d_string_erase(buffer, 0, offset); } else { // Do we need to strip BOM? - if (strncmp(buffer->str, "\xef\xbb\xbf",3) == 0) { + if (strncmp(buffer->str, "\xef\xbb\xbf", 3) == 0) { d_string_erase(buffer, 0, 3); } } diff --git a/Sources/libMultiMarkdown/uuid.c b/Sources/libMultiMarkdown/uuid.c index 5426f2b..eed3cbe 100644 --- a/Sources/libMultiMarkdown/uuid.c +++ b/Sources/libMultiMarkdown/uuid.c @@ -113,33 +113,33 @@ char * uuid_string_from_bits(unsigned char * raw) { // http://stackoverflow.com/questions/322938/recommended-way-to-initialize-srand // http://www.concentric.net/~Ttwang/tech/inthash.htm unsigned long mix(unsigned long a, unsigned long b, unsigned long c) { - a=a-b; - a=a-c; - a=a^(c >> 13); - b=b-c; - b=b-a; - b=b^(a << 8); - c=c-a; - c=c-b; - c=c^(b >> 13); - a=a-b; - a=a-c; - a=a^(c >> 12); - b=b-c; - b=b-a; - b=b^(a << 16); - c=c-a; - c=c-b; - c=c^(b >> 5); - a=a-b; - a=a-c; - a=a^(c >> 3); - b=b-c; - b=b-a; - b=b^(a << 10); - c=c-a; - c=c-b; - c=c^(b >> 15); + a = a - b; + a = a - c; + a = a ^ (c >> 13); + b = b - c; + b = b - a; + b = b ^ (a << 8); + c = c - a; + c = c - b; + c = c ^ (b >> 13); + a = a - b; + a = a - c; + a = a ^ (c >> 12); + b = b - c; + b = b - a; + b = b ^ (a << 16); + c = c - a; + c = c - b; + c = c ^ (b >> 5); + a = a - b; + a = a - c; + a = a ^ (c >> 3); + b = b - c; + b = b - a; + b = b ^ (a << 10); + c = c - a; + c = c - b; + c = c ^ (b >> 15); return c; } diff --git a/Sources/libMultiMarkdown/writer.c b/Sources/libMultiMarkdown/writer.c index 421fd6e..701d927 100644 --- a/Sources/libMultiMarkdown/writer.c +++ b/Sources/libMultiMarkdown/writer.c @@ -409,8 +409,8 @@ char * label_from_string(const char * str) { next_char++; } } else if ((*str >= '0' && *str <= '9') || (*str >= 'A' && *str <= 'Z') - || (*str >= 'a' && *str <= 'z') || (*str == '.') || (*str== '_') - || (*str== '-') || (*str== ':')) { + || (*str >= 'a' && *str <= 'z') || (*str == '.') || (*str == '_') + || (*str == '-') || (*str == ':')) { // Allow 0-9, A-Z, a-z, ., _, -, : d_string_append_c(out, tolower(*str)); } @@ -1020,7 +1020,7 @@ void extract_from_paren(token * paren, const char * source, char ** url, char ** /// Create a link from an explicit link `[foo](bar)` link * explicit_link(scratch_pad * scratch, token * bracket, token * paren, const char * source) { - char * url_char =NULL; + char * url_char = NULL; char * title_char = NULL; char * attr_char = NULL; link * l = NULL; @@ -1346,10 +1346,10 @@ void process_definition_block(mmd_engine * e, token * block) { f = footnote_new(e->dstr->str, label, block->child, false); if (f && f->clean_text) { - memmove(f->clean_text, &(f->clean_text)[1],strlen(f->clean_text)); + memmove(f->clean_text, &(f->clean_text)[1], strlen(f->clean_text)); while (char_is_whitespace((f->clean_text)[0])) { - memmove(f->clean_text, &(f->clean_text)[1],strlen(f->clean_text)); + memmove(f->clean_text, &(f->clean_text)[1], strlen(f->clean_text)); } } @@ -1383,7 +1383,7 @@ void process_definition_block(mmd_engine * e, token * block) { f = footnote_new(e->dstr->str, label, block->child, false); if (f && f->clean_text) { - memmove(f->clean_text, &(f->clean_text)[1],strlen(f->clean_text)); + memmove(f->clean_text, &(f->clean_text)[1], strlen(f->clean_text)); } //if (f && f->label_text) @@ -1466,7 +1466,7 @@ token * manual_label_from_header(token * h, const char * source) { case PAIR_BRACKET: label = walker; - while(walker && walker->type == PAIR_BRACKET) { + while (walker && walker->type == PAIR_BRACKET) { walker = walker->prev; count++; } @@ -2579,7 +2579,7 @@ bool raw_filter_text_matches(char * pattern, short format) { } else if (strcmp("{=*}", pattern) == 0) { return true; } else { - switch(format) { + switch (format) { case FORMAT_HTML: if (strstr(pattern, "html")) { return true; diff --git a/Sources/multimarkdown/main.c b/Sources/multimarkdown/main.c index 18216c1..f8ce390 100644 --- a/Sources/multimarkdown/main.c +++ b/Sources/multimarkdown/main.c @@ -170,7 +170,7 @@ int main(int argc, char** argv) { a_format = arg_str0("t", "to", "FORMAT", "convert to FORMAT, FORMAT = html|latex|beamer|memoir|mmd|odt|fodt|epub|bundle|bundlezip"), a_o = arg_file0("o", "output", "FILE", "send output to FILE"), - a_rem3 = arg_rem("",""), + a_rem3 = arg_rem("", ""), a_accept = arg_lit0("a", "accept", "accept all CriticMarkup changes"), a_reject = arg_lit0("r", "reject", "reject all CriticMarkup changes"), @@ -186,7 +186,7 @@ int main(int argc, char** argv) { a_rem6 = arg_rem("", ""), - a_file = arg_filen(NULL, NULL, "", 0, argc+2, "read input from file(s) -- use stdin if no files given"), + a_file = arg_filen(NULL, NULL, "", 0, argc + 2, "read input from file(s) -- use stdin if no files given"), a_end = arg_end(20), };