From: Lady Date: Thu, 28 Mar 2024 03:04:05 +0000 (-0400) Subject: Improve the implementation of wrapplaintext X-Git-Tag: 0.6.2 X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/57f94dc06adb2cb0a977322edd2c6d9803161484?ds=inline Improve the implementation of wrapplaintext - Use `printf` and octal escapes instead of hexadecimal ones, as they are more portable. - Use `xargs` and piping to compose the wrapper and its contents, rather than a subcommand. --- diff --git a/GNUmakefile b/GNUmakefile index c953ac7..054ebc2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -384,7 +384,7 @@ override ensuredirectory = if $(TEST) ! -d $(call quote,$1); then $(MKDIR) -p $( override id = $(XMLLINT) --xpath '/*/*[local-name()="id" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"]/text()[1]' $(call quote,$1) 2> /dev/null || $(PRINTF) '%s\n' $(call quote,about:shushe?$(or $2,unknown)=$(call pathenc,$(basename $(notdir $1)))) # (callable) Sanitize and wrap the provided plaintext file in X·M·L, printing to `stdout´. -override wrapplaintext = $(PRINTF) '%s\n' "$$($(PRINTF) '%b' '\n')" +override wrapplaintext = $(TR) '\000\013\014' '\032\011\012' < $(call quote,$1) | $(SED) "$$($(PRINTF) '%b' 's/]]>/]]]]>/g\ns/\0357\0277\0276/�/g\ns/\0357\0277\0277/�/g\n$$!s/\\r$$//g\ns/\\r/\\n/g\n$$!s/\0302\0205$$//g\ns/\0302\0205/\\n/g;s/\0342\0200\0250/\\n/g;s/[\0001-\0010]/�/g;s/[\0016-\0037]/�/g')" | $(XARGS) -0 -J %% $(PRINTF) '%b%s%s\n' '\n' # (callable) Check if the provided X·M·L file is X·M·L 1.1, and if so, coerce to X·M·L 1.0 as best as possible, printing the result (or the original file contents) to `stdout´. #