From d1e53d9835133bb145c7230107ad2d6b3766db55 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 29 Nov 2008 11:55:24 +0000 Subject: Test data for illegal utf-8 byte sequence. Fix command line argument parsing somewhat. Ensure we output all the converted data, even if we're aborting because of an illegal byte sequence. svn path=/trunk/iconv/; revision=5818 --- module/module.c | 14 ++++++++------ test/data/utf8-ilseq.txt | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 test/data/utf8-ilseq.txt diff --git a/module/module.c b/module/module.c index f50d64a..591a721 100644 --- a/module/module.c +++ b/module/module.c @@ -228,8 +228,6 @@ _kernel_oserror *do_iconv(int argc, const char *args) p++; } *f = '\0'; - while (*p == ' ') - p++; argc--; break; case 't': @@ -246,8 +244,6 @@ _kernel_oserror *do_iconv(int argc, const char *args) p++; } *t = '\0'; - while (*p == ' ') - p++; argc--; break; case 'l': @@ -269,8 +265,6 @@ _kernel_oserror *do_iconv(int argc, const char *args) p++; } *o = '\0'; - while (*p == ' ') - p++; argc--; break; case 'v': @@ -290,6 +284,9 @@ _kernel_oserror *do_iconv(int argc, const char *args) "Iconv: invalid option -- %c", *(p+1)); return &ErrorGeneric; } + + while (*p == ' ') + p++; } if (list) { @@ -388,7 +385,12 @@ _kernel_oserror *do_iconv(int argc, const char *args) "character sequence: " "'%10s'\n", in); } + if (stop_on_invalid) { + /* Flush through any output */ + fwrite(output, 1, + sizeof(output) - outlen, + ofp); iconv_close(cd); fclose(ofp); fclose(inf); diff --git a/test/data/utf8-ilseq.txt b/test/data/utf8-ilseq.txt new file mode 100644 index 0000000..a3f6d55 --- /dev/null +++ b/test/data/utf8-ilseq.txt @@ -0,0 +1,2 @@ +This side-scroller is plenty of fun if you can deal with all the clichés. Spiderman is your typical, old-fashioned, jump-kick-punch game. + -- cgit v1.2.3