184 lines
5.0 KiB
Diff
184 lines
5.0 KiB
Diff
diff -ru groff-1.18.1.1.orig//src/roff/nroff/nroff.sh groff-1.18.1.1/src/roff/nroff/nroff.sh
|
|
--- groff-1.18.1.1.orig//src/roff/nroff/nroff.sh 2009-02-02 18:44:00.000000000 +0100
|
|
+++ groff-1.18.1.1/src/roff/nroff/nroff.sh 2009-02-02 18:44:40.000000000 +0100
|
|
@@ -87,11 +87,177 @@
|
|
shift
|
|
done
|
|
|
|
+# special hacks to display Japanese, Chinese, ...man pages correctly in UTF-8 locale:
|
|
+
|
|
+guess_legacy_encoding () {
|
|
+ # Guess the legacy encoding used by the language/country
|
|
+ # found in the current LC_CTYPE value.
|
|
+
|
|
+ # First determine the LC_CTYPE locale category setting
|
|
+ ctype=${LC_ALL-${LC_CTYPE-${LANG-en_US}}}
|
|
+
|
|
+ case $ctype in
|
|
+ zh_TW*)
|
|
+ LEGACY_ENCODING=Big5
|
|
+ ;;
|
|
+ zh_HK*)
|
|
+ LEGACY_ENCODING=Big5HKSCS
|
|
+ ;;
|
|
+ zh*)
|
|
+ LEGACY_ENCODING=GB18030
|
|
+ ;;
|
|
+ ja*)
|
|
+ LEGACY_ENCODING=EUC-JP
|
|
+ ;;
|
|
+ ko*)
|
|
+ LEGACY_ENCODING=EUC-KR
|
|
+ ;;
|
|
+ ru*)
|
|
+ LEGACY_ENCODING=KOI8-R
|
|
+ ;;
|
|
+ uk*)
|
|
+ LEGACY_ENCODING=KOI8-U
|
|
+ ;;
|
|
+ pl*|hr*|hu*|cs*|sk*|sl*)
|
|
+ LEGACY_ENCODING=ISO-8859-2
|
|
+ ;;
|
|
+ eo*|mt*)
|
|
+ LEGACY_ENCODING=ISO-8859-3
|
|
+ ;;
|
|
+ el*)
|
|
+ LEGACY_ENCODING=ISO-8859-7
|
|
+ ;;
|
|
+ he*)
|
|
+ LEGACY_ENCODING=ISO-8859-8
|
|
+ ;;
|
|
+ tr*)
|
|
+ LEGACY_ENCODING=ISO-8859-9
|
|
+ ;;
|
|
+ th*)
|
|
+ LEGACY_ENCODING=TIS-620 # or ISO-8859-11
|
|
+ ;;
|
|
+ lt*)
|
|
+ LEGACY_ENCODING=ISO-8859-13
|
|
+ ;;
|
|
+ cy*)
|
|
+ LEGACY_ENCODING=ISO-8859-14
|
|
+ ;;
|
|
+ ro*)
|
|
+ LEGACY_ENCODING=ISO-8859-14 # or ISO-8859-16
|
|
+ ;;
|
|
+ am*|vi*)
|
|
+ LEGACY_ENCODING=UTF-8
|
|
+ ;;
|
|
+ *)
|
|
+ LEGACY_ENCODING=ISO-8859-1
|
|
+ ;;
|
|
+ esac
|
|
+}
|
|
+
|
|
+guess_legacy_encoding;
|
|
+
|
|
+TMPDIR=`mktemp -d /tmp/nroff.XXXXXX`
|
|
+if [ $? -ne 0 ]; then
|
|
+ echo "$0: Can't create temp directory, exiting..."
|
|
+ exit 1
|
|
+fi
|
|
+trap "exec rm -rf $TMPDIR" EXIT SIGHUP SIGINT SIGPIPE SIGTERM SIGIO
|
|
+
|
|
+# parse groff options to find out whether a file was given as argument or whether the
|
|
+# input is read from stdin:
|
|
+OLDARGS=""
|
|
+TEMP=$(getopt --options "abcCd:eEf:F:gGhiI:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ" --longoptions help,version -- ${1+"$@"})
|
|
+eval set -- "$TEMP"
|
|
+while true ; do
|
|
+ case "$1" in
|
|
+ --)
|
|
+ if [ -n "$2" ] ; then
|
|
+ INPUTFILE="$2"
|
|
+ shift 2
|
|
+ else
|
|
+ INPUTFILE=""
|
|
+ shift 1
|
|
+ fi
|
|
+ break
|
|
+ ;;
|
|
+ *)
|
|
+ OLDARGS="$OLDARGS $1"
|
|
+ echo $1
|
|
+ shift 1
|
|
+ ;;
|
|
+ esac
|
|
+done
|
|
+eval set -- "$OLDARGS"
|
|
+
|
|
+if [ -n "$INPUTFILE" ] ; then
|
|
+ # input comes from a file
|
|
+ cat "$INPUTFILE" > $TMPDIR/input
|
|
+else
|
|
+ # input comes from stdin
|
|
+ cat > $TMPDIR/input
|
|
+fi
|
|
+
|
|
+#iconv -s -c -f utf-8 -t utf-8 < $TMPDIR/input > /dev/null
|
|
+#if [ $? -eq 0 ]; then
|
|
+# iconv -s -c -f utf-8 -t $LEGACY_ENCODING < $TMPDIR/input > $TMPDIR/input.new
|
|
+# mv $TMPDIR/input.new $TMPDIR/input
|
|
+#fi
|
|
+
|
|
+ICONV="cat"
|
|
+case "`locale charmap 2>/dev/null`" in
|
|
+ UTF-8)
|
|
+ case "${LANGUAGE-${LC_ALL-${LC_MESSAGES-${LANG}}}}" in
|
|
+ ja*)
|
|
+ # Japanese man page in UTF-8 locale, special case!
|
|
+ # force the device 'nippon' to run groff in ja_JP.eucJP locale
|
|
+ # and convert the result to UTF-8 using iconv:
|
|
+ T=-Tnippon
|
|
+ export LC_ALL=ja_JP.eucJP
|
|
+ ICONV="iconv -f EUC-JP -t UTF-8"
|
|
+ ;;
|
|
+ zh_TW*)
|
|
+ T=-Tnippon
|
|
+ export LC_ALL=zh_TW.Big5
|
|
+ ICONV="iconv -f Big5 -t UTF-8"
|
|
+ ;;
|
|
+ zh_HK*)
|
|
+ T=-Tnippon
|
|
+ export LC_ALL=zh_HK.Big5HKSCS
|
|
+ ICONV="iconv -f Big5HKSCS -t UTF-8"
|
|
+ ;;
|
|
+ zh*)
|
|
+ T=-Tnippon
|
|
+ export LC_ALL=zh_CN.GB18030
|
|
+ ICONV="iconv -f GB18030 -t UTF-8"
|
|
+ ;;
|
|
+ ko*)
|
|
+ T=-Tlatin1
|
|
+ export LC_ALL=ko_KR.EUC-KR
|
|
+ # See https://bugzilla.novell.com/show_bug.cgi?id=470921
|
|
+ # for the reason why the "-c" is needed and
|
|
+ # why a conversion from ISO-8859-1 instead of EUC-KR to
|
|
+ # UTF-8 may be needed if an English man-page is displayed:
|
|
+ ICONV="iconv -c -f EUC-KR -t UTF-8"
|
|
+ iconv -s -f ASCII -t UTF-8 < $TMPDIR/input > /dev/null
|
|
+ if [ $? -eq 0 ]; then
|
|
+ ICONV="iconv -f ISO-8859-1 -t UTF-8"
|
|
+ fi
|
|
+ ;;
|
|
+ # make 'man iso-8859-15' display correctly in UTF-8 locales using Euro
|
|
+ ca_ES*|de_AT*|de_BE*|de_DE*|de_LU*|en_BE*|en_IE*|es_ES*|eu_ES*|fi_FI*|fr_BE*|fr_FR*|fr_LU*|ga_IE*|gl_ES*|it_IT*|nl_BE*|nl_NL*|pt_PT*|sv_FI*|wa_BE*)
|
|
+ T=-Tlatin1
|
|
+ export LC_ALL=de_DE@euro
|
|
+ ICONV="iconv -f ISO-8859-15 -t UTF-8"
|
|
+ ;;
|
|
+ esac
|
|
+ ;;
|
|
+esac
|
|
+
|
|
# This shell script is intended for use with man, so warnings are
|
|
# probably not wanted. Also load nroff-style character definitions.
|
|
|
|
-: ${GROFF_BIN_PATH=@BINDIR@}
|
|
+: ${GROFF_BIN_PATH=@BINDIR@}
|
|
export GROFF_BIN_PATH
|
|
-PATH=$GROFF_BIN_PATH:$PATH groff -mtty-char $T $opts ${1+"$@"}
|
|
+PATH=$GROFF_BIN_PATH:$PATH groff -mtty-char $T $opts ${1+"$@"} < $TMPDIR/input | $ICONV
|
|
|
|
# eof
|