home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / xlisp / ufg.arc / XLISP.PAT < prev   
Text File  |  1987-06-01  |  4KB  |  126 lines

  1.              <<< ALIEN::DISK$DATA01:[NOTES$LIBRARY]XLISP.NOTE;1 >>>
  2.                           -< LISP without apologies >-
  3. ================================================================================
  4. Note 53.0         Unix-customization and modified print-routine          1 reply
  5. UTR01::DEHARTOG "AI is better than none!"           118 lines  11-MAR-1987 04:18
  6. --------------------------------------------------------------------------------
  7.  
  8. Here is the makefile for Unix. Note that dependency from xlisp.h is
  9. not mentioned here; so if you change anything in xlisp.h, you should
  10. recompile all modules.
  11. The difference with the PC-world is the file xlunix.c (in place of
  12. pcstuff.c or msstuff.c). It contains two lispfunctions: SH which allows
  13. you to give any unix-command from xlisp by (sh "unix-command") and
  14. SCNDS which results in the number of seconds since some time ago.
  15. Note that the -i in the cc-command is for separate I&D space only
  16. (i.e for the PRO380, ommit it for the PRO350).
  17.  
  18. objects=xlisp.o xlbfun.o xlcont.o xldbug.o xldmem.o xleval.o xlfio.o\
  19.  xlftab.o xlglob.o xlinit.o xlio.o xljump.o xllist.o xlmath.o\
  20.  xlobj.o xlprin.o xlread.o xlstr.o xlsubr.o xlsym.o xlsys.o\
  21.  xlunix.o lstksiz.o
  22. xlisp : $(objects)
  23.     cc -o xlisp -i -s $(objects) -lm
  24. ---------------------------------------------------------------------
  25. Here is a modified version of the routine printit (from module xlfio.c).
  26. It makes the lisp-function PRINT behave as in normal (Common) Lisp (i.e.
  27. it starts with a newline and prints a space at the end). The original
  28. print did not print a space at the end, but did the newline at the end.
  29.  
  30. /* printit - common print function */
  31. LOCAL NODE *printit(args,pflag,tflag)
  32.   NODE *args; int pflag,tflag;
  33. {
  34.     NODE *fptr,*val;
  35.  
  36.     /* get expression to print and file pointer */
  37.     val = xlarg(&args);
  38.     fptr = (args ? xlgetfile(&args) : getvalue(s_stdout));
  39.     xllastarg(args);
  40.  
  41.     /* start with newline if necessary */
  42.     if (tflag)
  43.     xlterpri(fptr);
  44.  
  45.     /* print the value */
  46.     xlprint(fptr,val,pflag);
  47.  
  48.     /* follow with a space if necessary */
  49.     if (tflag)
  50.     xlputc(fptr, ' ');
  51.  
  52.     /* return the result */
  53.     return (val);
  54. }
  55. -------------------------------------------------------------------------
  56. Here is the module xlunix.c :
  57. ===========================
  58.  
  59. #include "xlisp.h"
  60.  
  61. extern NODE *true;
  62. extern int errno;
  63.  
  64. /* osinit - os specific initialization */
  65. osinit(banner)
  66.   char *banner;
  67. {
  68.     printf("%s\n",banner);
  69.     srand(getpid());    /* for random-function */
  70. }
  71.  
  72. /* osgetc - get a character from a file (or stdin) */
  73. int osgetc(fp)
  74.   FILE *fp;
  75. {
  76.     return (getc(fp));
  77. }
  78.  
  79. /* osputc - write a character to a file (or stdout) */
  80. int osputc(ch,fp)
  81.   int ch;
  82.   FILE *fp;
  83. {
  84.     return (putc(ch,fp));
  85. }
  86.  
  87. /* oscheck - check for control characters */
  88. oscheck()
  89. {
  90. }
  91.  
  92. /* osrand - return a random number between 0 and n-1 */
  93. int osrand(n)
  94.   int n;
  95. {
  96.     return (rand() % n);
  97. }
  98.  
  99. /* osfinish - clean up before returning to the operating system */
  100. osfinish()
  101. {
  102. }
  103.  
  104. /* xshell - shell escape for unix */
  105. NODE *xshell(args) NODE *args;{
  106.     char *cmd;
  107.     cmd = xlmatch(STR, &args)->n_str;
  108.     xllastargs(args);
  109.     return(system(cmd) ? cvfixnum((FIXNUM)errno) : true);
  110. }
  111.  
  112. /* xseconds - return clocktime in seconds since some time */
  113. NODE *xseconds(args) NODE *args;{
  114.     long time();
  115.  
  116.     xllastargs(args);
  117.     return(cvfixnum((FIXNUM)time((long *) 0)));
  118. }
  119.  
  120. /* osfinit - initialize unix specific functions */
  121. osfinit()
  122. {
  123.     xlsubr("SH",    SUBR,    xshell);
  124.     xlsubr("SCNDS",    SUBR,    xseconds);
  125. }
  126.