Digital Research
This commit is contained in:
2020-11-06 18:50:37 +01:00
parent 621ed8ccaf
commit 31738079c4
8481 changed files with 1888323 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
dup(x)
int x;
{
return(x);
}

View File

@@ -0,0 +1,50 @@
#define BLEN 512
struct iob {
int fd; /*file descriptor*/
int cc; /*char count*/
char *cp; /*ptr to next char*/
char cbuf[BLEN]; /*char buffer*/
};
fopen(fname,ibuf,x)
char *fname;
register struct iob *ibuf;
int x;
{
ibuf->cc = 0; /*no chars*/
x = (x == 0) ? 0 : 1;
return(ibuf->fd=open(fname,0,x));
}
getc(ibuf)
register struct iob *ibuf;
{
if(ibuf->cc<=0) {
ibuf->cp = &(ibuf->cbuf[0]);
ibuf->cc = read(ibuf->fd,ibuf->cp,BLEN);
}
if(ibuf->cc <= 0) {
return(-1);
}
ibuf->cc--;
return((int)(*(ibuf->cp)++)&0xff);
}
getw(ibuf)
register struct iob *ibuf;
{
register int j;
register int i;
if((j=getc(ibuf)) == -1)
return(-1);
i = j&0377;
if((j=getc(ibuf)) == -1)
return(-1);
i |= ((j & 0377)<<8);
return(i);
}

View File

@@ -0,0 +1,24 @@
# define MAXFILES 15
struct fileps
{
char *buff; /* beginning of buffer */
char *bptr; /* current position */
int nchars; /* number of characters internal */
int bsize; /* size of buffer */
char eoferr; /* end of file flag */
char wrflag; /* mode flag */
char *pbuff; /* bottom of peek buffer */
};
struct fileps __filehdr[MAXFILES];
struct param
{
int bufsize; /* initial buffer size */
int peeksize; /* initial peek size */
};
extern struct param __param;
int __statbuf[MAXFILES];

View File

@@ -0,0 +1,12 @@
__length(s)
char *s;
{
register int l;
register char *p;
p = s;
l = 0;
while (*p++)
l++;
return(l);
}

View File

