pkg://bg5sgmltools-0.8-8.src.rpm:18711/bg5sgmltools-0.8.tar.gz
info downloads
bg5sgmltools-0.8/ 40755 144 144 0 6621552150 12737 5 ustar cwhuang users bg5sgmltools-0.8/COPYING 100644 144 144 43127 6574541337 14132 0 ustar cwhuang users GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
bg5sgmltools-0.8/Makefile 100644 144 144 4325 6574541337 14514 0 ustar cwhuang users #
# Makefile for the bg5sgmltools package: ripped straight from ipchains.
# (C) 1998 All rights reserved.
# EMail complaints to C.W.Huang <cwhuang@phys.ntu.edu.tw>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
VERSION = $(shell cat VERSION)
CC = c++
COPTS = -O2
CFLAGS = -Wall -Wunused $(COPTS)
LIB = -lstdc++
BIN = /usr/local/bin
MANDIR = /usr/man
INSTALL = install
SCRIPT = bg5sgmlfunctions bg5sgmlcheck \
bg5sgml2html bg5sgml2latex bg5sgml2txt bg5sgml2lyx
.SUFFIXES: .html .txt .tex .lyx .sgml
.sgml.html:
@PATH=.:$(PATH) ./bg5sgml2html $<
.sgml.txt:
./bg5sgml2txt $<
.sgml.tex:
@PATH=.:$(PATH) ./bg5sgml2latex $< --clean \
--output=tex --output=dvi --output=ps
.sgml.lyx:
@PATH=.:$(PATH) ./bg5sgml2lyx $<
all: b2a readme.html readme.txt readme.tex readme.lyx
b2a: b2a.cc
$(CC) $(CFLAGS) $(LIB) -o b2a b2a.cc
version:
@echo This is version $(VERSION).
install:
$(INSTALL) -s -m 0755 -o 0 -g 0 b2a $(BIN)
for i in $(SCRIPT); \
do $(INSTALL) -m 0755 -o 0 -g 0 $$i $(BIN) ; \
done
uninstall:
for i in $(SCRIPT) b2a; do rm -f $(BIN)/$$i; done
doc: b2a
@PATH=.:$(PATH) ./bg5sgml2html readme
@if [ -n `type -path lynx` ]; then \
PATH=.:$(PATH) ./bg5sgml2txt readme ; \
fi
@if [ -n `type -path chilatex` ]; then \
PATH=.:$(PATH) ./bg5sgml2latex readme --clean \
--output=tex --output=dvi --output=ps ; \
fi
@PATH=.:$(PATH) ./bg5sgml2lyx readme
clean:
rm -f b2a *.o core tmp@
rm -f *.htm *.html *.tex *.dvi *.ps *.aux *.toc *.log *.txt
rm -f *.info *.rtf *.man *.lyx
pack: clean
cd ..; tar cf - bg5sgmltools-$(VERSION) | \
gzip -9 > bg5sgmltools-$(VERSION).tar.gz
bg5sgmltools-0.8/b2a.cc 100644 144 144 5557 6574541337 14037 0 ustar cwhuang users //
// Convert BIG5 file to plain ASCII format
//
// by C.W.Huang 12-13 May 1998
// updated 27-31 July 1998
//
// Usage
//
// b2a read from stdin and write to stdout
// -f file read from the specific file
// -o file write to the specific file
// -d decoding
// -e encoding (default)
// -s seq escape sequence
//
// Compile
//
// gcc -lstdc++ -o b2a b2a.cc
//
//
// No use here!! Refer to later...
//
char escape='@';
char *escapeseq="@=";
const char endchar=' ';
struct scope {
unsigned int begin, end;
};
scope big5scope[]={
{ 0xa440, 0xc67e },
{ 0xc940, 0xf9fe },
{ 0xa140, 0xa3c7 }
};
#include <stdlib.h>
#include <string.h>
#include <fstream.h>
bool isDoubleBytesWord(int lobyte, int hibyte)
{
unsigned int word=(hibyte << 8) + lobyte;
for (unsigned int i=0; i<sizeof(big5scope); i++) {
if (word >= big5scope[i].begin && word <= big5scope[i].end)
return true;
}
return false;
}
inline bool isBig5Code(int hicode, int locode)
{
return !((locode < 0x40 || locode > 0xFE || (locode > 0x7E && locode < 0xA1)) ||
(hicode < 0xA1 || hicode > 0xF9 || (hicode > 0xC6 && hicode < 0xC9)));
}
void Encoding(istream& ifs, ostream& ofs)
{
ofs << hex;
unsigned char ch=ifs.get();
while (ifs.good()) {
if (ch == '\n') {
ofs.put('\n');
} else if (ch == escape) {
ofs.put(escape);
ofs.put(escape);
} else {
unsigned char cl=ifs.get();
if (ifs.eof()) {
ofs.put(ch);
break;
}
if (isBig5Code(ch, cl)) {
unsigned int code=((unsigned int)ch << 8) + cl;
ofs << escapeseq << code << endchar;
} else {
ofs.put(ch);
ch=cl;
continue;
}
}
ch=ifs.get();
}
}
void Decoding(istream& ifs, ostream& ofs)
{
ifs >> hex;
while (ifs.good()) {
unsigned char ch=ifs.get();
if (!ifs.good())
break;
if (ch == escape) {
unsigned char cl=ifs.get();
if (cl == escapeseq[1]) {
unsigned int code;
ifs >> code;
ofs.put((unsigned char)(code>>8));
ofs.put((unsigned char)code);
ifs.get();
} else {
if (cl != escape)
ofs.put(ch);
ofs.put(cl);
}
} else
ofs.put(ch);
}
}
int main(int argc, char *argv[])
{
void (*convert)(istream&, ostream&) = Encoding;
istream *pifs = &cin;
ostream *pofs = &cout;
fstream ifs, ofs;
char esc[]="@=";
escapeseq=esc;
for (int i=1; i<argc; i++) {
switch (argv[i][1]) {
case 's':
memcpy(escapeseq, argv[++i], 2);
escape=escapeseq[0];
break;
case 'd':
convert = Decoding;
break;
case 'e':
convert = Encoding;
break;
case 'f':
ifs.open(argv[++i], ios::in);
pifs=&ifs;
break;
case 'o':
ofs.open(argv[++i], ios::out);
pofs=&ofs;
break;
default:
cerr << "Unknown options!\n";
exit(1);
}
}
convert(*pifs, *pofs);
return 0;
}
bg5sgmltools-0.8/bg5sgml2html 100755 144 144 1446 6601217161 15274 0 ustar cwhuang users #!/bin/bash
#
# by Chih-Wei Huang
# 27-31 July 1998
# Updated 20 September 1998
#
PATH=.:$PATH
FUNCTIONS="`type -path bg5sgmlfunctions`"
if [ -z $FUNCTIONS ]; then
echo "$0: include file not found!"
exit 1
fi
. $FUNCTIONS
for src in $filelist
do
checksrcfile $src
[ $? = 0 ] && continue
encodingbg5 $src
pushd . > /dev/null
cd $TMP
sgml2html $options $name.sgml
if [ -e $name.html ]; then
list=`ls $name*.html`
elif [ -e $name.htm ]; then
list=`ls $name*.htm`
else
exit 2
fi
popd > /dev/null
for file in $list
do
sed 's/<HEAD>/<HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text\/html; charset=big5">/g' $TMP/$file | \
$B2A -d -o $file
done
done
cleartmp
bg5sgmltools-0.8/bg5sgml2latex 100755 144 144 5355 6601217653 15456 0 ustar cwhuang users #!/bin/bash
#
# by Chih-Wei Huang
# 27-31 July 1998
# Updated 20 September 1998
#
PATH=.:$PATH
FUNCTIONS="`type -path bg5sgmlfunctions`"
if [ -z $FUNCTIONS ]; then
echo "$0: include file not found!"
exit 1
fi
. $FUNCTIONS
sgmloptions=""
TEX=0
DVI=0
PS=0
CLEAN=0
STOP=0
for opt in $options
do
case $opt in
--output=tex)
TEX=1
;;
--output=dvi)
DVI=1
;;
--output=ps)
PS=1
;;
--output=all)
TEX=1; DVI=1; PS=1
;;
--clean)
CLEAN=1
;;
--stop)
STOP=1
;;
--font*)
FONT=`echo $opt | cut -d= -f2`
;;
*)
sgmloptions="$sgmloptions $opt"
;;
esac
done
unalias chilatex
if [ "$DVI" = "1" -o "$PS" = "1" ]; then
if [ -z "`type -path chilatex`" ]; then
echo "chilatex not found! create .tex file only..."
TEX=1; DVI=0; PS=0
fi
else
TEX=1
fi
TEXINPUTS="`kpsexpand \\\$TEXINPUTS`:/usr/lib/sgml-tools//"
export TEXINPUTS
function TeXHeader()
{
head -1 $TMP/$1.tex > $1.tex
cat << 'EOH' >> $1.tex
\let\labelold\label
\def\label{\protect\labelold}
\let\bfseriesold\bfseries
\def\bfseries{\protect\bfseriesold}
%\let\numberlineold\numberline
%\def\numberline{\protect\numberlineold}
EOH
[ "$STOP" != "1" ] && echo '\nonstopmode' >> $1.tex
[ ! -z $FONT ] && echo "\\$FONT" >> $1.tex
}
for src in $filelist
do
checksrcfile $src
[ $? = 0 ] && continue
encodingbg5 $src
pushd . > /dev/null
cd $TMP
sgml2latex --output=tex $sgmloptions $name.sgml
popd > /dev/null
if [ -e $TMP/$name.tex ]; then
head -1 $TMP/$name.tex > $name.tex
[ "$STOP" != "1" ] && echo '\nonstopmode' >> $name.tex
# NOTE: ! -z is not the same as -n !! A bug ??
[ ! -z $FONT ] && echo "\\$FONT" >> $name.tex
tail +2 $TMP/$name.tex | $B2A -d >> $name.tex
if [ "$DVI" = "1" -o "$PS" = "1" ]; then
[ ! -e $name.toc ] && chilatex $name.tex
chilatex $name.tex
# if [ "$CLEAN" != "1" -a -x /usr/lib/texmf/bin/chitex/ctran ]; then
# /usr/lib/texmf/bin/chitex/ctran $name.log > $name.log@
# mv -f $name.log@ $name.log
# [ -e tmp@ ] && rm -f tmp@
# fi
if [ -e $name.dvi -a "$PS" = "1" ]; then
dvips -o $name.ps $name.dvi
fi
fi
if [ "$CLEAN" = "1" ]; then
rm -f $name.aux $name.log $name.toc
[ "$TEX" = "0" -a -e $name.tex ] && rm -f $name.tex
[ "$DVI" = "0" -a -e $name.dvi ] && rm -f $name.dvi
[ "$PS" = "0" -a -e $name.ps ] && rm -f $name.ps
fi
fi
done
cleartmp
bg5sgmltools-0.8/bg5sgmlcheck 100755 144 144 732 6601217606 15304 0 ustar cwhuang users #!/bin/bash
#
# by Chih-Wei Huang
# 27-31 July 1998
# Updated 20 September 1998
#
PATH=.:$PATH
FUNCTIONS="`type -path bg5sgmlfunctions`"
if [ -z $FUNCTIONS ]; then
echo "$0: include file not found!"
exit 1
fi
. $FUNCTIONS
for src in $filelist
do
checksrcfile $src
[ $? = 0 ] && continue
encodingbg5 $src
pushd . > /dev/null
cd $TMP
sgmlcheck $options $name.sgml
popd > /dev/null
done
cleartmp
bg5sgmltools-0.8/bg5sgmlfunctions 100755 144 144 2560 6601217554 16262 0 ustar cwhuang users #!/bin/bash
#
# by Chih-Wei Huang
# 31 July 1998
# Updated 20 September 1998
#
BINPATH="/bin:/usr/bin:/usr/local/bin"
PATH="$BINPATH:`pwd`"
if [ $# = 0 ]; then
echo "Usage: $0 [options] file1 [file2, ...]"
exit 1
fi
UMASK=`umask`
umask 022
unset LANG
unset LC_CTYPE
unset LC_ALL
unalias b2a
B2A="`type -path b2a`"
if [ -z "$B2A" ]; then
echo "b2a utility not found!"
exit 1
fi
PATH=$BINPATH
unalias dos2unix
DOS2UNIX="`type -path dos2unix`"
if [ -z "$DOS2UNIX" ]; then
DOS2UNIX=cat
fi
options=""
filelist=""
DEBUG=0
TMP=/tmp/bg5sgmltools.$$
trap 'rm -rf $TMP' 2 3 15
mkdir $TMP
for opt in $*; do
if [ "`echo $opt | cut -c1`" = "-" ]; then
if [ "$opt" = "-d" ]; then
DEBUG=1
else
options="$options $opt"
fi
else
filelist="$filelist $opt"
fi
done
function checksrcfile()
{
if [ ! -e $1 ]; then
if [ ! -e $1.sgml ]; then
echo "File $1 doesn't exist!"
return 0
fi
src=$1.sgml
fi
return 1
}
function encodingbg5()
{
name=`basename $1 .sgml`
# Filter out some buggy macros in latex output
sed 's/<nidx>/<!--nidx>/g; s/<\/nidx>/<\/nidx-->/g' $1 | \
$DOS2UNIX | $B2A -e -o $TMP/$name.sgml
}
function cleartmp()
{
[ "$DEBUG" != "1" ] && rm -rf $TMP
umask $UMASK
exit 0
}
bg5sgmltools-0.8/readme.sgml 100644 144 144 14263 6574541337 15217 0 ustar cwhuang users <!doctype linuxdoc system>
<!-- 作者 黃志偉 -->
<article>
<!-- Title information -->
<title>SGMLtools 中文套件使用說明
<author>
<htmlurl url="http://www.phys.ntu.edu.tw/~cwhuang/pub/" name="黃志偉">
<tt><htmlurl url="mailto:cwhuang@phys.ntu.edu.tw" name="cwhuang@phys.ntu.edu.tw"></tt>
<date>
<!--v0.5, bgein on 31 July 1998 -->
<!--v0.6, 1 August 1998-->
<!--v0.7, 8 August 1998-->
v0.8, 7 September 1998
<abstract>
本文件說明如何使用 SGMLtools 中文套件處理中文 SGML 檔案。
</abstract>
<!-- Table of contents -->
<toc>
<!-- Begin of document -->
<!---------- Next Section ---------->
<sect>簡介
<p>
由於 SGMLtools 1.0.x 不能正確處理中文的 SGML 文件,因此我寫了這個中文套件,先將中文編碼後再交給 SGMLtools 處理。
套件中包含一工具程式 <tt/b2a/, 可自標準輸入或檔案中讀取資料,將其中的 BIG5 字元編碼成 <tt/@=XXXX/ 的形式,其中 <tt/XXXX/ 就是該字的 BIG5 碼。
這個程式同時也能將這種編碼的資料予以解碼。
套件中還包含一些指令稿(shell script), 將中文 SGML 檔案交由 <tt/b2a/ 編碼後交給 SGMLtools 處理,再將輸出的檔案解碼成正常的中文檔案。
要使用本套件,你必須先安裝這些工具程式:
<itemize>
<item>最新穩定版本的 <em/SGMLtools/. 在本文撰寫時是 <tt/v1.0.7/.
<item>如果想輸出 dvi 格式,需要 <em/ChiTeX/. 本文撰寫時的最新版本是 <tt/v6.0.8p3/.
<item>如果想輸出純文字格式需安裝 <em/lynx/.
<item>將 DOS 文字檔格式轉換為 UNIX 格式的程式 <em/dos2unix/ (非必備).
</itemize>
最新版的程式可在此取得:
<tscreen>
<htmlurl url="ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/src/" name="ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/src/bg5sgmltools-0.8.tar.gz"><newline>
<htmlurl url="ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/rpm/" name="ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/rpm/bg5sgmltools-0.8-x.i386.rpm"><newline>
<htmlurl url="ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/srpm/" name="ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/srpm/bg5sgmltools-0.8-x.src.rpm">
</tscreen>
安裝很簡單。解開後
<tscreen><verb>
make
make install
</verb></tscreen>
本程式是 Linux 中文文件計劃(CLDP)的一部份。如果你參與 CLDP 計劃,請安裝本套件以便測試,轉換中文 SGML 檔案。請參考本計劃的網頁:
<quote>
<htmlurl url="http://www.linux.org.tw/CLDP/" name="http://www.linux.org.tw/CLDP/">
</quote>
如果你發現臭蟲,或有任何建議,請來信告知:<newline>
<tt><htmlurl url="mailto:cwhuang@phys.ntu.edu.tw" name="cwhuang@phys.ntu.edu.tw"></tt>
<!---------- Next Section ---------->
<sect>使用
<p>
目前套件中提供五個指令稿: <tt/bg5sgmlcheck/, <tt/bg5sgml2html/, <tt/bg5sgml2txt/, <tt/bg5sgml2latex/, <tt/bg5sgml2lyx/,
分別對應 SGMLtools 中的 <tt/sgmlcheck/, <tt/sgml2html/, <tt/sgml2txt/, <tt/sgml2latex/ 及 <tt/sgml2lyx/.
大部份的指令都可加上原來 SGMLtools 對應指令的選項(options),只有些許例外,見<ref id="note" name="註">。
現分別說明如下:
<descrip>
<tag/bg5sgmlcheck/
用來檢查 SGML 檔案格式是否正確。用法:
<tscreen><verb>
bg5sgmlcheck [options] file.sgml [file2.sgml ...]
</verb></tscreen>
所有 <tt/sgmlcheck/ 可用的選項(options)都可用在 <tt/bg5sgmlcheck/ 上。
可一次檢查數個檔案。副檔名 <tt/.sgml/ 可省略。
<tag/bg5sgml2html/
將 SGML 檔案轉換為 HTML 格式。用法:
<tscreen><verb>
bg5sgml2html [options] file.sgml [file2.sgml ...]
</verb></tscreen>
所有 <tt/sgml2html/ 可用的選項都可用在 <tt/bg5sgml2html/ 上。可一次轉換數個檔案。副檔名 <tt/.sgml/ 可省略。
<tag/bg5sgml2txt/
將 SGML 檔案轉換為純文字格式。用法:
<tscreen><verb>
bg5sgml2txt [options] file.sgml [file2.sgml ...]
</verb></tscreen>
可一次檢查數個檔案。副檔名 <tt/.sgml/ 可省略。選項
<itemize>
<item><tt/--width=NUMBER/ 設定輸出寬度為 <tt/NUMBER/. 預設是 80 行。
<item><tt/--noidx/ 不產生各章節的索引。可節省時間。
</itemize>
請注意目前尚不支援 <tt/sgml2txt/ 專用的選項,如 <tt/--man/ 等。
<tag/bg5sgml2latex/
將 SGML 檔案轉換為 tex, dvi, PostScript 格式。使用方法:
<tscreen><verb>
bg5sgml2latex [options] file.sgml [file2.sgml ...]
</verb></tscreen>
同樣地,所有 <tt/sgml2latex/ 可用的選項都可用在 <tt/bg5sgml2latex/ 上。
可一次轉換數個檔案。副檔名 <tt/.sgml/ 也可省略。
然而與 <tt/sgml2latex/ 不同的是 <tt/bg5sgml2latex/ 預設產生 tex 檔案,而非 dvi 檔。
如果想轉換為 dvi 或 PostScript 檔案,你還必須安裝 ChiTeX 套件。可從這裡取得 rpm 檔案:
<quote>
<htmlurl url="ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/rpm/" name="ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/rpm/chitex-6.0.8p3-x.i386.rpm">
</quote>
選項
<itemize>
<item><tt/--output=tex/ 產生 tex 檔案(預設)。
<item><tt/--output=dvi/ 輸出 dvi 檔案。
<item><tt/--output=ps/ 輸出 PostScript 檔案。
<item><tt/--output=all/ 同時輸出 tex, dvi, PostScript 檔案。
<item><tt/--clean/ 刪除轉換過程中產生的暫存檔。
<item><tt/--stop/ 編譯 tex 檔案遇到錯誤時暫停下來(預設是繼續編譯下去)。
<item><tt/--font=FONT/ 指定中文字型為 FONT. FONT 是 ChiTeX 字型巨集名稱。
</itemize>
比較特別的是 <tt/--output=tex/, <tt/--output=dvi/, <tt/--output=ps/ 選項可以並存,表示同時輸出這些格式。例如:
<tscreen><verb>
bg5sgml2latex --clean --output=tex --output=ps --font=kai file.sgml
</verb></tscreen>
表輸出 tex 及 PostScript 檔,中文字型使用 \kai, 並刪除轉換過程中產生的 <tt/.aux/, <tt/.toc/ 等檔案。
<tag/bg5sgml2lyx/
將 SGML 檔案轉換為 LyX 格式。用法:
<tscreen><verb>
bg5sgml2lyx [options] file.sgml [file2.sgml ...]
</verb></tscreen>
可將 <tt/sgml2lyx/ 的選項都可用在 <tt/bg5sgml2lyx/ 上。一次可轉換數個檔案。副檔名 <tt/.sgml/ 可省略。
</descrip>
<label id="note">
<bf/注意/:
<itemize>
<item>大部份 SGMLtools 指令的選項都有長短兩種格式,如 <tt/--debug/, <tt/-d/ 是相同的。
如果該選項有附帶參數,在 <tt/bg5sgmltools/ 中你必須使用長的格式,例如用 <tt/--papersize=a4/ 而別用 <tt/-p a4/.
<item><!--ChiTeX 有時無法編譯輸出的 tex 檔。這或許是臭蟲...?-->
目前本中文套件僅支援使用 ChiTeX. 將來的版本可能會支援使用其它的中文 TeX.
</itemize>
<!---------- Next Section ---------->
<sect>版權
<p>
本文件所提到的商標分屬於個別的持有者。
SGMLtools 中文套件的版權屬於 <em/黃志偉/ <tt><cwhuang@phys.ntu.edu.tw></tt>。
你可以依照自由軟體基金會(Free Software Foundation)發佈的 GNU 一般授權許可(GNU General Public License)所規定的方法修改或是重新散佈本軟體。
要遵照此授權許可的第二版或是以後的版本隨你高興。
我撰寫並散佈本程式是希望對大家有所幫助,但不提供任何<bf/保證/!
詳情請見 GNU 一般授權許可的說明。 隨附本套件你應該收到一份授權許可的複本。
如果沒有的話,請寫信到自由軟體基金會索取。
<tscreen><verb>
Free Software Foundation,
Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</verb></tscreen>
</article>
bg5sgmltools-0.8/ChangeLog 100644 144 144 2746 6621547260 14625 0 ustar cwhuang users Version 0.8
1998/11/07
* Modify bg5sgml2txt to cooperate with lynx 2.8.1
1998/09/20
* Fix problems on different umask
* First find bg5sgmlfunctions in the current directory
1998/09/07
* Fix bug on find include file in the current directory
* Add --output=all option
* Determine TEXINPUTS by kpsexpand in bg5sgml2latex
1998/08/26
* Remove temp dir when interrupted
1998/08/20
* Fixed bug in search PATH of b2a
1998/08/19
* Make Makefile more complete
* Change spec file
1998/08/18
* Add bg5sgml2lyx
* bg5sgml2txt enhanced, add --noidx option
* Fixed possible conflicts of tmp files between multi instances
Version 0.7
1998/08/13
* Fixed bg5sgml2txt incorrectly delete $name.html
1998/08/12
* Change binaries install path in .spec to /usr/bin
* Add exit zero code if no errors
1998/08/11
* Fixed some typos in readme.sgml
* Change check file to .toc in bg5sgml2latex
1998/08/08
* Remove \protect macro added to tex sources
* Unset LANG, LC_CTYPE, LC_ALL
* Remark <nidx> </nidx> before parsing SGML file
1998/08/07
* Fixed VERSION reference in Makefile
* Fixed bg5sgml2html bug in --dosnames option
* Add bg5sgml2txt
* Remove tex log converting
* Add --font option to bg5sgml2latex
Version 0.6
1998/08/03
* Add \nonstopmode to the output tex file
* Convert tex log to Chinese by ctran
* Add \protect to some macros of the output tex file
* Add --stop option to bg5sgml2latex
Version 0.5
1998/08/01
* First release of version 0.5
bg5sgmltools-0.8/VERSION 100644 144 144 4 6574541337 14032 0 ustar cwhuang users 0.8
bg5sgmltools-0.8/bg5sgmltools.spec 100644 144 144 3547 6621547171 16351 0 ustar cwhuang users Summary: A wrapper for SGMLtools to process Chinese
Name: bg5sgmltools
%define bg5_version 0.8
Version: %{bg5_version}
Release: 8
Copyright: GPL
Group: Applications/Publishing
Packager: "Chih-Wei Huang" <cwhuang@phys.ntu.edu.tw>
Source: ftp://ftp.phys.ntu.edu.tw/pub/OS/Linux/src/bg5sgmltools-%{bg5_version}.tar.gz
URL: http://www.linux.org.tw/CLDP/
Buildroot: /var/tmp/bg5sgmltools-root
Requires: sgml-tools
%description
This is a wrapper for SGMLtools, let you convert Chinese SGML
file to HTML, plain text, LaTeX, and so on.
%changelog
* Mon Nov 7 1998 Chih-Wei Huang <cwhuang@phys.ntu.edu.tw>
- Modify bg5sgml2txt to cooperate with lynx 2.8.1
* Thu Aug 20 1998 Chih-Wei Huang <cwhuang@phys.ntu.edu.tw>
- Change build & install step to use Makefile
* Tue Aug 18 1998 Chih-Wei Huang <cwhuang@phys.ntu.edu.tw>
- Updated to version 0.8
- Only make b2a and plain text document
* Wed Aug 12 1998 Chih-Wei Huang <cwhuang@phys.ntu.edu.tw>
- Change binaries install path to /usr/bin
- Install files to Buildroot while making package
- Add sgml-tool to required dependence
* Sat Aug 8 1998 Chih-Wei Huang <cwhuang@phys.ntu.edu.tw>
- Remove \protect macro added to tex sources
- Unset LANG, LC_CTYPE, LC_ALL
- Remark <nidx> </nidx> before parsing SGML file
* Mon Aug 06 1998 Chih-Wei Huang <cwhuang@phys.ntu.edu.tw>
- Updated to version 0.7
- Add bg5sgml2txt
* Mon Aug 03 1998 Chih-Wei Huang <cwhuang@phys.ntu.edu.tw>
- Updated to version 0.6
* Sat Aug 01 1998 Chih-Wei Huang <cwhuang@phys.ntu.edu.tw>
- Updated to version 0.5
%prep
%setup
%build
make b2a readme.txt
%install
BIN=$RPM_BUILD_ROOT/usr/bin
mkdir -p $BIN
make install BIN=$BIN
%clean
rm -rf $RPM_BUILD_ROOT
%files
%doc COPYING TODO ChangeLog readme.sgml readme.txt
/usr/bin/b2a
/usr/bin/bg5sgmlfunctions
/usr/bin/bg5sgmlcheck
/usr/bin/bg5sgml2html
/usr/bin/bg5sgml2txt
/usr/bin/bg5sgml2latex
/usr/bin/bg5sgml2lyx
bg5sgmltools-0.8/TODO 100644 144 144 267 6574541337 13525 0 ustar cwhuang users 1998/08/06
* Add man pages, usage help
1998/08/05
* Add support of other formats
1998/08/03
* Add support of compiling with other Chinese TeX like CJK
* bg5sgml2txt (done)
bg5sgmltools-0.8/bg5sgml2txt 100755 144 144 3132 6621547345 15155 0 ustar cwhuang users #!/bin/bash
#
# by Chih-Wei Huang
# 6 August 1998
# Updated 7 November 1998
#
PATH=.:$PATH
FUNCTIONS="`type -path bg5sgmlfunctions`"
if [ -z $FUNCTIONS ]; then
echo "$0: include file not found!"
exit 1
fi
. $FUNCTIONS
unalias lynx
LYNX=`type -path lynx`
if [ -z $LYNX ]; then
echo "lynx not found!"
exit 1
fi
WIDTH=""
NOIDX=0
for opt in $options
do
case $opt in
--width*)
WIDTH=`echo $opt | cut -b2-`
;;
--noidx)
NOIDX=1
;;
# ignore these options
--filter | -f | \
--man | -m | \
--pass | -P | \
--dosnames | -h | \
--split | -s)
;;
*)
sgmloptions="$sgmloptions $opt"
;;
esac
done
for src in $filelist
do
checksrcfile $src
[ $? = 0 ] && continue
encodingbg5 $src
pushd . > /dev/null
cd $TMP
# Generate the index
if [ "$NOIDX" = "0" ]; then
sgml2html $sgmloptions $name.sgml
[ -e $name.html ] || exit 2
$B2A -d -f $name.html -o $name.idx.html
$LYNX $WIDTH -dump -nolist $name.idx.html | \
csplit -s --prefix=$name- - /______/+1 {*}
else
touch $name-03
fi
# Generate the main content
sgml2html --split=0 $sgmloptions $name.sgml > /dev/null
$B2A -d -f $name.html -o $name.txt.html
$LYNX $WIDTH -dump $name.txt.html | \
csplit -s --prefix=$name. --keep-files - /______/+1 {1}
popd > /dev/null
# Concatenate the result
cat $TMP/$name.00 $TMP/$name.01 $TMP/$name-03 $TMP/$name.02 > $name.txt
done
cleartmp
bg5sgmltools-0.8/bg5sgml2lyx 100755 144 144 1042 6601220037 15130 0 ustar cwhuang users #!/bin/bash
#
# by Chih-Wei Huang
# 17 August 1998
# Updated 20 September 1998
#
PATH=.:$PATH
FUNCTIONS="`type -path bg5sgmlfunctions`"
if [ -z $FUNCTIONS ]; then
echo "$0: include file not found!"
exit 1
fi
. $FUNCTIONS
for src in $filelist
do
checksrcfile $src
[ $? = 0 ] && continue
encodingbg5 $src
pushd . > /dev/null
cd $TMP
sgml2lyx $options $name.sgml
[ -e $name.lyx ] || exit 2
popd > /dev/null
$B2A -d -f $TMP/$name.lyx -o $name.lyx
done
cleartmp