aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2014-09-04 18:45:44 +0200
committerVicent Marti <tanoku@gmail.com>2014-09-09 03:39:16 +0200
commit9e4855365b920c2a80b0f1ab6937280f0b504334 (patch)
tree1e38497b5bc339930f183ef0f0bae5429366fea6
parent647b15968c95ec268d6d728eea73756c7ba648a8 (diff)
Rename `inl`
-rw-r--r--src/html/html.c2
-rw-r--r--src/inlines.c88
-rw-r--r--src/print.c2
-rw-r--r--src/stmd.h28
4 files changed, 62 insertions, 58 deletions
diff --git a/src/html/html.c b/src/html/html.c
index 53521b8..a7bb21a 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, struct inl* ils)
+void inlines_to_html(strbuf *html, node_inl* ils)
{
strbuf scrap = GH_BUF_INIT;
diff --git a/src/inlines.c b/src/inlines.c
index 301125e..6bb89da 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 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 node_inl *parse_chunk_inlines(chunk *chunk, reference** refmap);
+static node_inl *parse_inlines_while(subject* subj, int (*f)(subject*));
+static int parse_inline(subject* subj, node_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 struct inl* make_link_from_reference(struct inl* label, reference *ref)
+inline static node_inl* make_link_from_reference(node_inl* label, reference *ref)
{
- struct inl* e = (struct inl*) malloc(sizeof(struct inl));
+ node_inl* e = (node_inl*) malloc(sizeof(node_inl));
e->tag = INL_LINK;
e->content.linkable.label = label;
e->content.linkable.url = strdup(ref->url);
@@ -120,9 +120,9 @@ inline static struct inl* make_link_from_reference(struct inl* label, reference
}
// Create an inline with a linkable string value.
-inline static struct inl* make_link(struct inl* label, chunk url, chunk title, int is_email)
+inline static node_inl* make_link(node_inl* label, chunk url, chunk title, int is_email)
{
- struct inl* e = (struct inl*) malloc(sizeof(struct inl));
+ node_inl* e = (node_inl*) malloc(sizeof(node_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 struct inl* make_link(struct inl* label, chunk url, chunk title, i
return e;
}
-inline static struct inl* make_inlines(int t, struct inl* contents)
+inline static node_inl* make_inlines(int t, node_inl* contents)
{
- struct inl* e = (struct inl*) malloc(sizeof(struct inl));
+ node_inl* e = (node_inl*) malloc(sizeof(node_inl));
e->tag = t;
e->content.inlines = contents;
e->next = NULL;
@@ -141,9 +141,9 @@ inline static struct inl* make_inlines(int t, struct inl* contents)
}
// Create an inline with a literal string value.
-inline static struct inl* make_literal(int t, chunk s)
+inline static node_inl* make_literal(int t, chunk s)
{
- struct inl* e = (struct inl*) malloc(sizeof(struct inl));
+ node_inl* e = (node_inl*) malloc(sizeof(node_inl));
e->tag = t;
e->content.literal = s;
e->next = NULL;
@@ -151,9 +151,9 @@ inline static struct inl* make_literal(int t, chunk s)
}
// Create an inline with no value.
-inline static struct inl* make_simple(int t)
+inline static node_inl* make_simple(int t)
{
- struct inl* e = (struct inl*) malloc(sizeof(struct inl));
+ node_inl* e = (node_inl*) malloc(sizeof(node_inl));
e->tag = t;
e->next = NULL;
return e;
@@ -170,9 +170,9 @@ inline static struct inl* make_simple(int t)
#define make_strong(contents) make_inlines(INL_STRONG, contents)
// Free an inline list.
-extern void free_inlines(struct inl* e)
+extern void free_inlines(node_inl* e)
{
- struct inl * next;
+ node_inl * next;
while (e != NULL) {
switch (e->tag){
case INL_STRING:
@@ -205,12 +205,12 @@ extern void free_inlines(struct inl* e)
// Append inline list b to the end of inline list a.
// Return pointer to head of new list.
-inline static struct inl* append_inlines(struct inl* a, struct inl* b)
+inline static node_inl* append_inlines(node_inl* a, node_inl* b)
{
if (a == NULL) { // NULL acts like an empty list
return b;
}
- struct inl* cur = a;
+ node_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 struct inl* handle_backticks(subject *subj)
+static node_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 struct inl* handle_strong_emph(subject* subj, char c)
+static node_inl* handle_strong_emph(subject* subj, char c)
{
bool can_open, can_close;
- 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;
+ node_inl * result = NULL;
+ node_inl ** last = malloc(sizeof(node_inl *));
+ node_inl * new;
+ node_inl * il;
+ node_inl * first_head = NULL;
+ node_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 struct inl* handle_backslash(subject *subj)
+static node_inl* handle_backslash(subject *subj)
{
advance(subj);
unsigned char nextchar = peek_char(subj);
@@ -525,10 +525,10 @@ static struct inl* handle_backslash(subject *subj)
// Parse an entity or a regular "&" string.
// Assumes the subject has an '&' character at the current position.
-static struct inl* handle_entity(subject* subj)
+static node_inl* handle_entity(subject* subj)
{
int match;
- struct inl *result;
+ node_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 struct inl* handle_entity(subject* subj)
// Like make_str, but parses entities.
// Returns an inline sequence consisting of str and entity elements.
-static struct inl *make_str_with_entities(chunk *content)
+static node_inl *make_str_with_entities(chunk *content)
{
- struct inl *result = NULL;
- struct inl *new;
+ node_inl *result = NULL;
+ node_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 struct inl* handle_pointy_brace(subject* subj)
+static node_inl* handle_pointy_brace(subject* subj)
{
int matchlen = 0;
chunk contents;
@@ -693,7 +693,7 @@ static struct inl* handle_pointy_brace(subject* subj)
static int link_label(subject* subj, chunk *raw_label)
{
int nestlevel = 0;
- struct inl* tmp = NULL;
+ node_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 struct inl* handle_left_bracket(subject* subj)
+static node_inl* handle_left_bracket(subject* subj)
{
- struct inl *lab = NULL;
- struct inl *result = NULL;
+ node_inl *lab = NULL;
+ node_inl *result = NULL;
reference *ref;
int n;
int sps;
@@ -838,7 +838,7 @@ static struct 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 struct inl* handle_newline(subject *subj)
+static node_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 struct inl* parse_inlines_while(subject* subj, int (*f)(subject*))
+extern node_inl* parse_inlines_while(subject* subj, int (*f)(subject*))
{
- struct inl* result = NULL;
- struct inl** last = &result;
+ node_inl* result = NULL;
+ node_inl** last = &result;
while ((*f)(subj) && parse_inline(subj, last)) {
}
return result;
}
-struct inl *parse_chunk_inlines(chunk *chunk, reference** refmap)
+node_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, struct inl ** last)
+static int parse_inline(subject* subj, node_inl ** last)
{
- struct inl* new = NULL;
+ node_inl* new = NULL;
chunk contents;
unsigned char c;
int endpos;
@@ -971,7 +971,7 @@ static int parse_inline(subject* subj, struct inl ** last)
return 1;
}
-extern struct inl* parse_inlines(strbuf *input, reference** refmap)
+extern node_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 63f63c8..01e9136 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(struct inl* ils, int indent)
+extern void print_inlines(node_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 9ed33ec..dbc8c8c 100644
--- a/src/stmd.h
+++ b/src/stmd.h
@@ -10,7 +10,7 @@
#define VERSION "0.1"
#define CODE_INDENT 4
-struct inl {
+struct node_inl {
enum {
INL_STRING,
INL_SOFTBREAK,
@@ -25,22 +25,26 @@ struct inl {
} tag;
union {
chunk literal;
- struct inl *inlines;
+ struct node_inl *inlines;
struct {
- struct inl *label;
+ struct node_inl *label;
unsigned char *url;
unsigned char *title;
} linkable;
} content;
- struct inl *next;
+ struct node_inl *next;
};
-typedef struct Reference {
+typedef struct node_inl node_inl;
+
+struct reference {
unsigned char *label;
unsigned char *url;
unsigned char *title;
- UT_hash_handle hh; // used by uthash
-} reference;
+ UT_hash_handle hh; // used by uthash
+};
+
+typedef struct reference reference;
// Types for blocks
@@ -87,7 +91,7 @@ typedef struct Block {
struct Block* parent;
struct Block* top;
strbuf string_content;
- struct inl* inline_content;
+ node_inl* inline_content;
union {
struct ListData list_data;
struct FencedCodeData fenced_code_data;
@@ -98,8 +102,8 @@ typedef struct Block {
struct Block * prev;
} block;
-struct inl* parse_inlines(strbuf *input, reference** refmap);
-void free_inlines(struct inl* e);
+node_inl* parse_inlines(strbuf *input, reference** refmap);
+void free_inlines(node_inl* e);
int parse_reference(strbuf *input, reference** refmap);
void free_reference(reference *ref);
@@ -116,11 +120,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(struct inl* ils, int indent);
+void print_inlines(node_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, struct inl *b);
+void inlines_to_html(strbuf *html, node_inl *b);
void utf8proc_case_fold(strbuf *dest, const unsigned char *str, int len);