Annotation of researchv9/cmd/tbl/tm.c, revision 1.1

1.1     ! root        1:  /* tm.c: split numerical fields */
        !             2: # include "t..c"
        !             3: char *maknew(str)
        !             4:        char *str;
        !             5: {
        !             6:        /* make two numerical fields */
        !             7:        extern char *chspace();
        !             8:        int dpoint, c;
        !             9:        char *p, *q, *ba;
        !            10:        p = str;
        !            11:        for (ba= 0; c = *str; str++)
        !            12:                if (c == '\\' && *(str+1)== '&')
        !            13:                        ba=str;
        !            14:        str=p;
        !            15:        if (ba==0)
        !            16:                {
        !            17:                for (dpoint=0; *str; str++)
        !            18:                        {
        !            19:                        if (*str=='.' && !ineqn(str,p) &&
        !            20:                                (str>p && digit(*(str-1)) ||
        !            21:                                digit(*(str+1))))
        !            22:                                        dpoint=(int)str;
        !            23:                        }
        !            24:                if (dpoint==0)
        !            25:                        for(; str>p; str--)
        !            26:                        {
        !            27:                        if (digit( * (str-1) ) && !ineqn(str, p))
        !            28:                                break;
        !            29:                        }
        !            30:                if (!dpoint && p==str) /* not numerical, don't split */
        !            31:                        return(0);
        !            32:                if (dpoint) str=(char *)dpoint;
        !            33:                }
        !            34:        else
        !            35:                str = ba;
        !            36:        p =str;
        !            37:        if (exstore ==0 || exstore >exlim)
        !            38:                {
        !            39:                exstore = exspace = chspace();
        !            40:                exlim= exstore+MAXCHS;
        !            41:                }
        !            42:        q = exstore;
        !            43:        while (*exstore++ = *str++);
        !            44:        *p = 0;
        !            45:        return(q);
        !            46:        }
        !            47: ineqn (s, p)
        !            48:        char *s, *p;
        !            49: {
        !            50: /* true if s is in a eqn within p */
        !            51: int ineq = 0, c;
        !            52: while (c = *p)
        !            53:        {
        !            54:        if (s == p)
        !            55:                return(ineq);
        !            56:        p++;
        !            57:        if ((ineq == 0) && (c == delim1))
        !            58:                ineq = 1;
        !            59:        else
        !            60:        if ((ineq == 1) && (c == delim2))
        !            61:                ineq = 0;
        !            62:        }
        !            63: return(0);
        !            64: }

unix.superglobalmegacorp.com

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