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

« back to all changes in this revision

Viewing changes to routines/f2c/libf2c/rsfe.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
/* read sequential formatted external */
 
2
#include "f2c.h"
 
3
#include "fio.h"
 
4
#include "fmt.h"
 
5
 
 
6
xrd_SL(Void)
 
7
{       int ch;
 
8
        if(!f__curunit->uend)
 
9
                while((ch=getc(f__cf))!='\n')
 
10
                        if (ch == EOF) {
 
11
                                f__curunit->uend = 1;
 
12
                                break;
 
13
                                }
 
14
        f__cursor=f__recpos=0;
 
15
        return(1);
 
16
}
 
17
x_getc(Void)
 
18
{       int ch;
 
19
        if(f__curunit->uend) return(EOF);
 
20
        ch = getc(f__cf);
 
21
        if(ch!=EOF && ch!='\n')
 
22
        {       f__recpos++;
 
23
                return(ch);
 
24
        }
 
25
        if(ch=='\n')
 
26
        {       (void) ungetc(ch,f__cf);
 
27
                return(ch);
 
28
        }
 
29
        if(f__curunit->uend || feof(f__cf))
 
30
        {       errno=0;
 
31
                f__curunit->uend=1;
 
32
                return(-1);
 
33
        }
 
34
        return(-1);
 
35
}
 
36
x_endp(Void)
 
37
{
 
38
        xrd_SL();
 
39
        return f__curunit->uend == 1 ? EOF : 0;
 
40
}
 
41
x_rev(Void)
 
42
{
 
43
        (void) xrd_SL();
 
44
        return(0);
 
45
}
 
46
#ifdef KR_headers
 
47
integer s_rsfe(a) cilist *a; /* start */
 
48
#else
 
49
integer s_rsfe(cilist *a) /* start */
 
50
#endif
 
51
{       int n;
 
52
        if(!f__init) f_init();
 
53
        if(n=c_sfe(a)) return(n);
 
54
        f__reading=1;
 
55
        f__sequential=1;
 
56
        f__formatted=1;
 
57
        f__external=1;
 
58
        f__elist=a;
 
59
        f__cursor=f__recpos=0;
 
60
        f__scale=0;
 
61
        f__fmtbuf=a->cifmt;
 
62
        f__curunit= &f__units[a->ciunit];
 
63
        f__cf=f__curunit->ufd;
 
64
        if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio");
 
65
        f__getn= x_getc;
 
66
        f__doed= rd_ed;
 
67
        f__doned= rd_ned;
 
68
        fmt_bg();
 
69
        f__doend=x_endp;
 
70
        f__donewrec=xrd_SL;
 
71
        f__dorevert=x_rev;
 
72
        f__cblank=f__curunit->ublnk;
 
73
        f__cplus=0;
 
74
        if(f__curunit->uwrt && f__nowreading(f__curunit))
 
75
                err(a->cierr,errno,"read start");
 
76
        if(f__curunit->uend)
 
77
                err(f__elist->ciend,(EOF),"read start");
 
78
        return(0);
 
79
}