Minor cleanup.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
diff --git a/src/md4c.c b/src/md4c.c
index 285d111..233b8ea 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -72,25 +72,47 @@
#define FALSE 0
#endif
-/* For falling through case labels in switch statements. */
-#if defined __clang__
- #if __clang_major__ >= 12
- #define MD4C_FALLTHROUGH() __attribute__((fallthrough))
- #else
- #define MD4C_FALLTHROUGH() ((void)0)
- #endif
-#elif defined __GNUC__
- #if __GNUC__ >= 7
- #define MD4C_FALLTHROUGH() __attribute__((fallthrough))
+#define MD_LOG(msg) \
+ do { \
+ if(ctx->parser.debug_log != NULL) \
+ ctx->parser.debug_log((msg), ctx->userdata); \
+ } while(0)
+
+#ifdef DEBUG
+ #define MD_ASSERT(cond) \
+ do { \
+ if(!(cond)) { \
+ MD_LOG(__FILE__ ":" STRINGIZE(__LINE__) ": " \
+ "Assertion '" STRINGIZE(cond) "' failed."); \
+ exit(1); \
+ } \
+ } while(0)
+
+ #define MD_UNREACHABLE() MD_ASSERT(1 == 0)
+#else
+ #ifdef __GNUC__
+ #define MD_ASSERT(cond) do { if(!(cond)) __builtin_unreachable(); } while(0)
+ #define MD_UNREACHABLE() do { __builtin_unreachable(); } while(0)
+ #elif defined _MSC_VER && _MSC_VER > 120
+ #define MD_ASSERT(cond) do { __assume(cond); } while(0)
+ #define MD_UNREACHABLE() do { __assume(0); } while(0)
#else
- #define MD4C_FALLTHROUGH() ((void)0)
+ #define MD_ASSERT(cond) do {} while(0)
+ #define MD_UNREACHABLE() do {} while(0)
#endif
+#endif
+
+/* For falling through case labels in switch statements. */
+#if defined __clang__ && __clang_major__ >= 12
+ #define MD_FALLTHROUGH() __attribute__((fallthrough))
+#elif defined __GNUC__ && __GNUC__ >= 7
+ #define MD_FALLTHROUGH() __attribute__((fallthrough))
#else
- #define MD4C_FALLTHROUGH() ((void)0)
+ #define MD_FALLTHROUGH() ((void)0)
#endif
/* Suppress "unused parameter" warnings. */
-#define MD4C_UNUSED(x) ((void)x)
+#define MD_UNUSED(x) ((void)x)
/************************
@@ -250,41 +272,6 @@ struct MD_VERBATIMLINE_tag {
};
-/*******************
- *** Debugging ***
- *******************/
-
-#define MD_LOG(msg) \
- do { \
- if(ctx->parser.debug_log != NULL) \
- ctx->parser.debug_log((msg), ctx->userdata); \
- } while(0)
-
-#ifdef DEBUG
- #define MD_ASSERT(cond) \
- do { \
- if(!(cond)) { \
- MD_LOG(__FILE__ ":" STRINGIZE(__LINE__) ": " \
- "Assertion '" STRINGIZE(cond) "' failed."); \
- exit(1); \
- } \
- } while(0)
-
- #define MD_UNREACHABLE() MD_ASSERT(1 == 0)
-#else
- #ifdef __GNUC__
- #define MD_ASSERT(cond) do { if(!(cond)) __builtin_unreachable(); } while(0)
- #define MD_UNREACHABLE() do { __builtin_unreachable(); } while(0)
- #elif defined _MSC_VER && _MSC_VER > 120
- #define MD_ASSERT(cond) do { __assume(cond); } while(0)
- #define MD_UNREACHABLE() do { __assume(0); } while(0)
- #else
- #define MD_ASSERT(cond) do {} while(0)
- #define MD_UNREACHABLE() do {} while(0)
- #endif
-#endif
-
-
/*****************
*** Helpers ***
*****************/
@@ -914,7 +901,7 @@ md_merge_lines(MD_CTX* ctx, OFF beg, OFF end, const MD_LINE* lines, int n_lines,
int line_index = 0;
OFF off = beg;
- MD4C_UNUSED(n_lines);
+ MD_UNUSED(n_lines);
while(1) {
const MD_LINE* line = &lines[line_index];
@@ -1257,7 +1244,7 @@ static int
md_is_hex_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, OFF* p_end)
{
OFF off = beg;
- MD4C_UNUSED(ctx);
+ MD_UNUSED(ctx);
while(off < max_end && ISXDIGIT_(text[off]) && off - beg <= 8)
off++;
@@ -1274,7 +1261,7 @@ static int
md_is_dec_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, OFF* p_end)
{
OFF off = beg;
- MD4C_UNUSED(ctx);
+ MD_UNUSED(ctx);
while(off < max_end && ISDIGIT_(text[off]) && off - beg <= 8)
off++;
@@ -1291,7 +1278,7 @@ static int
md_is_named_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, OFF* p_end)
{
OFF off = beg;
- MD4C_UNUSED(ctx);
+ MD_UNUSED(ctx);
if(off < max_end && ISALPHA_(text[off]))
off++;
@@ -1397,7 +1384,7 @@ md_build_attr_append_substr(MD_CTX* ctx, MD_ATTRIBUTE_BUILD* build,
static void
md_free_attribute(MD_CTX* ctx, MD_ATTRIBUTE_BUILD* build)
{
- MD4C_UNUSED(ctx);
+ MD_UNUSED(ctx);
if(build->substr_alloc > 0) {
free(build->text);
@@ -2698,7 +2685,7 @@ md_rollback(MD_CTX* ctx, int opener_index, int closer_index, int how)
mark_index = mark->prev;
break;
}
- MD4C_FALLTHROUGH();
+ MD_FALLTHROUGH();
default:
mark_index--;
break;
@@ -3961,8 +3948,8 @@ md_analyze_marks(MD_CTX* ctx, const MD_LINE* lines, int n_lines,
int mark_beg, int mark_end, const CHAR* mark_chars)
{
int i = mark_beg;
- MD4C_UNUSED(lines);
- MD4C_UNUSED(n_lines);
+ MD_UNUSED(lines);
+ MD_UNUSED(n_lines);
while(i < mark_end) {
MD_MARK* mark = &ctx->marks[i];
@@ -4181,7 +4168,7 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
}
break;
}
- MD4C_FALLTHROUGH();
+ MD_FALLTHROUGH();
case '*': /* Emphasis, strong emphasis. */
if(mark->flags & MD_MARK_OPENER) {
@@ -4280,7 +4267,7 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
break;
}
/* Pass through, if auto-link. */
- MD4C_FALLTHROUGH();
+ MD_FALLTHROUGH();
case '@': /* Permissive e-mail autolink. */
case ':': /* Permissive URL autolink. */
@@ -5559,7 +5546,7 @@ md_enter_child_containers(MD_CTX* ctx, int n_children, unsigned data)
case _T(')'):
case _T('.'):
is_ordered_list = TRUE;
- MD4C_FALLTHROUGH();
+ MD_FALLTHROUGH();
case _T('-'):
case _T('+'):
@@ -5605,7 +5592,7 @@ md_leave_child_containers(MD_CTX* ctx, int n_keep)
case _T(')'):
case _T('.'):
is_ordered_list = TRUE;
- MD4C_FALLTHROUGH();
+ MD_FALLTHROUGH();
case _T('-'):
case _T('+'):