Rev | Line | |
---|
[9] | 1 | /* $Header: /cvsup/minix/src/lib/ack/libp/rdi.c,v 1.1 2005/10/10 15:27:47 beng Exp $ */
|
---|
| 2 | /*
|
---|
| 3 | * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
---|
| 4 | *
|
---|
| 5 | * This product is part of the Amsterdam Compiler Kit.
|
---|
| 6 | *
|
---|
| 7 | * Permission to use, sell, duplicate or disclose this software must be
|
---|
| 8 | * obtained in writing. Requests for such permissions may be sent to
|
---|
| 9 | *
|
---|
| 10 | * Dr. Andrew S. Tanenbaum
|
---|
| 11 | * Wiskundig Seminarium
|
---|
| 12 | * Vrije Universiteit
|
---|
| 13 | * Postbox 7161
|
---|
| 14 | * 1007 MC Amsterdam
|
---|
| 15 | * The Netherlands
|
---|
| 16 | *
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | /* Author: J.W. Stevenson */
|
---|
| 20 |
|
---|
| 21 | #include <pc_file.h>
|
---|
| 22 | #include <pc_err.h>
|
---|
| 23 |
|
---|
| 24 | extern _trp();
|
---|
| 25 | extern _rf();
|
---|
| 26 | extern _incpt();
|
---|
| 27 |
|
---|
| 28 | _skipsp(f) struct file *f; {
|
---|
| 29 | while ((*f->ptr == ' ') || (*f->ptr == '\t'))
|
---|
| 30 | _incpt(f);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | int _getsig(f) struct file *f; {
|
---|
| 34 | int sign;
|
---|
| 35 |
|
---|
| 36 | if ((sign = (*f->ptr == '-')) || *f->ptr == '+')
|
---|
| 37 | _incpt(f);
|
---|
| 38 | return(sign);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | int _fstdig(f) struct file *f; {
|
---|
| 42 | int ch;
|
---|
| 43 |
|
---|
| 44 | ch = *f->ptr - '0';
|
---|
| 45 | if ((unsigned) ch > 9) {
|
---|
| 46 | _trp(EDIGIT);
|
---|
| 47 | ch = 0;
|
---|
| 48 | }
|
---|
| 49 | return(ch);
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | int _nxtdig(f) struct file *f; {
|
---|
| 53 | int ch;
|
---|
| 54 |
|
---|
| 55 | _incpt(f);
|
---|
| 56 | ch = *f->ptr - '0';
|
---|
| 57 | if ((unsigned) ch > 9)
|
---|
| 58 | return(-1);
|
---|
| 59 | return(ch);
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | int _getint(f) struct file *f; {
|
---|
| 63 | int is_signed,i,ch;
|
---|
| 64 |
|
---|
| 65 | is_signed = _getsig(f);
|
---|
| 66 | ch = _fstdig(f);
|
---|
| 67 | i = 0;
|
---|
| 68 | do
|
---|
| 69 | i = i*10 - ch;
|
---|
| 70 | while ((ch = _nxtdig(f)) >= 0);
|
---|
| 71 | return(is_signed ? i : -i);
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | int _rdi(f) struct file *f; {
|
---|
| 75 | _rf(f);
|
---|
| 76 | _skipsp(f);
|
---|
| 77 | return(_getint(f));
|
---|
| 78 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.