lread.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. #include "f2c.h"
  2. #include "fio.h"
  3. /* Compile with -DF8X_NML_ELIDE_QUOTES to permit eliding quotation */
  4. /* marks in namelist input a la the Fortran 8X Draft published in */
  5. /* the May 1989 issue of Fortran Forum. */
  6. #ifdef Allow_TYQUAD
  7. static longint f__llx;
  8. #endif
  9. #ifdef KR_headers
  10. extern double atof();
  11. extern char *malloc(), *realloc();
  12. int (*f__lioproc)(), (*l_getc)(), (*l_ungetc)();
  13. #else
  14. #undef abs
  15. #undef min
  16. #undef max
  17. #include "stdlib.h"
  18. #endif
  19. #include "fmt.h"
  20. #include "lio.h"
  21. #include "ctype.h"
  22. #include "fp.h"
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #ifdef KR_headers
  27. extern char *f__fmtbuf;
  28. #else
  29. extern const char *f__fmtbuf;
  30. int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint), (*l_getc)(void),
  31. (*l_ungetc)(int,FILE*);
  32. #endif
  33. int l_eof;
  34. #define isblnk(x) (f__ltab[x+1]&B)
  35. #define issep(x) (f__ltab[x+1]&SX)
  36. #define isapos(x) (f__ltab[x+1]&AX)
  37. #define isexp(x) (f__ltab[x+1]&EX)
  38. #define issign(x) (f__ltab[x+1]&SG)
  39. #define iswhit(x) (f__ltab[x+1]&WH)
  40. #define SX 1
  41. #define B 2
  42. #define AX 4
  43. #define EX 8
  44. #define SG 16
  45. #define WH 32
  46. char f__ltab[128+1] = { /* offset one for EOF */
  47. 0,
  48. 0,0,AX,0,0,0,0,0,0,WH|B,SX|WH,0,0,0,0,0,
  49. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  50. SX|B|WH,0,AX,0,0,0,0,AX,0,0,0,SG,SX,SG,0,SX,
  51. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  52. 0,0,0,0,EX,EX,0,0,0,0,0,0,0,0,0,0,
  53. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  54. AX,0,0,0,EX,EX,0,0,0,0,0,0,0,0,0,0,
  55. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  56. };
  57. #ifdef ungetc
  58. static int
  59. #ifdef KR_headers
  60. un_getc(x,f__cf) int x; FILE *f__cf;
  61. #else
  62. un_getc(int x, FILE *f__cf)
  63. #endif
  64. { return ungetc(x,f__cf); }
  65. #else
  66. #define un_getc ungetc
  67. #ifdef KR_headers
  68. extern int ungetc();
  69. #else
  70. extern int ungetc(int, FILE*); /* for systems with a buggy stdio.h */
  71. #endif
  72. #endif
  73. int
  74. t_getc(Void)
  75. { int ch;
  76. if(f__curunit->uend) return(EOF);
  77. if((ch=getc(f__cf))!=EOF) return(ch);
  78. if(feof(f__cf))
  79. f__curunit->uend = l_eof = 1;
  80. return(EOF);
  81. }
  82. integer e_rsle(Void)
  83. {
  84. int ch;
  85. if(f__curunit->uend) return(0);
  86. while((ch=t_getc())!='\n')
  87. if (ch == EOF) {
  88. if(feof(f__cf))
  89. f__curunit->uend = l_eof = 1;
  90. return EOF;
  91. }
  92. return(0);
  93. }
  94. flag f__lquit;
  95. int f__lcount,f__ltype,nml_read;
  96. char *f__lchar;
  97. double f__lx,f__ly;
  98. #define ERR(x) if(n=(x)) return(n)
  99. #define GETC(x) (x=(*l_getc)())
  100. #define Ungetc(x,y) (*l_ungetc)(x,y)
  101. static int
  102. #ifdef KR_headers
  103. l_R(poststar, reqint) int poststar, reqint;
  104. #else
  105. l_R(int poststar, int reqint)
  106. #endif
  107. {
  108. char s[FMAX+EXPMAXDIGS+4];
  109. register int ch;
  110. register char *sp, *spe, *sp1;
  111. long e, exp;
  112. int havenum, havestar, se;
  113. if (!poststar) {
  114. if (f__lcount > 0)
  115. return(0);
  116. f__lcount = 1;
  117. }
  118. #ifdef Allow_TYQUAD
  119. f__llx = 0;
  120. #endif
  121. f__ltype = 0;
  122. exp = 0;
  123. havestar = 0;
  124. retry:
  125. sp1 = sp = s;
  126. spe = sp + FMAX;
  127. havenum = 0;
  128. switch(GETC(ch)) {
  129. case '-': *sp++ = ch; sp1++; spe++;
  130. case '+':
  131. GETC(ch);
  132. }
  133. while(ch == '0') {
  134. ++havenum;
  135. GETC(ch);
  136. }
  137. while(isdigit(ch)) {
  138. if (sp < spe) *sp++ = ch;
  139. else ++exp;
  140. GETC(ch);
  141. }
  142. if (ch == '*' && !poststar) {
  143. if (sp == sp1 || exp || *s == '-') {
  144. errfl(f__elist->cierr,112,"bad repetition count");
  145. }
  146. poststar = havestar = 1;
  147. *sp = 0;
  148. f__lcount = atoi(s);
  149. goto retry;
  150. }
  151. if (ch == '.') {
  152. #ifndef ALLOW_FLOAT_IN_INTEGER_LIST_INPUT
  153. if (reqint)
  154. errfl(f__elist->cierr,115,"invalid integer");
  155. #endif
  156. GETC(ch);
  157. if (sp == sp1)
  158. while(ch == '0') {
  159. ++havenum;
  160. --exp;
  161. GETC(ch);
  162. }
  163. while(isdigit(ch)) {
  164. if (sp < spe)
  165. { *sp++ = ch; --exp; }
  166. GETC(ch);
  167. }
  168. }
  169. havenum += sp - sp1;
  170. se = 0;
  171. if (issign(ch))
  172. goto signonly;
  173. if (havenum && isexp(ch)) {
  174. #ifndef ALLOW_FLOAT_IN_INTEGER_LIST_INPUT
  175. if (reqint)
  176. errfl(f__elist->cierr,115,"invalid integer");
  177. #endif
  178. GETC(ch);
  179. if (issign(ch)) {
  180. signonly:
  181. if (ch == '-') se = 1;
  182. GETC(ch);
  183. }
  184. if (!isdigit(ch)) {
  185. bad:
  186. errfl(f__elist->cierr,112,"exponent field");
  187. }
  188. e = ch - '0';
  189. while(isdigit(GETC(ch))) {
  190. e = 10*e + ch - '0';
  191. if (e > EXPMAX)
  192. goto bad;
  193. }
  194. if (se)
  195. exp -= e;
  196. else
  197. exp += e;
  198. }
  199. (void) Ungetc(ch, f__cf);
  200. if (sp > sp1) {
  201. ++havenum;
  202. while(*--sp == '0')
  203. ++exp;
  204. if (exp)
  205. sprintf(sp+1, "e%ld", exp);
  206. else
  207. sp[1] = 0;
  208. f__lx = atof(s);
  209. #ifdef Allow_TYQUAD
  210. if (reqint&2 && (se = sp - sp1 + exp) > 14 && se < 20) {
  211. /* Assuming 64-bit longint and 32-bit long. */
  212. if (exp < 0)
  213. sp += exp;
  214. if (sp1 <= sp) {
  215. f__llx = *sp1 - '0';
  216. while(++sp1 <= sp)
  217. f__llx = 10*f__llx + (*sp1 - '0');
  218. }
  219. while(--exp >= 0)
  220. f__llx *= 10;
  221. if (*s == '-')
  222. f__llx = -f__llx;
  223. }
  224. #endif
  225. }
  226. else
  227. f__lx = 0.;
  228. if (havenum)
  229. f__ltype = TYLONG;
  230. else
  231. switch(ch) {
  232. case ',':
  233. case '/':
  234. break;
  235. default:
  236. if (havestar && ( ch == ' '
  237. ||ch == '\t'
  238. ||ch == '\n'))
  239. break;
  240. if (nml_read > 1) {
  241. f__lquit = 2;
  242. return 0;
  243. }
  244. errfl(f__elist->cierr,112,"invalid number");
  245. }
  246. return 0;
  247. }
  248. static int
  249. #ifdef KR_headers
  250. rd_count(ch) register int ch;
  251. #else
  252. rd_count(register int ch)
  253. #endif
  254. {
  255. if (ch < '0' || ch > '9')
  256. return 1;
  257. f__lcount = ch - '0';
  258. while(GETC(ch) >= '0' && ch <= '9')
  259. f__lcount = 10*f__lcount + ch - '0';
  260. Ungetc(ch,f__cf);
  261. return f__lcount <= 0;
  262. }
  263. static int
  264. l_C(Void)
  265. { int ch, nml_save;
  266. double lz;
  267. if(f__lcount>0) return(0);
  268. f__ltype=0;
  269. GETC(ch);
  270. if(ch!='(')
  271. {
  272. if (nml_read > 1 && (ch < '0' || ch > '9')) {
  273. Ungetc(ch,f__cf);
  274. f__lquit = 2;
  275. return 0;
  276. }
  277. if (rd_count(ch))
  278. if(!f__cf || !feof(f__cf))
  279. errfl(f__elist->cierr,112,"complex format");
  280. else
  281. err(f__elist->cierr,(EOF),"lread");
  282. if(GETC(ch)!='*')
  283. {
  284. if(!f__cf || !feof(f__cf))
  285. errfl(f__elist->cierr,112,"no star");
  286. else
  287. err(f__elist->cierr,(EOF),"lread");
  288. }
  289. if(GETC(ch)!='(')
  290. { Ungetc(ch,f__cf);
  291. return(0);
  292. }
  293. }
  294. else
  295. f__lcount = 1;
  296. while(iswhit(GETC(ch)));
  297. Ungetc(ch,f__cf);
  298. nml_save = nml_read;
  299. nml_read = 0;
  300. if (ch = l_R(1,0))
  301. return ch;
  302. if (!f__ltype)
  303. errfl(f__elist->cierr,112,"no real part");
  304. lz = f__lx;
  305. while(iswhit(GETC(ch)));
  306. if(ch!=',')
  307. { (void) Ungetc(ch,f__cf);
  308. errfl(f__elist->cierr,112,"no comma");
  309. }
  310. while(iswhit(GETC(ch)));
  311. (void) Ungetc(ch,f__cf);
  312. if (ch = l_R(1,0))
  313. return ch;
  314. if (!f__ltype)
  315. errfl(f__elist->cierr,112,"no imaginary part");
  316. while(iswhit(GETC(ch)));
  317. if(ch!=')') errfl(f__elist->cierr,112,"no )");
  318. f__ly = f__lx;
  319. f__lx = lz;
  320. #ifdef Allow_TYQUAD
  321. f__llx = 0;
  322. #endif
  323. nml_read = nml_save;
  324. return(0);
  325. }
  326. static char nmLbuf[256], *nmL_next;
  327. static int (*nmL_getc_save)(Void);
  328. #ifdef KR_headers
  329. static int (*nmL_ungetc_save)(/* int, FILE* */);
  330. #else
  331. static int (*nmL_ungetc_save)(int, FILE*);
  332. #endif
  333. static int
  334. nmL_getc(Void)
  335. {
  336. int rv;
  337. if (rv = *nmL_next++)
  338. return rv;
  339. l_getc = nmL_getc_save;
  340. l_ungetc = nmL_ungetc_save;
  341. return (*l_getc)();
  342. }
  343. static int
  344. #ifdef KR_headers
  345. nmL_ungetc(x, f) int x; FILE *f;
  346. #else
  347. nmL_ungetc(int x, FILE *f)
  348. #endif
  349. {
  350. f = f; /* banish non-use warning */
  351. return *--nmL_next = x;
  352. }
  353. static int
  354. #ifdef KR_headers
  355. Lfinish(ch, dot, rvp) int ch, dot, *rvp;
  356. #else
  357. Lfinish(int ch, int dot, int *rvp)
  358. #endif
  359. {
  360. char *s, *se;
  361. static char what[] = "namelist input";
  362. s = nmLbuf + 2;
  363. se = nmLbuf + sizeof(nmLbuf) - 1;
  364. *s++ = ch;
  365. while(!issep(GETC(ch)) && ch!=EOF) {
  366. if (s >= se) {
  367. nmLbuf_ovfl:
  368. return *rvp = err__fl(f__elist->cierr,131,what);
  369. }
  370. *s++ = ch;
  371. if (ch != '=')
  372. continue;
  373. if (dot)
  374. return *rvp = err__fl(f__elist->cierr,112,what);
  375. got_eq:
  376. *s = 0;
  377. nmL_getc_save = l_getc;
  378. l_getc = nmL_getc;
  379. nmL_ungetc_save = l_ungetc;
  380. l_ungetc = nmL_ungetc;
  381. nmLbuf[1] = *(nmL_next = nmLbuf) = ',';
  382. *rvp = f__lcount = 0;
  383. return 1;
  384. }
  385. if (dot)
  386. goto done;
  387. for(;;) {
  388. if (s >= se)
  389. goto nmLbuf_ovfl;
  390. *s++ = ch;
  391. if (!isblnk(ch))
  392. break;
  393. if (GETC(ch) == EOF)
  394. goto done;
  395. }
  396. if (ch == '=')
  397. goto got_eq;
  398. done:
  399. Ungetc(ch, f__cf);
  400. return 0;
  401. }
  402. static int
  403. l_L(Void)
  404. {
  405. int ch, rv, sawdot;
  406. if(f__lcount>0)
  407. return(0);
  408. f__lcount = 1;
  409. f__ltype=0;
  410. GETC(ch);
  411. if(isdigit(ch))
  412. {
  413. rd_count(ch);
  414. if(GETC(ch)!='*')
  415. if(!f__cf || !feof(f__cf))
  416. errfl(f__elist->cierr,112,"no star");
  417. else
  418. err(f__elist->cierr,(EOF),"lread");
  419. GETC(ch);
  420. }
  421. sawdot = 0;
  422. if(ch == '.') {
  423. sawdot = 1;
  424. GETC(ch);
  425. }
  426. switch(ch)
  427. {
  428. case 't':
  429. case 'T':
  430. if (nml_read && Lfinish(ch, sawdot, &rv))
  431. return rv;
  432. f__lx=1;
  433. break;
  434. case 'f':
  435. case 'F':
  436. if (nml_read && Lfinish(ch, sawdot, &rv))
  437. return rv;
  438. f__lx=0;
  439. break;
  440. default:
  441. if(isblnk(ch) || issep(ch) || ch==EOF)
  442. { (void) Ungetc(ch,f__cf);
  443. return(0);
  444. }
  445. if (nml_read > 1) {
  446. Ungetc(ch,f__cf);
  447. f__lquit = 2;
  448. return 0;
  449. }
  450. errfl(f__elist->cierr,112,"logical");
  451. }
  452. f__ltype=TYLONG;
  453. while(!issep(GETC(ch)) && ch!=EOF);
  454. Ungetc(ch, f__cf);
  455. return(0);
  456. }
  457. #define BUFSIZE 128
  458. static int
  459. l_CHAR(Void)
  460. { int ch,size,i;
  461. static char rafail[] = "realloc failure";
  462. char quote,*p;
  463. if(f__lcount>0) return(0);
  464. f__ltype=0;
  465. if(f__lchar!=NULL) free(f__lchar);
  466. size=BUFSIZE;
  467. p=f__lchar = (char *)malloc((unsigned int)size);
  468. if(f__lchar == NULL)
  469. errfl(f__elist->cierr,113,"no space");
  470. GETC(ch);
  471. if(isdigit(ch)) {
  472. /* allow Fortran 8x-style unquoted string... */
  473. /* either find a repetition count or the string */
  474. f__lcount = ch - '0';
  475. *p++ = ch;
  476. for(i = 1;;) {
  477. switch(GETC(ch)) {
  478. case '*':
  479. if (f__lcount == 0) {
  480. f__lcount = 1;
  481. #ifndef F8X_NML_ELIDE_QUOTES
  482. if (nml_read)
  483. goto no_quote;
  484. #endif
  485. goto noquote;
  486. }
  487. p = f__lchar;
  488. goto have_lcount;
  489. case ',':
  490. case ' ':
  491. case '\t':
  492. case '\n':
  493. case '/':
  494. Ungetc(ch,f__cf);
  495. /* no break */
  496. case EOF:
  497. f__lcount = 1;
  498. f__ltype = TYCHAR;
  499. return *p = 0;
  500. }
  501. if (!isdigit(ch)) {
  502. f__lcount = 1;
  503. #ifndef F8X_NML_ELIDE_QUOTES
  504. if (nml_read) {
  505. no_quote:
  506. errfl(f__elist->cierr,112,
  507. "undelimited character string");
  508. }
  509. #endif
  510. goto noquote;
  511. }
  512. *p++ = ch;
  513. f__lcount = 10*f__lcount + ch - '0';
  514. if (++i == size) {
  515. f__lchar = (char *)realloc(f__lchar,
  516. (unsigned int)(size += BUFSIZE));
  517. if(f__lchar == NULL)
  518. errfl(f__elist->cierr,113,rafail);
  519. p = f__lchar + i;
  520. }
  521. }
  522. }
  523. else (void) Ungetc(ch,f__cf);
  524. have_lcount:
  525. if(GETC(ch)=='\'' || ch=='"') quote=ch;
  526. else if(isblnk(ch) || (issep(ch) && ch != '\n') || ch==EOF) {
  527. Ungetc(ch,f__cf);
  528. return 0;
  529. }
  530. #ifndef F8X_NML_ELIDE_QUOTES
  531. else if (nml_read > 1) {
  532. Ungetc(ch,f__cf);
  533. f__lquit = 2;
  534. return 0;
  535. }
  536. #endif
  537. else {
  538. /* Fortran 8x-style unquoted string */
  539. *p++ = ch;
  540. for(i = 1;;) {
  541. switch(GETC(ch)) {
  542. case ',':
  543. case ' ':
  544. case '\t':
  545. case '\n':
  546. case '/':
  547. Ungetc(ch,f__cf);
  548. /* no break */
  549. case EOF:
  550. f__ltype = TYCHAR;
  551. return *p = 0;
  552. }
  553. noquote:
  554. *p++ = ch;
  555. if (++i == size) {
  556. f__lchar = (char *)realloc(f__lchar,
  557. (unsigned int)(size += BUFSIZE));
  558. if(f__lchar == NULL)
  559. errfl(f__elist->cierr,113,rafail);
  560. p = f__lchar + i;
  561. }
  562. }
  563. }
  564. f__ltype=TYCHAR;
  565. for(i=0;;)
  566. { while(GETC(ch)!=quote && ch!='\n'
  567. && ch!=EOF && ++i<size) *p++ = ch;
  568. if(i==size)
  569. {
  570. newone:
  571. f__lchar= (char *)realloc(f__lchar,
  572. (unsigned int)(size += BUFSIZE));
  573. if(f__lchar == NULL)
  574. errfl(f__elist->cierr,113,rafail);
  575. p=f__lchar+i-1;
  576. *p++ = ch;
  577. }
  578. else if(ch==EOF) return(EOF);
  579. else if(ch=='\n')
  580. { if(*(p-1) != '\\') continue;
  581. i--;
  582. p--;
  583. if(++i<size) *p++ = ch;
  584. else goto newone;
  585. }
  586. else if(GETC(ch)==quote)
  587. { if(++i<size) *p++ = ch;
  588. else goto newone;
  589. }
  590. else
  591. { (void) Ungetc(ch,f__cf);
  592. *p = 0;
  593. return(0);
  594. }
  595. }
  596. }
  597. int
  598. #ifdef KR_headers
  599. c_le(a) cilist *a;
  600. #else
  601. c_le(cilist *a)
  602. #endif
  603. {
  604. if(!f__init)
  605. f_init();
  606. f__fmtbuf="list io";
  607. f__curunit = &f__units[a->ciunit];
  608. if(a->ciunit>=MXUNIT || a->ciunit<0)
  609. err(a->cierr,101,"stler");
  610. f__scale=f__recpos=0;
  611. f__elist=a;
  612. if(f__curunit->ufd==NULL && fk_open(SEQ,FMT,a->ciunit))
  613. err(a->cierr,102,"lio");
  614. f__cf=f__curunit->ufd;
  615. if(!f__curunit->ufmt) err(a->cierr,103,"lio")
  616. return(0);
  617. }
  618. int
  619. #ifdef KR_headers
  620. l_read(number,ptr,len,type) ftnint *number,type; char *ptr; ftnlen len;
  621. #else
  622. l_read(ftnint *number, char *ptr, ftnlen len, ftnint type)
  623. #endif
  624. {
  625. #define Ptr ((flex *)ptr)
  626. int i,n,ch;
  627. doublereal *yy;
  628. real *xx;
  629. for(i=0;i<*number;i++)
  630. {
  631. if(f__lquit) return(0);
  632. if(l_eof)
  633. err(f__elist->ciend, EOF, "list in")
  634. if(f__lcount == 0) {
  635. f__ltype = 0;
  636. for(;;) {
  637. GETC(ch);
  638. switch(ch) {
  639. case EOF:
  640. err(f__elist->ciend,(EOF),"list in")
  641. case ' ':
  642. case '\t':
  643. case '\n':
  644. continue;
  645. case '/':
  646. f__lquit = 1;
  647. goto loopend;
  648. case ',':
  649. f__lcount = 1;
  650. goto loopend;
  651. default:
  652. (void) Ungetc(ch, f__cf);
  653. goto rddata;
  654. }
  655. }
  656. }
  657. rddata:
  658. switch((int)type)
  659. {
  660. case TYINT1:
  661. case TYSHORT:
  662. case TYLONG:
  663. #ifndef ALLOW_FLOAT_IN_INTEGER_LIST_INPUT
  664. ERR(l_R(0,1));
  665. break;
  666. #endif
  667. case TYREAL:
  668. case TYDREAL:
  669. ERR(l_R(0,0));
  670. break;
  671. #ifdef TYQUAD
  672. case TYQUAD:
  673. n = l_R(0,2);
  674. if (n)
  675. return n;
  676. break;
  677. #endif
  678. case TYCOMPLEX:
  679. case TYDCOMPLEX:
  680. ERR(l_C());
  681. break;
  682. case TYLOGICAL1:
  683. case TYLOGICAL2:
  684. case TYLOGICAL:
  685. ERR(l_L());
  686. break;
  687. case TYCHAR:
  688. ERR(l_CHAR());
  689. break;
  690. }
  691. while (GETC(ch) == ' ' || ch == '\t');
  692. if (ch != ',' || f__lcount > 1)
  693. Ungetc(ch,f__cf);
  694. loopend:
  695. if(f__lquit) return(0);
  696. if(f__cf && ferror(f__cf)) {
  697. clearerr(f__cf);
  698. errfl(f__elist->cierr,errno,"list in");
  699. }
  700. if(f__ltype==0) goto bump;
  701. switch((int)type)
  702. {
  703. case TYINT1:
  704. case TYLOGICAL1:
  705. Ptr->flchar = (char)f__lx;
  706. break;
  707. case TYLOGICAL2:
  708. case TYSHORT:
  709. Ptr->flshort = (short)f__lx;
  710. break;
  711. case TYLOGICAL:
  712. case TYLONG:
  713. Ptr->flint = (ftnint)f__lx;
  714. break;
  715. #ifdef Allow_TYQUAD
  716. case TYQUAD:
  717. if (!(Ptr->fllongint = f__llx))
  718. Ptr->fllongint = f__lx;
  719. break;
  720. #endif
  721. case TYREAL:
  722. Ptr->flreal=f__lx;
  723. break;
  724. case TYDREAL:
  725. Ptr->fldouble=f__lx;
  726. break;
  727. case TYCOMPLEX:
  728. xx=(real *)ptr;
  729. *xx++ = f__lx;
  730. *xx = f__ly;
  731. break;
  732. case TYDCOMPLEX:
  733. yy=(doublereal *)ptr;
  734. *yy++ = f__lx;
  735. *yy = f__ly;
  736. break;
  737. case TYCHAR:
  738. b_char(f__lchar,ptr,len);
  739. break;
  740. }
  741. bump:
  742. if(f__lcount>0) f__lcount--;
  743. ptr += len;
  744. if (nml_read)
  745. nml_read++;
  746. }
  747. return(0);
  748. #undef Ptr
  749. }
  750. #ifdef KR_headers
  751. integer s_rsle(a) cilist *a;
  752. #else
  753. integer s_rsle(cilist *a)
  754. #endif
  755. {
  756. int n;
  757. f__reading=1;
  758. f__external=1;
  759. f__formatted=1;
  760. if(n=c_le(a)) return(n);
  761. f__lioproc = l_read;
  762. f__lquit = 0;
  763. f__lcount = 0;
  764. l_eof = 0;
  765. if(f__curunit->uwrt && f__nowreading(f__curunit))
  766. err(a->cierr,errno,"read start");
  767. if(f__curunit->uend)
  768. err(f__elist->ciend,(EOF),"read start");
  769. l_getc = t_getc;
  770. l_ungetc = un_getc;
  771. f__doend = xrd_SL;
  772. return(0);
  773. }
  774. #ifdef __cplusplus
  775. }
  776. #endif