"Dr. Werner Fink" wrote:
> a new version of my patch wich also makes the SHIFT-JIS character
> 0x81 0x7C work (yes 0x72 is the pipe symbol).  Beside this I
> change the mbchar() cpp macro to be able to use the printf builtin.
> The problem was that the former version of mbchar() uses mbtowc()
> even for real ASCII characters which shifts the backslash (0x5C)
> to the latin1 Yen symbol (0xA5).  The patch also includes a test
> case for Japanese SHIFT-JIS characters which include an ASCII
> character as second byte.
[snip]
>  ------------------------------------------------------------------------
>                              Name: ksh93-shift_ijs.dif
>    ksh93-shift_ijs.dif       Type: Plain Text (text/plain)
>                       Description: ksh93-shift_ijs.dif


Misc questions and some review bickering (mainly based on
http://mail.opensolaris.org/pipermail/shell-discuss/2007-June/000993.html
and http://www.opensolaris.org/os/project/shell/shellstyle/) follows:

> --- src/cmd/ksh93/tests/sjis.sh
> +++ src/cmd/ksh93/tests/sjis.sh 2007-11-20 13:07:57.000000000 +0000
> @@ -0,0 +1,62 @@
[snip]
> +#
> +# Byte ranges for Shift-JIS encoding (hexadecimal):
> +# First byte:   81-9F, E0-EF
> +# Second byte:  40-7E, 80-FC
> +#
> +# Now test out some multi byte characters which
> +# include 7bit aka ASCII bytes with 0x81 0x{40-7E}
> +#
> +
> +typeset -i chr=0
> +typeset -i err=0
> +typeset printf=$(type -p printf 2>/dev/null)
> +
> +unset LC_ALL
> +unset LC_CTYPE
> +export LANG=ja_JP.SJIS

Is "ja_JP.SJIS" the official name of the locale (I'm asking because
Solaris uses "ja_JP.PCK" for the same stuff and right now it doesn't
recognise "ja_JP.SJIS" which causes the test to go down in flames) ?

> +for second in $(seq 64 126); do

Erm... "seq" is only available in Linux (or bette: GNU coreutils). AFAIK
it's better to use
for ((second=64 ; second <= 128 ; second++ )) ; do

> +    : $((chr++))

AFAIK a plain...
(( chr++ ))
...works, too (see
http://svn.genunix.org/repos/on/branches/ksh93/gisburn/scripts/mandelbrotset1.ksh
for more examples).

> +    second=$(printf '%x' ${second})
> +    mbchar="$(printf "\x81\x${second}")"
> +    if test -z "${mbchar}" ; then
> +       : $((err++))            # ERROR in builtin printf

AFAIK a plain...
(( err++ ))
...works, too...

> +       continue
> +    fi
> +    if test -x "${printf}" ; then
> +       if test $(${printf} "\x81\x${second}") != ${mbchar} ; then
> +           : $((err++))        # ERROR in builtin printf

See above, AFAIAK the ": $" can be skipped.

> +           continue
> +       fi
> +    fi
> +    uq=$(echo ${mbchar})
> +    dq=$(echo "${mbchar}")
> +    test "$uq" != "$dq" && let err+=1

AFAIK it may be better to use [[ ]] instead of using the "test" builtin.
 
> +done
> +
> +if test $err -ne 0 ; then

Please use (( err != 0 )) (see
http://www.opensolaris.org/os/project/shell/shellstyle/#use_posix_arithmetric_expressions).

> +    : err_exit
> +    : err_exit
> +    print -u2 -n "\t"
> +    print -u2 -r ${0##*/}[$LINENO]: "Shift-JIS encoding failed"
> +fi
> +exit $err

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [EMAIL PROTECTED]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to