| ... | @@ -55,10 +55,10 @@ comptime { | ... | @@ -55,10 +55,10 @@ comptime { |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | | 57 | |
| 58 | // NOTE: If the input is not representable as an unsigned char or is not EOF the behaviour is undefined. | 58 | // NOTE: If the input is not representable as an unsigned char or is not EOF (which is a negative integer value) the behaviour is undefined. |
| 59 | | 59 | |
| 60 | fn isalnum(c: c_int) callconv(.c) c_int { | 60 | fn isalnum(c: c_int) callconv(.c) c_int { |
| 61 | return @intFromBool(std.ascii.isAlphanumeric(@intCast(c))); | 61 | return @intFromBool(std.ascii.isAlphanumeric(@truncate(@as(c_uint, @bitCast(c))))); // @truncate instead of @intCast as we have to handle EOF |
| 62 | } | 62 | } |
| 63 | | 63 | |
| 64 | fn __isalnum_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 64 | fn __isalnum_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -67,7 +67,7 @@ fn __isalnum_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -67,7 +67,7 @@ fn __isalnum_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 67 | } | 67 | } |
| 68 | | 68 | |
| 69 | fn isalpha(c: c_int) callconv(.c) c_int { | 69 | fn isalpha(c: c_int) callconv(.c) c_int { |
| 70 | return @intFromBool(std.ascii.isAlphabetic(@intCast(c))); | 70 | return @intFromBool(std.ascii.isAlphabetic(@truncate(@as(c_uint, @bitCast(c))))); |
| 71 | } | 71 | } |
| 72 | | 72 | |
| 73 | fn __isalpha_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 73 | fn __isalpha_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -85,7 +85,7 @@ fn __isblank_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -85,7 +85,7 @@ fn __isblank_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 85 | } | 85 | } |
| 86 | | 86 | |
| 87 | fn iscntrl(c: c_int) callconv(.c) c_int { | 87 | fn iscntrl(c: c_int) callconv(.c) c_int { |
| 88 | return @intFromBool(std.ascii.isControl(@intCast(c))); | 88 | return @intFromBool(std.ascii.isControl(@truncate(@as(c_uint, @bitCast(c))))); |
| 89 | } | 89 | } |
| 90 | | 90 | |
| 91 | fn __iscntrl_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 91 | fn __iscntrl_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -94,7 +94,7 @@ fn __iscntrl_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -94,7 +94,7 @@ fn __iscntrl_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 94 | } | 94 | } |
| 95 | | 95 | |
| 96 | fn isdigit(c: c_int) callconv(.c) c_int { | 96 | fn isdigit(c: c_int) callconv(.c) c_int { |
| 97 | return @intFromBool(std.ascii.isDigit(@intCast(c))); | 97 | return @intFromBool(std.ascii.isDigit(@truncate(@as(c_uint, @bitCast(c))))); |
| 98 | } | 98 | } |
| 99 | | 99 | |
| 100 | fn __isdigit_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 100 | fn __isdigit_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -103,7 +103,7 @@ fn __isdigit_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -103,7 +103,7 @@ fn __isdigit_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 103 | } | 103 | } |
| 104 | | 104 | |
| 105 | fn isgraph(c: c_int) callconv(.c) c_int { | 105 | fn isgraph(c: c_int) callconv(.c) c_int { |
| 106 | return @intFromBool(std.ascii.isGraphical(@intCast(c))); | 106 | return @intFromBool(std.ascii.isGraphical(@truncate(@as(c_uint, @bitCast(c))))); |
| 107 | } | 107 | } |
| 108 | | 108 | |
| 109 | fn __isgraph_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 109 | fn __isgraph_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -112,7 +112,7 @@ fn __isgraph_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -112,7 +112,7 @@ fn __isgraph_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 112 | } | 112 | } |
| 113 | | 113 | |
| 114 | fn islower(c: c_int) callconv(.c) c_int { | 114 | fn islower(c: c_int) callconv(.c) c_int { |
| 115 | return @intFromBool(std.ascii.isLower(@intCast(c))); | 115 | return @intFromBool(std.ascii.isLower(@truncate(@as(c_uint, @bitCast(c))))); |
| 116 | } | 116 | } |
| 117 | | 117 | |
| 118 | fn __islower_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 118 | fn __islower_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -121,7 +121,7 @@ fn __islower_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -121,7 +121,7 @@ fn __islower_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 121 | } | 121 | } |
| 122 | | 122 | |
| 123 | fn isprint(c: c_int) callconv(.c) c_int { | 123 | fn isprint(c: c_int) callconv(.c) c_int { |
| 124 | return @intFromBool(std.ascii.isPrint(@intCast(c))); | 124 | return @intFromBool(std.ascii.isPrint(@truncate(@as(c_uint, @bitCast(c))))); |
| 125 | } | 125 | } |
| 126 | | 126 | |
| 127 | fn __isprint_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 127 | fn __isprint_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -130,7 +130,7 @@ fn __isprint_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -130,7 +130,7 @@ fn __isprint_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 130 | } | 130 | } |
| 131 | | 131 | |
| 132 | fn ispunct(c: c_int) callconv(.c) c_int { | 132 | fn ispunct(c: c_int) callconv(.c) c_int { |
| 133 | return @intFromBool(std.ascii.isPunctuation(@intCast(c))); | 133 | return @intFromBool(std.ascii.isPunctuation(@truncate(@as(c_uint, @bitCast(c))))); |
| 134 | } | 134 | } |
| 135 | | 135 | |
| 136 | fn __ispunct_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 136 | fn __ispunct_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -139,7 +139,7 @@ fn __ispunct_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -139,7 +139,7 @@ fn __ispunct_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 139 | } | 139 | } |
| 140 | | 140 | |
| 141 | fn isspace(c: c_int) callconv(.c) c_int { | 141 | fn isspace(c: c_int) callconv(.c) c_int { |
| 142 | return @intFromBool(std.ascii.isWhitespace(@intCast(c))); | 142 | return @intFromBool(std.ascii.isWhitespace(@truncate(@as(c_uint, @bitCast(c))))); |
| 143 | } | 143 | } |
| 144 | | 144 | |
| 145 | fn __isspace_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 145 | fn __isspace_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -148,7 +148,7 @@ fn __isspace_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -148,7 +148,7 @@ fn __isspace_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 148 | } | 148 | } |
| 149 | | 149 | |
| 150 | fn isupper(c: c_int) callconv(.c) c_int { | 150 | fn isupper(c: c_int) callconv(.c) c_int { |
| 151 | return @intFromBool(std.ascii.isUpper(@intCast(c))); | 151 | return @intFromBool(std.ascii.isUpper(@truncate(@as(c_uint, @bitCast(c))))); |
| 152 | } | 152 | } |
| 153 | | 153 | |
| 154 | fn __isupper_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 154 | fn __isupper_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -157,7 +157,7 @@ fn __isupper_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -157,7 +157,7 @@ fn __isupper_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 157 | } | 157 | } |
| 158 | | 158 | |
| 159 | fn isxdigit(c: c_int) callconv(.c) c_int { | 159 | fn isxdigit(c: c_int) callconv(.c) c_int { |
| 160 | return @intFromBool(std.ascii.isHex(@intCast(c))); | 160 | return @intFromBool(std.ascii.isHex(@truncate(@as(c_uint, @bitCast(c))))); |
| 161 | } | 161 | } |
| 162 | | 162 | |
| 163 | fn __isxdigit_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 163 | fn __isxdigit_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -166,7 +166,7 @@ fn __isxdigit_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -166,7 +166,7 @@ fn __isxdigit_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 166 | } | 166 | } |
| 167 | | 167 | |
| 168 | fn tolower(c: c_int) callconv(.c) c_int { | 168 | fn tolower(c: c_int) callconv(.c) c_int { |
| 169 | return std.ascii.toLower(@intCast(c)); | 169 | return std.ascii.toLower(@truncate(@as(c_uint, @bitCast(c)))); |
| 170 | } | 170 | } |
| 171 | | 171 | |
| 172 | fn __tolower_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 172 | fn __tolower_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -175,7 +175,7 @@ fn __tolower_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -175,7 +175,7 @@ fn __tolower_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 175 | } | 175 | } |
| 176 | | 176 | |
| 177 | fn toupper(c: c_int) callconv(.c) c_int { | 177 | fn toupper(c: c_int) callconv(.c) c_int { |
| 178 | return std.ascii.toUpper(@intCast(c)); | 178 | return std.ascii.toUpper(@truncate(@as(c_uint, @bitCast(c)))); |
| 179 | } | 179 | } |
| 180 | | 180 | |
| 181 | fn __toupper_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | 181 | fn __toupper_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| ... | @@ -184,7 +184,7 @@ fn __toupper_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { | ... | @@ -184,7 +184,7 @@ fn __toupper_l(c: c_int, locale: *anyopaque) callconv(.c) c_int { |
| 184 | } | 184 | } |
| 185 | | 185 | |
| 186 | fn isascii(c: c_int) callconv(.c) c_int { | 186 | fn isascii(c: c_int) callconv(.c) c_int { |
| 187 | return @intFromBool(std.ascii.isAscii(@intCast(c))); | 187 | return @intFromBool(std.ascii.isAscii(@truncate(@as(c_uint, @bitCast(c))))); |
| 188 | } | 188 | } |
| 189 | | 189 | |
| 190 | fn toascii(c: c_int) callconv(.c) c_int { | 190 | fn toascii(c: c_int) callconv(.c) c_int { |