mirror of
https://github.com/fletcher/MultiMarkdown-6.git
synced 2024-10-05 02:57:19 +03:00
FIXED: Fix memory leaks etc
This commit is contained in:
parent
ac675c0a62
commit
4f878f0d0e
@ -76,6 +76,7 @@ void mmd_outline_add_beamer(DString * out, token * current, scratch_pad * scratc
|
||||
break;
|
||||
case BLOCK_SETEXT_2:
|
||||
level = 2;
|
||||
break;
|
||||
default:
|
||||
level = 1 + current->type - BLOCK_H1;
|
||||
}
|
||||
@ -95,6 +96,7 @@ void mmd_outline_add_beamer(DString * out, token * current, scratch_pad * scratc
|
||||
break;
|
||||
case BLOCK_SETEXT_2:
|
||||
t_level = 2;
|
||||
break;
|
||||
default:
|
||||
t_level = 1 + t->type - BLOCK_H1;
|
||||
}
|
||||
@ -149,14 +151,8 @@ void mmd_export_token_beamer(DString * out, const char * source, token * t, scra
|
||||
return;
|
||||
|
||||
short temp_short;
|
||||
short temp_short2;
|
||||
link * temp_link = NULL;
|
||||
char * temp_char = NULL;
|
||||
char * temp_char2 = NULL;
|
||||
char * temp_char3 = NULL;
|
||||
bool temp_bool = 0;
|
||||
token * temp_token = NULL;
|
||||
footnote * temp_note = NULL;
|
||||
|
||||
switch (t->type) {
|
||||
case DOC_START_TOKEN:
|
||||
@ -290,7 +286,6 @@ void mmd_export_citation_list_beamer(DString * out, const char * source, scratch
|
||||
pad(out, 2, scratch);
|
||||
|
||||
note = stack_peek_index(scratch->used_citations, i);
|
||||
content = note->content;
|
||||
|
||||
printf("\\bibitem{%s}\n", note->label_text);
|
||||
scratch->padded = 6;
|
||||
|
23
src/latex.c
23
src/latex.c
@ -204,7 +204,6 @@ void mmd_print_localized_char_latex(DString * out, unsigned short type, scratch_
|
||||
|
||||
|
||||
void mmd_export_link_latex(DString * out, const char * source, token * text, link * link, scratch_pad * scratch) {
|
||||
attr * a = link->attributes;
|
||||
char * temp_char;
|
||||
|
||||
if (link->url) {
|
||||
@ -234,21 +233,6 @@ void mmd_export_link_latex(DString * out, const char * source, token * text, lin
|
||||
} else
|
||||
print("\\href{}");
|
||||
|
||||
// if (link->title && link->title[0] != '\0') {
|
||||
// print(" title=\"");
|
||||
// mmd_print_string_latex(out, link->title);
|
||||
// print("\"");
|
||||
// }
|
||||
|
||||
// while (a) {
|
||||
// print(" ");
|
||||
// print(a->key);
|
||||
// print("=\"");
|
||||
// print(a->value);
|
||||
// print("\"");
|
||||
// a = a->next;
|
||||
// }
|
||||
|
||||
print("{");
|
||||
|
||||
// If we're printing contents of bracket as text, then ensure we include it all
|
||||
@ -1367,10 +1351,10 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
||||
if (t->next && t->next->type == TABLE_DIVIDER) {
|
||||
t = t->next;
|
||||
|
||||
if (t->next && t->next->type == TABLE_CELL)
|
||||
if (t->next && t->next->type == TABLE_CELL) {
|
||||
print("&");
|
||||
|
||||
scratch->table_cell_count += t->next->len;
|
||||
scratch->table_cell_count += t->next->len;
|
||||
}
|
||||
} else
|
||||
scratch->table_cell_count++;
|
||||
|
||||
@ -1669,7 +1653,6 @@ void mmd_export_citation_list_latex(DString * out, const char * source, scratch_
|
||||
|
||||
scratch->footnote_para_counter = 0;
|
||||
|
||||
content = note->content;
|
||||
scratch->citation_being_printed = i + 1;
|
||||
|
||||
mmd_export_token_tree_latex(out, source, content, scratch);
|
||||
|
@ -67,15 +67,7 @@ void mmd_export_token_memoir(DString * out, const char * source, token * t, scra
|
||||
if (t == NULL)
|
||||
return;
|
||||
|
||||
short temp_short;
|
||||
short temp_short2;
|
||||
link * temp_link = NULL;
|
||||
char * temp_char = NULL;
|
||||
char * temp_char2 = NULL;
|
||||
char * temp_char3 = NULL;
|
||||
bool temp_bool = 0;
|
||||
token * temp_token = NULL;
|
||||
footnote * temp_note = NULL;
|
||||
|
||||
switch (t->type) {
|
||||
case DOC_START_TOKEN:
|
||||
|
@ -1693,7 +1693,6 @@ void strip_line_tokens_from_block(mmd_engine * e, token * block) {
|
||||
goto handle_line;
|
||||
}
|
||||
default:
|
||||
handle_block:
|
||||
//fprintf(stderr, "Unspecified line type %d inside block type %d\n", l->type, block->type);
|
||||
// This is a block, need to remove it from chain and
|
||||
// Add to parent
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Generated by re2c 0.14.3 on Mon Feb 13 09:48:30 2017 */
|
||||
/* Generated by re2c 0.14.3 on Thu Feb 16 19:37:08 2017 */
|
||||
/**
|
||||
|
||||
MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
|
||||
@ -8876,7 +8876,6 @@ yy650:
|
||||
|
||||
|
||||
size_t scan_meta_key(const char * c) {
|
||||
const char * marker = NULL;
|
||||
const char * start = c;
|
||||
|
||||
|
||||
@ -9489,7 +9488,6 @@ yy734:
|
||||
|
||||
|
||||
size_t scan_destination(const char * c) {
|
||||
const char * marker = NULL;
|
||||
const char * start = c;
|
||||
|
||||
|
||||
|
@ -353,7 +353,6 @@ size_t scan_meta_line(const char * c) {
|
||||
|
||||
|
||||
size_t scan_meta_key(const char * c) {
|
||||
const char * marker = NULL;
|
||||
const char * start = c;
|
||||
|
||||
/*!re2c
|
||||
@ -403,7 +402,6 @@ size_t scan_alignment_string(const char * c) {
|
||||
|
||||
|
||||
size_t scan_destination(const char * c) {
|
||||
const char * marker = NULL;
|
||||
const char * start = c;
|
||||
|
||||
/*!re2c
|
||||
|
17
src/writer.c
17
src/writer.c
@ -258,11 +258,12 @@ char * text_inside_pair(const char * source, token * pair) {
|
||||
char * result = NULL;
|
||||
|
||||
if (source && pair) {
|
||||
if (pair->child->mate) {
|
||||
if (pair->child && pair->child->mate) {
|
||||
// [foo], [^foo], [#foo] should give different strings -- use closer len
|
||||
result = strndup(&source[pair->start + pair->child->mate->len], pair->len - (pair->child->mate->len * 2));
|
||||
} else {
|
||||
result = strndup(&source[pair->start + pair->child->len], pair->len - (pair->child->len + 1));
|
||||
if (pair->child)
|
||||
result = strndup(&source[pair->start + pair->child->len], pair->len - (pair->child->len + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1454,9 +1455,13 @@ void parse_brackets(const char * source, scratch_pad * scratch, token * bracket,
|
||||
|
||||
if (temp_link) {
|
||||
// Don't output brackets
|
||||
bracket->child->type = TEXT_EMPTY;
|
||||
bracket->child->mate->type = TEXT_EMPTY;
|
||||
|
||||
if (bracket->child) {
|
||||
bracket->child->type = TEXT_EMPTY;
|
||||
|
||||
if (bracket->child->mate)
|
||||
bracket->child->mate->type = TEXT_EMPTY;
|
||||
}
|
||||
|
||||
*final_link = temp_link;
|
||||
|
||||
// Skip over second bracket if present
|
||||
@ -1707,7 +1712,7 @@ bool table_has_caption(token * t) {
|
||||
(t->next->type == TEXT_LINEBREAK)))
|
||||
t = t->next;
|
||||
|
||||
if (t->next == NULL)
|
||||
if (t && t->next == NULL)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user