Compare commits
3 Commits
c54020305d
...
master
Author | SHA1 | Date | |
---|---|---|---|
aaccb1c70d | |||
259117bad5 | |||
c6a517ff1e |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
valid-utf8
|
valid-utf8
|
||||||
|
*.inc
|
||||||
|
9
Makefile
9
Makefile
@ -2,8 +2,8 @@ include premake.make
|
|||||||
|
|
||||||
# git commit hash and version for this build
|
# git commit hash and version for this build
|
||||||
COMMIT-HASH != git log 2>/dev/null | sed -e '1s/^commit //;q'
|
COMMIT-HASH != git log 2>/dev/null | sed -e '1s/^commit //;q'
|
||||||
COMMIT := "const char* commit = \"$(COMMIT-HASH)\";"
|
COMMIT := "static const char* commit = \"$(COMMIT-HASH)\";"
|
||||||
VERSION := "const char* version = \"$(MAJOR).$(MINOR).$(PATCH)\";"
|
VERSION := "static const char* version = \"$(MAJOR).$(MINOR).$(PATCH)\";"
|
||||||
|
|
||||||
# some important install locations
|
# some important install locations
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
@ -53,7 +53,7 @@ BIN := $(OUTDIR)/$(PROJ)
|
|||||||
SRCS += $(notdir $(wildcard src/*.cpp))
|
SRCS += $(notdir $(wildcard src/*.cpp))
|
||||||
OBJS := $(addprefix $(BUILDDIR)/, $(SRCS:.cpp=.o))
|
OBJS := $(addprefix $(BUILDDIR)/, $(SRCS:.cpp=.o))
|
||||||
DEPS := $(addprefix $(BUILDDIR)/, $(SRCS:.cpp=.dep))
|
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*/*))
|
MANS := $(addprefix $(PREFIX)/, $(wildcard man/man*/*))
|
||||||
|
|
||||||
# if project supports plugins, link to libdl where needed
|
# if project supports plugins, link to libdl where needed
|
||||||
@ -126,7 +126,8 @@ else
|
|||||||
$(OUTDIR)/$(REALNAME): $(OBJS)
|
$(OUTDIR)/$(REALNAME): $(OBJS)
|
||||||
endif
|
endif
|
||||||
ifeq ($(UNAME_S),Darwin)
|
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)
|
else ifeq ($(UNAME_S),OpenBSD)
|
||||||
$(CXX) -g -shared -Wl,-soname,$(REALNAME) -o $(OUTDIR)/$(REALNAME) $(LDFLAGS) $(OBJS) $(LDLIBS)
|
$(CXX) -g -shared -Wl,-soname,$(REALNAME) -o $(OUTDIR)/$(REALNAME) $(LDFLAGS) $(OBJS) $(LDLIBS)
|
||||||
else ifeq ($(UNAME_S),Linux)
|
else ifeq ($(UNAME_S),Linux)
|
||||||
|
40
README.md
Normal file
40
README.md
Normal 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 "{}" \;`
|
||||||
|
|
@ -13,7 +13,7 @@ PRODUCT := tool
|
|||||||
# Single source of truth for version.
|
# Single source of truth for version.
|
||||||
MAJOR := 1
|
MAJOR := 1
|
||||||
MINOR := 0
|
MINOR := 0
|
||||||
PATCH := 0
|
PATCH := 1
|
||||||
|
|
||||||
# Specify desired C++ standard for this project.
|
# Specify desired C++ standard for this project.
|
||||||
CXXFLAGS += -std=c++20
|
CXXFLAGS += -std=c++20
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
#include "version.inc"
|
|
||||||
#include "commit.inc"
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
std::string valid_utf8_version() {
|
std::string valid_utf8_version() {
|
||||||
|
#include "version.inc"
|
||||||
|
#include "commit.inc"
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "valid-utf8 version " << version;
|
oss << "valid-utf8 version " << version;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
Reference in New Issue
Block a user