@@ -68,18 +68,14 @@ module stdlib_ascii
68
68
! > Checks whether `c` is an ASCII letter (A .. Z, a .. z).
69
69
pure logical function is_alpha(c)
70
70
character (len= 1 ), intent (in ) :: c ! ! The character to test.
71
- integer :: ic
72
- ic = iachar (c)
73
- is_alpha = (ic >= iachar (' A' ) .and. ic <= iachar (' Z' )) .or. (ic >= iachar (' a' ) .and. ic <= iachar (' z' ))
71
+ is_alpha = (c >= ' A' .and. c <= ' Z' ) .or. (c >= ' a' .and. c <= ' z' )
74
72
end function
75
73
76
74
! > Checks whether `c` is a letter or a number (0 .. 9, a .. z, A .. Z).
77
75
pure logical function is_alphanum(c)
78
76
character (len= 1 ), intent (in ) :: c ! ! The character to test.
79
- integer :: ic
80
- ic = iachar (c)
81
- is_alphanum = (ic >= iachar (' 0' ) .and. ic <= iachar (' 9' )) .or. (ic >= iachar (' a' ) .and. ic <= iachar (' z' )) &
82
- .or. (ic >= iachar (' A' ) .and. ic <= iachar (' Z' ))
77
+ is_alphanum = (c >= ' 0' .and. c <= ' 9' ) .or. (c >= ' a' .and. c <= ' z' ) &
78
+ .or. (c >= ' A' .and. c <= ' Z' )
83
79
end function
84
80
85
81
! > Checks whether or not `c` is in the ASCII character set -
@@ -100,26 +96,20 @@ pure logical function is_control(c)
100
96
! > Checks whether `c` is a digit (0 .. 9).
101
97
pure logical function is_digit(c)
102
98
character (len= 1 ), intent (in ) :: c ! ! The character to test.
103
- integer :: ic
104
- ic = iachar (c)
105
- is_digit = (iachar (' 0' ) <= ic) .and. (ic <= iachar (' 9' ))
99
+ is_digit = (' 0' <= c) .and. (c <= ' 9' )
106
100
end function
107
101
108
102
! > Checks whether `c` is a digit in base 8 (0 .. 7).
109
103
pure logical function is_octal_digit(c)
110
104
character (len= 1 ), intent (in ) :: c ! ! The character to test.
111
- integer :: ic
112
- ic = iachar (c)
113
- is_octal_digit = (ic >= iachar (' 0' )) .and. (ic <= iachar (' 7' ))
105
+ is_octal_digit = (c >= ' 0' ) .and. (c <= ' 7' );
114
106
end function
115
107
116
108
! > Checks whether `c` is a digit in base 16 (0 .. 9, A .. F, a .. f).
117
109
pure logical function is_hex_digit(c)
118
110
character (len= 1 ), intent (in ) :: c ! ! The character to test.
119
- integer :: ic
120
- ic = iachar (c)
121
- is_hex_digit = (ic >= iachar (' 0' ) .and. ic <= iachar (' 9' )) .or. (ic >= iachar (' a' ) .and. ic <= iachar (' f' )) &
122
- .or. (ic >= iachar (' A' ) .and. ic <= iachar (' F' )) .or. (ic >= iachar (' a' ) .and. ic <= iachar (' f' ))
111
+ is_hex_digit = (c >= ' 0' .and. c <= ' 9' ) .or. (c >= ' a' .and. c <= ' f' ) &
112
+ .or. (c >= ' A' .and. c <= ' F' )
123
113
end function
124
114
125
115
! > Checks whether or not `c` is a punctuation character. That includes
@@ -165,9 +155,7 @@ pure logical function is_lower(c)
165
155
! > Checks whether `c` is an uppercase ASCII letter (A .. Z).
166
156
pure logical function is_upper(c)
167
157
character (len= 1 ), intent (in ) :: c ! ! The character to test.
168
- integer :: ic
169
- ic = iachar (c)
170
- is_upper = ic >= iachar (' A' ) .and. ic <= iachar (' Z' )
158
+ is_upper = (c >= ' A' ) .and. (c <= ' Z' )
171
159
end function
172
160
173
161
! > Checks whether or not `c` is a whitespace character. That includes the
@@ -177,7 +165,7 @@ pure logical function is_white(c)
177
165
character (len= 1 ), intent (in ) :: c ! ! The character to test.
178
166
integer :: ic
179
167
ic = iachar (c) ! TAB, LF, VT, FF, CR
180
- is_white = ic == iachar ( ' ' ) .or. (ic >= int (z' 09' ) .and. ic <= int (z' 0D' ))
168
+ is_white = (c == ' ' ) .or. (ic >= int (z' 09' ) .and. ic <= int (z' 0D' ));
181
169
end function
182
170
183
171
! > Checks whether or not `c` is a blank character. That includes the
@@ -186,7 +174,7 @@ pure logical function is_blank(c)
186
174
character (len= 1 ), intent (in ) :: c ! ! The character to test.
187
175
integer :: ic
188
176
ic = iachar (c) ! TAB
189
- is_blank = ic == iachar ( ' ' ) .or. ic == int (z' 09' )
177
+ is_blank = (c == ' ' ) .or. ( ic == int (z' 09' ));
190
178
end function
191
179
192
180
! > Returns the corresponding lowercase letter, if `c` is an uppercase
0 commit comments