home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume4 / xtroff / part09 < prev    next >
Encoding:
Internet Message Format  |  1989-07-17  |  49.4 KB

  1. Path: uunet!island!argv
  2. From: argv@island.uu.net (Dan Heller)
  3. Newsgroups: comp.sources.x
  4. Subject: v04i054: xtroff -- troff previewer for X11, Part09/18
  5. Message-ID: <888@island.uu.net>
  6. Date: 18 Jul 89 07:26:01 GMT
  7. Organization: Island Graphics, Marin County, California
  8. Lines: 1796
  9. Approved: island!argv@sun.com
  10.  
  11. Submitted-by: Mark Moraes <moraes@ai.toronto.edu>
  12. Posting-number: Volume 4, Issue 54
  13. Archive-name: xtroff/part09
  14.  
  15.  
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 9 (of 18)."
  24. # Contents:  xtroff/XtStuff/ask.c xtroff/devpsc/Makefile xtroff/draw.c
  25. #   xtroff/fontstuff/Makefile xtroff/parse.c
  26. # Wrapped by moraes@neat.ai on Thu Jul 13 20:55:12 1989
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'xtroff/XtStuff/ask.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'xtroff/XtStuff/ask.c'\"
  30. else
  31. echo shar: Extracting \"'xtroff/XtStuff/ask.c'\" \(9084 characters\)
  32. sed "s/^X//" >'xtroff/XtStuff/ask.c' <<'END_OF_FILE'
  33. X/* This file contains code from the JOVE screen editor */
  34. X
  35. X/************************************************************************
  36. X * JOVE is Copyright (C) 1986 by Jonathan Payne.  JOVE is               *
  37. X * provided to you without charge, and with no warranty.  You may give  *
  38. X * away copies of JOVE, including sources, provided that this notice is *
  39. X * included in all the files.                                           *
  40. X ************************************************************************/
  41. X
  42. X/*
  43. X *  Modified by Mark Moraes for use in a widget for the X Windows System
  44. X *  Version 11. This file is still independent of the X Windows System.
  45. X */
  46. X
  47. X/* The routines in this file perform Tenex-style filename completion. 
  48. X   The routine to be called is 
  49. X    f_complete(buf, cursorposition, cols, c)
  50. X    char *buf;
  51. X
  52. X   where 'buf' contains the filename so far. 'cursorposition' is the 
  53. X   location of the cursor in 'buf' - it should be at the end of the 'buf'.
  54. X   'cols' is the width of the screen used for typeout, (the listing of files)
  55. X   and 'c' is one of ' ', '\t', and '?'. For the former two, f_complete
  56. X   attempts to complete the name in 'buf', and for the latter, it
  57. X   lists out the files which match the name so far using the typeout
  58. X   routines.
  59. X
  60. X   It requires two sets of external routines to do this - insert_s(), 
  61. X   add_mess() and rbell() are used for completion, and TOstart(), 
  62. X   Typeout(), and TOstop() are used for typeout. These are described 
  63. X   below 
  64. X */
  65. X#include <ctype.h>
  66. X#include <signal.h>
  67. X#include <varargs.h>
  68. X#include <stdio.h>
  69. X#ifdef XWINDOWS
  70. X# include <X11/Xos.h>
  71. X#else
  72. X# include <strings.h>
  73. X# include <sys/types.h>
  74. X#endif
  75. X#include <sys/stat.h>
  76. X#ifdef DIRENT
  77. X# include <sys/param.h>
  78. X# include <dirent.h>
  79. X# ifndef DIRSIZE
  80. X#  define DIRSIZE(entry)    DIRSIZ
  81. X# endif
  82. X# ifndef direct
  83. X#  define direct    dirent
  84. X# endif
  85. X#else
  86. X# include <sys/dir.h>
  87. X# define DIRSIZE(entry)    DIRSIZ(entry)
  88. X#endif DIRENT
  89. X
  90. X#define FILESIZE    128
  91. X#define TRUE        1
  92. X#define FALSE        0
  93. X#define min(x, y)    ((x) < (y) ? (x) : (y))
  94. X#define max(x, y)    ((x) > (y) ? (x) : (y))
  95. X
  96. Xstatic char *linebuf;
  97. Xstatic int curchar;
  98. Xstatic int maxCols;
  99. X
  100. Xextern char *malloc();
  101. Xextern char *realloc();
  102. X
  103. X/**********************External functions **********************************/
  104. X/* insert_s(at, s, len, curpos) char *at, *s; int len; int *curpos;
  105. X *    deletes from 'at' to the end of the line, and inserts the first len
  106. X *    characters of 's' there. It returns 'curpos' as the new end of the
  107. X *    string being edited - the cursor should now be there
  108. X */
  109. Xextern void insert_s();
  110. X
  111. X/* add_mess(s) char *s;
  112. X *    inserts 's' at the end of the buffer, then waits a respectable
  113. X *    interval, deletes 's', and returns
  114. X */
  115. Xextern void add_mess();
  116. X
  117. X/* rbell()
  118. X *    Rings a bell or attracts the user's attention in some other way 
  119. X */
  120. Xextern void rbell();
  121. X
  122. X/* TOstart(s) char *s;
  123. X *    Starts the typeout, and prints 's' as a title. Typeout is some 
  124. X *    sort of overlay 'window' or something, for temporary output, 
  125. X *    which can popup, and vanish after the user has read it. 
  126. X */
  127. Xextern TOstart();
  128. X
  129. X/* Typeout(fmt, args) char *fmt; va_dcl args;
  130. X *    Is like printf() - prints args according to format 'fmt'. 
  131. X *    Is a <varargs> routine
  132. X */
  133. Xextern Typeout();
  134. X
  135. X/* TOstop()
  136. X *    End of typeout - this performs some sort of wait()
  137. X *    - like for a keypress or a mouse click. It then cleans up
  138. X *    the typeout and returns.
  139. X */
  140. Xextern TOstop();
  141. X
  142. Xchar *xmalloc(n)
  143. X{
  144. X    extern char *malloc();
  145. X    char *p = malloc((unsigned) n);
  146. X
  147. X    if (!p) {
  148. X        (void) fprintf(stderr, "out of memory in malloc\n");
  149. X        exit(-1);
  150. X    }
  151. X    return p;
  152. X}
  153. X
  154. Xchar *xrealloc(s, n)
  155. Xchar *s;
  156. X{
  157. X    extern char *realloc();
  158. X    char *p = realloc(s, (unsigned) n);
  159. X
  160. X    if (!p) {
  161. X        (void) fprintf(stderr, "out of memory in realloc\n");
  162. X        exit(-1);
  163. X    }
  164. X    return p;
  165. X}
  166. X
  167. X/* Scandir returns the number of entries or -1 if the directory cannoot
  168. X   be opened or malloc fails. */
  169. X
  170. Xint
  171. Xmyscandir(dir, nmptr, qualify, sorter)
  172. Xchar    *dir;
  173. Xchar    ***nmptr;
  174. Xint    (*qualify)();
  175. Xint    (*sorter)();
  176. X{
  177. X    DIR    *dirp;
  178. X    struct direct    *entry;
  179. X    char    **ourarray;
  180. X    int    nalloc = 10;
  181. X    int    nentries = 0;
  182. X
  183. X    if ((dirp = opendir(dir)) == 0)
  184. X        return -1;
  185. X    ourarray = (char **) xmalloc(nalloc * sizeof (char *));
  186. X    while ((entry = readdir(dirp)) != 0) {
  187. X        if (qualify != 0 && (*qualify)(entry->d_name) == 0)
  188. X            continue;
  189. X        if (nentries == nalloc) {
  190. X            ourarray = (char **) xrealloc((char *) ourarray, (nalloc += 10) * sizeof (char *));
  191. X        }
  192. X        ourarray[nentries] = (char *) xmalloc((int) DIRSIZE(entry) + 1);
  193. X        null_ncpy(ourarray[nentries], entry->d_name, (int) DIRSIZE(entry));
  194. X        nentries++;
  195. X    }
  196. X    closedir(dirp);
  197. X    if ((nentries + 1) != nalloc)
  198. X        ourarray = (char **) xrealloc((char *) ourarray,
  199. X                    ((nentries + 1) * sizeof (char *)));
  200. X    if (sorter != 0)
  201. X        qsort((char *) ourarray, nentries, sizeof (char **), sorter);
  202. X    *nmptr = ourarray;
  203. X    ourarray[nentries] = 0;        /* guaranteed 0 pointer */
  204. X
  205. X    return nentries;
  206. X}
  207. X
  208. Xfreedir(nmptr, nentries)
  209. Xchar    ***nmptr;
  210. X{
  211. X    char    **ourarray = *nmptr;
  212. X
  213. X    while (--nentries >= 0)
  214. X        free(*ourarray++);
  215. X    free((char *) *nmptr);
  216. X    *nmptr = 0;
  217. X}
  218. X
  219. Xalphacomp(a, b)
  220. Xchar    **a,
  221. X    **b;
  222. X{
  223. X    return strcmp(*a, *b);
  224. X}
  225. X
  226. Xnumcomp(s1, s2)
  227. Xregister char    *s1,
  228. X        *s2;
  229. X{
  230. X    register int    count = 0;
  231. X
  232. X    while (*s1 != 0 && *s1++ == *s2++)
  233. X        count++;
  234. X    return count;
  235. X}
  236. X
  237. Xstatic char    *fc_filebase;
  238. Xchar    BadExtensions[128] = ".o";
  239. X
  240. Xstatic
  241. Xbad_extension(name, bads)
  242. Xchar    *name,
  243. X    *bads;
  244. X{
  245. X    char    *ip;
  246. X    int    namelen = strlen(name),
  247. X        ext_len,
  248. X        stop = 0;
  249. X
  250. X    do {
  251. X        if (ip = index(bads, ' '))
  252. X            *ip = 0;
  253. X        else {
  254. X            ip = bads + strlen(bads);
  255. X            stop++;
  256. X        }
  257. X        if ((ext_len = ip - bads) == 0)
  258. X            continue;
  259. X        if ((ext_len < namelen) &&
  260. X            (strcmp(&name[namelen - ext_len], bads) == 0))
  261. X            return TRUE;
  262. X    } while ((bads = ip + 1), !stop);
  263. X    return FALSE;
  264. X}
  265. X
  266. Xf_match(file)
  267. Xchar    *file;
  268. X{
  269. X    int    len = strlen(fc_filebase);
  270. X
  271. X    return ((len == 0) ||
  272. X        (strncmp(file, fc_filebase, strlen(fc_filebase)) == 0));
  273. X}
  274. X
  275. Xstatic
  276. Xisdir(name)
  277. Xchar    *name;
  278. X{
  279. X    struct stat    stbuf;
  280. X    char    filebuf[FILESIZE];
  281. X
  282. X    PathParse(name, filebuf);
  283. X    return ((stat(filebuf, &stbuf) != -1) &&
  284. X        (stbuf.st_mode & S_IFDIR) == S_IFDIR);
  285. X}
  286. X
  287. Xstatic
  288. Xfill_in(dir_vec, n)
  289. Xregister char    **dir_vec;
  290. X{
  291. X    int    minmatch = 0,
  292. X            numfound = 0,
  293. X            lastmatch = -1,
  294. X        i,
  295. X        the_same = TRUE, /* After filling in, are we the same
  296. X                    as when we were called? */
  297. X        is_ntdir;    /* Is Newly Typed Directory name */
  298. X    char    bads[128];
  299. X
  300. X    for (i = 0; i < n; i++) {
  301. X        (void) strcpy(bads, BadExtensions);
  302. X        /* bad_extension() is destructive */
  303. X        if (bad_extension(dir_vec[i], bads))
  304. X            continue;
  305. X        if (numfound)
  306. X            minmatch = min(minmatch,
  307. X                       numcomp(dir_vec[lastmatch], dir_vec[i]));
  308. X        else
  309. X            minmatch = strlen(dir_vec[i]);
  310. X        lastmatch = i;
  311. X        numfound++;
  312. X    }
  313. X    /* Ugh.  Beware--this is hard to get right in a reasonable
  314. X       manner.  Please excuse this code--it's past my bedtime. */
  315. X    if (numfound == 0) {
  316. X        rbell();
  317. X        return;
  318. X    }
  319. X    if (minmatch > strlen(fc_filebase)) {
  320. X        the_same = FALSE;
  321. X        insert_s(fc_filebase, dir_vec[lastmatch], minmatch, &curchar);
  322. X    }
  323. X    is_ntdir = ((numfound == 1) &&
  324. X            (curchar > 0) &&
  325. X            (linebuf[curchar - 1] != '/') &&
  326. X            (isdir(linebuf)));
  327. X    if (the_same && !is_ntdir) {
  328. X        add_mess((n == 1) ? " [Unique]" : " [Ambiguous]");
  329. X    }
  330. X    if (is_ntdir)
  331. X        insert_s(&linebuf[curchar], "/", 1, &curchar);
  332. X}
  333. X
  334. X/*
  335. X *  called when one of "\t ?" is typed.  Does the right thing,
  336. X *  depending on which.
  337. X */
  338. X
  339. Xf_complete(sbuf, curpos, cols, c)
  340. Xchar *sbuf;
  341. X{
  342. X    char    dir[FILESIZE],
  343. X        **dir_vec;
  344. X    int    nentries;
  345. X#ifdef TYPEOUT
  346. X    int    i;
  347. X#endif
  348. X
  349. X    linebuf = sbuf;
  350. X    curchar = curpos;
  351. X    maxCols = cols;
  352. X    
  353. X    if (linebuf[curpos] != '\0')
  354. X        linebuf[curpos] = '\0';
  355. X        
  356. X    if ((fc_filebase = rindex(linebuf, '/')) != 0) {
  357. X        char    tmp[FILESIZE];
  358. X
  359. X        null_ncpy(tmp, linebuf, (++fc_filebase - linebuf));
  360. X        if (tmp[0] == '\0')
  361. X            (void) strcpy(tmp, "/");
  362. X        PathParse(tmp, dir);
  363. X    } else {        
  364. X        fc_filebase = linebuf;
  365. X        (void) strcpy(dir, ".");
  366. X    }
  367. X    if ((nentries = myscandir(dir, &dir_vec, f_match, alphacomp)) == -1) {
  368. X        char err[FILESIZE];
  369. X        
  370. X        (void) sprintf(err, " [Unknown directory: %s]", dir);
  371. X        add_mess(err);
  372. X        return 1;
  373. X    }
  374. X    if (nentries == 0) {
  375. X        add_mess(" [No match]");
  376. X    } else if (c == ' ' || c == '\t')
  377. X        fill_in(dir_vec, nentries);
  378. X    else {
  379. X        /* we're a '?' */
  380. X#ifdef TYPEOUT
  381. X        int    maxlen = 0,
  382. X            ncols,
  383. X            col,
  384. X            lines,
  385. X            linespercol;
  386. X
  387. X        TOstart("Completion");
  388. X        Typeout("(! means file will not be chosen unless typed explicitly)");
  389. X        Typeout((char *) 0);
  390. X        Typeout("Possible completions (in %s):", dir);
  391. X        Typeout((char *) 0);
  392. X
  393. X        for (i = 0; i < nentries; i++)
  394. X            maxlen = max(strlen(dir_vec[i]), maxlen);
  395. X        maxlen += 4;    /* pad each column with at least 4 spaces */
  396. X        ncols = (maxCols - 2) / maxlen;
  397. X        linespercol = 1 + (nentries / ncols);
  398. X
  399. X        for (lines = 0; lines < linespercol; lines++) {
  400. X            for (col = 0; col < ncols; col++) {
  401. X                int    isbad,
  402. X                    which;
  403. X                char    bads[128];
  404. X
  405. X                which = (col * linespercol) + lines;
  406. X                if (which >= nentries)
  407. X                    break;
  408. X                (void) strcpy(bads, BadExtensions);
  409. X                isbad = bad_extension(dir_vec[which], bads);
  410. X                Typeout("%s%-*s", isbad ? "!" : "",
  411. X                    maxlen - isbad, dir_vec[which]);
  412. X            }
  413. X            Typeout((char *) 0);
  414. X        }
  415. X        TOstop();
  416. X#endif
  417. X    }
  418. X    freedir(&dir_vec, nentries);
  419. X    return 1;
  420. X}
  421. END_OF_FILE
  422. if test 9084 -ne `wc -c <'xtroff/XtStuff/ask.c'`; then
  423.     echo shar: \"'xtroff/XtStuff/ask.c'\" unpacked with wrong size!
  424. fi
  425. # end of 'xtroff/XtStuff/ask.c'
  426. fi
  427. if test -f 'xtroff/devpsc/Makefile' -a "${1}" != "-c" ; then 
  428.   echo shar: Will not clobber existing file \"'xtroff/devpsc/Makefile'\"
  429. else
  430. echo shar: Extracting \"'xtroff/devpsc/Makefile'\" \(10120 characters\)
  431. sed "s/^X//" >'xtroff/devpsc/Makefile' <<'END_OF_FILE'
  432. X# Makefile generated by imake - do not edit!
  433. X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
  434. X#
  435. X# The cpp used on this machine replaces all newlines and multiple tabs and
  436. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  437. X# for this, but is not always successful.
  438. X#
  439. X
  440. X###########################################################################
  441. X# X Window System Makefile generated from template file Imake.tmpl
  442. X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
  443. X#
  444. X# Do not change the body of the imake template file.  Server-specific
  445. X# parameters may be set in the appropriate .macros file; site-specific
  446. X# parameters (but shared by all servers) may be set in site.def.  If you
  447. X# make any changes, you'll need to rebuild the makefiles using
  448. X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
  449. X# the top level directory.
  450. X#
  451. X# If your C preprocessor doesn't define any unique symbols, you'll need
  452. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  453. X# "make Makefile", "make Makefiles", or "make World").
  454. X#
  455. X# If you absolutely can't get imake to work, you'll need to set the
  456. X# variables at the top of each Makefile as well as the dependencies at the
  457. X# bottom (makedepend will do this automatically).
  458. X#
  459. X
  460. X###########################################################################
  461. X# platform-specific configuration parameters - edit Sun.macros to change
  462. X
  463. X# platform:  $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
  464. X# operating system:   SunOS 3.5
  465. X
  466. XBOOTSTRAPCFLAGS =
  467. X             AS = as
  468. X             CC = cc
  469. X            CPP = /lib/cpp
  470. X             LD = ld
  471. X           LINT = lint
  472. X        INSTALL = install
  473. X           TAGS = ctags
  474. X             RM = rm -f
  475. X             MV = mv
  476. X             LN = ln -s
  477. X         RANLIB = ranlib
  478. XRANLIBINSTFLAGS = -t
  479. X             AR = ar clq
  480. X             LS = ls
  481. X       LINTOPTS = -axz
  482. X    LINTLIBFLAG = -C
  483. X           MAKE = make
  484. XSTD_CPP_DEFINES =
  485. X    STD_DEFINES =
  486. X
  487. X###########################################################################
  488. X# site-specific configuration parameters - edit site.def to change
  489. X
  490. X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
  491. X
  492. X   GCC = gcc -traditional
  493. X    CC = $(GCC)
  494. X
  495. XCC = gcc -traditional
  496. X
  497. X XWSRC = $(CONTRIBSRC)/widgets/Xhp/Xw
  498. X
  499. X XWLIB = $(USRLIBDIR)/libXw.a
  500. X
  501. X###########################################################################
  502. X# definitions common to all Makefiles - do not edit
  503. X
  504. X          SHELL =  /bin/sh
  505. X
  506. X        DESTDIR =
  507. X      USRLIBDIR = /local/lib/X11
  508. X         BINDIR = /local/bin/X11
  509. X         INCDIR = $(LIBDIR)/include
  510. X        INCROOT = $(DESTDIR)/usr/include
  511. X         ADMDIR =  /scr/Xerrors
  512. X         LIBDIR = /local/share/X11
  513. X     LINTLIBDIR = $(LIBDIR)/lint
  514. X        FONTDIR = $(LIBDIR)/fonts
  515. X       XINITDIR = $(LIBDIR)/xinit
  516. X         XDMDIR = $(LIBDIR)/xdm
  517. X         UWMDIR = $(LIBDIR)/uwm
  518. X         AWMDIR = $(LIBDIR)/awm
  519. X         TWMDIR = $(LIBDIR)/twm
  520. X        MANPATH = /local/man
  521. X  MANSOURCEPATH = $(MANPATH)/man
  522. X         MANDIR = $(MANSOURCEPATH)x
  523. X      LIBMANDIR = $(MANSOURCEPATH)3
  524. X    XAPPLOADDIR = $(LIBDIR)/app-defaults
  525. X
  526. X   INSTBINFLAGS = -m 0755
  527. X   INSTUIDFLAGS = -m 4755
  528. X   INSTLIBFLAGS = -m 0664
  529. X   INSTINCFLAGS = -m 0444
  530. X   INSTMANFLAGS = -m 0444
  531. X   INSTAPPFLAGS = -m 0444
  532. X  INSTKMEMFLAGS = -g kmem -m 2755
  533. X        FCFLAGS = -t
  534. X    CDEBUGFLAGS = -O
  535. X
  536. X        PATHSEP = /
  537. X         DEPEND = $(DEPENDSRC)/makedepend
  538. X          IMAKE = $(IMAKESRC)/imake
  539. X            RGB = $(RGBSRC)/rgb
  540. X             FC = $(BDFTOSNFSRC)/bdftosnf
  541. X      MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
  542. X      MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
  543. X
  544. X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
  545. X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
  546. X        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
  547. X            TOP = ../../../../../csri3/X.V11R3
  548. X      CLIENTSRC = $(TOP)/clients
  549. X        DEMOSRC = $(TOP)/demos
  550. X         LIBSRC = $(TOP)/lib
  551. X        FONTSRC = $(TOP)/fonts
  552. X     INCLUDESRC = $(TOP)/X11
  553. X      SERVERSRC = $(TOP)/server
  554. X        UTILSRC = $(TOP)/util
  555. X     SCRIPTSSRC = $(UTILSRC)/scripts
  556. X     EXAMPLESRC = $(TOP)/examples
  557. X     CONTRIBSRC = $(TOP)/contrib
  558. X         DOCSRC = $(TOP)/doc
  559. X         RGBSRC = $(TOP)/rgb
  560. X      DEPENDSRC = $(UTILSRC)/makedepend
  561. X       IMAKESRC = $(UTILSRC)/imake
  562. X       IRULESRC = $(UTILSRC)/imake.includes
  563. X        XLIBSRC = $(LIBSRC)/X
  564. X         XMUSRC = $(LIBSRC)/Xmu
  565. X     TOOLKITSRC = $(LIBSRC)/Xt
  566. X     AWIDGETSRC = $(LIBSRC)/Xaw
  567. X     OLDXLIBSRC = $(LIBSRC)/oldX
  568. X    BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  569. X   MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  570. X   EXTENSIONSRC = $(TOP)/extensions
  571. X
  572. X   EXTENSIONLIB = $(USRLIBDIR)/lib/libXext.a
  573. X           XLIB = $(USRLIBDIR)/libX11.a
  574. X         XMULIB = $(USRLIBDIR)/libXmu.a
  575. X        OLDXLIB = $(USRLIBDIR)/liboldX.a
  576. X       XTOOLLIB = $(USRLIBDIR)/libXt.a
  577. X         XAWLIB = $(USRLIBDIR)/libXaw.a
  578. X       INCLUDES = -I$(INCDIR) -I$(INCROOT)
  579. X
  580. X       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
  581. X        LINTXMU = $(XMUSRC)/llib-lXmu.ln
  582. X      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
  583. X        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
  584. X      MACROFILE = Sun.macros
  585. X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
  586. X            $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
  587. X  IMAKE_DEFINES =
  588. X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
  589. X            -s Makefile $(IMAKE_DEFINES)
  590. X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
  591. X            .emacs_* tags TAGS make.log MakeOut
  592. X
  593. X###########################################################################
  594. X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
  595. X
  596. X###########################################################################
  597. X# start of Imakefile
  598. X
  599. X# fonts/bdf/75dpi/devpsc/Makefile
  600. X#
  601. X# Copyright (c) 1988 Cray Research, Inc.  All Rights Reserved.
  602. X# PostScript is a trademark of Adobe Systems, Inc.
  603. X
  604. X# see README for more information
  605. X# makedev is the program that builds device descriptions
  606. X
  607. XFONTDIR = $(WIDTHDIR)/devpsc
  608. XOFILES = [A-Z].out [A-Z][0-9A-Z].out DESC.out
  609. XAFILES = [A-Z].aux [A-Z][0-9A-Z].aux
  610. XXFONTDIR = ../xfonts
  611. X
  612. XLOADFONTS = R I B BI H HB C CB S
  613. XMOREFONTS = HO HD CO CD N NI NB ND
  614. X
  615. XFONTNAMES = ${LOADFONTS} ${MOREFONTS}
  616. XFONTMAP = ${LOADMAP} ${MOREMAP}
  617. XTEMPFILES = temp.header temp.spaces temp.trailer
  618. X
  619. Xall:: DESC.out moreout
  620. X
  621. XDESC.out: DESC ${FONTNAMES}
  622. X    ${MAKEDEV} DESC
  623. X
  624. Xmoreout: ${MOREFONTS}
  625. X    ${MAKEDEV} $?
  626. X
  627. Xinstall:: all
  628. X
  629. Xinstall::
  630. X    $(MKDIRHIER)  $(FONTDIR)
  631. X
  632. Xinstall::
  633. X    @case '${MFLAGS}' in *[i]*) set +e;; esac; \
  634. X    for i in $(OFILES) $(AFILES) $(MFILES); do \
  635. X    (set -x; $(INSTALL) -c $(INSTALLFLAGS) $$i  $(FONTDIR)); \
  636. X    done
  637. X
  638. Xclean::
  639. X    rm -f ${TEMPFILES} core *.out *.font temp*
  640. X
  641. Xclobber:: clean
  642. X    rm -f [A-Z] [A-Z][A-Z] *.aux
  643. X
  644. XR:    ${XFONTDIR}/timR24.bdf
  645. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  646. XI:    ${XFONTDIR}/timI24.bdf
  647. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  648. XB:    ${XFONTDIR}/timB24.bdf
  649. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  650. XBI:    ${XFONTDIR}/timBI24.bdf
  651. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  652. XS:    ${XFONTDIR}/symb24.bdf
  653. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  654. XC:    ${XFONTDIR}/courR24.bdf
  655. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  656. XCB:    ${XFONTDIR}/courB24.bdf
  657. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  658. XCD:    ${XFONTDIR}/courBO24.bdf
  659. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  660. XCO:    ${XFONTDIR}/courO24.bdf
  661. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  662. XH:    ${XFONTDIR}/helvR24.bdf
  663. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  664. XHB:    ${XFONTDIR}/helvB24.bdf
  665. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  666. XHD:    ${XFONTDIR}/helvBO24.bdf
  667. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  668. XHO:    ${XFONTDIR}/helvO24.bdf
  669. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  670. XN:    ${XFONTDIR}/ncenR24.bdf
  671. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  672. XNB:    ${XFONTDIR}/ncenB24.bdf
  673. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  674. XND:    ${XFONTDIR}/ncenBI24.bdf
  675. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  676. XNI:    ${XFONTDIR}/ncenI24.bdf
  677. X    awk -f ${XFONTDIR}/adobe.awk $? | awk -f bdfdit.awk ; cat ${TEMPFILES} > $@; mv temp.aux $@.aux; rm ${TEMPFILES}
  678. X
  679. X###########################################################################
  680. X# Imake.tmpl common rules for all Makefiles - do not edit
  681. X
  682. Xemptyrule::
  683. X
  684. Xclean::
  685. X    $(RM_CMD) \#*
  686. X
  687. XMakefile:: $(IMAKE)
  688. X
  689. XMakefile:: Imakefile \
  690. X    $(IRULESRC)/Imake.tmpl \
  691. X    $(IRULESRC)/Imake.rules \
  692. X    $(IRULESRC)/site.def \
  693. X    $(IRULESRC)/$(MACROFILE)
  694. X    -@if [ -f Makefile ]; then \
  695. X    echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  696. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  697. X    else exit 0; fi
  698. X    $(IMAKE_CMD) -DTOPDIR=$(TOP)
  699. X
  700. X$(IMAKE):
  701. X    @echo "making $@"; \
  702. X    cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
  703. X
  704. Xtags::
  705. X    $(TAGS) -w *.[ch]
  706. X    $(TAGS) -xw *.[ch] > TAGS
  707. X
  708. X###########################################################################
  709. X# empty rules for directories that do not have SUBDIRS - do not edit
  710. X
  711. Xinstall::
  712. X    @echo "install done"
  713. X
  714. Xinstall.man::
  715. X    @echo "install.man done"
  716. X
  717. XMakefiles::
  718. X
  719. X###########################################################################
  720. X# dependencies generated by makedepend
  721. X
  722. END_OF_FILE
  723. if test 10120 -ne `wc -c <'xtroff/devpsc/Makefile'`; then
  724.     echo shar: \"'xtroff/devpsc/Makefile'\" unpacked with wrong size!
  725. fi
  726. # end of 'xtroff/devpsc/Makefile'
  727. fi
  728. if test -f 'xtroff/draw.c' -a "${1}" != "-c" ; then 
  729.   echo shar: Will not clobber existing file \"'xtroff/draw.c'\"
  730. else
  731. echo shar: Extracting \"'xtroff/draw.c'\" \(8188 characters\)
  732. sed "s/^X//" >'xtroff/draw.c' <<'END_OF_FILE'
  733. X/*
  734. X *    SunTroff -  A program to display the output of Device Independent
  735. X *        Troff as a window on a Sun Workstation.
  736. X *
  737. X *    Troff_draw.c - Code to do the draw the simple stuff in the page
  738. X *        bit map.
  739. X *
  740. X *    Authors - The original version of this program was written by
  741. X *            Richard L. Hyde (Purdue)
  742. X *            David Slattengren (Berkeley)
  743. X *        It was nearly all rewritten, cleaned up and a more elegant
  744. X *        user interface installed by
  745. X *            Malcolm Slaney (Schlumberger Palo Alto Research)
  746. X *        Combine characters into words
  747. X *            David Cahlander (Cray Research, Inc.)
  748. X *
  749. X *    Legalese -  This command was developed as an independent project
  750. X *        to satisfy a need of the author.  This program may contain
  751. X *        bugs and the user is cautioned to independently verify that
  752. X *        the program is suitable for the user's intended purpose.
  753. X *        The program is made available on an ``as is'' basis with
  754. X *        all faults and without any implied or expressed warranties
  755. X *        or support from either the author, Malcolm Slaney, or
  756. X *        Schlumberger Palo Alto Research Laboratory.
  757. X *
  758. X *        I am putting this program in the public domain.  You are
  759. X *        free to use it as you wish.  In return I ask two things.
  760. X *        First, that you do not remove the names of the authors
  761. X *        from this work.  Secondly, if you make changes or
  762. X *        improvements to this program that you pass these back to
  763. X *        the author so that everybody can benefit from the
  764. X *        improvements.
  765. X *
  766. X *                    Malcolm Slaney  (December 1986)
  767. X *                    Schlumberger Palo Alto Research
  768. X *                    3340 Hillview Avenue
  769. X *                    Palo Alto, CA 94304
  770. X *                    (415) 496-4669
  771. X *                    spar!malcolm@decwrl.dec.com
  772. X *                    malcolm@ecn.purdue.edu
  773. X *                    malcolm@spar.slb.com (Someday)
  774. X */
  775. X
  776. X#include    "suntroff.h"
  777. X#ifdef SUNTOOLS
  778. X#include    <suntool/sunview.h>
  779. X#include    <suntool/panel.h>
  780. X#include    <suntool/canvas.h>
  781. X#include    <suntool/scrollbar.h>
  782. X
  783. Xextern    Frame    BaseFrame;        /* Top Level Window Frame */
  784. Xextern    Canvas    DrawingCanvas;        /* Main Drawing Window for Text */
  785. Xextern    Menu    MainMenu;        /* Top Level User Menu */
  786. X#else SUNTOOLS
  787. X#include <X11/Intrinsic.h>
  788. X#include <math.h>
  789. Xextern Window DrawingCanvas;
  790. Xextern Widget CanvasWidget;
  791. Xextern Display *dpy;
  792. Xextern GC gc;
  793. Xextern GC fillgc;
  794. Xextern GC cleargc;
  795. Xextern Pixmap PagePixRect;
  796. Xextern int ViewTop, ViewLeft, ViewHeight, ViewWidth;
  797. Xextern int SUNRES;
  798. X#endif SUNTOOLS
  799. Xextern    int    DisplayOutput;        /* Display the output for user? */
  800. X
  801. X#define    FastScale(x)    (((x) * SUNRES) / UserTypesetter->Device.res)
  802. X
  803. XScale(x)
  804. Xint    x;
  805. X{
  806. X    return(((x) * SUNRES) / UserTypesetter->Device.res);
  807. X}
  808. X
  809. XClearPage(){
  810. X#ifdef DEBUG
  811. X    printf("clearing page\n");
  812. X#endif /* DEBUG */
  813. X#ifdef SUNTOOLS
  814. X    extern struct pixrect *PagePixRect;
  815. X
  816. X    pr_rop(PagePixRect,0,0,1000000,1000000,PIX_CLR,NULL,0,0);
  817. X#else /* !SUNTOOLS */
  818. X    XFillRectangle(dpy, PagePixRect, cleargc, 0, 0, 
  819. X     (unsigned int) PAGE_PIXEL_WIDTH, (unsigned int) PAGE_PIXEL_HEIGHT);
  820. X#endif /* !SUNTOOLS */
  821. X}
  822. X
  823. XRefreshPage(){
  824. X#ifdef DEBUG
  825. X    printf("refreshing page\n");
  826. X#endif
  827. X#ifdef SUNTOOLS
  828. X    RepaintCanvas(DrawingCanvas,canvas_pixwin(DrawingCanvas),0);    
  829. X#else
  830. X    RepaintCanvas(CanvasWidget, (caddr_t) NULL, (XEvent *) NULL);
  831. X#endif 
  832. X}
  833. X
  834. XDrawString(x,y,s)
  835. Xint    x, y;
  836. Xchar    *s;
  837. X{
  838. X    if (!CurrentFont)
  839. X        fatal("Don't have a Current Font.\n");
  840. X
  841. X    if (!CurrentFont->Bits)
  842. X        fatal("Don't have the bits for the Current Font.\n");
  843. X
  844. X    XDrawString(dpy, PagePixRect, gc, FastScale(x), FastScale(y), s, strlen(s));
  845. X}
  846. X
  847. X/*ARGSUSED*/
  848. XDrawCharacter(x,y,c,cwidth)
  849. Xint    x, y, c, cwidth;
  850. X{
  851. X#ifdef SUNTOOLS
  852. X    struct pr_prpos where;
  853. X    char    Text[2];
  854. X    extern struct pixrect *PagePixRect;
  855. X
  856. X    if (!CurrentFont){
  857. X        fatal("Don't have a Current Font.\n");
  858. X    }
  859. X
  860. X    if (!CurrentFont->Bits){
  861. X        fatal("Don't have the bits for the Current Font.\n");
  862. X    }
  863. X
  864. X    where.pos.x = FastScale(x);
  865. X    where.pos.y = FastScale(y);
  866. X    where.pr = PagePixRect;
  867. X
  868. X    Text[0] = c;
  869. X    Text[1] = 0;
  870. X
  871. X    if (DisplayOutput)
  872. X        pf_text(where,PIX_SRC|PIX_DST,CurrentFont->Bits,Text);
  873. X#else
  874. X    static char s[2] = " ";
  875. X    int dx = 0;
  876. X    
  877. X    if (!CurrentFont){
  878. X        fatal("Don't have a Current Font.\n");
  879. X    }
  880. X
  881. X    if (!CurrentFont->Bits){
  882. X        fatal("Don't have the bits for the Current Font.\n");
  883. X    }
  884. X
  885. X    if (DisplayOutput) {
  886. X        s[0] = c;
  887. X#ifndef NOADJUST
  888. X        /* 
  889. X         *  This kludge tries to centre the X char within the
  890. X         *  troff char space. Looks a bit better. Thanks to Dave
  891. X         *  Blythe, U of Toronto.
  892. X         */
  893. X        dx = (CurrentFont->Bits->per_char)? 
  894. X         CurrentFont->Bits->per_char[c-1].width : 
  895. X         CurrentFont->Bits->min_bounds.width;
  896. X        dx = (FastScale(cwidth) - dx)/2;
  897. X#ifdef FONTDEBUG
  898. X        printf("char \"%c\"(0x%x), dx = %d, xwid = %d (lb,rb = %d,%d), cwid = %d (%d scaled)\n",
  899. X         c, c, dx, CurrentFont->Bits->per_char[c-1].width,
  900. X         CurrentFont->Bits->per_char[c-1].lbearing,
  901. X         CurrentFont->Bits->per_char[c-1].rbearing,
  902. X         cwidth, FastScale(cwidth));
  903. X#endif
  904. X#endif NOADJUST
  905. X        XDrawString(dpy, PagePixRect, gc, 
  906. X         FastScale(x) + dx, 
  907. X         FastScale(y), s, 1);
  908. X    }
  909. X#endif
  910. X}
  911. X
  912. X
  913. XDrawLine(x,y)
  914. X{
  915. X    if (DisplayOutput)
  916. X#ifdef SUNTOOLS
  917. X        pr_vector(PagePixRect,
  918. X              FastScale(HorizontalPosition),
  919. X              FastScale(VerticalPosition),
  920. X              FastScale(HorizontalPosition+x),
  921. X              FastScale(VerticalPosition+y),
  922. X              PIX_SET,1);
  923. X#else /* !SUNTOOLS */
  924. X#ifdef DEBUG
  925. X        printf("Drawline to %d, %d\n", FastScale(HorizontalPosition + x), FastScale(VerticalPosition + y));
  926. X#endif /* DEBUG */
  927. X        XDrawLine(dpy, PagePixRect, gc, 
  928. X              FastScale(HorizontalPosition),
  929. X              FastScale(VerticalPosition),
  930. X              FastScale(HorizontalPosition+x),
  931. X              FastScale(VerticalPosition+y));
  932. X#endif /* !SUNTOOLS */
  933. X    HorizontalPosition += x;
  934. X    VerticalPosition += y;
  935. X}
  936. X
  937. X#ifndef SUNTOOLS
  938. Xbox(x1, y1, x2, y2)
  939. Xfloat    x1, y1, x2, y2;
  940. X{
  941. X    int i1, j1, i2, j2;
  942. X
  943. X    i1 = round(ditsiz * x1);
  944. X    j1 = round(ditsiz * y1);
  945. X    i2 = round(ditsiz * x2);
  946. X    j2 = round(ditsiz * y2);
  947. X    XFillRectangle(dpy, PagePixRect, gc, 
  948. X        FastScale(HorizontalPosition) + i1,
  949. X        FastScale(VerticalPosition) + j1,
  950. X        (unsigned int) (i2 - i1), (unsigned int) (j2 - j1));
  951. X}
  952. X
  953. Xline(x1, y1, x2, y2)
  954. Xfloat    x1, y1, x2, y2;
  955. X{
  956. X    int i1, j1, i2, j2;
  957. X
  958. X    i1 = round(ditsiz * x1);
  959. X    j1 = round(ditsiz * y1);
  960. X    i2 = round(ditsiz * x2);
  961. X    j2 = round(ditsiz * y2);
  962. X    XDrawLine(dpy, PagePixRect, gc, 
  963. X        FastScale(HorizontalPosition) + i1,
  964. X        FastScale(VerticalPosition) + j1,
  965. X        FastScale(HorizontalPosition) + i2,
  966. X        FastScale(VerticalPosition) + j2);
  967. X}
  968. X
  969. Xround(x)
  970. Xfloat    x;
  971. X{
  972. X    if (x < 0)
  973. X        return(x - .5);
  974. X    else
  975. X        return(x + .5);
  976. X}
  977. X
  978. Xdraw_fraction(num, den, size)
  979. Xchar num, den;
  980. Xint size;
  981. X{
  982. X    char s[2];
  983. X
  984. X    SetFontSize(round(0.6 * size));
  985. X    LoadFontBits();
  986. X    s[0] = num;
  987. X    XDrawString(dpy, PagePixRect, gc,
  988. X     FastScale(HorizontalPosition), 
  989. X     FastScale(VerticalPosition) - round(0.3 * size), s, 1);
  990. X    s[0] = den;
  991. X    XDrawString(dpy, PagePixRect, gc,
  992. X     FastScale(HorizontalPosition) + round(0.5 * size),
  993. X     FastScale(VerticalPosition), s, 1);
  994. X    SetFontSize(size);
  995. X    LoadFontBits();
  996. X    s[0] = '\244';
  997. X    XDrawString(dpy, PagePixRect, gc,
  998. X     FastScale(HorizontalPosition) + round(.16 * ditsiz), 
  999. X     FastScale(VerticalPosition), s, 1);
  1000. X}
  1001. X
  1002. X
  1003. X#endif /*SUNTOOLS*/
  1004. X
  1005. Xpoint(x,y)
  1006. Xint    x, y;
  1007. X{
  1008. X    if (DisplayOutput)
  1009. X#ifdef SUNTOOLS
  1010. X        pr_put(PagePixRect,x,y,1);
  1011. X#else
  1012. X        XDrawPoint(dpy, PagePixRect, gc, x, y);
  1013. X#endif
  1014. X}
  1015. X
  1016. X#ifndef SUNTOOLS
  1017. X/*
  1018. X *  draw a circle
  1019. X *    x1 - x position in character box (0. - 1.)
  1020. X *    y1 - y position in character box (0. - 1.)
  1021. X *    r  - radius of arc (0. - 1.)
  1022. X *    fill - TRUE if filled circle
  1023. X */
  1024. X
  1025. Xcircle(x1, y1, r, fill)
  1026. Xfloat    x1, y1, r;
  1027. Xint    fill;
  1028. X{
  1029. X    arc(x1, y1, r, 0, 360, fill);
  1030. X}
  1031. X
  1032. X/*
  1033. X *  draw an arc
  1034. X *    x1 - x position in character box (0. - 1.)
  1035. X *    y1 - y position in character box (0. - 1.)
  1036. X *    r  - radius of arc (0. - 1.)
  1037. X *    a1 - start angle of arc (degrees)
  1038. X *    a2 - length of arc (degrees)
  1039. X *    fill - TRUE if filled arc
  1040. X */
  1041. X
  1042. Xarc(x1, y1, r, a1, a2, fill)
  1043. Xfloat    x1, y1, r;
  1044. Xint    a1, a2;
  1045. Xint    fill;
  1046. X{
  1047. X    int i1, j1, r1;
  1048. X
  1049. X    i1 = round(ditsiz * x1);
  1050. X    j1 = round(ditsiz * y1);
  1051. X    r1 = round(ditsiz * r);
  1052. X    if (fill)
  1053. X        XFillArc(dpy, PagePixRect, fillgc,
  1054. X            FastScale(HorizontalPosition) + i1 - r1,
  1055. X            FastScale(VerticalPosition) + j1 - r1,
  1056. X            (unsigned int) (2 * r1), (unsigned int) (2 * r1),
  1057. X            a1 * 64, a2 * 64);
  1058. X    else
  1059. X        XDrawArc(dpy, PagePixRect, gc,
  1060. X            FastScale(HorizontalPosition) + i1 - r1,
  1061. X            FastScale(VerticalPosition) + j1 - r1,
  1062. X            (unsigned int) (2 * r1), (unsigned int) (2 * r1),
  1063. X            a1 * 64, a2 * 64);
  1064. X}
  1065. X#endif /*SUNTOOLS*/
  1066. END_OF_FILE
  1067. if test 8188 -ne `wc -c <'xtroff/draw.c'`; then
  1068.     echo shar: \"'xtroff/draw.c'\" unpacked with wrong size!
  1069. fi
  1070. # end of 'xtroff/draw.c'
  1071. fi
  1072. if test -f 'xtroff/fontstuff/Makefile' -a "${1}" != "-c" ; then 
  1073.   echo shar: Will not clobber existing file \"'xtroff/fontstuff/Makefile'\"
  1074. else
  1075. echo shar: Extracting \"'xtroff/fontstuff/Makefile'\" \(9877 characters\)
  1076. sed "s/^X//" >'xtroff/fontstuff/Makefile' <<'END_OF_FILE'
  1077. X# Makefile generated by imake - do not edit!
  1078. X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
  1079. X#
  1080. X# The cpp used on this machine replaces all newlines and multiple tabs and
  1081. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  1082. X# for this, but is not always successful.
  1083. X#
  1084. X
  1085. X###########################################################################
  1086. X# X Window System Makefile generated from template file Imake.tmpl
  1087. X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
  1088. X#
  1089. X# Do not change the body of the imake template file.  Server-specific
  1090. X# parameters may be set in the appropriate .macros file; site-specific
  1091. X# parameters (but shared by all servers) may be set in site.def.  If you
  1092. X# make any changes, you'll need to rebuild the makefiles using
  1093. X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
  1094. X# the top level directory.
  1095. X#
  1096. X# If your C preprocessor doesn't define any unique symbols, you'll need
  1097. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  1098. X# "make Makefile", "make Makefiles", or "make World").
  1099. X#
  1100. X# If you absolutely can't get imake to work, you'll need to set the
  1101. X# variables at the top of each Makefile as well as the dependencies at the
  1102. X# bottom (makedepend will do this automatically).
  1103. X#
  1104. X
  1105. X###########################################################################
  1106. X# platform-specific configuration parameters - edit Sun.macros to change
  1107. X
  1108. X# platform:  $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
  1109. X# operating system:   SunOS 3.5
  1110. X
  1111. XBOOTSTRAPCFLAGS =
  1112. X             AS = as
  1113. X             CC = cc
  1114. X            CPP = /lib/cpp
  1115. X             LD = ld
  1116. X           LINT = lint
  1117. X        INSTALL = install
  1118. X           TAGS = ctags
  1119. X             RM = rm -f
  1120. X             MV = mv
  1121. X             LN = ln -s
  1122. X         RANLIB = ranlib
  1123. XRANLIBINSTFLAGS = -t
  1124. X             AR = ar clq
  1125. X             LS = ls
  1126. X       LINTOPTS = -axz
  1127. X    LINTLIBFLAG = -C
  1128. X           MAKE = make
  1129. XSTD_CPP_DEFINES =
  1130. X    STD_DEFINES =
  1131. X
  1132. X###########################################################################
  1133. X# site-specific configuration parameters - edit site.def to change
  1134. X
  1135. X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
  1136. X
  1137. X   GCC = gcc -traditional
  1138. X    CC = $(GCC)
  1139. X
  1140. XCC = gcc -traditional
  1141. X
  1142. X XWSRC = $(CONTRIBSRC)/widgets/Xhp/Xw
  1143. X
  1144. X XWLIB = $(USRLIBDIR)/libXw.a
  1145. X
  1146. X###########################################################################
  1147. X# definitions common to all Makefiles - do not edit
  1148. X
  1149. X          SHELL =  /bin/sh
  1150. X
  1151. X        DESTDIR =
  1152. X      USRLIBDIR = /local/lib/X11
  1153. X         BINDIR = /local/bin/X11
  1154. X         INCDIR = $(LIBDIR)/include
  1155. X        INCROOT = $(DESTDIR)/usr/include
  1156. X         ADMDIR =  /scr/Xerrors
  1157. X         LIBDIR = /local/share/X11
  1158. X     LINTLIBDIR = $(LIBDIR)/lint
  1159. X        FONTDIR = $(LIBDIR)/fonts
  1160. X       XINITDIR = $(LIBDIR)/xinit
  1161. X         XDMDIR = $(LIBDIR)/xdm
  1162. X         UWMDIR = $(LIBDIR)/uwm
  1163. X         AWMDIR = $(LIBDIR)/awm
  1164. X         TWMDIR = $(LIBDIR)/twm
  1165. X        MANPATH = /local/man
  1166. X  MANSOURCEPATH = $(MANPATH)/man
  1167. X         MANDIR = $(MANSOURCEPATH)x
  1168. X      LIBMANDIR = $(MANSOURCEPATH)3
  1169. X    XAPPLOADDIR = $(LIBDIR)/app-defaults
  1170. X
  1171. X   INSTBINFLAGS = -m 0755
  1172. X   INSTUIDFLAGS = -m 4755
  1173. X   INSTLIBFLAGS = -m 0664
  1174. X   INSTINCFLAGS = -m 0444
  1175. X   INSTMANFLAGS = -m 0444
  1176. X   INSTAPPFLAGS = -m 0444
  1177. X  INSTKMEMFLAGS = -g kmem -m 2755
  1178. X        FCFLAGS = -t
  1179. X    CDEBUGFLAGS = -O
  1180. X
  1181. X        PATHSEP = /
  1182. X         DEPEND = $(DEPENDSRC)/makedepend
  1183. X          IMAKE = $(IMAKESRC)/imake
  1184. X            RGB = $(RGBSRC)/rgb
  1185. X             FC = $(BDFTOSNFSRC)/bdftosnf
  1186. X      MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
  1187. X      MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
  1188. X
  1189. X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
  1190. X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
  1191. X        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
  1192. X            TOP = ../../../../../csri3/X.V11R3
  1193. X      CLIENTSRC = $(TOP)/clients
  1194. X        DEMOSRC = $(TOP)/demos
  1195. X         LIBSRC = $(TOP)/lib
  1196. X        FONTSRC = $(TOP)/fonts
  1197. X     INCLUDESRC = $(TOP)/X11
  1198. X      SERVERSRC = $(TOP)/server
  1199. X        UTILSRC = $(TOP)/util
  1200. X     SCRIPTSSRC = $(UTILSRC)/scripts
  1201. X     EXAMPLESRC = $(TOP)/examples
  1202. X     CONTRIBSRC = $(TOP)/contrib
  1203. X         DOCSRC = $(TOP)/doc
  1204. X         RGBSRC = $(TOP)/rgb
  1205. X      DEPENDSRC = $(UTILSRC)/makedepend
  1206. X       IMAKESRC = $(UTILSRC)/imake
  1207. X       IRULESRC = $(UTILSRC)/imake.includes
  1208. X        XLIBSRC = $(LIBSRC)/X
  1209. X         XMUSRC = $(LIBSRC)/Xmu
  1210. X     TOOLKITSRC = $(LIBSRC)/Xt
  1211. X     AWIDGETSRC = $(LIBSRC)/Xaw
  1212. X     OLDXLIBSRC = $(LIBSRC)/oldX
  1213. X    BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  1214. X   MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  1215. X   EXTENSIONSRC = $(TOP)/extensions
  1216. X
  1217. X   EXTENSIONLIB = $(USRLIBDIR)/lib/libXext.a
  1218. X           XLIB = $(USRLIBDIR)/libX11.a
  1219. X         XMULIB = $(USRLIBDIR)/libXmu.a
  1220. X        OLDXLIB = $(USRLIBDIR)/liboldX.a
  1221. X       XTOOLLIB = $(USRLIBDIR)/libXt.a
  1222. X         XAWLIB = $(USRLIBDIR)/libXaw.a
  1223. X       INCLUDES = -I$(INCDIR) -I$(INCROOT)
  1224. X
  1225. X       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
  1226. X        LINTXMU = $(XMUSRC)/llib-lXmu.ln
  1227. X      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
  1228. X        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
  1229. X      MACROFILE = Sun.macros
  1230. X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
  1231. X            $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
  1232. X  IMAKE_DEFINES =
  1233. X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
  1234. X            -s Makefile $(IMAKE_DEFINES)
  1235. X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
  1236. X            .emacs_* tags TAGS make.log MakeOut
  1237. X
  1238. X###########################################################################
  1239. X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
  1240. X
  1241. X###########################################################################
  1242. X# start of Imakefile
  1243. X
  1244. X#    Not standalone - it gets a lot of variables from the invocation.
  1245. X#    VFONTS, RSTFONTS, SUNTROFF_FONTS, PERCENT, PREVIEWER, FC
  1246. X
  1247. XDEFINES=-DVFONTDIR=\"$(VFONTS)\" -DRSTFONTDIR=\"$(RSTFONTS)\"
  1248. XSRCS = vft2ch.c ch2vft.c ch2rst.c rst2ch.c scalech.c vf2bdf.c
  1249. X
  1250. Xall: vft2ch ch2vft ch2rst rst2ch scalech vf2bdf
  1251. X
  1252. Xvft2ch: vft2ch.o
  1253. X    $(RM) $@
  1254. X    $(CC) -o $@ vft2ch.o  $(LDFLAGS)  $(SYSLAST_LIBRARIES)
  1255. X
  1256. Xrelink::
  1257. X    $(RM) vft2ch
  1258. X    $(MAKE) $(MFLAGS) vft2ch
  1259. X
  1260. Xclean::
  1261. X    $(RM) vft2ch
  1262. X
  1263. Xinstall:: vft2ch
  1264. X    $(INSTALL) -c $(INSTALLFLAGS) vft2ch  $(BINDIR)
  1265. X
  1266. Xinstall.man:: vft2ch.man
  1267. X    $(INSTALL) -c $(INSTMANFLAGS) vft2ch.man  $(MANDIR)/vft2ch.x
  1268. X
  1269. Xch2vft: ch2vft.o
  1270. X    $(RM) $@
  1271. X    $(CC) -o $@ ch2vft.o  $(LDFLAGS)  $(SYSLAST_LIBRARIES)
  1272. X
  1273. Xrelink::
  1274. X    $(RM) ch2vft
  1275. X    $(MAKE) $(MFLAGS) ch2vft
  1276. X
  1277. Xclean::
  1278. X    $(RM) ch2vft
  1279. X
  1280. Xinstall:: ch2vft
  1281. X    $(INSTALL) -c $(INSTALLFLAGS) ch2vft  $(BINDIR)
  1282. X
  1283. Xinstall.man:: ch2vft.man
  1284. X    $(INSTALL) -c $(INSTMANFLAGS) ch2vft.man  $(MANDIR)/ch2vft.x
  1285. X
  1286. Xch2rst: ch2rst.o
  1287. X    $(RM) $@
  1288. X    $(CC) -o $@ ch2rst.o  $(LDFLAGS)  $(SYSLAST_LIBRARIES)
  1289. X
  1290. Xrelink::
  1291. X    $(RM) ch2rst
  1292. X    $(MAKE) $(MFLAGS) ch2rst
  1293. X
  1294. Xclean::
  1295. X    $(RM) ch2rst
  1296. X
  1297. Xinstall:: ch2rst
  1298. X    $(INSTALL) -c $(INSTALLFLAGS) ch2rst  $(BINDIR)
  1299. X
  1300. Xinstall.man:: ch2rst.man
  1301. X    $(INSTALL) -c $(INSTMANFLAGS) ch2rst.man  $(MANDIR)/ch2rst.x
  1302. X
  1303. Xrst2ch: rst2ch.o
  1304. X    $(RM) $@
  1305. X    $(CC) -o $@ rst2ch.o  $(LDFLAGS)  $(SYSLAST_LIBRARIES)
  1306. X
  1307. Xrelink::
  1308. X    $(RM) rst2ch
  1309. X    $(MAKE) $(MFLAGS) rst2ch
  1310. X
  1311. Xclean::
  1312. X    $(RM) rst2ch
  1313. X
  1314. Xinstall:: rst2ch
  1315. X    $(INSTALL) -c $(INSTALLFLAGS) rst2ch  $(BINDIR)
  1316. X
  1317. Xinstall.man:: rst2ch.man
  1318. X    $(INSTALL) -c $(INSTMANFLAGS) rst2ch.man  $(MANDIR)/rst2ch.x
  1319. X
  1320. Xscalech: scalech.o
  1321. X    $(RM) $@
  1322. X    $(CC) -o $@ scalech.o  $(LDFLAGS)  $(SYSLAST_LIBRARIES)
  1323. X
  1324. Xrelink::
  1325. X    $(RM) scalech
  1326. X    $(MAKE) $(MFLAGS) scalech
  1327. X
  1328. Xclean::
  1329. X    $(RM) scalech
  1330. X
  1331. Xinstall:: scalech
  1332. X    $(INSTALL) -c $(INSTALLFLAGS) scalech  $(BINDIR)
  1333. X
  1334. Xinstall.man:: scalech.man
  1335. X    $(INSTALL) -c $(INSTMANFLAGS) scalech.man  $(MANDIR)/scalech.x
  1336. X
  1337. Xvf2bdf: vf2bdf.o
  1338. X    $(RM) $@
  1339. X    $(CC) -o $@ vf2bdf.o  $(LDFLAGS)  $(SYSLAST_LIBRARIES)
  1340. X
  1341. Xrelink::
  1342. X    $(RM) vf2bdf
  1343. X    $(MAKE) $(MFLAGS) vf2bdf
  1344. X
  1345. Xclean::
  1346. X    $(RM) vf2bdf
  1347. X
  1348. Xinstall:: vf2bdf
  1349. X    $(INSTALL) -c $(INSTALLFLAGS) vf2bdf  $(BINDIR)
  1350. X
  1351. Xinstall.man:: vf2bdf.man
  1352. X    $(INSTALL) -c $(INSTMANFLAGS) vf2bdf.man  $(MANDIR)/vf2bdf.x
  1353. X
  1354. Xdepend:: $(DEPEND)
  1355. X
  1356. Xdepend::
  1357. X    $(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
  1358. X
  1359. X$(DEPEND):
  1360. X    @echo "making $@"; \
  1361. X    cd $(DEPENDSRC); $(MAKE)
  1362. X
  1363. X#        The two scripts check for suntroff or xtroff.
  1364. Xsunfonts:    ch2vft ch2rst vft2ch rst2ch scalech vf2bdf
  1365. X        if test -d ${VFONTS}; then \
  1366. X            ./MakeSunFonts ${VFONTS} ${SUNTROFF_FONTS} \
  1367. X            ${SUNPERCENT} ${PREVIEWER} ${FC} ${SUNDEVICE}; fi
  1368. X
  1369. Xrstfonts:
  1370. X        if test -d ${RSTFONTS}; then \
  1371. X            ./MakeImFonts ${RSTFONTS} ${SUNTROFF_FONTS} \
  1372. X            ${RSTPERCENT} ${PREVIEWER} ${FC} ${RSTDEVICE}; fi
  1373. X
  1374. X###########################################################################
  1375. X# Imake.tmpl common rules for all Makefiles - do not edit
  1376. X
  1377. Xemptyrule::
  1378. X
  1379. Xclean::
  1380. X    $(RM_CMD) \#*
  1381. X
  1382. XMakefile:: $(IMAKE)
  1383. X
  1384. XMakefile:: Imakefile \
  1385. X    $(IRULESRC)/Imake.tmpl \
  1386. X    $(IRULESRC)/Imake.rules \
  1387. X    $(IRULESRC)/site.def \
  1388. X    $(IRULESRC)/$(MACROFILE)
  1389. X    -@if [ -f Makefile ]; then \
  1390. X    echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  1391. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  1392. X    else exit 0; fi
  1393. X    $(IMAKE_CMD) -DTOPDIR=$(TOP)
  1394. X
  1395. X$(IMAKE):
  1396. X    @echo "making $@"; \
  1397. X    cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
  1398. X
  1399. Xtags::
  1400. X    $(TAGS) -w *.[ch]
  1401. X    $(TAGS) -xw *.[ch] > TAGS
  1402. X
  1403. X###########################################################################
  1404. X# empty rules for directories that do not have SUBDIRS - do not edit
  1405. X
  1406. Xinstall::
  1407. X    @echo "install done"
  1408. X
  1409. Xinstall.man::
  1410. X    @echo "install.man done"
  1411. X
  1412. XMakefiles::
  1413. X
  1414. X###########################################################################
  1415. X# dependencies generated by makedepend
  1416. X
  1417. X# DO NOT DELETE
  1418. X
  1419. Xvft2ch.o: /usr/include/stdio.h /usr/include/ctype.h /usr/include/vfont.h
  1420. Xch2vft.o: /usr/include/stdio.h /usr/include/ctype.h /usr/include/vfont.h
  1421. Xch2rst.o: /usr/include/stdio.h /usr/include/ctype.h rst.h
  1422. Xrst2ch.o: /usr/include/stdio.h /usr/include/ctype.h rst.h
  1423. Xscalech.o: /usr/include/stdio.h /usr/include/ctype.h
  1424. Xvf2bdf.o: /usr/include/stdio.h /usr/include/vfont.h /usr/include/sys/types.h
  1425. Xvf2bdf.o: /usr/include/sys/sysmacros.h
  1426. END_OF_FILE
  1427. if test 9877 -ne `wc -c <'xtroff/fontstuff/Makefile'`; then
  1428.     echo shar: \"'xtroff/fontstuff/Makefile'\" unpacked with wrong size!
  1429. fi
  1430. # end of 'xtroff/fontstuff/Makefile'
  1431. fi
  1432. if test -f 'xtroff/parse.c' -a "${1}" != "-c" ; then 
  1433.   echo shar: Will not clobber existing file \"'xtroff/parse.c'\"
  1434. else
  1435. echo shar: Extracting \"'xtroff/parse.c'\" \(8018 characters\)
  1436. sed "s/^X//" >'xtroff/parse.c' <<'END_OF_FILE'
  1437. X/*
  1438. X *    SunTroff -  A program to display the output of Device Independent
  1439. X *        Troff as a window on a Sun Workstation.
  1440. X *
  1441. X *    Troff_parse.c - Parse the device independent troff file.  All
  1442. X *        the real work of drawing the bits is done by other
  1443. X *        files.
  1444. X *
  1445. X *    Authors - The original version of this program was written by
  1446. X *            Richard L. Hyde (Purdue)
  1447. X *            David Slattengren (Berkeley)
  1448. X *        It was nearly all rewritten, cleaned up and a more elegant
  1449. X *        user interface installed by
  1450. X *            Malcolm Slaney (Schlumberger Palo Alto Research)
  1451. X *        Combine characters into words
  1452. X *            David Cahlander (Cray Research, Inc.)
  1453. X *
  1454. X *    Legalese -  This command was developed as an independent project
  1455. X *        to satisfy a need of the author.  This program may contain
  1456. X *        bugs and the user is cautioned to independently verify that
  1457. X *        the program is suitable for the user's intended purpose.
  1458. X *        The program is made available on an ``as is'' basis with
  1459. X *        all faults and without any implied or expressed warranties
  1460. X *        or support from either the author, Malcolm Slaney, or
  1461. X *        Schlumberger Palo Alto Research Laboratory.
  1462. X *
  1463. X *        I am putting this program in the public domain.  You are
  1464. X *        free to use it as you wish.  In return I ask two things.
  1465. X *        First, that you do not remove the names of the authors
  1466. X *        from this work.  Secondly, if you make changes or
  1467. X *        improvements to this program that you pass these back to
  1468. X *        the author so that everybody can benefit from the
  1469. X *        improvements.
  1470. X *
  1471. X *                    Malcolm Slaney  (December 1986)
  1472. X *                    Schlumberger Palo Alto Research
  1473. X *                    3340 Hillview Avenue
  1474. X *                    Palo Alto, CA 94304
  1475. X *                    (415) 496-4669
  1476. X *                    spar!malcolm@decwrl.dec.com
  1477. X *                    malcolm@ecn.purdue.edu
  1478. X *                    malcolm@spar.slb.com (Someday)
  1479. X */
  1480. X
  1481. X#include    "suntroff.h"
  1482. X
  1483. Xstatic int StopSeen = 0;
  1484. X
  1485. Xextern char *GetWord(), *GetLine();
  1486. X
  1487. XParseInput()
  1488. X{
  1489. X    int    n, k, c;
  1490. X    char    Buffer[BUFSIZ];
  1491. X
  1492. X    StopSeen = 0;
  1493. X
  1494. X    for (;;) {
  1495. X        if ((c = GetChar()) != EOF) {
  1496. X            switch (c) {
  1497. X            case '\n':    
  1498. X                LineNumber++;
  1499. X                break;
  1500. X            case ' ':    /* when input is text */
  1501. X            case 0:        /* occasional noise creeps in */
  1502. X                break;
  1503. X            case '{':    /* push down current environment */
  1504. X                push_env();
  1505. X                break;
  1506. X            case '}':
  1507. X                pop_env();
  1508. X                break;
  1509. X                    /* two motion digits plus a
  1510. X                       character */
  1511. X            case '0': case '1': case '2': case '3': case '4':
  1512. X            case '5': case '6': case '7': case '8': case '9':
  1513. X                HorizontalMove((c-'0')*10 + GetChar()-'0');
  1514. X                PutCharacter(GetChar());
  1515. X                break;
  1516. X            case 'c':    /* single ascii character */
  1517. X                PutCharacterString();
  1518. X                break;
  1519. X            case 'C':
  1520. X                GetWord(Buffer, BUFSIZ);
  1521. X                PutSpecialCharacter(Buffer);
  1522. X                break;
  1523. X#ifdef    BEZERKELYISM
  1524. X            case 't':    /* straight text */
  1525. X            {
  1526. X                char    *s, c;
  1527. X
  1528. X                if (GetLine(Buffer,BUFSIZ) == NULL){
  1529. X                    fatal("unexpected end of input");
  1530. X                }
  1531. X
  1532. X                s = Buffer;
  1533. X
  1534. X                while ((c = *s++) != '\n') {
  1535. X                    if (c == '\\') {
  1536. X                        switch (c = *s++) {
  1537. X                        case '\\':
  1538. X                        case 'e':
  1539. X                            PutCharacter('\\');
  1540. X                            break;
  1541. X                        case '(':
  1542. X                        {
  1543. X                            char str[3];
  1544. X
  1545. X                            str[0] = *s++;
  1546. X                            str[1] = *s++;
  1547. X                            str[2] = '\0';
  1548. X                            PutSpecialCharacter(str);
  1549. X                            break;
  1550. X                        }
  1551. X                        }
  1552. X                    } else {
  1553. X                        PutCharacter(c);
  1554. X                    }
  1555. X                    /*hmot((int)hscale);*/
  1556. X                }
  1557. X                break;
  1558. X            }
  1559. X#endif    BEZERKELYISM                
  1560. X            case 'D':    /* draw function */
  1561. X                GetLine(Buffer, BUFSIZ);
  1562. X                ParseDrawFunction(Buffer);
  1563. X                break;
  1564. X            case 's':
  1565. X                    /* ignore fractional sizes */
  1566. X                n = GetNumber();
  1567. X                SetFontSize(n);
  1568. X                break;
  1569. X            case 'f':
  1570. X                n = GetNumber();
  1571. X                SetFont(n);
  1572. X                break;
  1573. X#ifdef    BEZERKELYISM
  1574. X            case 'i':
  1575. X                n = GetNumber();
  1576. X                setstip(n);    /* ignore for now */
  1577. X                break;
  1578. X#endif    BEZERKELYISM
  1579. X            case 'H':    /* absolute horizontal motion */
  1580. X                k = GetNumber();
  1581. X                HorizontalGoto(k);
  1582. X                break;
  1583. X            case 'h':    /* relative horizontal motion */
  1584. X                k = GetNumber();
  1585. X                HorizontalMove(k);
  1586. X                break;
  1587. X            case 'w':    /* word space */
  1588. X#ifndef BEZERKELYISM
  1589. X                c = GetChar();
  1590. X                if (c < '0' || c > '9') {
  1591. X                    UnGetChar(c);
  1592. X                    break;
  1593. X                }
  1594. X                HorizontalMove((c-'0')*10 + GetChar()-'0');
  1595. X                PutCharacterString();
  1596. X#endif
  1597. X                break;
  1598. X            case 'V':
  1599. X                n = GetNumber();
  1600. X                VerticalGoto(n);
  1601. X                break;
  1602. X            case 'v':
  1603. X                n = GetNumber();
  1604. X                VerticalMove(n);
  1605. X                break;
  1606. X            case 'P':    /* new spread */
  1607. X                break;
  1608. X            case 'p':    /* new page */
  1609. X                (void) GetNumber();
  1610. X                return(RememberPagePosition());
  1611. X            case 'n':    /* end of line */
  1612. X                GetNumber();
  1613. X                GetNumber();
  1614. X                HorizontalGoto(0);
  1615. X                break;
  1616. X            case '#':    /* comment */
  1617. X                GetLine((char *) NULL, 0);
  1618. X                break;
  1619. X            case 'x':    /* device control */
  1620. X                ParseDeviceControl();
  1621. X                break;
  1622. X            default:
  1623. X                warning("Unknown input character %c(%d)\n",
  1624. X                      c, c);
  1625. X            }
  1626. X        } else {
  1627. X            extern int LastPage, CurrentPage;
  1628. X            if (!LastPage && !StopSeen){
  1629. X                warning("File is incomplete!\nEnd of file reached before finding\nthe end of the document.\nHave read %d pages.",CurrentPage);
  1630. X            }
  1631. X            return(CurrentPage);
  1632. X        }
  1633. X    }
  1634. X}
  1635. X
  1636. Xstruct    state {
  1637. X    int    size;
  1638. X    int    font;
  1639. X    int    style;
  1640. X    int     thick;
  1641. X    int    h_pos;
  1642. X    int    v_pos;
  1643. X};
  1644. X
  1645. Xstruct    state     StateStack[MAXSTATE];
  1646. Xstruct    state    *statep = StateStack;
  1647. X      
  1648. Xpush_env()                    /* begin a new block */
  1649. X{
  1650. X    statep->size = size;
  1651. X    statep->font = font;
  1652. X    statep->style = linmod;
  1653. X    statep->thick = linethickness;
  1654. X    statep->h_pos = HorizontalPosition;
  1655. X    statep->v_pos = VerticalPosition;
  1656. X    if (statep+1 >= StateStack+MAXSTATE)
  1657. X        warning( "{ nested too deep");
  1658. X    else
  1659. X        statep++;
  1660. X}
  1661. X
  1662. Xpop_env()                    /* pop to previous state */
  1663. X{
  1664. X    if (--statep < StateStack)
  1665. X        warning("extra }");
  1666. X    else {
  1667. X        size = statep->size;
  1668. X        font = statep->font;
  1669. X            HorizontalPosition = statep->h_pos;
  1670. X        VerticalPosition = statep->v_pos;
  1671. X        linmod = statep->style;
  1672. X        linethickness = statep->thick;
  1673. X        SetFont(font);
  1674. X        SetFontSize(size);
  1675. X    }
  1676. X}
  1677. X
  1678. XParseDrawFunction(buf)
  1679. Xchar    *buf;
  1680. X{
  1681. X    int    n, m, n1, m1;
  1682. X    int bordered; /* until we do polygons right */
  1683. X
  1684. X    switch (buf[0]) {
  1685. X    case 'l':                /* draw a line */
  1686. X        sscanf(buf+1, "%d %d", &n, &m);
  1687. X        DrawLine(n, m);
  1688. X        break;
  1689. X    case 'c':                /* circle */
  1690. X        sscanf(buf+1, "%d", &n);
  1691. X        DrawCircle(n);
  1692. X        break;
  1693. X    case 'e':                /* ellipse */
  1694. X        sscanf(buf+1, "%d %d", &m, &n);
  1695. X        DrawEllipse(m, n);
  1696. X        break;
  1697. X    case 'a':                /* arc */
  1698. X        sscanf(buf+1, "%d %d %d %d", &n, &m, &n1, &m1);
  1699. X        DrawArc(n, m, n1, m1);
  1700. X        break;
  1701. X    case '~':                /* wiggly line */
  1702. X        DrawSpline(buf+1,1);
  1703. X        break;
  1704. X#ifdef    BEZERKELYISM
  1705. X    case 'q':                /* versatec polygon - ignore */
  1706. X        while (buf[strlen(buf) - 1] != '\n'){
  1707. X            if (GetLine(buf, sizeof(buf)) == NULL){
  1708. X                fatal("unexpected end of input");
  1709. X            }
  1710. X        }
  1711. X        break;
  1712. X    case 'P':                /* unbordered */
  1713. X        bordered = 0;
  1714. X    case 'p':                /* polygon */
  1715. X        sscanf(buf+1, "%d", &n);
  1716. X        n = 1;
  1717. X        while(buf[n++] == ' ');
  1718. X        while(isdigit(buf[n])) n++;
  1719. X        DrawSpline(buf+n, -1);
  1720. X        bordered = 1;
  1721. X        break;
  1722. X    case 'g':                /* gremlin spline */
  1723. X        DrawSpline(buf+1, 0);
  1724. X        break;
  1725. X    case 't':                /* line thickness */
  1726. X        sscanf(buf+1, "%d", &n);
  1727. X        drawthick(n); 
  1728. X        break;
  1729. X    case 's':    /* line style */
  1730. X        sscanf(buf+1, "%d", &n);
  1731. X        drawstyle(n);
  1732. X        break;
  1733. X#endif    BEZERKELEYISM
  1734. X    default:
  1735. X        warning("unknown drawing function %s", buf);
  1736. X        break;
  1737. X    }
  1738. X} 
  1739. X
  1740. XParseDeviceControl()                /* Parse the x commands */
  1741. X{
  1742. X        char str[20], str1[50];
  1743. X    int c, n;
  1744. X    extern int LastPage, CurrentPage;
  1745. X
  1746. X    GetWord(str, 20);
  1747. X    switch (str[0]) {            /* crude for now */
  1748. X    case 'T':                /* output device */
  1749. X        GetWord(DeviceName, 10);
  1750. X        break;
  1751. X    case 'i':                /* initialize */
  1752. X        UserTypesetter = LoadDevice(DeviceName);
  1753. X        CurrentPage = 1;
  1754. X        SetPrinter(DeviceName);
  1755. X        InitTypesetter();
  1756. X        break;
  1757. X    case 't':                /* trailer */
  1758. X        break;
  1759. X    case 'p':                /* pause -- can restart */
  1760. X        break;
  1761. X    case 's':                /* stop */
  1762. X        StopSeen = 1;
  1763. X        LastPage = CurrentPage;
  1764. X        return;
  1765. X    case 'r':                /* resolution when prepared */
  1766. X        DeviceResolution = GetNumber();
  1767. X        break;
  1768. X    case 'f':                /* font used */
  1769. X        n = GetNumber();
  1770. X        (void) GetWord(str, 20);
  1771. X        (void) GetLine(str1, 50);
  1772. X        SetFontPosition(n, str, str1);
  1773. X        break;
  1774. X    case 'H':                /* char height */
  1775. X        break;
  1776. X    case 'S':                /* slant */
  1777. X        break;
  1778. X    }
  1779. X    while ((c = GetChar()) != '\n')        /* skip rest of input line */
  1780. X        if (c == EOF)
  1781. X            return;
  1782. X    return;
  1783. X}
  1784. END_OF_FILE
  1785. if test 8018 -ne `wc -c <'xtroff/parse.c'`; then
  1786.     echo shar: \"'xtroff/parse.c'\" unpacked with wrong size!
  1787. fi
  1788. # end of 'xtroff/parse.c'
  1789. fi
  1790. echo shar: End of archive 9 \(of 18\).
  1791. cp /dev/null ark9isdone
  1792. MISSING=""
  1793. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  1794.     if test ! -f ark${I}isdone ; then
  1795.     MISSING="${MISSING} ${I}"
  1796.     fi
  1797. done
  1798. if test "${MISSING}" = "" ; then
  1799.     echo You have unpacked all 18 archives.
  1800.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1801. else
  1802.     echo You still need to unpack the following archives:
  1803.     echo "        " ${MISSING}
  1804. fi
  1805. ##  End of shell archive.
  1806. exit 0
  1807.