summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2012-11-09 09:46:05 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2012-11-13 15:45:49 +0100
commit6572d52d8dcc26052a68d640c29f2c0f16af133b (patch)
tree5b091e35f2b1ceb4d5c78703f39f21ad195a2f38
parent9e6b34b5203f56e705e5764b7f70a02c1d58804b (diff)
input: Simplify choose_decoder().
-rw-r--r--input.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/input.c b/input.c
index 02f5dce..b219d0a 100644
--- a/input.c
+++ b/input.c
@@ -294,21 +294,16 @@ static int my_strcasecmp(const char *s1, const char *s2)
static void choose_decoder(input_t *result, const char *encoding)
{
- if (encoding == NULL) {
- result->decode = decode_utf8;
- } else {
+ if (encoding) {
for (named_decoder_t const *i = decoders; i->name != NULL; ++i) {
if (my_strcasecmp(encoding, i->name) != 0)
continue;
result->decode = i->decoder;
- break;
- }
- if (result->decode == NULL) {
- fprintf(stderr, "error: input encoding \"%s\" not supported\n",
- encoding);
- result->decode = decode_utf8;
+ return;
}
+ fprintf(stderr, "error: input encoding \"%s\" not supported\n", encoding);
}
+ result->decode = decode_utf8;
}
input_t *input_from_stream(FILE *file, const char *encoding)