summaryrefslogtreecommitdiff
path: root/fgetwc_fix.c
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2015-07-07 02:49:51 +0200
committerjaseg <code@jaseg.net>2015-07-07 02:49:51 +0200
commit84dc917720ff12a741bf87824bef1e6c31c9e1f2 (patch)
tree0dd61b098bc8192dfcc7399db686926ff5a56442 /fgetwc_fix.c
parent5bd8c7dccaf04939fc8aa8b9a9aecdb56f2b9b91 (diff)
downloadlolcat-84dc917720ff12a741bf87824bef1e6c31c9e1f2.tar.gz
lolcat-84dc917720ff12a741bf87824bef1e6c31c9e1f2.tar.bz2
lolcat-84dc917720ff12a741bf87824bef1e6c31c9e1f2.zip
Link statically against musl
Diffstat (limited to 'fgetwc_fix.c')
-rw-r--r--fgetwc_fix.c35
1 files changed, 0 insertions, 35 deletions
diff --git a/fgetwc_fix.c b/fgetwc_fix.c
deleted file mode 100644
index 76cf52b..0000000
--- a/fgetwc_fix.c
+++ /dev/null
@@ -1,35 +0,0 @@
-
-/* This file contains a fixed implementation of fgetwc since glibc's one is a little segfaulty when used on fmemopen'ed files. */
-
-#include <stdlib.h>
-#include <wchar.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include "fgetwc_fix.h"
-
-/* code blatantly ripped from newlib. If you are from newlib: newlib rocks, keep going! */
-wint_t _fgetwc_fixed(FILE *fp) {
- wchar_t wc;
- size_t res;
- size_t nconv = 0;
- char buf[MB_CUR_MAX];
- mbstate_t mbstate;
- memset(&mbstate, 0, sizeof(mbstate));
-
- while((buf[nconv++] = fgetc(fp)) != EOF){
- res = mbrtowc(&wc, buf, nconv, &mbstate);
- if (res == (size_t)-1) /* invalid sequence */
- break;
- else if (res == (size_t)-2) /* incomplete sequence */
- continue;
- else if (res == 0)
- return L'\0';
- else
- return wc;
- }
-
- errno = EILSEQ;
- return WEOF;
-}