[Toybox] iconv fixes

Felix Janda felix.janda at posteo.de
Sat May 31 02:43:55 PDT 2014


Hello,

the first attachment is a test case for iconv. It is the same I've sent
before but additionally testing the toybox default of echoign characters
in illegal sequences to stdout, and adding the "-s" option to suppress
possible output to stderr.

Currently toybox passes none of the tests. The second attachment is a
patch against the current toy adding the missing options (ignoring them)
and making the toy at least pass the first test. (It should also pass
the third test.)

I'm not sure what would be the best way to make it pass the third test
(testing illegal sequences). xwrite() should not repeatedly output from
outstart(=toybuf+2048) when there are many illegal characters in a row.
Anyway, the test cases should help with debugging.

Then for your entertainment attached an iconv.c with my strange error
checking loop which passes all (three...) tests.

Felix
-------------- next part --------------
#!/bin/bash

[ -f testing.sh ] && . testing.sh

#testing "name" "command" "result" "infile" "stdin"

iso=$(printf '\357')
utf=$(printf '\303\257') # "?"
printf a > iso
printf a > utf
for i in $(seq 4096)
do
  printf "$iso" >> iso
  printf "$utf" >> utf
done

testing "iconv" "iconv -f iso-8859-1 iso" "$(cat utf)" "" ""
testing "iconv -c" "iconv -cs -f utf-8 iso" "a" "" ""

# toybox specific: assumes that bad characters are echoed by default
testing "iconv (echo)" "iconv -s -f utf-8 iso" "$(cat iso)" "" ""

rm iso utf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iconv.patch
Type: text/x-patch
Size: 1515 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20140531/e45f80fb/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iconv.c
Type: text/x-c
Size: 1914 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20140531/e45f80fb/attachment-0009.bin>


More information about the Toybox mailing list