~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/f2c/libf2c/iio.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "f2c.h"
 
2
#include "fio.h"
 
3
#include "fmt.h"
 
4
extern char *f__icptr;
 
5
char *f__icend;
 
6
extern icilist *f__svic;
 
7
int f__icnum;
 
8
extern int f__hiwater;
 
9
z_getc(Void)
 
10
{
 
11
        if(f__recpos++ < f__svic->icirlen) {
 
12
                if(f__icptr >= f__icend) err(f__svic->iciend,(EOF),"endfile");
 
13
                return(*(unsigned char *)f__icptr++);
 
14
                }
 
15
        return '\n';
 
16
}
 
17
#ifdef KR_headers
 
18
z_putc(c)
 
19
#else
 
20
z_putc(int c)
 
21
#endif
 
22
{
 
23
        if(f__icptr >= f__icend) err(f__svic->icierr,110,"inwrite");
 
24
        if(f__recpos++ < f__svic->icirlen)
 
25
                *f__icptr++ = c;
 
26
        else    err(f__svic->icierr,110,"recend");
 
27
        return 0;
 
28
}
 
29
z_rnew(Void)
 
30
{
 
31
        f__icptr = f__svic->iciunit + (++f__icnum)*f__svic->icirlen;
 
32
        f__recpos = 0;
 
33
        f__cursor = 0;
 
34
        f__hiwater = 0;
 
35
        return 1;
 
36
}
 
37
 
 
38
 static int
 
39
z_endp(Void)
 
40
{
 
41
        (*f__donewrec)();
 
42
        return 0;
 
43
        }
 
44
 
 
45
#ifdef KR_headers
 
46
c_si(a) icilist *a;
 
47
#else
 
48
c_si(icilist *a)
 
49
#endif
 
50
{
 
51
        f__elist = (cilist *)a;
 
52
        f__fmtbuf=a->icifmt;
 
53
        if(pars_f(f__fmtbuf)<0)
 
54
                err(a->icierr,100,"startint");
 
55
        fmt_bg();
 
56
        f__sequential=f__formatted=1;
 
57
        f__external=0;
 
58
        f__cblank=f__cplus=f__scale=0;
 
59
        f__svic=a;
 
60
        f__icnum=f__recpos=0;
 
61
        f__cursor = 0;
 
62
        f__hiwater = 0;
 
63
        f__icptr = a->iciunit;
 
64
        f__icend = f__icptr + a->icirlen*a->icirnum;
 
65
        f__curunit = 0;
 
66
        f__cf = 0;
 
67
        return(0);
 
68
}
 
69
 
 
70
 int
 
71
iw_rev(Void)
 
72
{
 
73
        if(f__workdone)
 
74
                z_endp();
 
75
        f__hiwater = f__recpos = f__cursor = 0;
 
76
        return(f__workdone=0);
 
77
        }
 
78
 
 
79
#ifdef KR_headers
 
80
integer s_rsfi(a) icilist *a;
 
81
#else
 
82
integer s_rsfi(icilist *a)
 
83
#endif
 
84
{       int n;
 
85
        if(n=c_si(a)) return(n);
 
86
        f__reading=1;
 
87
        f__doed=rd_ed;
 
88
        f__doned=rd_ned;
 
89
        f__getn=z_getc;
 
90
        f__dorevert = z_endp;
 
91
        f__donewrec = z_rnew;
 
92
        f__doend = z_endp;
 
93
        return(0);
 
94
}
 
95
 
 
96
z_wnew(Void)
 
97
{
 
98
        if (f__recpos < f__hiwater) {
 
99
                f__icptr += f__hiwater - f__recpos;
 
100
                f__recpos = f__hiwater;
 
101
                }
 
102
        while(f__recpos++ < f__svic->icirlen)
 
103
                *f__icptr++ = ' ';
 
104
        f__recpos = 0;
 
105
        f__cursor = 0;
 
106
        f__hiwater = 0;
 
107
        f__icnum++;
 
108
        return 1;
 
109
}
 
110
#ifdef KR_headers
 
111
integer s_wsfi(a) icilist *a;
 
112
#else
 
113
integer s_wsfi(icilist *a)
 
114
#endif
 
115
{       int n;
 
116
        if(n=c_si(a)) return(n);
 
117
        f__reading=0;
 
118
        f__doed=w_ed;
 
119
        f__doned=w_ned;
 
120
        f__putn=z_putc;
 
121
        f__dorevert = iw_rev;
 
122
        f__donewrec = z_wnew;
 
123
        f__doend = z_endp;
 
124
        return(0);
 
125
}
 
126
integer e_rsfi(Void)
 
127
{       int n;
 
128
        n = en_fio();
 
129
        f__fmtbuf = NULL;
 
130
        return(n);
 
131
}
 
132
integer e_wsfi(Void)
 
133
{
 
134
        int n;
 
135
        n = en_fio();
 
136
        f__fmtbuf = NULL;
 
137
        if(f__icnum >= f__svic->icirnum)
 
138
                return(n);
 
139
        while(f__recpos++ < f__svic->icirlen)
 
140
                *f__icptr++ = ' ';
 
141
        return(n);
 
142
}