summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c36
-rw-r--r--src/cmark.h12
-rw-r--r--src/main.c12
-rw-r--r--src/node.c2
-rw-r--r--src/parser.h2
5 files changed, 32 insertions, 32 deletions
diff --git a/src/blocks.c b/src/blocks.c
index c028b8b..1bdf67b 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -42,9 +42,9 @@ static cmark_node* make_document()
return e;
}
-cmark_doc_parser *cmark_new_doc_parser()
+cmark_parser *cmark_parser_new()
{
- cmark_doc_parser *parser = (cmark_doc_parser*)malloc(sizeof(cmark_doc_parser));
+ cmark_parser *parser = (cmark_parser*)malloc(sizeof(cmark_parser));
cmark_node *document = make_document();
strbuf *line = (strbuf*)malloc(sizeof(strbuf));
cmark_strbuf_init(line, 256);
@@ -58,7 +58,7 @@ cmark_doc_parser *cmark_new_doc_parser()
return parser;
}
-void cmark_free_doc_parser(cmark_doc_parser *parser)
+void cmark_parser_free(cmark_parser *parser)
{
cmark_strbuf_free(parser->curline);
free(parser->curline);
@@ -66,7 +66,7 @@ void cmark_free_doc_parser(cmark_doc_parser *parser)
free(parser);
}
-static void finalize(cmark_doc_parser *parser, cmark_node* b, int line_number);
+static void finalize(cmark_parser *parser, cmark_node* b, int line_number);
// Returns true if line has only space characters, else false.
static bool is_blank(strbuf *s, int offset)
@@ -143,7 +143,7 @@ static bool ends_with_blank_line(cmark_node* cmark_node)
}
// Break out of all containing lists
-static int break_out_of_lists(cmark_doc_parser *parser, cmark_node ** bptr, int line_number)
+static int break_out_of_lists(cmark_parser *parser, cmark_node ** bptr, int line_number)
{
cmark_node *container = *bptr;
cmark_node *b = parser->root;
@@ -163,7 +163,7 @@ static int break_out_of_lists(cmark_doc_parser *parser, cmark_node ** bptr, int
}
-static void finalize(cmark_doc_parser *parser, cmark_node* b, int line_number)
+static void finalize(cmark_parser *parser, cmark_node* b, int line_number)
{
int firstlinelen;
int pos;
@@ -250,7 +250,7 @@ static void finalize(cmark_doc_parser *parser, cmark_node* b, int line_number)
}
// Add a cmark_node as child of another. Return pointer to child.
-static cmark_node* add_child(cmark_doc_parser *parser, cmark_node* parent,
+static cmark_node* add_child(cmark_parser *parser, cmark_node* parent,
cmark_node_type block_type, int start_line, int start_column)
{
assert(parent);
@@ -399,7 +399,7 @@ static int lists_match(cmark_list *list_data, cmark_list *item_data)
list_data->bullet_char == item_data->bullet_char);
}
-static cmark_node *finalize_document(cmark_doc_parser *parser)
+static cmark_node *finalize_document(cmark_parser *parser)
{
while (parser->current != parser->root) {
finalize(parser, parser->current, parser->line_number);
@@ -415,17 +415,17 @@ static cmark_node *finalize_document(cmark_doc_parser *parser)
extern cmark_node *cmark_parse_file(FILE *f)
{
char buffer[4096];
- cmark_doc_parser *parser = cmark_new_doc_parser();
+ cmark_parser *parser = cmark_parser_new();
size_t offset;
cmark_node *document;
while (fgets(buffer, sizeof(buffer), f)) {
offset = strlen(buffer);
- cmark_process_line(parser, buffer, offset);
+ cmark_parser_process_line(parser, buffer, offset);
}
- document = cmark_finish(parser);
- cmark_free_doc_parser(parser);
+ document = cmark_parser_finish(parser);
+ cmark_parser_free(parser);
return document;
}
@@ -434,20 +434,20 @@ extern cmark_node *cmark_parse_document(const char *buffer, size_t len)
int linenum = 1;
const char *end = buffer + len;
size_t offset;
- cmark_doc_parser *parser = cmark_new_doc_parser();
+ cmark_parser *parser = cmark_parser_new();
cmark_node *document;
while (buffer < end) {
const char *eol
= (const char *)memchr(buffer, '\n', end - buffer);
offset = eol ? (eol - buffer) + 1 : end - buffer;
- cmark_process_line(parser, buffer, offset);
+ cmark_parser_process_line(parser, buffer, offset);
buffer += offset;
linenum++;
}
- document = cmark_finish(parser);
- cmark_free_doc_parser(parser);
+ document = cmark_parser_finish(parser);
+ cmark_parser_free(parser);
return document;
}
@@ -469,7 +469,7 @@ static void chop_trailing_hashtags(chunk *ch)
}
}
-void cmark_process_line(cmark_doc_parser *parser, const char *buffer,
+void cmark_parser_process_line(cmark_parser *parser, const char *buffer,
size_t bytes)
{
cmark_node* last_matched_container;
@@ -829,7 +829,7 @@ void cmark_process_line(cmark_doc_parser *parser, const char *buffer,
}
-cmark_node *cmark_finish(cmark_doc_parser *parser)
+cmark_node *cmark_parser_finish(cmark_parser *parser)
{
finalize_document(parser);
strbuf_free(parser->curline);
diff --git a/src/cmark.h b/src/cmark.h
index 12da846..a1ec0b2 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -53,7 +53,7 @@ typedef enum {
} cmark_delim_type;
typedef struct cmark_node cmark_node;
-typedef struct cmark_doc_parser cmark_doc_parser;
+typedef struct cmark_parser cmark_parser;
// Construction and destruction
@@ -61,7 +61,7 @@ CMARK_EXPORT cmark_node*
cmark_node_new(cmark_node_type type);
CMARK_EXPORT void
-cmark_node_destroy(cmark_node *node);
+cmark_node_free(cmark_node *node);
CMARK_EXPORT void
cmark_free_nodes(cmark_node *e);
@@ -165,16 +165,16 @@ cmark_node_append_child(cmark_node *node, cmark_node *child);
// Parser
CMARK_EXPORT
-cmark_doc_parser *cmark_new_doc_parser();
+cmark_parser *cmark_parser_new();
CMARK_EXPORT
-void cmark_free_doc_parser(cmark_doc_parser *parser);
+void cmark_parser_free(cmark_parser *parser);
CMARK_EXPORT
-cmark_node *cmark_finish(cmark_doc_parser *parser);
+cmark_node *cmark_parser_finish(cmark_parser *parser);
CMARK_EXPORT
-void cmark_process_line(cmark_doc_parser *parser, const char *buffer, size_t bytes);
+void cmark_parser_process_line(cmark_parser *parser, const char *buffer, size_t bytes);
CMARK_EXPORT
cmark_node *cmark_parse_document(const char *buffer, size_t len);
diff --git a/src/main.c b/src/main.c
index a7f18cb..bb4fd94 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,11 +34,11 @@ int main(int argc, char *argv[])
bool ast = false;
int *files;
char buffer[4096];
- cmark_doc_parser *parser;
+ cmark_parser *parser;
size_t offset;
cmark_node *document;
- parser = cmark_new_doc_parser();
+ parser = cmark_parser_new();
files = (int *)malloc(argc * sizeof(*files));
for (i = 1; i < argc; i++) {
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
start_timer();
while (fgets((char *)buffer, sizeof(buffer), fp)) {
offset = strlen((char *)buffer);
- cmark_process_line(parser, buffer, offset);
+ cmark_parser_process_line(parser, buffer, offset);
}
end_timer("processing lines");
@@ -87,14 +87,14 @@ int main(int argc, char *argv[])
while (fgets((char *)buffer, sizeof(buffer), stdin)) {
offset = strlen((char *)buffer);
- cmark_process_line(parser, buffer, offset);
+ cmark_parser_process_line(parser, buffer, offset);
}
}
start_timer();
- document = cmark_finish(parser);
+ document = cmark_parser_finish(parser);
end_timer("finishing document");
- cmark_free_doc_parser(parser);
+ cmark_parser_free(parser);
start_timer();
print_document(document, ast);
diff --git a/src/node.c b/src/node.c
index 8b107bc..d2c4431 100644
--- a/src/node.c
+++ b/src/node.c
@@ -33,7 +33,7 @@ cmark_node_new(cmark_node_type type) {
}
void
-cmark_node_destroy(cmark_node *node) {
+cmark_node_free(cmark_node *node) {
S_node_unlink(node);
node->next = NULL;
cmark_free_nodes(node);
diff --git a/src/parser.h b/src/parser.h
index bbbc3b1..e0ed507 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -11,7 +11,7 @@ extern "C" {
#define MAX_LINK_LABEL_LENGTH 1000
-struct cmark_doc_parser {
+struct cmark_parser {
struct cmark_reference_map *refmap;
struct cmark_node* root;
struct cmark_node* current;