home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume23 / abc / part22 < prev    next >
Encoding:
Internet Message Format  |  1991-01-08  |  54.3 KB

  1. Subject:  v23i101:  ABC interactive programming environment, Part22/25
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 533435ee 634a895b 374c7342 db43f9b7
  5.  
  6. Submitted-by: Steven Pemberton <steven@cwi.nl>
  7. Posting-number: Volume 23, Issue 101
  8. Archive-name: abc/part22
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then feed it
  12. # into a shell via "sh file" or similar.  To overwrite existing files,
  13. # type "sh file -c".
  14. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  16. # Contents:  abc/b/b1memo.c abc/b/b1mess.c abc/bhdrs/b.h
  17. #   abc/bhdrs/b0lan.h abc/bint1/i1nut.c abc/bint2/DEP
  18. #   abc/bint3/i3com.c abc/bint3/i3imm.c abc/bint3/i3in2.c
  19. #   abc/bint3/i3ini.c abc/boot/main.h abc/ehdrs/keys.h
  20. #   abc/ehdrs/node.h abc/keys/DEP abc/stc/i2stc.h abc/tc/tputs.c
  21. # Wrapped by rsalz@litchi.bbn.com on Mon Dec 17 13:28:23 1990
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 22 (of 25)."'
  25. if test -f 'abc/b/b1memo.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'abc/b/b1memo.c'\"
  27. else
  28.   echo shar: Extracting \"'abc/b/b1memo.c'\" \(2602 characters\)
  29.   sed "s/^X//" >'abc/b/b1memo.c' <<'END_OF_FILE'
  30. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  31. X
  32. X/* general memory handling */
  33. X
  34. X#include "b.h"
  35. X#include "bmem.h"
  36. X
  37. Xchar *malloc();
  38. Xchar *realloc();
  39. X
  40. XVisible ptr getmem(syze) unsigned syze; {
  41. X    ptr p= (ptr) malloc(syze);
  42. X    if (p == Nil) memexh();
  43. X#ifdef MEMTRACE
  44. X    writetrace(F_ALLOC, p, syze);
  45. X#endif
  46. X    return p;
  47. X}
  48. X
  49. XVisible Procedure regetmem(v, syze) ptr *v; unsigned syze; {
  50. X    ptr p= (ptr) realloc(*v, syze);
  51. X    if (p == Nil) memexh();
  52. X#ifdef MEMTRACE
  53. X    writetrace(F_FREE, *v, 0);
  54. X    writetrace(F_ALLOC, p, syze);
  55. X#endif
  56. X    *v= p;
  57. X}
  58. X
  59. XVisible Procedure freemem(p) ptr p; {
  60. X#ifdef MEMTRACE
  61. X    writetrace(F_FREE, p, 0);
  62. X#endif
  63. X    free((char *)p);
  64. X}
  65. X
  66. XVisible ptr savestr(s) char *s; {
  67. X    ptr p= (ptr) getmem((unsigned) strlen(s) + 1);
  68. X    strcpy(p, s);
  69. X    return p;
  70. X}
  71. X
  72. X#ifdef MEMTRACE
  73. X
  74. X/*
  75. X * to fix memory that surely won't be free'd
  76. X */
  77. XVisible Procedure fixmem(p) ptr p; {
  78. X    writetrace(F_FREE, p, 0);
  79. X}
  80. X
  81. Xextern FILE *memfp;    /* set in ??main.c */
  82. X
  83. Xwritetrace(flag, p, size) int flag; ptr *p; unsigned size; {
  84. X    address *frameptr;
  85. X    
  86. X    if (memfp == NULL)
  87. X        return;
  88. X    fwrite(&flag, sizeof(int), 1, memfp);
  89. X    fwrite(&p, sizeof(ptr), 1, memfp);
  90. X    fwrite(&size, sizeof(unsigned), 1, memfp);
  91. X    
  92. X    frameptr= (unsigned*) &flag - 1; 
  93. X    frameptr= (unsigned*) *frameptr;    /* skip getmem or freemem */
  94. X    do {
  95. X        /* dump PC */
  96. X        fwrite((char*)(frameptr-2), sizeof(address), 1, memfp);
  97. X        /* follow FP */
  98. X        frameptr= (unsigned*) *frameptr;
  99. X    } while (*frameptr);
  100. X    fwrite((char*)frameptr, sizeof(address), 1, memfp);
  101. X}
  102. X
  103. X#endif /*MEMTRACE*/
  104. X
  105. X/************************************************************************/
  106. X
  107. X#define BUFINCR 100
  108. X
  109. XVisible Procedure bufinit(bp) bufadm *bp; {
  110. X    bp->buf= (char *) getmem((unsigned) BUFINCR);
  111. X    bp->ptr= bp->buf;
  112. X    bp->end= bp->buf + BUFINCR;
  113. X    *(bp->ptr)= '\0';
  114. X}
  115. X
  116. XVisible Procedure buffree(bp) bufadm *bp; {
  117. X    freemem((ptr) bp->buf);
  118. X}
  119. X
  120. XVisible Procedure bufreinit(bp) bufadm *bp; {
  121. X    buffree(bp);
  122. X    bufinit(bp);
  123. X}
  124. X
  125. XVisible Procedure bufgrow(bp) bufadm *bp; {
  126. X    int n_ptr= bp->ptr - bp->buf;
  127. X    int syze= (bp->end - bp->buf) + BUFINCR;
  128. X    
  129. X    regetmem((ptr *) &(bp->buf), (unsigned) syze);
  130. X    bp->ptr= bp->buf + n_ptr;
  131. X    bp->end= bp->buf + syze;
  132. X}
  133. X
  134. XVisible Procedure bufpush(bp, c) bufadm *bp; char c; {
  135. X    if (bp->ptr >= bp->end)
  136. X        bufgrow(bp);
  137. X    *(bp->ptr)++= c;
  138. X}
  139. X
  140. XVisible Procedure bufcpy(bp, s) bufadm *bp; char *s; {
  141. X    int len= strlen(s);
  142. X
  143. X    while (bp->ptr + len >= bp->end)
  144. X        bufgrow(bp);
  145. X    strcpy(bp->ptr, s);
  146. X    bp->ptr+= len;
  147. X}
  148. X
  149. XVisible Procedure bufncpy(bp, s, len) bufadm *bp; char *s; int len; {
  150. X    while (bp->ptr + len >= bp->end)
  151. X        bufgrow(bp);
  152. X    strncpy(bp->ptr, s, len);
  153. X    bp->ptr+= len;
  154. X    *(bp->ptr)= '\0';
  155. X}
  156. END_OF_FILE
  157.   if test 2602 -ne `wc -c <'abc/b/b1memo.c'`; then
  158.     echo shar: \"'abc/b/b1memo.c'\" unpacked with wrong size!
  159.   fi
  160.   # end of 'abc/b/b1memo.c'
  161. fi
  162. if test -f 'abc/b/b1mess.c' -a "${1}" != "-c" ; then 
  163.   echo shar: Will not clobber existing file \"'abc/b/b1mess.c'\"
  164. else
  165.   echo shar: Extracting \"'abc/b/b1mess.c'\" \(3072 characters\)
  166.   sed "s/^X//" >'abc/b/b1mess.c' <<'END_OF_FILE'
  167. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  168. X
  169. X/* B error message handling */
  170. X
  171. X/* All error messages are collected in a file, both to save data space
  172. X   and to ease translation to other languages.    The English version
  173. X   of the database can be recreated from the program sources by scanning
  174. X   for the pattern "MESS".  This is a macro whose first argument is
  175. X   the message number and whose second number is the message string;
  176. X   this macro expands to only the message number which is passed to
  177. X   the error routines.    The error routines then dig the message from
  178. X   the error message file, or just print the number if the file can't be
  179. X   opened.  There is also a way to pass a message that is determined
  180. X   at runtime.
  181. X*/
  182. X
  183. X#include "b.h"
  184. X#include "bfil.h"
  185. X#include "bmem.h"
  186. X#include "bobj.h"
  187. X
  188. X/* While we are reading the Messages file, we build an index.
  189. X   probe[k] contains the first message number found in block k.
  190. X   blocks are BUFSIZ in size. */
  191. X
  192. X#define FILESIZE 22454 /* Approximated current size of Messages file */
  193. X#define MAXPROBE (10 + FILESIZE/BUFSIZ) /* Allow some growth */
  194. X
  195. XHidden short probe[MAXPROBE];
  196. XHidden int nprobes= 1;
  197. X
  198. X#define NOT_OPENED ((FILE*)(-1))
  199. X#define NO_MESSFILE "*** Cannot find or read messages file; using numbers\n"
  200. XHidden FILE *messfp= NOT_OPENED;
  201. X
  202. Xchar *messbuf; /* used for messages with arguments */
  203. XHidden char buf[MESSBUFSIZE];
  204. X
  205. XVisible string getmess(nr) int nr;  {
  206. X    int last, c; char *cp= NULL;
  207. X    bool new; int block; long ftell();
  208. X    static int last_nr= 0;
  209. X
  210. X    if (nr <= 0) 
  211. X        return nr == -1 ? "%s" : nr == -2 ? "%s%s" : "";
  212. X    if (messfp == NOT_OPENED) {
  213. X        if (messfile)
  214. X            messfp= fopen(messfile, "r");
  215. X        else
  216. X            messfp= NULL;
  217. X        if (messfp == NULL) {
  218. X            fflush(stdout);
  219. X            putstr(errfile, NO_MESSFILE);
  220. X            fflush(errfile);
  221. X        }
  222. X    }
  223. X    if (nr == last_nr) {
  224. X        cp= strchr(buf, '\t');
  225. X        if (cp != NULL)
  226. X            return cp+1;
  227. X    }
  228. X    if (messfp) {
  229. X        for (block= nprobes-1; block > 0; --block) {
  230. X            if (probe[block] <= nr)
  231. X                break;
  232. X        }
  233. X        new= block == nprobes-1;
  234. X        fseek(messfp, (long)block*BUFSIZ, 0);
  235. X        last= 0;
  236. X        while (last < nr) {
  237. X            if (new) block= ftell(messfp) / BUFSIZ;
  238. X            cp= buf;
  239. X            while ((c= getc(messfp)) != EOF && c != '\n') {
  240. X                if (cp >= buf + MESSBUFSIZE - 2) break;
  241. X                if (c != '\\')
  242. X                    *cp= c;
  243. X                else {
  244. X                    c= getc(messfp);
  245. X                    if (c == EOF || c == '\n') break;
  246. X                    switch (c) {
  247. X                    case 'n': *cp= '\n'; break;
  248. X                    case 'r': *cp= '\r'; break;
  249. X                    case 't': *cp= '\t'; break;
  250. X                    case 'b': *cp= '\b'; break;
  251. X                    default: *cp++= '\\'; *cp= c; break;
  252. X                    }
  253. X                }
  254. X                cp++;
  255. X            }
  256. X            *cp= '\0';
  257. X            if (c == EOF) break;
  258. X            last= atoi(buf);
  259. X            if (last <= 0)
  260. X                continue;
  261. X            if (new && block >= nprobes && nprobes < MAXPROBE) {
  262. X                probe[block]= last;
  263. X                nprobes= block+1;
  264. X            }
  265. X        }
  266. X        if (last == nr) {
  267. X            cp= strchr(buf, '\t');
  268. X            if (cp != NULL) {
  269. X                last_nr= nr;
  270. X                return cp+1;
  271. X            }
  272. X        }
  273. X    }
  274. X    sprintf(buf, " (message %d) ", nr);
  275. X    last_nr= 0;
  276. X    return buf;
  277. X}
  278. X
  279. XVisible Procedure initmess() {
  280. X    messbuf= (char*) getmem(MESSBUFSIZE);
  281. X}
  282. X
  283. XVisible Procedure endmess() {
  284. X    freemem((ptr) messbuf);
  285. X}
  286. END_OF_FILE
  287.   if test 3072 -ne `wc -c <'abc/b/b1mess.c'`; then
  288.     echo shar: \"'abc/b/b1mess.c'\" unpacked with wrong size!
  289.   fi
  290.   # end of 'abc/b/b1mess.c'
  291. fi
  292. if test -f 'abc/bhdrs/b.h' -a "${1}" != "-c" ; then 
  293.   echo shar: Will not clobber existing file \"'abc/bhdrs/b.h'\"
  294. else
  295.   echo shar: Extracting \"'abc/bhdrs/b.h'\" \(3346 characters\)
  296.   sed "s/^X//" >'abc/bhdrs/b.h' <<'END_OF_FILE'
  297. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  298. X
  299. X/* b.h: general */
  300. X
  301. X#include "osconf.h"
  302. X#include "os.h"
  303. X#include "conf.h"
  304. X#include "config.h"
  305. X
  306. X#define Forward
  307. X#define Visible
  308. X#define Hidden static
  309. X#define Procedure
  310. X
  311. X/* The following are not intended as pseudo-encapsulation, */
  312. X/* but to emphasize intention. */
  313. X
  314. Xtypedef int bool;
  315. Xtypedef char *string; /* Strings are always terminated with a char '\0'. */
  316. X
  317. X#define Yes ((bool) 1)
  318. X#define No  ((bool) 0)
  319. X
  320. Xtypedef short intlet;
  321. X
  322. X/************************************************************************/
  323. X/*                                                                      */
  324. X/* Values                                                               */
  325. X/*                                                                      */
  326. X/* There are different modules for values, however all agree that       */
  327. X/* the first field of a value is its type, and the second its reference */
  328. X/* count. All other fields depend on the module.                        */
  329. X/*                                                                      */
  330. X/************************************************************************/
  331. X
  332. X/*
  333. X * "SMALL INTEGERS":
  334. X *
  335. X * When a "value" pointer has its low bit set, it is not a pointer.
  336. X * By casting to int and shifting one bit to the right, it is converted
  337. X * to its "int" value.  This can save a lot of heap space used for
  338. X * small integers.
  339. X * Sorry, you have to change this on machines with word rather than byte
  340. X * addressing (maybe you can use the sign bit as tag).
  341. X */
  342. X
  343. X#define IsSmallInt(v) (((int)(v)) & 1)
  344. X#define SmallIntVal(v) (((int)(v) & ~1) / 2)
  345. X#define MkSmallInt(i) ((value)((i)*2 | 1))
  346. X    /* (Can't use << and >> because their effect on negative numbers
  347. X        is not defined.) */
  348. X
  349. Xtypedef struct value {HEADER; string *cts;} *value;
  350. X
  351. X#define Hdrsize (sizeof(struct value)-sizeof(string))
  352. X
  353. X#define Type(v) (IsSmallInt(v) ? Num : (v)->type)
  354. X#define Length(v) ((v)->len)
  355. X#define Refcnt(v) ((v)->refcnt)
  356. X#define Unique(v) ((v)->refcnt==1)
  357. X
  358. X#define Dummy NULL
  359. X#define Dumval ((value) Dummy)
  360. X#define Vnil ((value) NULL)
  361. X#define Pnil ((value *) NULL)
  362. X
  363. X#define Valid(v) ((v) != Vnil)
  364. X
  365. X#define Ats(v) ((value *)&((v)->cts))
  366. X#define Str(v) ((string)&((v)->cts))
  367. X
  368. X/* Types: */
  369. X
  370. X#define Num '0'
  371. X#define Tex '"'
  372. X#define Com ','
  373. X#define Lis 'L'
  374. X#define Ran 'R'        /* doesn't belong here !!! */
  375. X#define Tab 'M'
  376. X#define ELT '}'
  377. X
  378. X#define Is_text(v) (Type(v) == Tex)
  379. X#define Is_number(v) (Type(v) == Num)
  380. X#define Is_compound(v) (Type(v) == Com)
  381. X#define Is_list(v) (Type(v) == Lis || Type(v) == ELT || Type(v) == Ran)
  382. X#define Is_range(v) (Type(v) == Ran)
  383. X#define Is_table(v) (Type(v) == Tab || Type(v) == ELT)
  384. X#define Is_tlt(v) (Type(v)==Tex||Type(v)==Lis||Type(v)==Ran||Type(v)==Tab||Type(v)==ELT)
  385. X#define Is_ELT(v) (Type(v) == ELT)
  386. X
  387. X/****************************************************************************/
  388. X
  389. Xvalue copy();
  390. Xextern bool still_ok;
  391. Xextern bool mess_ok;
  392. Xextern bool interactive;
  393. Xextern bool rd_interactive;
  394. Xextern bool interrupted;
  395. Xextern bool can_interrupt;
  396. Xextern bool testing;
  397. Xextern bool terminated;
  398. X
  399. X#define MESS(nr, text) nr
  400. X#define GMESS(nr, text) getmess(nr)
  401. Xstring getmess();
  402. Xextern char *messbuf;
  403. X#define MESSBUFSIZE 300
  404. X
  405. Xextern FILE *errfile;        /* should be in screen handling module */
  406. X                /* but edi and int ... */
  407. X#define DEBUGFILE stderr
  408. END_OF_FILE
  409.   if test 3346 -ne `wc -c <'abc/bhdrs/b.h'`; then
  410.     echo shar: \"'abc/bhdrs/b.h'\" unpacked with wrong size!
  411.   fi
  412.   # end of 'abc/bhdrs/b.h'
  413. fi
  414. if test -f 'abc/bhdrs/b0lan.h' -a "${1}" != "-c" ; then 
  415.   echo shar: Will not clobber existing file \"'abc/bhdrs/b0lan.h'\"
  416. else
  417.   echo shar: Extracting \"'abc/bhdrs/b0lan.h'\" \(2596 characters\)
  418.   sed "s/^X//" >'abc/bhdrs/b0lan.h' <<'END_OF_FILE'
  419. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  420. X
  421. X/*  Keywords
  422. X *  Predefined functions and predicates
  423. X *  See for the displayer strings the file bint2/i2dis.c
  424. X */
  425. X
  426. X#define Indent "   "    /* Output for each indentation level */
  427. X#define INDENTSIZE 3    /* Number of spaces in same */
  428. X
  429. X/* *********************** KEYWORDS ******************************************* */
  430. X
  431. X/* R_HOW_TO for bed/e1sugg.c; should conform with boot/lang.h */
  432. X#ifdef FRENCH
  433. X#define R_HOW_TO    "COMMENT "
  434. X#define S_HOW_TO    "COMMENT ?: "
  435. X#else
  436. X#define R_HOW_TO    "HOW TO "
  437. X#define S_HOW_TO    "HOW TO ?: "
  438. X#endif
  439. X
  440. X#define K_HOW         "HOW"
  441. X#define K_TO_how    "TO"
  442. X#define K_PUT        "PUT"
  443. X#define K_IN_put    "IN"
  444. X#define K_INSERT    "INSERT"
  445. X#define K_IN_insert    "IN"
  446. X#define K_REMOVE    "REMOVE"
  447. X#define K_FROM_remove    "FROM"
  448. X#define K_SETRANDOM    "SET RANDOM"
  449. X#define K_DELETE    "DELETE"
  450. X#define K_CHECK     "CHECK"
  451. X#define K_SHARE     "SHARE"
  452. X#define K_PASS        "PASS"
  453. X#define K_WRITE     "WRITE"
  454. X#define K_READ        "READ"
  455. X#define K_EG        "EG"
  456. X#define K_RAW        "RAW"
  457. X#define K_IF        "IF"
  458. X#define K_WHILE     "WHILE"
  459. X#define K_FOR        "FOR"
  460. X#define K_IN_for    "IN"
  461. X#define K_SELECT    "SELECT"
  462. X#define K_ELSE        "ELSE"
  463. X#define K_QUIT        "QUIT"
  464. X#define K_RETURN    "RETURN"
  465. X#define K_REPORT    "REPORT"
  466. X#define K_SUCCEED    "SUCCEED"
  467. X#define K_FAIL        "FAIL"
  468. X#define K_AND        "AND"
  469. X#define K_OR        "OR"
  470. X#define K_NOT        "NOT"
  471. X#define K_SOME        "SOME"
  472. X#define K_EACH        "EACH"
  473. X#define K_NO        "NO"
  474. X#define K_IN_quant    "IN"
  475. X#define K_HAS        "HAS"
  476. X
  477. X#ifdef GFX /* Graphics extension */
  478. X#define K_LINEFROM    "LINE FROM"
  479. X#define K_TO_line    "TO"
  480. X#define K_SPACEFROM    "SPACE FROM"
  481. X#define K_TO_space    "TO"
  482. X#define K_CLEARSCREEN    "CLEAR SCREEN"
  483. X#endif
  484. X
  485. X/* *********************** predefined FUNCTIONS ******************************* */
  486. X
  487. X#define F_pi        "pi"
  488. X#define F_e        "e"
  489. X#define F_now        "now"
  490. X#define F_abs        "abs"
  491. X#define F_sign        "sign"
  492. X#define F_floor     "floor"
  493. X#define F_ceiling    "ceiling"
  494. X#define F_round     "round"
  495. X#define F_mod        "mod"
  496. X#define F_root        "root"
  497. X#define F_random    "random"
  498. X#define F_exactly    "exactly"
  499. X#define F_sin        "sin"
  500. X#define F_cos        "cos"
  501. X#define F_tan        "tan"
  502. X#define F_arctan    "arctan"
  503. X#define F_angle        "angle"
  504. X#define F_radius    "radius"
  505. X#define F_exp        "exp"
  506. X#define F_log        "log"
  507. X#define F_stripped    "stripped"
  508. X#define F_split        "split"
  509. X#define F_upper        "upper"
  510. X#define F_lower        "lower"
  511. X#define F_keys        "keys"
  512. X#ifdef B_COMPAT
  513. X#define F_thof        "th'of"
  514. X#endif
  515. X#define F_item        "item"
  516. X#define F_min        "min"
  517. X#define F_max        "max"
  518. X#define F_choice    "choice"
  519. X
  520. X/* *********************** predefined PREDICATES ****************************** */
  521. X
  522. X#define P_exact        "exact"
  523. X#define P_in        "in"
  524. X#define P_notin     "not.in"
  525. X
  526. END_OF_FILE
  527.   if test 2596 -ne `wc -c <'abc/bhdrs/b0lan.h'`; then
  528.     echo shar: \"'abc/bhdrs/b0lan.h'\" unpacked with wrong size!
  529.   fi
  530.   # end of 'abc/bhdrs/b0lan.h'
  531. fi
  532. if test -f 'abc/bint1/i1nut.c' -a "${1}" != "-c" ; then 
  533.   echo shar: Will not clobber existing file \"'abc/bint1/i1nut.c'\"
  534. else
  535.   echo shar: Extracting \"'abc/bint1/i1nut.c'\" \(3197 characters\)
  536.   sed "s/^X//" >'abc/bint1/i1nut.c' <<'END_OF_FILE'
  537. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1988. */
  538. X
  539. X#include "b.h"
  540. X#include "bobj.h" /* for relation */
  541. X#include "i1num.h"
  542. X
  543. X/*
  544. X * This file contains routines to speed up some time consuming operations
  545. X * when dealing with big numbers, such as:
  546. X * . exactly() via prod2n()
  547. X * . convnum() and round2() via prod10n()
  548. X */
  549. X
  550. X/* To shut off lint and other warnings: */
  551. X#undef Copy
  552. X#define Copy(x) ((integer)copy((value)(x)))
  553. X
  554. X/*
  555. X * prod2n() returns (v= p/q) * (2**n),
  556. X * simplification rationals is done by sieving the 2 factors out of
  557. X * q if n>0 or p if n<0
  558. X */
  559. X
  560. XVisible value prod2n(v, n, simplify) value v, n; bool simplify; {
  561. X    relation n1 = numcomp(n, zero);
  562. X    integer p, q;
  563. X    integer t1, t2;
  564. X    value k;
  565. X
  566. X    if (n1 >= 0) {
  567. X        p = Integral(v) ? Copy(v) : Copy(Numerator((rational) v));
  568. X        q = Integral(v) ? int_1   : Copy(Denominator((rational) v));
  569. X        n = copy(n);
  570. X    }
  571. X    else {
  572. X        p = Integral(v) ? int_1   : Copy(Denominator((rational) v));
  573. X        q = Integral(v) ? Copy(v) : Copy(Numerator((rational) v));
  574. X        n = negated(n);
  575. X    }
  576. X    
  577. X    if (simplify) {
  578. X        while (n != zero && Even(Lsd(q)) && !Interrupted()) {
  579. X            q = int_half(q);
  580. X            n = diff(k = n, one);
  581. X            release(k);
  582. X        }
  583. X    }
  584. X    
  585. X    if (n != zero) {
  586. X        t1 = (integer) power((value) int_2, n);
  587. X        p = int_prod(t2 = p, t1);
  588. X        Release(t1); Release(t2);
  589. X    }
  590. X    release(n);
  591. X    
  592. X    if (n1 >= 0 && q == int_1)
  593. X        return (value) p;
  594. X    else if (n1 < 0 && p == int_1)
  595. X        return (value) q;
  596. X    else {
  597. X        rational r = mk_rat(n1>=0 ? p : q, n1>=0 ? q : p, 0, No);
  598. X        Release(p); Release(q);
  599. X        return (value) r;
  600. X    }
  601. X}
  602. X
  603. X/* v is shifted n "digits" to the left */
  604. X
  605. XHidden integer int10shift(v, n) integer v; intlet n; {
  606. X    struct integer vv;
  607. X    integer w;
  608. X    int i;
  609. X    
  610. X    if (n == 0)
  611. X        return Copy(v);
  612. X    FreezeSmallInt(v, vv);
  613. X    w = (integer) grab_num(Length(v) + n);
  614. X    for (i = 0; i<Length(v); ++i)
  615. X        Digit(w, i+n) = Digit(v, i);
  616. X    return int_canon(w);
  617. X}
  618. X
  619. X/* returns u * 10**|n| */
  620. X
  621. XHidden integer int10mul(u, n) integer u; int n; {
  622. X    integer v, w;
  623. X
  624. X    if (n<0) n = -n;
  625. X    v = int10shift(u, n / tenlogBASE);
  626. X    w = (integer) tento(n % tenlogBASE);
  627. X    u = int_prod(v, w);
  628. X    Release(v); Release(w);
  629. X    return u;
  630. X}
  631. X
  632. X/* prod10n(v,n) returns (v= p/q) * 10**n;
  633. X * to prevent a time consuming multiplication of two possible big
  634. X * numbers, the relevant operand (p if n>0 and q else) is first shifted
  635. X * |n|/tenlogBASE "digits"
  636. X */
  637. X
  638. XVisible value prod10n(v, n, simplify) value v; int n; bool simplify; {
  639. X    integer p, q, t;
  640. X
  641. X    v = Approximate(v) ? exactly(v) : copy(v);
  642. X
  643. X    if (Integral(v)) {
  644. X        p = Copy(v);
  645. X        q = int_1;
  646. X    }
  647. X    else {
  648. X        p = Copy(Numerator((rational) v));
  649. X        q = Copy(Denominator((rational) v));
  650. X    }
  651. X    if (n > 0) {
  652. X        p = int10mul(t = p, n);
  653. X        Release(t);
  654. X    }
  655. X    else if (n < 0) {
  656. X        q = int10mul(t = q, -n);
  657. X        Release(t);
  658. X    }
  659. X    release(v);
  660. X
  661. X    if (q == int_1)
  662. X        return (value) p;
  663. X    else {
  664. X        rational r = mk_rat(p, q, 0, simplify);
  665. X        Release(p); Release(q);
  666. X        return (value) r;
  667. X    }
  668. X}
  669. X
  670. X/* returns u+0.5 not simplified */
  671. X
  672. XVisible rational ratsumhalf(u) rational u; {
  673. X    integer p, q;
  674. X    rational s;
  675. X
  676. X    p = int_prod(Numerator(u), int_2);
  677. X    p = int_sum(q = p, Denominator(u)); Release(q);
  678. X    q = int_prod(Denominator(u), int_2);
  679. X
  680. X    s = mk_rat(p, q, 0, No);
  681. X        /* roundsize not used, so 0 is sufficient */
  682. X    Release(p); Release(q);
  683. X    return s;
  684. X}
  685. END_OF_FILE
  686.   if test 3197 -ne `wc -c <'abc/bint1/i1nut.c'`; then
  687.     echo shar: \"'abc/bint1/i1nut.c'\" unpacked with wrong size!
  688.   fi
  689.   # end of 'abc/bint1/i1nut.c'
  690. fi
  691. if test -f 'abc/bint2/DEP' -a "${1}" != "-c" ; then 
  692.   echo shar: Will not clobber existing file \"'abc/bint2/DEP'\"
  693. else
  694.   echo shar: Extracting \"'abc/bint2/DEP'\" \(3282 characters\)
  695.   sed "s/^X//" >'abc/bint2/DEP' <<'END_OF_FILE'
  696. Xi2ana.o: i2ana.c
  697. Xi2ana.o: ../bhdrs/b.h
  698. Xi2ana.o: ../uhdrs/osconf.h
  699. Xi2ana.o: ../uhdrs/os.h
  700. Xi2ana.o: ../uhdrs/conf.h
  701. Xi2ana.o: ../uhdrs/config.h
  702. Xi2ana.o: ../bhdrs/bint.h
  703. Xi2ana.o: ../bhdrs/bobj.h
  704. Xi2ana.o: ../ihdrs/i0err.h
  705. Xi2ana.o: ../ihdrs/i2nod.h
  706. Xi2ana.o: ../ihdrs/i2gen.h
  707. Xi2ana.o: ../ihdrs/i3env.h
  708. Xi2ana.o: ../ihdrs/i3sou.h
  709. Xi2cmd.o: i2cmd.c
  710. Xi2cmd.o: ../bhdrs/b.h
  711. Xi2cmd.o: ../uhdrs/osconf.h
  712. Xi2cmd.o: ../uhdrs/os.h
  713. Xi2cmd.o: ../uhdrs/conf.h
  714. Xi2cmd.o: ../uhdrs/config.h
  715. Xi2cmd.o: ../bhdrs/bint.h
  716. Xi2cmd.o: ../uhdrs/feat.h
  717. Xi2cmd.o: ../bhdrs/bobj.h
  718. Xi2cmd.o: ../ihdrs/i0err.h
  719. Xi2cmd.o: ../bhdrs/b0lan.h
  720. Xi2cmd.o: ../ihdrs/i2par.h
  721. Xi2cmd.o: ../ihdrs/i2nod.h
  722. Xi2cmd.o: ../ihdrs/i3env.h
  723. Xi2dis.o: i2dis.c
  724. Xi2dis.o: ../bhdrs/b.h
  725. Xi2dis.o: ../uhdrs/osconf.h
  726. Xi2dis.o: ../uhdrs/os.h
  727. Xi2dis.o: ../uhdrs/conf.h
  728. Xi2dis.o: ../uhdrs/config.h
  729. Xi2dis.o: ../bhdrs/bint.h
  730. Xi2dis.o: ../bhdrs/bobj.h
  731. Xi2dis.o: ../bhdrs/b0lan.h
  732. Xi2dis.o: ../ihdrs/i2par.h
  733. Xi2dis.o: ../ihdrs/i2nod.h
  734. Xi2exp.o: i2exp.c
  735. Xi2exp.o: ../bhdrs/b.h
  736. Xi2exp.o: ../uhdrs/osconf.h
  737. Xi2exp.o: ../uhdrs/os.h
  738. Xi2exp.o: ../uhdrs/conf.h
  739. Xi2exp.o: ../uhdrs/config.h
  740. Xi2exp.o: ../bhdrs/bint.h
  741. Xi2exp.o: ../bhdrs/bmem.h
  742. Xi2exp.o: ../bhdrs/bobj.h
  743. Xi2exp.o: ../ihdrs/i0err.h
  744. Xi2exp.o: ../ihdrs/i2par.h
  745. Xi2exp.o: ../ihdrs/i2nod.h
  746. Xi2exp.o: ../ihdrs/i2gen.h
  747. Xi2exp.o: ../ihdrs/i2exp.h
  748. Xi2fix.o: i2fix.c
  749. Xi2fix.o: ../bhdrs/b.h
  750. Xi2fix.o: ../uhdrs/osconf.h
  751. Xi2fix.o: ../uhdrs/os.h
  752. Xi2fix.o: ../uhdrs/conf.h
  753. Xi2fix.o: ../uhdrs/config.h
  754. Xi2fix.o: ../bhdrs/bint.h
  755. Xi2fix.o: ../bhdrs/bobj.h
  756. Xi2fix.o: ../ihdrs/i0err.h
  757. Xi2fix.o: ../ihdrs/i2exp.h
  758. Xi2fix.o: ../ihdrs/i2nod.h
  759. Xi2fix.o: ../ihdrs/i2gen.h
  760. Xi2fix.o: ../ihdrs/i2par.h
  761. Xi2fix.o: ../ihdrs/i3env.h
  762. Xi2gen.o: i2gen.c
  763. Xi2gen.o: ../bhdrs/b.h
  764. Xi2gen.o: ../uhdrs/osconf.h
  765. Xi2gen.o: ../uhdrs/os.h
  766. Xi2gen.o: ../uhdrs/conf.h
  767. Xi2gen.o: ../uhdrs/config.h
  768. Xi2gen.o: ../bhdrs/bint.h
  769. Xi2gen.o: ../uhdrs/feat.h
  770. Xi2gen.o: ../bhdrs/bobj.h
  771. Xi2gen.o: ../ihdrs/i0err.h
  772. Xi2gen.o: ../ihdrs/i2nod.h
  773. Xi2gen.o: ../ihdrs/i2gen.h
  774. Xi2gen.o: ../ihdrs/i2par.h
  775. Xi2gen.o: ../ihdrs/i3env.h
  776. Xi2gen.o: ../ihdrs/i3int.h
  777. Xi2gen.o: ../ihdrs/i3sou.h
  778. Xi2syn.o: i2syn.c
  779. Xi2syn.o: ../bhdrs/b.h
  780. Xi2syn.o: ../uhdrs/osconf.h
  781. Xi2syn.o: ../uhdrs/os.h
  782. Xi2syn.o: ../uhdrs/conf.h
  783. Xi2syn.o: ../uhdrs/config.h
  784. Xi2syn.o: ../bhdrs/bint.h
  785. Xi2syn.o: ../uhdrs/feat.h
  786. Xi2syn.o: ../bhdrs/bmem.h
  787. Xi2syn.o: ../bhdrs/bobj.h
  788. Xi2syn.o: ../bhdrs/b0lan.h
  789. Xi2syn.o: ../ihdrs/i2par.h
  790. Xi2syn.o: ../ihdrs/i3scr.h
  791. Xi2syn.o: ../ihdrs/i3env.h
  792. Xi2tar.o: i2tar.c
  793. Xi2tar.o: ../bhdrs/b.h
  794. Xi2tar.o: ../uhdrs/osconf.h
  795. Xi2tar.o: ../uhdrs/os.h
  796. Xi2tar.o: ../uhdrs/conf.h
  797. Xi2tar.o: ../uhdrs/config.h
  798. Xi2tar.o: ../bhdrs/bint.h
  799. Xi2tar.o: ../bhdrs/bobj.h
  800. Xi2tar.o: ../ihdrs/i2par.h
  801. Xi2tar.o: ../ihdrs/i2nod.h
  802. Xi2tes.o: i2tes.c
  803. Xi2tes.o: ../bhdrs/b.h
  804. Xi2tes.o: ../uhdrs/osconf.h
  805. Xi2tes.o: ../uhdrs/os.h
  806. Xi2tes.o: ../uhdrs/conf.h
  807. Xi2tes.o: ../uhdrs/config.h
  808. Xi2tes.o: ../bhdrs/bint.h
  809. Xi2tes.o: ../bhdrs/bobj.h
  810. Xi2tes.o: ../ihdrs/i0err.h
  811. Xi2tes.o: ../bhdrs/b0lan.h
  812. Xi2tes.o: ../ihdrs/i2par.h
  813. Xi2tes.o: ../ihdrs/i2nod.h
  814. Xi2uni.o: i2uni.c
  815. Xi2uni.o: ../bhdrs/b.h
  816. Xi2uni.o: ../uhdrs/osconf.h
  817. Xi2uni.o: ../uhdrs/os.h
  818. Xi2uni.o: ../uhdrs/conf.h
  819. Xi2uni.o: ../uhdrs/config.h
  820. Xi2uni.o: ../bhdrs/bint.h
  821. Xi2uni.o: ../uhdrs/feat.h
  822. Xi2uni.o: ../bhdrs/bobj.h
  823. Xi2uni.o: ../ihdrs/i0err.h
  824. Xi2uni.o: ../bhdrs/b0lan.h
  825. Xi2uni.o: ../ihdrs/i2par.h
  826. Xi2uni.o: ../ihdrs/i2nod.h
  827. Xi2uni.o: ../ihdrs/i3env.h
  828. Xi2uni.o: ../ihdrs/i3sou.h
  829. END_OF_FILE
  830.   if test 3282 -ne `wc -c <'abc/bint2/DEP'`; then
  831.     echo shar: \"'abc/bint2/DEP'\" unpacked with wrong size!
  832.   fi
  833.   # end of 'abc/bint2/DEP'
  834. fi
  835. if test -f 'abc/bint3/i3com.c' -a "${1}" != "-c" ; then 
  836.   echo shar: Will not clobber existing file \"'abc/bint3/i3com.c'\"
  837. else
  838.   echo shar: Extracting \"'abc/bint3/i3com.c'\" \(2542 characters\)
  839.   sed "s/^X//" >'abc/bint3/i3com.c' <<'END_OF_FILE'
  840. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  841. X
  842. X#include "b.h"
  843. X#include "bmem.h"
  844. X#include "bobj.h"
  845. X#include "bfil.h"
  846. X#include "bcom.h"
  847. X#include "i3scr.h"
  848. X
  849. X/****************************************************************************/
  850. X
  851. X/* Edit a file.  Parameters are the file name (as ABC value), a line
  852. X   number where the focus should appear (may be 0 if not applicable; may
  853. X   be ignored by some editors), and the kind of file: 't' for targets,
  854. X   'u' for units.
  855. X   Returns a bool: Yes if the file has been modified.
  856. X*/
  857. X
  858. XVisible bool f_edit(fname, errline, kind, creating) value fname; intlet errline;
  859. X        literal kind; bool creating; {
  860. X    struct stat statbuf;
  861. X    time_t modtime= 0;
  862. X    string filename= sstrval(fname);
  863. X    bool edited= Yes;
  864. X
  865. X    if (stat(filename, &statbuf) == 0)
  866. X        modtime= statbuf.st_mtime;
  867. X#ifdef unix
  868. X    if (editor) /* another editor */
  869. X        ed_file(filename, errline);
  870. X    else
  871. X#endif
  872. X        abced_file(filename, errline, kind, creating);
  873. X#ifdef macintosh
  874. X    sync();
  875. X#endif
  876. X#ifndef macintosh
  877. X    /* stat() doesn't work properly on the mac */
  878. X    edited= !(stat(filename, &statbuf) == 0 && modtime == statbuf.st_mtime);
  879. X#endif
  880. X    fstrval(filename);
  881. X    still_ok= Yes; /* ignore interrupts that occurred */
  882. X    return edited;
  883. X}
  884. X
  885. X/****************************************************************************/
  886. X
  887. XVisible bool cmdline(kind, bp, indent) literal kind; bufadm *bp; int indent; {
  888. X    static char *edfirst= NULL;
  889. X    static char *edbuf;
  890. X    char *ed_line();
  891. X    char *edlast;
  892. X
  893. X    for (;;) {
  894. X        if (edfirst == NULL) {
  895. X            if (kind == R_cmd && outeractive) {
  896. X                oline();
  897. X                at_nwl= No;
  898. X            }
  899. X            edbuf= ed_line(kind, indent);
  900. X            if (edbuf == NULL) { /* editor interrupted */
  901. X                still_ok= No;
  902. X                return No;
  903. X            }
  904. X            edfirst= edbuf;
  905. X        }
  906. X        if (*edfirst == '\0') { /* at the end of edbuf */
  907. X            edfirst= NULL;
  908. X            freemem((ptr) edbuf);
  909. X            if (kind != R_cmd)
  910. X                continue;
  911. X            bufcpy(bp, "\n");
  912. X            return No;
  913. X        }
  914. X        edlast= strchr(edfirst, '\n');
  915. X        if (edlast == NULL)
  916. X            syserr(MESS(4500, "in cmdline()"));
  917. X        bufncpy(bp, edfirst, edlast - edfirst + 1);
  918. X        edfirst= ++edlast;
  919. X#ifdef MEMTRACE
  920. X        if (strcmp(edbuf, "QUIT\n") == 0)
  921. X            freemem(edbuf);
  922. X#endif
  923. X        return Yes;
  924. X    }
  925. X}
  926. X
  927. X/* delete file from positions file */
  928. X
  929. XVisible Procedure idelpos(fname) value fname; {
  930. X    string file= sstrval(fname);
  931. X    delpos(file);
  932. X    fstrval(file);
  933. X}    
  934. X
  935. X/* move position in positions file */
  936. X
  937. XVisible Procedure imovpos(ofname, nfname) value ofname, nfname; {
  938. X    string o_file= sstrval(ofname);
  939. X    string n_file= sstrval(nfname);
  940. X    movpos(o_file, n_file);
  941. X    fstrval(o_file);
  942. X    fstrval(n_file);
  943. X}
  944. END_OF_FILE
  945.   if test 2542 -ne `wc -c <'abc/bint3/i3com.c'`; then
  946.     echo shar: \"'abc/bint3/i3com.c'\" unpacked with wrong size!
  947.   fi
  948.   # end of 'abc/bint3/i3com.c'
  949. fi
  950. if test -f 'abc/bint3/i3imm.c' -a "${1}" != "-c" ; then 
  951.   echo shar: Will not clobber existing file \"'abc/bint3/i3imm.c'\"
  952. else
  953.   echo shar: Extracting \"'abc/bint3/i3imm.c'\" \(3018 characters\)
  954.   sed "s/^X//" >'abc/bint3/i3imm.c' <<'END_OF_FILE'
  955. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  956. X
  957. X#include "b.h"
  958. X#include "bint.h"
  959. X#include "feat.h"
  960. X#include "bobj.h"
  961. X#include "b0lan.h"
  962. X#include "i2par.h"
  963. X#include "i3env.h"
  964. X#include "i3scr.h"
  965. X#ifdef MENUS
  966. X#include "abcmenus.h"
  967. X#endif
  968. X
  969. X/* ******************************************************************** */
  970. X/*        immediate command                    */
  971. X/* ******************************************************************** */
  972. X
  973. X#define TERM_COMMAND    MESS(3300, "terminating commands only allowed in how-to's and refinements")
  974. X#define SHARE_COMMAND    MESS(3301, "share-command only allowed in a how-to")
  975. X#define NO_COMMAND    MESS(3302, "I don't recognise this as a command")
  976. X
  977. XHidden Procedure imm_command() {
  978. X    parsetree codeseq= NilTree;
  979. X    parsetree c= NilTree, d= NilTree; 
  980. X    int level;
  981. X    char *kw;
  982. X    txptr tx0;
  983. X    
  984. X    cntxt= In_command; still_ok= Yes; interrupted= No;
  985. X    can_interrupt= Yes;
  986. X    terminated= No;
  987. X    resexp= Voi; lino= 0;
  988. X#ifdef MENUS
  989. X    adjust_menus(Prompt_menus);
  990. X#endif
  991. X    level= ilev();
  992. X#ifdef MENUS
  993. X    if (terminated) return;
  994. X#endif
  995. X    if (!still_ok) return;
  996. X    if (level > 0)
  997. X        parerr(MESS(3303, "outer indentation not zero"));
  998. X    else if (findceol(), Ceol(tx));
  999. X    else if (Char(tx) ==C_COLON || Char(tx) == C_EQUAL ||
  1000. X            Char(tx) == C_GREATER || Char(tx) == '!') {
  1001. X        if (interactive) special();
  1002. X        else parerr(MESS(3304, "special commands only interactively"));
  1003. X    }
  1004. X    else if (tx0= tx, is_cmdname(ceol, &kw)) {
  1005. X        if (how_keyword(kw)) {
  1006. X            tx= tx0;
  1007. X#ifdef MENUS
  1008. X            adjust_menus(Editor_menus);
  1009. X#endif
  1010. X            create_unit();
  1011. X        }
  1012. X        else if (quit_keyword(kw))
  1013. X            terminated= Yes;
  1014. X        else if (term_com(kw, &c)) {
  1015. X            release(c);
  1016. X            parerr(TERM_COMMAND);
  1017. X        }
  1018. X        else if (share_keyword(kw))
  1019. X            parerr(SHARE_COMMAND);
  1020. X        else if (control_command(kw, &c) ||
  1021. X                 simple_command(kw, &c, &d)) {
  1022. X            /* control_command MUST come before simple above */
  1023. X#ifdef MENUS
  1024. X            adjust_menus(Interpreter_menus);
  1025. X#endif
  1026. X            if (still_ok) fix_nodes(&c, &codeseq);
  1027. X            curline= c; curlino= one;
  1028. X            execthread(codeseq);
  1029. X            release(c); release(d);
  1030. X        }
  1031. X        else parerr(NO_COMMAND);
  1032. X    }
  1033. X    else parerr(NO_COMMAND);
  1034. X}
  1035. X
  1036. XVisible Procedure process() {
  1037. X    re_screen();
  1038. X    re_env();
  1039. X    f_lino= 0;
  1040. X    terminated= No;
  1041. X    while (!Eof && !terminated) {
  1042. X        imm_command();
  1043. X        if (!interactive && !still_ok) bye(1);
  1044. X    }
  1045. X}
  1046. X
  1047. XHidden Procedure special() {
  1048. X    switch(Char(tx++)) {
  1049. X        case ':':       skipsp(&tx);
  1050. X                if (Char(tx) == C_COLON) {
  1051. X#ifdef MENUS
  1052. X                    adjust_menus(Interpreter_menus);
  1053. X#endif
  1054. X                    lst_uhds();
  1055. X                }
  1056. X                else {
  1057. X#ifdef MENUS
  1058. X                    adjust_menus(Editor_menus);
  1059. X#endif
  1060. X                    edit_unit();
  1061. X                }
  1062. X                break;
  1063. X        case '=':       skipsp(&tx);
  1064. X                if (Char(tx) == C_EQUAL) {
  1065. X#ifdef MENUS
  1066. X                    adjust_menus(Interpreter_menus);
  1067. X#endif
  1068. X                    lst_ttgs();
  1069. X                }
  1070. X                else {
  1071. X#ifdef MENUS
  1072. X                    adjust_menus(Editor_menus);
  1073. X#endif
  1074. X                    edit_target();
  1075. X                }
  1076. X                break;
  1077. X        case '>':       skipsp(&tx);
  1078. X#ifdef MENUS
  1079. X                adjust_menus(Interpreter_menus);
  1080. X#endif
  1081. X                if (Char(tx) == C_GREATER) {
  1082. X                    lst_wss();
  1083. X                }
  1084. X                else {
  1085. X                    goto_ws();
  1086. X                }
  1087. X                break;
  1088. X        default:    syserr(MESS(3305, "special"));
  1089. X    }
  1090. X}
  1091. X
  1092. END_OF_FILE
  1093.   if test 3018 -ne `wc -c <'abc/bint3/i3imm.c'`; then
  1094.     echo shar: \"'abc/bint3/i3imm.c'\" unpacked with wrong size!
  1095.   fi
  1096.   # end of 'abc/bint3/i3imm.c'
  1097. fi
  1098. if test -f 'abc/bint3/i3in2.c' -a "${1}" != "-c" ; then 
  1099.   echo shar: Will not clobber existing file \"'abc/bint3/i3in2.c'\"
  1100. else
  1101.   echo shar: Extracting \"'abc/bint3/i3in2.c'\" \(2625 characters\)
  1102.   sed "s/^X//" >'abc/bint3/i3in2.c' <<'END_OF_FILE'
  1103. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  1104. X
  1105. X/* B interpreter -- independent subroutines */
  1106. X
  1107. X#include "b.h"
  1108. X#include "bint.h"
  1109. X#include "bobj.h"
  1110. X#include "i0err.h"
  1111. X#include "i3env.h"
  1112. X#include "i3in2.h"
  1113. X#include "i3sou.h"
  1114. X
  1115. X/* Newlines for WRITE /// */
  1116. X
  1117. XVisible Procedure nl(n) value n; {
  1118. X    value l= size(n); int c= intval(l); release(l);
  1119. X    while (c--) newline();
  1120. X}
  1121. X
  1122. X
  1123. X/* Evaluating basic targets */
  1124. X
  1125. XVisible value v_local(name, number) value name, number; {
  1126. X    value *aa= envassoc(curnv->tab, number);
  1127. X    if (aa != Pnil && *aa != Vnil) {
  1128. X        if (Is_indirect(*aa)) {
  1129. X            value v= Indirect(*aa)->val;
  1130. X            if (v == Vnil) interrV(NO_VALUE, name);
  1131. X            return copy(v);
  1132. X        }
  1133. X        else return copy(*aa);
  1134. X    }
  1135. X    interrV(NO_VALUE, name);
  1136. X    return Vnil;
  1137. X}
  1138. X
  1139. XVisible value v_global(name) value name; {
  1140. X    value *aa= envassoc(prmnv->tab, name);
  1141. X    if (aa != Pnil && *aa != Vnil) {
  1142. X        if (Is_indirect(*aa)) {
  1143. X            load_global(*aa, name, Yes);
  1144. X            return copy(Indirect(*aa)->val);
  1145. X        }
  1146. X        else return copy(*aa);
  1147. X    }
  1148. X    interrV(NO_VALUE, name);
  1149. X    return Vnil;
  1150. X}
  1151. X
  1152. XVisible Procedure load_global(v, name, err) value v, name; bool err; {
  1153. X    indirect *w= Indirect(v);
  1154. X    if (w->val == Vnil) {
  1155. X        value *aa, pname= permkey(name, Tar);
  1156. X        if (p_exists(pname, &aa)) {
  1157. X            release(errtname); errtname= copy(name);
  1158. X            w->val= getval(*aa, In_tarval);
  1159. X        }
  1160. X        else if (err)
  1161. X            interrV(NO_VALUE, name);
  1162. X        release(pname);
  1163. X    }
  1164. X}
  1165. X
  1166. X/* Rangers */
  1167. X
  1168. X/* An IN-ranger is represented on the stack as a compound of three fields:
  1169. X   the last index used, the value of the expression after IN, and its length.
  1170. X   (The latter is redundant, but saves save many calls of 'size()'.)
  1171. X   When first called, there is, of course, no compound on the stack, but only
  1172. X   the value of the expression.  As the expression should always be a text,
  1173. X   list or table, this is recognizable as a special case, and then the
  1174. X   compound is created.
  1175. X   Return value is Yes if a new element was available and assigned, No if not.
  1176. X*/
  1177. X
  1178. XVisible bool in_ranger(l, pv) loc l; value *pv; {
  1179. X    value v= *pv, ind, tlt, len, i1, val; bool res;
  1180. X    if (!Is_compound(v) || Nfields(v) != 3) { /* First time */
  1181. X        tlt= v;
  1182. X        if (!Is_tlt(tlt)) {
  1183. X            interr(MESS(3400, "in ... i IN e, e is not a text, list or table"));
  1184. X            return No;
  1185. X        }
  1186. X        if (empty(tlt)) return No;
  1187. X        *pv= v= mk_compound(3);
  1188. X        *Field(v, 0)= ind= one;
  1189. X        *Field(v, 1)= tlt;
  1190. X        *Field(v, 2)= len= size(tlt);
  1191. X        bind(l);
  1192. X    }
  1193. X    else {
  1194. X        ind= *Field(v, 0); tlt= *Field(v, 1); len= *Field(v, 2);
  1195. X        res= numcomp(ind, len) < 0;
  1196. X        if (!res) { unbind(l); return No; }
  1197. X        *Field(v, 0)= ind= sum(i1= ind, one); release(i1);
  1198. X    }
  1199. X    put(val= item(tlt, ind), l); release(val);
  1200. X    return Yes;
  1201. X}
  1202. END_OF_FILE
  1203.   if test 2625 -ne `wc -c <'abc/bint3/i3in2.c'`; then
  1204.     echo shar: \"'abc/bint3/i3in2.c'\" unpacked with wrong size!
  1205.   fi
  1206.   # end of 'abc/bint3/i3in2.c'
  1207. fi
  1208. if test -f 'abc/bint3/i3ini.c' -a "${1}" != "-c" ; then 
  1209.   echo shar: Will not clobber existing file \"'abc/bint3/i3ini.c'\"
  1210. else
  1211.   echo shar: Extracting \"'abc/bint3/i3ini.c'\" \(3270 characters\)
  1212.   sed "s/^X//" >'abc/bint3/i3ini.c' <<'END_OF_FILE'
  1213. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1988. */
  1214. X
  1215. X#include "b.h"
  1216. X#include "bint.h"
  1217. X#include "feat.h"
  1218. X#include "bobj.h"
  1219. X#include "bfil.h"
  1220. X#include "i3env.h"
  1221. X#include "i3scr.h"
  1222. X#include "release.h"
  1223. X
  1224. XHidden Procedure print_heading() {
  1225. X    if (!f_interactive(stdin))
  1226. X        return;
  1227. X    putSstr(stderr,
  1228. X    "ABC Release %s.\n", RELEASE);
  1229. X    putstr(stderr,
  1230. X    "Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1989.\n");
  1231. X}
  1232. X
  1233. XVisible Procedure initcall(argc, argv) int argc; char **argv; {
  1234. X    bool filearg= No;
  1235. X    
  1236. X    /* check call: */
  1237. X    while (argc > 0) {
  1238. X        if (argv[0][0] == '-' && argv[0][1] == '\0');
  1239. X        else if (!F_readable(argv[0])) {
  1240. X            putSstr(errfile, "can't open input file %s\n", argv[0]);
  1241. X            immexit(-1);
  1242. X        }
  1243. X        else filearg= Yes;
  1244. X        ++argv; --argc;
  1245. X    }
  1246. X    /* initial setting flag interactive: */
  1247. X    interactive= !filearg && f_interactive(stdin);
  1248. X}
  1249. X
  1250. XVisible Procedure run_abc(argc, argv) int argc; char **argv; {
  1251. X    bool filearg= argc > 0;
  1252. X    
  1253. X    i_lino= 0;
  1254. X    while (argc >= 0) {
  1255. X        if (argc == 0 || (argv[0][0] == '-' && argv[0][1] == '\0')) {
  1256. X            if (argc == 0 && filearg) break;
  1257. X            release(iname);
  1258. X            iname = Vnil;
  1259. X            ifile = stdin;
  1260. X            process();
  1261. X        }
  1262. X        else {
  1263. X            filearg= Yes;
  1264. X            release(iname);
  1265. X            iname = mk_text(argv[0]);
  1266. X            if (Isabspath(argv[0]))
  1267. X                ifile= fopen(argv[0], "r");
  1268. X            else {
  1269. X                char *path= makepath(startdir, argv[0]);
  1270. X                ifile= fopen(path, "r");
  1271. X                freepath(path);
  1272. X            }
  1273. X            if (ifile != NULL) {
  1274. X                process();
  1275. X                fclose(ifile);
  1276. X            }
  1277. X            else {
  1278. X                putSstr(errfile, "can't open input file %s\n", argv[0]);
  1279. X                immexit(-1);
  1280. X            }
  1281. X        }
  1282. X        ++argv; --argc;
  1283. X    }
  1284. X}
  1285. X
  1286. XVisible Procedure set_vars() {
  1287. X    initmess();    /* set messbuf */
  1288. X    initfmt();    /* set fmtbuf */
  1289. X    initfile();    /* locate files (messages, keydefs, copybuffer, etc) */
  1290. X    init_scr();    /* set outeractive and rd_interactive */
  1291. X    initerr();    /* set errfile (!) */
  1292. X}
  1293. X
  1294. XVisible bool in_init= Yes;
  1295. X
  1296. Xextern bool use_bed;
  1297. X
  1298. XVisible Procedure init(prompt_help) bool prompt_help; {
  1299. X#ifdef SIGNAL
  1300. X    initsig();    /* catch signals */
  1301. X#endif /* SIGNAL */
  1302. X    if (use_bed) {
  1303. X        init_erro();    /* buffers for error messages from editor */
  1304. X        initkeys();    /* read key definitions from termcap and file */
  1305. X        initterm();    /* start trm module */
  1306. X        initgram();    /* edi's grammar tables */
  1307. X        initclasses();    /* suggestions for builtins */
  1308. X        initbed();    /* top-ep's admin; read copybuffer */
  1309. X    }
  1310. X    
  1311. X    initnum();
  1312. X    initsyn();
  1313. X#ifdef TYPE_CHECK
  1314. X    initpol();
  1315. X#endif
  1316. X    initprmnv();
  1317. X    /* start first output here,
  1318. X     * since trm module may start alternative screen ... */
  1319. X    print_heading();
  1320. X    if (interactive && prompt_help)
  1321. X        putmess(errfile, MESS(1700, "Type '?' for help.\n"));
  1322. X    /* ... and initbws() prints ">current_ws_name" */
  1323. X    initbws();
  1324. X
  1325. X    in_init= No;
  1326. X}
  1327. X
  1328. XVisible Procedure endall() {
  1329. X    /* real tasks: */
  1330. X    endbws();
  1331. X    if (use_bed) {
  1332. X        endbed();    /* save editor parsetree and copybuffer */
  1333. X        endterm();    /* reset terminal */
  1334. X    }
  1335. X
  1336. X#ifdef MEMTRACE
  1337. X    /* the following only free memory: */
  1338. X    endstrval();    /* hack to free strval static store */
  1339. X    endnoderepr();    /* hack to free noderepr static store */
  1340. X
  1341. X#ifdef TYPE_CHECK
  1342. X    endpol();
  1343. X#endif
  1344. X    endsta();
  1345. X    endsyn();
  1346. X    endnum();
  1347. X#ifdef USERSUGG
  1348. X    endclasses();
  1349. X#endif
  1350. X    end_erro();
  1351. X    end_scr();
  1352. X    endfile();
  1353. X    endmess();
  1354. X#endif /* MEMTRACE */
  1355. X}
  1356. X
  1357. XVisible Procedure crashend() {
  1358. X    if (cntxt != In_wsgroup && cntxt != In_prmnv)
  1359. X        endbws();
  1360. X}
  1361. END_OF_FILE
  1362.   if test 3270 -ne `wc -c <'abc/bint3/i3ini.c'`; then
  1363.     echo shar: \"'abc/bint3/i3ini.c'\" unpacked with wrong size!
  1364.   fi
  1365.   # end of 'abc/bint3/i3ini.c'
  1366. fi
  1367. if test -f 'abc/boot/main.h' -a "${1}" != "-c" ; then 
  1368.   echo shar: Will not clobber existing file \"'abc/boot/main.h'\"
  1369. else
  1370.   echo shar: Extracting \"'abc/boot/main.h'\" \(3090 characters\)
  1371.   sed "s/^X//" >'abc/boot/main.h' <<'END_OF_FILE'
  1372. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1988. */
  1373. X
  1374. Xtypedef short item;    /* used for indexing xxxdef[] arrays;
  1375. X             * each grammatical item will be represented
  1376. X             * by its index in the applicable table.
  1377. X             */
  1378. Xtypedef item *itemptr;
  1379. X
  1380. X/* to indicate end of classinfo arrays: */
  1381. X#define Nilitem ((item) -1)
  1382. X#define Isnilitem(i) (((item) (i)) == ((item) -1))
  1383. X/* (We can't use zero, because an item can indicate  the zero's entry
  1384. X * of a xxxdef[] array.
  1385. X */
  1386. Xstruct classinfo {    /* the itemptr's here indicate 0-terminated array's */
  1387. X    string c_name;
  1388. X        /* only lower-case */
  1389. X    itemptr c_syms;
  1390. X        /* list of possible Symbols or LEXICALS */
  1391. X    itemptr c_insert;
  1392. X        /* list of pairs (char, class) for insertion */
  1393. X    itemptr c_append;
  1394. X        /* ditto for append to child already there */
  1395. X    itemptr c_join;
  1396. X        /* ditto for join of child with new node */
  1397. X};
  1398. X
  1399. X#define MAXCHILD 4    /* should actually be computed from input-grammar */
  1400. X            /* but this makes live easier ... */
  1401. Xstruct syminfo {
  1402. X    string s_name;
  1403. X        /* first char upper-case, rest lower */
  1404. X    string s_repr[MAXCHILD+1];
  1405. X        /* fixed-text parts */
  1406. X        /* entries are [0..nch] inclusive */
  1407. X    item s_class[MAXCHILD];
  1408. X        /* index of child into classdef[] */
  1409. X};
  1410. X
  1411. Xstruct lexinfo {
  1412. X    string l_name;    /* representing NAME, only Capitals */
  1413. X    string l_start; /* char's that may start this lexical */
  1414. X    string l_cont;    /* char's that may continue this lexical;
  1415. X             * only used in abc-editor, not in mktable.
  1416. X             */
  1417. X    int l_body;    /* index of enveloping class in classdef[] */
  1418. X    int l_sym;    /* index in symdef[], for use in class-definition */
  1419. X    int l_class;    /* index in classdef[], for use in Symbol-definition */
  1420. X};
  1421. X
  1422. Xstruct nameinfo {
  1423. X    string n_name;
  1424. X    item n_index;    /* into classdef[] | symdef[] | lexdef[] */
  1425. X    char n_type;    /* Class or Sym or Lex */
  1426. X};
  1427. X
  1428. X#define Class ('C')
  1429. X#define Sym ('S')
  1430. X#define Lex ('L')
  1431. X#define Errtype ('E')
  1432. X
  1433. X/* MAX's to allocate space; can be overwritten with commandline options */
  1434. X#define MAXSYM 127
  1435. X#define MAXCLASS 100
  1436. X#define MAXLEX 20
  1437. X#define MAXNAME 300
  1438. X
  1439. X#define NAMELEN 100    /* maximum significant part of name */
  1440. X#define STRINGLEN 256    /* maximum string length */
  1441. X#define SYMLEN 200    /* maximum number of alternative symbols in
  1442. X             * any class definition */
  1443. X
  1444. Xextern struct classinfo *classdef;
  1445. Xextern struct syminfo *symdef;
  1446. Xextern struct lexinfo *lexdef;
  1447. Xextern struct nameinfo *namelist;
  1448. X
  1449. Xextern int maxclass;
  1450. Xextern int maxsym;
  1451. Xextern int maxlex;
  1452. Xextern int maxname;
  1453. X
  1454. Xextern int nclass;
  1455. Xextern int nsym;
  1456. Xextern int nlex;
  1457. Xextern int nname;
  1458. X
  1459. Xextern int nsuggstnbody;
  1460. Xextern int lsuggestion;
  1461. Xextern int nsuggestion;
  1462. X
  1463. Xextern int nsugghowbody;
  1464. Xextern int lsugghowname;
  1465. Xextern int nsugghowname;
  1466. X
  1467. Xextern int noptional;
  1468. Xextern int nhole;
  1469. Xextern int nlexical;
  1470. X
  1471. X#define GRAMMAR "grammar"
  1472. X#define TABLES "tabl.c.out"
  1473. X#define INCLUDE "tabl.h.out"
  1474. X#define HFILE "tabl.h"
  1475. X
  1476. Xextern string progname;
  1477. Xextern FILE *gfp;
  1478. Xextern char *gfile;
  1479. Xextern FILE *tfp;
  1480. Xextern char *tfile;
  1481. Xextern FILE *ifp;
  1482. Xextern char *ifile;
  1483. Xextern char *hfile;
  1484. X
  1485. Xchar *getmem();
  1486. Xstring savestr();
  1487. Xitemptr savearray();
  1488. X
  1489. X#define Assert(cond) ((cond) || asserr(__FILE__, __LINE__))
  1490. END_OF_FILE
  1491.   if test 3090 -ne `wc -c <'abc/boot/main.h'`; then
  1492.     echo shar: \"'abc/boot/main.h'\" unpacked with wrong size!
  1493.   fi
  1494.   # end of 'abc/boot/main.h'
  1495. fi
  1496. if test -f 'abc/ehdrs/keys.h' -a "${1}" != "-c" ; then 
  1497.   echo shar: Will not clobber existing file \"'abc/ehdrs/keys.h'\"
  1498. else
  1499.   echo shar: Extracting \"'abc/ehdrs/keys.h'\" \(2943 characters\)
  1500.   sed "s/^X//" >'abc/ehdrs/keys.h' <<'END_OF_FILE'
  1501. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  1502. X
  1503. X/*
  1504. X * B editor -- Command key definitions as returned by inchar() in getc.c.
  1505. X * Old kludges removed.
  1506. X * The values must differ from the ones returned by inchar:
  1507. X *    32..126 (for printable chars == ABC alphabet)
  1508. X *    EOF (for end of file)
  1509. X *    0377 (for ignore, rings a bell?).
  1510. X *
  1511. X * New kludge: the order is used for mapping menuchoices 
  1512. X * to editoroperations (saves static data on the Mac:-);
  1513. X * the "holes" are caused by deviding lines in the menus
  1514. X * and later used for operations not on any menu.
  1515. X * So, look at mhdrs/abcmenus.h and mac/m1menus.c if you change this.
  1516. X */
  1517. X
  1518. X#define IGNORE 0377
  1519. X
  1520. X/* Focus menu: */
  1521. X#define     FOCUS 0 /* one less than WIDEN */
  1522. X#define WIDEN        1
  1523. X#define EXTEND        2
  1524. X#define FIRST        3
  1525. X#define LAST        4
  1526. X#define PREVIOUS    5
  1527. X#define NEXT        6
  1528. X
  1529. X#define UPLINE        8
  1530. X#define DOWNLINE    9
  1531. X
  1532. X#define UPARROW        11
  1533. X#define DOWNARROW    12
  1534. X#define LEFTARROW    13
  1535. X#define RITEARROW    14
  1536. X
  1537. X/* not on a menu (mouseclick) */
  1538. X#define GOTO        7
  1539. X
  1540. X/* Edit menu: */
  1541. X#define        EDIT 14 /* one less than UNDO */
  1542. X#define UNDO        15
  1543. X#define REDO        16
  1544. X#define CUT            17
  1545. X#define COPY        18
  1546. X#define PASTE        19
  1547. X#define DELETE        20
  1548. X
  1549. X/* Special menu: */
  1550. X#define     SPECIAL 20    /* one less than ACCEPT */
  1551. X#define ACCEPT        21
  1552. X#define NEWLINE        22
  1553. X
  1554. X#define RECORD        24
  1555. X#define PLAYBACK    25
  1556. X
  1557. X#define EXIT        27
  1558. X
  1559. X/* Pause menu: */
  1560. X#define CANCEL        26
  1561. X
  1562. X/* not on menus: */
  1563. X
  1564. X#define SUSPEND        28
  1565. X
  1566. X#define REDRAW        10
  1567. X#define LOOK        REDRAW
  1568. X
  1569. X#define HELP        23
  1570. X
  1571. X#ifdef KEYS
  1572. X#define DELBIND        29
  1573. X#endif
  1574. X
  1575. X/* string-valued codes; must be < 0 */
  1576. X
  1577. X#define TERMINIT     -1
  1578. X#define TERMDONE    -2
  1579. X
  1580. X
  1581. X/* the next one is only used in printing the helpblurb
  1582. X   and should differ from all others above.
  1583. X */
  1584. X#define NOTHING        0
  1585. X
  1586. X/* the same for menus handled by do_menu_choice(),
  1587. X * instead of passed to editdocument().
  1588. X */
  1589. X#define HANDLED        0
  1590. X
  1591. X
  1592. X/* the strings belonging to the codes above: */
  1593. X
  1594. X#define S_IGNORE    "[ignore]"
  1595. X
  1596. X#define S_WIDEN        "[widen]"
  1597. X#define S_EXTEND    "[extend]"
  1598. X#define S_FIRST        "[first]"
  1599. X#define S_LAST        "[last]"
  1600. X#define S_PREVIOUS    "[previous]"
  1601. X#define S_NEXT        "[next]"
  1602. X#define S_UPLINE    "[upline]"
  1603. X#define S_DOWNLINE    "[downline]"
  1604. X#define S_UPARROW    "[up]"
  1605. X#define S_DOWNARROW    "[down]"
  1606. X#define S_LEFTARROW    "[left]"
  1607. X#define S_RITEARROW    "[right]"
  1608. X#define S_GOTO        "[goto]"
  1609. X#define S_ACCEPT    "[accept]"
  1610. X#define S_NEWLINE    "[newline]"
  1611. X#define S_RETURN    "[return]"
  1612. X#define S_UNDO        "[undo]"
  1613. X#define S_REDO        "[redo]"
  1614. X#define S_COPY        "[copy]"
  1615. X#define S_DELETE    "[delete]"
  1616. X#define S_RECORD    "[record]"
  1617. X#define S_PLAYBACK    "[playback]"
  1618. X#define S_REDRAW    "[redraw]"
  1619. X#define S_LOOK        "[look]"
  1620. X#define S_HELP        "[help]"
  1621. X#define S_EXIT        "[exit]"
  1622. X#define S_INTERRUPT    "[interrupt]"
  1623. X#define S_CANCEL    "[cancel]"
  1624. X#define S_SUSPEND    "[suspend]"
  1625. X#define S_PASTE        "[paste]"
  1626. X#define S_CUT        "[cut]"
  1627. X
  1628. X/* These two are not key defs but string-valued options: */
  1629. X
  1630. X#define S_DELBIND    S_IGNORE
  1631. X
  1632. X#define S_TERMINIT    "[term-init]"
  1633. X#define S_TERMDONE    "[term-done]"
  1634. X
  1635. X#define S_NOTHING    ""
  1636. END_OF_FILE
  1637.   if test 2943 -ne `wc -c <'abc/ehdrs/keys.h'`; then
  1638.     echo shar: \"'abc/ehdrs/keys.h'\" unpacked with wrong size!
  1639.   fi
  1640.   # end of 'abc/ehdrs/keys.h'
  1641. fi
  1642. if test -f 'abc/ehdrs/node.h' -a "${1}" != "-c" ; then 
  1643.   echo shar: Will not clobber existing file \"'abc/ehdrs/node.h'\"
  1644. else
  1645.   echo shar: Extracting \"'abc/ehdrs/node.h'\" \(2785 characters\)
  1646.   sed "s/^X//" >'abc/ehdrs/node.h' <<'END_OF_FILE'
  1647. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  1648. X
  1649. X/*
  1650. X * B editor -- Parse tree and Focus stack.
  1651. X */
  1652. X
  1653. X/*
  1654. X * Assertion macro.
  1655. X *
  1656. X * This one differs from the one in #include <assert.h> in that it
  1657. X * is usable as an expression operand, e.g. up(ep) || Assert(No).
  1658. X * The function asserr() must unconditionally terminate the program.
  1659. X * If the accumulated __FILE__ data wastes too much of your data
  1660. X * space, omit them and change the code in asserr() that uses them.
  1661. X * You better trust your code then, because unless compiled with "-g"
  1662. X * it's difficult to dig the line number information from the core dump.
  1663. X *
  1664. X * There is also a variant called Abort() which is equivalent to Assert(No).
  1665. X */
  1666. X
  1667. X#ifdef NDEBUG
  1668. X#define Abort() abort() /* Always fail */
  1669. X#define Assert(cond) 0 /* Dummy expression */
  1670. X#else /* NDEBUG */
  1671. X#define Abort() asserr(__FILE__, __LINE__)
  1672. X#define Assert(cond) ((cond) || Abort())
  1673. X#endif /* NDEBUG */
  1674. X
  1675. Xnode newnode();
  1676. X
  1677. X#ifndef NDEBUG
  1678. X#define symbol(n) (Assert(Is_Node(n)), (n)->n_symbol)
  1679. X#define nchildren(n) (Assert(Is_Node(n)), Length(n))
  1680. X#define marks(n) (Assert(Is_Node(n)), (n)->n_marks)
  1681. X#define child(n, i) \
  1682. X    (Assert(Is_Node(n) && (i)>0 && (i)<=Length(n)), (n)->n_child[(i)-1])
  1683. X#define lastchild(n) \
  1684. X    (Assert(Is_Node(n) && Length(n)>0), (n)->n_child[Length(n)-1])
  1685. X#define firstchild(n) \
  1686. X    (Assert(Is_Node(n) && Length(n)>0), (n)->n_child[0])
  1687. X#else /* NDEBUG */
  1688. X#define symbol(n) ((n)->n_symbol)
  1689. X#define nchildren(n) (Length(n))
  1690. X#define marks(n) ((n)->n_marks)
  1691. X#define child(n, i) ((n)->n_child[(i)-1])
  1692. X#define lastchild(n) ((n)->n_child[Length(n)-1])
  1693. X#define firstchild(n) ((n)->n_child[0])
  1694. X#endif /* NDEBUG */
  1695. X
  1696. Xint nodewidth();
  1697. X#define marked(p, x) (marks(tree(p))&(x))
  1698. X
  1699. Xpath newpath();
  1700. X
  1701. X#define parent(p) ((p)->p_parent)
  1702. X#define tree(p) ((p)->p_tree)
  1703. X#define ichild(p) ((p)->p_ichild)
  1704. X
  1705. X#define Ycoord(p) ((p)->p_ycoord)
  1706. X#define Xcoord(p) ((p)->p_xcoord)
  1707. X#define Level(p) ((p)->p_level)
  1708. X
  1709. X/* Procedure markpath(); */
  1710. X/* Procedure unmkpath(); */
  1711. X/* Procedure treereplace(); */
  1712. Xbool up();
  1713. Xbool downi();
  1714. X
  1715. X#define down(n) downi(n, 1)
  1716. X
  1717. Xbool downrite();
  1718. Xbool left();
  1719. Xbool rite();
  1720. X/* Procedure top(); */
  1721. Xbool nextnode();
  1722. X/* Procedure firstleaf(); */
  1723. Xbool nextleaf();
  1724. Xbool prevnode();
  1725. X/* Procedure lastleaf(); */
  1726. Xbool prevleaf();
  1727. Xbool nextmarked();
  1728. Xbool prevmarked();
  1729. X
  1730. X/*
  1731. X * The following are routines for lint, but macros for CC.
  1732. X * This way lint can detect wrong arguments passed.
  1733. X */
  1734. X
  1735. X#ifdef lint
  1736. X
  1737. Xnode nodecopy();
  1738. Xnoderelease();
  1739. Xnodeuniql();
  1740. X
  1741. Xpath pathcopy();
  1742. Xpathrelease();
  1743. Xpathuniql();
  1744. X
  1745. X#else
  1746. X
  1747. X#define nodecopy(n) ((node)copy(n))
  1748. X#define noderelease(n) release(n)
  1749. X#define nodeuniql(pn) uniql(pn)
  1750. X
  1751. X#define pathcopy(p) ((path)copy(p))
  1752. X#define pathrelease(p) release(p)
  1753. X#define pathuniql(pp) uniql(pp)
  1754. X
  1755. X#endif
  1756. X
  1757. Xnode grab_node();
  1758. Xpath grab_path();
  1759. X
  1760. END_OF_FILE
  1761.   if test 2785 -ne `wc -c <'abc/ehdrs/node.h'`; then
  1762.     echo shar: \"'abc/ehdrs/node.h'\" unpacked with wrong size!
  1763.   fi
  1764.   # end of 'abc/ehdrs/node.h'
  1765. fi
  1766. if test -f 'abc/keys/DEP' -a "${1}" != "-c" ; then 
  1767.   echo shar: Will not clobber existing file \"'abc/keys/DEP'\"
  1768. else
  1769.   echo shar: Extracting \"'abc/keys/DEP'\" \(2626 characters\)
  1770.   sed "s/^X//" >'abc/keys/DEP' <<'END_OF_FILE'
  1771. Xkeydef.o: keydef.c
  1772. Xkeydef.o: ../bhdrs/b.h
  1773. Xkeydef.o: ../uhdrs/osconf.h
  1774. Xkeydef.o: ../uhdrs/os.h
  1775. Xkeydef.o: ../uhdrs/conf.h
  1776. Xkeydef.o: ../uhdrs/config.h
  1777. Xkeydef.o: ../bhdrs/bfil.h
  1778. Xkeydef.o: ../bhdrs/bmem.h
  1779. Xkeydef.o: ../uhdrs/feat.h
  1780. Xkeydef.o: ../ehdrs/keys.h
  1781. Xkeydef.o: ../ehdrs/getc.h
  1782. Xkeydef.o: ../ehdrs/trm.h
  1783. Xkeydef.o: ../bhdrs/release.h
  1784. Xkeydef.o: ./keydef.h
  1785. Xkeyhlp.o: keyhlp.c
  1786. Xkeyhlp.o: ../bhdrs/b.h
  1787. Xkeyhlp.o: ../uhdrs/osconf.h
  1788. Xkeyhlp.o: ../uhdrs/os.h
  1789. Xkeyhlp.o: ../uhdrs/conf.h
  1790. Xkeyhlp.o: ../uhdrs/config.h
  1791. Xkeyhlp.o: ../uhdrs/feat.h
  1792. Xkeyhlp.o: ../bhdrs/bmem.h
  1793. Xkeyhlp.o: ../ehdrs/keys.h
  1794. Xkeyhlp.o: ../ehdrs/getc.h
  1795. Xe1getc.o: ../bed/e1getc.c
  1796. Xe1getc.o: ../bhdrs/b.h
  1797. Xe1getc.o: ../uhdrs/osconf.h
  1798. Xe1getc.o: ../uhdrs/os.h
  1799. Xe1getc.o: ../uhdrs/conf.h
  1800. Xe1getc.o: ../uhdrs/config.h
  1801. Xe1getc.o: ../uhdrs/feat.h
  1802. Xe1getc.o: ../bhdrs/bmem.h
  1803. Xe1getc.o: ../bhdrs/bobj.h
  1804. Xe1getc.o: ../bhdrs/bfil.h
  1805. Xe1getc.o: ../ehdrs/keys.h
  1806. Xe1getc.o: ../ehdrs/getc.h
  1807. Xe1getc.o: ../uhdrs/args.h
  1808. Xb1file.o: ../b/b1file.c
  1809. Xb1file.o: ../bhdrs/b.h
  1810. Xb1file.o: ../uhdrs/osconf.h
  1811. Xb1file.o: ../uhdrs/os.h
  1812. Xb1file.o: ../uhdrs/conf.h
  1813. Xb1file.o: ../uhdrs/config.h
  1814. Xb1file.o: ../bhdrs/bfil.h
  1815. Xb1file.o: ../bhdrs/bmem.h
  1816. Xb1memo.o: ../b/b1memo.c
  1817. Xb1memo.o: ../bhdrs/b.h
  1818. Xb1memo.o: ../uhdrs/osconf.h
  1819. Xb1memo.o: ../uhdrs/os.h
  1820. Xb1memo.o: ../uhdrs/conf.h
  1821. Xb1memo.o: ../uhdrs/config.h
  1822. Xb1memo.o: ../bhdrs/bmem.h
  1823. Xb1mess.o: ../b/b1mess.c
  1824. Xb1mess.o: ../bhdrs/b.h
  1825. Xb1mess.o: ../uhdrs/osconf.h
  1826. Xb1mess.o: ../uhdrs/os.h
  1827. Xb1mess.o: ../uhdrs/conf.h
  1828. Xb1mess.o: ../uhdrs/config.h
  1829. Xb1mess.o: ../bhdrs/bfil.h
  1830. Xb1mess.o: ../bhdrs/bmem.h
  1831. Xb1mess.o: ../bhdrs/bobj.h
  1832. Xgetopt.o: ../b/getopt.c
  1833. Xgetopt.o: ../uhdrs/os.h
  1834. Xb1outp.o: ../b/b1outp.c
  1835. Xb1outp.o: ../bhdrs/b.h
  1836. Xb1outp.o: ../uhdrs/osconf.h
  1837. Xb1outp.o: ../uhdrs/os.h
  1838. Xb1outp.o: ../uhdrs/conf.h
  1839. Xb1outp.o: ../uhdrs/config.h
  1840. Xb1outp.o: ../bhdrs/bmem.h
  1841. Xu1file.o: ../unix/u1file.c
  1842. Xu1file.o: ../bhdrs/b.h
  1843. Xu1file.o: ../uhdrs/osconf.h
  1844. Xu1file.o: ../uhdrs/os.h
  1845. Xu1file.o: ../uhdrs/conf.h
  1846. Xu1file.o: ../uhdrs/config.h
  1847. Xu1file.o: ../bhdrs/bmem.h
  1848. Xu1file.o: ../uhdrs/dest.h
  1849. Xu1file.o: ../bhdrs/bfil.h
  1850. Xu1keys.o: ../unix/u1keys.c
  1851. Xu1keys.o: ../bhdrs/b.h
  1852. Xu1keys.o: ../uhdrs/osconf.h
  1853. Xu1keys.o: ../uhdrs/os.h
  1854. Xu1keys.o: ../uhdrs/conf.h
  1855. Xu1keys.o: ../uhdrs/config.h
  1856. Xu1keys.o: ../uhdrs/feat.h
  1857. Xu1keys.o: ../bhdrs/bmem.h
  1858. Xu1keys.o: ../ehdrs/getc.h
  1859. Xu1keys.o: ../ehdrs/keys.h
  1860. Xu1keys.o: ../uhdrs/args.h
  1861. Xu1trm.o: ../unix/u1trm.c
  1862. Xu1trm.o: ../bhdrs/b.h
  1863. Xu1trm.o: ../uhdrs/osconf.h
  1864. Xu1trm.o: ../uhdrs/os.h
  1865. Xu1trm.o: ../uhdrs/conf.h
  1866. Xu1trm.o: ../uhdrs/config.h
  1867. Xu1trm.o: ../ehdrs/trm.h
  1868. Xu1dir.o: ../unix/u1dir.c
  1869. Xu1dir.o: ../bhdrs/b.h
  1870. Xu1dir.o: ../uhdrs/osconf.h
  1871. Xu1dir.o: ../uhdrs/os.h
  1872. Xu1dir.o: ../uhdrs/conf.h
  1873. Xu1dir.o: ../uhdrs/config.h
  1874. END_OF_FILE
  1875.   if test 2626 -ne `wc -c <'abc/keys/DEP'`; then
  1876.     echo shar: \"'abc/keys/DEP'\" unpacked with wrong size!
  1877.   fi
  1878.   # end of 'abc/keys/DEP'
  1879. fi
  1880. if test -f 'abc/stc/i2stc.h' -a "${1}" != "-c" ; then 
  1881.   echo shar: Will not clobber existing file \"'abc/stc/i2stc.h'\"
  1882. else
  1883.   echo shar: Extracting \"'abc/stc/i2stc.h'\" \(2818 characters\)
  1884.   sed "s/^X//" >'abc/stc/i2stc.h' <<'END_OF_FILE'
  1885. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1986. */
  1886. X
  1887. X/*************************************************************************/
  1888. X
  1889. X/* polytype representation */
  1890. X
  1891. Xtypedef value typekind;
  1892. Xtypedef value polytype;
  1893. X
  1894. X/* accessing, NOT giving new values */
  1895. X
  1896. Xtypekind kind();     /* polytype u */
  1897. Xintlet nsubtypes();     /* polytype u */
  1898. Xpolytype subtype();     /* polytype u, intlet i */
  1899. Xpolytype asctype();     /* polytype u */
  1900. Xpolytype keytype();     /* polytype u */
  1901. Xvalue ident();         /* polytype u */
  1902. X
  1903. X/* MaKe Types, where subtypes are "eaten" */
  1904. X
  1905. Xpolytype mkt_polytype(); /* typekind k; intlet nsub */
  1906. X                /* visible only in bunif.c */
  1907. X/* Procedure putsubtype(); */    /* polytype sub, *pcomp; intlet isub */
  1908. X                /* to be used after mkt_polytype or
  1909. X                 * mkt_compound */
  1910. X
  1911. Xpolytype mkt_number();
  1912. Xpolytype mkt_text();
  1913. Xpolytype mkt_tn();
  1914. Xpolytype mkt_error();
  1915. Xpolytype mkt_list();     /* polytype s */
  1916. Xpolytype mkt_table();    /* polytype k, a */
  1917. Xpolytype mkt_lt();     /* polytype s */
  1918. Xpolytype mkt_tlt();     /* polytype s */
  1919. Xpolytype mkt_compound();    /* intlet nsub */
  1920. Xpolytype mkt_var();     /* value id */
  1921. Xpolytype mkt_newvar();
  1922. Xpolytype mkt_ext();
  1923. X
  1924. Xpolytype p_copy();     /* polytype u */
  1925. X/* Procedure p_release(); */        /* polytype u */
  1926. X
  1927. X/* predicates */
  1928. X
  1929. Xbool are_same_types();     /* polytype u, v */
  1930. Xbool have_same_structure();/* polytype u, v */
  1931. X
  1932. Xbool t_is_number();    /* typekind k */
  1933. Xbool t_is_text();    /* typekind k */
  1934. Xbool t_is_tn();        /* typekind k */
  1935. Xbool t_is_error();    /* typekind k */
  1936. Xbool t_is_list();     /* typekind k */
  1937. Xbool t_is_table();    /* typekind k */
  1938. Xbool t_is_lt();     /* typekind k */
  1939. Xbool t_is_tlt();    /* typekind k */
  1940. Xbool t_is_compound();    /* typekind k */
  1941. Xbool t_is_var();    /* typekind k */
  1942. Xbool t_is_ext();    /* typekind k */
  1943. Xbool has_number();     /* typekind k */
  1944. Xbool has_text();     /* typekind k */
  1945. Xbool has_lt();         /* typekind k */
  1946. X
  1947. X/* typetable */
  1948. X
  1949. X/* Procedure repl_type_of(); */ /* polytype u, tu */
  1950. Xbool table_has_type_of();    /* polytype u */
  1951. Xpolytype bottomtype();         /* polytype u */
  1952. Xpolytype bottomvar();         /* polytype u */
  1953. X
  1954. X/* Procedure usetypetable(); */        /* value t */
  1955. X/* Procedure deltypetable(); */
  1956. X
  1957. X/* init */
  1958. X
  1959. X/* Procedure initpol(); */     /* */
  1960. X
  1961. X/*************************************************************************/
  1962. X
  1963. X/* unification of polytypes */
  1964. X
  1965. X/* Procedure unify(); */     /* polytype a, b, &u; bool &bad */
  1966. X
  1967. Xbool contains();     /* polytype u, a */
  1968. Xbool equal_vars();     /* polytype s, a */
  1969. X
  1970. X/*************************************************************************/
  1971. X
  1972. X/* type unification errors */
  1973. X
  1974. X/* Procedure start_vars(); */         /* */
  1975. X/* Procedure add_var(); */        /* polytype tvar */
  1976. X/* Procedure end_vars(); */        /* */
  1977. X
  1978. X/* Procedure setreprtable(); */     /* */
  1979. X/* Procedure delreprtable(); */        /* */
  1980. X
  1981. X/* Procedure badtyperr(); */        /* polytype a, b */
  1982. X/* Procedure cyctyperr(); */        /* polytype a */
  1983. X
  1984. Xvalue conc();
  1985. END_OF_FILE
  1986.   if test 2818 -ne `wc -c <'abc/stc/i2stc.h'`; then
  1987.     echo shar: \"'abc/stc/i2stc.h'\" unpacked with wrong size!
  1988.   fi
  1989.   # end of 'abc/stc/i2stc.h'
  1990. fi
  1991. if test -f 'abc/tc/tputs.c' -a "${1}" != "-c" ; then 
  1992.   echo shar: Will not clobber existing file \"'abc/tc/tputs.c'\"
  1993. else
  1994.   echo shar: Extracting \"'abc/tc/tputs.c'\" \(1724 characters\)
  1995.   sed "s/^X//" >'abc/tc/tputs.c' <<'END_OF_FILE'
  1996. X#include <sgtty.h>
  1997. X#include <ctype.h>
  1998. X
  1999. X/*
  2000. X * The following array gives the number of tens of milliseconds per
  2001. X * character for each speed as returned by gtty.  Thus since 300
  2002. X * baud returns a 7, there are 33.3 milliseconds per char at 300 baud.
  2003. X */
  2004. Xstatic
  2005. Xshort    tmspc10[] = {
  2006. X    0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5
  2007. X};
  2008. X
  2009. Xshort    ospeed;
  2010. Xchar    PC;
  2011. X
  2012. X/*
  2013. X * Put the character string cp out, with padding.
  2014. X * The number of affected lines is affcnt, and the routine
  2015. X * used to output one character is outc.
  2016. X */
  2017. Xtputs(cp, affcnt, outc)
  2018. X    register char *cp;
  2019. X    int affcnt;
  2020. X    int (*outc)();
  2021. X{
  2022. X    register int i = 0;
  2023. X    register int mspc10;
  2024. X
  2025. X    if (cp == 0)
  2026. X        return;
  2027. X
  2028. X    /*
  2029. X     * Convert the number representing the delay.
  2030. X     */
  2031. X    if (isdigit(*cp)) {
  2032. X        do
  2033. X            i = i * 10 + *cp++ - '0';
  2034. X        while (isdigit(*cp));
  2035. X    }
  2036. X    i *= 10;
  2037. X    if (*cp == '.') {
  2038. X        cp++;
  2039. X        if (isdigit(*cp))
  2040. X            i += *cp - '0';
  2041. X        /*
  2042. X         * Only one digit to the right of the decimal point.
  2043. X         */
  2044. X        while (isdigit(*cp))
  2045. X            cp++;
  2046. X    }
  2047. X
  2048. X    /*
  2049. X     * If the delay is followed by a `*', then
  2050. X     * multiply by the affected lines count.
  2051. X     */
  2052. X    if (*cp == '*')
  2053. X        cp++, i *= affcnt;
  2054. X
  2055. X    /*
  2056. X     * The guts of the string.
  2057. X     */
  2058. X    while (*cp)
  2059. X        (*outc)(*cp++);
  2060. X
  2061. X    /*
  2062. X     * If no delay needed, or output speed is
  2063. X     * not comprehensible, then don't try to delay.
  2064. X     */
  2065. X    if (i == 0)
  2066. X        return;
  2067. X    if (ospeed <= 0 || ospeed >= (sizeof tmspc10 / sizeof tmspc10[0]))
  2068. X        return;
  2069. X
  2070. X    /*
  2071. X     * Round up by a half a character frame,
  2072. X     * and then do the delay.
  2073. X     * Too bad there are no user program accessible programmed delays.
  2074. X     * Transmitting pad characters slows many
  2075. X     * terminals down and also loads the system.
  2076. X     */
  2077. X    mspc10 = tmspc10[ospeed];
  2078. X    i += mspc10 / 2;
  2079. X    for (i /= mspc10; i > 0; i--)
  2080. X        (*outc)(PC);
  2081. X}
  2082. END_OF_FILE
  2083.   if test 1724 -ne `wc -c <'abc/tc/tputs.c'`; then
  2084.     echo shar: \"'abc/tc/tputs.c'\" unpacked with wrong size!
  2085.   fi
  2086.   # end of 'abc/tc/tputs.c'
  2087. fi
  2088. echo shar: End of archive 22 \(of 25\).
  2089. cp /dev/null ark22isdone
  2090. MISSING=""
  2091. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ; do
  2092.     if test ! -f ark${I}isdone ; then
  2093.     MISSING="${MISSING} ${I}"
  2094.     fi
  2095. done
  2096. if test "${MISSING}" = "" ; then
  2097.     echo You have unpacked all 25 archives.
  2098.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2099. else
  2100.     echo You still must unpack the following archives:
  2101.     echo "        " ${MISSING}
  2102. fi
  2103. exit 0 # Just in case...
  2104.