Annotation of 43BSD/contrib/X/doc/Xlib/fixindex.icn, revision 1.1

1.1     ! root        1: # transform raw index entries into new macros
        !             2: #
        !             3: #      features include:  merging page numbers and suppressing duplicates
        !             4: #                         sorting out major headings from minor
        !             5: #
        !             6: # the (pre-sorted) input is of the form
        !             7: #      <page-number><tab><major name><tab><minor name>
        !             8: #
        !             9: 
        !            10: 
        !            11: record LineState(PageNum, Major, Minor)
        !            12: 
        !            13: procedure main()
        !            14:        local pageList, old, new
        !            15: 
        !            16:        old := LineState()
        !            17:        new := LineState()
        !            18:        split(old) | return
        !            19:        pageList := old.PageNum
        !            20: 
        !            21:        if old.Minor ~== "" then
        !            22:            write(".Ib \"", old.Major, "\"")
        !            23: 
        !            24:        while split(new) do {
        !            25:            if old.Major == new.Major then
        !            26:                if old.Minor == new.Minor then {
        !            27:                    if old.PageNum ~= new.PageNum then
        !            28:                        pageList ||:= "," || new.PageNum }
        !            29:                else {
        !            30:                    WriteEntry(old, pageList)
        !            31:                    pageList := new.PageNum }
        !            32:            else {
        !            33:                WriteEntry(old, pageList)
        !            34:                pageList := new.PageNum
        !            35: 
        !            36:                if new.Minor ~== "" then 
        !            37:                    write(".Ib \"", new.Major, "\"") }
        !            38: 
        !            39:            AssignRecord(new, old) }            # new -> old
        !            40: 
        !            41:        WriteEntry(old, pageList)
        !            42:  end
        !            43: 
        !            44: 
        !            45: procedure split(state)
        !            46:        static tabChar,
        !            47:               digits
        !            48:        initial { tabChar := cset("\t");
        !            49:                  digits := cset("0123456789") }
        !            50: 
        !            51:        read() | fail ? {
        !            52:            state.PageNum := tab(many(digits))
        !            53:            tab(many(tabChar))
        !            54:            state.Major := tab(upto(tabChar)) | tab(0)
        !            55:            tab(many(tabChar))
        !            56:            state.Minor := tab(0) }
        !            57: 
        !            58:        return
        !            59: end
        !            60: 
        !            61: 
        !            62: procedure WriteEntry(state, pageList)
        !            63:        if state.Minor == "" then
        !            64:            write(".I> \"", state.Major, "\" \"", pageList, "\"")
        !            65:        else
        !            66:            write(".I< \"", state.Major, "\" \"", state.Minor, 
        !            67:                                        "\" \"", pageList, "\"")
        !            68:  end
        !            69: 
        !            70: 
        !            71: procedure AssignRecord(a, b)
        !            72:        b.Major := a.Major
        !            73:        b.Minor := a.Minor
        !            74:        b.PageNum := a.PageNum
        !            75: end

unix.superglobalmegacorp.com

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