1 /* beint.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure            BEINT  ( Be an Integer? ) */
beint_(char * string,ftnlen string_len)9 logical beint_(char *string, ftnlen string_len)
10 {
11     /* System generated locals */
12     logical ret_val;
13 
14     /* Builtin functions */
15     integer i_len(char *, ftnlen);
16 
17     /* Local variables */
18     integer i__, l;
19     extern logical beuns_(char *, ftnlen);
20     extern integer frstnb_(char *, ftnlen);
21     char letter[1];
22 
23 /* $ Abstract */
24 
25 /*     Determine whether a string represents an integer. */
26 
27 /* $ Disclaimer */
28 
29 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
30 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
31 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
32 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
33 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
34 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
35 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
36 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
37 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
38 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
39 
40 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
41 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
42 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
43 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
44 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
45 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
46 
47 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
48 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
49 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
50 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
51 
52 /* $ Required_Reading */
53 
54 /*     WORDS */
55 
56 /* $ Keywords */
57 
58 /*     ALPHANUMERIC */
59 /*     NUMBERS */
60 /*     SCANNING */
61 /*     UTILITY */
62 
63 /* $ Declarations */
64 /* $ Brief_I/O */
65 
66 /*     Variable  I/O  Description */
67 /*     --------  ---  -------------------------------------------------- */
68 /*     STRING     I   Character string. */
69 
70 /*     The function returns TRUE if the string represents an integer. */
71 /*     Otherwise, it returns FALSE. */
72 
73 /* $ Detailed_Input */
74 
75 /*     STRING      is any string. */
76 
77 /* $ Detailed_Output */
78 
79 /*     If the input string contains an integer (as defined in */
80 /*     $Particulars below), the function returns TRUE. Otherwise, */
81 /*     the function returns FALSE. */
82 
83 /* $ Parameters */
84 
85 /*     None. */
86 
87 /* $ Exceptions */
88 
89 /*     Error free. */
90 
91 /* $ Files */
92 
93 /*     None. */
94 
95 /* $ Particulars */
96 
97 /*      An integer may be either of the following: */
98 
99 /*         1) An unsigned integer (as defined by function BEUNS). */
100 
101 /*         2) A sign ('+' or '-') followed by an unsigned */
102 /*            integer. */
103 
104 /* $ Examples */
105 
106 /*     Four classes of numbers recognized by the various BE functions. */
107 
108 /*        UNS      unsigned integer */
109 /*        INT      integer                (includes INT) */
110 /*        DEC      decimal number         (includes UNS, INT) */
111 /*        NUM      number                 (includes UNS, INT, NUM) */
112 
113 /*     The following table illustrates the differences between */
114 /*     the classes. (Any number of leading and trailing blanks */
115 /*     are acceptable.) */
116 
117 /*        String                  Accepted by */
118 /*        ------------------      ------------------ */
119 /*        0                       UNS, INT, DEC, NUM */
120 /*        21 */
121 /*        21994217453648 */
122 
123 /*        +0                      INT, DEC, NUM */
124 /*        -13 */
125 /*        +21946 */
126 
127 /*        1.23                    DEC, NUM */
128 /*        12. */
129 /*        .17 */
130 /*        +4.1 */
131 /*        -.25 */
132 
133 /*        2.3e17                  NUM */
134 /*        17.D-13275849 */
135 /*        -.194265E+0004 */
136 
137 /*     Note that the functions don't take the magnitudes of the numbers */
138 /*     into account. They may accept numbers that cannot be represented */
139 /*     in Fortran variables. (For example, '2.19E999999999999' probably */
140 /*     exceeds the maximum floating point number on any machine, but */
141 /*     is perfectly acceptable to BENUM.) */
142 
143 /*     The following strings are not accepted by any of the functions. */
144 
145 /*        String             Reason */
146 /*        ---------------    ---------------------------------------- */
147 /*        3/4                No implied operations (rational numbers) */
148 /*        37+14              No explicit operations */
149 /*        E12                Must have mantissa */
150 /*        217,346.91         No commas */
151 /*        3.14 159 264       No embedded spaces */
152 /*        PI                 No special numbers */
153 /*        FIVE               No textual numbers */
154 /*        CXIV               No roman numerals */
155 
156 /* $ Restrictions */
157 
158 /*     None. */
159 
160 /* $ Literature_References */
161 
162 /*     None. */
163 
164 /* $ Author_and_Institution */
165 
166 /*     W.L. Taber     (JPL) */
167 
168 /* $ Version */
169 
170 /* -    SPICELIB Version 1.0.0, 01-DEC-1995 (WLT) */
171 
172 /* -& */
173 /* $ Index_Entries */
174 
175 /*     determine if a string is an integer */
176 
177 /* -& */
178 
179 /*     Find the first non-blank character and the length of the */
180 /*     string. */
181 
182     l = i_len(string, string_len);
183     i__ = frstnb_(string, string_len);
184 
185 /*     If there isn't a non-blank character, this isn't an */
186 /*     integer. */
187 
188     if (i__ == 0) {
189 	ret_val = FALSE_;
190 	return ret_val;
191     }
192 
193 /*     Copy the first non-blank letter in the string. */
194 
195     *(unsigned char *)letter = *(unsigned char *)&string[i__ - 1];
196     if (i__ < l) {
197 
198 /*        The first character is not the last, so we might start with */
199 /*        a plus or minus.  If so the rest must be an unsigned integer. */
200 
201 	if (*(unsigned char *)letter == '+' || *(unsigned char *)letter ==
202 		'-') {
203 	    ++i__;
204 	    if (*(unsigned char *)&string[i__ - 1] != ' ') {
205 		ret_val = beuns_(string + (i__ - 1), string_len - (i__ - 1));
206 	    } else {
207 		ret_val = FALSE_;
208 	    }
209 	} else {
210 
211 /*           If the first character isn't plus (+) or minus (-) */
212 /*           the string must be an unsigned integer if its going */
213 /*           to be an integer. */
214 
215 	    ret_val = beuns_(string + (i__ - 1), string_len - (i__ - 1));
216 	}
217     } else {
218 
219 /*        If the first (non-blank) character is the last one, then */
220 /*        it must be an unsigned integer, for the string to */
221 /*        represent an integer. */
222 
223 	ret_val = beuns_(letter, (ftnlen)1);
224     }
225     return ret_val;
226 } /* beint_ */
227 
228