commit aae6ac70939bf828c13ae0ce48ce8c4dc688252f Author: ingenarel (NeoJesus) Date: Tue Aug 18 00:58:38 2026 +0600 DEFAULT-PATCHES diff --git a/Makefile b/Makefile index 3c16848..22db6ac 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,6 @@ .PHONY: clean fmt install profile test uninstall -OPTFLAGS ?= -O2 -finline-functions -WARNFLAGS ?= -Wall -Wextra -Wpedantic -Wshadow -Werror -Wfatal-errors -Wconversion -Wsign-conversion -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -CFLAGS ?= -std=c11 -pipe -fPIC $(OPTFLAGS) $(WARNFLAGS) - -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Darwin) - CFLAGS += -fstack-protector-strong -D_GNU_SOURCE -else ifeq ($(OS),Windows_NT) - CFLAGS += -D_WIN32 -s -else - CFLAGS += -fstack-protector-strong -D_GNU_SOURCE -fno-plt -Wl,-z,now -D_FORTIFY_SOURCE=3 -endif +CFLAGS += -std=c11 -D_GNU_SOURCE $(LDFLAGS) PREFIX ?= /usr BINDIR ?= $(PREFIX)/bin @@ -28,9 +17,6 @@ tinyxxd: main.c tinyxxd_debug: main.c $(CC) $(CFLAGS) -g -o $@ $< -tinyxxd_asan: main.c - $(CC) $(CFLAGS) -g -fsanitize=address,undefined -o $@ $< - profile: tinyxxd_debug dd if=/dev/random of=sample.bin bs=1M count=1 valgrind --dump-instr=yes --collect-jumps=yes --tool=callgrind ./tinyxxd_debug sample.bin @@ -48,7 +34,7 @@ benchfull: fmt: main.c clang-format -style=WebKit -i main.c -test: xxd tinyxxd_asan +test: @echo 'Preparing tests...' @echo -n 'This is a test file' > sample.bin @printf '\x00\x09\x0a\x0d\x20\x41\x7e\x7f\x80\xff' > colorbytes.bin @@ -92,8 +78,8 @@ test: xxd tinyxxd_asan run_test: @echo "Running test: $(DESC)" - @./tinyxxd_asan $(CMD) > tinyxxd_output.txt - @./xxd $(CMD) > xxd_output.txt + @./tinyxxd $(CMD) > tinyxxd_output.txt + @xxd $(CMD) > xxd_output.txt @if diff -q tinyxxd_output.txt xxd_output.txt > /dev/null; then \ echo 'Test passed'; \ else \ @@ -103,8 +89,8 @@ run_test: verify_conversion_test: @echo "Running conversion and verification test..." - @./tinyxxd_asan sample.bin > sample_tinyxxd.bin - @./tinyxxd_asan -r sample_tinyxxd.bin > sample_restored.bin + @./tinyxxd sample.bin > sample_tinyxxd.bin + @./tinyxxd -r sample_tinyxxd.bin > sample_restored.bin @if diff -q sample.bin sample_restored.bin > /dev/null; then \ echo -e "\033[0;32mConversion and verification test passed\033[0m"; \ else \ @@ -116,7 +102,7 @@ verify_conversion_test: test_revert_crlf: @echo "Running test: Revert hex dump with CRLF line endings" @printf "00000000: 3132 3334\r\n00000004: 3536 3738\r\n" > repro_crlf.hex - @./tinyxxd_asan -r repro_crlf.hex > repro_crlf.bin + @./tinyxxd -r repro_crlf.hex > repro_crlf.bin @printf "12345678" > expected_crlf.bin @if diff -q repro_crlf.bin expected_crlf.bin > /dev/null; then \ echo 'Test passed'; \ @@ -129,7 +115,7 @@ test_revert_crlf: test_le_padding: @echo "Running test: Little-endian hex dump with padding" @printf "ABCDEFG" > 7.bin - @./tinyxxd_asan -e -c 8 7.bin > le_padding_output.txt + @./tinyxxd -e -c 8 7.bin > le_padding_output.txt @printf "00000000: 44434241 474645 ABCDEFG\n" > le_padding_expected.txt @if diff -q le_padding_output.txt le_padding_expected.txt > /dev/null; then \ echo 'Test passed'; \ @@ -142,7 +128,7 @@ test_le_padding: test_help_stdout: @echo "Running test: -h outputs to stdout" - @if ./tinyxxd_asan -h 2>/dev/null | grep -q 'Usage'; then \ + @if ./tinyxxd -h 2>/dev/null | grep -q 'Usage'; then \ echo 'Test passed'; \ else \ echo 'Test failed: -h should write to stdout'; \ @@ -151,7 +137,7 @@ test_help_stdout: test_error_stderr: @echo "Running test: bad option outputs to stderr" - @if ./tinyxxd_asan -Z 2>&1 >/dev/null | grep -q 'Usage'; then \ + @if ./tinyxxd -Z 2>&1 >/dev/null | grep -q 'Usage'; then \ echo 'Test passed'; \ else \ echo 'Test failed: bad option should write to stderr'; \ @@ -181,12 +167,6 @@ fuzz: tinyxxd_fuzz @dd if=/dev/urandom of=input_dir/sample.bin count=1 bs=128 AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 afl-fuzz -i input_dir -o fuzz_output -- ./tinyxxd_fuzz @@ -testfiles/xxd.c: - cd testfiles && curl -sOL "https://raw.githubusercontent.com/vim/vim/master/src/xxd/xxd.c" - -xxd: testfiles/xxd.c - $(CC) -std=c11 -pipe -D_GNU_SOURCE $(OPTFLAGS) -o $@ $< - install: tinyxxd install -D -m 755 tinyxxd "$(DESTDIR)$(BINDIR)/tinyxxd"