Category : Miscellaneous Language Source Code
Archive   : XLISPS.ZIP
Filename : XLSYM.C
#ifdef AZTEC
#include "stdio.h"
#else
#include
#endif
#include "xlisp.h"
/* external variables */
extern struct node *xlstack;
/* external procedures */
extern char *strcat();
/* xstrlen - length of a string */
struct node *xstrlen(args)
struct node *args;
{
struct node *val;
int total;
/* initialize */
total = 0;
/* loop over args and total */
while (args != NULL)
total += strlen(xlmatch(STR,&args)->n_str);
/* create the value node */
val = newnode(INT);
val->n_int = total;
/* return the total */
return (val);
}
/* xstrcat - concatenate a bunch of strings */
struct node *xstrcat(args)
struct node *args;
{
struct node *oldstk,val,*p;
char *str;
int len;
/* create a new stack frame */
oldstk = xlsave(&val,NULL);
/* find the length of the new string */
for (p = args, len = 0; p; )
len += strlen(xlmatch(STR,&p)->n_str);
/* create the result string */
val.n_ptr = newnode(STR);
val.n_ptr->n_str = str = stralloc(len);
*str = 0;
/* combine the strings */
while (args)
strcat(str,xlmatch(STR,&args)->n_str);
/* restore the previous stack frame */
xlstack = oldstk;
/* return the new string */
return (val.n_ptr);
}
/* xsubstr - return a substring */
struct node *xsubstr(args)
struct node *args;
{
struct node *oldstk,arg,src,val;
int start,forlen,srclen;
char *srcptr,*dstptr;
/* create a new stack frame */
oldstk = xlsave(&arg,&src,&val,NULL);
/* initialize */
arg.n_ptr = args;
/* get string and its length */
src.n_ptr = xlmatch(STR,&arg.n_ptr);
srcptr = src.n_ptr->n_str;
srclen = strlen(srcptr);
/* get starting pos -- must be present */
start = xlmatch(INT,&arg.n_ptr)->n_int;
/* get length -- if not present use remainder of string */
if (arg.n_ptr != NULL)
forlen = xlmatch(INT,&arg.n_ptr)->n_int;
else
forlen = srclen; /* use len and fix below */
/* make sure there aren't any more arguments */
xllastarg(arg.n_ptr);
/* don't take more than exists */
if (start + forlen > srclen)
forlen = srclen - start + 1;
/* if start beyond string -- return null string */
if (start > srclen) {
start = 1;
forlen = 0; }
/* create return node */
val.n_ptr = newnode(STR);
val.n_ptr->n_str = dstptr = stralloc(forlen);
/* move string */
for (srcptr += start-1; forlen--; *dstptr++ = *srcptr++)
;
*dstptr = 0;
/* restore the previous stack frame */
xlstack = oldstk;
/* return the substring */
return (val.n_ptr);
}
/* xascii - return ascii val
"listp", SUBR, xlistp,
"consp", SUBR, xconsp,
"eq", SUBR, xeq,
"equal", SUBR, xequal,
/* control functions */
"cond", FSUBR, xcond,
"and", FSUBR, xand,
"or", FSUBR, xor,
"let", FSUBR, xlet,
"if", FSUBR, xif,
"progn", FSUBR, xprogn,
"while", FSUBR, xwhile,
"repeat", FSUBR, xrepeat,
/* arithmetic functions */
"+", SUBR, xadd,
"-", SUBR, xsub,
"*", SUBR, xmul,
"/", SUBR, xdiv,
"1+", SUBR, xadd1,
"1-", SUBR, xsub1,
"rem", SUBR, xrem,
"minus", SUBR, xminus,
"min", SUBR, xmin,
"max", SUBR, xmax,
"abs", SUBR, xabs,
/* bitwise logical functions */
"bit-and", SUBR, xbitand,
"bit-ior", SUBR, xbitior,
"bit-xor", SUBR, xbitxor,
"bit-not", SUBR, xbitnot,
/* numeric comparison functions */
"<", SUBR, xlss,
"<=", SUBR, xleq,
"=", SUBR, xeql,
"/=", SUBR, xneq,
">=", SUBR, xgeq,
">", SUBR, xgtr,
/* string functions */
"strlen", SUBR, xstrlen,
"strcat", SUBR, xstrcat,
"substr", SUBR, xsubstr,
"ascii", SUBR, xascii,
"chr", SUBR, xchr,
"atoi", SUBR, xatoi,
"itoa", SUBR, xitoa,
/* I/O functions */
"read", SUBR, xread,
"print", SUBR, xprint,
"prin1", SUBR, xprin1,
"princ", SUBR, xprinc,
"terpri", SUBR, xterpri,
"flatsize", SUBR, xflatsize,
"flatc", SUBR, xflatc,
"explode", SUBR, xexplode,
"explodec", SUBR, xexplc,
"implode", SUBR, ximplode,
"maknam", SUBR, xmaknam,
/* file I/O functions */
"openi", SUBR, xopeni,
"openo", SUBR, xopeno,
"close", SUBR, xclose,
"read-char", SUBR, xrdchar,
"peek-char", SUBR, xpkchar,
"write-char", SUBR, xwrchar,
"readline", SUBR, xreadline,
/* system functions */
"load", SUBR, xload,
"gc", SUBR, xgc,
"expand", SUBR, xexpand,
"alloc", SUBR, xalloc,
"mem", SUBR, xmem,
"type", SUBR, xtype,
"exit", SUBR, xexit,
0
};
getc(fptr);
/* loop looking for a closing quote */
for (i = 0; i < STRMAX && (ch = checkeof(fptr)) != '"'; i++) {
switch (ch) {
case EOF:
badeof();
case '\\':
switch (ch = checkeof(fptr)) {
case 'e':
ch = '\033';
break;
case 'n':
ch = '\n';
break;
case 'r':
ch = '\r';
break;
case 't':
ch = '\t';
break;
default:
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/