From 19207b66bfc5d43b71602823bc3401b803d70339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcela=20Ma=C5=A1l=C3=A1=C5=88ov=C3=A1?= Date: Tue, 3 Jul 2007 09:53:23 +0000 Subject: [PATCH] Add feature. --- groff.spec | 5 ++++- nroff | 49 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/groff.spec b/groff.spec index 099b71d..132cbed 100644 --- a/groff.spec +++ b/groff.spec @@ -3,7 +3,7 @@ Summary: A document formatting system Name: groff Version: 1.18.1.4 -Release: 4%{?dist} +Release: 5%{?dist} License: GPL Group: Applications/Publishing URL: http://groff.ffii.org @@ -233,6 +233,9 @@ exit 0 %endif %changelog +* Mon Jul 2 2007 Marcela Maslanova - 1.18.1.4-5 +- Resolves: rhbz#245934 + * Tue Feb 27 2007 Marcela Maslanova - 1.18.1.4-4 - merge review - rhbz#225859 review diff --git a/nroff b/nroff index 2c7f3d0..fb9d176 100644 --- a/nroff +++ b/nroff @@ -4,7 +4,7 @@ prog="$0" charset_in=iso-8859-1 charset_out=`locale charmap 2>/dev/null` -opts= +opts="-mtty-char -Tutf8" for i do @@ -44,15 +44,21 @@ do shift done -TMPFILE=$(mktemp /tmp/man.XXXXXX) -trap "rm -f $TMPFILE" 0 1 2 3 15 - -cat ${1+"$@"} >| ${TMPFILE} - -if iconv -f utf-8 -t utf-8 -o /dev/null ${TMPFILE} 2>/dev/null -then - charset_in=utf-8 +if TMPFILE=$(mktemp /tmp/man.XXXXXX 2>/dev/null); then + trap "rm -f $TMPFILE" 0 1 2 3 15 + cat ${1+"$@"} >| $TMPFILE else + buf=$(cat ${1+"$@"}) + TMPFILE=buf +fi + +if [ $TMPFILE = buf ]; then + echo -n "$buf" | iconv -f utf-8 -t utf-8 &>/dev/null && charset_in=utf-8 +else + iconv -f utf-8 -t utf-8 $TMPFILE &>/dev/null && charset_in=utf-8 +fi + +if [ $charset_in != utf-8 ]; then echo XXX echo XXX $"WARNING: old character encoding and/or character set" echo XXX @@ -64,10 +70,27 @@ export LC_ALL=en_US.UTF-8 # This shell script is intended for use with man, so warnings are # probably not wanted. Also load nroff-style character definitions. -/usr/bin/iconv -f ${charset_in} -t utf-8 ${TMPFILE} | \ - /usr/bin/groff -mtty-char -Tutf8 $opts 2>/dev/null | \ +if [ $charset_in = utf-8 -a $charset_out = UTF-8 ]; then + if [ $TMPFILE = buf ]; then + 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 + if [ $TMPFILE = buf ]; then + echo -n "$buf" | \ + /usr/bin/iconv -f $charset_in -t utf-8 | \ + /usr/bin/groff $opts 2>/dev/null | \ + /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 + # eof