summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2021-01-12 00:50:04 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2021-01-16 12:27:13 +0100
commit7270aee2452804631741c971d3b4bc6d52ca72a6 (patch)
treeb44fd09771bd2603e8d538e527bb7eb372f74ef6
parent4c35fd89e81ee83b1174dd6cfed3d6beaf25dc63 (diff)
sfeed_update: make convertencoding() consistent with other overridable functions
This adds the name as the first parameter for the convertencoding() function, like filter, merge, order, etc. This can be useful to make an exception rule for text decoding in a more clean way.
-rwxr-xr-xsfeed_update8
-rw-r--r--sfeedrc.56
2 files changed, 8 insertions, 6 deletions
diff --git a/sfeed_update b/sfeed_update
index 0d39625..d7c41da 100755
--- a/sfeed_update
+++ b/sfeed_update
@@ -45,10 +45,10 @@ fetch() {
}
# convert encoding from one encoding to another.
-# convertencoding(from, to)
+# convertencoding(name, from, to)
convertencoding() {
- if [ "$1" != "" ] && [ "$2" != "" ] && [ "$1" != "$2" ]; then
- iconv -cs -f "$1" -t "$2" 2> /dev/null
+ if [ "$2" != "" ] && [ "$3" != "" ] && [ "$2" != "$3" ]; then
+ iconv -cs -f "$2" -t "$3" 2> /dev/null
else
# else no convert, just output
cat
@@ -106,7 +106,7 @@ feed() {
# try to detect encoding (if not specified). if detecting the encoding fails assume utf-8.
[ "${encoding}" = "" ] && encoding=$(sfeed_xmlenc < "${tmpfeedfile}.fetch")
- if ! convertencoding "${encoding}" "utf-8" < "${tmpfeedfile}.fetch" > "${tmpfeedfile}.utf8"; then
+ if ! convertencoding "${name}" "${encoding}" "utf-8" < "${tmpfeedfile}.fetch" > "${tmpfeedfile}.utf8"; then
log "${name}" "FAIL (ENCODING)"
return
fi
diff --git a/sfeedrc.5 b/sfeedrc.5
index 00b912e..12c8f87 100644
--- a/sfeedrc.5
+++ b/sfeedrc.5
@@ -1,4 +1,4 @@
-.Dd February 4, 2020
+.Dd January 11, 2021
.Dt SFEEDRC 5
.Os
.Sh NAME
@@ -71,10 +71,12 @@ Used feedfile (useful for comparing modification times).
By default the tool
.Xr curl 1
is used.
-.It Fn convertencoding "from" "to"
+.It Fn convertencoding "name" "from" "to"
Convert from text-encoding to another and writes it to stdout, its arguments
are:
.Bl -tag -width Ds
+.It Fa name
+Feed name.
.It Fa from
From text-encoding.
.It Fa to