Annotation of coherent/d/bin/nroff/misc/test.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.49.09;  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:  * Test reads in a font width table and produces a file which will test
                     40:  * the accuracy of this table.
                     41:  * The usage is
                     42:  *     test font_select_string
                     43:  * where the argument is the string to select the font, with escapes
                     44:  * represented by `~'.
                     45:  */
                     46: #include "hlib.h"
                     47: 
                     48: #define        LOW     (' ')           /* lowest input character */
                     49: #define        HIGH    ('\177')        /* highest input character */
                     50: #define        QUANTA  300             /* resolution (per inch) */
                     51: #define        EQUANTA 720             /* external resolution (per inch) */
                     52: #define        RIGHT   (7*QUANTA)      /* right margin */
                     53: #define        LEFT    (1*QUANTA)      /* left margin */
                     54: 
                     55: main(argc, argv)
                     56: int    argc;
                     57: char   *argv[];
                     58: {
                     59:        register int    i;
                     60: 
                     61:        if (argc != 2 || **++argv == '-')
                     62:                die("Usage: test font_select_string");
                     63:        init(*argv);
                     64:        for (i=LOW; i <= HIGH; ++i) {
                     65:                if (not skip())
                     66:                        die("Unexpected end of file");
                     67:                doit(i, getint());
                     68:        }
                     69:        if (skip())
                     70:                die("Extra input");
                     71:        return (0);
                     72: }
                     73: 
                     74: init(str)
                     75: register char  *str;
                     76: {
                     77:        printf("\033E");
                     78:        loop
                     79:                switch (*str) {
                     80:                case '~':
                     81:                        putchar('\033');
                     82:                        ++str;
                     83:                        break;
                     84:                case EOS:
                     85:                        return;
                     86:                default:
                     87:                        putchar(*str);
                     88:                        ++str;
                     89:                }
                     90: }
                     91: 
                     92: /*
                     93:  * Doit tests to see if ch has width w.
                     94:  */
                     95: doit(ch, w)
                     96: int    ch,
                     97:        w;
                     98: {
                     99:        register int    n;
                    100: 
                    101:        n = (RIGHT-LEFT) / w;
                    102:        pos(RIGHT - n*w);
                    103:        while (n-- != 0)
                    104:                putchar(ch);
                    105:        printf("|\n");
                    106: }
                    107: 
                    108: pos(n)
                    109: int    n;
                    110: {
                    111:        n = ((long)EQUANTA*n + EQUANTA-1) / QUANTA;
                    112:        printf("\033&a%dH", n);
                    113: }
                    114: 
                    115: skip()
                    116: {
                    117:        register int    ch;
                    118: 
                    119:        do {
                    120:                ch = getchar();
                    121:        } while (ch == ' ' || ch == '\t' || ch == '\n');
                    122:        ungetc(ch, stdin);
                    123:        return (ch != EOF);
                    124: }
                    125: 
                    126: getint()
                    127: {
                    128:        register int    res,
                    129:                        ch;
                    130: 
                    131:        ch = getchar();
                    132:        if (ch < '0' || ch > '9')
                    133:                die("Bad number");
                    134:        res = ch - '0';
                    135:        loop {
                    136:                ch = getchar();
                    137:                if (ch < '0' || ch > '9')
                    138:                        break;
                    139:                res = 10*res + ch-'0';
                    140:        }
                    141:        ungetc(ch, stdin);
                    142:        return (res);
                    143: }
                    144: @

unix.superglobalmegacorp.com

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