Annotation of researchv10no/cmd/mk/src/defns, revision 1.1.1.1

1.1       root        1: IND=../index/tools
                      2: 
                      3: ENVIRON='runind(){
                      4:        if test -s $1.ms
                      5:        then
                      6:                J=`basename $1 .ms`
                      7:                F=$1.ms
                      8:                O=x$1.ms
                      9:        else if test -s $1.m
                     10:        then
                     11:                J=`basename $1 .m`
                     12:                F=$1.m
                     13:                O=x$1.m
                     14:        else if test $1
                     15:        then
                     16:                J=$1
                     17:                F=$1
                     18:                O=x$1
                     19:        else
                     20:                echo $1 not found
                     21:                exit
                     22:        fi
                     23:        fi
                     24:        fi
                     25: tr A-Z a-z <$J.terms|sed "s/\([a-z][a-z/]*\)\.\([a-z][a-z]*\)/\1zz1\2/g"|sort|uniq|
                     26: awk '\''       {
                     27:        if(last == $0)next
                     28:        if(last "s" == $0){
                     29:                print last
                     30:                last = ""
                     31:                next
                     32:        }
                     33:        else if(last != "")
                     34:                print last
                     35:        last = $0
                     36:        }
                     37: END    {
                     38:        if(last != "")print last
                     39: } >$J.lt
                     40: sed s/\([a-z][a-z]*\)\.\([a-z][a-z]*\)/\1zz1\2/g $F >foo
                     41: $IND/diction -f $J.lt -o $J.hits foo >/dev/null
                     42: sed s/zz1/\./g $J.hits|tr $ ~ >$J.nh
                     43: mv $J.nh $J.hits
                     44: awk  -v name=$J.hits 
                     45: BEGIN  {
                     46:        getterm()
                     47:        }
                     48: /.*/   {
                     49:        line = $0
                     50:        if(NR >= number){
                     51:                putterm()
                     52:        }
                     53:        print line
                     54:        if(line ~ /^\.PS[ ]*</)next
                     55:        if(line ~ /^\.[TPI]S/){
                     56:                while(getline > 0){
                     57:                        if($0 ~ /^\.T\&/){
                     58:                                if(NR >= number)
                     59:                                        putterm()
                     60:                        }
                     61:                        print $0
                     62:                        if($0 ~ /^\.([PTI]E)|IF/)break
                     63:                }
                     64:        }
                     65:        if(line ~ /^\.EQ/){
                     66:                while(getline > 0){
                     67:                        print $0
                     68:                        if($0 ~ /^\.EN/)break
                     69:                }
                     70:        }
                     71:        }
                     72: function getterm(){
                     73:        if((getline < name)<= 0){
                     74:                number += 1000
                     75:        }
                     76:        else if($0 ~ /^[0-9]/ && NF > 1){
                     77:                number = $1
                     78:                sub(/^[0-9][0-9]* /,"")
                     79:                term = $0
                     80:        } else term=$0
                     81: }
                     82: function putterm(){
                     83:        print ".Tm " term
                     84:        getterm()
                     85:        if(NR >= number){
                     86:                while(NR >= number){
                     87:                        print ".Tm " term
                     88:                        getterm()
                     89:                }
                     90:        }
                     91: }
                     92:  $F >$O
                     93: rm foo
                     94: }
                     95: 
                     96: mkindex(){             #uses either $1.x or $2.x to make base.ind
                     97:        if test $# -eq 0
                     98:        then
                     99:                echo mkindex directory file or mkindex file
                    100:                exit
                    101:        fi
                    102:        if test $# -eq 1
                    103:        then
                    104:        j=`basename $1 .x`
                    105:        sed -n "/^\.XX.*$j/p" ../contents/contents.ms|awk {print $2 >"name"}
                    106:        else
                    107:        j=`basename $2 .x`
                    108:        sed -n "/^\.XX.*$1\/$j/p" ../contents/contents.ms|awk {print $2 >"name"}
                    109:        fi
                    110:        FILE=$j.x
                    111: S=`cat name`
                    112: sed -e "/^0    /d" -e "s/ #.*//" -e "s/:/!/g" -e "/^[A-Za-z.]/d" -e "/Examp/d" $FILE|
                    113: awk
                    114: BEGIN  {FS="   " }
                    115: NF==2  { print str ", " $2 ": " $1
                    116:        print $2 ", " str ": " $1
                    117:        }
                    118: NF==3  {
                    119:        if($NF == "s" )print str ", " $2 ": " $1
                    120:        else print $2 ", " str ": " $1
                    121: } str=$S | sort -u -t":" +0 -1 +1n |
                    122: awk 
                    123: BEGIN  {FS=":"}
                    124:        { if($1 != laststr){
                    125:                if(start){
                    126:                        if(range)pages = pages "-" npage
                    127:                        print laststr "," pages
                    128:                }
                    129:                start=1
                    130:                laststr=$1
                    131:                pages = " " $2
                    132:                npage = 0 + $2
                    133:                range=0
                    134:        }
                    135:        else {
                    136:                if($2 == npage+1){
                    137:                        range=1
                    138:                        npage++
                    139:                        next
                    140:                }
                    141:                else if(range) pages = pages "-" npage "," $2
                    142:                else pages = pages "," $2
                    143:                npage = 0 + $2
                    144:                range = 0
                    145:        }
                    146: }
                    147: END    {
                    148:        if(range)pages = pages "-" npage
                    149:        print laststr "," pages
                    150:        }
                    151: 
                    152: |sed -e s/~/\$/g -e s/!/:/g>$j.ind
                    153: }'
                    154: 

unix.superglobalmegacorp.com

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