Annotation of researchv10no/cmd/docsubmit/odocsubmit, revision 1.1.1.1

1.1       root        1: #      @(#)fulltext:docsubmit  1.18
                      2: 
                      3: # THis routine was originally written by Lorinda Cherry - it gathers up
                      4: # all the files connected with a documents, and transmits them via
                      5: # uucp to   mhuxd!~/full.text/
                      6: #
                      7: # It bundles all the files involved together into one cpio file
                      8: # called <1st 5 chars of machine name><process id>.cp
                      9: 
                     10: # Finding a good awk is a pain - set it here if you want
                     11: AWK=""
                     12: if test -z "${AWK}"
                     13: then
                     14:     if ans=`sh -c 'logdir exptools' 2>&1` ; then
                     15:        :
                     16:     else
                     17:        ans=`grep '^exptools:' /etc/passwd | sed "s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*/\1/"`
                     18:        fi
                     19:     if test -r ${ans}/bin/nawk
                     20:     then
                     21:        AWK=${ans}/bin/nawk
                     22:        fi
                     23:     fi
                     24: if test -z "${AWK}"
                     25: then
                     26:     if test -r /usr/local/bin/awk
                     27:     then
                     28:        AWK=/usr/local/bin/awk
                     29:        fi
                     30:     fi
                     31: if test -z "${AWK}"
                     32: then
                     33:     AWK=awk
                     34:     fi
                     35: 
                     36: # Get machine nodename - swiped from rn build routine Configure
                     37: if ans=`sh -c hostname 2>&1` ; then
                     38:     MACH=$ans
                     39: elif ans=`sh -c 'uuname -l' 2>&1` ; then
                     40:        MACH=$ans
                     41: elif ans=`sh -c 'uname -n' 2>&1` ; then
                     42:        MACH=$ans
                     43: else
                     44:        MACH=failedget
                     45:        fi
                     46: # Get the users LOGNAME
                     47: if ans=`sh -c logname 2>&1` ; then
                     48:     LOGNAME=$ans
                     49: else
                     50:     LOGNAME=`echo $HOME|sed 's/.*\///'`
                     51:     fi
                     52: 
                     53: T=/tmp
                     54: AWKTEMP=/tmp/Doc.Awk.$$
                     55: OUTP="junk"
                     56: COVER="junk"
                     57: DOCNUM="junk"
                     58: REF=""
                     59: # cut the machine name down to a max of 5 characters
                     60: DIR=`echo ${MACH} | sed 's/\(.....\).*/\1/'`$$
                     61: NAME=$DIR
                     62: DIR=$T/$DIR
                     63: trap 'rm -f ${AWKTEMP} $DIR/* $T/$NAME.cp ; rmdir $DIR 2>>/dev/null; trap 0;exit' 0 1 2 15
                     64: if test $# -eq 0
                     65: then
                     66:        echo "docsubmit -C -c file.cover -N number -r ref_file -t  file(s)"
                     67:        echo "   -C if document complete without coversheet, else -c file.cover"
                     68:        echo "   -N number   if document number not included in the files"
                     69:        echo "   -r to include a refer file"
                     70:        echo "   -t if source is Knuths TeX instead of troff/nroff\n"
                     71:        echo "  Two examples, first with cover sheet, second without:"
                     72:        echo "    docsubmit -c mydoc.cover mydoc.text mydoc.append"
                     73:        echo "    docsubmit -C -N 79111-880324-01 mydoc.text"
                     74:        exit 0
                     75: fi
                     76: for i in $*
                     77: do case $i in
                     78:     -r) shift; REF=$1; shift; continue;;
                     79:     -c) shift; COVER=$1; shift; continue;;
                     80:     -C) shift; COVER=$$; continue;;
                     81:     -t) shift; TEX="yes"; ARG=$1; shift; continue;;
                     82:     -N) shift; DOCNUM=$1; shift; continue;;
                     83:     -*) echo docsubmit unknown flag $i; exit 1;;
                     84:     esac
                     85:     done
                     86: ARGS=$*
                     87: if test "$COVER" = "junk" 
                     88: then
                     89:     echo "You must include the coversheet file for the paper to be submitted"
                     90:     echo "If the coversheet is in the files (or the files are the complete document),"
                     91:     echo "       indicate this by using the -C flag"
                     92:     echo "Use the flag  -N number   if document number not included in the files"
                     93:     echo "     ===> Full text of document not sent <==="
                     94:     exit 1
                     95:     fi
                     96: 
                     97: # check the entered document number
                     98: if test ${DOCNUM} != "junk"
                     99: then
                    100:     x=`expr "${DOCNUM}" : '^[a-zA-Z0-9]*-[89][0-9]*-[0-9][0-9]'`
                    101:     if test $x -lt 2
                    102:     then
                    103:        echo "\nDocument numbers must be of form  OrgNum-Date-seq"
                    104:        echo "   Where Date is usually YYMMDD (e.g. 881224) [always starts with a year]"
                    105:        echo "   and the sequence number is always 2 digits (e.g. 03)"
                    106:        echo "     ===> Full text of document not sent <==="
                    107:        exit 1
                    108:        fi
                    109:     fi
                    110: OUTP=$DIR/$NAME
                    111: mkdir $DIR
                    112: if test $TEX
                    113: then
                    114:        case $OUTP in
                    115:        *.*) echo "the name for a TeX paper cannot contain . tex gets confused"
                    116:                echo "  use _ or - instead"
                    117:                exit 1
                    118:        esac
                    119:        BBL=$OUTP.bbl
                    120:        OUTP=$OUTP.tex
                    121:        echo "%...\\\"" `date` >$OUTP
                    122:        echo "%...\\\"" EmailAddress ${MACH}"!"${LOGNAME} >>$OUTP
                    123:        if test "${DOCNUM}" != "junk"
                    124:        then
                    125:            echo "%...\\\" DocNum ${DOCNUM}" >>$OUTP
                    126:            fi
                    127:        echo "%...\\\"" `pwd` >>$OUTP
                    128:        # THis was doinput.awk - put it inline for exptools ease
                    129:        # NOTE - ends with line   END doinput.awk
                    130: cat >${AWKTEMP} <<!
                    131: BEGIN  {
                    132:        if(texinp != "")
                    133:                ninputs = split(texinp, texinputs, ":")
                    134:        else {
                    135:                ninputs = 1
                    136:                texinputs[1] = "."
                    137:        }
                    138:        idef=0
                    139:        }
                    140: /\\\\newcommand/       {
                    141:        ckdef(0, \$0, 1)
                    142:        next
                    143:        }
                    144: /\\\\def[^a-z]/        {
                    145:        ckdef(0, \$0, 0)
                    146:        next
                    147:        }
                    148: /\\\\(input|include)[{ ]/      {
                    149:        getfile()
                    150:        next
                    151:        }
                    152: /\\\\bibliography[{ ]/ {
                    153:        n = substr(\$0, index(\$0,"{")+1, index(\$0,"}")-index(\$0,"{")-1)
                    154:        if(n ~ ","){
                    155:                num=split(n, b, ",")
                    156:                for(i=1;i<=num;i++)
                    157:                        system("cp " b[i] ".bbl " dir)
                    158:                        close("cp " b[i] ".bbl " dir)
                    159:        }
                    160:        else{
                    161:                system("cp " n ".bbl " dir)
                    162:                close("cp " n ".bbl " dir)
                    163:        }
                    164:        }
                    165: /^\\\\includepicture/  {
                    166:        n=index(\$0,"{")+1
                    167:        fname=substr(\$0,n,index(\$0,"}")-n)
                    168:        system ("cp " fname ".t " dir )
                    169:        close ("cp " fname ".t " dir )
                    170:        system ("cp " fname ".tex " dir )
                    171:        close ("cp " fname ".tex " dir )
                    172:        }
                    173: /\\\\special/  {
                    174:        getpost(\$0)
                    175:        next
                    176:        }
                    177: /\\\\/ {
                    178:        isdef(\$0)
                    179:        next
                    180:        }
                    181: /.*/   {
                    182:        print \$0
                    183:        }
                    184: function getfile(      saveline, n, bname, tname, j, name, flag){
                    185:        saveline = \$0
                    186:        if(\$0 ~ /\\\\input/)n = index(\$0,"\\\\input")+7
                    187:        else n=index(\$0,"\\\\include")+9
                    188:        bname = substr(\$0,n)
                    189:        gsub(/^[ {]*/,"",bname)
                    190:        gsub(/[ }].*/,"",bname)
                    191:        gsub(/[ }]\$/,"",bname)
                    192:        tname = bname ".tex"
                    193:        for(j=1; j<= ninputs; j++){
                    194:                name = texinputs[j] "/" tname
                    195:                if((getline <name) >=0)break
                    196:                name = texinputs[j] "/" bname
                    197:                if((getline <name) >=0)break
                    198:                name = ""
                    199:        }
                    200:        if(name == ""){
                    201:                print "cannot open file " bname " or " tname | "cat 1>&2"
                    202:                return
                    203:        }
                    204:        if(name ~ /\\/usr\\/lib\\/tex\\/macros/){
                    205:                print saveline
                    206:                return
                    207:        }
                    208:        flag=0
                    209:        while(1){
                    210:                if(flag)if((getline <name)<1)break
                    211:                flag=1
                    212:                if(\$0 ~ /\\\\newcommand/){
                    213:                        ckdef(name, \$0, 1)
                    214:                        continue
                    215:                }
                    216:                if(\$0 ~ /\\\\def[^a-z]/){
                    217:                        ckdef(name, \$0, 0)
                    218:                        continue
                    219:                }
                    220:                if(\$0 ~ /\\\\(input|include)[{ ]/){
                    221:                        getfile()
                    222:                }
                    223:                else if(\$0 ~ /\\\\special/)getpost(\$0)
                    224:                else if(\$0 ~ /\\\\/){
                    225:                        isdef(\$0)
                    226:                }
                    227:                else print \$0
                    228:        }
                    229:        close(name)
                    230: }
                    231: function getpost(str){
                    232:        if(str ~ /psfile/){
                    233:                n=substr(str,index(str,"psfile"))
                    234:                if(n ~ / /)sub(/ .*/, "", n)
                    235:                if(n ~ /\\=/)sub(/.*=/, "", n)
                    236:                if(n ~ /,$/)sub(/,/, "", n)
                    237:                if(n ~ /,.*/)sub(/,.*/, "", n)
                    238:                system( "cp " n " " dir)
                    239:                close( "cp " n " " dir)
                    240:                if(n ~ /\\//){
                    241:                        num = split(n, xa, /\\//)
                    242:                        sub(n, xa[num], str)
                    243:                }
                    244:                print str
                    245:        }
                    246:        else print str
                    247:        }
                    248: function ckdef(file, first,new){
                    249:        print first
                    250:        if(new){
                    251:                n=index(first,"{")+1
                    252:                name=substr(first,n,index(first,"}")-n)
                    253:                name = "\\\\" name
                    254:                n=index(first,"[")+1
                    255:                if(n > 1)
                    256:                        args=substr(first,n,index(first,"]")-n)+0
                    257:                else args=0
                    258:        }
                    259:        else {
                    260:                sub(/\\\\def\\\\/,"")
                    261:                savs = first
                    262:                if(first ~ /^[A-Za-z]/){
                    263:                        abc=first
                    264:                        sub(/[^A-Za-z]/,"{",abc)
                    265:                        name = "\\\\\\\\" substr(first,0,index(abc,"{")-1)
                    266:                }
                    267:                else name = "\\\\\\\\" substr(first,0,1)
                    268:                if(savs ~ /#/){
                    269:                        if(savs ~ "{")gsub(/{.*/, "",savs)
                    270:                        n=split(savs, z, "#")
                    271:                        args = n-1
                    272:                }
                    273:                else args=0
                    274:                xdef=1
                    275:        }
                    276:        if(first ~ "%"){
                    277:                n=split(first, z, "%")
                    278:                save = z[1]
                    279:                left=gsub(/{/,":",z[1])
                    280:                right=gsub(/}/,";",z[1])
                    281:        }
                    282:        else{
                    283:                save = \$0
                    284:                left=gsub(/{/,":")
                    285:                right=gsub(/}/,";")
                    286:        }
                    287:        psav = isav = 0 
                    288:        if(\$0 ~ /special/){
                    289:                getpattern(file, save)
                    290:                psav++
                    291:        }
                    292:        while(left != right || (left == 1 && !xdef)){
                    293:                if(file== 0){
                    294:                        if((getline) <1){
                    295:                                print "ran out of file in newcommand"|"cat 1>&2"
                    296:                                exit
                    297:                        }
                    298:                }
                    299:                else if((getline<file) < 1){
                    300:                                print "ran out of file in newcommand"|"cat 1>&2"
                    301:                                exit
                    302:                        }
                    303:                save=\$0
                    304:                left +=gsub(/{/,":")
                    305:                right+=gsub(/}/,";")
                    306:                if(\$0 ~ /special/){
                    307:                        getpattern(file, save)
                    308:                        psav++
                    309:                }
                    310:                if(\$0 ~ /(input|include)/){
                    311:                        getpattern(file, save)
                    312:                        isav++
                    313:                }
                    314:                else print save
                    315:        }
                    316:        if(psav||isav){
                    317:                argct[idef] = args
                    318:                if(psave)post[idef] = psav
                    319:                else inp[idef]=isav
                    320:                def[idef++] = name
                    321:        }
                    322: 
                    323: }
                    324: function getpattern(file, command){
                    325:        save = command
                    326:        if(command ~ /psfile/){
                    327:                n=substr(command, index(command, "psfile"))
                    328:                sub(/.*=[ \\t]*/,"",n)
                    329:                sub(/}*\$/,"",n)
                    330:                sub(/ .*/,"",n)
                    331:                ckargs(n,save)
                    332:        }
                    333:        if(command ~ /(input|include)/){
                    334:                if(command ~ /\\\\input/)n = index(command,"\\\\input")+7
                    335:                else n=index(command,"\\\\include")+9
                    336:                bname = substr(command,n)
                    337:                gsub(/^[ ]*/,"",bname)
                    338:                gsub(/[ }].*/,"",bname)
                    339:                gsub(/[ }]\$/,"",bname)
                    340:                ckargs(bname,save)
                    341:        }
                    342: }
                    343: function ckargs(pat,command){
                    344:        if(pat ~ /#/)
                    345:                num = substr(pat,index(pat,"#")+1,1)
                    346:        else num = 0
                    347:        pattern[idef,num] = pat
                    348:        if(command ~ /\\//){
                    349:                num = split(pat, xa, /\\//)
                    350:                sub(n, xa[num], command)
                    351:        }
                    352:        print command
                    353: }
                    354: function cpfile(name, pat){
                    355:        if(name ~ "}")
                    356:                sub(/}.*/,"", name)
                    357:        sub(/#./,name,pat)
                    358:        system("cp " pat " " dir)
                    359:        close("cp " pat " " dir)
                    360:        if(name ~ /\\//){
                    361:                num = split(name, xa, /\\//)
                    362:                sub(name, xa[num],string)
                    363:        }
                    364: }
                    365: function isdef(string, i, gotarg, a, x, j, l, r){
                    366:        if(idef){
                    367:                for(i=0;i<idef;i++){
                    368:                        if(string !~ def[i])continue
                    369:                        if((i,0) in pattern){
                    370:                                system("cp " pattern[idef,0] " " dir)
                    371:                                close("cp " pattern[idef,0] " " dir)
                    372:                                break
                    373:                        }
                    374:                        gotarg=0
                    375:                        a=string
                    376:                        while(gotarg<argct[i]){
                    377:                                x=0
                    378:                                if(j=index(a,"{")){
                    379:                                        x++
                    380:                                        a = substr(a,j+1)
                    381:                                        if((i,gotarg+1) in pattern)
                    382:                                                cpfile(a, pattern[i,gotarg+1])
                    383:                                        while(x){
                    384:                                                l=index(a,"{")
                    385:                                                r=index(a,"}")
                    386:                                                if(!l && !r){
                    387:                                                        getline
                    388:                                                        string = string "\\n" \$0
                    389:                                                        a=\$0
                    390:                                                        continue
                    391:                                                }
                    392:                                                if(l<r && l>0){
                    393:                                                        x++
                    394:                                                        a=substr(a,l+1)
                    395:                                                }
                    396:                                                else{
                    397:                                                        a=substr(a,r+1)
                    398:                                                        x--
                    399:                                                }
                    400:                                        }
                    401:                                        gotarg++
                    402:                                }
                    403:                                else {
                    404:                                        getline
                    405:                                        string = string "\\n" \$0
                    406:                                        a = \$0
                    407:                                }
                    408:                        }
                    409:                        break
                    410:                }
                    411:        }
                    412:        print string
                    413: }
                    414: !
                    415:        ${AWK} -f ${AWKTEMP} dir=$DIR texinp=$TEXINPUTS $ARG.tex >>$OUTP
                    416:        # NOTE - END of doinput.awk
                    417:        # Check that it ended okay
                    418:        if test $? -ne 0
                    419:        then
                    420:            echo "Sorry - couldnt collect together the full text of your document."
                    421:            echo "No full text was sent! Contact the docsubmit provider with questions."
                    422:            exit 1 
                    423:            fi
                    424: 
                    425:        if test -s $ARG.bbl
                    426:        then
                    427:                cp $ARG.bbl $BBL
                    428:        else if test \( -s $ARG.bib \) -a \( ! -s $DIR/$ARG.bib \)
                    429:        then
                    430:                cp $ARG.bib $BIB
                    431:        fi
                    432:        fi
                    433: else
                    434:        echo "...\\\"" `date` >$OUTP
                    435:        echo "...\\\"" EmailAddress ${MACH}"!"${LOGNAME} >>$OUTP
                    436:        if test "${DOCNUM}" != "junk"
                    437:        then
                    438:            echo "...\\\" DocNum ${DOCNUM}" >>$OUTP
                    439:            fi
                    440:        echo "...\\\"" `pwd` >>$OUTP
                    441:        if test $REF
                    442:        then
                    443:        cat >>$OUTP <<x
                    444: ...\"refer first
                    445: x
                    446:        fi
                    447:        if test $COVER = $$
                    448:        then
                    449:                PARMS="$ARGS"
                    450:        else
                    451:                PARMS="$COVER $ARGS"
                    452:        fi
                    453:        # THis use to invoke subso.awk
                    454:        # Note ends with ENOD of subso.awk
                    455: cat >${AWKTEMP} <<!
                    456: BEGIN  {seen[""] = 0
                    457:        picoutput = "This paper appears to have pic output included.\\n"
                    458:        picoutput = picoutput "We do not accept papers with pic output.\\n"
                    459:        picoutput = picoutput "Please resubmit it with the pic input instead.\\n"
                    460:        picoutput = picoutput "If the pic input is in separate files, you can include it by saying:\\n"
                    461:        picoutput = picoutput " .PS <picfile"
                    462:        tbloutput = "This paper appears to have tbl output included.\\n"
                    463:        tbloutput = tbloutput "We do not accept papers with tbl output.\\n"
                    464:        tbloutput = tbloutput "Please resubmit it with the tbl input instead.\\n"
                    465:        tpedoutput = "This paper appears to have tped output included.\\n"
                    466:        tpedoutput = tpedoutput "We do not accept papers with tped output.\\n"
                    467:        tpedoutput = tpedoutput "Please resubmit it with the tped input instead.\\n"
                    468:        intbl = ineq = tped = 0
                    469:        }
                    470: #                      macro include picture macro, guess that it's arg2
                    471: /^\\./ {
                    472:        if((\$1 in incmacro) && (NF > 1)){
                    473:                havecopy(\$1, \$2, 2)
                    474:                next
                    475:        }
                    476:        }
                    477: #                      .so - get input file
                    478: #                      or .de that includes .so - try to get file as arg2
                    479: /^\\.so/ || \$1 in hasso       {
                    480:        getfile(\$2)
                    481:        next
                    482:        }
                    483: #                      bwk macro
                    484: /^\\.ge/       {
                    485:        system( "trget " NF " " \$2 " " \$3 " " \$4 " " \$5 )
                    486:        close( "trget " NF " " \$2 " " \$3 " " \$4 " " \$5 )
                    487:        next
                    488:        }
                    489: #                      bwk macro
                    490: /^\\.ru/       {
                    491:        system( \$2 " " \$3 " " \$4 " " \$5 " " \$6 " " \$7 " " \$8 " " \$9 )
                    492:        close( \$2 " " \$3 " " \$4 " " \$5 " " \$6 " " \$7 " " \$8 " " \$9 )
                    493:        next
                    494:        }
                    495: #                      inline .sy - execute
                    496: /^\\.sy/       {
                    497:        system( \$2 " " \$3 " " \$4 " " \$5 " " \$6 " " \$7 " " \$8 " " \$9 )
                    498:        close( \$2 " " \$3 " " \$4 " " \$5 " " \$6 " " \$7 " " \$8 " " \$9 )
                    499:        next
                    500:        }
                    501: /^\\.bm/       {
                    502:        next
                    503:        }
                    504: #                      switch in and out of eqn
                    505: /^\\.EQ/       { ineq = 1 }
                    506: /^\\.EN/       { ineq = 0 }
                    507: #                      switch in and out of tbl
                    508: /^\\.TS/       { intbl = 1 }
                    509: /^\\.TE/       { intbl = 0 }
                    510: #                      all tbl output has this - unlikely otherwise - reject
                    511: /^\\.de 35/    {
                    512:        if(intbl){
                    513:                print tbloutput|"cat 1>&2"
                    514:                exit 1
                    515:        }
                    516:        }
                    517: #                      save eqn delimiters - # bad for tbl, pic - warn
                    518: /^[ ]*delim[ ]*/       {
                    519:        if(ineq){
                    520:                if(\$2 ~ /#/)
                    521:                        print "eqn delimiters in " \$0 " will break tbl, pic etc"|"cat 1>&2"
                    522:                delim = \$0
                    523:        }
                    524:        }
                    525: #                      macro definition - check for embedded picture macros
                    526: #                      bitmaps, or .so
                    527: /^\\.de/       {
                    528:        if(\$0 ~ /IS/)
                    529:                print ".IS is defined in " file " check it for ideal"|"cat 1>&2"
                    530:        print \$0
                    531:        xname = \$2
                    532:        while((getline) > 0){
                    533:                if(\$0 ~ /^\\.\\./)break
                    534:                if(\$0 ~ /^\\.BM/)incmacro["." xname]=1
                    535:                if(\$0 ~ /^\\.BP/)incmacro["." xname]=1
                    536:                if(\$0 ~ /^\\.PI/)incmacro["." xname]=1
                    537:                if(\$0 ~ /^\\.so/){
                    538:                        hasso["." xname] = 1
                    539:                        print "The .so embedded in macro " xname " will cause files not to be shipped " | "cat 1>&2"
                    540:                        defso = 1
                    541:                }
                    542:                print \$0
                    543:        }
                    544:        }
                    545: #                      .PS <file
                    546: #                      check if file contains .PS
                    547: #                      replace .PS <file with file (and .PS in needed)
                    548: #                      copy other files if copy thru included
                    549: /^\\.PS[ \\t]*</       {
                    550:        gsub(/ /,"")
                    551:        a=substr(\$0,index(\$0,"<")+1)
                    552:        if((getline<a) >0){
                    553:                if(\$0 ~ /^\\./){
                    554:                        print \$0
                    555:                        pflag=1
                    556:                        if(\$0 !~ /^\\.PS/){
                    557:                                while(getline<a > 0){
                    558:                                        if(\$0 !~ /^\\./)break
                    559:                                        print \$0
                    560:                                        if(\$0 ~ /^\\.PS/)pflag=0
                    561:                                }
                    562:                                if(pflag)print ".PS"
                    563:                        }
                    564:                }
                    565:                else print ".PS"
                    566:                flag=0
                    567:                pflag = 1
                    568:                while(1){
                    569:                        if(flag)if((getline<a)<=0)break
                    570:                        flag=1
                    571:                        if(\$0 ~ /^\\.P[EF]/)pflag=0
                    572:                        if(\$0 ~ /(copy|include)/){
                    573:                                for(i=1;i<NF;i++)
                    574:                                        if(\$i ~ /(copy|include)/)break
                    575:                                i++
                    576:                                if ((\$i !~ "thru") && (\$i !~ "through")) {
                    577:                                        havecopy(\$1, \$i, i);
                    578:                                }
                    579:                                else print \$0
                    580:                        }
                    581:                        else print \$0
                    582:                }
                    583:                if(pflag)print ".PE"
                    584:                close(a)
                    585:        }
                    586:        else {
                    587:                print "couldn't open pic file:" a|"cat 1>&2"
                    588:                print "from line: " \$0|"cat 1>&2"
                    589:                exit 1
                    590:        }
                    591:        next
                    592:        }
                    593: #                      tped .GS may name file to include
                    594: #                      if so, copy file; replace full path with file name
                    595: #                      else toggle tped flag
                    596: /^\\.GS/       {
                    597:        if(NF > 1){
                    598:                for(t=2; t<=NF;t++){
                    599:                        if(\$t !~ "-" && \$t !~ "="){
                    600:                                system( "cp " \$t " " dir )
                    601:                                close( "cp " \$t " " dir )
                    602:                                if(\$0 ~ "/"){
                    603:                                        nstat=split(\$0,stat,"/")
                    604:                                        cmd = ""
                    605:                                        for(xx=1;xx<t;xx++)
                    606:                                                cmd= cmd \$xx " "
                    607:                                        print cmd stat[nstat]
                    608:                                }
                    609:                                else print \$0
                    610:                                next
                    611:                        }
                    612:                }
                    613:        }
                    614:        intped=1
                    615:        }
                    616: /^\\.GE/       {
                    617:        intped=0
                    618:        }
                    619: #                      .sp -1 clue of included tped output
                    620: /^\\.sp -1/    {
                    621:        if(intped){
                    622:                print tpedout|"cat 1>&2"
                    623:                exit 1
                    624:        }
                    625:        }
                    626: #                      grap/pic may include file
                    627: /^\\.(G1|PS)/  {
                    628:        print \$0
                    629:        while(getline > 0){
                    630:                if(\$0 ~ /(copy|include)/){
                    631:                        for(i=1;i<NF;i++)
                    632:                                if(\$i ~ /(copy|include)/)break
                    633:                        i++
                    634:                        if ((\$i !~ "thru") && (\$i !~ "through")) {
                    635:                                havecopy(\$1, \$i, i);
                    636:                        }
                    637:                        else print \$0
                    638:                }
                    639:                else if(\$0 ~ /^\\.(G2|PE)/){
                    640:                        print \$0
                    641:                        break
                    642:                }
                    643:                else if(\$0 ~ /^\\.sp -1/){     #sign in pic output included
                    644:                                print picoutput|"cat 1>&2"
                    645:                                exit 1
                    646:                }
                    647:                else print \$0
                    648:        }
                    649:        next
                    650:        }
                    651: #                      ideal - may include file
                    652: /^\\.IS/       {
                    653:        print \$0
                    654:        while(getline){
                    655:                if(\$0 ~ /^\\.I[EF]/){
                    656:                        print \$0
                    657:                        next
                    658:                }
                    659:                else if(\$0 ~ /^[\\.]+include/)
                    660:                        doinclude(\$1, \$2, 0)
                    661:                else print \$0
                    662:        }
                    663:        }
                    664: #                      postscript pictures - get file
                    665: /^\\.(BM|BP|PI)/       {
                    666:        if(NF > 1)havecopy(\$1,\$2,2)
                    667:        else print \$0
                    668:        next
                    669:        }
                    670: #                      macro called that includes .so probably not included
                    671: /^\\./ {
                    672:        if(\$1 in hasso)
                    673:                print \$2 | "cat 1>&2"
                    674:        }
                    675: /.*/   {
                    676:        print \$0
                    677:        }
                    678: function havecopy(cmd, file, i){
                    679:        if(file ~ /"/){
                    680:                quotes=1
                    681:                n = split(file, name, "\\"")
                    682:                if(n>1)rname = name[2]
                    683:        }
                    684:        else {
                    685:                rname = file
                    686:                quotes=0
                    687:        }
                    688:        system( "cp " rname " " dir )
                    689:        close( "cp " rname " " dir )
                    690:        if(rname ~ "/"){
                    691:                n = split(rname,nn, "/")
                    692:                NAME=nn[n]
                    693:        }
                    694:        else NAME=rname
                    695:        if(i > 2)for(j=2;j<i;j++)cmd = cmd " " \$j
                    696:        if(quotes)cmd = cmd " \\"" NAME "\\""
                    697:        else cmd = cmd " " NAME
                    698:        if(NF >= i+1)
                    699:                for(j=i+1; j<=NF; j++)cmd = cmd " " \$j
                    700:        print cmd
                    701: }
                    702: function getfile(file, File, eflag,first,indef,xname,fintbl,finpic){
                    703:        if(file ~ /\\/usr\\/lib\\//|| file ~ /\\/exptools\\//){
                    704:                print \$0
                    705:                return
                    706:        }
                    707:        if((getline <file) > 0){
                    708:                if(\$0 ~ /^\\.lf/){
                    709:                        File=\$NF
                    710:                        saveline=\$0
                    711:                        if((getline <File)<=0){
                    712:                        print "This paper contains preprocessor output evidenced by  " saveline| "cat 1>&2"
                    713:                        print "and I can't find the source file " File|"cat 1>&2"
                    714:                        while((getline < file) >0 && \$0 ~ /^\\.lf/)
                    715:                                print \$0| "cat 1>&2"
                    716:                        print "paper not submitted" | "cat 1>&2"
                    717:                        exit 1
                    718:                        }
                    719:                }
                    720:                else File = file
                    721:        }
                    722:        else {
                    723:                print "cannot open file " file | "cat 1>&2"
                    724:                return
                    725:        }
                    726:        if(File in seen){
                    727:                close(File)
                    728:                return
                    729:        }
                    730:        if(delim != ""){
                    731:                print ".EQ\\ndelim off\\n.EN"
                    732:                eflag=1
                    733:        }
                    734:        seen[File] = 1
                    735:        first=1
                    736:        while(1){
                    737:                if(first==0)if((getline <File)<=0)break
                    738:                first = 0
                    739:                if(\$0 ~ /^\\.(de|am)/){
                    740:                        if(fintbl && \$0 ~ /^\\.de 35/){
                    741:                                print tbloutput|"cat 1>&2"
                    742:                print "The tbl output is in the .so file named:" File|"cat 1>&2"
                    743:                                exit 1
                    744:                        }
                    745:                        indef=1
                    746:                        xname = \$2
                    747:                }
                    748:                if(indef && \$0 ~ /^\\.BM/)incmacro["." xname]=1
                    749:                if(indef && \$0 ~ /^\\.BP/)incmacro["." xname]=1
                    750:                if(indef && \$0 ~ /^\\.PI/)incmacro["." xname]=1
                    751:                if(\$0 ~ /^\\.\\.\$/)indef=0
                    752:                if(\$0 ~ /^\\.sy/ && indef == 0){
                    753:        print "the .sy commands in this paper will not be handled" indef|"cat 1>&2"
                    754:                        if(debug ~ /-d/){
                    755:                                print \$0
                    756:                                continue
                    757:                        }
                    758:                        print "paper not submitted" | "cat 1>&2"
                    759:                        exit 1
                    760:                }
                    761:                if(\$0 ~ /^\\.TS/)fintbl=1
                    762:                if(\$0 ~ /^\\.TE/)fintbl=0
                    763:                if(\$0 ~ /^\\.PS/)finpic=1
                    764:                if(\$0 ~ /^\\.PE/)finpic=0
                    765:                if(finpic && \$0 ~ /^\\.sp -1/){
                    766:                        print picoutput|"cat 1>&2"
                    767:                print "The pic output is in the .so file named:" File|"cat 1>&2"
                    768:                        exit 1
                    769:                }
                    770:                if((\$1 in incmacro)&& (NF > 1))
                    771:                        havecopy(\$1, \$2, 2)
                    772:                else if(!indef && \$0 ~ /^\\.so/)
                    773:                        getfile(\$2)
                    774:                else print \$0
                    775:        }
                    776:        close(File)
                    777:        if(eflag){
                    778:                print ".EQ\\n" delim "\\n.EN"
                    779:                eflat = 0
                    780:        }
                    781: }
                    782: function doinclude(cmd, fname, fileflag, file){
                    783:        if(fname ~ "/"){
                    784:                n=split(fname,name,"/")
                    785:                if(fileflag)print cmd " " name[n] >(dir "/" file)
                    786:                else print cmd " " name[n]
                    787:        }
                    788:        else if(fileflag)print cmd " " fname >(dir "/" file)
                    789:        else print cmd " " fname
                    790:        while((getline<fname)>0){
                    791:                if(\$0 ~ /^[\\.]+include/)
                    792:                        doinclude(\$1, \$2, 1, fname)
                    793:                else print \$0 >(dir "/" fname)
                    794:        }
                    795:        close(fname)
                    796: }
                    797: !
                    798:        ${AWK} -f ${AWKTEMP} dir=$DIR $PARMS >>$OUTP
                    799:        # NOTE: END of subso.awk
                    800:        # Check that it ended okay
                    801:        if test $? -ne 0
                    802:        then
                    803:            echo "Sorry - couldnt collect together the full text of your document."
                    804:            echo "No full text was sent! Contact the docsubmit provider with questions."
                    805:            exit 1 
                    806:            fi
                    807: 
                    808:        if test $REF
                    809:        then
                    810:        cat >>$OUTP <<x
                    811: ...\"refer begin
                    812: x
                    813:        cat $REF >>$OUTP
                    814:        cat >>$OUTP <<x
                    815: ...\"refer end
                    816: x
                    817:        fi
                    818: fi
                    819: cd $T
                    820: ls $NAME/*|cpio -oc >$NAME.cp
                    821: chmod 0644 $NAME.cp
                    822: uucp -C $NAME.cp mhuxd!~/full.text/
                    823: echo "
                    824: The full text of your document has been sent to the Library Network.
                    825: Please note that an official paper copy MUST still be filed.
                    826: "
                    827: exit 0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.