Mapper
shint.c
Go to the documentation of this file.
1 /*Translated by FOR_C, v3.4.2 (-), on 06/07/94 at 17:02:36 */
2 /*FOR_C Options SET: c=2 com=u do=r4 ftn=2ln6k op=iv s=dvn str=l sq=i */
3 #define _POSIX_SOURCE
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <ctype.h>
7 #include <dirent.h>
8 #include <unistd.h>
9 #include <math.h>
10 #include <string.h>
11 #include <fcntl.h>
12 #include <sys/stat.h>
13 #include "shef_structs_external.h"
14 
15 /*---------------------------------------------------------------------
16 
17  NAME
18  SUBROUTINE SHINT(INUM,NDIG,IFLAG,STATUS)
19 
20  PURPOSE
21 
22  This routine will extract an integer of NDIG digits from
23  the input file and return it in INUM. If IFLAG is set to 0,
24  it uses the last character read. The number of digits
25  actually read is returned in NDIG.
26 
27  VERSION and UPDATES
28  1.0 APR 82 Geoffrey M. Bonnin
29  Original Version
30  2.0 JUN 94 David G. Brandon
31  Also Translated to 'C' using FOR_C
32  Removed alternate returns in subroutines
33  2.1 Add iscore to t_codes array.
34  *--------------------------------------------------------------------- */
35 
36 
37 void shint(inum, ndig, iflag, status)
38 short int *inum, *ndig, iflag, *status;
39 {
40  short int num();
41  static short int idig;
42 
43 int xtemp, xcode;
44  *status = 0;
45  *inum = 0;
46  idig = 0;
47  /* Get the next digit and check it */
48 
49  if( iflag == 0 )
50  goto L_20;
51 L_10:
52  nextch( &xchar_.ichar, status );
53  if( *status == 1 )
54  {
55  *status = 0;
56  goto L_9010;
57  }
58  else if( *status == 2 )
59  {
60  *status = 0;
61  goto L_9020;
62  }
63 
64 L_20:
65  irang( &xchar_.ichar, &codes_.ich0, &codes_.ich9, status );
66  if( *status == 1 )
67  {
68  *status = 0;
69  goto L_9030;
70  }
71  /* Build number */
72 
73 /* *inum = *inum*10 + (num( &xchar_.ichar ) - num( &codes_.ich0 )); */
74  *inum = *inum*10 + ( xchar_.ichar - codes_.ich0 );
75  /* Check if another digit is required */
76 
77  idig = idig + 1;
78  if( idig >= *ndig )
79  goto L_9000;
80  goto L_10;
81 
82  /* Normal return */
83 
84 L_9000:
85  return;
86 
87  /* Stop reading the line */
88 
89 L_9010:
90  *status = 1;
91  return;
92 
93  /* Error in reading the file */
94 
95 L_9020:
96  *status = 2;
97  return;
98 
99  /* Error in number of digits */
100 
101 L_9030:
102  *ndig = idig;
103  *status = 3;
104  return;
105 
106 }
107 
void irang(short int *i, short int *min_, short int *max_, short int *status)
Definition: irang.c:33
void nextch(short int *ichar, short int *status)
Definition: nextch.c:76
struct t_codes_ codes_
struct t_xchar_ xchar_
void shint(short int *inum, short int *ndig, short int iflag, short int *status)
Definition: shint.c:37
short int ich0
Definition: shef_structs.h:80
short int ich9
Definition: shef_structs.h:81
short int ichar
Definition: shef_structs.h:112