From 86fda06897ccd4d610410f920923c6e1f3e2bf3d Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Mon, 29 Dec 2014 22:15:09 -0800
Subject: Added cmark_ctype.h with locale-independent isspace, ispunct, etc.

Otherwise cmark's behavior varies unpredictably with the locale.

`is_punctuation` in utf8.h has also been adjusted so that everything
that counts all ASCII symbol characters count as punctuation, even
though some are not in P* character classes.
---
 src/cmark_ctype.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 src/cmark_ctype.c

(limited to 'src/cmark_ctype.c')

diff --git a/src/cmark_ctype.c b/src/cmark_ctype.c
new file mode 100644
index 0000000..9ed4b5c
--- /dev/null
+++ b/src/cmark_ctype.c
@@ -0,0 +1,33 @@
+/**
+ * Returns 1 if c is a "whitespace" character as defined by the spec.
+ */
+int isspace(char c)
+{
+	return (c == 0x09 ||
+		c == 0x20 ||
+		c == 0x0a ||
+		c == 0x0d);
+}
+
+/**
+ * Returns 1 if c is an ascii punctuation character.
+ */
+int ispunct(char c)
+{
+	return ((c >= 33 && c <= 47) ||
+		(c >= 58 && c <= 64) ||
+		(c >= 91 && c <= 96) ||
+		(c >= 123 && c <= 126));
+}
+
+int isalnum(char c)
+{
+	return ((c >= 48 && c <= 57) ||
+		(c >= 65 && c <= 90) ||
+		(c >= 97 && c <= 122));
+}
+
+int isdigit(char c)
+{
+	return (c >= 48 && c <= 57);
+}
-- 
cgit v1.2.3