/[smeserver]/rpms/wv/sme7/wv-wvtext-tmp.patch
ViewVC logotype

Contents of /rpms/wv/sme7/wv-wvtext-tmp.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Jun 12 17:54:00 2007 UTC (17 years, 5 months ago) by slords
Branch: MAIN
CVS Tags: wv-1_0_0-3_el4_sme, HEAD
Error occurred while calculating annotation data.
Import on branch sme7 of package wv-1.0.0-3.el4.sme.src.rpm

1 --- wvText.in
2 +++ wvText.in
3 @@ -3,24 +3,50 @@
4 prefix=@prefix@
5 exec_prefix=@exec_prefix@
6 datadir=@datadir@
7 -tmpdir=/tmp
8 +tmpdir=$(mktemp -d /tmp/wvText.XXXXXXXX) || { echo "$0: can not create temporary directory" >& 2; exit 1; }
9 +i_file=
10 +o_file=
11
12 # argument checking
13 -if [ ${#} -ne "2" ]; then
14 - echo "Usage: ${0} <word document> <text output file>"
15 +
16 +case ${#} in
17 + 1)
18 + i_file=${1}
19 + o_file=-
20 + ;;
21 + 2)
22 + i_file=${1}
23 + o_file=${2}
24 + ;;
25 + *)
26 + echo "Usage: `basename ${0}` <word document> [<text output file>]"
27 exit 1
28 -fi
29 + ;;
30 +esac
31
32 # start out optimistic
33 -USING_LYNX=1
34 -which lynx >/dev/null 2>&1
35 -if [ ${?} -ne "0" ]; then
36 - echo "Could not find required program 'lynx'"
37 - echo "Not using lynx. Ouput will be pretty bad."
38 - USING_LYNX=0
39 -fi
40 +USING_BROWSER=1
41 +BROWSER_CMD="w3m -dump -T text/html"
42 +browser=none
43 +
44 +which lynx >& /dev/null && browser=lynx
45 +which w3m >& /dev/null && browser=w3m
46 +
47 +case $browser in
48 + w3m)
49 + BROWSER_CMD="w3m -dump -T text/html"
50 + ;;
51 + lynx)
52 + BROWSER_CMD="lynx -dump -force_html"
53 + ;;
54 + *)
55 + echo "Neither w3m nor lynx found"
56 + echo "Output will be pretty bad."
57 + USING_BROWSER=0
58 + ;;
59 +esac
60
61 -if [ ${USING_LYNX} -ne "0" ]; then
62 +if [ ${USING_BROWSER} -ne "0" ]; then
63
64 # first, test for wvHtml
65 which wvHtml >/dev/null 2>&1
66 @@ -32,25 +58,34 @@
67 # intermediate file
68 TMP_FILE="wv$$.html"
69
70 - wvHtml "${1}" --targetdir="${tmpdir}" "${TMP_FILE}" >/dev/null 2>&1
71 + wvHtml "$i_file" --targetdir="${tmpdir}" "${TMP_FILE}" >/dev/null 2>&1
72 if [ ${?} -ne "0" ]; then
73 - echo "Could not convert into HTML"
74 + echo "Could not convert $i_file into HTML"
75 exit 1
76 fi
77
78 # lynx actually does quite well
79 - TERM=vt100 lynx -dump -force_html "${tmpdir}/${TMP_FILE}" > "${2}"
80 + # Output to stdout requested
81 + if test "x$o_file" = "x-"; then
82 + TERM=vt100 ${BROWSER_CMD} "${tmpdir}/${TMP_FILE}"
83 + else
84 + TERM=vt100 ${BROWSER_CMD} "${tmpdir}/${TMP_FILE}" > "$o_file"
85 + fi
86 if [ ${?} -ne "0" ]; then
87 - echo "Could not convert into Text"
88 + echo "Could not convert $i_file into Text"
89 exit 1
90 fi
91
92 # clean up
93 - rm -f "${tmpdir}/${TMP_FILE}"
94 + rm -rf "${tmpdir}"
95
96 else
97 # fall back onto our cruddy output
98 # this is, admittedly, better than running
99 # 'strings' on the word document though :)
100 - wvWare -x ${datadir}/wv/wvText.xml "${1}" > "${2}"
101 + if test "x$o_file" = "x-"; then
102 + wvWare -x ${datadir}/wv/wvText.xml "$i_file"
103 + else
104 + wvWare -x ${datadir}/wv/wvText.xml "$i_file" > "$o_file"
105 + fi
106 fi
107

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed