Final realease of nroff. Reviewed-by: mlichvar and skasal
This commit is contained in:
parent
ce8b802af9
commit
36fd98f7e3
71
nroff
71
nroff
@ -4,8 +4,7 @@
|
|||||||
prog="$0"
|
prog="$0"
|
||||||
charset_in=iso-8859-1
|
charset_in=iso-8859-1
|
||||||
charset_out=`locale charmap 2>/dev/null`
|
charset_out=`locale charmap 2>/dev/null`
|
||||||
# we prefer utf8
|
opts="-mtty-char"
|
||||||
opts="-mtty-char -Tutf8"
|
|
||||||
|
|
||||||
for i
|
for i
|
||||||
do
|
do
|
||||||
@ -19,12 +18,10 @@ do
|
|||||||
exit 1 ;;
|
exit 1 ;;
|
||||||
-[iptSUC] | -[mrno]*)
|
-[iptSUC] | -[mrno]*)
|
||||||
opts="$opts $1" ;;
|
opts="$opts $1" ;;
|
||||||
# someone wants specified -T, let's change opts from utf8
|
|
||||||
-Tascii | -Tlatin1 | -Tutf8 | -Tcp1047 | -Tascii8 | -Tnippon | -Tkorean)
|
-Tascii | -Tlatin1 | -Tutf8 | -Tcp1047 | -Tascii8 | -Tnippon | -Tkorean)
|
||||||
T=$1 ;
|
T=$1 ;;
|
||||||
opts="-mtty-char $T";;
|
|
||||||
-[eq] | -s* | -u* | -T*)
|
-[eq] | -s* | -u* | -T*)
|
||||||
# ignore other devices
|
# ignore these options
|
||||||
;;
|
;;
|
||||||
-v | --version)
|
-v | --version)
|
||||||
echo $"GNU nroff (groff) with Red Hat i18n/l10n support"
|
echo $"GNU nroff (groff) with Red Hat i18n/l10n support"
|
||||||
@ -49,6 +46,11 @@ do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Don't convert encodings when -T is specified
|
||||||
|
[ -n "$T" ] && exec /usr/bin/groff $opts $T ${1+"$@"} 2>/dev/null
|
||||||
|
|
||||||
|
opts="$opts -Tutf8"
|
||||||
|
|
||||||
if TMPFILE=$(mktemp /tmp/man.XXXXXX 2>/dev/null); then
|
if TMPFILE=$(mktemp /tmp/man.XXXXXX 2>/dev/null); then
|
||||||
trap "rm -f $TMPFILE" 0 1 2 3 15
|
trap "rm -f $TMPFILE" 0 1 2 3 15
|
||||||
cat ${1+"$@"} >| $TMPFILE
|
cat ${1+"$@"} >| $TMPFILE
|
||||||
@ -57,48 +59,43 @@ else
|
|||||||
TMPFILE=buf
|
TMPFILE=buf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if -T was set -> just run groff and quit nroff
|
if [ $TMPFILE = buf ]; then
|
||||||
if [ -n "$T" ]; then
|
echo -n "$buf" | iconv -f utf-8 -t utf-8 &>/dev/null && charset_in=utf-8
|
||||||
/usr/bin/groff -mtty-char $opts ${TMPFILE} 2>/dev/null
|
|
||||||
else
|
else
|
||||||
if [ $TMPFILE = buf ]; then
|
iconv -f utf-8 -t utf-8 $TMPFILE &>/dev/null && charset_in=utf-8
|
||||||
echo -n "$buf" | iconv -f utf-8 -t utf-8 &>/dev/null && charset_in=utf-8
|
fi
|
||||||
else
|
|
||||||
iconv -f utf-8 -t utf-8 $TMPFILE &>/dev/null && charset_in=utf-8
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $charset_in != utf-8 ]; then
|
if [ $charset_in != utf-8 ]; then
|
||||||
echo XXX
|
echo XXX
|
||||||
echo XXX $"WARNING: old character encoding and/or character set"
|
echo XXX $"WARNING: old character encoding and/or character set"
|
||||||
echo XXX
|
echo XXX
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# en_US is chosen arbitrarily; any UTF-8 locale should work
|
# en_US is chosen arbitrarily; any UTF-8 locale should work
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
# This shell script is intended for use with man, so warnings are
|
# This shell script is intended for use with man, so warnings are
|
||||||
# probably not wanted. Also load nroff-style character definitions.
|
# probably not wanted. Also load nroff-style character definitions.
|
||||||
if [ $charset_in = utf-8 -a $charset_out = UTF-8 ]; then
|
if [ $charset_in = utf-8 -a $charset_out = UTF-8 ]; then
|
||||||
if [ $TMPFILE = buf ]; then
|
if [ $TMPFILE = buf ]; then
|
||||||
echo -n "$buf" | /usr/bin/groff $opts 2>/dev/null
|
echo -n "$buf" | /usr/bin/groff $opts 2>/dev/null
|
||||||
else
|
|
||||||
exec < $TMPFILE
|
|
||||||
rm -f $TMPFILE
|
|
||||||
exec /usr/bin/groff $opts 2>/dev/null
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [ $TMPFILE = buf ]; then
|
exec < $TMPFILE
|
||||||
echo -n "$buf" | \
|
rm -f $TMPFILE
|
||||||
/usr/bin/iconv -f $charset_in -t utf-8 | \
|
exec /usr/bin/groff $opts 2>/dev/null
|
||||||
/usr/bin/groff $opts 2>/dev/null | \
|
fi
|
||||||
/usr/bin/iconv -f utf-8 -t ${charset_out}//translit
|
else
|
||||||
else
|
if [ $TMPFILE = buf ]; then
|
||||||
/usr/bin/iconv -f $charset_in -t utf-8 $TMPFILE | \
|
echo -n "$buf" | \
|
||||||
|
/usr/bin/iconv -f $charset_in -t utf-8 | \
|
||||||
/usr/bin/groff $opts 2>/dev/null | \
|
/usr/bin/groff $opts 2>/dev/null | \
|
||||||
/usr/bin/iconv -f utf-8 -t ${charset_out}//translit
|
/usr/bin/iconv -f utf-8 -t ${charset_out}//translit
|
||||||
|
else
|
||||||
|
/usr/bin/iconv -f $charset_in -t utf-8 $TMPFILE | \
|
||||||
|
/usr/bin/groff $opts 2>/dev/null | \
|
||||||
|
/usr/bin/iconv -f utf-8 -t ${charset_out}//translit
|
||||||
|
|
||||||
rm -f $TMPFILE
|
rm -f $TMPFILE
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# eof
|
# eof
|
||||||
|
Loading…
Reference in New Issue
Block a user