1984-07-20 11:03:31 +00:00
|
|
|
/* $Header$ */
|
1984-07-20 10:44:57 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
*
|
|
|
|
* This product is part of the Amsterdam Compiler Kit.
|
|
|
|
*
|
|
|
|
* Permission to use, sell, duplicate or disclose this software must be
|
|
|
|
* obtained in writing. Requests for such permissions may be sent to
|
|
|
|
*
|
|
|
|
* Dr. Andrew S. Tanenbaum
|
|
|
|
* Wiskundig Seminarium
|
|
|
|
* Vrije Universiteit
|
|
|
|
* Postbox 7161
|
|
|
|
* 1007 MC Amsterdam
|
|
|
|
* The Netherlands
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Author: J.W. Stevenson */
|
|
|
|
|
|
|
|
#include <pc_file.h>
|
|
|
|
#include <pc_err.h>
|
|
|
|
|
|
|
|
extern _trp();
|
|
|
|
extern _rf();
|
|
|
|
extern _incpt();
|
|
|
|
|
|
|
|
_skipsp(f) struct file *f; {
|
|
|
|
while ((*f->ptr == ' ') || (*f->ptr == '\t'))
|
|
|
|
_incpt(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
int _getsig(f) struct file *f; {
|
|
|
|
int sign;
|
|
|
|
|
|
|
|
if ((sign = (*f->ptr == '-')) || *f->ptr == '+')
|
|
|
|
_incpt(f);
|
|
|
|
return(sign);
|
|
|
|
}
|
|
|
|
|
|
|
|
int _fstdig(f) struct file *f; {
|
|
|
|
int ch;
|
|
|
|
|
|
|
|
ch = *f->ptr - '0';
|
|
|
|
if ((unsigned) ch > 9) {
|
|
|
|
_trp(EDIGIT);
|
|
|
|
ch = 0;
|
|
|
|
}
|
|
|
|
return(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
int _nxtdig(f) struct file *f; {
|
|
|
|
int ch;
|
|
|
|
|
|
|
|
_incpt(f);
|
|
|
|
ch = *f->ptr - '0';
|
|
|
|
if ((unsigned) ch > 9)
|
|
|
|
return(-1);
|
|
|
|
return(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
int _getint(f) struct file *f; {
|
1990-11-06 13:02:55 +00:00
|
|
|
int is_signed,i,ch;
|
1984-07-20 10:44:57 +00:00
|
|
|
|
1990-11-06 13:02:55 +00:00
|
|
|
is_signed = _getsig(f);
|
1984-07-20 10:44:57 +00:00
|
|
|
ch = _fstdig(f);
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
i = i*10 - ch;
|
|
|
|
while ((ch = _nxtdig(f)) >= 0);
|
1990-11-06 13:02:55 +00:00
|
|
|
return(is_signed ? i : -i);
|
1984-07-20 10:44:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int _rdi(f) struct file *f; {
|
|
|
|
_rf(f);
|
|
|
|
_skipsp(f);
|
|
|
|
return(_getint(f));
|
|
|
|
}
|