aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-12-13 11:24:26 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-12-13 11:24:26 -0800
commit225d720d6e9b473c7d6498e811b3f412472cc9ce (patch)
treeb3f1b4f97a43a09dfddd060b0b4f8696e496f739
parent831bf6de49ae58bd3630f40bdb6f8bc5371a33dd (diff)
Removed cmark_ prefix on chunk and strbuf.
This isn't needed any more since we don't expose these in the API.
-rw-r--r--src/blocks.c8
-rw-r--r--src/buffer.c100
-rw-r--r--src/buffer.h132
-rw-r--r--src/chunk.h46
-rw-r--r--src/inlines.c4
-rw-r--r--src/inlines.h6
-rw-r--r--src/node.c14
-rw-r--r--src/node.h6
-rw-r--r--src/parser.h4
-rw-r--r--src/references.h4
-rw-r--r--src/utf8.h6
11 files changed, 127 insertions, 203 deletions
diff --git a/src/blocks.c b/src/blocks.c
index ebef88b..512a30a 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -56,8 +56,8 @@ cmark_parser *cmark_parser_new()
cmark_node *document = make_document();
strbuf *line = (strbuf*)malloc(sizeof(strbuf));
strbuf *buf = (strbuf*)malloc(sizeof(strbuf));
- cmark_strbuf_init(line, 256);
- cmark_strbuf_init(buf, 0);
+ strbuf_init(line, 256);
+ strbuf_init(buf, 0);
parser->refmap = cmark_reference_map_new();
parser->root = document;
@@ -71,9 +71,9 @@ cmark_parser *cmark_parser_new()
void cmark_parser_free(cmark_parser *parser)
{
- cmark_strbuf_free(parser->curline);
+ strbuf_free(parser->curline);
free(parser->curline);
- cmark_strbuf_free(parser->linebuf);
+ strbuf_free(parser->linebuf);
free(parser->linebuf);
cmark_reference_map_free(parser->refmap);
free(parser);
diff --git a/src/buffer.c b/src/buffer.c
index 45b6984..765cb46 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -11,8 +11,8 @@
/* Used as default value for strbuf->ptr so that people can always
* assume ptr is non-NULL and zero terminated even for new strbufs.
*/
-unsigned char cmark_strbuf__initbuf[1];
-unsigned char cmark_strbuf__oom[1];
+unsigned char strbuf__initbuf[1];
+unsigned char strbuf__oom[1];
#define ENSURE_SIZE(b, d) \
if ((d) > buf->asize && strbuf_grow(b, (d)) < 0) \
@@ -22,22 +22,22 @@ unsigned char cmark_strbuf__oom[1];
#define MIN(x,y) ((x<y) ? x : y)
#endif
-void cmark_strbuf_init(strbuf *buf, int initial_size)
+void strbuf_init(strbuf *buf, int initial_size)
{
buf->asize = 0;
buf->size = 0;
- buf->ptr = cmark_strbuf__initbuf;
+ buf->ptr = strbuf__initbuf;
if (initial_size)
- cmark_strbuf_grow(buf, initial_size);
+ strbuf_grow(buf, initial_size);
}
-int cmark_strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom)
+int strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom)
{
unsigned char *new_ptr;
int new_size;
- if (buf->ptr == cmark_strbuf__oom)
+ if (buf->ptr == strbuf__oom)
return -1;
if (target_size <= buf->asize)
@@ -63,7 +63,7 @@ int cmark_strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom)
if (!new_ptr) {
if (mark_oom)
- buf->ptr = cmark_strbuf__oom;
+ buf->ptr = strbuf__oom;
return -1;
}
@@ -78,32 +78,32 @@ int cmark_strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom)
return 0;
}
-int cmark_strbuf_grow(cmark_strbuf *buf, int target_size)
+int strbuf_grow(strbuf *buf, int target_size)
{
- return cmark_strbuf_try_grow(buf, target_size, true);
+ return strbuf_try_grow(buf, target_size, true);
}
-bool cmark_strbuf_oom(const cmark_strbuf *buf)
+bool strbuf_oom(const strbuf *buf)
{
- return (buf->ptr == cmark_strbuf__oom);
+ return (buf->ptr == strbuf__oom);
}
-size_t cmark_strbuf_len(const cmark_strbuf *buf)
+size_t strbuf_len(const strbuf *buf)
{
return buf->size;
}
-void cmark_strbuf_free(strbuf *buf)
+void strbuf_free(strbuf *buf)
{
if (!buf) return;
- if (buf->ptr != cmark_strbuf__initbuf && buf->ptr != cmark_strbuf__oom)
+ if (buf->ptr != strbuf__initbuf && buf->ptr != strbuf__oom)
free(buf->ptr);
- cmark_strbuf_init(buf, 0);
+ strbuf_init(buf, 0);
}
-void cmark_strbuf_clear(strbuf *buf)
+void strbuf_clear(strbuf *buf)
{
buf->size = 0;
@@ -111,10 +111,10 @@ void cmark_strbuf_clear(strbuf *buf)
buf->ptr[0] = '\0';
}
-int cmark_strbuf_set(strbuf *buf, const unsigned char *data, int len)
+int strbuf_set(strbuf *buf, const unsigned char *data, int len)
{
if (len <= 0 || data == NULL) {
- cmark_strbuf_clear(buf);
+ strbuf_clear(buf);
} else {
if (data != buf->ptr) {
ENSURE_SIZE(buf, len + 1);
@@ -126,14 +126,14 @@ int cmark_strbuf_set(strbuf *buf, const unsigned char *data, int len)
return 0;
}
-int cmark_strbuf_sets(strbuf *buf, const char *string)
+int strbuf_sets(strbuf *buf, const char *string)
{
- return cmark_strbuf_set(buf,
+ return strbuf_set(buf,
(const unsigned char *)string,
string ? strlen(string) : 0);
}
-int cmark_strbuf_putc(strbuf *buf, int c)
+int strbuf_putc(strbuf *buf, int c)
{
ENSURE_SIZE(buf, buf->size + 2);
buf->ptr[buf->size++] = c;
@@ -141,7 +141,7 @@ int cmark_strbuf_putc(strbuf *buf, int c)
return 0;
}
-int cmark_strbuf_put(strbuf *buf, const unsigned char *data, int len)
+int strbuf_put(strbuf *buf, const unsigned char *data, int len)
{
if (len <= 0)
return 0;
@@ -153,12 +153,12 @@ int cmark_strbuf_put(strbuf *buf, const unsigned char *data, int len)
return 0;
}
-int cmark_strbuf_puts(strbuf *buf, const char *string)
+int strbuf_puts(strbuf *buf, const char *string)
{
- return cmark_strbuf_put(buf, (const unsigned char *)string, strlen(string));
+ return strbuf_put(buf, (const unsigned char *)string, strlen(string));
}
-int cmark_strbuf_vprintf(strbuf *buf, const char *format, va_list ap)
+int strbuf_vprintf(strbuf *buf, const char *format, va_list ap)
{
const int expected_size = buf->size + (strlen(format) * 2);
int len;
@@ -174,7 +174,7 @@ int cmark_strbuf_vprintf(strbuf *buf, const char *format, va_list ap)
if (len < 0) {
free(buf->ptr);
- buf->ptr = cmark_strbuf__oom;
+ buf->ptr = strbuf__oom;
return -1;
}
@@ -189,19 +189,19 @@ int cmark_strbuf_vprintf(strbuf *buf, const char *format, va_list ap)
return 0;
}
-int cmark_strbuf_printf(strbuf *buf, const char *format, ...)
+int strbuf_printf(strbuf *buf, const char *format, ...)
{
int r;
va_list ap;
va_start(ap, format);
- r = cmark_strbuf_vprintf(buf, format, ap);
+ r = strbuf_vprintf(buf, format, ap);
va_end(ap);
return r;
}
-void cmark_strbuf_copy_cstr(char *data, int datasize, const strbuf *buf)
+void strbuf_copy_cstr(char *data, int datasize, const strbuf *buf)
{
int copylen;
@@ -219,29 +219,29 @@ void cmark_strbuf_copy_cstr(char *data, int datasize, const strbuf *buf)
data[copylen] = '\0';
}
-void cmark_strbuf_swap(strbuf *buf_a, strbuf *buf_b)
+void strbuf_swap(strbuf *buf_a, strbuf *buf_b)
{
strbuf t = *buf_a;
*buf_a = *buf_b;
*buf_b = t;
}
-unsigned char *cmark_strbuf_detach(strbuf *buf)
+unsigned char *strbuf_detach(strbuf *buf)
{
unsigned char *data = buf->ptr;
- if (buf->asize == 0 || buf->ptr == cmark_strbuf__oom) {
+ if (buf->asize == 0 || buf->ptr == strbuf__oom) {
/* return an empty string */
return (unsigned char *)calloc(1, 1);
}
- cmark_strbuf_init(buf, 0);
+ strbuf_init(buf, 0);
return data;
}
-void cmark_strbuf_attach(strbuf *buf, unsigned char *ptr, int asize)
+void strbuf_attach(strbuf *buf, unsigned char *ptr, int asize)
{
- cmark_strbuf_free(buf);
+ strbuf_free(buf);
if (ptr) {
buf->ptr = ptr;
@@ -251,18 +251,18 @@ void cmark_strbuf_attach(strbuf *buf, unsigned char *ptr, int asize)
else /* pass 0 to fall back on strlen + 1 */
buf->asize = buf->size + 1;
} else {
- cmark_strbuf_grow(buf, asize);
+ strbuf_grow(buf, asize);
}
}
-int cmark_strbuf_cmp(const strbuf *a, const strbuf *b)
+int strbuf_cmp(const strbuf *a, const strbuf *b)
{
int result = memcmp(a->ptr, b->ptr, MIN(a->size, b->size));
return (result != 0) ? result :
(a->size < b->size) ? -1 : (a->size > b->size) ? 1 : 0;
}
-int cmark_strbuf_strchr(const strbuf *buf, int c, int pos)
+int strbuf_strchr(const strbuf *buf, int c, int pos)
{
const unsigned char *p = (unsigned char *)memchr(buf->ptr + pos, c, buf->size - pos);
if (!p)
@@ -271,7 +271,7 @@ int cmark_strbuf_strchr(const strbuf *buf, int c, int pos)
return (int)(p - (const unsigned char *)buf->ptr);
}
-int cmark_strbuf_strrchr(const strbuf *buf, int c, int pos)
+int strbuf_strrchr(const strbuf *buf, int c, int pos)
{
int i;
@@ -283,7 +283,7 @@ int cmark_strbuf_strrchr(const strbuf *buf, int c, int pos)
return -1;
}
-void cmark_strbuf_truncate(strbuf *buf, int len)
+void strbuf_truncate(strbuf *buf, int len)
{
if (len < buf->size) {
buf->size = len;
@@ -291,7 +291,7 @@ void cmark_strbuf_truncate(strbuf *buf, int len)
}
}
-void cmark_strbuf_drop(strbuf *buf, int n)
+void strbuf_drop(strbuf *buf, int n)
{
if (n > 0) {
buf->size = buf->size - n;
@@ -302,7 +302,7 @@ void cmark_strbuf_drop(strbuf *buf, int n)
}
}
-void cmark_strbuf_rtrim(strbuf *buf)
+void strbuf_rtrim(strbuf *buf)
{
if (!buf->size)
return;
@@ -317,7 +317,7 @@ void cmark_strbuf_rtrim(strbuf *buf)
buf->ptr[buf->size] = '\0';
}
-void cmark_strbuf_trim(strbuf *buf)
+void strbuf_trim(strbuf *buf)
{
int i = 0;
@@ -327,14 +327,14 @@ void cmark_strbuf_trim(strbuf *buf)
while (i < buf->size && isspace(buf->ptr[i]))
i++;
- cmark_strbuf_drop(buf, i);
+ strbuf_drop(buf, i);
- cmark_strbuf_rtrim(buf);
+ strbuf_rtrim(buf);
}
// Destructively modify string, collapsing consecutive
// space and newline characters into a single space.
-void cmark_strbuf_normalize_whitespace(strbuf *s)
+void strbuf_normalize_whitespace(strbuf *s)
{
bool last_char_was_space = false;
int r, w;
@@ -356,11 +356,11 @@ void cmark_strbuf_normalize_whitespace(strbuf *s)
}
}
- cmark_strbuf_truncate(s, w);
+ strbuf_truncate(s, w);
}
// Destructively unescape a string: remove backslashes before punctuation chars.
-extern void cmark_strbuf_unescape(strbuf *buf)
+extern void strbuf_unescape(strbuf *buf)
{
int r, w;
@@ -371,5 +371,5 @@ extern void cmark_strbuf_unescape(strbuf *buf)
buf->ptr[w++] = buf->ptr[r];
}
- cmark_strbuf_truncate(buf, w);
+ strbuf_truncate(buf, w);
}
diff --git a/src/buffer.h b/src/buffer.h
index 7401b22..c827ea8 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -4,7 +4,6 @@
#include <stddef.h>
#include <stdarg.h>
#include "config.h"
-#include "cmark_export.h"
#ifdef __cplusplus
extern "C" {
@@ -13,15 +12,13 @@ extern "C" {
typedef struct {
unsigned char *ptr;
int asize, size;
-} cmark_strbuf;
+} strbuf;
-CMARK_EXPORT
-extern unsigned char cmark_strbuf__initbuf[];
+extern unsigned char strbuf__initbuf[];
-CMARK_EXPORT
-extern unsigned char cmark_strbuf__oom[];
+extern unsigned char strbuf__oom[];
-#define CMARK_GH_BUF_INIT { cmark_strbuf__initbuf, 0, 0 }
+#define GH_BUF_INIT { strbuf__initbuf, 0, 0 }
/**
* Initialize a strbuf structure.
@@ -29,8 +26,7 @@ extern unsigned char cmark_strbuf__oom[];
* For the cases where GH_BUF_INIT cannot be used to do static
* initialization.
*/
-CMARK_EXPORT
-void cmark_strbuf_init(cmark_strbuf *buf, int initial_size);
+void strbuf_init(strbuf *buf, int initial_size);
/**
* Attempt to grow the buffer to hold at least `target_size` bytes.
@@ -40,8 +36,7 @@ void cmark_strbuf_init(cmark_strbuf *buf, int initial_size);
* existing buffer content will be preserved, but calling code must handle
* that buffer was not expanded.
*/
-CMARK_EXPORT
-int cmark_strbuf_try_grow(cmark_strbuf *buf, int target_size, bool mark_oom);
+int strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom);
/**
* Grow the buffer to hold at least `target_size` bytes.
@@ -51,13 +46,10 @@ int cmark_strbuf_try_grow(cmark_strbuf *buf, int target_size, bool mark_oom);
*
* @return 0 on success or -1 on failure
*/
-CMARK_EXPORT
-int cmark_strbuf_grow(cmark_strbuf *buf, int target_size);
+int strbuf_grow(strbuf *buf, int target_size);
-CMARK_EXPORT
-void cmark_strbuf_free(cmark_strbuf *buf);
-CMARK_EXPORT
-void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b);
+void strbuf_free(strbuf *buf);
+void strbuf_swap(strbuf *buf_a, strbuf *buf_b);
/**
* Test if there have been any reallocation failures with this strbuf.
@@ -70,28 +62,22 @@ void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b);
*
* @return false if no error, true if allocation error
*/
-CMARK_EXPORT
-bool cmark_strbuf_oom(const cmark_strbuf *buf);
+bool strbuf_oom(const strbuf *buf);
-CMARK_EXPORT
-size_t cmark_strbuf_len(const cmark_strbuf *buf);
+size_t strbuf_len(const strbuf *buf);
-CMARK_EXPORT
-int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b);
+int strbuf_cmp(const strbuf *a, const strbuf *b);
-CMARK_EXPORT
-void cmark_strbuf_attach(cmark_strbuf *buf, unsigned char *ptr, int asize);
-CMARK_EXPORT
-unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
-CMARK_EXPORT
-void cmark_strbuf_copy_cstr(char *data, int datasize, const cmark_strbuf *buf);
+void strbuf_attach(strbuf *buf, unsigned char *ptr, int asize);
+unsigned char *strbuf_detach(strbuf *buf);
+void strbuf_copy_cstr(char *data, int datasize, const strbuf *buf);
-static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf)
+static inline const char *strbuf_cstr(const strbuf *buf)
{
return (char *)buf->ptr;
}
-#define cmark_strbuf_at(buf, n) ((buf)->ptr[n])
+#define strbuf_at(buf, n) ((buf)->ptr[n])
/*
* Functions below that return int value error codes will return 0 on
@@ -101,74 +87,24 @@ static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf)
* return code of these functions and call them in a series then just call
* strbuf_oom at the end.
*/
-CMARK_EXPORT
-int cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data, int len);
-CMARK_EXPORT
-int cmark_strbuf_sets(cmark_strbuf *buf, const char *string);
-CMARK_EXPORT
-int cmark_strbuf_putc(cmark_strbuf *buf, int c);
-CMARK_EXPORT
-int cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data, int len);
-CMARK_EXPORT
-int cmark_strbuf_puts(cmark_strbuf *buf, const char *string);
-CMARK_EXPORT
-int cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...)
+int strbuf_set(strbuf *buf, const unsigned char *data, int len);
+int strbuf_sets(strbuf *buf, const char *string);
+int strbuf_putc(strbuf *buf, int c);
+int strbuf_put(strbuf *buf, const unsigned char *data, int len);
+int strbuf_puts(strbuf *buf, const char *string);
+int strbuf_printf(strbuf *buf, const char *format, ...)
CMARK_ATTRIBUTE((format (printf, 2, 3)));
-CMARK_EXPORT
-int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap);
-CMARK_EXPORT
-void cmark_strbuf_clear(cmark_strbuf *buf);
-
-CMARK_EXPORT
-int cmark_strbuf_strchr(const cmark_strbuf *buf, int c, int pos);
-CMARK_EXPORT
-int cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, int pos);
-CMARK_EXPORT
-void cmark_strbuf_drop(cmark_strbuf *buf, int n);
-CMARK_EXPORT
-void cmark_strbuf_truncate(cmark_strbuf *buf, int len);
-CMARK_EXPORT
-void cmark_strbuf_rtrim(cmark_strbuf *buf);
-CMARK_EXPORT
-void cmark_strbuf_trim(cmark_strbuf *buf);
-CMARK_EXPORT
-void cmark_strbuf_normalize_whitespace(cmark_strbuf *s);
-CMARK_EXPORT
-void cmark_strbuf_unescape(cmark_strbuf *s);
-
-// Convenience macros
-#define strbuf cmark_strbuf
-#define strbuf__initbuf cmark_strbuf__initbuf
-#define strbuf__oom cmark_strbuf__oom
-#define GH_BUF_INIT CMARK_GH_BUF_INIT
-#define strbuf_init cmark_strbuf_init
-#define strbuf_try_grow cmark_strbuf_try_grow
-#define strbuf_grow cmark_strbuf_grow
-#define strbuf_free cmark_strbuf_free
-#define strbuf_swap cmark_strbuf_swap
-#define strbuf_oom cmark_strbuf_oom
-#define strbuf_len cmark_strbuf_len
-#define strbuf_cmp cmark_strbuf_cmp
-#define strbuf_attach cmark_strbuf_attach
-#define strbuf_detach cmark_strbuf_detach
-#define strbuf_copy_cstr cmark_strbuf_copy_cstr
-#define strbuf_at cmark_strbuf_at
-#define strbuf_set cmark_strbuf_set
-#define strbuf_sets cmark_strbuf_sets
-#define strbuf_putc cmark_strbuf_putc
-#define strbuf_put cmark_strbuf_put
-#define strbuf_puts cmark_strbuf_puts
-#define strbuf_printf cmark_strbuf_printf
-#define strbuf_vprintf cmark_strbuf_vprintf
-#define strbuf_clear cmark_strbuf_clear
-#define strbuf_strchr cmark_strbuf_strchr
-#define strbuf_strrchr cmark_strbuf_strrchr
-#define strbuf_drop cmark_strbuf_drop
-#define strbuf_truncate cmark_strbuf_truncate
-#define strbuf_rtrim cmark_strbuf_rtrim
-#define strbuf_trim cmark_strbuf_trim
-#define strbuf_normalize_whitespace cmark_strbuf_normalize_whitespace
-#define strbuf_unescape cmark_strbuf_unescape
+int strbuf_vprintf(strbuf *buf, const char *format, va_list ap);
+void strbuf_clear(strbuf *buf);
+
+int strbuf_strchr(const strbuf *buf, int c, int pos);
+int strbuf_strrchr(const strbuf *buf, int c, int pos);
+void strbuf_drop(strbuf *buf, int n);
+void strbuf_truncate(strbuf *buf, int len);
+void strbuf_rtrim(strbuf *buf);
+void strbuf_trim(strbuf *buf);
+void strbuf_normalize_whitespace(strbuf *s);
+void strbuf_unescape(strbuf *s);
#ifdef __cplusplus
}
diff --git a/src/chunk.h b/src/chunk.h
index 22594b1..b29c1b9 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -11,9 +11,9 @@ typedef struct {
unsigned char *data;
int len;
int alloc; // also implies a NULL-terminated string
-} cmark_chunk;
+} chunk;
-static inline void cmark_chunk_free(cmark_chunk *c)
+static inline void chunk_free(chunk *c)
{
if (c->alloc)
free(c->data);
@@ -23,7 +23,7 @@ static inline void cmark_chunk_free(cmark_chunk *c)
c->len = 0;
}
-static inline void cmark_chunk_ltrim(cmark_chunk *c)
+static inline void chunk_ltrim(chunk *c)
{
assert(!c->alloc);
@@ -33,7 +33,7 @@ static inline void cmark_chunk_ltrim(cmark_chunk *c)
}
}
-static inline void cmark_chunk_rtrim(cmark_chunk *c)
+static inline void chunk_rtrim(chunk *c)
{
while (c->len > 0) {
if (!isspace(c->data[c->len - 1]))
@@ -43,19 +43,19 @@ static inline void cmark_chunk_rtrim(cmark_chunk *c)
}
}
-static inline void cmark_chunk_trim(cmark_chunk *c)
+static inline void chunk_trim(chunk *c)
{
- cmark_chunk_ltrim(c);
- cmark_chunk_rtrim(c);
+ chunk_ltrim(c);
+ chunk_rtrim(c);
}
-static inline int cmark_chunk_strchr(cmark_chunk *ch, int c, int offset)
+static inline int chunk_strchr(chunk *ch, int c, int offset)
{
const unsigned char *p = (unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
return p ? (int)(p - ch->data) : ch->len;
}
-static inline const char *cmark_chunk_to_cstr(cmark_chunk *c)
+static inline const char *chunk_to_cstr(chunk *c)
{
unsigned char *str;
@@ -73,7 +73,7 @@ static inline const char *cmark_chunk_to_cstr(cmark_chunk *c)
return (char *)str;
}
-static inline void cmark_chunk_set_cstr(cmark_chunk *c, const char *str)
+static inline void chunk_set_cstr(chunk *c, const char *str)
{
if (c->alloc) {
free(c->data);
@@ -84,39 +84,27 @@ static inline void cmark_chunk_set_cstr(cmark_chunk *c, const char *str)
memcpy(c->data, str, c->len + 1);
}
-static inline cmark_chunk cmark_chunk_literal(const char *data)
+static inline chunk chunk_literal(const char *data)
{
- cmark_chunk c = {(unsigned char *)data, data ? strlen(data) : 0, 0};
+ chunk c = {(unsigned char *)data, data ? strlen(data) : 0, 0};
return c;
}
-static inline cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, int pos, int len)
+static inline chunk chunk_dup(const chunk *ch, int pos, int len)
{
- cmark_chunk c = {ch->data + pos, len, 0};
+ chunk c = {ch->data + pos, len, 0};
return c;
}
-static inline cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf)
+static inline chunk chunk_buf_detach(strbuf *buf)
{
- cmark_chunk c;
+ chunk c;
c.len = buf->size;
- c.data = cmark_strbuf_detach(buf);
+ c.data = strbuf_detach(buf);
c.alloc = 1;
return c;
}
-// Convenience macros
-#define chunk cmark_chunk
-#define chunk_free cmark_chunk_free
-#define chunk_ltrim cmark_chunk_ltrim
-#define chunk_rtrim cmark_chunk_rtrim
-#define chunk_trim cmark_chunk_trim
-#define chunk_strchr cmark_chunk_strchr
-#define chunk_to_cstr cmark_chunk_to_cstr
-#define chunk_literal cmark_chunk_literal
-#define chunk_dup cmark_chunk_dup
-#define chunk_buf_detach cmark_chunk_buf_detach
-
#endif
diff --git a/src/inlines.c b/src/inlines.c
index 08a934b..2b6f788 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -80,13 +80,13 @@ static inline cmark_node *make_link(cmark_node *label, unsigned char *url, unsig
return e;
}
-static inline cmark_node* make_autolink(cmark_node* label, cmark_chunk url, int is_email)
+static inline cmark_node* make_autolink(cmark_node* label, chunk url, int is_email)
{
return make_link(label, cmark_clean_autolink(&url, is_email), NULL);
}
// Create an inline with a literal string value.
-static inline cmark_node* make_literal(cmark_node_type t, cmark_chunk s)
+static inline cmark_node* make_literal(cmark_node_type t, chunk s)
{
cmark_node * e = (cmark_node *)calloc(1, sizeof(*e));
if(e != NULL) {
diff --git a/src/inlines.h b/src/inlines.h
index d2ccfb4..b4897d7 100644
--- a/src/inlines.h
+++ b/src/inlines.h
@@ -5,12 +5,12 @@
extern "C" {
#endif
-unsigned char *cmark_clean_url(cmark_chunk *url);
-unsigned char *cmark_clean_title(cmark_chunk *title);
+unsigned char *cmark_clean_url(chunk *url);
+unsigned char *cmark_clean_title(chunk *title);
void cmark_parse_inlines(cmark_node* parent, cmark_reference_map *refmap);
-int cmark_parse_reference_inline(cmark_strbuf *input, cmark_reference_map *refmap);
+int cmark_parse_reference_inline(strbuf *input, cmark_reference_map *refmap);
#ifdef __cplusplus
}
diff --git a/src/node.c b/src/node.c
index 980229e..e021d64 100644
--- a/src/node.c
+++ b/src/node.c
@@ -46,7 +46,7 @@ void S_free_nodes(cmark_node *e)
case NODE_TEXT:
case NODE_INLINE_HTML:
case NODE_INLINE_CODE:
- cmark_chunk_free(&e->as.literal);
+ chunk_free(&e->as.literal);
break;
case NODE_LINK:
case NODE_IMAGE:
@@ -184,12 +184,12 @@ cmark_node_get_string_content(cmark_node *node) {
switch (node->type) {
case NODE_CODE_BLOCK:
case NODE_HTML:
- return cmark_strbuf_cstr(&node->string_content);
+ return strbuf_cstr(&node->string_content);
case NODE_TEXT:
case NODE_INLINE_HTML:
case NODE_INLINE_CODE:
- return cmark_chunk_to_cstr(&node->as.literal);
+ return chunk_to_cstr(&node->as.literal);
default:
break;
@@ -207,13 +207,13 @@ cmark_node_set_string_content(cmark_node *node, const char *content) {
switch (node->type) {
case NODE_CODE_BLOCK:
case NODE_HTML:
- cmark_strbuf_sets(&node->string_content, content);
+ strbuf_sets(&node->string_content, content);
return 1;
case NODE_TEXT:
case NODE_INLINE_HTML:
case NODE_INLINE_CODE:
- cmark_chunk_set_cstr(&node->as.literal, content);
+ chunk_set_cstr(&node->as.literal, content);
return 1;
default:
@@ -356,7 +356,7 @@ cmark_node_get_fence_info(cmark_node *node) {
}
if (node->type == NODE_CODE_BLOCK) {
- return cmark_strbuf_cstr(&node->as.code.info);
+ return strbuf_cstr(&node->as.code.info);
}
else {
return NULL;
@@ -370,7 +370,7 @@ cmark_node_set_fence_info(cmark_node *node, const char *info) {
}
if (node->type == NODE_CODE_BLOCK) {
- cmark_strbuf_sets(&node->as.code.info, info);
+ strbuf_sets(&node->as.code.info, info);
return 1;
}
else {
diff --git a/src/node.h b/src/node.h
index b842ed8..e015c12 100644
--- a/src/node.h
+++ b/src/node.h
@@ -26,7 +26,7 @@ typedef struct {
int fence_length;
int fence_offset;
unsigned char fence_char;
- cmark_strbuf info;
+ strbuf info;
} cmark_code;
typedef struct {
@@ -54,10 +54,10 @@ struct cmark_node {
bool open;
bool last_line_blank;
- cmark_strbuf string_content;
+ strbuf string_content;
union {
- cmark_chunk literal;
+ chunk literal;
cmark_list list;
cmark_code code;
cmark_header header;
diff --git a/src/parser.h b/src/parser.h
index 9d65b67..1f63d9c 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -16,8 +16,8 @@ struct cmark_parser {
struct cmark_node* root;
struct cmark_node* current;
int line_number;
- cmark_strbuf *curline;
- cmark_strbuf *linebuf;
+ strbuf *curline;
+ strbuf *linebuf;
};
#ifdef __cplusplus
diff --git a/src/references.h b/src/references.h
index 69325bb..58658b6 100644
--- a/src/references.h
+++ b/src/references.h
@@ -27,8 +27,8 @@ typedef struct cmark_reference_map cmark_reference_map;
cmark_reference_map *cmark_reference_map_new(void);
void cmark_reference_map_free(cmark_reference_map *map);
-cmark_reference* cmark_reference_lookup(cmark_reference_map *map, cmark_chunk *label);
-extern void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label, cmark_chunk *url, cmark_chunk *title);
+cmark_reference* cmark_reference_lookup(cmark_reference_map *map, chunk *label);
+extern void cmark_reference_create(cmark_reference_map *map, chunk *label, chunk *url, chunk *title);
#ifdef __cplusplus
}
diff --git a/src/utf8.h b/src/utf8.h
index 7df1573..9558576 100644
--- a/src/utf8.h
+++ b/src/utf8.h
@@ -8,10 +8,10 @@
extern "C" {
#endif
-void utf8proc_case_fold(cmark_strbuf *dest, const uint8_t *str, int len);
-void utf8proc_encode_char(int32_t uc, cmark_strbuf *buf);
+void utf8proc_case_fold(strbuf *dest, const uint8_t *str, int len);
+void utf8proc_encode_char(int32_t uc, strbuf *buf);
int utf8proc_iterate(const uint8_t *str, int str_len, int32_t *dst);
-void utf8proc_detab(cmark_strbuf *dest, const uint8_t *line, size_t size);
+void utf8proc_detab(strbuf *dest, const uint8_t *line, size_t size);
int utf8proc_is_space(int32_t uc);
int utf8proc_is_punctuation(int32_t uc);