aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-04-19 11:39:12 +0100
committergingerBill <bill@gingerbill.org>2019-04-19 11:39:12 +0100
commit0755dfbd5d19f2634fa31dcb9416dfcf04b78c94 (patch)
tree3b8b6444526ff152b3faa020dc6b926bb0fde9d1
parent2780f82f303561535031cb696394498bde4cdbd4 (diff)
parent5dcb5c2ba34f05acf11dda065ff29e23fec5b86c (diff)
Merge branch 'master' of https://github.com/odin-lang/Odin
-rw-r--r--core/encoding/json/tokenizer.odin42
-rw-r--r--core/encoding/json/types.odin2
-rw-r--r--core/sys/win32/helpers.odin29
3 files changed, 51 insertions, 22 deletions
diff --git a/core/encoding/json/tokenizer.odin b/core/encoding/json/tokenizer.odin
index dd1704ba7..48cbb22c0 100644
--- a/core/encoding/json/tokenizer.odin
+++ b/core/encoding/json/tokenizer.odin
@@ -68,12 +68,12 @@ next_rune :: proc(t: ^Tokenizer) -> rune #no_bounds_check {
get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
skip_digits :: proc(t: ^Tokenizer) {
for t.offset < len(t.data) {
- next_rune(t);
if '0' <= t.r && t.r <= '9' {
// Okay
} else {
return;
}
+ next_rune(t);
}
}
skip_hex_digits :: proc(t: ^Tokenizer) {
@@ -158,6 +158,7 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
skip_whitespace(t);
token.pos = t.pos;
+
token.kind = Kind.Invalid;
curr_rune := t.r;
@@ -213,23 +214,6 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
}
fallthrough;
- case '.':
- err = Error.Illegal_Character;
- if t.spec == Specification.JSON5 { // Allow leading decimal point
- skip_digits(t);
- if t.r == 'e' || t.r == 'E' {
- switch r := next_rune(t); r {
- case '+', '-':
- next_rune(t);
- }
- skip_digits(t);
- }
- str := string(t.data[token.offset:t.offset]);
- if !is_valid_number(str, t.spec) {
- err = Error.Invalid_Number;
- }
- }
-
case '0'..'9':
token.kind = Kind.Integer;
if t.spec == Specification.JSON5 { // Hexadecimal Numbers
@@ -241,6 +225,7 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
}
skip_digits(t);
+
if t.r == '.' {
token.kind = Kind.Float;
next_rune(t);
@@ -259,6 +244,23 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
err = Error.Invalid_Number;
}
+ case '.':
+ err = Error.Illegal_Character;
+ if t.spec == Specification.JSON5 { // Allow leading decimal point
+ skip_digits(t);
+ if t.r == 'e' || t.r == 'E' {
+ switch r := next_rune(t); r {
+ case '+', '-':
+ next_rune(t);
+ }
+ skip_digits(t);
+ }
+ str := string(t.data[token.offset:t.offset]);
+ if !is_valid_number(str, t.spec) {
+ err = Error.Invalid_Number;
+ }
+ }
+
case '\'':
err = Error.Illegal_Character;
@@ -436,8 +438,8 @@ is_valid_string_literal :: proc(s: string, spec: Specification) -> bool {
i += 5;
for j := 0; j < 4; j += 1 {
- c := hex[j];
- switch c {
+ c2 := hex[j];
+ switch c2 {
case '0'..'9', 'a'..'z', 'A'..'Z':
// Okay
case:
diff --git a/core/encoding/json/types.odin b/core/encoding/json/types.odin
index 6973d3dc5..036fe50b4 100644
--- a/core/encoding/json/types.odin
+++ b/core/encoding/json/types.odin
@@ -1,7 +1,5 @@
package json
-import "core:strconv"
-
Specification :: enum {
JSON,
JSON5,
diff --git a/core/sys/win32/helpers.odin b/core/sys/win32/helpers.odin
new file mode 100644
index 000000000..fd8b7c3c5
--- /dev/null
+++ b/core/sys/win32/helpers.odin
@@ -0,0 +1,29 @@
+// +build windows
+package win32
+
+import "core:strings";
+
+call_external_process :: proc(program, command_line: string) -> bool {
+ si := Startup_Info{ cb=size_of(Startup_Info) };
+ pi := Process_Information{};
+
+ return cast(bool)create_process_w(
+ utf8_to_wstring(program),
+ utf8_to_wstring(command_line),
+ nil,
+ nil,
+ Bool(false),
+ u32(0x10),
+ nil,
+ nil,
+ &si,
+ &pi
+ );
+}
+
+open_website :: proc(url: string) -> bool {
+ p :: "C:\\Windows\\System32\\cmd.exe";
+ arg := []string{"/C", "start", url};
+ args := strings.join(arg, " ", context.temp_allocator);
+ return call_external_process(p, args);
+} \ No newline at end of file