aboutsummaryrefslogtreecommitdiffstats
path: root/text.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--text.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/text.c b/text.c
new file mode 100644
index 0000000..abea26a
--- /dev/null
+++ b/text.c
@@ -0,0 +1,46 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+#if defined(__linux__)
+# include <linux/kd.h>
+
+int
+have_micro_symbol(void)
+{
+ static int ret = -1;
+ if (ret < 0) {
+ struct unimapdesc desc;
+ struct unipair *pairs = NULL;
+ size_t i;
+ ret = 1;
+ desc.entry_ct = 0;
+ desc.entries = NULL;
+ if (ioctl(STDIN_FILENO, GIO_UNIMAP, &desc))
+ if (!desc.entry_ct)
+ goto out;
+ desc.entries = pairs = ecalloc(desc.entry_ct, sizeof(*pairs));
+ if (ioctl(STDIN_FILENO, GIO_UNIMAP, &desc))
+ goto out;
+ for (i = 0; i < desc.entry_ct; i++)
+ if (desc.entries[i++].unicode == 0xB5U)
+ goto out;
+ ret = 0;
+ out:
+ free(pairs);
+ }
+ return ret;
+}
+
+#else
+
+# if defined(__GNUC__)
+__attribute__((__const__))
+# endif
+int
+have_micro_symbol(void)
+{
+ return 1;
+}
+
+#endif