1 /* frstnb.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            FRSTNB ( First non-blank character ) */
frstnb_(char * string,ftnlen string_len)9 integer frstnb_(char *string, ftnlen string_len)
10 {
11     /* System generated locals */
12     integer ret_val, i__1;
13 
14     /* Builtin functions */
15     integer s_cmp(char *, char *, ftnlen, ftnlen), i_len(char *, ftnlen);
16 
17     /* Local variables */
18     integer i__;
19 
20 /* $ Abstract */
21 
22 /*      Return the index of the first non-blank character in */
23 /*      a character string. */
24 
25 /* $ Disclaimer */
26 
27 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
28 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
29 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
30 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
31 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
32 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
33 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
34 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
35 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
36 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
37 
38 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
39 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
40 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
41 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
42 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
43 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
44 
45 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
46 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
47 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
48 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
49 
50 /* $ Required_Reading */
51 
52 /*     None. */
53 
54 /* $ Keywords */
55 
56 /*      ASCII,  CHARACTER,  SEARCH */
57 
58 /* $ Declarations */
59 /* $ Brief_I/O */
60 
61 /*      VARIABLE  I/O  DESCRIPTION */
62 /*      --------  ---  -------------------------------------------------- */
63 /*      STRING     I   Input character string. */
64 /*      FRSTNB     O   Index of the first non-blank character in STRING. */
65 
66 /* $ Detailed_Input */
67 
68 /*      STRING      is the input character string. */
69 
70 /* $ Detailed_Output */
71 
72 /*      FRSTNB      is the index if the first non-blank character */
73 /*                  in the input string. If there are no non-blank */
74 /*                  characters in the string, FRSTNB is zero. */
75 
76 /* $ Parameters */
77 
78 /*     None. */
79 
80 /* $ Particulars */
81 
82 /*      If the string is blank, return zero. Otherwise, step through */
83 /*      the string one character at a time until something other than */
84 /*      a blank is found. Return the index of that something within */
85 /*      the string. */
86 
87 /* $ Examples */
88 
89 /*      The following examples illustrate the use of FRSTNB. */
90 
91 /*            FRSTNB ( 'ABCDE'         )   = 1 */
92 /*            FRSTNB ( 'AN EXAMPLE'    )   = 1 */
93 /*            FRSTNB ( '   AN EXAMPLE' )   = 4 */
94 /*            FRSTNB ( '             ' )   = 0 */
95 
96 /* $ Restrictions */
97 
98 /*      None. */
99 
100 /* $ Exceptions */
101 
102 /*      Error free. */
103 
104 /* $ Files */
105 
106 /*      None. */
107 
108 /* $ Author_and_Institution */
109 
110 /*      K.R. Gehringer  (JPL) */
111 /*      I.M. Underwood  (JPL) */
112 
113 /* $ Literature_References */
114 
115 /*      None. */
116 
117 /* $ Version */
118 
119 /* -     SPICELIB Version 2.0.0, 12-MAR-1996 (KRG) */
120 
121 /*         Modified the comparison to use integer values and the ICHAR() */
122 /*         function. This improves the performance of the subroutine. */
123 
124 /* -     SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
125 
126 /*         Comment section for permuted index source lines was added */
127 /*         following the header. */
128 
129 /* -     SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */
130 
131 /* -& */
132 /* $ Index_Entries */
133 
134 /*     first non-blank character */
135 
136 /* -& */
137 
138 /*     Local parameters */
139 
140 
141 /*     Local variables */
142 
143 
144 /*     Just like it says in the header. */
145 
146     if (s_cmp(string, " ", string_len, (ftnlen)1) == 0) {
147 	ret_val = 0;
148     } else {
149 	i__1 = i_len(string, string_len);
150 	for (i__ = 1; i__ <= i__1; ++i__) {
151 	    if (*(unsigned char *)&string[i__ - 1] != 32) {
152 		ret_val = i__;
153 		return ret_val;
154 	    }
155 	}
156     }
157     return ret_val;
158 } /* frstnb_ */
159 
160