@@ -0,0 +1,90 @@
eprintf.oZe5lV
w |_>BBe5
&5
(@
@%5
(5&u%&5
(5&5$_.B$C%%@fNe&f(_ F%l5
@%-5
u C%0uu"C%0C%9u"5
"A"Wp
@A@`@eP5"hu C%.5
C%0C%9
A Wp
@A@`@eP5 m5
C%lC%L5
@@e*5@_juuu
fff
fNe*f$ue$_ Fe
uue$_Z
f&
f
fNe*f$ue$_ Fe
_Zuuu
f&
ffNe*f$ue$_ Fe
uue$_ZuuuC%X
Nf&
ffNe*f$ue$_ Fe
uue$V55$Qu$ue$u*5
+E@fNe&f(_ F%_@8
rA
yV !] % '_l ($] N _ _l  !_" &4D _" +;N_ 5u- u u @"@m5u)u% }%-u
@5
fNe&f(_ F%@u
@
@fNe&f(_ F%n@u
@@5
fNe&f(_ F%l@u
@
@fNe&f(_ F%n_@u%(=
&wB|Feh_w 6|%@@_ N@&_ V@=
H @
x\@wj{Zw d{_ND
upu
n@5r5tu%CurutC@t@EpAt@rv|5rutC
geu%!CurutC@t@ExAt@rv}5rutC
gCtE|@u
ur@=
H-At@r5ruturut#fpfnftfrw lzFe5vuxTxfpfnftfrw HzFe5rutWw2zFe
_ xHR^p)HXHXHXHXx9)Hx9)y 9_printf"~printfcsv parlistL1>L2fmtcbuf*mode(fd&ppi$width"prec leftlongfpadcharsnfnlenL4*L5:L6@L7.L8h___putch"FL9|L10L11L12DL13*L14VL15VL16|L10000
L17L19jL20"L21"L220___prtld"L236___prtsh ___prtin L24hL18ZL25lL26lL27L28L29"L30(L31XL32\L33\L34jL35pL10001zL10002~L36,L37.L38.L398L408L41PL10004VL10006xL10007L10008H___lengt L42zL43^L44:L45:L46^L47^L48L49L50*L51:L3:cret ~__putchFmodepfdcL52L53LL56L57R_putchar L55
L58^_putc L59pL10010\L54~__prtldpobjpbufbasesigned
digs
L60NL61 xvnrbnpiL63|L64HL10011TL65zL66FL67FL68L10012L69:L70DL71FL72tL73tL10013L74Flrem ldiv L62Jprtint.oZj5|(w |5fNejf
ffNef}
Fe
@@ej!
B@@ej!C%
Ce0 u@7@W`Ri
wFeHw SD
upu
nutu
ru
urAt@r5rut@=
H-uEruEturutfpfnftfrw Fe@fpfnftfrw t~Fe5rut[w^~Fe
*)y))9y___prtin"~__prtincsv pobjbufbasesigned
f
upperL1pL2digsjdpkpL44L58L6fL7PL8bL10000\L10001`L3lcret ___prtsh"v~__prtshvpobjpbufbasesigned
digs
L9"L10|xvnrpbnL12DL13PL14PL10002\L15lrem ldiv L11putc.oZz5(`w |Dt@e4u
@5Nf6f_ %
w:aw 4D%t@e4N&&_ %@%@
t|4
t
@wdZw ^D@&_ HV@tx&_ HV@w,fhw $DCmt@e4N&&_ %@ @
wf~c)(I)HI)I)HI_fcreat"~fcreatcsv fnameibufxL1FL2
L10000$L10001(_creat L3Bcret _putc"H~putcHcibufL4L5RL7_write L8~L6_putw"~putwwibufL9TL10(jixL11P_myfflus"X~myfflusXibufL12L13biL15L14putchar.oZo5<|w |;w%0NfNef_ %@%@%@"wwBNfxfp_ %@%@
wZV7
Rw
L@wDw ~DDm2w,wB(f"f_ %!@
wFdB9Y9Y_fout#<_putchar"~putcharcsv ccL1|L2L44_write L5.L3xL6dL7^cret _myflush"~~myflush~L8:L9iL112L106length.oZ[5\w |C
S
|wdt)9___lengt"~__lengtcsv sL1L2lpL4
L5L3cret getc.oZQDZw |D4
u
@5N&
f_ %
wHhw BD#t@e4N&&_ %4t@ t
@E4

View File

@@ -0,0 +1,10 @@
/*
* Use this file to determine what kind of machine you want the
* Alcyon stuff to run on ....
*/
/*#define MC68000 1*/ /* 68000 version */
/*#define VAX 1*/ /* VAX Version */
#define PDP11 1 /* PDP-11 Version*/
/*#define CPM 1*/ /* CP/M Operating System*/
#define UNIX 1 /* UNIX Operating System*/
/*#define VMS 1*/ /* VMS Operating System*/

View File

@@ -0,0 +1,9 @@
cc -c getc.c
cc -c length.c
cc -c printf.c
cc -c prtint.c
cc -c putchar.c
cc -c xstrcmp.c
cc -c putc.c
rm libx.a
ar r libx.a printf.o prtint.o putc.o putchar.o length.o getc.o xstrcmp.o

View File

@@ -0,0 +1,256 @@
# define BUFSIZ 80
/**
** formated print
**/
printf(parlist)
char *parlist;
{
register char *fmt, c;
char buf[BUFSIZ];
extern char *__prtshort(), *__prtld(), *__prtld();
int mode;
char *fd;
register char **p;
register int *pi;
int width, prec;
int left, longf;
char padchar;
char *s;
int n;
auto (*fn)();
int len;
p = &parlist;
fd = 0;
mode = 0; /* mode zero, putchar */
if (parlist + 1 < 16 + 1)
{
mode++; /* mode one, cputc */
fd = *p++;
}
if (fd == -1)
{
mode++; /* mode two, string */
fd = *p++;
}
fmt = *p++;
pi = p;
while (c = *fmt++)
{
p = pi;
if (c != '%')
{
__putch(mode, &fd, c);
continue;
}
left = 0;
if ((c = *fmt++) == '-')
{
c = *fmt++;
left++;
}
padchar = ' ';
if (c == '0')
{
padchar = c;
c = *fmt++;
}
width = -1;
while (c >= '0' && c <= '9')
{
if (width < 0)
width = 0;
width = width * 10 + (c - '0');
c = *fmt++;
}
prec = -1;
if (c == '.')
{
prec = 0;
c = *fmt++;
}
while (c >= '0' && c <= '9')
{
prec = prec * 10 + (c - '0');
c = *fmt++;
}
longf = 0;
if (c == 'l' || c == 'L')
{
longf++;
c = *fmt++;
}
/* we now have all the prelims out of the way;
let's see what we want to print */
s = buf;
switch (c)
{
case 'd': /* decimal signed */
case 'D':
if (longf)
fn = __prtld;
else
fn = __prtshort;
__prtint(pi++, buf, 10, 1, fn, 0);
if (longf)
pi++;
break;
case 'u': /* decimal unsigned */
case 'U':
__prtint(pi++, buf, 10, 0, __prtshort, 0);
break;
case 'o': /* octal unsigned */
case 'O':
if (longf)
fn = __prtld;
else
fn = __prtshort;
__prtint(pi++, buf, 8, 0, fn, 0);
if (longf)
pi++;
break;
case 'x': /* hexadecimal unsigned */
case 'X':
if (longf)
fn = __prtld;
else
fn = __prtshort;
__prtint(pi++, buf, 16, 0, fn, c == 'X');
if (longf)
pi++;
break;
case 's': /* string */
case 'S':
s = *p++;
pi = p;
break;
case 'c': /* character */
case 'C':
n = *pi++;
buf[0] = n;
buf[1] = '\0';
break;
default: /* just print the character */
__putch(mode, &fd, c);
continue;
}
len = __length(s);
if (prec < len && prec >= 0)
len = prec;
n = width - len;
if (!left)
{
if (padchar != ' ' && *s == '-')
{
len--;
__putch(mode, &fd, *s++);
}
while (n-- > 0)
__putch(mode, &fd, padchar);
}
while (len--)
__putch(mode, &fd, *s++);
while (n-- > 0)
__putch(mode, &fd, padchar);
}
if (mode == 2)
*fd = '\0';
}
__putch(mode, pfd, c)
int mode;
char c;
char **pfd;
{
switch (mode)
{
case 0:
putchar(c);
break;
case 1:
putc(c, *pfd);
break;
case 2:
*(*pfd)++ = c;
break;
}
return (c);
}
char *__prtld(pobj, pbuf, base, signed, digs)
long *pobj;
char **pbuf;
int base;
int signed;
char *digs;
{
long x;
register long n;
register long b;
register char *p;
struct {
char cbyte0;
char cbyte1;
char cbyte2;
char cbyte3;
};
register i;
struct {
int wd1;
int wd2;
};
p = digs;
b = base;
n = *pobj;
if(base == 16) { /*special because of negatives*/
i = 8;
while(n && i) {
*p++ = n & 0xf;
n =>> 4;
i--;
}
}
else if(base == 8) {
i = 11;
while(n && i) {
*p++ = n & 7;
n =>> 3;
i--;
}
if(i==0) {
*(p-1) =& 3; /*only 2 bits in upper octal digit*/
}
}
else {
if (signed && n < 0) {
*(*pbuf)++ = '-';
n = -n;
}
while(n) {
x = n % b;
*p++ = x;
n = n / b;
}
}
return (p);
}

View File

@@ -0,0 +1,29 @@
/*****************************************************************************
*
* P R I N T F F U N C T I O N
* -------------------------------
*
* The "printf" function is used to write data to the standard output.
*
* calling sequence:
*
* printf(format,arg1,arg2, ... argn);
*
* Where:
*
* format is a text string as described in K & R
* Arg1-argn are optional arguments to be converted and
* placed in the output
*
*****************************************************************************/
__putc(fd,c) /* WSL is backwards!! */
{ /****************************/
putchar(c); /* Output character */
} /****************************/
printf (fmt,a1) /* Declare args */
char *fmt; /* -> Format string */
int a1; /* Whatever the right size */
{ /****************************/
_printf (0,__putc,fmt,&a1); /* Invoke secret routine */
} /****************************/

View File

@@ -0,0 +1,62 @@
char *__prtint(pobj, buf, base, signed, f, upper)
int *pobj;
char *buf;
int base;
int signed;
int upper;
char *(*f)();
{
char digs[15];
register char *dp;
register int k;
register char *p;
dp = (*f)(pobj, &buf, base, signed, digs);
if (dp == digs)
*dp++ = 0;
p = buf;
while (dp != digs)
{
k = *--dp;
if (k < 10)
k =+ '0';
else
k =+ upper ? 'A'-10 : 'a'-10;
*p++ = k;
}
*p = 0;
return (p);
}
char *__prtshort(pobj, pbuf, base, signed, digs)
int *pobj;
char **pbuf;
int base;
int signed;
char *digs;
{
long x;
register long n;
register char *p;
register long b;
p = digs;
b = base;
n = *pobj;
if (signed && n < 0)
{
n = -n;
*(*pbuf)++ = '-';
}
else {
n =& 0xffffL; /*clear upper half*/
}
while (n != 0)
{
*p++ = n % b;
n = n / b;
}
return (p);
}

View File

@@ -0,0 +1,63 @@
#define BLEN 512
struct iob {
int fd; /*file descriptor*/
int cc; /*char count*/
char *cp; /*ptr to next char*/
char cbuf[BLEN]; /*char buffer*/
};
fcreat(fname,ibuf,x)
char *fname;
int x;
register struct iob *ibuf;
{
ibuf->cc = BLEN; /*no chars*/
ibuf->cp = &(ibuf->cbuf[0]);
x = (x == 0) ? 0 : 1;
return(ibuf->fd=creat(fname,0666,x));
}
putc(c,ibuf)
char c;
register struct iob *ibuf;
{
if(ibuf->cc<=0) {
ibuf->cp = &(ibuf->cbuf[0]);
if(write(ibuf->fd,ibuf->cp,BLEN) != BLEN)
return(-1);
ibuf->cc = BLEN;
}
*(ibuf->cp)++ = c;
ibuf->cc--;
return(c);
}
putw(w,ibuf)
int w;
register struct iob *ibuf;
{
register j;
int i;
putc((char)w,ibuf);
putc((char)(w>>8),ibuf);
return(w);
}
myfflush(ibuf)
register struct iob *ibuf;
{
register i;
i = BLEN - ibuf->cc;
ibuf->cc = BLEN;
ibuf->cp = &(ibuf->cbuf[0]);
if(write(ibuf->fd,ibuf->cp,i) != i)
return(-1);
return(0);
}

View File

@@ -0,0 +1,42 @@
#define BLEN 512
struct iob {
int fd; /*file descriptor*/
int cc; /*char count*/
char *cp; /*ptr to next char*/
char cbuf[BLEN]; /*char buffer*/
} fout = {0,BLEN,&fout.cbuf[0]};
putchar(cc)
char cc;
{
if(fout.fd <= 1) {
if(write(1,&cc,1) != 1)
return(-1);
return(cc);
}
/* buffered output*/
if(fout.cc<=0) {
fout.cp = &(fout.cbuf[0]);
if(write(fout.fd,fout.cp,BLEN) != BLEN)
return(-1);
fout.cc = BLEN;
}
*(fout.cp)++ = cc;
fout.cc--;
return(cc);
}
myflush()
{
register i;
i = BLEN - fout.cc;
fout.cc = BLEN;
fout.cp = &(fout.cbuf[0]);
if(write(fout.fd,fout.cp,i) != i)
return(-1);
return(0);
}

View File

@@ -0,0 +1,167 @@
/*****************************************************************************
*
* P R I N T F I N T E R N A L R O U T I N E
* ---------------------------------------------
*
* Routine "_printf" is used to handle all "printf" functions, including
* "sprintf", and "fprintf".
*
* Calling Sequence:
*
* _printf(fd,func,fmt,arg1);
*
* Where:
*
* fd Is the file or string pointer.
* func Is the function to handle output.
* fmt Is the address of the format string.
* arg1 Is the address of the first arg.
*
* Bugs:
*
* It is assumed that args are contiguous starting at "arg1", and that
* all are the same size (int), except for floating point.
*
* "putc" arguments are reversed from UNIX.
*
*****************************************************************************/
#include "machine.h"
char *_ptrbf = 0;
char *_ptrst = 0;
char *__fmt = 0;
_printf(fd,f,fmt,a1) /****************************/
int fd; /* Not really, but ... */
char (*f)(); /* Function pointer */
char *fmt; /* -> Format string */
int *a1; /* -> Arg list */
{ /****************************/
auto char c, *s, adj, *ptr,*p, buf[30];
auto int *adx, x, n, m, width, prec,i, padchar;
double zz, *dblptr;
extern _putstr();
_ptrbf = buf;
adx = a1;
_ptrst = fd;
__fmt = fmt;
while( c = *__fmt++ ){
if(c != '%') (*f)(fd,c);
else { x = *adx++;
if( *__fmt == '-' ){ adj = 'l'; __fmt++; }
else adj = 'r';
padchar = (*__fmt=='0') ? '0' : ' ';
width = __conv();
if( *__fmt == '.'){++__fmt; prec = __conv();}
else prec = 0;
s = 0;
if(*__fmt == 'l' || *__fmt == 'L') __fmt++;
switch ( c = *__fmt++ ) {
case 'D':
case 'd':
_prt1(x); break;
case 'o':
case 'O':
_prnt8(x); break;
case 'x':
case 'X':
_prntx(x); break;
case 'S':
case 's': s=x;
break;
case 'C':
case 'c': *_ptrbf++ = x&0777;
break;
#ifndef UNIX
case 'E':
case 'e':
case 'F':
case 'f':
dblptr = adx-1;
zz = *dblptr;
adx =+ 1;
ftoa (zz, buf, prec, c);
prec = 0;
s = buf;
break;
#endif
default: (*f)(fd,c);
adx--;
}
if (s == 0)
{*_ptrbf = '\0'; s = buf;}
n = strlen (s);
n = (prec<n && prec != 0) ? prec : n;
m = width-n;
if (adj == 'r') while (m-- > 0) (*f)(fd,padchar);
while (n--) (*f)(fd,*s++);
while (m-- > 0) (*f)(fd,padchar);
_ptrbf = buf;
}
}
if((*f) == _putstr) (*f)(fd,'\0');
}
_prnt8 (n)
{ /* print in octal */
int p, k, sw;
if (n==0) {*_ptrbf++ = '0'; return;}
sw = 0;
for (p=31; p >= 0; p =- 3)
if ((k = (n>>p)&07) || sw)
{
if (p==31)
k = k & 02;
*_ptrbf++ = '0' + k;
sw = 1;
}
}
_prntx (n)
{
int d,a;
if (a = n>>4)
_prntx ( a & 0xfffffff);
d = n&017;
*_ptrbf++ = d > 9 ? 'A'+d-10 : '0' + d;
}
__conv()
{
auto c,n;
n = 0;
while( ((c = *__fmt++) >= '0') && (c<='9'))
n = n*10+c-'0';
__fmt--;
return(n);
}
_putstr(str,chr)
char chr;
char *str;
{
*_ptrst++ = chr;
return;
}
_prt1(n)
{
int digs[15], *dpt;
dpt = digs;
if (n >= 0)
n = -n;
else
*_ptrbf++ = '-';
for (; n != 0; n = n/10)
*dpt++ = n%10;
if (dpt == digs)
*dpt++ = 0;
while (dpt != digs)
{
--dpt;
*_ptrbf++ = '0' - *dpt;
}
}

View File

@@ -0,0 +1,37 @@
/*********************************************************************
* STRCMP - compares strings
*
* Special version which is case - insensitive.
*
* WORD strcmp(s1,s2)
* BYTE *s1, *s2;
*
* 'strcmp' compares null terminated strings s1 and s2.
* Returns:
* strcmp < 0 if s1<s2
* strcmp = 0 if s1=s2
* strcmp > 0 if s1>s2
*********************************************************************/
#include <portab.h>
WORD _strcmp(s1,s2)
REG BYTE *s1, *s2;
{
REG BYTE a,b;
while (*s1 && *s2)
{
a = _toupper(*s1++);
b = _toupper(*s2++);
if (a > b) return (1);
if (a < b) return (-1);
}
return(0);
}
MLOCAL BYTE _toupper(c)
REG BYTE c;
{
if(c >= 'a' && c <= 'z')
c -= 'a' - 'A';
return(c);
}