Annotation of researchv10dc/vol2/index/tools/headings.awk, revision 1.1.1.1

1.1       root        1: BEGIN  {
                      2:        longest = 0
                      3:        overf = 0
                      4:        i = 1
                      5:        }
                      6: (/^\.sh/&& NF == 1)||
                      7: /^\.(([NS]H)|(TL)|(TI))/       {
                      8:        place[i] = total
                      9:        if($0 ~ /SH/ && NF > 1|| $0 ~ /NH/ && (NF > 2 || $2 ~ /[A-Za-z]/)){
                     10:                if($0 ~ /"/){
                     11:                        n = split($0,x,"\"")
                     12:                        heading = x[2]
                     13:                }
                     14:                else heading = $2
                     15:                hsize += length(heading) + 1
                     16:        }
                     17:        else {
                     18:        total += length($0) + 1
                     19:        nlines = 0
                     20:        while(getline){
                     21:                if(nlines++ > 3){
                     22:                        print "too many lines in heading:" heading |"cat 1>&2"
                     23:                        break
                     24:                }
                     25:                total += length($0) +1
                     26:                hsize += length($0) +1
                     27:                if($0 ~ /^\.UX/){
                     28:                        nlines--
                     29:                        heading = heading " UNIX"
                     30:                        hsize += 1
                     31:                }
                     32:                else if($0 ~ /^\./){
                     33:                        if($1 ~ /^\.P/ || $1 ~ /^\.LP/|| $1 ~ /^\.[AT]/)break
                     34:                        if(heading == "")heading = $2
                     35:                        else heading = heading " " $2
                     36:                        if(NF > 2)for(n=3;n<=NF;n++)
                     37:                                heading = heading " " $n
                     38:                }
                     39:                else if(heading == "")
                     40:                        heading = $0
                     41:                else
                     42:                        heading = heading " " $0
                     43:        }
                     44:        }
                     45:        total += length($0) +1
                     46:        text[i] = heading
                     47:        l = length(heading)
                     48:        if(longest < l+1)
                     49:                longest = l + 1
                     50:        if(l > 23){
                     51:                while(l>=23){
                     52:                        overf++;
                     53:                        l -= 23
                     54:                }
                     55:        }
                     56:        heading = ""
                     57:        i++
                     58:        next
                     59:        }
                     60: /^\.(H[U ]|[su]h)/     {
                     61:        place[i] = total
                     62:        total += length($0) + 1
                     63:        if($0 ~ /"/){
                     64:                n = split($0, hd, "\"")
                     65:                if(n == 3)
                     66:                        heading = hd[2]
                     67:                else{
                     68:                        heading = hd[2]
                     69:                        print "unbalanced quotes: " $0 >"err.hd"
                     70:                }
                     71:        }
                     72:        else if($1 ~ /HU|uh/)heading = $2
                     73:        else  heading = $3
                     74:        text[i] = heading
                     75:        l = length(heading)
                     76:        hsize += l + 1
                     77:        if(longest < l+1)
                     78:                longest = l + 1
                     79:        if(l > 23){
                     80:                while(l>=23){
                     81:                        overf++;
                     82:                        l -= 23
                     83:                }
                     84:        }
                     85:        heading = ""
                     86:        i++
                     87:        next
                     88:        }
                     89: /^\.de/        {
                     90:        total += length($0) +1
                     91:        while(getline && $0 !~ /^\.\.$/){
                     92:                total += length($0) +1
                     93:        }
                     94:        total += length($0) +1
                     95:        next
                     96:        }
                     97: /.*/   {
                     98:        total += length($0) + 1
                     99:        }
                    100: END    {
                    101:        if(i > 1){
                    102: #              print hsize " " longest " " i-1 " " overf
                    103:                for(n=1;n<i;n++){
                    104: #                      print place[n]
                    105:                        print text[n]
                    106:                }
                    107:        }
                    108:        }

unix.superglobalmegacorp.com

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