Hi,

I'm checking termwrap in base-config and found some fixes are needed.
I created a patch. Can I commit this, Joey? (when alioth come back :-) )

This patch fixes:
1. unset_lang_language unsets LANG and LANGUAGES, but need to unset
   LC_ALL (and maybe ENCODING) also.
2. prebaseconfig.udeb removed for inserting FB module. As Pere said,
   base-config should cover it only if LANG needs (try_load_fb).
3. WRAPPER check routine is broken. New variable, WRAPPER_OPTION is
   needed (Bug#225865).
4. When WRAPPER goes fail, LANGs which use special terminal should
   unset its LANG (fallback to English).

TODO:
- I checked for mainly Japanese. I don't so similar with
  Russian/Korean/Chinese. Is this code OK for them?
- Is there other language needs special terminal?
- I think try_load_fb is i386 specific. What's FrameBuffer module name
  on another arch?

--- termwrap.old        2003-12-19 05:01:52.000000000 +0900
+++ termwrap    2004-01-02 19:33:24.000000000 +0900
@@ -66,6 +66,8 @@
        if [ "$LANG" ] ; then
                warning "Disabling unsupported locale '$LANG'."
                unset LANG
+               unset LC_ALL
+               unset ENCODING
        fi
        if [ "$LANGUAGE" ] ; then
                warning "Disabling unsupported language list '$LANGUAGE'."
@@ -92,6 +94,11 @@
        esac
 }
 
+try_load_fb() {
+       # Load framebuffer module
+       modprobe -q vesafb || modprobe -q vga16fb || true
+}
+
 ######################################################################
 ##     Generate the locale data files if missing
 ######################################################################
@@ -217,6 +224,7 @@
 ##     Select suitable terminal as wrapper.
 ######################################################################
 WRAPPER=""
+WRAPPER_OPTION=""
 
 # For this to work, the current locale must be valid.  The block
 # generating the locale should have taken care of that.  If it isn't
@@ -246,19 +254,58 @@
        case $TERMINAL in
        x)
                #WRAPPER="/usr/X11R6/bin/kterm -e"
-               WRAPPER="/usr/X11R6/bin/krxvt -e"
+               WRAPPER="/usr/X11R6/bin/krxvt"
+               WRAPPER_OPTION="-e"
                ;;
        console)
                if [ "$SUBARCH" != pc9800 -a "$TERMINAL" = console ]; then
                        # Any platform except PC9800 require jfbterm
                        # to display japanese fonts on console.
-                       WRAPPER="/usr/bin/jfbterm -c other,EUC-JP,iconv.UTF-8 -e"
+                       try_load_fb
+                       WRAPPER="/usr/bin/jfbterm"
+                       WRAPPER_OPTION="-q -c other,EUC-JP,iconv,UTF-8 -e"
                fi
                ;;
        # On pseudo and serial, we can't tell
        # if the terminal can display japanese fonts...
        esac
        ;;
+eucKR|euc-KR)
+       case $TERMINAL in
+       console)
+               try_load_fb
+               WRAPPER="/usr/bin/jfbterm"
+               WRAPPER_OPTION="-q -c other,EUC-KR,iconv,UTF-8 -e"
+               ;;
+       esac
+       ;;
+zh_CN|GB2312)
+       case $TERMINAL in
+       console)
+               try_load_fb
+               WRAPPER="/usr/bin/jfbterm"
+               WRAPPER_OPTION="-q -c other,GB2312,iconv,UTF-8 -e"
+               ;;
+       esac
+       ;;
+zh_TW|BIG5)
+       case $TERMINAL in
+       console)
+               try_load_fb
+               WRAPPER="/usr/bin/jfbterm"
+               WRAPPER_OPTION="-q -c other,BIG5,iconv,UTF-8 -e"
+               ;;
+       esac
+       ;;
+KOI8-R)
+       case $TERMINAL in
+       console)
+               try_load_fb
+               WRAPPER="/usr/bin/jfbterm"
+               WRAPPER_OPTION="-q -c other,KOI8-R,iconv,UTF-8 -e"
+               ;;
+       esac
+       ;;
 UTF-8)
        # Enable UTF-8 in console
        if [ "$TERMINAL" = console ] ; then
@@ -284,7 +331,17 @@
 ##     Execute Wrapper.
 ######################################################################
 if [ ! -z "$WRAPPER" -a -x "$WRAPPER" ]; then
-       $WRAPPER /bin/true && exec $WRAPPER $@
+       $WRAPPER $WRAPPER_OPTION /bin/true && exec $WRAPPER $WRAPPER_OPTION $@
+       
+       case $ENCODING in
+       eucJP|EUC-JP|ujis|EUC-KR|zh_CN|zh_TW|KOI8-R)
+               # Unset LANG
+               unset_lang_language
+               ;;
+       *)
+               # Nothing to do
+               ;;
+       esac
 fi
 
 $@
@@ -305,7 +362,7 @@
        # Unload ISO-8859-15 charset mapping, by loading ISO-8859-1 instead
        try_load_charset "$ENCODING" iso01
        ;;
-eucJP|EUC-JP|ujis)
+eucJP|EUC-JP|ujis|EUC-KR|zh_CN|zh_TW|KOI8-R)
        # Nothing to do, using wrapper
        error "Should never end up here when using '$ENCODING'"
        ;;

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to