summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-08-10 20:22:29 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-08-10 20:22:29 -0700
commitf1b1e2ec71f50a00850db3a68c421a2d79bba115 (patch)
treefccd86d01fb7d6bb7a7fabdc0b451cd113a71b9d
parent735098e097ad62bdc4b1121c6c0c983eb7483485 (diff)
Don't include static in CMARK_INLINE.
ALso don't set CMARK_INLINE to __inline if we're compiling under MSVC in cplusplus mode.
-rw-r--r--src/buffer.h6
-rw-r--r--src/chunk.h24
-rw-r--r--src/config.h.in4
3 files changed, 18 insertions, 16 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 88b79f3..6fd0cae 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -48,7 +48,7 @@ unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
void cmark_strbuf_copy_cstr(char *data, bufsize_t datasize,
const cmark_strbuf *buf);
-CMARK_INLINE const char *cmark_strbuf_cstr(const cmark_strbuf *buf) {
+static CMARK_INLINE const char *cmark_strbuf_cstr(const cmark_strbuf *buf) {
return (char *)buf->ptr;
}
@@ -75,14 +75,14 @@ void cmark_strbuf_unescape(cmark_strbuf *s);
/* Print error and abort. */
void cmark_strbuf_overflow_err(void);
-CMARK_INLINE bufsize_t cmark_strbuf_check_bufsize(size_t size) {
+static CMARK_INLINE bufsize_t cmark_strbuf_check_bufsize(size_t size) {
if (size > BUFSIZE_MAX) {
cmark_strbuf_overflow_err();
}
return (bufsize_t)size;
}
-CMARK_INLINE bufsize_t cmark_strbuf_safe_strlen(const char *str) {
+static CMARK_INLINE bufsize_t cmark_strbuf_safe_strlen(const char *str) {
return cmark_strbuf_check_bufsize(strlen(str));
}
diff --git a/src/chunk.h b/src/chunk.h
index 90cf568..a8a11f6 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -16,7 +16,7 @@ typedef struct {
bufsize_t alloc; // also implies a NULL-terminated string
} cmark_chunk;
-CMARK_INLINE void cmark_chunk_free(cmark_chunk *c) {
+static CMARK_INLINE void cmark_chunk_free(cmark_chunk *c) {
if (c->alloc)
free(c->data);
@@ -25,7 +25,7 @@ CMARK_INLINE void cmark_chunk_free(cmark_chunk *c) {
c->len = 0;
}
-CMARK_INLINE void cmark_chunk_ltrim(cmark_chunk *c) {
+static CMARK_INLINE void cmark_chunk_ltrim(cmark_chunk *c) {
assert(!c->alloc);
while (c->len && cmark_isspace(c->data[0])) {
@@ -34,7 +34,7 @@ CMARK_INLINE void cmark_chunk_ltrim(cmark_chunk *c) {
}
}
-CMARK_INLINE void cmark_chunk_rtrim(cmark_chunk *c) {
+static CMARK_INLINE void cmark_chunk_rtrim(cmark_chunk *c) {
while (c->len > 0) {
if (!cmark_isspace(c->data[c->len - 1]))
break;
@@ -43,19 +43,19 @@ CMARK_INLINE void cmark_chunk_rtrim(cmark_chunk *c) {
}
}
-CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) {
+static CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) {
cmark_chunk_ltrim(c);
cmark_chunk_rtrim(c);
}
-CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
+static CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
bufsize_t offset) {
const unsigned char *p =
(unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
return p ? (bufsize_t)(p - ch->data) : ch->len;
}
-CMARK_INLINE const char *cmark_chunk_to_cstr(cmark_chunk *c) {
+static CMARK_INLINE const char *cmark_chunk_to_cstr(cmark_chunk *c) {
unsigned char *str;
if (c->alloc) {
@@ -74,7 +74,8 @@ CMARK_INLINE const char *cmark_chunk_to_cstr(cmark_chunk *c) {
return (char *)str;
}
-CMARK_INLINE void cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
+static CMARK_INLINE void
+cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
if (c->alloc) {
free(c->data);
}
@@ -90,19 +91,20 @@ CMARK_INLINE void cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
}
}
-CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) {
+static CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) {
bufsize_t len = data ? cmark_strbuf_safe_strlen(data) : 0;
cmark_chunk c = {(unsigned char *)data, len, 0};
return c;
}
-CMARK_INLINE cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, bufsize_t pos,
- bufsize_t len) {
+static CMARK_INLINE
+cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, bufsize_t pos,
+ bufsize_t len) {
cmark_chunk c = {ch->data + pos, len, 0};
return c;
}
-CMARK_INLINE cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf) {
+static CMARK_INLINE cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf) {
cmark_chunk c;
c.len = buf->size;
diff --git a/src/config.h.in b/src/config.h.in
index a392111..2792313 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -17,9 +17,9 @@
#endif
#ifndef CMARK_INLINE
- #ifdef _MSC_VER
+ #if defined(_MSC_VER) && !defined(__cplusplus)
#define CMARK_INLINE __inline
#else
- #define CMARK_INLINE static inline
+ #define CMARK_INLINE inline
#endif
#endif