+# astyle configuration file
+# http://astyle.sourceforge.net/astyle.html
+
+
# Brace style
--style=java
# 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
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);
}
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);
}
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';
mmd_print_string_html(out, m->value, false);
print_const("</dc:language>\n");
} else {
- switch(scratch->language) {
+ switch (scratch->language) {
case LC_ES:
print_const("<dc:language>es</dc:language>\n");
break;
// 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");
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");
}
result[i] = tolower(result[i]);
}
- if (strstr(&result[strlen(result)-2],"px")) {
+ if (strstr(&result[strlen(result) - 2], "px")) {
// Leave 'px' alone
return result;
}
if (m) {
printf(" lang=\"%s\"", m->value);
} else {
- switch(scratch->language) {
+ switch (scratch->language) {
case LC_ES:
print_const(" lang=\"es\"");
break;
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++;
}
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++;
}
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++;
}
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");
}
// 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);
// 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);
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':
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;
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);
}
// 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;
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);
}
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
}
}
- line = token_new(0,s.cur - e->dstr->str,0);
+ line = token_new(0, s.cur - e->dstr->str, 0);
break;
default:
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
(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
}
if (t->child != NULL) {
- switch(t->type) {
+ switch (t->type) {
case PAIR_BACKTICK:
case PAIR_MATH:
break;
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");
}
// 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");
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<KK; j++) {
- aa[j]=ran_x[j];
+ for (j = 0; j < KK; j++) {
+ aa[j] = ran_x[j];
}
- for (; j<n; j++) {
- aa[j]=mod_diff(aa[j-KK],aa[j-LL]);
+ for (; j < n; j++) {
+ aa[j] = mod_diff(aa[j - KK], aa[j - LL]);
}
- for (i=0; i<LL; i++,j++) {
- ran_x[i]=mod_diff(aa[j-KK],aa[j-LL]);
+ for (i = 0; i < LL; i++, j++) {
+ ran_x[i] = mod_diff(aa[j - KK], aa[j - LL]);
}
- for (; i<KK; i++,j++) {
- ran_x[i]=mod_diff(aa[j-KK],ran_x[i-LL]);
+ for (; i < KK; i++, j++) {
+ ran_x[i] = mod_diff(aa[j - KK], ran_x[i - LL]);
}
}
#define QUALITY 1009 /* recommended quality level for high-res use */
long ran_arr_buf[QUALITY];
-long ran_arr_dummy=-1, ran_arr_started=-1;
-long *ran_arr_ptr=&ran_arr_dummy; /* the next random number, or -1 */
+long ran_arr_dummy = -1, ran_arr_started = -1;
+long *ran_arr_ptr = &ran_arr_dummy; /* the next random number, or -1 */
#define TT 70 /* guaranteed separation between streams */
#define is_odd(x) ((x)&1) /* units bit of x */
long seed; /* selector for different streams */
#endif
{
- register int t,j;
- long x[KK+KK-1]; /* the preparation buffer */
- register long ss=(seed+2)&(MM-2);
+ register int t, j;
+ long x[KK + KK - 1]; /* the preparation buffer */
+ register long ss = (seed + 2) & (MM - 2);
- for (j=0; j<KK; j++) {
- x[j]=ss; /* bootstrap the buffer */
- ss<<=1;
+ for (j = 0; j < KK; j++) {
+ x[j] = ss; /* bootstrap the buffer */
+ ss <<= 1;
- if (ss>=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<LL; j++) {
- ran_x[j+KK-LL]=x[j];
+ for (j = 0; j < LL; j++) {
+ ran_x[j + KK - LL] = x[j];
}
- for (; j<KK; j++) {
- ran_x[j-LL]=x[j];
+ for (; j < KK; j++) {
+ ran_x[j - LL] = x[j];
}
- for (j=0; j<10; j++) {
- ran_array(x,KK+KK-1); /* warm things up */
+ for (j = 0; j < 10; j++) {
+ ran_array(x, KK + KK - 1); /* warm things up */
}
- ran_arr_ptr=&ran_arr_started;
+ ran_arr_ptr = &ran_arr_started;
}
#define ran_arr_next() (*ran_arr_ptr>=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];
}
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;
// 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");
text[stop - start - 2] = '\0';
// Is this just {{TOC}}
- if (strcmp("TOC",text) == 0) {
+ if (strcmp("TOC", text) == 0) {
start = strstr(stop, "{{");
continue;
}
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);
}
}
// 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;
}
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));
}
/// 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;
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));
}
}
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)
case PAIR_BRACKET:
label = walker;
- while(walker && walker->type == PAIR_BRACKET) {
+ while (walker && walker->type == PAIR_BRACKET) {
walker = walker->prev;
count++;
}
} else if (strcmp("{=*}", pattern) == 0) {
return true;
} else {
- switch(format) {
+ switch (format) {
case FORMAT_HTML:
if (strstr(pattern, "html")) {
return true;
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"),
a_rem6 = arg_rem("", ""),
- a_file = arg_filen(NULL, NULL, "<FILE>", 0, argc+2, "read input from file(s) -- use stdin if no files given"),
+ a_file = arg_filen(NULL, NULL, "<FILE>", 0, argc + 2, "read input from file(s) -- use stdin if no files given"),
a_end = arg_end(20),
};