summaryrefslogtreecommitdiff
path: root/ustring.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>1999-07-31 18:44:53 +0000
committerSimon Tatham <anakin@pobox.com>1999-07-31 18:44:53 +0000
commit0d14833a9c76c51cc7417d8fd60bec9d92714b8e (patch)
treec0716d398e83bc746baad088d5dfc215d5fea483 /ustring.c
parent4c8c2b256ed01563a98b4cd820dc8ffef30d7fc1 (diff)
downloadhalibut-0d14833a9c76c51cc7417d8fd60bec9d92714b8e.zip
halibut-0d14833a9c76c51cc7417d8fd60bec9d92714b8e.tar.gz
halibut-0d14833a9c76c51cc7417d8fd60bec9d92714b8e.tar.bz2
halibut-0d14833a9c76c51cc7417d8fd60bec9d92714b8e.tar.xz
Further development work. Parser nearly finished
[originally from svn r187]
Diffstat (limited to 'ustring.c')
-rw-r--r--ustring.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/ustring.c b/ustring.c
new file mode 100644
index 0000000..00e26b6
--- /dev/null
+++ b/ustring.c
@@ -0,0 +1,47 @@
+/*
+ * ustring.c: Unicode string routines
+ */
+
+#include <wchar.h>
+#include "buttress.h"
+
+wchar_t *ustrdup(wchar_t *s) {
+ wchar_t *r;
+ if (s) {
+ r = smalloc((1+ustrlen(s)) * sizeof(wchar_t));
+ ustrcpy(r, s);
+ } else {
+ r = smalloc(1);
+ *r = 0;
+ }
+ return r;
+}
+
+char *ustrtoa(wchar_t *s, char *outbuf, int size) {
+ char *p;
+ if (!s) {
+ *outbuf = '\0';
+ return outbuf;
+ }
+ for (p = outbuf; *s && p < outbuf+size; p++,s++)
+ *p = *s;
+ if (p < outbuf+size)
+ *p = '\0';
+ else
+ outbuf[size-1] = '\0';
+ return outbuf;
+}
+
+int ustrlen(wchar_t *s) {
+ int len = 0;
+ while (*s++) len++;
+ return len;
+}
+
+wchar_t *ustrcpy(wchar_t *dest, wchar_t *source) {
+ wchar_t *ret = dest;
+ do {
+ *dest++ = *source;
+ } while (*source++);
+ return ret;
+}