projects
/
cparser
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
implement support for complex types
[cparser]
/
input.c
diff --git
a/input.c
b/input.c
index
8c5d892
..
fa2ae92
100644
(file)
--- a/
input.c
+++ b/
input.c
@@
-1,9
+1,9
@@
#include "config.h"
#include "config.h"
+#include "diagnostic.h"
#include "input.h"
#include <ctype.h>
#include "input.h"
#include <ctype.h>
-#include "lexer.h"
typedef size_t (*decode_func)(input_t *input, utf32 *buffer, size_t buffer_size);
typedef size_t (*decode_func)(input_t *input, utf32 *buffer, size_t buffer_size);
@@
-104,7
+104,7
@@
static size_t decode_utf8(input_t *input, utf32 *buffer, size_t buffer_size)
{
unsigned char read_buf[buffer_size];
{
unsigned char read_buf[buffer_size];
-
while (true
) {
+
for (;;
) {
size_t const s = read_block(input, read_buf, sizeof(read_buf));
if (s == 0) {
if (input->utf8_part_decoded_rest_len > 0)
size_t const s = read_block(input, read_buf, sizeof(read_buf));
if (s == 0) {
if (input->utf8_part_decoded_rest_len > 0)
@@
-295,21
+295,16
@@
static int my_strcasecmp(const char *s1, const char *s2)
static void choose_decoder(input_t *result, const char *encoding)
{
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;
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)
}
input_t *input_from_stream(FILE *file, const char *encoding)