diff options
author | jaseg <code@jaseg.net> | 2015-07-07 02:49:51 +0200 |
---|---|---|
committer | jaseg <code@jaseg.net> | 2015-07-07 02:49:51 +0200 |
commit | 84dc917720ff12a741bf87824bef1e6c31c9e1f2 (patch) | |
tree | 0dd61b098bc8192dfcc7399db686926ff5a56442 | |
parent | 5bd8c7dccaf04939fc8aa8b9a9aecdb56f2b9b91 (diff) | |
download | lolcat-84dc917720ff12a741bf87824bef1e6c31c9e1f2.tar.gz lolcat-84dc917720ff12a741bf87824bef1e6c31c9e1f2.tar.bz2 lolcat-84dc917720ff12a741bf87824bef1e6c31c9e1f2.zip |
Link statically against musl
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | fgetwc_fix.c | 35 | ||||
-rw-r--r-- | fgetwc_fix.h | 5 | ||||
-rw-r--r-- | lolcat.c | 6 | ||||
m--------- | musl | 0 |
7 files changed, 17 insertions, 49 deletions
@@ -1,3 +1,2 @@ lolcat -.*.swo -.*.swp +lolcat.o diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f80450c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "musl"] + path = musl + url = git://git.musl-libc.org/musl @@ -1,11 +1,19 @@ all: lolcat -lolcat: lolcat.c fgetwc_fix.c - gcc -g -std=c99 -Wall -o lolcat lolcat.c fgetwc_fix.c +musl/lib/libc.a musl/lib/crt1.o: + cd musl; ./configure + make -C musl + +lolcat: lolcat.c musl/lib/libc.a musl/lib/crt1.o + gcc -c -std=c11 -Wall -Imusl/include -o lolcat.o lolcat.c + gcc -s -nostartfiles -nodefaultlibs -nostdinc -static -ffunction-sections -fdata-sections -Wl,--gc-sections -o lolcat lolcat.o musl/lib/crt1.o musl/lib/libc.a install: lolcat install lolcat /usr/local/bin -.PHONY: install all +clean: + rm -f lolcat lolcat.o + +.PHONY: install clean 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; -} diff --git a/fgetwc_fix.h b/fgetwc_fix.h deleted file mode 100644 index 343d9f7..0000000 --- a/fgetwc_fix.h +++ /dev/null @@ -1,5 +0,0 @@ - -#include <wchar.h> -#include <stdint.h> - -wint_t _fgetwc_fixed(FILE *fp); @@ -19,7 +19,7 @@ #include <stdio.h> #include <wchar.h> #include <ctype.h> -#include <error.h> +#include <err.h> #include <errno.h> #include <stdlib.h> #include <string.h> @@ -27,8 +27,6 @@ #include <unistd.h> #include <sys/time.h> -#include "fgetwc_fix.h" - static char helpstr[] = "\n" "Usage: lolcat [-h horizontal_speed] [-v vertical_speed] [--] [FILES...]\n" @@ -139,7 +137,7 @@ int main(int argc, char **argv){ return 2; } - while((c = _fgetwc_fixed(f)) > 0){ + while((c = fgetwc(f)) > 0){ if(colors){ find_escape_sequences(c, &escape_state); diff --git a/musl b/musl new file mode 160000 +Subproject fb58545f8d1c5fa32122244caeaf3625c12ddc0 |