diff options
author | Vicent Marti <tanoku@gmail.com> | 2014-09-02 13:30:13 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2014-09-09 03:39:15 +0200 |
commit | 24248c0f1a6de6f229890c5c03aeff8738214fee (patch) | |
tree | 57dee9b9a4a21b279f160776aa3e876800bbd091 | |
parent | 582674e662d1f8757350c51486a5e0a837195e15 (diff) |
Rename inlines
-rw-r--r-- | src/inlines.c | 50 | ||||
-rw-r--r-- | src/print.c | 22 | ||||
-rw-r--r-- | src/stmd.h | 4 |
3 files changed, 38 insertions, 38 deletions
diff --git a/src/inlines.c b/src/inlines.c index 82c7219..b9ece0e 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -151,15 +151,15 @@ inline static inl* make_simple(int t) } // Macros for creating various kinds of inlines. -#define make_str(s) make_literal(str, s) -#define make_code(s) make_literal(code, s) -#define make_raw_html(s) make_literal(raw_html, s) -#define make_entity(s) make_literal(entity, s) -#define make_linebreak() make_simple(linebreak) -#define make_softbreak() make_simple(softbreak) -#define make_link(label, url, title) make_linkable(link, label, url, title) -#define make_emph(contents) make_inlines(emph, contents) -#define make_strong(contents) make_inlines(strong, contents) +#define make_str(s) make_literal(INL_STRING, s) +#define make_code(s) make_literal(INL_CODE, s) +#define make_raw_html(s) make_literal(INL_RAW_HTML, s) +#define make_entity(s) make_literal(INL_ENTITY, s) +#define make_linebreak() make_simple(INL_LINEBREAK) +#define make_softbreak() make_simple(INL_SOFTBREAK) +#define make_link(label, url, title) make_linkable(INL_LINK, label, url, title) +#define make_emph(contents) make_inlines(INL_EMPH, contents) +#define make_strong(contents) make_inlines(INL_STRONG, contents) // Free an inline list. extern void free_inlines(inl* e) @@ -167,23 +167,23 @@ extern void free_inlines(inl* e) inl * next; while (e != NULL) { switch (e->tag){ - case str: - case raw_html: - case code: - case entity: + case INL_STRING: + case INL_RAW_HTML: + case INL_CODE: + case INL_ENTITY: chunk_free(&e->content.literal); break; - case linebreak: - case softbreak: + case INL_LINEBREAK: + case INL_SOFTBREAK: break; - case link: - case image: + case INL_LINK: + case INL_IMAGE: free(e->content.linkable.url); free(e->content.linkable.title); free_inlines(e->content.linkable.label); break; - case emph: - case strong: + case INL_EMPH: + case INL_STRONG: free_inlines(e->content.inlines); break; default: @@ -454,7 +454,7 @@ static inl* handle_strong_emph(subject* subj, char c) numdelims = scan_delims(subj, c, &can_open, &can_close); if (numdelims >= 1 && can_close) { subj->pos += 1; - first_head->tag = emph; + first_head->tag = INL_EMPH; chunk_free(&first_head->content.literal); first_head->content.inlines = first_head->next; first_head->next = NULL; @@ -471,7 +471,7 @@ static inl* handle_strong_emph(subject* subj, char c) numdelims = scan_delims(subj, c, &can_open, &can_close); if (numdelims >= 2 && can_close) { subj->pos += 2; - first_head->tag = strong; + first_head->tag = INL_STRONG; chunk_free(&first_head->content.literal); first_head->content.inlines = first_head->next; first_head->next = NULL; @@ -502,10 +502,10 @@ static inl* handle_strong_emph(subject* subj, char c) } subj->pos += numdelims; if (first_close) { - first_head->tag = first_close_delims == 1 ? strong : emph; + first_head->tag = first_close_delims == 1 ? INL_STRONG : INL_EMPH; chunk_free(&first_head->content.literal); first_head->content.inlines = - make_inlines(first_close_delims == 1 ? emph : strong, + make_inlines(first_close_delims == 1 ? INL_EMPH : INL_STRONG, first_head->next); il = first_head->next; @@ -989,8 +989,8 @@ static int parse_inline(subject* subj, inl ** last) advance(subj); if (peek_char(subj) == '[') { new = handle_left_bracket(subj); - if (new != NULL && new->tag == link) { - new->tag = image; + if (new != NULL && new->tag == INL_LINK) { + new->tag = INL_IMAGE; } else { new = append_inlines(make_str(chunk_literal("!")), new); } diff --git a/src/print.c b/src/print.c index 3ebde16..0a87925 100644 --- a/src/print.c +++ b/src/print.c @@ -124,35 +124,35 @@ extern void print_inlines(inl* ils, int indent) putchar(' '); } switch(ils->tag) { - case str: + case INL_STRING: printf("str "); print_str(ils->content.literal.data, ils->content.literal.len); putchar('\n'); break; - case linebreak: + case INL_LINEBREAK: printf("linebreak\n"); break; - case softbreak: + case INL_SOFTBREAK: printf("softbreak\n"); break; - case code: + case INL_CODE: printf("code "); print_str(ils->content.literal.data, ils->content.literal.len); putchar('\n'); break; - case raw_html: + case INL_RAW_HTML: printf("html "); print_str(ils->content.literal.data, ils->content.literal.len); putchar('\n'); break; - case entity: + case INL_ENTITY: printf("entity "); print_str(ils->content.literal.data, ils->content.literal.len); putchar('\n'); break; - case link: - case image: - printf("%s url=", ils->tag == link ? "link" : "image"); + case INL_LINK: + case INL_IMAGE: + printf("%s url=", ils->tag == INL_LINK ? "link" : "image"); print_str(ils->content.linkable.url, -1); if (ils->content.linkable.title) { printf(" title="); @@ -161,11 +161,11 @@ extern void print_inlines(inl* ils, int indent) putchar('\n'); print_inlines(ils->content.linkable.label, indent + 2); break; - case strong: + case INL_STRONG: printf("strong\n"); print_inlines(ils->content.linkable.label, indent + 2); break; - case emph: + case INL_EMPH: printf("emph\n"); print_inlines(ils->content.linkable.label, indent + 2); break; @@ -12,8 +12,8 @@ typedef struct { } chunk; typedef struct Inline { - enum { str, softbreak, linebreak, code, raw_html, entity, - emph, strong, link, image } tag; + enum { INL_STRING, INL_SOFTBREAK, INL_LINEBREAK, INL_CODE, INL_RAW_HTML, INL_ENTITY, + INL_EMPH, INL_STRONG, INL_LINK, INL_IMAGE } tag; union { chunk literal; struct Inline *inlines; |