aboutsummaryrefslogtreecommitdiff
path: root/core/encoding
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-12-01 11:53:08 +0000
committergingerBill <gingerBill@users.noreply.github.com>2025-12-01 11:53:08 +0000
commit3771ff7b123bf1debe2da2886d833791ee890b39 (patch)
tree69cc14a85ef5cb47ede1280df76f6206aa934d00 /core/encoding
parent9f80d697027a41a9c36b8eb42d9c98f9b7fcbe2c (diff)
parente72aad983bb683858a1aee935b2956ced40f69f8 (diff)
Merge branch 'master' into vendor/curl
Diffstat (limited to 'core/encoding')
-rw-r--r--core/encoding/base64/base64.odin54
-rw-r--r--core/encoding/cbor/tags.odin32
-rw-r--r--core/encoding/entity/entity.odin2
-rw-r--r--core/encoding/json/parser.odin2
-rw-r--r--core/encoding/json/unmarshal.odin30
-rw-r--r--core/encoding/uuid/LICENSE39
-rw-r--r--core/encoding/varint/leb128.odin2
-rw-r--r--core/encoding/xml/debug_print.odin2
-rw-r--r--core/encoding/xml/helpers.odin2
-rw-r--r--core/encoding/xml/tokenizer.odin2
-rw-r--r--core/encoding/xml/xml_reader.odin2
11 files changed, 90 insertions, 79 deletions
diff --git a/core/encoding/base64/base64.odin b/core/encoding/base64/base64.odin
index 2cd7227b5..032716bde 100644
--- a/core/encoding/base64/base64.odin
+++ b/core/encoding/base64/base64.odin
@@ -26,23 +26,39 @@ ENC_TABLE := [64]byte {
PADDING :: '='
-DEC_TABLE := [128]int {
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 62, -1, -1, -1, 63,
+DEC_TABLE := [256]u8 {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 62, 0, 0, 0, 63,
52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, -1, -1, -1, -1, -1, -1,
- -1, 0, 1, 2, 3, 4, 5, 6,
+ 60, 61, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, -1, -1, -1, -1, -1,
- -1, 26, 27, 28, 29, 30, 31, 32,
+ 23, 24, 25, 0, 0, 0, 0, 0,
+ 0, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, -1, -1, -1, -1, -1,
+ 49, 50, 51, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
}
encode :: proc(data: []byte, ENC_TBL := ENC_TABLE, allocator := context.allocator) -> (encoded: string, err: mem.Allocator_Error) #optional_allocator_error {
@@ -120,10 +136,10 @@ decode_into :: proc(w: io.Writer, data: string, DEC_TBL := DEC_TABLE) -> io.Erro
i, j: int
for ; j + 3 <= length; i, j = i + 4, j + 3 {
#no_bounds_check {
- c0 = DEC_TBL[data[i]]
- c1 = DEC_TBL[data[i + 1]]
- c2 = DEC_TBL[data[i + 2]]
- c3 = DEC_TBL[data[i + 3]]
+ c0 = int(DEC_TBL[data[i]])
+ c1 = int(DEC_TBL[data[i + 1]])
+ c2 = int(DEC_TBL[data[i + 2]])
+ c3 = int(DEC_TBL[data[i + 3]])
b0 = (c0 << 2) | (c1 >> 4)
b1 = (c1 << 4) | (c2 >> 2)
@@ -140,9 +156,9 @@ decode_into :: proc(w: io.Writer, data: string, DEC_TBL := DEC_TABLE) -> io.Erro
rest := length - j
if rest > 0 {
#no_bounds_check {
- c0 = DEC_TBL[data[i]]
- c1 = DEC_TBL[data[i + 1]]
- c2 = DEC_TBL[data[i + 2]]
+ c0 = int(DEC_TBL[data[i]])
+ c1 = int(DEC_TBL[data[i + 1]])
+ c2 = int(DEC_TBL[data[i + 2]])
b0 = (c0 << 2) | (c1 >> 4)
b1 = (c1 << 4) | (c2 >> 2)
diff --git a/core/encoding/cbor/tags.odin b/core/encoding/cbor/tags.odin
index be07b926a..fa456673d 100644
--- a/core/encoding/cbor/tags.odin
+++ b/core/encoding/cbor/tags.odin
@@ -130,9 +130,9 @@ tag_time_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number, v:
case .U8, .U16, .U32, .U64, .Neg_U8, .Neg_U16, .Neg_U32, .Neg_U64:
switch &dst in v {
case time.Time:
- i: i64
- _unmarshal_any_ptr(d, &i, hdr) or_return
- dst = time.unix(i64(i), 0)
+ secs: i64
+ _unmarshal_any_ptr(d, &secs, hdr) or_return
+ dst = time.unix(i64(secs), 0)
return
case:
return _unmarshal_value(d, v, hdr)
@@ -152,19 +152,23 @@ tag_time_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number, v:
case:
maj, add := _header_split(hdr)
- if maj == .Other {
- i := _decode_tiny_u8(add) or_return
-
- switch &dst in v {
- case time.Time:
- dst = time.unix(i64(i), 0)
- case:
- if _assign_int(v, i) { return }
- }
+ secs: u8
+ #partial switch maj {
+ case .Unsigned:
+ secs = _decode_tiny_u8(add) or_return
+ case .Other:
+ secs = u8(_decode_tiny_simple(add) or_return)
+ case:
+ return .Bad_Tag_Value
}
- // Only numbers and floats are allowed in this tag.
- return .Bad_Tag_Value
+ switch &dst in v {
+ case time.Time:
+ dst = time.unix(i64(secs), 0)
+ return
+ case:
+ if _assign_int(v, secs) { return }
+ }
}
return _unsupported(v, hdr)
diff --git a/core/encoding/entity/entity.odin b/core/encoding/entity/entity.odin
index 28ff58170..e112eedf2 100644
--- a/core/encoding/entity/entity.odin
+++ b/core/encoding/entity/entity.odin
@@ -15,7 +15,7 @@ package encoding_unicode_entity
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
- Made available under Odin's BSD-3 license.
+ Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
diff --git a/core/encoding/json/parser.odin b/core/encoding/json/parser.odin
index 38f71edf6..d6c3df7c6 100644
--- a/core/encoding/json/parser.odin
+++ b/core/encoding/json/parser.odin
@@ -137,7 +137,7 @@ parse_value :: proc(p: ^Parser, loc := #caller_location) -> (value: Value, err:
case .Ident:
if p.spec == .MJSON {
advance_token(p)
- return string(token.text), nil
+ return clone_string(token.text, p.allocator, loc)
}
case .String:
diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin
index 0b65adaac..3cdc6429d 100644
--- a/core/encoding/json/unmarshal.odin
+++ b/core/encoding/json/unmarshal.odin
@@ -188,8 +188,18 @@ assign_float :: proc(val: any, f: $T) -> bool {
@(private)
-unmarshal_string_token :: proc(p: ^Parser, val: any, str: string, ti: ^reflect.Type_Info) -> (ok: bool, err: Error) {
- val := val
+unmarshal_string_token :: proc(p: ^Parser, val: any, token: Token, ti: ^reflect.Type_Info) -> (ok: bool, err: Error) {
+ str: string
+ switch {
+ case token.kind == .String:
+ str = unquote_string(token, p.spec, p.allocator) or_return
+ case:
+ str = clone_string(token.text, p.allocator) or_return
+ }
+ defer if !ok || (val.id != string && val.id != cstring) {
+ delete(str, p.allocator)
+ }
+
switch &dst in val {
case string:
dst = str
@@ -339,7 +349,7 @@ unmarshal_value :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
case .Ident:
advance_token(p)
if p.spec == .MJSON {
- if unmarshal_string_token(p, any{v.data, ti.id}, token.text, ti) or_return {
+ if unmarshal_string_token(p, any{v.data, ti.id}, token, ti) or_return {
return nil
}
}
@@ -347,18 +357,10 @@ unmarshal_value :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) {
case .String:
advance_token(p)
- str := unquote_string(token, p.spec, p.allocator) or_return
- dest := any{v.data, ti.id}
- if !(unmarshal_string_token(p, dest, str, ti) or_return) {
- delete(str, p.allocator)
- return UNSUPPORTED_TYPE
+ if unmarshal_string_token(p, any{v.data, ti.id}, token, ti) or_return {
+ return nil
}
-
- switch destv in dest {
- case string, cstring:
- case: delete(str, p.allocator)
- }
- return nil
+ return UNSUPPORTED_TYPE
case .Open_Brace:
return unmarshal_object(p, v, .Close_Brace)
diff --git a/core/encoding/uuid/LICENSE b/core/encoding/uuid/LICENSE
index e4e21e62d..c7f46ddf6 100644
--- a/core/encoding/uuid/LICENSE
+++ b/core/encoding/uuid/LICENSE
@@ -1,28 +1,17 @@
-BSD 3-Clause License
+Copyright (c) 2024-2025 Feoramund, Ginger Bill. All rights reserved.
-Copyright (c) 2024, Feoramund
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution. \ No newline at end of file
diff --git a/core/encoding/varint/leb128.odin b/core/encoding/varint/leb128.odin
index 876a1ba76..86a72f121 100644
--- a/core/encoding/varint/leb128.odin
+++ b/core/encoding/varint/leb128.odin
@@ -2,7 +2,7 @@ package encoding_varint
/*
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
- Made available under Odin's BSD-3 license.
+ Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
diff --git a/core/encoding/xml/debug_print.odin b/core/encoding/xml/debug_print.odin
index acced262a..9c47e79e8 100644
--- a/core/encoding/xml/debug_print.odin
+++ b/core/encoding/xml/debug_print.odin
@@ -4,7 +4,7 @@ package encoding_xml
An XML 1.0 / 1.1 parser
Copyright 2021-2022 Jeroen van Rijn <nom@duclavier.com>.
- Made available under Odin's BSD-3 license.
+ Made available under Odin's license.
A from-scratch XML implementation, loosely modeled on the [spec](https://www.w3.org/TR/2006/REC-xml11-20060816).
diff --git a/core/encoding/xml/helpers.odin b/core/encoding/xml/helpers.odin
index a9d4ad493..79f2d72c7 100644
--- a/core/encoding/xml/helpers.odin
+++ b/core/encoding/xml/helpers.odin
@@ -4,7 +4,7 @@ package encoding_xml
An XML 1.0 / 1.1 parser
Copyright 2021-2022 Jeroen van Rijn <nom@duclavier.com>.
- Made available under Odin's BSD-3 license.
+ Made available under Odin's license.
This file contains helper functions.
*/
diff --git a/core/encoding/xml/tokenizer.odin b/core/encoding/xml/tokenizer.odin
index 3ef9a6388..71fa0bdf5 100644
--- a/core/encoding/xml/tokenizer.odin
+++ b/core/encoding/xml/tokenizer.odin
@@ -4,7 +4,7 @@ package encoding_xml
An XML 1.0 / 1.1 parser
Copyright 2021-2022 Jeroen van Rijn <nom@duclavier.com>.
- Made available under Odin's BSD-3 license.
+ Made available under Odin's license.
A from-scratch XML implementation, loosely modeled on the [spec](https://www.w3.org/TR/2006/REC-xml11-20060816).
diff --git a/core/encoding/xml/xml_reader.odin b/core/encoding/xml/xml_reader.odin
index 621c9c2d0..0e773fd8a 100644
--- a/core/encoding/xml/xml_reader.odin
+++ b/core/encoding/xml/xml_reader.odin
@@ -3,7 +3,7 @@ package encoding_xml
An XML 1.0 / 1.1 parser
2021-2022 Jeroen van Rijn <nom@duclavier.com>.
- available under Odin's BSD-3 license.
+ available under Odin's license.
List of contributors:
- Jeroen van Rijn: Initial implementation.