summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2014-09-04 18:42:49 +0200
committerVicent Marti <tanoku@gmail.com>2014-09-09 03:39:16 +0200
commit647b15968c95ec268d6d728eea73756c7ba648a8 (patch)
tree3b30eb0821ee23197f643cbc87170e998a690ade /src
parent543c2c94d71adee42c7bd2f8027d75c87ed8120d (diff)
Rename inl
Diffstat (limited to 'src')
-rw-r--r--src/html/html.c2
-rw-r--r--src/inlines.c88
-rw-r--r--src/print.c2
-rw-r--r--src/stmd.h34
4 files changed, 68 insertions, 58 deletions
diff --git a/src/html/html.c b/src/html/html.c
index a9356dd..53521b8 100644
--- a/src/html/html.c
+++ b/src/html/html.c
@@ -141,7 +141,7 @@ void blocks_to_html(strbuf *html, block *b, bool tight)
}
// Convert an inline list to HTML. Returns 0 on success, and sets result.
-void inlines_to_html(strbuf *html, inl* ils)
+void inlines_to_html(strbuf *html, struct inl* ils)
{
strbuf scrap = GH_BUF_INIT;
diff --git a/src/inlines.c b/src/inlines.c
index 33973df..301125e 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -28,9 +28,9 @@ inline static chunk chunk_literal(const char *data);
inline static chunk chunk_buf_detach(strbuf *buf);
inline static chunk chunk_dup(const chunk *ch, int pos, int len);
-static inl *parse_chunk_inlines(chunk *chunk, reference** refmap);
-static inl *parse_inlines_while(subject* subj, int (*f)(subject*));
-static int parse_inline(subject* subj, inl ** last);
+static struct inl *parse_chunk_inlines(chunk *chunk, reference** refmap);
+static struct inl *parse_inlines_while(subject* subj, int (*f)(subject*));
+static int parse_inline(subject* subj, struct inl ** last);
static void subject_from_chunk(subject *e, chunk *chunk, reference** refmap);
static void subject_from_buf(subject *e, strbuf *buffer, reference** refmap);
@@ -108,9 +108,9 @@ extern void add_reference(reference** refmap, reference* ref)
}
}
-inline static inl* make_link_from_reference(inl* label, reference *ref)
+inline static struct inl* make_link_from_reference(struct inl* label, reference *ref)
{
- inl* e = (inl*) malloc(sizeof(inl));
+ struct inl* e = (struct inl*) malloc(sizeof(struct inl));
e->tag = INL_LINK;
e->content.linkable.label = label;
e->content.linkable.url = strdup(ref->url);
@@ -120,9 +120,9 @@ inline static inl* make_link_from_reference(inl* label, reference *ref)
}
// Create an inline with a linkable string value.
-inline static inl* make_link(inl* label, chunk url, chunk title, int is_email)
+inline static struct inl* make_link(struct inl* label, chunk url, chunk title, int is_email)
{
- inl* e = (inl*) malloc(sizeof(inl));
+ struct inl* e = (struct inl*) malloc(sizeof(struct inl));
e->tag = INL_LINK;
e->content.linkable.label = label;
e->content.linkable.url = clean_url(&url, is_email);
@@ -131,9 +131,9 @@ inline static inl* make_link(inl* label, chunk url, chunk title, int is_email)
return e;
}
-inline static inl* make_inlines(int t, inl* contents)
+inline static struct inl* make_inlines(int t, struct inl* contents)
{
- inl* e = (inl*) malloc(sizeof(inl));
+ struct inl* e = (struct inl*) malloc(sizeof(struct inl));
e->tag = t;
e->content.inlines = contents;
e->next = NULL;
@@ -141,9 +141,9 @@ inline static inl* make_inlines(int t, inl* contents)
}
// Create an inline with a literal string value.
-inline static inl* make_literal(int t, chunk s)
+inline static struct inl* make_literal(int t, chunk s)
{
- inl* e = (inl*) malloc(sizeof(inl));
+ struct inl* e = (struct inl*) malloc(sizeof(struct inl));
e->tag = t;
e->content.literal = s;
e->next = NULL;
@@ -151,9 +151,9 @@ inline static inl* make_literal(int t, chunk s)
}
// Create an inline with no value.
-inline static inl* make_simple(int t)
+inline static struct inl* make_simple(int t)
{
- inl* e = (inl*) malloc(sizeof(inl));
+ struct inl* e = (struct inl*) malloc(sizeof(struct inl));
e->tag = t;
e->next = NULL;
return e;
@@ -170,9 +170,9 @@ inline static inl* make_simple(int t)
#define make_strong(contents) make_inlines(INL_STRONG, contents)
// Free an inline list.
-extern void free_inlines(inl* e)
+extern void free_inlines(struct inl* e)
{
- inl * next;
+ struct inl * next;
while (e != NULL) {
switch (e->tag){
case INL_STRING:
@@ -205,12 +205,12 @@ extern void free_inlines(inl* e)
// Append inline list b to the end of inline list a.
// Return pointer to head of new list.
-inline static inl* append_inlines(inl* a, inl* b)
+inline static struct inl* append_inlines(struct inl* a, struct inl* b)
{
if (a == NULL) { // NULL acts like an empty list
return b;
}
- inl* cur = a;
+ struct inl* cur = a;
while (cur->next) {
cur = cur->next;
}
@@ -336,7 +336,7 @@ static void normalize_whitespace(strbuf *s)
// Parse backtick code section or raw backticks, return an inline.
// Assumes that the subject has a backtick at the current position.
-static inl* handle_backticks(subject *subj)
+static struct inl* handle_backticks(subject *subj)
{
chunk openticks = take_while(subj, isbacktick);
int startpos = subj->pos;
@@ -382,15 +382,15 @@ static int scan_delims(subject* subj, char c, bool * can_open, bool * can_close)
// Parse strong/emph or a fallback.
// Assumes the subject has '_' or '*' at the current position.
-static inl* handle_strong_emph(subject* subj, char c)
+static struct inl* handle_strong_emph(subject* subj, char c)
{
bool can_open, can_close;
- inl * result = NULL;
- inl ** last = malloc(sizeof(inl *));
- inl * new;
- inl * il;
- inl * first_head = NULL;
- inl * first_close = NULL;
+ struct inl * result = NULL;
+ struct inl ** last = malloc(sizeof(struct inl *));
+ struct inl * new;
+ struct inl * il;
+ struct inl * first_head = NULL;
+ struct inl * first_close = NULL;
int first_close_delims = 0;
int numdelims;
@@ -508,7 +508,7 @@ done:
}
// Parse backslash-escape or just a backslash, returning an inline.
-static inl* handle_backslash(subject *subj)
+static struct inl* handle_backslash(subject *subj)
{
advance(subj);
unsigned char nextchar = peek_char(subj);
@@ -525,10 +525,10 @@ static inl* handle_backslash(subject *subj)
// Parse an entity or a regular "&" string.
// Assumes the subject has an '&' character at the current position.
-static inl* handle_entity(subject* subj)
+static struct inl* handle_entity(subject* subj)
{
int match;
- inl *result;
+ struct inl *result;
match = scan_entity(&subj->input, subj->pos);
if (match) {
result = make_entity(chunk_dup(&subj->input, subj->pos, match));
@@ -542,10 +542,10 @@ static inl* handle_entity(subject* subj)
// Like make_str, but parses entities.
// Returns an inline sequence consisting of str and entity elements.
-static inl *make_str_with_entities(chunk *content)
+static struct inl *make_str_with_entities(chunk *content)
{
- inl *result = NULL;
- inl *new;
+ struct inl *result = NULL;
+ struct inl *new;
int searchpos;
char c;
subject subj;
@@ -634,7 +634,7 @@ static unsigned char *clean_title(chunk *title)
// Parse an autolink or HTML tag.
// Assumes the subject has a '<' character at the current position.
-static inl* handle_pointy_brace(subject* subj)
+static struct inl* handle_pointy_brace(subject* subj)
{
int matchlen = 0;
chunk contents;
@@ -693,7 +693,7 @@ static inl* handle_pointy_brace(subject* subj)
static int link_label(subject* subj, chunk *raw_label)
{
int nestlevel = 0;
- inl* tmp = NULL;
+ struct inl* tmp = NULL;
int startpos = subj->pos;
if (subj->label_nestlevel) {
@@ -751,10 +751,10 @@ static int link_label(subject* subj, chunk *raw_label)
}
// Parse a link or the link portion of an image, or return a fallback.
-static inl* handle_left_bracket(subject* subj)
+static struct inl* handle_left_bracket(subject* subj)
{
- inl *lab = NULL;
- inl *result = NULL;
+ struct inl *lab = NULL;
+ struct inl *result = NULL;
reference *ref;
int n;
int sps;
@@ -838,7 +838,7 @@ static inl* handle_left_bracket(subject* subj)
// Parse a hard or soft linebreak, returning an inline.
// Assumes the subject has a newline at the current position.
-static inl* handle_newline(subject *subj)
+static struct inl* handle_newline(subject *subj)
{
int nlpos = subj->pos;
// skip over newline
@@ -862,16 +862,16 @@ inline static int not_eof(subject* subj)
}
// Parse inlines while a predicate is satisfied. Return inlines.
-extern inl* parse_inlines_while(subject* subj, int (*f)(subject*))
+extern struct inl* parse_inlines_while(subject* subj, int (*f)(subject*))
{
- inl* result = NULL;
- inl** last = &result;
+ struct inl* result = NULL;
+ struct inl** last = &result;
while ((*f)(subj) && parse_inline(subj, last)) {
}
return result;
}
-inl *parse_chunk_inlines(chunk *chunk, reference** refmap)
+struct inl *parse_chunk_inlines(chunk *chunk, reference** refmap)
{
subject subj;
subject_from_chunk(&subj, chunk, refmap);
@@ -894,9 +894,9 @@ static int subject_find_special_char(subject *subj)
// Parse an inline, advancing subject, and add it to last element.
// Adjust tail to point to new last element of list.
// Return 0 if no inline can be parsed, 1 otherwise.
-static int parse_inline(subject* subj, inl ** last)
+static int parse_inline(subject* subj, struct inl ** last)
{
- inl* new = NULL;
+ struct inl* new = NULL;
chunk contents;
unsigned char c;
int endpos;
@@ -971,7 +971,7 @@ static int parse_inline(subject* subj, inl ** last)
return 1;
}
-extern inl* parse_inlines(strbuf *input, reference** refmap)
+extern struct inl* parse_inlines(strbuf *input, reference** refmap)
{
subject subj;
subject_from_buf(&subj, input, refmap);
diff --git a/src/print.c b/src/print.c
index 832ad4f..63f63c8 100644
--- a/src/print.c
+++ b/src/print.c
@@ -117,7 +117,7 @@ extern void print_blocks(block* b, int indent)
}
// Prettyprint an inline list, for debugging.
-extern void print_inlines(inl* ils, int indent)
+extern void print_inlines(struct inl* ils, int indent)
{
while(ils != NULL) {
for (int i=0; i < indent; i++) {
diff --git a/src/stmd.h b/src/stmd.h
index 2e86f3a..9ed33ec 100644
--- a/src/stmd.h
+++ b/src/stmd.h
@@ -10,20 +10,30 @@
#define VERSION "0.1"
#define CODE_INDENT 4
-typedef struct Inline {
- enum { INL_STRING, INL_SOFTBREAK, INL_LINEBREAK, INL_CODE, INL_RAW_HTML, INL_ENTITY,
- INL_EMPH, INL_STRONG, INL_LINK, INL_IMAGE } tag;
+struct inl {
+ 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;
+ struct inl *inlines;
struct {
- struct Inline *label;
+ struct inl *label;
unsigned char *url;
unsigned char *title;
} linkable;
} content;
- struct Inline *next;
-} inl;
+ struct inl *next;
+};
typedef struct Reference {
unsigned char *label;
@@ -77,7 +87,7 @@ typedef struct Block {
struct Block* parent;
struct Block* top;
strbuf string_content;
- inl* inline_content;
+ struct inl* inline_content;
union {
struct ListData list_data;
struct FencedCodeData fenced_code_data;
@@ -88,8 +98,8 @@ typedef struct Block {
struct Block * prev;
} block;
-inl* parse_inlines(strbuf *input, reference** refmap);
-void free_inlines(inl* e);
+struct inl* parse_inlines(strbuf *input, reference** refmap);
+void free_inlines(struct inl* e);
int parse_reference(strbuf *input, reference** refmap);
void free_reference(reference *ref);
@@ -106,11 +116,11 @@ void free_blocks(block* e);
extern block *stmd_parse_document(const unsigned char *buffer, size_t len);
extern block *stmd_parse_file(FILE *f);
-void print_inlines(inl* ils, int indent);
+void print_inlines(struct inl* ils, int indent);
void print_blocks(block* blk, int indent);
void blocks_to_html(strbuf *html, block *b, bool tight);
-void inlines_to_html(strbuf *html, inl *b);
+void inlines_to_html(strbuf *html, struct inl *b);
void utf8proc_case_fold(strbuf *dest, const unsigned char *str, int len);