aboutsummaryrefslogtreecommitdiff
path: root/src/unicode.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-11-23 12:29:50 +0000
committerGinger Bill <bill@gingerbill.org>2016-11-23 12:29:50 +0000
commit4d30ef7eda0021f0cb827c7a218ef3afc6ce8b55 (patch)
tree9f31e2b07cf610300c1db3c511b84d9d2cc72d6b /src/unicode.cpp
parenta77c6b3e55c5857c9c0ba36baae2dbdcd7564cd4 (diff)
Change extensions .cpp to .c
Diffstat (limited to 'src/unicode.cpp')
-rw-r--r--src/unicode.cpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/unicode.cpp b/src/unicode.cpp
deleted file mode 100644
index 5c9f91f46..000000000
--- a/src/unicode.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#pragma warning(push)
-#pragma warning(disable: 4245)
-
-// #include "utf8proc/utf8proc.h"
-#include "utf8proc/utf8proc.c"
-
-#pragma warning(pop)
-
-bool rune_is_letter(Rune r) {
- if ((r < 0x80 && gb_char_is_alpha(cast(char)r)) ||
- r == '_') {
- return true;
- }
- switch (utf8proc_category(r)) {
- case UTF8PROC_CATEGORY_LU:
- case UTF8PROC_CATEGORY_LL:
- case UTF8PROC_CATEGORY_LT:
- case UTF8PROC_CATEGORY_LM:
- case UTF8PROC_CATEGORY_LO:
- return true;
- }
- return false;
-}
-
-bool rune_is_digit(Rune r) {
- if (r < 0x80 && gb_is_between(r, '0', '9')) {
- return true;
- }
- return utf8proc_category(r) == UTF8PROC_CATEGORY_ND;
-}
-
-bool rune_is_whitespace(Rune r) {
- switch (r) {
- case ' ':
- case '\t':
- case '\n':
- case '\r':
- return true;
- }
- return false;
-}
-
-
-bool is_string_an_identifier(String s) {
- if (s.len < 1) {
- return false;
- }
- isize offset = 0;
- while (offset < s.len) {
- bool ok = false;
- Rune r = -1;
- isize size = gb_utf8_decode(s.text+offset, s.len-offset, &r);
- if (offset == 0) {
- ok = rune_is_letter(r);
- } else {
- ok = rune_is_letter(r) || rune_is_digit(r);
- }
-
- if (!ok) {
- return false;
- }
- offset += size;
- }
-
- return offset == s.len;
-}