@@ -65,18 +65,14 @@ module stdlib_ascii
65
65
! > Checks whether `c` is an ASCII letter (A .. Z, a .. z).
66
66
pure logical function is_alpha(c)
67
67
character (len= 1 ), intent (in ) :: c ! ! The character to test.
68
- integer :: ic
69
- ic = iachar (c)
70
- is_alpha = (ic >= iachar (' A' ) .and. ic <= iachar (' Z' )) .or. (ic >= iachar (' a' ) .and. ic <= iachar (' z' ))
68
+ is_alpha = (c >= ' A' .and. c <= ' Z' ) .or. (c >= ' a' .and. c <= ' z' )
71
69
end function
72
70
73
71
! > Checks whether `c` is a letter or a number (0 .. 9, a .. z, A .. Z).
74
72
pure logical function is_alphanum(c)
75
73
character (len= 1 ), intent (in ) :: c ! ! The character to test.
76
- integer :: ic
77
- ic = iachar (c)
78
- is_alphanum = (ic >= iachar (' 0' ) .and. ic <= iachar (' 9' )) .or. (ic >= iachar (' a' ) .and. ic <= iachar (' z' )) &
79
- .or. (ic >= iachar (' A' ) .and. ic <= iachar (' Z' ))
74
+ is_alphanum = (c >= ' 0' .and. c <= ' 9' ) .or. (c >= ' a' .and. c <= ' z' ) &
75
+ .or. (c >= ' A' .and. c <= ' Z' )
80
76
end function
81
77
82
78
! > Checks whether or not `c` is in the ASCII character set -
@@ -97,25 +93,20 @@ pure logical function is_control(c)
97
93
! > Checks whether `c` is a digit (0 .. 9).
98
94
pure logical function is_digit(c)
99
95
character (len= 1 ), intent (in ) :: c ! ! The character to test.
100
- integer :: ic
101
- is_digit = (iachar (' 0' ) <= ic) .and. (ic <= iachar (' 9' ))
96
+ is_digit = (' 0' <= c) .and. (c <= ' 9' )
102
97
end function
103
98
104
99
! > Checks whether `c` is a digit in base 8 (0 .. 7).
105
100
pure logical function is_octal_digit(c)
106
101
character (len= 1 ), intent (in ) :: c ! ! The character to test.
107
- integer :: ic
108
- ic = iachar (c)
109
- is_octal_digit = (ic >= iachar (' 0' )) .and. (ic <= iachar (' 7' ))
102
+ is_octal_digit = (c >= ' 0' ) .and. (c <= ' 7' );
110
103
end function
111
104
112
105
! > Checks whether `c` is a digit in base 16 (0 .. 9, A .. F, a .. f).
113
- pure logical function is_hex_digit(cin )
106
+ pure logical function is_hex_digit(c )
114
107
character (len= 1 ), intent (in ) :: c ! ! The character to test.
115
- integer :: ic
116
- ic = iachar (c)
117
- is_hex_digit = (ic >= iachar (' 0' ) .and. ic <= iachar (' 9' )) .or. (ic >= iachar (' a' ) .and. ic <= iachar (' f' )) &
118
- .or. (ic >= iachar (' A' ) .and. ic <= iachar (' F' )) .or. (ic >= iachar (' a' ) .and. ic <= iachar (' f' ))
108
+ is_hex_digit = (c >= ' 0' .and. c <= ' 9' ) .or. (c >= ' a' .and. c <= ' f' ) &
109
+ .or. (c >= ' A' .and. c <= ' F' )
119
110
end function
120
111
121
112
! > Checks whether or not `c` is a punctuation character. That includes
@@ -148,17 +139,15 @@ pure logical function is_printable(c)
148
139
end function
149
140
150
141
! > Checks whether `c` is a lowercase ASCII letter (a .. z).
151
- pure logical function is_lower(cin )
142
+ pure logical function is_lower(c )
152
143
character (len= 1 ), intent (in ) :: c ! ! The character to test.
153
144
is_lower = (c >= ' a' ) .and. (c <= ' z' )
154
145
end function
155
146
156
147
! > Checks whether `c` is an uppercase ASCII letter (A .. Z).
157
148
pure logical function is_upper(c)
158
149
character (len= 1 ), intent (in ) :: c ! ! The character to test.
159
- integer :: ic
160
- ic = iachar (c)
161
- is_upper = (ic >= iachar (' A' )) .and. (ic <= iachar (' Z' ))
150
+ is_upper = (c >= ' A' ) .and. (c <= ' Z' )
162
151
end function
163
152
164
153
! > Checks whether or not `c` is a whitespace character. That includes the
@@ -168,7 +157,7 @@ pure logical function is_white(c)
168
157
character (len= 1 ), intent (in ) :: c ! ! The character to test.
169
158
integer :: ic
170
159
ic = iachar (c) ! TAB, LF, VT, FF, CR
171
- is_white = (ic == iachar ( ' ' ) ) .or. (ic >= int (z' 09' ) .and. ic <= int (z' 0D' ));
160
+ is_white = (c == ' ' ) .or. (ic >= int (z' 09' ) .and. ic <= int (z' 0D' ));
172
161
end function
173
162
174
163
! > Checks whether or not `c` is a blank character. That includes the
@@ -177,7 +166,7 @@ pure logical function is_blank(c)
177
166
character (len= 1 ), intent (in ) :: c ! ! The character to test.
178
167
integer :: ic
179
168
ic = iachar (c) ! TAB
180
- is_blank = (ic == iachar ( ' ' ) ) .or. (ic == int (z' 09' ));
169
+ is_blank = (c == ' ' ) .or. (ic == int (z' 09' ));
181
170
end function
182
171
183
172
! > Returns the corresponding lowercase letter, if `c` is an uppercase
0 commit comments