commit 193dbfd0cc0d2cbe16206a6d566dad0ac31526eb
parent ccc6a0eca3ad29a37df8e25129148ddea0449a4b
Author: hhvn <dev@hhvn.uk>
Date: Tue, 24 May 2022 21:16:33 +0100
Move wctos/stowc to str.c
Diffstat:
3 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/src/hirc.h b/src/hirc.h
@@ -56,6 +56,8 @@ int param_len(char **params);
char ** param_create(char *msg);
/* str.c */
+wchar_t * stowc(char *str);
+char * wctos(wchar_t *str);
char * homepath(char *path);
int strcmp_n(const char *s1, const char *s2);
char * struntil(char *str, char until);
@@ -72,8 +74,6 @@ char * estrdup(const char *str);
void * talloc(size_t size);
char * tstrdup(const char *str);
wchar_t * ewcsdup(const wchar_t *str);
-wchar_t * stowc(char *str);
-char * wctos(wchar_t *str);
/* chan.c */
void chan_free(struct Channel *channel);
diff --git a/src/mem.c b/src/mem.c
@@ -93,32 +93,3 @@ ewcsdup(const wchar_t *str) {
}
return ret;
}
-
-/* Helper functions for widechar <-> utf-8 conversion */
-wchar_t *
-stowc(char *str) {
- wchar_t *ret;
- size_t len;
-
- if (!str) return NULL;
-
- len = mbstowcs(NULL, str, 0) + 1;
- if (!len) return NULL;
- ret = emalloc(len * sizeof(wchar_t));
- mbstowcs(ret, str, len);
- return ret;
-}
-
-char *
-wctos(wchar_t *str) {
- char *ret;
- size_t len;
-
- if (!str) return NULL;
-
- len = wcstombs(NULL, str, 0) + 1;
- if (!len) return NULL;
- ret = emalloc(len);
- wcstombs(ret, str, len);
- return ret;
-}
diff --git a/src/str.c b/src/str.c
@@ -22,6 +22,35 @@
#include <limits.h>
#include "hirc.h"
+/* Helper functions for widechar <-> utf-8 conversion */
+wchar_t *
+stowc(char *str) {
+ wchar_t *ret;
+ size_t len;
+
+ if (!str) return NULL;
+
+ len = mbstowcs(NULL, str, 0) + 1;
+ if (!len) return NULL;
+ ret = emalloc(len * sizeof(wchar_t));
+ mbstowcs(ret, str, len);
+ return ret;
+}
+
+char *
+wctos(wchar_t *str) {
+ char *ret;
+ size_t len;
+
+ if (!str) return NULL;
+
+ len = wcstombs(NULL, str, 0) + 1;
+ if (!len) return NULL;
+ ret = emalloc(len);
+ wcstombs(ret, str, len);
+ return ret;
+}
+
char *
homepath(char *path) {
static char ret[1024];