From: Lady Date: Fri, 2 Feb 2024 04:09:47 +0000 (-0500) Subject: Make percent‐decoding awk script portable X-Git-Tag: 0.5.0~4 X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/88823523127972944771746f48bc2838e0317d31?ds=sidebyside Make percent‐decoding awk script portable This script depended on `printf` having the same behaviour within `awk` and on the commandline. This doesn’t appear to be true in G·N·U Awk. Instead, pipe into the shell version from within the Awk script. --- diff --git a/GNUmakefile b/GNUmakefile index 1bdc8b7..4979bfb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -202,7 +202,7 @@ override silent := $(if $(VERBOSE),,@) override sedesc = $(subst /,[/],$(subst $$,\$$,$(subst *,\*,$(subst .,\.,$(subst [,\[,$(subst ^,\^,$(subst \,\\,$1))))))) # (callable) Percent‐decode the given strings. -override perdec = $(foreach encoded,$1,$(shell $(PRINTF) '%s\n' $(call quote,$(encoded)) | $(SED) 's/|/%7C/g;s/[\]/%5C/g;s/%[0-9A-Fa-f]\{2\}/|&|/g' | $(TR) '|' '\n' | $(SED) '/^%[0-9A-Fa-f]\{2\}$$/!s/%/|%25|/' | $(TR) '|' '\n' | $(AWK) '$$0!~/%/{printf("%s",$$0)}/%/{sub("%","0x");printf("\\%04o",$$0)}' | $(XARGS) -0 $(PRINTF) '%b')) +override perdec = $(foreach encoded,$1,$(shell $(PRINTF) '%s\n' $(call quote,$(encoded)) | $(SED) 's/|/%7C/g;s/[\]/%5C/g;s/%[0-9A-Fa-f]\{2\}/|&|/g' | $(TR) '|' '\n' | $(SED) '/^%[0-9A-Fa-f]\{2\}$$/!s/%/|%25|/' | $(TR) '|' '\n' | $(AWK) '$$0!~/%/{printf "%s",$$0}/%/{sub("%","0x");cmd="$(XARGS) $(PRINTF) \"%04o\"";printf "%s","\\";printf "%s",$$0|cmd;close(cmd)}' | $(XARGS) -0 $(PRINTF) '%b')) # (callable) Percent‐encode the given strings. #