summaryrefslogtreecommitdiff
path: root/src/buffer.c
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 /src/buffer.c
parent831bf6de49ae58bd3630f40bdb6f8bc5371a33dd (diff)
Removed cmark_ prefix on chunk and strbuf.
This isn't needed any more since we don't expose these in the API.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c100
1 files changed, 50 insertions, 50 deletions
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);
}