Compare commits

..

3 Commits

Author SHA1 Message Date
aaccb1c70d Bumped version to 1.0.1 2025-01-08 13:13:43 +01:00
259117bad5 Add README.md 2024-12-10 17:13:52 +01:00
c6a517ff1e Add *.inc to .gitignore 2024-12-10 17:02:21 +01:00
5 changed files with 49 additions and 7 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
valid-utf8
*.inc

View File

@ -2,8 +2,8 @@ include premake.make
# git commit hash and version for this build
COMMIT-HASH != git log 2>/dev/null | sed -e '1s/^commit //;q'
COMMIT := "const char* commit = \"$(COMMIT-HASH)\";"
VERSION := "const char* version = \"$(MAJOR).$(MINOR).$(PATCH)\";"
COMMIT := "static const char* commit = \"$(COMMIT-HASH)\";"
VERSION := "static const char* version = \"$(MAJOR).$(MINOR).$(PATCH)\";"
# some important install locations
PREFIX ?= /usr/local
@ -53,7 +53,7 @@ BIN := $(OUTDIR)/$(PROJ)
SRCS += $(notdir $(wildcard src/*.cpp))
OBJS := $(addprefix $(BUILDDIR)/, $(SRCS:.cpp=.o))
DEPS := $(addprefix $(BUILDDIR)/, $(SRCS:.cpp=.dep))
HDRS ?= $(wildcard src/*.hpp)
HDRS ?= $(filter-out src/precomp.hpp, $(wildcard src/*.hpp))
MANS := $(addprefix $(PREFIX)/, $(wildcard man/man*/*))
# if project supports plugins, link to libdl where needed
@ -126,7 +126,8 @@ else
$(OUTDIR)/$(REALNAME): $(OBJS)
endif
ifeq ($(UNAME_S),Darwin)
$(CXX) -dynamiclib -o $(OUTDIR)/$(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(OBJS) $(LDLIBS)
$(CXX) -dynamiclib -o $(OUTDIR)/$(REALNAME) -install_name $(LIBDIR)/$(REALNAME) \
-current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(OBJS) $(LDLIBS)
else ifeq ($(UNAME_S),OpenBSD)
$(CXX) -g -shared -Wl,-soname,$(REALNAME) -o $(OUTDIR)/$(REALNAME) $(LDFLAGS) $(OBJS) $(LDLIBS)
else ifeq ($(UNAME_S),Linux)

40
README.md Normal file
View File

@ -0,0 +1,40 @@
# valid-utf8 — Filter tool to check whether text is valid UTF-8 or not
If no file argument is given, valid-utf8 reads from standard input.
## Build
`make`
after building and installing dependencies:
- [libscstring](https://git.bobpolis.com/bob/libscstring/)
## Install
`sudo make install`
or, on OpenBSD:
`doas gmake install`
## Run
Test a file:
`valid-utf8 <file>`
No output, but exit status will be 0 on success, but 1 if file is not valid
UTF8.
Use a a filter:
`echo "some text" | valid-utf8`
Again, only exit status will indicate validity.
Find all valid UTF8 files in the current directory, and all directories under
it:
`find . -exec valid-utf8 "{}" \;`

View File

@ -13,7 +13,7 @@ PRODUCT := tool
# Single source of truth for version.
MAJOR := 1
MINOR := 0
PATCH := 0
PATCH := 1
# Specify desired C++ standard for this project.
CXXFLAGS += -std=c++20

View File

@ -1,9 +1,9 @@
#include "version.hpp"
#include "version.inc"
#include "commit.inc"
#include <sstream>
std::string valid_utf8_version() {
#include "version.inc"
#include "commit.inc"
std::ostringstream oss;
oss << "valid-utf8 version " << version;
#ifdef DEBUG