X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=input.c;h=b405f6b8f7cd8589a9ef9c6fb3f513244d0dc32a;hb=8845feb009950d2c76a394660a5bd81a0be0f2a6;hp=02f5dcee3c8b6aae3f6860e8beecad64266a72e1;hpb=0b51d8dd64a117bfca6119be6d8fd1d35570ee1f;p=cparser diff --git a/input.c b/input.c index 02f5dce..b405f6b 100644 --- a/input.c +++ b/input.c @@ -1,5 +1,10 @@ +/* + * This file is part of cparser. + * Copyright (C) 2012 Matthias Braun + */ #include "config.h" +#include "diagnostic.h" #include "input.h" #include @@ -294,21 +299,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; } + errorf(NULL, "input encoding \"%s\" not supported", encoding); } + result->decode = decode_utf8; } input_t *input_from_stream(FILE *file, const char *encoding)