rsli.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #include "f2c.h"
  2. #include "fio.h"
  3. #include "lio.h"
  4. #include "fmt.h" /* for f__doend */
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. extern flag f__lquit;
  9. extern int f__lcount;
  10. extern char *f__icptr;
  11. extern char *f__icend;
  12. extern icilist *f__svic;
  13. extern int f__icnum, f__recpos;
  14. static int i_getc(Void)
  15. {
  16. if(f__recpos >= f__svic->icirlen) {
  17. if (f__recpos++ == f__svic->icirlen)
  18. return '\n';
  19. z_rnew();
  20. }
  21. f__recpos++;
  22. if(f__icptr >= f__icend)
  23. return EOF;
  24. return(*f__icptr++);
  25. }
  26. static
  27. #ifdef KR_headers
  28. int i_ungetc(ch, f) int ch; FILE *f;
  29. #else
  30. int i_ungetc(int ch, FILE *f)
  31. #endif
  32. {
  33. if (--f__recpos == f__svic->icirlen)
  34. return '\n';
  35. if (f__recpos < -1)
  36. err(f__svic->icierr,110,"recend");
  37. /* *--icptr == ch, and icptr may point to read-only memory */
  38. return *--f__icptr /* = ch */;
  39. }
  40. static void
  41. #ifdef KR_headers
  42. c_lir(a) icilist *a;
  43. #else
  44. c_lir(icilist *a)
  45. #endif
  46. {
  47. extern int l_eof;
  48. f__reading = 1;
  49. f__external = 0;
  50. f__formatted = 1;
  51. f__svic = a;
  52. L_len = a->icirlen;
  53. f__recpos = -1;
  54. f__icnum = f__recpos = 0;
  55. f__cursor = 0;
  56. l_getc = i_getc;
  57. l_ungetc = i_ungetc;
  58. l_eof = 0;
  59. f__icptr = a->iciunit;
  60. f__icend = f__icptr + a->icirlen*a->icirnum;
  61. f__cf = 0;
  62. f__curunit = 0;
  63. f__elist = (cilist *)a;
  64. }
  65. #ifdef KR_headers
  66. integer s_rsli(a) icilist *a;
  67. #else
  68. integer s_rsli(icilist *a)
  69. #endif
  70. {
  71. f__lioproc = l_read;
  72. f__lquit = 0;
  73. f__lcount = 0;
  74. c_lir(a);
  75. f__doend = 0;
  76. return(0);
  77. }
  78. integer e_rsli(Void)
  79. { return 0; }
  80. #ifdef KR_headers
  81. integer s_rsni(a) icilist *a;
  82. #else
  83. extern int x_rsne(cilist*);
  84. integer s_rsni(icilist *a)
  85. #endif
  86. {
  87. extern int nml_read;
  88. integer rv;
  89. cilist ca;
  90. ca.ciend = a->iciend;
  91. ca.cierr = a->icierr;
  92. ca.cifmt = a->icifmt;
  93. c_lir(a);
  94. rv = x_rsne(&ca);
  95. nml_read = 0;
  96. return rv;
  97. }
  98. #ifdef __cplusplus
  99. }
  100. #endif