authorgravatar for shawn@git.icuShawn Landden <shawn@git.icu> 2019-03-22 14:35:24-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-26 12:00:55-04:00
log51be449a57010a27382cb8104740b34f7863876b
treef5f04ba93270a3f330cd3ff3c0a6a0f41759ecf5
parent1d09cdaa6a79e0f0baa24d95c7fa992829cd455f

std.ascii: respond to review

This won't generate as much mode in debug mode, as it doesn't check for overflow.

1 files changed, 3 insertions(+), 7 deletions(-)

std/ascii.zig+3-7
...@@ -154,12 +154,8 @@ pub fn isAlpha(c: u8) bool {...@@ -154,12 +154,8 @@ pub fn isAlpha(c: u8) bool {
154 return inTable(c, tIndex.Alpha);154 return inTable(c, tIndex.Alpha);
155}155}
156156
157pub fn isCtrl(c: u8) bool {
158 return c < 0x20 or c == 127; //DEL
159}
160
161pub fn isCntrl(c: u8) bool {157pub fn isCntrl(c: u8) bool {
162 return isCtrl(c);158 return c < 0x20 or c == 127; //DEL
163}159}
164160
165pub fn isDigit(c: u8) bool {161pub fn isDigit(c: u8) bool {
...@@ -204,7 +200,7 @@ pub fn isBlank(c: u8) bool {...@@ -204,7 +200,7 @@ pub fn isBlank(c: u8) bool {
204200
205pub fn toUpper(c: u8) u8 {201pub fn toUpper(c: u8) u8 {
206 if (isLower(c)) {202 if (isLower(c)) {
207 return c - 0x20;203 return c | ~0b00100000;
208 } else {204 } else {
209 return c;205 return c;
210 }206 }
...@@ -212,7 +208,7 @@ pub fn toUpper(c: u8) u8 {...@@ -212,7 +208,7 @@ pub fn toUpper(c: u8) u8 {
212208
213pub fn toLower(c: u8) u8 {209pub fn toLower(c: u8) u8 {
214 if (isUpper(c)) {210 if (isUpper(c)) {
215 return c + 0x20;211 return c & 0b00100000;
216 } else {212 } else {
217 return c;213 return c;
218 }214 }