Commit c393a399fb

Andrew Kelley <superjoe30@gmail.com>
2018-07-18 16:51:18
fix invalid character test on windows
1 parent cd488c9
Changed files (1)
src/tokenizer.cpp
@@ -460,16 +460,21 @@ static const char* get_escape_shorthand(uint8_t c) {
 static void invalid_char_error(Tokenize *t, uint8_t c) {
     if (c == '\r') {
         tokenize_error(t, "invalid carriage return, only '\\n' line endings are supported");
-    } else if (isprint(c)) {
+        return;
+    }
+
+    const char *sh = get_escape_shorthand(c);
+    if (sh) {
+        tokenize_error(t, "invalid character: '%s'", sh);
+        return;
+    }
+
+    if (isprint(c)) {
         tokenize_error(t, "invalid character: '%c'", c);
-    } else {
-        const char *sh = get_escape_shorthand(c);
-        if (sh) {
-            tokenize_error(t, "invalid character: '%s'", sh);
-        } else {
-            tokenize_error(t, "invalid character: '\\x%x'", c);
-        }
+        return;
     }
+
+    tokenize_error(t, "invalid character: '\\x%02x'", c);
 }
 
 void tokenize(Buf *buf, Tokenization *out) {