summaryrefslogtreecommitdiff
path: root/src/cmark_ctype.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-12-29 22:15:09 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-12-29 22:16:11 -0800
commit86fda06897ccd4d610410f920923c6e1f3e2bf3d (patch)
tree980d5b11b914223de03e1688503d40f9b4acbbec /src/cmark_ctype.c
parentd943eed9db668bb3399264d5c978e20882bc6098 (diff)
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.
Diffstat (limited to 'src/cmark_ctype.c')
-rw-r--r--src/cmark_ctype.c33
1 files changed, 33 insertions, 0 deletions
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);
+}