home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume26 / wroff / part03 < prev    next >
Encoding:
Text File  |  1991-12-11  |  54.7 KB  |  2,473 lines

  1. Newsgroups: comp.sources.misc
  2. From: bkw@uecok.ECOK.EDU (Bill Walker)
  3. Subject:  v26i099:  wroff - text formatter for HP LaserJet with PDS 25-font cartridge, Part03/05
  4. Message-ID: <1991Dec10.063609.9741@sparky.imd.sterling.com>
  5. X-Md4-Signature: 21643e284efc9cc014da8d64c7752599
  6. Date: Tue, 10 Dec 1991 06:36:09 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: bkw@uecok.ECOK.EDU (Bill Walker)
  10. Posting-number: Volume 26, Issue 99
  11. Archive-name: wroff/part03
  12. Environment: SCO, HPUX, MS-DOS, CPM-68K
  13.  
  14. #! /bin/sh
  15. # into a shell via "sh file" or similar.  To overwrite existing files,
  16. # type "sh file -c".
  17. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  18. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  19. # Contents:  Fonts/Line8.5H Fonts/sampler MACROS/mathmacs Makefile
  20. #   TestData/hw2.w TestData/lesson1.w TestData/lesson2.w
  21. #   TestData/mathdemo.w source/alg.c source/defs.h source/expr.c
  22. #   source/externs.c source/globals.c source/macros.c source/main.c
  23. #   source/makefile source/rpn.c source/stacks.c source/tags
  24. #   source/test.c source/traps.c
  25. # Wrapped by kent@sparky on Tue Dec 10 00:26:39 1991
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. echo If this archive is complete, you will see the following message:
  28. echo '          "shar: End of archive 3 (of 5)."'
  29. if test -f 'Fonts/Line8.5H' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'Fonts/Line8.5H'\"
  31. else
  32.   echo shar: Extracting \"'Fonts/Line8.5H'\" \(313 characters\)
  33.   sed "s/^X//" >'Fonts/Line8.5H' <<'END_OF_FILE'
  34. XE&l1OE(0UE(sp16.66h8.5vsb0T
  35. X18
  36. X18
  37. X18
  38. X18
  39. X18
  40. X18
  41. X18
  42. X18
  43. X18
  44. X18
  45. X18
  46. X18
  47. X18
  48. X18
  49. X18
  50. X18
  51. X18
  52. X18
  53. X18
  54. X18
  55. X18
  56. X18
  57. X18
  58. X18
  59. X18
  60. X18
  61. X18
  62. X18
  63. X18
  64. X18
  65. X18
  66. X18
  67. X18
  68. X18
  69. X18
  70. X18
  71. X18
  72. X18
  73. X18
  74. X18
  75. X18
  76. X18
  77. X18
  78. X18
  79. X18
  80. X18
  81. X18
  82. X18
  83. X18
  84. X18
  85. X18
  86. X18
  87. X18
  88. X18
  89. X18
  90. X18
  91. X18
  92. X18
  93. X18
  94. X18
  95. X18
  96. X18
  97. X18
  98. X18
  99. X18
  100. X18
  101. X18
  102. X18
  103. X18
  104. X18
  105. X18
  106. X18
  107. X18
  108. X18
  109. X18
  110. X18
  111. X18
  112. X18
  113. X18
  114. X18
  115. X18
  116. X18
  117. X18
  118. X18
  119. X18
  120. X18
  121. X18
  122. X18
  123. X18
  124. X18
  125. X18
  126. X18
  127. X18
  128. X18
  129. X18
  130. END_OF_FILE
  131.   if test 313 -ne `wc -c <'Fonts/Line8.5H'`; then
  132.     echo shar: \"'Fonts/Line8.5H'\" unpacked with wrong size!
  133.   fi
  134.   # end of 'Fonts/Line8.5H'
  135. fi
  136. if test -f 'Fonts/sampler' -a "${1}" != "-c" ; then 
  137.   echo shar: Will not clobber existing file \"'Fonts/sampler'\"
  138. else
  139.   echo shar: Extracting \"'Fonts/sampler'\" \(3498 characters\)
  140.   sed "s/^X//" >'Fonts/sampler' <<'END_OF_FILE'
  141. X.fm RESET
  142. X\fMFont RESET will clear the printer to default\fP
  143. X.sp
  144. XThis is a print sampler.
  145. X.sp 4
  146. X.fm LGN9.5A
  147. X\fMFont LGN9.5A is Letter Gothic, Normal, 9.5 point, ASCII\fP
  148. X.sp
  149. X.fm LGN14L
  150. X\fMFont LGN14L is Letter Gothic, Norman, 14 point, LEGAL\fP
  151. X.sp
  152. X.fm TMN10B
  153. XFont TMN10B is a math font: \fM abcdefgh\fP
  154. X.sp
  155. X.fm PAFS4.8_12
  156. X\fMFont\fP PAFS4.8_12 \fM is PDP AFS 4.8 point, 12 lpi\fP
  157. X.sp 
  158. X.fm PAFS4.8_16
  159. X\fMFont\fP PAFS4.8_16 \fM is PDP AFS 4.8 point, 16 lpi\fP
  160. X.sp
  161. X.fm PCLine14
  162. XFont PCLine14 is a line drawing font: \fM0123456789\fP
  163. X.sp
  164. X.fm TaxB12
  165. XFont TaxB12 is a tax form font, boldfaced: \fMabcdefgh\fP
  166. X.sp
  167. X.fm LineDraw12
  168. XFont LineDraw12 is a line drawing font: \fMabcdefgh\fP
  169. X.sp
  170. X.fm LGN14A
  171. X\fMFont LGN14A is Letter Gothic, Normal, 14 point, ASCII\fP
  172. X.sp
  173. X.fm LGB12A
  174. X\fMFont LGB12A is Letter Gothic, Bold, 12 point, ASCII\fP
  175. X.sp
  176. X.fm LP8.5PC
  177. X\fMFont LP8.5PC is Line Printer, 8.5 point, PC\fP
  178. X.sp
  179. X.fm ci12
  180. X\fMFont ci12 is Courier, Italic, 12 point, ASCII\fP
  181. X.sp
  182. X.fm cn12
  183. X\fMFont cn12 is Courier, Normal, 12 point, ASCII\fP
  184. X.sp
  185. X.fm pen7
  186. X\fMFont pen7 is Prestige Elite, Normal, 7 point, ASCII\fP
  187. X.sp
  188. X.fm lp8.5
  189. X\fMFont lp8.5 is a Line Printer, 8.5 point, ASCII\fP
  190. X.sp
  191. X.fm pb18
  192. X\fMFont pb18 is Presentation, Bold, 18 point, ASCII\fP
  193. X.sp
  194. X.fm pb16a
  195. X\fMFont pb16a is Presentation, Bold, 16 point, ASCII\fP
  196. X.sp
  197. X.fm pei10.l
  198. X\fMFont pei10.l is Prestige Elite, Italic, 10 point, Legal\fP
  199. X.sp
  200. X.fm pen10.l
  201. X\fMFont pen10.l is Prestige Elite, Normal, 10 point, Legal\fP
  202. X.sp
  203. X.fm peb10.l
  204. X\fMFont peb10.l is Prestige Elite, Bold, 10 point, Legal\fP
  205. X.sp
  206. X.fm ct12r-8
  207. X\fMFont ct12r-8 is Courier, Italic, 12 point, Roman-8\fP
  208. X.sp
  209. X.fm pb14
  210. X\fMFont pb14 is Presentation, Bold, 14 points, ASCII\fP
  211. X.sp
  212. X.fm HB14ECMA
  213. X\fMFont HB14ECMA is Helvetica, Bold, 14 point, ECMA, 10 series\fP
  214. X.sp
  215. X.fm TMN8A
  216. XFont TMN8A is Times Math, Normal, 8 point, MATH A  \fMabcdefg1234567\fP
  217. X.sp
  218. X.fm HN10
  219. X\fMFont HN10 is Helvetica, Normal, 10 point, ASCII\fP
  220. X.sp
  221. X.fm HI10
  222. X\fMFont HI10 is Helvetica, Italic, 10 point, ASCII\fP
  223. X.sp
  224. X.fm HB8
  225. X\fMFont HB8 is Helvetica, Bold, 8 point, ASCII\fP
  226. X.sp
  227. X.fm HN8
  228. X\fMFont HN8 is Helvetica, Normal, 8 point, ASCII\fP
  229. X.sp
  230. X.fm HN6
  231. X\fMFont HN6 is Helvetic, Normal, 6 point, ASCII\fP
  232. X.sp
  233. X.fm trn12
  234. X\fMFont trn12 is Times Roman, Normal, 12 point, ASCII\fP
  235. X.sp
  236. X.fm trb12
  237. X\fMFont trb12 is Times Roman, Bold, 12 point, ASCII\fP
  238. X.sp
  239. X.fm tri12
  240. X\fMFont tri12 is Times Roman, Italic, 12 point, ASCII\fP
  241. X.sp
  242. X.fm trn8
  243. X\fMFont trn8 is Times Roman, Normal, 8 point, ASCII\fP
  244. X.sp
  245. X.fm tri10
  246. X\fMFont tri10 is Times Roman, Italic, 10 point, ASCII\fP
  247. X.sp
  248. X.fm trn10
  249. X\fMFont trn10 is Times Roman, Normal, 10 point, ASCII\fP
  250. X.sp 
  251. X.fm trb10
  252. X\fMFont trb10 is Times Roman, Bold, 10 point, ASCII\fP
  253. X.sp
  254. X.fm lgn12
  255. X\fMFont lgn12 is Letter Gothic, Normal, 12 point, ASCII\fP
  256. X.sp
  257. X.fm lgi12
  258. X\fMFont lgi12 is Letter Gothic, Italic, 12 point, ASCII\fP
  259. X.sp 
  260. X.fm PB18L
  261. X\fMFont PB18L is Presentation, Bold, 18 point, Legal\fP
  262. X.sp
  263. X.fm PB16L
  264. X\fMFont PB16L is Presentation, Bold, 16 point, Legal\fP
  265. X.sp
  266. X.fm PB14L
  267. X\fMFont PB14L is Presentation, Bold, 14 point, Legal\fP
  268. X.sp
  269. X.fm HB14
  270. X\fMFont HB14 is Helvetica, Bold, 14 point, ASCII\fP
  271. X.sp
  272. X.fm TMN8B
  273. XFont TMN8B is Times Math, Normal, 8 point, MATH B  \fMabcdef123456\fP
  274. X.sp
  275. X.fm HB12
  276. X\fMFont HB12 is Helvetica, Bold, 12 point, ASCII\fP
  277. X.sp
  278. X.fm HN12
  279. X\fMFont HN12 is Helvetica, Normal, 12 point, ASCII\fP
  280. X.sp
  281. X.fm HI12
  282. X\fMFont HI12 is Helvetica, Italic, 12 point, ASCII\fP
  283. X.sp
  284. X.fm HB10
  285. X\fMFont HB10 is Helvetica, Bold, 10 point, ASCII\fP
  286. X.sp
  287. X.fm PEN7L
  288. X\fMFont PEN7L is Prestige Elite, Normal, 7 point, Legal\fP
  289. END_OF_FILE
  290.   if test 3498 -ne `wc -c <'Fonts/sampler'`; then
  291.     echo shar: \"'Fonts/sampler'\" unpacked with wrong size!
  292.   fi
  293.   # end of 'Fonts/sampler'
  294. fi
  295. if test -f 'MACROS/mathmacs' -a "${1}" != "-c" ; then 
  296.   echo shar: Will not clobber existing file \"'MACROS/mathmacs'\"
  297. else
  298.   echo shar: Extracting \"'MACROS/mathmacs'\" \(797 characters\)
  299.   sed "s/^X//" >'MACROS/mathmacs' <<'END_OF_FILE'
  300. X.de INT
  301. X.fm TMN10B
  302. X\fMu\fP
  303. X\[ p = X + M + L ]
  304. X.gx -48
  305. X.gy +8
  306. X\fMg\fP
  307. X.gx -48
  308. X.gy -16
  309. X\fMe\fP
  310. X.gy +8
  311. X.gx \(p)
  312. X.gy +12
  313. X$1
  314. X.gx \(p)
  315. X.gy -24
  316. X$2
  317. X.gy +12
  318. X\fP
  319. X.en
  320. X.de LBRACE
  321. X.fm TMN10B
  322. X\fMc\fP
  323. X\[ p = X + M + L -140 ]
  324. X.gx -48
  325. X.gy +8
  326. X\fMd\fP
  327. X.gx -48
  328. X.gy -16
  329. X\fMb\fP
  330. X.gy +8
  331. X.gx \(p)
  332. X\fP
  333. X.en
  334. X.de RBRACE
  335. X.fm TMN10B
  336. X\fMs\fP
  337. X\[ p = X + M + L - 175 ]
  338. X.gx -48
  339. X.gy +8
  340. X\fMt\fP
  341. X.gx -48
  342. X.gy -16
  343. X\fMr\fP
  344. X.gy +8
  345. X.gx \(p)
  346. X\fP
  347. X.en
  348. X.de int 
  349. X.fm TMN10B
  350. X\fMU\fP
  351. X.en
  352. X.de lbrace
  353. X\f0{\fP
  354. X.en
  355. X.de rbrace
  356. X\f0}\fP
  357. X.en
  358. X.de SU
  359. X.gy -5
  360. X\f2$1\fP
  361. X.gy +5
  362. X.en
  363. X.de SB
  364. X.gy +3
  365. X\f2$1\fP
  366. X.gy -3
  367. X.en
  368. X.de SUM 
  369. X.fm TMN10B
  370. X\[ p = X + M + L  +50  ]
  371. X.gy +4
  372. X\fMj\fP
  373. X.gx -48 
  374. X.gy -8
  375. X\fMh\fP
  376. X.gy +4
  377. X.gx \(p)
  378. X.en
  379. X
  380. X
  381. X
  382. X\{INT 1 2} \{LBRACE} (x \{SU 2} - y \{SB 4} + (r + s) \{SU 3} ) \{RBRACE} dx
  383. X
  384. X
  385. X
  386. X
  387. X\{int} \{lbrace} ( \{SUM} some function) \{rbrace} dx
  388. X
  389. X
  390. END_OF_FILE
  391.   if test 797 -ne `wc -c <'MACROS/mathmacs'`; then
  392.     echo shar: \"'MACROS/mathmacs'\" unpacked with wrong size!
  393.   fi
  394.   # end of 'MACROS/mathmacs'
  395. fi
  396. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  397.   echo shar: Will not clobber existing file \"'Makefile'\"
  398. else
  399.   echo shar: Extracting \"'Makefile'\" \(1812 characters\)
  400.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  401. X
  402. X# this is the command to print something on your laser printer
  403. XPRINT=lp
  404. X
  405. X# the owner of the system files --- need not be root
  406. XOWNER=root
  407. X
  408. X# directory to contain the font tables
  409. X# leave as it is for testing, but change it for production
  410. X#FONTS='"./Fonts"'
  411. X#here's where we keep it, but you will want to change it.
  412. XFONTS='"/usr/ECU/Fonts"'
  413. X
  414. X#source is located in this directory
  415. XSOURCE=./source
  416. X
  417. X#documentation is contained in this directory
  418. XDOCDIR=./doc
  419. X
  420. X#local bin directory
  421. X#leave it as is for testing, but change it for actual installation
  422. X#BINDIR=./bin
  423. X# we use this, but again you will certainly want to change it
  424. XBINDIR=/usr/ECU/bin
  425. X
  426. XCFLAGS = -DFONTSDIR='"$(FONTS)"' -i -DUNIX -g
  427. X
  428. X
  429. Xa.out : 
  430. X    cd source; make -f makefile -k "CC=$(CC)" "CFLAGS=$(CFLAGS)"; \
  431. X         mv a.out ../a.out
  432. X
  433. X
  434. X# be sure you have write permission whereever these directories are
  435. Xinstall :
  436. X    strip a.out
  437. X    mv a.out $(BINDIR)/wroff
  438. X    cp ./Fonts/* $(FONTSDIR)
  439. X    chmod $(OWNER) $(FONTSDIR)/*
  440. X    chmod u+r $(FONTSDIR)/*
  441. X    chmod go+rx $(BINDIR)/wroff
  442. X    chown $(OWNER) $(BINDIR)/wroff
  443. X
  444. X
  445. X# make "manual page" documentation for wroff -- it is stored under DOCDIR
  446. X# note that we assume that the (unstripped) wroff executable is named "a.out"
  447. X
  448. Xmanpage : 
  449. X    a.out $(DOCDIR)/macs.w $(DOCDIR)/wroff.1.w -p -k -o $(DOCDIR)/doc.pr
  450. X
  451. X# make a tutorial for wroff -- store it in the DOCDIR
  452. X# note that we assume that the (unstripped) wroff executable is named "a.out"
  453. X
  454. Xtut :
  455. X    a.out $(DOCDIR)/macs.w $(DOCDIR)/wroff.tut.w -p -k -o $(DOCDIR)/tut.pr
  456. X
  457. X
  458. X#clean up the mess
  459. Xclean:
  460. X    rm $(SOURCE)/*.o
  461. X
  462. X
  463. X# this will test wroff to see if it works at all
  464. Xtest :
  465. X    $(BINDIR)/wroff $(DOCDIR)/welcome
  466. X    $(BINDIR)/wroff $(DOCDIR)/welcome | $(PRINT)
  467. X
  468. X
  469. X# this will print a convenient "sampler" to demonstrate the available fonts
  470. Xsampler:
  471. X    $(BINDIR)/wroff TestData/sampler | $(PRINT)
  472. X
  473. END_OF_FILE
  474.   if test 1812 -ne `wc -c <'Makefile'`; then
  475.     echo shar: \"'Makefile'\" unpacked with wrong size!
  476.   fi
  477.   # end of 'Makefile'
  478. fi
  479. if test -f 'TestData/hw2.w' -a "${1}" != "-c" ; then 
  480.   echo shar: Will not clobber existing file \"'TestData/hw2.w'\"
  481. else
  482.   echo shar: Extracting \"'TestData/hw2.w'\" \(541 characters\)
  483.   sed "s/^X//" >'TestData/hw2.w' <<'END_OF_FILE'
  484. X.de SU
  485. X.gy -5
  486. X\f2$1\f0
  487. X.gy +5
  488. X.en
  489. X.ce 10
  490. X\fBComputer Science 1133
  491. XThird Homework Assignment
  492. XDue: September 22, 1989\fP
  493. X.ce 0
  494. X.sp 2
  495. X.PP
  496. XThe purpose of this assignment is to illustrate the use of
  497. Xfunction subprograms, and illustrate a loop that "quits"
  498. Xafter an indefinite number of iterations.
  499. X.PP
  500. XYou are to use Newton's Method to solve the following
  501. Xequations:
  502. X
  503. X.sp 3
  504. X.in +5
  505. Xx \{SU 3} - x = 0         (Answer: 0, 1, -1)
  506. X.sp 3
  507. Xx \{SU 2} + 3x + 2 = 0    (Answer: -1, -2)
  508. X.sp 3
  509. Xx sin(x) - 3 = 0          (Answer: could be several -- check it)
  510. END_OF_FILE
  511.   if test 541 -ne `wc -c <'TestData/hw2.w'`; then
  512.     echo shar: \"'TestData/hw2.w'\" unpacked with wrong size!
  513.   fi
  514.   # end of 'TestData/hw2.w'
  515. fi
  516. if test -f 'TestData/lesson1.w' -a "${1}" != "-c" ; then 
  517.   echo shar: Will not clobber existing file \"'TestData/lesson1.w'\"
  518. else
  519.   echo shar: Extracting \"'TestData/lesson1.w'\" \(1401 characters\)
  520.   sed "s/^X//" >'TestData/lesson1.w' <<'END_OF_FILE'
  521. X.ce 10
  522. X\fBFirst Lesson
  523. XComputer Programming II\fP
  524. X.ce 0
  525. X.sp
  526. X.in 15
  527. X.ti -5
  528. X\fBvi editor exercise:\fP  Here are the commands that you will need
  529. Xto know about today:
  530. X.nf
  531. X
  532. X.in +5
  533. X\fBvi file.pas
  534. X
  535. Xi     \f|-     \f|insert
  536. XESC    \f|-     \f|quit inserting
  537. Xx    \f|-    \f|cross out character
  538. X:wq    \f|-    \f|save work and quit
  539. X
  540. X^u    \f|-    \f|move up half page
  541. X^d    \f|-    \f|move down half page
  542. X^p    \f|-    \f|previous line
  543. X^n    \f|-    \f|next line
  544. X^h    \f|-    \f|left one character
  545. Xspace    \f|-    \f|right one character\fP
  546. X
  547. XEnter the following code:
  548. X
  549. X.nf
  550. X\fT
  551. Xprogram summer (input, output);
  552. X    var  i, sum : integer;
  553. X    
  554. Xbegin
  555. X    sum := 0;
  556. X    
  557. X    i := 1;
  558. X    while i <= 10 do
  559. X      begin
  560. X        sum := sum + i;
  561. X    i := i + 1;
  562. X      end;
  563. X    writeln('the sum is ', sum);
  564. Xend.
  565. X\fP
  566. X.fi
  567. X.bp
  568. X.OP 1.
  569. XEnter and execute the program. This will require that you know how
  570. Xto log in, how to use \fBpc file.pas\fP, and how to execute a program by
  571. Xtyping \fBa.out\fP.  You may also find \fBls\fP handy.
  572. X.OP 2.
  573. XModify the program to sum the first 100 positive integers instead.
  574. X.OP 3.
  575. XModify the program to sum the first 25 positive integers.
  576. X.OP 4.
  577. XUse \fBcat file.pas\fP to print the program on your screen, then
  578. Xuse \fBcat file.pas | lp\fP to print the program on the printer.
  579. X.OP 5.
  580. XUse \fBa.out\fP to execute the program on your screen, then use
  581. X\fBa.out | lp\fP to print the output of the program on the printer.
  582. X\fBDO NOT USE "cat a.out" FOR ANYTHING!\fP
  583. END_OF_FILE
  584.   if test 1401 -ne `wc -c <'TestData/lesson1.w'`; then
  585.     echo shar: \"'TestData/lesson1.w'\" unpacked with wrong size!
  586.   fi
  587.   # end of 'TestData/lesson1.w'
  588. fi
  589. if test -f 'TestData/lesson2.w' -a "${1}" != "-c" ; then 
  590.   echo shar: Will not clobber existing file \"'TestData/lesson2.w'\"
  591. else
  592.   echo shar: Extracting \"'TestData/lesson2.w'\" \(3630 characters\)
  593.   sed "s/^X//" >'TestData/lesson2.w' <<'END_OF_FILE'
  594. X.ce 10
  595. X\fBSecond Lesson
  596. XComputer Programming II\fP
  597. X.ce 0
  598. X.sp 3
  599. X.in +5
  600. X.ti -5
  601. XHere are the commands that you will need to know about
  602. Xtoday:
  603. X.sp 2
  604. X\fB
  605. X.nf 
  606. Xpasswd     \f|-    \f|change your password
  607. Xls     \f|-    \f|list contents of directory 
  608. Xdate     \f|-    \f|show the time and date
  609. Xwho     \f|-    \f|determine who is on the system
  610. Xmkdir     \f|-    \f|create a new subdirectory
  611. Xcd     \f|-    \f|change the working directory
  612. Xpwd     \f|-    \f|print the working directory
  613. Xwc     \f|-    \f|count lines, words, and characters
  614. Xlp     \f|-    \f|copy standard input to the printer
  615. Xcat file \f|-    \f|copy file to standard output
  616. Xvisprint \f|-    \f|copy standard input to both printer and screen
  617. X|     \f|-    \f|connect standard output of one program
  618. X        \f|to standard input of another ("pipe")
  619. Xmailx     \f|-    \f|send or receive electronic mail
  620. Xname     \f|-    \f|determine login ids
  621. Xvnews     \f|-    \f|read  public electronic news
  622. X\fP
  623. X.fi
  624. X.in +5
  625. X.vl 5
  626. X.sp 2
  627. X.OP 1.  
  628. XLog into the machine.
  629. X.OP 2.  
  630. XChange your password by using \fBpasswd\fP.  Note that
  631. X\fBpasswd\fP asks you for your previous password, and then
  632. Xfor a new password.  It does not print on the screen when
  633. Xyou type, so be prepared to type "in the blind."
  634. X.OP 3.  
  635. XWhen you logged in, you almost certainly received notice
  636. Xthat there was "news".  To read this news, type \fBvnews\fP.
  637. XAt any time while vnews is running, you can type a \fB?\fP
  638. Xto get some help.  Use the letter "n" to page through the
  639. Xnews.
  640. X.OP 4.  
  641. XUse \fBdate\fP to determine today's date, and then use \fBwho\fP to
  642. Xdetermine who is on the system.
  643. X.OP 5.  
  644. XThe symbol "|" connects the output of one program to the
  645. Xinput of a second program.  The program \fBwc\fP is used to count
  646. Xthe number of lines, words, and characters that appear in
  647. Xits input.  What does the sequence \fBwho | wc\fP determine ?
  648. XTry \fBdate | wc\fP .  What did you get ?
  649. X.OP 6.  
  650. XThe programs \fBlp\fP and \fBvisprint\fP are somewhat similar.  Both
  651. Xprint their input to the printer.  The \fBvisprint\fP program also
  652. Xprints its input to the screen as well.
  653. XWhat happens if you type \fBwho | lp\fP ?  What if you type
  654. X\fBwho | visprint\fP ?  What about \fBwho | wc | visprint\fP ?
  655. X.OP 7.  
  656. XUse \fBls\fP to determine the contents of your
  657. Xdirectory.  (Could you print this on the printer if you
  658. Xneeded to ?)  Now use \fBmkdir pascal\fP to create a new
  659. Xdirectory.  Issue another \fBls\fP.  What happened ?
  660. X.OP 8.  
  661. XType \fBpwd\fP and see what you get, then
  662. Xuse \fBcd pascal\fP to "change directory" to the pascal
  663. Xdirectory, and type \fBpwd\fP again.  Use \fBls\fP to see if
  664. Xthere is anything in the directory that you just created.
  665. XYou can return "home" by just saying \fBcd\fP.
  666. X.OP 9.  
  667. XReturn to "home" and create another directory called
  668. X"wordproc" that can be used to hold your word processing
  669. Xfiles.  Confirm that it exists, and is empty.
  670. X.OP 10.  
  671. XFrom now on, when you write a program in Pascal, be
  672. Xsure to first \fBcd pascal\fP before you start to program.
  673. X.OP 11.  
  674. XIf you had a message concerning "mail", you may want to
  675. Xread your mail.  To do so, just type \fBmailx\fP.  You will
  676. Xbe given a list of your messages.  Select the one(s) you
  677. Xwant to read by typing the number of the message.  When you
  678. Xare done with a message, type \fBd\fP to delete that message
  679. X(otherwise it is saved, which is usually messy.)  When you
  680. Xhave read all the mail, type \fBq\fP to quit the mail
  681. Xsystem.
  682. X.OP 12.  
  683. XUse \fBname myfriend\fP to determine the login id of
  684. Xyour friend.  Then send mail to your friend by typing
  685. X\fBmailx loginid\fP, where "loginid" is the login id of your
  686. Xfriend.  Everything you type on the terminal will be mailed
  687. Xto your friend.  End your letter by putting a period (".")
  688. Xon a line by itself.
  689. END_OF_FILE
  690.   if test 3630 -ne `wc -c <'TestData/lesson2.w'`; then
  691.     echo shar: \"'TestData/lesson2.w'\" unpacked with wrong size!
  692.   fi
  693.   # end of 'TestData/lesson2.w'
  694. fi
  695. if test -f 'TestData/mathdemo.w' -a "${1}" != "-c" ; then 
  696.   echo shar: Will not clobber existing file \"'TestData/mathdemo.w'\"
  697. else
  698.   echo shar: Extracting \"'TestData/mathdemo.w'\" \(797 characters\)
  699.   sed "s/^X//" >'TestData/mathdemo.w' <<'END_OF_FILE'
  700. X.de INT
  701. X.fm TMN10B
  702. X\fMu\fP
  703. X\[ p = X + M + L ]
  704. X.gx -48
  705. X.gy +8
  706. X\fMg\fP
  707. X.gx -48
  708. X.gy -16
  709. X\fMe\fP
  710. X.gy +8
  711. X.gx \(p)
  712. X.gy +12
  713. X$1
  714. X.gx \(p)
  715. X.gy -24
  716. X$2
  717. X.gy +12
  718. X\fP
  719. X.en
  720. X.de LBRACE
  721. X.fm TMN10B
  722. X\fMc\fP
  723. X\[ p = X + M + L -140 ]
  724. X.gx -48
  725. X.gy +8
  726. X\fMd\fP
  727. X.gx -48
  728. X.gy -16
  729. X\fMb\fP
  730. X.gy +8
  731. X.gx \(p)
  732. X\fP
  733. X.en
  734. X.de RBRACE
  735. X.fm TMN10B
  736. X\fMs\fP
  737. X\[ p = X + M + L - 175 ]
  738. X.gx -48
  739. X.gy +8
  740. X\fMt\fP
  741. X.gx -48
  742. X.gy -16
  743. X\fMr\fP
  744. X.gy +8
  745. X.gx \(p)
  746. X\fP
  747. X.en
  748. X.de int 
  749. X.fm TMN10B
  750. X\fMU\fP
  751. X.en
  752. X.de lbrace
  753. X\f0{\fP
  754. X.en
  755. X.de rbrace
  756. X\f0}\fP
  757. X.en
  758. X.de SU
  759. X.gy -5
  760. X\f2$1\fP
  761. X.gy +5
  762. X.en
  763. X.de SB
  764. X.gy +3
  765. X\f2$1\fP
  766. X.gy -3
  767. X.en
  768. X.de SUM 
  769. X.fm TMN10B
  770. X\[ p = X + M + L  +50  ]
  771. X.gy +4
  772. X\fMj\fP
  773. X.gx -48 
  774. X.gy -8
  775. X\fMh\fP
  776. X.gy +4
  777. X.gx \(p)
  778. X.en
  779. X
  780. X
  781. X
  782. X\{INT 1 2} \{LBRACE} (x \{SU 2} - y \{SB 4} + (r + s) \{SU 3} ) \{RBRACE} dx
  783. X
  784. X
  785. X
  786. X
  787. X\{int} \{lbrace} ( \{SUM} some function) \{rbrace} dx
  788. X
  789. X
  790. END_OF_FILE
  791.   if test 797 -ne `wc -c <'TestData/mathdemo.w'`; then
  792.     echo shar: \"'TestData/mathdemo.w'\" unpacked with wrong size!
  793.   fi
  794.   # end of 'TestData/mathdemo.w'
  795. fi
  796. if test -f 'source/alg.c' -a "${1}" != "-c" ; then 
  797.   echo shar: Will not clobber existing file \"'source/alg.c'\"
  798. else
  799.   echo shar: Extracting \"'source/alg.c'\" \(927 characters\)
  800.   sed "s/^X//" >'source/alg.c' <<'END_OF_FILE'
  801. X#include <stdio.h>
  802. X#define VOID
  803. X
  804. X
  805. Xextern float rpn();
  806. Xextern struct cstack;
  807. Xextern int iscempty();
  808. Xextern char cpop();
  809. Xextern int cpush();
  810. X
  811. Xstruct cstack *s;
  812. X
  813. XVOID alg(as,t)
  814. X char as[],t[];
  815. X{
  816. X  int i,j;
  817. X  char c;
  818. X  initcs(&s);
  819. X  i = 0;
  820. X  j = 0;
  821. X  while (t[i] != '\0') {
  822. X    if (isdigit(t[i]) || t[i] == '.' || t[i] == ' ')  {
  823. X       as[j++] = t[i++];
  824. X    }
  825. X    else if (t[i] == '(') {
  826. X       cpush(&s,t[i++]);
  827. X    }
  828. X    else if ( t[i] == ')' ) {
  829. X       while ((c=cpop(&s)) != '('){
  830. X      as[j++] = ' ';
  831. X      as[j++]=c;
  832. X      as[j++] = ' ';
  833. X       }
  834. X       i++;
  835. X    }
  836. X    else {
  837. X       while (prec(t[i])  <= prec(ctopofstack(s) ) ) {
  838. X      as[j++] = cpop(&s);
  839. X       }
  840. X       cpush(&s,t[i++]);
  841. X     }
  842. X    }
  843. X
  844. X
  845. X  while ( !iscempty(s) )
  846. X      as[j++] = cpop(&s);
  847. X  as[j] = t[i];
  848. X}
  849. X
  850. X
  851. X
  852. Xint prec(ch)
  853. Xchar ch;
  854. X{
  855. X  if (ch == '+' || ch == '-')
  856. X     return 1;
  857. X  else if (ch == '/' || ch == '*')
  858. X     return 2;
  859. X  else if (ch == '(')
  860. X     return 0;
  861. X}
  862. END_OF_FILE
  863.   if test 927 -ne `wc -c <'source/alg.c'`; then
  864.     echo shar: \"'source/alg.c'\" unpacked with wrong size!
  865.   fi
  866.   # end of 'source/alg.c'
  867. fi
  868. if test -f 'source/defs.h' -a "${1}" != "-c" ; then 
  869.   echo shar: Will not clobber existing file \"'source/defs.h'\"
  870. else
  871.   echo shar: Extracting \"'source/defs.h'\" \(1973 characters\)
  872.   sed "s/^X//" >'source/defs.h' <<'END_OF_FILE'
  873. X/* maximum length of string */
  874. X#define  MAXSTR 512    
  875. X
  876. X/* maximum output buffer size */
  877. X#define MAXBUF 1024
  878. X
  879. X/* length of a "short string" */
  880. X#define SHORTSTR 60
  881. X
  882. X/* number of files that can appear on command line */
  883. X#define MAXFILE 20
  884. X
  885. X/* for portability's sake */
  886. X#define VOID int
  887. X
  888. X/* number of format fields possible for a title field */
  889. X#define FNUMBER 20
  890. X
  891. X/* a big number */
  892. X#define HUGE 32767
  893. X
  894. X#ifdef UNIX
  895. X#define TRUE (1==1)
  896. X#define FALSE (1==0)
  897. X#else
  898. X#define TRUE 0
  899. X#define FALSE 1
  900. X#endif
  901. X
  902. X/* number of defined registers */
  903. X#define MAXREG 255
  904. X
  905. X/* reference register x, where x is a letter */
  906. X#define REG(x)  reg[x-32]
  907. X
  908. X/* maximum number of arguments in a command line */
  909. X#define MAXCMD 10
  910. X
  911. X/* default left margin */
  912. X#define DEFLMARGIN 300  
  913. X
  914. X/* default right margin */
  915. X#define DEFRMARGIN 2100 
  916. X
  917. X/* default page length */
  918. X#define DEFPAGELENGTH 480
  919. X
  920. X/* default line spacing */
  921. X#define DEFLSPACE 1
  922. X
  923. X/* default general value for ti, bd, it, etc. */
  924. X#define DEFCOUNT 1
  925. X
  926. X/* an ESCAPE character */
  927. X#define ESC '\033'
  928. X
  929. X/* a form-feed */
  930. X#define FF '\014'
  931. X
  932. X/* a SHIFTOUT */
  933. X#define SHIFTOUT '\016'
  934. X
  935. X/* the ANCHOR character */
  936. X#define ANCHOR '\017'
  937. X
  938. X/* dots per 1/10 inch */
  939. X#define DOTSCHAR 30
  940. X
  941. X/* registers */
  942. X#define CURRPAGE REG('#')
  943. X#define NEXTPAGE REG('A')
  944. X#define BOTTOMMARGIN REG('B')
  945. X#define CNTRCNT REG('C')
  946. X#define DIVLEN REG('D')
  947. X#define ITALCNT REG('E')
  948. X#define CURRFONT REG('F')
  949. X#define BOLDCNT REG('G')
  950. X#define RJUSTIFY REG('H')
  951. X#define FILLMODE REG('I')
  952. X#define TDLIM REG('J')
  953. X#define TABLEMODE REG('K')
  954. X#define LMARGIN REG('L')
  955. X#define TEMPINDENT REG('M')
  956. X#define ULCOUNT REG('N')
  957. X#define PAGECHAR REG('O')
  958. X#define PAGELENGTH REG('P')
  959. X#define CHARCNT REG('Q')
  960. X#define RMARGIN REG('R')
  961. X#define LSPACE REG('S')
  962. X#define TOPMARGIN REG('T')
  963. X#define SPACEWIDTH REG('U')
  964. X#define VSPACE REG('V')
  965. X#define IPARA REG('W')
  966. X#define CURRX REG('X')
  967. X#define CURRY REG('Y')
  968. X#define ULSTATE REG('Z')
  969. X#define TABSTOPS REG('!')
  970. X#define MTHREE REG('_')
  971. X#define MTWO  REG('^')
  972. X
  973. END_OF_FILE
  974.   if test 1973 -ne `wc -c <'source/defs.h'`; then
  975.     echo shar: \"'source/defs.h'\" unpacked with wrong size!
  976.   fi
  977.   # end of 'source/defs.h'
  978. fi
  979. if test -f 'source/expr.c' -a "${1}" != "-c" ; then 
  980.   echo shar: Will not clobber existing file \"'source/expr.c'\"
  981. else
  982.   echo shar: Extracting \"'source/expr.c'\" \(3196 characters\)
  983.   sed "s/^X//" >'source/expr.c' <<'END_OF_FILE'
  984. X#include <stdio.h>
  985. X#include <ctype.h>
  986. X
  987. X#include "defs.h"
  988. X#include "externs.c"
  989. X
  990. Xextern float rpneval();
  991. X
  992. X/* function eval is to evaluate an in-line expression */
  993. Xeval(estr)
  994. Xchar estr[];
  995. X{
  996. X    char lhs;
  997. X    char algstr[MAXSTR];
  998. X    char tempstr[MAXSTR];
  999. X    char temp1[MAXSTR];
  1000. X    int i,j,k;
  1001. X
  1002. X    /* the idea is that the estr is of the form
  1003. X
  1004. X         lhs = rhs
  1005. X
  1006. X      and we therefore should "peel off" the lhs, and the 
  1007. X      '=' sign.  The only possibility for the lhs is the
  1008. X      name of a register, which must be a single letter.
  1009. X      The rhs can consist of arithmetic expressions made
  1010. X      with numbers, including floating point numbers, and
  1011. X      single-letter registers. */
  1012. X
  1013. X      i = 0;
  1014. X      while (estr[i] != '\0' && isspace(estr[i]) ) i++;
  1015. X      lhs = estr[i];
  1016. X      i++;
  1017. X      while (estr[i] != '\0' && (estr[i] == '=' || isspace(estr[i]) ) )
  1018. X        i++;
  1019. X      /* here is the first of the rhs */
  1020. X      j = 0;
  1021. X      while (estr[i] != '\0') {
  1022. X        algstr[j] = estr[i];
  1023. X        i++;
  1024. X        j++;
  1025. X      }
  1026. X      algstr[j] = '\0';
  1027. X
  1028. X      /* now replace every "letter" in algstr by a number */
  1029. X      k = 0;
  1030. X      j = 0;
  1031. X      while (algstr[j] != '\0') {
  1032. X        if (isalpha(algstr[j]) ) {
  1033. X            sprintf(temp1,"%d",REG(algstr[j]));
  1034. X            i = 0;
  1035. X            while (temp1[i] != '\0') {
  1036. X                tempstr[k] = temp1[i];
  1037. X                i++;
  1038. X                k++;
  1039. X            }
  1040. X        }
  1041. X        else {
  1042. X            tempstr[k] = algstr[j];
  1043. X            k++;
  1044. X        }
  1045. X        j++;
  1046. X     }
  1047. X     tempstr[k] = '\0';
  1048. X
  1049. X     strcpy(algstr,tempstr);
  1050. X     alg(tempstr,algstr);
  1051. X     REG(lhs) = rpneval(tempstr);
  1052. X
  1053. X
  1054. X}
  1055. X
  1056. X
  1057. X
  1058. X/* function Beval takes a boolean expression and evaluates it */
  1059. Xint Beval(s)
  1060. Xchar s[];
  1061. X{
  1062. X    int i, j, k;
  1063. X    char lhs[SHORTSTR];
  1064. X    char rhs[SHORTSTR];
  1065. X    char rel[SHORTSTR];
  1066. X    char temp1[MAXSTR];
  1067. X    char tempstr[MAXSTR];
  1068. X    char rpnstr[MAXSTR];
  1069. X    float left,right;
  1070. X
  1071. X    left = 0.0; 
  1072. X    right = 0.0;
  1073. X
  1074. X      /* now replace every "letter" in algstr by a number */
  1075. X      k = 0;
  1076. X      j = 0;
  1077. X      while (s[j] != '\0') {
  1078. X        if (isalpha(s[j]) ) {
  1079. X            sprintf(temp1,"%d",REG(s[j]));
  1080. X            i = 0;
  1081. X            while (temp1[i] != '\0') {
  1082. X                tempstr[k] = temp1[i];
  1083. X                i++;
  1084. X                k++;
  1085. X            }
  1086. X        }
  1087. X        else {
  1088. X            tempstr[k] = s[j];
  1089. X            k++;
  1090. X        }
  1091. X        j++;
  1092. X     }
  1093. X     tempstr[k] = '\0';
  1094. X
  1095. X     strcpy(s,tempstr);
  1096. X    i = 0;
  1097. X    j = 0;
  1098. X    while (s[i] != '\0' && !isrelop(s[i]) ) {
  1099. X        lhs[j] = s[i];
  1100. X        i++;
  1101. X        j++;
  1102. X    }
  1103. X    lhs[j] = '\0';
  1104. X
  1105. X    /* if s[i] is a relop then we need to know which one */
  1106. X
  1107. X    j = 0;
  1108. X    while (s[i] != '\0' && isrelop(s[i]) ) {
  1109. X        rel[j] = s[i];
  1110. X        i++;
  1111. X        j++;
  1112. X    }
  1113. X    rel[j] = '\0';
  1114. X
  1115. X    /* if there is a rhs, we need to copy it */
  1116. X    j = 0;
  1117. X    while (s[i] != '\0') {
  1118. X        rhs[j] = s[i];
  1119. X        i++;
  1120. X        j++;
  1121. X    }
  1122. X    rhs[j] = '\0';
  1123. X
  1124. X    if (lhs[0] != '\0') {
  1125. X        alg(rpnstr,lhs);
  1126. X        left = rpneval(rpnstr);
  1127. X    }
  1128. X    if (rhs[0] != '\0') {
  1129. X        alg(rpnstr,rhs);
  1130. X        right = rpneval(rpnstr);
  1131. X    }
  1132. X    if (rel[0] == '\0')
  1133. X        return (left == 0.0);
  1134. X    else {
  1135. X        if (streq(rel,"<")) {
  1136. X            return (left < right);
  1137. X        }
  1138. X        else if (streq(rel,"<=")) {
  1139. X            return (left <= right);
  1140. X        }
  1141. X        else if (streq(rel,">")) {
  1142. X            return (left > right);
  1143. X        }
  1144. X        else if (streq(rel,">=")) {
  1145. X            return (left >= right);
  1146. X        }
  1147. X        else if (streq(rel,"==")) {
  1148. X            return (left == right);
  1149. X        }
  1150. X        else if (streq(rel,"!=")) {
  1151. X            return (left != right);
  1152. X        }
  1153. X        else {
  1154. X            fprintf(stderr,"error in boolean expression %s\n",s);
  1155. X            exit(0);
  1156. X        }
  1157. X    }
  1158. X
  1159. X
  1160. X}
  1161. X
  1162. Xint isrelop(c)
  1163. Xchar c;
  1164. X{
  1165. X    if (
  1166. X        c == '<'
  1167. X        || c == '='
  1168. X        || c == '>'
  1169. X        || c == '!'
  1170. X       )
  1171. X
  1172. X        return TRUE;
  1173. X    else
  1174. X        return FALSE;
  1175. X}
  1176. X
  1177. END_OF_FILE
  1178.   if test 3196 -ne `wc -c <'source/expr.c'`; then
  1179.     echo shar: \"'source/expr.c'\" unpacked with wrong size!
  1180.   fi
  1181.   # end of 'source/expr.c'
  1182. fi
  1183. if test -f 'source/externs.c' -a "${1}" != "-c" ; then 
  1184.   echo shar: Will not clobber existing file \"'source/externs.c'\"
  1185. else
  1186.   echo shar: Extracting \"'source/externs.c'\" \(3026 characters\)
  1187.   sed "s/^X//" >'source/externs.c' <<'END_OF_FILE'
  1188. X/* the externally defined stuff */
  1189. X#include "defs.h"
  1190. X
  1191. Xextern char    outbuf[MAXSTR];    /* the output buffer */
  1192. Xextern int    obufpos;    /* position of next character to go
  1193. X                   into the output buffer */
  1194. X
  1195. Xextern int    FONTCHANGE;     /* do emit all font changes */
  1196. Xextern int    FIRSTPAGE;     /* first page to print */
  1197. Xextern int    LASTPAGE;     /* last page to print */
  1198. Xextern int    FORMFEED;     /* use formfeeds to go to next page */
  1199. Xextern int    SCANONLY;     /* do not just scan the text for errors */
  1200. Xextern char    CMDCHAR;     /* startup command character */
  1201. Xextern int     ISTTY;        /* output is to a tty */
  1202. Xextern int     CLEANPAGE;    /* the output page is still clean */
  1203. Xextern int    LASTPERIOD;    /* last output character was a period */
  1204. Xextern int    InExpression;    /* not in an expression */
  1205. Xextern int    ShouldPrint;    /* print output by default */
  1206. Xextern int    InMacro;    /* not in an in-line macro at first */
  1207. Xextern int     InDiversion;    /* not in a diversion at first */
  1208. Xextern int    tplace;        /* a global counter */
  1209. Xextern int    DivStart;    /* place last diversion started */
  1210. Xextern int    shadd;        /* should add a space to the buffer before
  1211. X                    anything else */
  1212. X
  1213. Xextern int    reg[MAXREG]; /* registers */
  1214. X
  1215. Xextern char    prinit[SHORTSTR];    /* printer initialization string */
  1216. Xextern char    cfont[SHORTSTR];    /* current font */
  1217. Xextern int     *clen;            /* pointer to length array */
  1218. Xextern int    *defl;            /* pointer to default length array */
  1219. Xextern char    header[MAXSTR];        /* header line */
  1220. Xextern char    footer[MAXSTR];        /* footer line */
  1221. Xextern char    tfor[FNUMBER];        /* title formats */
  1222. Xextern char    expstr[MAXSTR];        /* expression string */
  1223. Xextern char    macline[MAXSTR];    /* in-line macro command line */
  1224. Xextern char    outselect;        /* output method selector */
  1225. X
  1226. X/* holds the length of characters for each font measured in "dots" */
  1227. Xextern int H12nl[127];  /* Helvetica 12 point normal */
  1228. Xextern int H12bl[127];  /* Helvetica 12 point bold */
  1229. Xextern int P18bl[127];  /* Presentation 18 point bold */
  1230. Xextern char Pres[SHORTSTR]; /* to initialize mountable font */
  1231. Xextern int H6nl[127];   /* Helvetica 6 point normal */
  1232. Xextern int C12nl[127];  /* Courier 12 point fixed spacing */
  1233. Xextern int H12il[127];  /* Helvetica 12 point italics */
  1234. X
  1235. X
  1236. X
  1237. X
  1238. X/* here is the macrolist and definitions for the macros */
  1239. X
  1240. Xextern struct machead {
  1241. X    char mname[SHORTSTR];
  1242. X    struct macro *mfront, *mback;
  1243. X    struct machead *nextmacro;
  1244. X};
  1245. X
  1246. Xextern struct machead *macrolist ;
  1247. X
  1248. Xextern struct macro {
  1249. X    char mline[MAXSTR];
  1250. X    struct macro *mnext;
  1251. X};
  1252. X
  1253. X
  1254. X/* the trap line stuff is here */
  1255. X
  1256. Xextern struct traphead {
  1257. X    int location;
  1258. X    int dirty;
  1259. X    char tname[SHORTSTR];
  1260. X    struct traphead *nexttrap;
  1261. X};
  1262. Xextern struct traphead *traplist ;
  1263. X
  1264. X
  1265. X
  1266. X
  1267. X/* here is the stuff for the font stack */
  1268. X
  1269. Xextern struct macro *fstk ;
  1270. X
  1271. X
  1272. X
  1273. X
  1274. X/* a stack of pointers to integers */
  1275. Xextern struct intpstk {
  1276. X    int *iptr;
  1277. X    struct intpstk *inext;
  1278. X};
  1279. X
  1280. Xextern struct intpstk *ipstk;
  1281. X
  1282. X
  1283. Xextern struct cstack {
  1284. X    char datum;
  1285. X    struct cstack *link;
  1286. X};
  1287. X
  1288. X
  1289. Xextern struct stack {
  1290. X   float gdatum;
  1291. X   struct stack *glink;
  1292. X};
  1293. X
  1294. X
  1295. Xextern float pop();
  1296. Xextern char cpop();
  1297. Xextern char ctopofstack();
  1298. END_OF_FILE
  1299.   if test 3026 -ne `wc -c <'source/externs.c'`; then
  1300.     echo shar: \"'source/externs.c'\" unpacked with wrong size!
  1301.   fi
  1302.   # end of 'source/externs.c'
  1303. fi
  1304. if test -f 'source/globals.c' -a "${1}" != "-c" ; then 
  1305.   echo shar: Will not clobber existing file \"'source/globals.c'\"
  1306. else
  1307.   echo shar: Extracting \"'source/globals.c'\" \(2820 characters\)
  1308.   sed "s/^X//" >'source/globals.c' <<'END_OF_FILE'
  1309. X#include <stdio.h>
  1310. X#include "defs.h"
  1311. X
  1312. X/* global variables */
  1313. Xchar     outbuf[MAXBUF];        /* the output buffer */
  1314. Xint     obufpos = 0;        /* the position of the next character
  1315. X                    to go in the output buffer */
  1316. X
  1317. Xint    FONTCHANGE = TRUE;    /* do emit all font changes */
  1318. Xint    FIRSTPAGE = 1;         /* first page to print */
  1319. Xint    LASTPAGE = HUGE;    /* last page to print */
  1320. Xint    FORMFEED = TRUE;    /* use formfeeds to go to next page */
  1321. Xint    SCANONLY = FALSE;    /* do not just scan the text for errors */
  1322. Xchar    CMDCHAR = '.';        /* startup command character */
  1323. Xint    ISTTY = TRUE;        /* output is to a tty */
  1324. Xint     CLEANPAGE = TRUE;    /* the output page is still clean */
  1325. Xint    LASTPERIOD = FALSE;    /* last output character was a period */
  1326. Xint    InExpression = FALSE;    /* not in an expression */
  1327. Xint     ShouldPrint = TRUE;    /* default is to output text */
  1328. Xint    InMacro = FALSE;    /* we are not in macro at first */
  1329. Xint    InDiversion = FALSE;    /* we are not in a diversion at first */
  1330. Xint    tplace = 0;        /* a global counter */
  1331. Xint    DivStart = 0;        /* start of a diversion */
  1332. Xint    shadd = TRUE;        /* should add a space to the buffer before
  1333. X                    appending output */
  1334. X
  1335. Xint    reg[MAXREG];    /* registers */
  1336. Xchar     prinit[SHORTSTR];    /* printer initialization string */
  1337. Xchar     cfont[SHORTSTR];    /* the current font */
  1338. Xint    *clen;            /* pointer to the current length array */
  1339. Xint     *defl;            /* pointer to the default font length array */
  1340. Xchar    header[MAXSTR];        /* header line */
  1341. Xchar    footer[MAXSTR];        /* footer line */
  1342. Xchar    tfor[FNUMBER];     /* title formats */
  1343. Xchar    expstr[MAXSTR];        /* expression string */
  1344. Xchar    macline[MAXSTR];    /* an in-line macro command line */
  1345. Xchar     outselect;        /* output method selector */
  1346. X
  1347. X
  1348. X/* holds the length of characters for each font measured in "dots" */
  1349. Xint H12nl[127];  /* Helvetica 12 point normal */
  1350. Xint H12bl[127];  /* Helvetica 12 point bold */
  1351. Xint P18bl[127];  /* Presentation 18 point bold */
  1352. Xchar Pres[SHORTSTR];  /* string to initialize Presentation (mountable) font */
  1353. Xint H6nl[127];   /* Helvetica 6 point normal */
  1354. Xint C12nl[127];  /* Courier 12 point fixed spacing */
  1355. Xint H12il[127];  /* Helvetica 12 point italics */
  1356. X
  1357. X
  1358. X/* here is the macrolist and definitions for the macros */
  1359. X
  1360. Xstruct machead {
  1361. X    char mname[SHORTSTR];
  1362. X    struct macro *mfront, *mback;
  1363. X    struct machead *nextmacro;
  1364. X}  ;
  1365. Xstruct machead *macrolist = NULL;
  1366. X
  1367. Xstruct macro {
  1368. X    char mline[MAXSTR];
  1369. X    struct macro *mnext;
  1370. X};
  1371. X
  1372. X
  1373. X/* the trap line stuff is here */
  1374. X
  1375. Xstruct traphead {
  1376. X    int location;
  1377. X    int dirty;
  1378. X    char tname[SHORTSTR];
  1379. X    struct traphead *nexttrap;
  1380. X} ;
  1381. Xstruct traphead *traplist = NULL;
  1382. X
  1383. X
  1384. X
  1385. X/* here is the font stack */
  1386. Xstruct macro *fstk = NULL;
  1387. X
  1388. X/* a stack of pointers to integers */
  1389. Xstruct intpstk {
  1390. X    int *iptr;
  1391. X    struct intpstk *inext;
  1392. X} ;
  1393. Xstruct intpstk *ipstk = NULL;
  1394. X
  1395. X
  1396. Xstruct cstack {
  1397. X    char datum;
  1398. X    struct cstack *link;
  1399. X};
  1400. X
  1401. X
  1402. Xstruct stack {
  1403. X   float gdatum;
  1404. X   struct stack *glink;
  1405. X};
  1406. X
  1407. X
  1408. END_OF_FILE
  1409.   if test 2820 -ne `wc -c <'source/globals.c'`; then
  1410.     echo shar: \"'source/globals.c'\" unpacked with wrong size!
  1411.   fi
  1412.   # end of 'source/globals.c'
  1413. fi
  1414. if test -f 'source/macros.c' -a "${1}" != "-c" ; then 
  1415.   echo shar: Will not clobber existing file \"'source/macros.c'\"
  1416. else
  1417.   echo shar: Extracting \"'source/macros.c'\" \(3338 characters\)
  1418.   sed "s/^X//" >'source/macros.c' <<'END_OF_FILE'
  1419. X#include <stdio.h>
  1420. X#include <ctype.h>
  1421. X#include "defs.h"
  1422. X#include "externs.c"
  1423. X
  1424. X/* this file contains the stuff pertaining to macros */
  1425. X/* a macro consists of a header with the macro name in it,
  1426. X   and a pointer to a linked list of lines.  The macrolist
  1427. X   is a linked list of macros */
  1428. X
  1429. X
  1430. X/* add a line to the macro whose header is headptr */
  1431. XVOID macaddline(headptr,s)
  1432. Xstruct machead *headptr;
  1433. Xchar s[];
  1434. X{
  1435. X    struct macro *temp;
  1436. X    if (headptr == NULL) {
  1437. X        fprintf(stderr,"macro not defined -- fatal error \n");
  1438. X        exit(1);
  1439. X    }
  1440. X    else {
  1441. X        temp = (struct macro *) (malloc(sizeof(struct macro)));
  1442. X        strcpy(temp->mline,s);
  1443. X        temp->mnext = NULL;
  1444. X        if (headptr->mfront == NULL) {
  1445. X            headptr->mfront = temp;
  1446. X            headptr->mback = temp;
  1447. X        }
  1448. X        else {
  1449. X            headptr->mback->mnext = temp;
  1450. X            headptr->mback = temp;
  1451. X        }
  1452. X    }
  1453. X}
  1454. X
  1455. X
  1456. X
  1457. X/* add a macro of name s to the macro list ... the macro does not yet
  1458. X  have any lines in it. The macro list is actually a stack of macros. */
  1459. XVOID defmac(s,list)
  1460. Xchar s[];
  1461. Xstruct machead **list;
  1462. X{
  1463. X    struct machead *temp;
  1464. X    temp = (struct machead *)(malloc(sizeof(struct machead)));
  1465. X    temp->mfront = NULL;
  1466. X    temp->mback = NULL;
  1467. X    temp->nextmacro = *list;
  1468. X    strcpy(temp->mname,s);
  1469. X    *list = temp;
  1470. X}
  1471. X
  1472. X
  1473. X
  1474. X/* find a macro definition header by name */
  1475. Xstruct machead * findmac(s)
  1476. Xchar s[];
  1477. X{
  1478. X    struct machead *temp;
  1479. X    temp = macrolist;
  1480. X    while (temp != NULL && !streq(temp->mname,s)) {
  1481. X        temp = temp->nextmacro;
  1482. X    }
  1483. X    return temp;
  1484. X}
  1485. X
  1486. X
  1487. X
  1488. X/* process a macro */
  1489. Xprocmacro (cline, ifile,ofile)
  1490. Xchar cline[];
  1491. XFILE *ifile,*ofile;
  1492. X{
  1493. X
  1494. X        struct machead *macptr;
  1495. X        struct macro *lineptr;
  1496. X        char temp[MAXSTR];
  1497. X        char args[MAXCMD][MAXSTR];
  1498. X        int i,j, k, cmdnbr;
  1499. X         
  1500. X        /* first parse out any arguments in the cline */
  1501. X        for (i = 0; i < MAXCMD; i++)
  1502. X            args[i][0] = '\0';
  1503. X        i = 0;
  1504. X        j = 0;
  1505. X        k = 0;
  1506. X        cmdnbr = 0;
  1507. X        /* move in cline to skip the cmdchar */
  1508. X        while (cline[i] != '\0' && (isspace(cline[i]) || cline[i] == CMDCHAR) )
  1509. X            i++;
  1510. X
  1511. X        
  1512. X        /* copy each nonspace to argument */
  1513. X        while (cline[i] != '\0') {
  1514. X            j = 0;
  1515. X            while ( cline[i] != '\0' && ! isspace(cline[i])) {
  1516. X                args[cmdnbr][j] = cline[i];
  1517. X                i++;
  1518. X                j++;
  1519. X            }
  1520. X            args[cmdnbr][j] = '\0';
  1521. X            cmdnbr++;
  1522. X            /* skip white space */
  1523. X            while (cline[i] != '\0' && isspace(cline[i]))
  1524. X                i++;
  1525. X        }
  1526. X
  1527. X        macptr = findmac(args[0]);
  1528. X        if (macptr == NULL) {
  1529. X            fprintf(stderr,"command %s not found\n",args[0]);
  1530. X            exit(1);
  1531. X        }
  1532. X        else {
  1533. X            /* run through the lines in the macro */
  1534. X            lineptr = macptr->mfront;
  1535. X            while (lineptr != NULL) {
  1536. X
  1537. X                /* expand the line lineptr->mline to include
  1538. X                   any references to "$#" stuff */
  1539. X                
  1540. X                j = 0;
  1541. X                i = 0;
  1542. X                k = 0;
  1543. X                temp[0] = '\0';
  1544. X                while (lineptr->mline[i] != '\0') {
  1545. X                  if(lineptr->mline[i] == '$') {
  1546. X                    /* see if next is a digit */
  1547. X                    if (isdigit(lineptr->mline[i+1]) ){
  1548. X                     i++; /* skip the $ */
  1549. X                     cmdnbr = lineptr->mline[i] - '0';
  1550. X                     i++; /* skip the digit */
  1551. X                     k = 0;
  1552. X                     while (args[cmdnbr][k] != '\0') {
  1553. X                       temp[j] = args[cmdnbr][k];
  1554. X                       k++;
  1555. X                       j++;
  1556. X                     }
  1557. X                    }
  1558. X                    else {
  1559. X                     /* just copy it */
  1560. X                     temp[j] = lineptr->mline[i];
  1561. X                     i++;
  1562. X                     j++;
  1563. X                    }
  1564. X                  }
  1565. X                  else {
  1566. X                    temp[j] = lineptr->mline[i];
  1567. X                    i++;
  1568. X                    j++;
  1569. X                  }
  1570. X                }
  1571. X                temp[j] = '\0';
  1572. X                
  1573. X                
  1574. X                procline(ifile,ofile,temp);
  1575. X                lineptr = lineptr->mnext;
  1576. X            }
  1577. X        }
  1578. X}
  1579. X
  1580. X
  1581. END_OF_FILE
  1582.   if test 3338 -ne `wc -c <'source/macros.c'`; then
  1583.     echo shar: \"'source/macros.c'\" unpacked with wrong size!
  1584.   fi
  1585.   # end of 'source/macros.c'
  1586. fi
  1587. if test -f 'source/main.c' -a "${1}" != "-c" ; then 
  1588.   echo shar: Will not clobber existing file \"'source/main.c'\"
  1589. else
  1590.   echo shar: Extracting \"'source/main.c'\" \(4740 characters\)
  1591.   sed "s/^X//" >'source/main.c' <<'END_OF_FILE'
  1592. X#include <stdio.h>
  1593. X#include <ctype.h>
  1594. X
  1595. X#include "defs.h"
  1596. X#include "globals.c"
  1597. X
  1598. XFILE *fopen(), *infile, *outfile;
  1599. Xextern char First();
  1600. X
  1601. X
  1602. X
  1603. Xmain(argc, argv)
  1604. Xint argc;
  1605. Xchar *argv[];
  1606. X{  int argnbr;   /* number of non-switch command line arguments */
  1607. X
  1608. X   char *d;      /* a character pointer */
  1609. X
  1610. X   int tint;     /* temporary integer */
  1611. X   char tchar;   /* temporary character */
  1612. X   char tempstr[MAXSTR];    /* temporary string */
  1613. X
  1614. X
  1615. X
  1616. X  char filename[MAXFILE][SHORTSTR];  /* array of filenames */
  1617. X  int filenbr, fnbr;  /* number of files on command line */
  1618. X
  1619. X/* make all initializations */
  1620. Xinit();
  1621. X
  1622. X  filenbr = 0;
  1623. X  infile = stdin;
  1624. X  outfile = stdout;
  1625. X
  1626. X  /* is the output to a tty ? */
  1627. X  if (isatty(1) == 1) {
  1628. X    ISTTY = TRUE;
  1629. X  }
  1630. X  else  {
  1631. X    ISTTY = FALSE;
  1632. X  }
  1633. X
  1634. X
  1635. X  if (argc == 1)  {
  1636. X    infile = stdin;
  1637. X    outfile = stdout;
  1638. X    filenbr = 0;
  1639. X  }
  1640. X  else  {
  1641. X     /* skip the first argument, since it is meaningless */
  1642. X     argc--;
  1643. X     argv++;
  1644. X
  1645. X/* now process the remaining arguments until there are no more */
  1646. X
  1647. X   argnbr = 0;         /* number of non-switch arguments */
  1648. X   while (argc > 0 ) {
  1649. X     d = argv[0];
  1650. X     if (*d == '-') {
  1651. X        /* its a switch */
  1652. X    d++;     /* skip the '-' */
  1653. X    while (*d != '\0') {
  1654. X       switch(*d) {
  1655. X
  1656. X          case 'b': /* begin printing with page */
  1657. X            argv++;
  1658. X            argc--;
  1659. X            FIRSTPAGE = atoi(argv[0]);
  1660. X            ShouldPrint = FALSE;
  1661. X            break;
  1662. X
  1663. X          case 'e': /* end printing after page */
  1664. X            argv++;
  1665. X            argc--;
  1666. X            LASTPAGE = atoi(argv[0]);
  1667. X            break;
  1668. X
  1669. X          case 'd': /* define a register to have a certain value */
  1670. X            argv++;
  1671. X            argc--;
  1672. X            tchar = argv[0][0];
  1673. X            argv++;
  1674. X            argc--;
  1675. X            tint = atoi(argv[0]);
  1676. X            REG(tchar) = tint;
  1677. X            break;
  1678. X
  1679. X          case 'k': /* do not use formfeeds to go to next page */
  1680. X            FORMFEED = FALSE;
  1681. X            break;
  1682. X
  1683. X          case 'o':  /* use next file as outfile */
  1684. X            argv++;
  1685. X            argc--;
  1686. X            ISTTY = FALSE;
  1687. X            outfile = fopen(argv[0],"w");
  1688. X            break;
  1689. X
  1690. X
  1691. X          case 'p' : /* preview mode: do not emit font changes */
  1692. X            FONTCHANGE = FALSE;
  1693. X            break;
  1694. X
  1695. X
  1696. X          case 's': /* scan for errors only */
  1697. X            SCANONLY = TRUE;
  1698. X            outfile = fopen("/dev/null","w");
  1699. X            break;
  1700. X
  1701. X          case 't': /* set tabstops at n */
  1702. X            argv++;
  1703. X            argc--;
  1704. X            TABSTOPS = atoi(argv[0]);
  1705. X            break;
  1706. X
  1707. X          case 'v':  /* print version number and exit */
  1708. X            printf("Wroff version: 2.2, September 4, 1991\n");
  1709. X            exit(0);
  1710. X            break;
  1711. X
  1712. X              default :  fprintf(stderr,"unknown switch %c\n",*d);
  1713. X             fprintf(stderr,"usage: wroff [-kpsv] [-b n] [-e n] [-t n] [-d reg value] [-p] [-o outfile] [infilelist]\n");
  1714. X                     exit(1);
  1715. X             break;
  1716. X
  1717. X       }  /* end of switch */
  1718. X       d++;    /* move to next character */
  1719. X    } /* of while */
  1720. X     }
  1721. X     else {
  1722. X        /* its not a switch */
  1723. X    argnbr++;  /* number of non-switch arguments processed so far 
  1724. X                      including this one */
  1725. X    strcpy(filename[filenbr],argv[0]);
  1726. X    filenbr++;
  1727. X     }
  1728. X
  1729. X   /* move to next argument */
  1730. X   argc--;
  1731. X   argv++;
  1732. X   }  /* of while */
  1733. X  }   /* of else */
  1734. X
  1735. X/* end of argument processing */  
  1736. Xif (ISTTY)
  1737. X    FONTCHANGE = FALSE;
  1738. X
  1739. X/* this is the START of the ACTION */
  1740. X    /* initialize the printer */
  1741. X    if (FONTCHANGE) {
  1742. X        sprintf(outbuf,"%s",prinit);
  1743. X        sprintf(tempstr,"%c&l%dC",ESC,VSPACE);
  1744. X        strcat(outbuf,tempstr);
  1745. X        putout(outfile,outbuf);
  1746. X        outbuf[0] = '\0';
  1747. X        tempstr[0] = '\0';
  1748. X    }
  1749. X
  1750. X    if (filenbr == 0 ) 
  1751. X        procfile(infile,outfile);
  1752. X    else {
  1753. X        fnbr = 0;
  1754. X        while (fnbr < filenbr ) {
  1755. X            infile = fopen(filename[fnbr],"r");
  1756. X            if (infile == NULL) {
  1757. X                fprintf(stderr,"file %s not found\n",filename[fnbr]);
  1758. X                exit(1);
  1759. X            }
  1760. X            procfile(infile,outfile);
  1761. X            fclose(infile);
  1762. X            fnbr++;
  1763. X        } /* of while fnbr < filenbr  */
  1764. X    }
  1765. X
  1766. X    brek(infile,outfile);
  1767. X    brpage(infile,outfile);
  1768. X    fclose(infile);
  1769. X    fclose(outfile);
  1770. X    exit(0);
  1771. X
  1772. X        
  1773. X}  /* of main */
  1774. X
  1775. X
  1776. XVOID procfile(ifile,ofile)
  1777. XFILE *ifile, * ofile;
  1778. X{
  1779. X        char line[MAXSTR];
  1780. X        while (getline(line,ifile) != EOF) {
  1781. X            procline(ifile,ofile,line);
  1782. X        }
  1783. X        procline(ifile,ofile,line);
  1784. X}
  1785. X
  1786. XVOID procline(ifile,ofile,line)
  1787. XFILE *ifile,*ofile;
  1788. Xchar line[];
  1789. X{
  1790. X        checktraps(CURRY,ifile,ofile);    
  1791. X        if (First(line) == CMDCHAR)
  1792. X            command(line,ifile,ofile);
  1793. X        else if (isblank(line)) {
  1794. X            outbuf[obufpos] = '\0';
  1795. X            brek(ifile,ofile);
  1796. X            /* end the current line */
  1797. X            endln();
  1798. X            finishline(ifile,ofile);
  1799. X        }
  1800. X        else if (!FILLMODE)
  1801. X            nonfill(line,ifile,ofile);
  1802. X        else
  1803. X            format(line,ifile,ofile);
  1804. X
  1805. X}
  1806. X
  1807. X
  1808. X/* routine to finish a line and reinitialize all the counters */
  1809. XVOID finishline(ifile,ofile)
  1810. XFILE *ifile,*ofile;
  1811. X{
  1812. X    int i;
  1813. X    /* now tack on any CR */
  1814. X
  1815. X
  1816. X    for (i = 1; i <= LSPACE; i++) {
  1817. X        if (ShouldPrint) putit('\n',ofile);
  1818. X        CURRY = CURRY + VSPACE;
  1819. X    }
  1820. X
  1821. X
  1822. X    /* be sure to empty the buffer again */
  1823. X    outbuf[0] = '\0';
  1824. X    obufpos = 0;
  1825. X    CHARCNT = 0;
  1826. X    if (CURRY  + MTHREE > (PAGELENGTH - BOTTOMMARGIN)) {
  1827. X        brek(ifile,ofile);
  1828. X        brpage(ifile,ofile);
  1829. X    }
  1830. X}
  1831. X
  1832. X
  1833. END_OF_FILE
  1834.   if test 4740 -ne `wc -c <'source/main.c'`; then
  1835.     echo shar: \"'source/main.c'\" unpacked with wrong size!
  1836.   fi
  1837.   # end of 'source/main.c'
  1838. fi
  1839. if test -f 'source/makefile' -a "${1}" != "-c" ; then 
  1840.   echo shar: Will not clobber existing file \"'source/makefile'\"
  1841. else
  1842.   echo shar: Extracting \"'source/makefile'\" \(581 characters\)
  1843.   sed "s/^X//" >'source/makefile' <<'END_OF_FILE'
  1844. XCFLAGS= -i 
  1845. XGLOBALS = globals.c defs.h
  1846. XEXTERNS = externs.c
  1847. XOBJS = main.o util.o io.o command.o init.o format.o macros.o traps.o stacks.o \
  1848. X    expr.o alg.o rpn.o
  1849. Xa.out : $(OBJS)
  1850. X    $(CC) $(CFLAGS) $(OBJS)
  1851. X
  1852. Xmain.o : $(GLOBALS)
  1853. X$(OBJS) : $(EXTERNS)
  1854. X
  1855. Xinstall :
  1856. X    strip a.out
  1857. X    mv a.out /usr/ECU/bin/wroff
  1858. X    chmod go+rx /usr/ECU/bin/wroff
  1859. X    chown root /usr/ECU/bin/wroff
  1860. X
  1861. Xdoc : macs.w wroff.1.w
  1862. X    a.out macs.w wroff.1.w -p -k -o doc.pr
  1863. X
  1864. Xtut : macs.w wroff.tut.w
  1865. X    a.out macs.w wroff.tut.w -p -k -o tut.pr
  1866. X
  1867. Xtar : 
  1868. X    rm wroff.tar
  1869. X    tar cvf ../wroff.tar *
  1870. X    mv ../wroff.tar .
  1871. X
  1872. X
  1873. Xclean:
  1874. X    rm a.out *.o
  1875. END_OF_FILE
  1876.   if test 581 -ne `wc -c <'source/makefile'`; then
  1877.     echo shar: \"'source/makefile'\" unpacked with wrong size!
  1878.   fi
  1879.   # end of 'source/makefile'
  1880. fi
  1881. if test -f 'source/rpn.c' -a "${1}" != "-c" ; then 
  1882.   echo shar: Will not clobber existing file \"'source/rpn.c'\"
  1883. else
  1884.   echo shar: Extracting \"'source/rpn.c'\" \(1324 characters\)
  1885.   sed "s/^X//" >'source/rpn.c' <<'END_OF_FILE'
  1886. X#include <stdio.h>
  1887. X#include "defs.h"
  1888. X#include "externs.c"
  1889. X
  1890. Xextern struct stack;
  1891. Xextern float pop();
  1892. Xextern int push();
  1893. Xextern int inits();
  1894. Xstruct stack *st;
  1895. X
  1896. Xint isdigit(c)
  1897. Xchar c;
  1898. X{
  1899. X  return ( (c <= '9') && (c >= '0'));
  1900. X}
  1901. X
  1902. X
  1903. Xint isop(ch)
  1904. Xchar ch;
  1905. X{
  1906. X   return ( (ch == '+')
  1907. X    || (ch == '-')
  1908. X    || (ch == '*')
  1909. X    || (ch == '/')
  1910. X    || (ch == ' ')
  1911. X      );
  1912. X}
  1913. X
  1914. X
  1915. X
  1916. Xfloat rpneval(s)
  1917. Xchar *s;
  1918. X{
  1919. X float i,j ;
  1920. X float sumr,sumi;
  1921. X float frac;
  1922. X inits(&st);
  1923. X while (*s != '\0') {
  1924. X  if (isop(*s)) {
  1925. X  switch(*s) {
  1926. X    case '+' :
  1927. X           i = pop(&st);
  1928. X           j = pop (&st);
  1929. X           push(&st,i+j);
  1930. X           break;
  1931. X    case '-' :
  1932. X           i = pop(&st);
  1933. X           j = pop(&st);
  1934. X           push(&st,j-i);
  1935. X          break;
  1936. X    case '*' :
  1937. X           i = pop(&st);
  1938. X               j = pop(&st);
  1939. X           push(&st,i*j);
  1940. X          break;
  1941. X    case '/' :
  1942. X           i = pop(&st);
  1943. X           j =  pop(&st);
  1944. X           push(&st,(j / i) );
  1945. X          break;
  1946. X    case ' ' :
  1947. X          break;
  1948. X  }
  1949. X  }
  1950. X  else {
  1951. X    if (isdigit(*s)) {
  1952. X      sumi = 0.0;
  1953. X      sumr = 0.0;
  1954. X      while (isdigit(*s)) {
  1955. X    sumi = 10 * sumi + (*s  - '0');
  1956. X    s++;
  1957. X      }
  1958. X      if ((*s) == '.') {
  1959. X        s++;
  1960. X    sumr = 0.0;
  1961. X    frac = 0.1;
  1962. X    while (isdigit(*s)) {
  1963. X     sumr = sumr + (*s -'0') * frac;
  1964. X     frac = frac * 0.1;
  1965. X     s++;
  1966. X        }
  1967. X      }
  1968. X      push(&st,sumi + sumr);
  1969. X      s--;
  1970. X    }
  1971. X    
  1972. X  }
  1973. X  s++;
  1974. X }
  1975. X return pop(&st);
  1976. X }
  1977. X
  1978. END_OF_FILE
  1979.   if test 1324 -ne `wc -c <'source/rpn.c'`; then
  1980.     echo shar: \"'source/rpn.c'\" unpacked with wrong size!
  1981.   fi
  1982.   # end of 'source/rpn.c'
  1983. fi
  1984. if test -f 'source/stacks.c' -a "${1}" != "-c" ; then 
  1985.   echo shar: Will not clobber existing file \"'source/stacks.c'\"
  1986. else
  1987.   echo shar: Extracting \"'source/stacks.c'\" \(2664 characters\)
  1988.   sed "s/^X//" >'source/stacks.c' <<'END_OF_FILE'
  1989. X#include <stdio.h>
  1990. X#include "defs.h"
  1991. X#include "externs.c"
  1992. X
  1993. X/* this file contains the stack handlers */
  1994. X
  1995. X
  1996. X/* we use pushf to push a font onto the font stack */
  1997. X/* note that the same struct as for macros is used */
  1998. XVOID pushf(s,l)
  1999. Xchar s[];
  2000. Xstruct macro **l;
  2001. X{
  2002. X    struct macro *temp;
  2003. X    temp = (struct macro *) (malloc(sizeof(struct macro)));
  2004. X    strcpy(temp->mline,s);
  2005. X    temp->mnext = *l;
  2006. X    *l = temp;
  2007. X}
  2008. X
  2009. XVOID popf(s,l)
  2010. Xchar s[];
  2011. Xstruct macro **l;
  2012. X{
  2013. X    struct macro *temp;
  2014. X    temp = *l;
  2015. X    if (temp != NULL) {
  2016. X        strcpy(s,temp->mline);
  2017. X        (*l) = temp->mnext;
  2018. X        free(temp);
  2019. X    }
  2020. X    else {
  2021. X        strcpy(s,prinit);
  2022. X    }
  2023. X
  2024. X}
  2025. X
  2026. XVOID popi(x,l)
  2027. Xint **x;
  2028. Xstruct intpstk **l;
  2029. X{
  2030. X    struct intpstk *temp;
  2031. X    temp = *l;
  2032. X    if ( temp != NULL) {
  2033. X        *x = (temp->iptr);
  2034. X        (*l) = temp->inext;
  2035. X        free (temp);
  2036. X    }
  2037. X    else
  2038. X        *x = defl;
  2039. X}
  2040. X
  2041. X
  2042. XVOID pushi(x,l)
  2043. Xint *x;
  2044. Xstruct intpstk **l;
  2045. X{
  2046. X    struct intpstk *temp;
  2047. X    temp = (struct intpstk *) (malloc(sizeof(struct intpstk)));
  2048. X    temp->iptr = x;
  2049. X    (temp->inext) = (*l);
  2050. X    (*l) = temp;
  2051. X}
  2052. X
  2053. Xstruct stack *stackalloc()
  2054. X{
  2055. X  return ((struct stack *)( malloc(sizeof(struct stack))));
  2056. X};
  2057. X
  2058. Xstruct cstack *cstackalloc()
  2059. X{ 
  2060. X   return (( struct cstack*)(malloc(sizeof(struct cstack))));
  2061. X};
  2062. X
  2063. X
  2064. X
  2065. XVOID push(s,item)
  2066. X struct stack **s;
  2067. X float item;
  2068. X{
  2069. X  struct stack *t;
  2070. X  t = stackalloc();
  2071. X  t->gdatum = item;
  2072. X  t->glink = *s;
  2073. X  *s = t;
  2074. X}
  2075. X
  2076. XVOID cpush(s,item)
  2077. X struct cstack **s;
  2078. X char item;
  2079. X{
  2080. X  struct cstack *t;
  2081. X  t = cstackalloc();
  2082. X  t->datum = item;
  2083. X  t->link = *s;
  2084. X  *s = t;
  2085. X}
  2086. X
  2087. X
  2088. X
  2089. X
  2090. Xfloat pop(s)
  2091. X struct stack **s;
  2092. X{
  2093. X  struct stack *t;
  2094. X  t = *s;
  2095. X  *s = (*s)->glink;
  2096. X  return (t->gdatum);
  2097. X}
  2098. X
  2099. Xchar cpop(s)
  2100. X  struct cstack **s;
  2101. X{
  2102. X  struct cstack *t;
  2103. X  t = *s;
  2104. X  *s = (*s)->link;
  2105. X  return (t->datum);
  2106. X}
  2107. X
  2108. Xchar ctopofstack(s)
  2109. X  struct cstack *s;
  2110. X  {
  2111. X    if (! iscempty(s) )
  2112. X       return (s)->datum;
  2113. X    else
  2114. X       return NULL;
  2115. X  }
  2116. X
  2117. X
  2118. XVOID inits(s)
  2119. X  struct stack **s;
  2120. X  {
  2121. X   *s = NULL;
  2122. X  }
  2123. X
  2124. XVOID initcs(s)
  2125. X  struct cstack **s;
  2126. X  {
  2127. X    *s = NULL;
  2128. X}
  2129. X
  2130. X
  2131. Xint isempty(s)
  2132. X struct stack *s;
  2133. X {
  2134. X  return (s == NULL);
  2135. X }
  2136. X
  2137. X
  2138. Xint iscempty(s)
  2139. X struct cstack*s;
  2140. X {
  2141. X   return (s == NULL);
  2142. X}
  2143. X
  2144. X
  2145. X
  2146. XVOID getint(pn)
  2147. X int *pn;
  2148. X{
  2149. X  int sign;
  2150. X  int sum;
  2151. X  char c;
  2152. X
  2153. X  while (( c = getchar()) == ' ' || c == '\n' || c == '\t')
  2154. X    ;
  2155. X  sign = 1;
  2156. X
  2157. X  if (c == '+' || c == '-') {
  2158. X    sign = (c=='+') ? 1 : -1;
  2159. X    c = getchar();
  2160. X  }
  2161. X
  2162. X  sum = 0;
  2163. X
  2164. X  while ( (c >= '0') && (c <= '9') ) {
  2165. X     sum  = 10 * (sum ) + c - '0';
  2166. X
  2167. X     c = getchar();
  2168. X  }
  2169. X
  2170. X  sum *= sign;
  2171. X  (*pn) = sum;
  2172. X
  2173. X
  2174. X}
  2175. X
  2176. XVOID dumpfstack(st)
  2177. Xstruct stack *st;
  2178. X{
  2179. X  while (st != NULL) {
  2180. X    printf("=== %10.2f\n",st->gdatum);
  2181. X    st = st->glink;
  2182. X  }
  2183. X}
  2184. X
  2185. XVOID dumpcstack(st)
  2186. X  struct cstack *st;
  2187. X{
  2188. X  while (st != NULL ) {
  2189. X     printf("=== %c\n",st->datum);
  2190. X     st = st->link;
  2191. X  }
  2192. X}
  2193. X
  2194. X
  2195. END_OF_FILE
  2196.   if test 2664 -ne `wc -c <'source/stacks.c'`; then
  2197.     echo shar: \"'source/stacks.c'\" unpacked with wrong size!
  2198.   fi
  2199.   # end of 'source/stacks.c'
  2200. fi
  2201. if test -f 'source/tags' -a "${1}" != "-c" ; then 
  2202.   echo shar: Will not clobber existing file \"'source/tags'\"
  2203. else
  2204.   echo shar: Extracting \"'source/tags'\" \(2969 characters\)
  2205.   sed "s/^X//" >'source/tags' <<'END_OF_FILE'
  2206. XBeval    expr.c    ?^int Beval(s)$?
  2207. XFirst    util.c    ?^char First(s)$?
  2208. XMmain    main.c    ?^main(argc, argv)$?
  2209. XMmaketest    maketest.c    ?^VOID finishline(ifile,ofile)$$?
  2210. Xaddbuf    util.c    ?^addbuf(s)$?
  2211. Xaddstr    util.c    ?^VOID addstr(s,sf,sb)$?
  2212. Xalg    alg.c    ?^VOID alg(as,t)$?
  2213. Xappend    format.c    ?^VOID append(s,chcnt)$?
  2214. Xargtype    command.c    ?^int argtype (s)$?
  2215. Xargval    command.c    ?^int argval(s)$?
  2216. Xbrek    format.c    ?^VOID brek(ifile,ofile)$?
  2217. Xbrpage    io.c    ?^VOID brpage(ifile,f) $?
  2218. Xchecktraps    traps.c    ?^checktraps(n,ifile,ofile)$?
  2219. Xcleantraps    traps.c    ?^cleantraps()$?
  2220. Xcommand    command.c    ?^command(s,ifile,ofile)$?
  2221. Xcpop    stacks.c    ?^char cpop(s)$?
  2222. Xcpush    stacks.c    ?^VOID cpush(s,item)$?
  2223. Xcstackalloc    stacks.c    ?^struct cstack *cstackalloc()$?
  2224. Xctopofstack    stacks.c    ?^char ctopofstack(s)$?
  2225. Xdefmac    macros.c    ?^VOID defmac(s,list)$?
  2226. Xdeftrap    traps.c    ?^VOID deftrap(s,loc,list)$?
  2227. Xdumpcstack    stacks.c    ?^VOID dumpcstack(st)$?
  2228. Xdumpfstack    stacks.c    ?^VOID dumpfstack(st)$?
  2229. Xdumptraps    traps.c    ?^dumptraps()$?
  2230. Xendln    io.c    ?^VOID endln()$?
  2231. Xerror    util.c    ?^VOID error(s)$?
  2232. Xeval    expr.c    ?^eval(estr)$?
  2233. Xexpand    util.c    ?^VOID expand(tempstr,s)$?
  2234. Xexpndreg    util.c    ?^expndreg(cmd1,cmd2)$?
  2235. Xfindmac    macros.c    ?^struct machead * findmac(s)$?
  2236. Xfinishline    main.c    ?^VOID finishline(ifile,ofile)$?
  2237. Xformat    format.c    ?^format(s,ifile,f)$?
  2238. Xforprint    io.c    ?^VOID forprint(ifile,f,diff)$?
  2239. Xgetint    stacks.c    ?^VOID getint(pn)$?
  2240. Xgetline    io.c    ?^VOID getline(s,f)$?
  2241. Xgetword    format.c    ?^VOID getword(t,s,i)$?
  2242. XgotoX    io.c    ?^gotoX(ifile,ofile,s)$?
  2243. XgotoXY    io.c    ?^gotoXY(ifile,ofile,x,y)$?
  2244. XgotoY    io.c    ?^gotoY(ifile,ofile,s)$?
  2245. Xinit    init.c    ?^VOID init()$?
  2246. Xinitcs    stacks.c    ?^VOID initcs(s)$?
  2247. Xinits    stacks.c    ?^VOID inits(s)$?
  2248. Xisblank    util.c    ?^int isblank(s)$?
  2249. Xiscempty    stacks.c    ?^int iscempty(s)$?
  2250. Xisdigit    rpn.c    ?^int isdigit(c)$?
  2251. Xisempty    stacks.c    ?^int isempty(s)$?
  2252. Xisop    rpn.c    ?^int isop(ch)$?
  2253. Xisrelop    expr.c    ?^int isrelop(c)$?
  2254. Xlength    format.c    ?^int length(c)$?
  2255. Xmacaddline    macros.c    ?^VOID macaddline(headptr,s)$?
  2256. Xnonfill    format.c    ?^nonfill(s,ifile,f)$?
  2257. Xnullprint    io.c    ?^VOID nullprint(ifile,ofile,diff)$?
  2258. Xoutput    io.c    ?^VOID output(ifile,ofile,n)$?
  2259. Xparseword    format.c    ?^VOID parseword(tstring,word,wordlength,chcnt,ifile?
  2260. Xpop    stacks.c    ?^float pop(s)$?
  2261. Xpopf    stacks.c    ?^VOID popf(s,l)$?
  2262. Xpopi    stacks.c    ?^VOID popi(x,l)$?
  2263. Xprec    alg.c    ?^int prec(ch)$?
  2264. Xprocfile    main.c    ?^VOID procfile(ifile,ofile)$?
  2265. Xprocline    main.c    ?^VOID procline(ifile,ofile,line)$?
  2266. Xprocmacro    macros.c    ?^procmacro (cline, ifile,ofile)$?
  2267. Xpush    stacks.c    ?^VOID push(s,item)$?
  2268. Xpushf    stacks.c    ?^VOID pushf(s,l)$?
  2269. Xpushi    stacks.c    ?^VOID pushi(x,l)$?
  2270. Xputfoot    io.c    ?^putfoot(ifile,ofile)$?
  2271. Xputhead    io.c    ?^puthead(ifile,ofile)$?
  2272. Xputit    io.c    ?^VOID putit(c,f)$?
  2273. Xputout    io.c    ?^VOID putout(f,s)$?
  2274. Xrawout    io.c    ?^VOID rawout(f,s)$?
  2275. Xrpneval    rpn.c    ?^float rpneval(s)$?
  2276. Xsetparm    command.c    ?^int setparm(sparm,satype,svalue,sdflt,smin,smax)$?
  2277. Xstackalloc    stacks.c    ?^struct stack *stackalloc()$?
  2278. Xstreq    util.c    ?^int streq(s,t)$?
  2279. Xtitle    util.c    ?^VOID title(ostr,istr,lmargin,rmargin,delim,tcnt,fs?
  2280. Xtprint    io.c    ?^VOID tprint(ifile,ofile,diff)$?
  2281. END_OF_FILE
  2282.   if test 2969 -ne `wc -c <'source/tags'`; then
  2283.     echo shar: \"'source/tags'\" unpacked with wrong size!
  2284.   fi
  2285.   # end of 'source/tags'
  2286. fi
  2287. if test -f 'source/test.c' -a "${1}" != "-c" ; then 
  2288.   echo shar: Will not clobber existing file \"'source/test.c'\"
  2289. else
  2290.   echo shar: Extracting \"'source/test.c'\" \(1442 characters\)
  2291.   sed "s/^X//" >'source/test.c' <<'END_OF_FILE'
  2292. X/* transparent mode */
  2293. X{
  2294. X    char xch;
  2295. X    int xquit; 
  2296. X
  2297. X    xquit = FALSE;
  2298. X
  2299. X    while ( (xch = getc(ifile)) != EOF && !xquit) {
  2300. X     if (xch == '\n') {  /* we have a newline, so must check what comes next */
  2301. X       xch = getc(ifile);  
  2302. X       /* it could be EOF !*/
  2303. X       if (xch == EOF) {  /* the file ended with a newline */
  2304. X        fprintf(ofile,"\n");
  2305. X        xquit = TRUE;
  2306. X       }
  2307. X       else if (xch == CMDCHAR ){  /* if we have a CMDCHAR we may be in business */
  2308. X         xch = getc(ifile);
  2309. X         /* be sure it isn't an EOF */
  2310. X         if (xch == EOF) {  /* file ended with "\nCMDCHAR" */
  2311. X        fprintf(ofile,"\n%c",CMDCHAR);
  2312. X        xquit = TRUE;
  2313. X         }
  2314. X         else {  /* we now have "\nCMDCHAR" followed by something real */
  2315. X           if (xch == 'e')  {  /* wow --- getting close */
  2316. X         xch = getc(ifile);
  2317. X         /* is it? is it? a "t" ?*/
  2318. X         if (xch == EOF) { /* nuts */
  2319. X           fprintf(ofile,"\n%ce",CMDCHAR);
  2320. X           xquit = TRUE;
  2321. X         }
  2322. X         else if (xch == 't') { /* GOT IT!  Yea! */
  2323. X
  2324. X            xquit = TRUE;
  2325. X         }
  2326. X         else {  /* gloom! */
  2327. X            fprintf(ofile,"\n%ce%c",CMDCHAR,xch);
  2328. X         }
  2329. X           }
  2330. X           else { /* broken heart */
  2331. X         fprintf(ofile,"\n%c%c",CMDCHAR,xch);
  2332. X           }
  2333. X         }
  2334. X
  2335. X       }
  2336. X       else { /* not a CMDCHAR -- just copy \n and the char to the output */
  2337. X        fprintf(ofile,"\n%c",xch);
  2338. X       }
  2339. X     }
  2340. X     else {  /* just copy the character to output */
  2341. X       putc(xch,ofile);
  2342. X     }
  2343. X     
  2344. X    }  /* of while loop */
  2345. X
  2346. X    /* at end of the loop output a newline */
  2347. X    putc('\n',ofile);
  2348. X
  2349. X    
  2350. X
  2351. X}
  2352. X /* end of transparent mode */
  2353. END_OF_FILE
  2354.   if test 1442 -ne `wc -c <'source/test.c'`; then
  2355.     echo shar: \"'source/test.c'\" unpacked with wrong size!
  2356.   fi
  2357.   # end of 'source/test.c'
  2358. fi
  2359. if test -f 'source/traps.c' -a "${1}" != "-c" ; then 
  2360.   echo shar: Will not clobber existing file \"'source/traps.c'\"
  2361. else
  2362.   echo shar: Extracting \"'source/traps.c'\" \(1706 characters\)
  2363.   sed "s/^X//" >'source/traps.c' <<'END_OF_FILE'
  2364. X#include <stdio.h>
  2365. X#include "defs.h"
  2366. X#include "externs.c"
  2367. X
  2368. X/* this file contains the stuff pertaining to traps.*/
  2369. X/* a trap consists of a header with the trap name in it,
  2370. X   and a pointer to a linked list of lines.  The traplist
  2371. X   is a linked list of traps */
  2372. X
  2373. X
  2374. X
  2375. X
  2376. X/* add a trap of name s to the trap list ... the trap does not yet
  2377. X  have any lines in it. The list is HAS to be kept ordered ! */
  2378. XVOID deftrap(s,loc,list)
  2379. Xchar s[];
  2380. Xint loc;
  2381. Xstruct traphead **list;
  2382. X{
  2383. X    struct traphead *temp;
  2384. X    if ((*list == NULL) || (loc < (*list)->location) ) {
  2385. X        temp = (struct traphead *)(malloc(sizeof(struct traphead)));
  2386. X        temp->nexttrap= *list;
  2387. X        temp->location = loc;
  2388. X        temp->dirty = FALSE;
  2389. X        strcpy(temp->tname,s);
  2390. X        *list = temp;
  2391. X    }
  2392. X    else 
  2393. X        deftrap(s,loc,&((*list)->nexttrap));
  2394. X}
  2395. X
  2396. X
  2397. X
  2398. X/* make the trap line 'clean' instead of dirty */
  2399. Xcleantraps()
  2400. X{
  2401. X    struct traphead *temp;
  2402. X    temp = traplist;
  2403. X    while (temp != NULL) {
  2404. X        temp->dirty = FALSE;
  2405. X        temp = temp->nexttrap;
  2406. X    }
  2407. X}
  2408. X
  2409. X/* check for any traps that are "clean" but that must be sprung
  2410. X   before the CURRY exceeds N --- spring these traps */
  2411. Xchecktraps(n,ifile,ofile)
  2412. Xint n;
  2413. XFILE *ifile, *ofile;
  2414. X{
  2415. X
  2416. X    struct traphead *temp;
  2417. X    temp = traplist;
  2418. X    while (temp != NULL) {
  2419. X        if ((temp->location <= n) && (temp->dirty == FALSE) ){
  2420. X            temp->dirty = TRUE;
  2421. X            /* go to that place on the page */
  2422. X            gotoXY(ifile,ofile,LMARGIN - length(' '),temp->location);
  2423. X            procmacro(temp->tname,ifile,ofile);
  2424. X        }
  2425. X        temp = temp->nexttrap;
  2426. X    }
  2427. X
  2428. X}
  2429. X
  2430. X
  2431. X
  2432. X/* debug procedure to dump trap line */
  2433. Xdumptraps()
  2434. X{
  2435. X    struct traphead *temp;
  2436. X    temp = traplist;
  2437. X    while (temp != NULL) {
  2438. X        fprintf(stderr,"debug: trap line holds macro ->%s<- at %d\n",
  2439. X            temp->tname,temp->location);
  2440. X        temp = temp->nexttrap;
  2441. X    }
  2442. X}
  2443. X
  2444. X
  2445. END_OF_FILE
  2446.   if test 1706 -ne `wc -c <'source/traps.c'`; then
  2447.     echo shar: \"'source/traps.c'\" unpacked with wrong size!
  2448.   fi
  2449.   # end of 'source/traps.c'
  2450. fi
  2451. echo shar: End of archive 3 \(of 5\).
  2452. cp /dev/null ark3isdone
  2453. MISSING=""
  2454. for I in 1 2 3 4 5 ; do
  2455.     if test ! -f ark${I}isdone ; then
  2456.     MISSING="${MISSING} ${I}"
  2457.     fi
  2458. done
  2459. if test "${MISSING}" = "" ; then
  2460.     echo You have unpacked all 5 archives.
  2461.     rm -f ark[1-9]isdone
  2462. else
  2463.     echo You still must unpack the following archives:
  2464.     echo "        " ${MISSING}
  2465. fi
  2466. exit 0
  2467. exit 0 # Just in case...
  2468. -- 
  2469. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2470. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2471. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2472. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2473.