Annotation of coherent/d/bin/nroff/misc/hptoroff.c,v, revision 1.1.1.1

1.1       root        1: head     1.1;
                      2: access   ;
                      3: symbols  ;
                      4: locks    ;
                      5: comment  @ * @;
                      6: 
                      7: 
                      8: 1.1
                      9: date     91.02.04.16.48.57;  author bin;  state Exp;
                     10: branches ;
                     11: next   ;
                     12: 
                     13: 
                     14: desc
                     15: @init ver prov by stevesf
                     16: @
                     17: 
                     18: 
                     19: 
                     20: 1.1
                     21: log
                     22: @Initial revision
                     23: @
                     24: text
                     25: @/* (-lgl
                     26:  *     The information contained herein is a trade secret of Mark Williams
                     27:  *     Company, and  is confidential information.  It is provided  under a
                     28:  *     license agreement,  and may be  copied or disclosed  only under the
                     29:  *     terms of  that agreement.  Any  reproduction or disclosure  of this
                     30:  *     material without the express written authorization of Mark Williams
                     31:  *     Company or persuant to the license agreement is unlawful.
                     32:  * 
                     33:  *     troff-nroff Version 002
                     34:  *     Copyright (c) 1984-1986.
                     35:  *     An unpublished work by Mark Williams Company, Chicago.
                     36:  *     All rights reserved.
                     37:  -lgl) */
                     38: /*
                     39:  * This program reads in a width table in 300-ths of an inch units,
                     40:  * for ascii characters from ascii space to ascii del.
                     41:  * It then prints out the width table in internal ?roff order.
                     42:  */
                     43: #include "hlib.h"
                     44: 
                     45: 
                     46: #define        LOW     (' ')           /* lowest input character */
                     47: #define        HIGH    ('\177')        /* highest input character */
                     48: #define        COLS    8               /* columns to output */
                     49: 
                     50: 
                     51: uint   intab[HIGH+1-LOW];
                     52: 
                     53: 
                     54: /*
                     55:  * Table to convert from the internal character set to ASCII.
                     56:  */
                     57: char intasc[] ={
                     58:        0,      '0',    '1',    '2',    '3',    '4',    '5',    '6',
                     59:        '7',    '8',    '9',    'A',    'B',    'C',    'D',    'E',
                     60:        'F',    'G',    'H',    'I',    'J',    'K',    'L',    'M',
                     61:        'N',    'O',    'P',    'Q',    'R',    'S',    'T',    'U',
                     62:        'V',    'W',    'X',    'Y',    'Z',    'a',    'b',    'c',
                     63:        'd',    'e',    'f',    'g',    'h',    'i',    'j',    'k',
                     64:        'l',    'm',    'n',    'o',    'p',    'q',    'r',    's',
                     65:        't',    'u',    'v',    'w',    'x',    'y',    'z',    '!',
                     66:        '"',    '#',    '$',    '%',    '&',    '(',    ')',    '*',
                     67:        '+',    ',',    '-',    '.',    '/',    ':',    ';',    '<',
                     68:        '=',    '>',    '?',    '@@',   '[',    '\\',   ']',    '^',
                     69:        '_',    '{',    '|',    '}',    '~',    '`',    '\'',   '\'',
                     70:        '`',    '^',    '-'
                     71: };
                     72: 
                     73: 
                     74: main()
                     75: {
                     76:        gettab();
                     77:        puttab();
                     78:        return (0);
                     79: }
                     80: 
                     81: gettab()
                     82: {
                     83:        register int    i;
                     84: 
                     85:        for (i=LOW; i <= HIGH; ++i) {
                     86:                if (not skip())
                     87:                        die("Unexpected end of file");
                     88:                intab[i-LOW] = getint();
                     89:        }
                     90:        if (skip())
                     91:                die("Extra input");
                     92: }
                     93: 
                     94: skip()
                     95: {
                     96:        register int    ch;
                     97: 
                     98:        do {
                     99:                ch = getchar();
                    100:        } while (ch == ' ' || ch == '\t' || ch == '\n');
                    101:        ungetc(ch, stdin);
                    102:        return (ch != EOF);
                    103: }
                    104: 
                    105: getint()
                    106: {
                    107:        register int    res,
                    108:                        ch;
                    109: 
                    110:        ch = getchar();
                    111:        if (ch < '0' || ch > '9')
                    112:                die("Bad number");
                    113:        res = ch - '0';
                    114:        loop {
                    115:                ch = getchar();
                    116:                if (ch < '0' || ch > '9')
                    117:                        break;
                    118:                res = 10*res + ch-'0';
                    119:        }
                    120:        ungetc(ch, stdin);
                    121:        return (res);
                    122: }
                    123: 
                    124: puttab()
                    125: {
                    126:        register char   *ip;
                    127:        register int    col;
                    128: 
                    129:        col = COLS;
                    130:        ip = intasc;
                    131:        loop {
                    132:                if (LOW <= *ip && *ip <= HIGH)
                    133:                        printf("\t%d", scale(intab[*ip-LOW]));
                    134:                else
                    135:                        printf("\t0");
                    136:                if (++ip == &intasc[sizeof(intasc) / sizeof(*intasc)])
                    137:                        break;
                    138:                printf(",");
                    139:                if (--col == 0) {
                    140:                        printf("\n");
                    141:                        col = COLS;
                    142:                }
                    143:        }
                    144:        if (col != COLS)
                    145:                printf("\n");
                    146: }
                    147: 
                    148: scale(x)
                    149: int    x;
                    150: {
                    151:        return (x);
                    152: }
                    153: @

unix.superglobalmegacorp.com

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