]> git.mxchange.org Git - simgear.git/blob - simgear/metar/Stspack2.cpp
#includes based off of srcdir rather than builddir.
[simgear.git] / simgear / metar / Stspack2.cpp
1 #pragma comment (compiler)
2 //#pragma comment (date)
3 //#pragma comment (timestamp)
4 #pragma pagesize(80)
5  
6 #include "Local.h"     /* standard header file */
7  
8 #pragma page(1)
9 #pragma subtitle(" ")
10 #pragma subtitle("stspack2 - Local string test functions       ")
11 /********************************************************************/
12 /*                                                                  */
13 /*  Title:         stspack2                                         */
14 /*  Organization:  W/OSO242 - GRAPHICS AND DISPLAY SECTION          */
15 /*  Date:          05 Oct 1992                                      */
16 /*  Programmer:    ALLAN DARLING                                    */
17 /*  Language:      C/2                                              */
18 /*                                                                  */
19 /*  Abstract:      The stspack2 package contains functions to       */
20 /*                 perform the isalnum through isxdigit functions   */
21 /*                 on strings.  The functions come in four forms:   */
22 /*                 those that test NULL delimited strings and are   */
23 /*                 named in the form sxxxxxxx, those that test at   */
24 /*                 most n characters and are named in the form      */
25 /*                 nxxxxxxx, those that search forward in a string  */
26 /*                 and are named in the form nxtyyyyy, and those    */
27 /*                 that search backward in a string and are named   */
28 /*                 in the form lstyyyyy.                            */
29 /*                                                                  */
30 /*                 The xxxxxxx is the name of the test applied to   */
31 /*                 each character in the string, such as isalpha,   */
32 /*                 thus a function to test a NULL delimited string  */
33 /*                 an return a nonzero value if all characters in   */
34 /*                 the string are digits is named sisdigit.         */
35 /*                                                                  */
36 /*                 The yyyyy is the name of the test applied to     */
37 /*                 characters in a string, minus the 'is' prefix.   */
38 /*                 Thus a function to find the next digit in a NULL */
39 /*                 delimited string and return a pointer to it is   */
40 /*                 named nxtdigit.                                  */
41 /*                                                                  */
42 /*                 The only exception to the naming rule is for the */
43 /*                 functions that test for hexadecimal digits.      */
44 /*                 These are named sisxdigi, nisxdigi, nxtxdigi,    */
45 /*                 and lstxdigi because of the eight character      */
46 /*                 function name limitation.                        */
47 /*                                                                  */
48 /*                 The nxxxxxxx class of functions will test up to  */
49 /*                 n characters or the first NULL character         */
50 /*                 encountered, whichever comes first.  For all     */
51 /*                 classes of functions, the string sentinal is     */
52 /*                 not included in the test.                        */
53 /*                                                                  */
54 /*  External Functions Called:                                      */
55 /*                 isalnum, isalpha, iscntrl, isdigit, isgraph,     */
56 /*                 islower, isprint, ispunct, isspace, isupper,     */
57 /*                 isxdigit.                                        */
58 /*                                                                  */
59 /*  Input:         For sxxxxxxx class functions, a pointer to a     */
60 /*                 NULL delimited character string.                 */
61 /*                                                                  */
62 /*                 For nxtyyyyy class functions, a pointer to a     */
63 /*                 NULL delimited character string.                 */
64 /*                                                                  */
65 /*                 for nxxxxxxx class functions, a pointer to a     */
66 /*                 character array, and a positive, nonzero integer.*/
67 /*                                                                  */
68 /*                 for lstyyyyy class functions, a pointer to a     */
69 /*                 character array, and a positive, nonzero integer.*/
70 /*                                                                  */
71 /*  Output:        A nonzero value if the test is true for all      */
72 /*                 characters in the string, a zero value otherwise.*/
73 /*                                                                  */
74 /*  Modification History:                                           */
75 /*                 None.                                            */
76 /*                                                                  */
77 /********************************************************************/
78 #pragma page(1)
79  
80 int nisalnum(char *s, int n) {
81  
82    for (; *s && n; s++, n--)
83  
84       if (!isalnum(*s))
85          return (0);
86  
87    return (1);
88  
89 } /* end nisalnum */
90  
91  
92 int nisalpha(char *s, int n) {
93  
94    for (; *s && n; s++, n--)
95  
96       if (!isalpha(*s))
97          return (0);
98  
99    return (1);
100  
101 } /* end nisalpha */
102  
103  
104 int niscntrl(char *s, int n) {
105  
106    for (; *s && n; s++, n--)
107  
108       if (!iscntrl(*s))
109          return (0);
110  
111    return (1);
112  
113 } /* end niscntrl */
114  
115  
116 int nisdigit(char *s, int n) {
117  
118    for (; *s && n; s++, n--)
119  
120       if (!isdigit(*s))
121          return (0);
122  
123    return (1);
124  
125 } /* end nisdigit */
126  
127  
128 int nisgraph(char *s, int n) {
129  
130    for (; *s && n; s++, n--)
131  
132       if (!isgraph(*s))
133          return (0);
134  
135    return (1);
136  
137 } /* end nisgraph */
138  
139  
140 int nislower(char *s, int n) {
141  
142    for (; *s && n; s++, n--)
143  
144       if (!islower(*s))
145          return (0);
146  
147    return (1);
148  
149 } /* end nislower */
150  
151  
152 int nisprint(char *s, int n) {
153  
154    for (; *s && n; s++, n--)
155  
156       if (!isprint(*s))
157          return (0);
158  
159    return (1);
160  
161 } /* end nisprint */
162  
163  
164 int nispunct(char *s, int n) {
165  
166    for (; *s && n; s++, n--)
167  
168       if (!ispunct(*s))
169          return (0);
170  
171    return (1);
172  
173 } /* end nispunct */
174  
175  
176 int nisspace(char *s, int n) {
177  
178    for (; *s && n; s++, n--)
179  
180       if (!isspace(*s))
181          return (0);
182  
183    return (1);
184  
185 } /* end nisspace */
186  
187  
188 int nisupper(char *s, int n) {
189  
190    for (; *s && n; s++, n--)
191  
192       if (!isupper(*s))
193          return (0);
194  
195    return (1);
196  
197 } /* end nisupper */
198  
199  
200 int nisxdigi(char *s, int n) {
201  
202    for (; *s && n; s++, n--)
203  
204       if (!isxdigit(*s))
205          return (0);
206  
207    return (1);
208  
209 } /* end nisxdigi */
210  
211 #pragma page(1)