1 |
27 |
unneback |
#!/bin/bash
|
2 |
|
|
# restart using a Tcl shell \
|
3 |
|
|
exec sh -c 'for tclshell in tclsh tclsh83 cygtclsh80 ; do \
|
4 |
|
|
( echo | $tclshell ) 2> /dev/null && exec $tclshell "`( cygpath -w \"$0\" ) 2> /dev/null || echo $0`" "$@" ; \
|
5 |
|
|
done ; \
|
6 |
|
|
echo "fixhtml.tcl: cannot find Tcl shell" ; exit 1' "$0" "$@"
|
7 |
|
|
|
8 |
|
|
#===============================================================================
|
9 |
|
|
#
|
10 |
|
|
# fixhtml.tcl
|
11 |
|
|
#
|
12 |
|
|
# Patch HTML files generated from DocBook sources.
|
13 |
|
|
#
|
14 |
|
|
#===============================================================================
|
15 |
|
|
#####ECOSGPLCOPYRIGHTBEGIN####
|
16 |
|
|
## -------------------------------------------
|
17 |
|
|
## This file is part of eCos, the Embedded Configurable Operating System.
|
18 |
|
|
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
19 |
|
|
##
|
20 |
|
|
## eCos is free software; you can redistribute it and/or modify it under
|
21 |
|
|
## the terms of the GNU General Public License as published by the Free
|
22 |
|
|
## Software Foundation; either version 2 or (at your option) any later version.
|
23 |
|
|
##
|
24 |
|
|
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
25 |
|
|
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
26 |
|
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
27 |
|
|
## for more details.
|
28 |
|
|
##
|
29 |
|
|
## You should have received a copy of the GNU General Public License along
|
30 |
|
|
## with eCos; if not, write to the Free Software Foundation, Inc.,
|
31 |
|
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
32 |
|
|
##
|
33 |
|
|
## As a special exception, if other files instantiate templates or use macros
|
34 |
|
|
## or inline functions from this file, or you compile this file and link it
|
35 |
|
|
## with other works to produce a work based on this file, this file does not
|
36 |
|
|
## by itself cause the resulting work to be covered by the GNU General Public
|
37 |
|
|
## License. However the source code for this file must still be made available
|
38 |
|
|
## in accordance with section (3) of the GNU General Public License.
|
39 |
|
|
##
|
40 |
|
|
## This exception does not invalidate any other reasons why a work based on
|
41 |
|
|
## this file might be covered by the GNU General Public License.
|
42 |
|
|
##
|
43 |
|
|
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
44 |
|
|
## at http://sources.redhat.com/ecos/ecos-license/
|
45 |
|
|
## -------------------------------------------
|
46 |
|
|
#####ECOSGPLCOPYRIGHTEND####
|
47 |
|
|
#===============================================================================
|
48 |
|
|
######DESCRIPTIONBEGIN####
|
49 |
|
|
#
|
50 |
|
|
# Author(s): bartv
|
51 |
|
|
# Contributors: bartv
|
52 |
|
|
# Date: 2000-03-14
|
53 |
|
|
# Purpose: HTML files generated from DocBook sources using the nwalsh
|
54 |
|
|
# stylesheets have a number of problems. Most importantly,
|
55 |
|
|
# Netscape 4.x does not understand all of the character entities
|
56 |
|
|
# defined by HTML 4.0x
|
57 |
|
|
#
|
58 |
|
|
#####DESCRIPTIONEND####
|
59 |
|
|
#===============================================================================
|
60 |
|
|
#
|
61 |
|
|
|
62 |
|
|
# Find out the current year for the copyright message. Ideally
|
63 |
|
|
# this would be a range extracted from the sources, but that is
|
64 |
|
|
# a little bit tricky.
|
65 |
|
|
|
66 |
|
|
set year [clock format [clock seconds] -format "%Y"]
|
67 |
|
|
|
68 |
|
|
set copyright_banner \
|
69 |
|
|
"<!-- Copyright (C) $year Red Hat, Inc. -->
|
70 |
|
|
<!-- This material may be distributed only subject to the terms -->
|
71 |
|
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
72 |
|
|
<!-- or later (the latest version is presently available at -->
|
73 |
|
|
<!-- http://www.opencontent.org/openpub/). -->
|
74 |
|
|
<!-- Distribution of the work or derivative of the work in any -->
|
75 |
|
|
<!-- standard (paper) book form is prohibited unless prior -->
|
76 |
|
|
<!-- permission is obtained from the copyright holder. -->"
|
77 |
|
|
|
78 |
|
|
set files [glob *.html]
|
79 |
|
|
foreach file $files {
|
80 |
|
|
set status [catch {
|
81 |
|
|
|
82 |
|
|
set fd [open $file "r"]
|
83 |
|
|
set data [read $fd]
|
84 |
|
|
close $fd
|
85 |
|
|
|
86 |
|
|
# If there is already a (C) message on the first line, skip this file.
|
87 |
|
|
if {[regexp {[^\n]*Copyright (C) [0-9]* Red Hat.*} $data] == 0} {
|
88 |
|
|
|
89 |
|
|
# The DSSSL has the annoying habit of splitting tags over several lines.
|
90 |
|
|
# This should sort things out.
|
91 |
|
|
# REMOVED by jifl: doing this can add newlines in tags like
|
92 |
|
|
# <literallayout>, <screen>, and/or <programlisting>
|
93 |
|
|
# regsub -all "\n>" $data ">\n" data
|
94 |
|
|
|
95 |
|
|
# Add a copyright banner
|
96 |
|
|
set data "[set copyright_banner]\n[set data]"
|
97 |
|
|
|
98 |
|
|
# Look for a smarttags meta. If absent, insert one. There should
|
99 |
|
|
# already be one meta present identifying the stylesheet, so
|
100 |
|
|
# that identifies a sensible location for inserting another meta.
|
101 |
|
|
if {[regexp {MSSmartTagsPreventParsing} $data] == 0} {
|
102 |
|
|
regsub -nocase {<META} $data "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n<META" data
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
# Take care of some character entities that Netscape does not understand
|
106 |
|
|
regsub -all "&mgr;" $data "\\BC;" data
|
107 |
|
|
regsub -all "—" $data "\\—" data
|
108 |
|
|
regsub -all "–" $data "\\–" data
|
109 |
|
|
regsub -all "…" $data "\\…" data
|
110 |
|
|
regsub -all "“" $data "\\“" data
|
111 |
|
|
regsub -all "”" $data "\\”" data
|
112 |
|
|
regsub -all "[" $data "\\[" data
|
113 |
|
|
regsub -all "]" $data "\\]" data
|
114 |
|
|
regsub -all "{" $data "\\{" data
|
115 |
|
|
regsub -all "}" $data "\\}" data
|
116 |
|
|
regsub -all "‘" $data "\\‘" data
|
117 |
|
|
regsub -all "’" $data "\\’" data
|
118 |
|
|
regsub -all "™" $data "\\™" data
|
119 |
|
|
regsub -all "*" $data "\\*" data
|
120 |
|
|
regsub -all "_" $data "\\_" data
|
121 |
|
|
regsub -all "/" $data "\\/" data
|
122 |
|
|
regsub -all "=" $data "\\=" data
|
123 |
|
|
regsub -all "#" $data "\\#" data
|
124 |
|
|
regsub -all "+" $data "\\+" data
|
125 |
|
|
regsub -all "%" $data "\\%" data
|
126 |
|
|
regsub -all "$" $data "\\$" data
|
127 |
|
|
regsub -all "│" $data "\\│" data
|
128 |
|
|
regsub -all "\" $data "\\\" data
|
129 |
|
|
regsub -all "█" $data "\\█" data
|
130 |
|
|
regsub -all "▮" $data "\\▮" data
|
131 |
|
|
|
132 |
|
|
# Now write the data back to the file. Do not bother to
|
133 |
|
|
# keep an old version lying around, the html files can be
|
134 |
|
|
# regenerated easily enough.
|
135 |
|
|
set fd [open $file "w"]
|
136 |
|
|
puts -nonewline $fd $data
|
137 |
|
|
close $fd
|
138 |
|
|
}
|
139 |
|
|
} result]
|
140 |
|
|
|
141 |
|
|
if {0 != $status} {
|
142 |
|
|
puts "Error while processing file $file\n $result"
|
143 |
|
|
exit 1
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
|
|
|