summaryrefslogtreecommitdiff
path: root/src/runtime/c/gu
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/c/gu')
-rw-r--r--src/runtime/c/gu/sysdeps.h2
-rw-r--r--src/runtime/c/gu/ucs.c17
-rw-r--r--src/runtime/c/gu/ucs.h16
-rw-r--r--src/runtime/c/gu/utf8.c32
-rw-r--r--src/runtime/c/gu/utf8.h28
5 files changed, 45 insertions, 50 deletions
diff --git a/src/runtime/c/gu/sysdeps.h b/src/runtime/c/gu/sysdeps.h
index c13945b5d..fc889ce19 100644
--- a/src/runtime/c/gu/sysdeps.h
+++ b/src/runtime/c/gu/sysdeps.h
@@ -1,8 +1,6 @@
#ifndef GU_SYSDEPS_H_
#define GU_SYSDEPS_H_
-#include <config.h>
-
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
# define GU_GNUC
#endif
diff --git a/src/runtime/c/gu/ucs.c b/src/runtime/c/gu/ucs.c
index dc210b312..42012e3e0 100644
--- a/src/runtime/c/gu/ucs.c
+++ b/src/runtime/c/gu/ucs.c
@@ -1,6 +1,6 @@
#include <gu/ucs.h>
#include <gu/assert.h>
-#include <config.h>
+#include "config.h"
GU_DEFINE_TYPE(GuUCSExn, abstract, _);
@@ -131,5 +131,16 @@ gu_ucs_to_str(const GuUCS* ubuf, size_t len, char* cbuf, GuExn* err)
extern inline bool
gu_ucs_valid(GuUCS ucs);
-extern inline GuUCS
-gu_char_ucs(char c);
+GuUCS
+gu_char_ucs(char c)
+{
+ gu_require(gu_char_is_valid(c));
+#ifdef CHAR_ASCII
+ GuUCS u = (GuUCS) c;
+#else
+ extern const uint8_t gu_ucs_ascii_reverse_[CHAR_MAX];
+ GuUCS u = gu_ucs_ascii_reverse_[(unsigned char) c];
+#endif
+ gu_ensure(u < 0x80);
+ return u;
+}
diff --git a/src/runtime/c/gu/ucs.h b/src/runtime/c/gu/ucs.h
index 0c9e7cce0..5764e60c8 100644
--- a/src/runtime/c/gu/ucs.h
+++ b/src/runtime/c/gu/ucs.h
@@ -5,7 +5,6 @@
#include <gu/exn.h>
#include <gu/assert.h>
-
#if defined(__STDC_ISO_10646__) && WCHAR_MAX >= 0x10FFFF
#include <wchar.h>
#define GU_UCS_WCHAR
@@ -25,19 +24,8 @@ gu_ucs_valid(GuUCS ucs)
return ucs >= 0 && ucs <= GU_UCS_MAX;
}
-inline GuUCS
-gu_char_ucs(char c)
-{
- gu_require(gu_char_is_valid(c));
-#ifdef CHAR_ASCII
- GuUCS u = (GuUCS) c;
-#else
- extern const uint8_t gu_ucs_ascii_reverse_[CHAR_MAX];
- GuUCS u = gu_ucs_ascii_reverse_[(unsigned char) c];
-#endif
- gu_ensure(u < 0x80);
- return u;
-}
+GuUCS
+gu_char_ucs(char c);
char
gu_ucs_char(GuUCS uc, GuExn* err);
diff --git a/src/runtime/c/gu/utf8.c b/src/runtime/c/gu/utf8.c
index b1d5996c2..fb0f2c150 100644
--- a/src/runtime/c/gu/utf8.c
+++ b/src/runtime/c/gu/utf8.c
@@ -1,6 +1,6 @@
#include <gu/assert.h>
#include <gu/utf8.h>
-#include <config.h>
+#include "config.h"
GuUCS
gu_utf8_decode(const uint8_t** src_inout)
@@ -73,7 +73,6 @@ fail:
return 0;
}
-
size_t
gu_advance_utf8(GuUCS ucs, uint8_t* buf)
{
@@ -105,6 +104,19 @@ gu_in_utf8_char_(GuIn* in, GuExn* err)
return gu_ucs_char(gu_in_utf8(in, err), err);
}
+char
+gu_in_utf8_char(GuIn* in, GuExn* err)
+{
+#ifdef CHAR_ASCII
+ int i = gu_in_peek_u8(in);
+ if (i >= 0 && i < 0x80) {
+ gu_in_consume(in, 1);
+ return (char) i;
+ }
+#endif
+ return gu_in_utf8_char_(in, err);
+}
+
void
gu_out_utf8_long_(GuUCS ucs, GuOut* out, GuExn* err)
{
@@ -210,11 +222,17 @@ void gu_str_out_utf8_(const char* str, GuOut* out, GuExn* err)
#endif
-extern inline void
-gu_str_out_utf8(const char* str, GuOut* out, GuExn* err);
-
extern inline GuUCS
gu_in_utf8(GuIn* in, GuExn* err);
-extern inline char
-gu_in_utf8_char(GuIn* in, GuExn* err);
+void
+gu_str_out_utf8(const char* str, GuOut* out, GuExn* err)
+{
+#ifdef CHAR_ASCII
+ gu_out_bytes(out, (const uint8_t*) str, strlen(str), err);
+#else
+ extern void
+ gu_str_out_utf8_(const char* str, GuOut* out, GuExn* err);
+ gu_str_out_utf8_(str, out, err);
+#endif
+}
diff --git a/src/runtime/c/gu/utf8.h b/src/runtime/c/gu/utf8.h
index c4112b5a5..410010c3f 100644
--- a/src/runtime/c/gu/utf8.h
+++ b/src/runtime/c/gu/utf8.h
@@ -18,19 +18,8 @@ gu_in_utf8(GuIn* in, GuExn* err)
}
-inline char
-gu_in_utf8_char(GuIn* in, GuExn* err)
-{
-#ifdef CHAR_ASCII
- int i = gu_in_peek_u8(in);
- if (i >= 0 && i < 0x80) {
- gu_in_consume(in, 1);
- return (char) i;
- }
-#endif
- extern char gu_in_utf8_char_(GuIn* in, GuExn* err);
- return gu_in_utf8_char_(in, err);
-}
+char
+gu_in_utf8_char(GuIn* in, GuExn* err);
void
gu_out_utf8_long_(GuUCS ucs, GuOut* out, GuExn* err);
@@ -52,16 +41,7 @@ gu_utf32_out_utf8(const GuUCS* src, size_t len, GuOut* out, GuExn* err);
GuUCS
gu_utf8_decode(const uint8_t** utf8);
-inline void
-gu_str_out_utf8(const char* str, GuOut* out, GuExn* err)
-{
-#ifdef CHAR_ASCII
- gu_out_bytes(out, (const uint8_t*) str, strlen(str), err);
-#else
- extern void
- gu_str_out_utf8_(const char* str, GuOut* out, GuExn* err);
- gu_str_out_utf8_(str, out, err);
-#endif
-}
+void
+gu_str_out_utf8(const char* str, GuOut* out, GuExn* err);
#endif // GU_UTF8_H_