#! /bin/sh # # sgml2info # Greg Hankins and Christian Schwarz, 10 September 1995 # # Based on the original 'mkinfo' scripts by Christian Schwarz. # # Don't make any changes here, it is all done by install! LINUXDOCBIN=/usr/bin LINUXDOCLIB=/usr/lib/linuxdoc-sgml AWK=gawk TABS="-8" # expand replaces tabs with 8 spaces CHAR="groff" # use ASCII (groff) character set STYLE= # Use standard Linuxdoc-SGML style DASHI=-ifmtinfo trap "CleanUp" 0 1 2 3 9 15 usage () { echo " Usage: sgml2info [-l] [-style ] [-t ] "; echo " -l use latin1 character set (default ASCII)"; echo " -style use info/mapping backend in addition to default"; echo " info/mapping"; echo " -t tabstops each th col (default 8)"; echo " SGML source file, .sgml extension is optional"; echo echo " Output will appear in .info" exit 1 } CleanUp() { rm -f /tmp/sgml2info$$tmp /tmp/sgml2info$$tmp1 /tmp/sgml2info$$tmp2 } # check argc if [ $# = 0 ] then usage fi # do they need help? case "$1" in "-h" | "--help" | "-help") usage exit 1 esac # getopt for i in $* do case $i in -c) CHECK="yes"; shift;; -style) style=$2;shift; shift;; -l) CHAR="latin1"; shift;; -t) TABS="-"$2; shift; shift;; --) shift; break;; esac done # SGML_PATH for sgmls - must be exported SGML_PATH=$LINUXDOCLIB/dtd/%N.dtd:$LINUXDOCLIB/dtd/%P.dtd:$LINUXDOCLIB/rep/info/%N export SGML_PATH if [ -f $LINUXDOCLIB/dtd/${style}.dcl ]; then SGMLDECL=$LINUXDOCLIB/dtd/${style}.dcl elif [ -f $LINUXDOCLIB/dtd/sgml.dcl ]; then SGMLDECL=$LINUXDOCLIB/dtd/sgml.dcl # else just use sgmls's defaults fi if [ "$style" != "" ]; then STYLE=$LINUXDOCLIB/rep/info/${style}mapping; fi # check to see if there is a source file FILE=$1 if [ -f $FILE.sgml ] then SGMLFILE=$FILE.sgml elif [ ! -f $FILE ] then echo "sgml2info: can't find $FILE or $FILE.sgml" >&2 exit 1 else SGMLFILE=$FILE fi INFOFILE=`basename $SGMLFILE .sgml`.info echo "Making $INFOFILE from $SGMLFILE." # format case $CHAR in latin1) sed 's/\@/\@\@/g' $SGMLDECL $SGMLFILE | sed -f \ $LINUXDOCLIB/latin1.sed | $LINUXDOCBIN/sgmls $DASHI \ > /tmp/sgml2info$$tmp;; *) sed 's/\@/\@\@/g' $SGMLDECL $SGMLFILE | $LINUXDOCBIN/sgmls \ $DASHI > /tmp/sgml2info$$tmp;; esac if [ $? = 1 ] then echo "SGML parsing error, no formatting done..." exit 1 fi # if there are no SGML parse errors, continue... cat /tmp/sgml2info$$tmp | $LINUXDOCBIN/sgmlsasp $STYLE \ $LINUXDOCLIB/rep/info/mapping | expand $TABS > /tmp/sgml2info$$tmp1 # Process AWK and makeinfo at a time. $AWK -v INFO=$INFOFILE -- ' function cut(s) { while ((substr(s,1,1)==" ")||(substr(s,1,1)=="\t")) s=substr(s,2,length(s)-1); while ((substr(s,length(s),1)==" ")||(substr(s,length(s),1)=="\t")) s=substr(s,1,length(s)-1); return s; } function rest(n) { save = $0; $0 = cut($0); for (i=0; i /tmp/sgml2info$$tmp2 makeinfo /tmp/sgml2info$$tmp2 -o $INFOFILE exit 0