[Refdb-cvs] CVS: refdb/scripts refdbnd.in,1.8,1.8.2.1 runbib.in,1.14,1.14.2.1
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2004-06-24 20:28:41
|
Update of /cvsroot/refdb/refdb/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7970/scripts Modified Files: Tag: Release_0_9_5_stable refdbnd.in runbib.in Log Message: added support for encoding Index: refdbnd.in =================================================================== RCS file: /cvsroot/refdb/refdb/scripts/refdbnd.in,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -U2 -r1.8 -r1.8.2.1 --- refdbnd.in 8 Feb 2004 00:36:39 -0000 1.8 +++ refdbnd.in 24 Jun 2004 20:28:33 -0000 1.8.2.1 @@ -3,5 +3,5 @@ # refdbnd: creates a new document and sets up a Makefile for use # with RefDB bibliographies -# Invocation: refdbnd basename doctype|filename pubtype database style +# Invocation: refdbnd basename doctype|filename pubtype database style encoding # or: refdbnd (interactive mode) @@ -29,5 +29,7 @@ defdatabase="refdbtest" defstyle="J.Biol.Chem." +defencoding="utf-8" xfile="" +encoding="" # Makefile-generated defaults @@ -54,12 +56,15 @@ doctype="db41x" pubtype=`grep "DTD DocBook XML V4.1.2//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'` + encoding=`grep "^<?xml version=\"1.0\"" $basename | sed 's/^.*encoding=\"\(.*\)\".*/\1/'` else if grep "^<!DOCTYPE.*DTD DocBook XML V4.2//EN" $basename; then doctype="db42x" pubtype=`grep "DTD DocBook XML V4.2//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'` + encoding=`grep "^<?xml version=\"1.0\"" $basename | sed 's/^.*encoding=\"\(.*\)\".*/\1/'` else if grep "^<!DOCTYPE.*TEI P4//DTD Main DTD Driver File//EN" $basename; then doctype="teix" pubtype=`grep "TEI P4//DTD Main DTD Driver File//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'` + encoding=`grep "^<?xml version=\"1.0\"" $basename | sed 's/^.*encoding=\"\(.*\)\".*/\1/'` fi fi @@ -72,7 +77,7 @@ } -# if we have five command line arguments, we'll use them. Otherwise +# if we have six command line arguments, we'll use them. Otherwise # ask interactively -if [ -z "$*" ] || [ "$#" -ne 5 ]; then +if [ -z "$*" ] || [ "$#" -ne 6 ]; then # get arguments interactively clear @@ -92,5 +97,7 @@ echo "[$defbasename]" read basename - + if [ -z "$basename" ]; then + basename=$defbasename + fi check_existing_doc @@ -128,4 +135,10 @@ read style echo "" + if [ -z $encoding ]; then + echo "Please enter the character encoding that your document should use" + echo "[$defencoding]" + read encoding + echo "" + fi # apply defaults to empty strings @@ -145,4 +158,7 @@ style=$defstyle fi + if [ -z "$encoding" ]; then + encoding=$defencoding + fi else @@ -154,4 +170,5 @@ database=$4 style=$5 + encoding=$6 fi @@ -162,4 +179,5 @@ echo "Database: $database" echo "Bibliography style: $style" +echo "Encoding: $encoding" echo "" @@ -210,9 +228,11 @@ # substitute values -sed "s%<doctypeswitch>%$doctypeswitch%" < $maketemplate | sed "s%<pubtype>%$pubtype%" | sed "s%<basename>%$basename%" | sed "s%<extension>%$extension%" | sed "s%<style>%$style%" | sed "s%<htmlstylesheet>%$htmlstylesheet%" | sed "s%<xhtmlstylesheet>%$xhtmlstylesheet%" | sed "s%<printstylesheet>%$printstylesheet%" | sed "s%<database>%$database%" | sed "s%all: pdf rtf html%$makeall%" | sed "s%dist: pdfdist rtfdist htmldist%$dist%" | sed "s%<transformscript>%$transformscript%" > Makefile +sed "s%<doctypeswitch>%$doctypeswitch%" < $maketemplate | sed "s%<pubtype>%$pubtype%" | sed "s%<basename>%$basename%" | sed "s%<extension>%$extension%" | sed "s%<style>%$style%" | sed "s%<htmlstylesheet>%$htmlstylesheet%" | sed "s%<xhtmlstylesheet>%$xhtmlstylesheet%" | sed "s%<printstylesheet>%$printstylesheet%" | sed "s%<database>%$database%" | sed "s%all: pdf rtf html%$makeall%" | sed "s%dist: pdfdist rtfdist htmldist%$dist%" | sed "s%<transformscript>%$transformscript%" | sed "s%<encoding>%$encoding%" > Makefile echo "Makefile created." echo "" +encodingstring=" encoding=\"$encoding\"" + # create an empty document if [ -z $xfile ]; then @@ -221,7 +241,7 @@ db40 ) echo -e "<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook V4.0//EN\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>" > $basename.short.$extension;; db41 ) echo -e "<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook V4.1//EN\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>" > $basename.short.$extension;; - db41x) echo -e "<?xml version=\"1.0\"?>\n<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>" > $basename.short.$extension;; - db42x) echo -e "<?xml version=\"1.0\"?>\n<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>" > $basename.short.$extension;; - teix ) echo -e "<?xml version=\"1.0\"?>\n<!DOCTYPE TEI.2 PUBLIC \"-//TEI P4//DTD Main DTD Driver File//EN\" \"http://www.tei-c.org/P4X/DTD/tei2.dtd\" [\n<!ENTITY % TEI.general 'INCLUDE'>\n<!ENTITY % TEI.names.dates 'INCLUDE'>\n<!ENTITY % TEI.linking 'INCLUDE'>\n<!ENTITY % TEI.XML 'INCLUDE'>\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>" > $basename.short.$extension;; + db41x) echo -e "<?xml version=\"1.0\"$encodingstring?>\n<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>" > $basename.short.$extension;; + db42x) echo -e "<?xml version=\"1.0\"$encodingstring?>\n<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>" > $basename.short.$extension;; + teix ) echo -e "<?xml version=\"1.0\"$encodingstring?>\n<!DOCTYPE TEI.2 PUBLIC \"-//TEI P4//DTD Main DTD Driver File//EN\" \"http://www.tei-c.org/P4X/DTD/tei2.dtd\" [\n<!ENTITY % TEI.general 'INCLUDE'>\n<!ENTITY % TEI.names.dates 'INCLUDE'>\n<!ENTITY % TEI.linking 'INCLUDE'>\n<!ENTITY % TEI.XML 'INCLUDE'>\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>" > $basename.short.$extension;; esac echo "Document $basename.short.$extension created." Index: runbib.in =================================================================== RCS file: /cvsroot/refdb/refdb/scripts/runbib.in,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -U2 -r1.14 -r1.14.2.1 --- runbib.in 13 Nov 2003 00:24:28 -0000 1.14 +++ runbib.in 24 Jun 2004 20:28:33 -0000 1.14.2.1 @@ -40,4 +40,5 @@ # some initialization databaseopt="" +encodingopt="" outtype=db31 username="" @@ -88,10 +89,12 @@ # read the command line options -while getopts ":d:hi:IN:p:S:t:u:w:" opt; do +while getopts ":d:E:hi:IN:p:S:t:u:w:" opt; do case $opt in d ) databaseopt="-d "$OPTARG;; + E ) encodingopt="-E "$OPTARG;; h ) echo "creates refdb bibliography from a SGML, XML, or Latex document" - echo 'usage: runbib [-d database] [-h] [-i includevar] [-I] [-N number] [-S style] [-t type] [-u username] [-w password] file1 [file2...]' + echo 'usage: runbib [-d database] [-E encoding] [-h] [-i includevar] [-I] [-N number] [-S style] [-t type] [-u username] [-w password] file1 [file2...]' echo "Options: -d select default database" + echo " -E set output character encoding" echo " -h print this help and exit" echo " -i specify variable to include marked sections" @@ -171,5 +174,5 @@ # the bibliography file and the style specification file - $myrefdbib $databaseopt $useropt $passwdopt $numopt $portarg -S $style -D "." -t db31 $basename.id.xml > $basename.bib.sgml + $myrefdbib $databaseopt $encodingopt $useropt $passwdopt $numopt $portarg -S $style -D "." -t db31 $basename.id.xml > $basename.bib.sgml if [ $? -ne 0 ]; then # move the output to error files so we can use the script @@ -192,5 +195,5 @@ fi - $myrefdbib $databaseopt $useropt $passwdopt $numopt $portarg -S $style -D "." -t db31x $basename.id.xml > $basename.bib.xml + $myrefdbib $databaseopt $encodingopt $useropt $passwdopt $numopt $portarg -S $style -D "." -t db31x $basename.id.xml > $basename.bib.xml if [ $? -ne 0 ]; then # move the output to error files so we can use the script @@ -217,5 +220,5 @@ fi - $myrefdbib $databaseopt $useropt $passwdopt $numopt $portarg -S $style -D "." -t teix $basename.id.xml > $basename.bib.xml + $myrefdbib $databaseopt $encodingopt $useropt $passwdopt $numopt $portarg -S $style -D "." -t teix $basename.id.xml > $basename.bib.xml if [ $? -ne 0 ]; then # move the output to error files so we can use the script @@ -248,5 +251,5 @@ fi - $mysort $filename | $myuniq | $myrefdbib $databaseopt $useropt $passwdopt -S $style -t bibtex > $basename.bib + $mysort $filename | $myuniq | $myrefdbib $databaseopt $encodingopt $useropt $passwdopt -S $style -t bibtex > $basename.bib if [ $? -ne 0 ]; then exit 1 |