Commit Graph

2226 Commits

Author SHA1 Message Date
Jeroen van Rijn 2dd67dba89 [core:encoding/entity] Add new package to decode &<entity>; entities.
Includes generator to generate a lookup for named entitiess.
2021-12-05 02:52:23 +01:00
Jeroen van Rijn 5807214406 [xml] Improvements. 2021-12-05 02:52:23 +01:00
Jeroen van Rijn 23baf56c87 [xml] Improve CDATA + comment handling in tag body. 2021-12-05 02:52:23 +01:00
Jeroen van Rijn beff90e1d1 [xml] Slight optimization.
About a 5% speed bump.

More rigorous optimization later.
2021-12-05 02:52:23 +01:00
Jeroen van Rijn ec63d0bbd2 [xml] Robustness improvement.
Can now parse  https://www.w3.org/2003/entities/2007xml/unicode.xml no problem.
2021-12-05 02:52:22 +01:00
Jeroen van Rijn 32eab04d66 [xml] Allow multi-line bodies w/o CDATA. Strip trailing whitespace. 2021-12-05 02:52:22 +01:00
Jeroen van Rijn 682783a2aa [xml] Tab indentation in debug printer. 2021-12-05 02:52:22 +01:00
Jeroen van Rijn 46a4927aca [xml] Use io.Writer for xml.print(doc). 2021-12-05 02:52:22 +01:00
Jeroen van Rijn 9b2e67df67 [xml] Small cleanup. 2021-12-05 02:52:22 +01:00
Jeroen van Rijn b5c828fe4e [xml] Initial implementation of core:encoding/xml.
A from-scratch XML implementation, loosely modeled on the [spec](https://www.w3.org/TR/2006/REC-xml11-20060816).

Features:
		- Supports enough of the XML 1.0/1.1 spec to handle the 99.9% of XML documents in common current usage.
		- Simple to understand and use. Small.

Caveats:
		- We do NOT support HTML in this package, as that may or may not be valid XML.
		  If it works, great. If it doesn't, that's not considered a bug.

		- We do NOT support UTF-16. If you have a UTF-16 XML file, please convert it to UTF-8 first. Also, our condolences.
		- <[!ELEMENT and <[!ATTLIST are not supported, and will be either ignored or return an error depending on the parser options.

TODO:
- Optional CDATA unboxing.
- Optional `&gt;`, `&#32;`, `&#x20;` and other escape substitution in tag bodies.
- Test suite

MAYBE:
- XML writer?
- Serialize/deserialize Odin types?
2021-12-05 02:52:22 +01:00
Daniel Gavin f1a126e162 Do not save the comment when peeking. 2021-12-02 22:44:47 +01:00
Daniel Gavin 517c8ff1dd Include Matrix_Type to the is_literal_type switch statement. 2021-11-28 02:14:25 +01:00
gingerBill 6616882708 Correct reading from a console on Windows
e.g. `os.read(os.stdin, buf[:])`
2021-11-27 14:59:35 +00:00
gingerBill c9c197ba08 Add os.read_at_least and os_read_full utility procedures. 2021-11-27 14:57:49 +00:00
gingerBill 7876660d8c Add new utf16 procedures: decode, decode_to_utf8 2021-11-27 14:57:20 +00:00
gingerBill 07ec93bfeb Add procs_windows_amd64.asm for use with -no-crt 2021-11-24 18:32:27 +00:00
gingerBill 5db505c42f Merge pull request #1277 from Yawning/feature/modern-crypto
core/crypto: Add some "modern" primitives
2021-11-23 17:54:03 +00:00
Dale Weiler a55f0cfb63 fix memory leak in path.join 2021-11-22 10:25:54 -05:00
gingerBill f40f12d480 Minor cleanup to math constants 2021-11-21 14:06:32 +00:00
gingerBill 8a2c829e07 Patch odin doc binary format 2021-11-21 14:06:15 +00:00
Gus 56d2bbc5b9 Added back ln for js 2021-11-20 20:03:54 +11:00
Michael Kutowski 4439d59105 add builtin. 2021-11-19 00:24:56 +01:00
gingerBill 12c1291805 Add optional seed parameters to all hashes 2021-11-18 16:14:33 +00:00
Yawning Angel 6bafa21bee crypto: Add rand_bytes
This adds `rand_bytes(dst: []byte)` which fills the destination buffer
with entropy from the cryptographic random number generator.  This takes
the "simple is best" approach and just directly returns the OS CSPRNG
output instead of doing anything fancy (a la OpenBSD's arc4random).
2021-11-17 14:00:00 +00:00
Yawning Angel 61c581baeb core/sys/unix: Add syscalls_linux.odin
Linux is in the unfortunate situation where the system call number is
architecture specific.  This consolidates the system call number
definitions in a single location, adds some wrappers, and hopefully
fixes the existing non-portable invocations of the syscall intrinsic.
2021-11-17 14:00:00 +00:00
Yawning Angel 6c4c9aef61 core/crypto: Add chacha20poly1305
This package implements the chacha20poly1305 AEAD construct as specified
in RFC 8439.
2021-11-17 13:59:53 +00:00
Yawning Angel 7bed317636 core/crypto: Add chacha20
This package implements the ChaCha20 stream cipher as specified in
RFC 8439, and the somewhat non-standard XChaCha20 variant that supports
a 192-bit nonce.

While an IETF draft for XChaCha20 standardization exists,
implementations that pre-date the draft use a 64-bit counter, instead of
the IETF-style 32-bit one.  This implementation opts for the latter as
compatibility with libsodium is more important than compatibility with
an expired IETF draft.
2021-11-17 13:59:53 +00:00
Yawning Angel 4647081f49 core/crypto/poly1305: Triple performance on amd64 with -o:speed 2021-11-17 13:59:53 +00:00
Yawning Angel 64db286582 core/crypto: Add poly1305
This package implements the Poly1305 MAC algorithm as specified in RFC
8439, using routines taked from fiat-crypto and poly1305-donna.
2021-11-17 13:59:53 +00:00
Yawning Angel 1a7a6a9116 core/crypto: Add x25519
This package implements the X25519 key agreement scheme as specified in
RFC 7748, using routines taken from fiat-crypto and Monocypher.
2021-11-17 13:59:53 +00:00
Yawning Angel d1e76ee4f2 core/crypto: Add constant-time memory comparison routines
Using a constant-time comparison is required when comparing things like
MACs, password digests, and etc to avoid exposing sensitive data via
trivial timing attacks.

These routines could also live under core:mem, but they are somewhat
specialized, and are likely only useful for cryptographic applications.
2021-11-17 13:59:53 +00:00
gingerBill e877525073 Keep -vet happy for -no-crt and wasm targets 2021-11-17 10:40:55 +00:00
gingerBill f09638318f Add support for darwin to core:c/libc 2021-11-16 21:19:08 +00:00
gingerBill 1b28226a67 Add math.lgamma based off FreeBSD's /usr/src/lib/msun/src/e_lgamma_r.c 2021-11-16 15:32:32 +00:00
gingerBill 2b546a598c Add math.signbit; Add math.gamma based on http://netlib.sandia.gov/cephes/cprob/gamma.c 2021-11-16 15:23:19 +00:00
gingerBill b530ca9a5e Add math.nextafter 2021-11-16 15:12:01 +00:00
gingerBill d232796149 Fix typo 2021-11-16 15:09:47 +00:00
gingerBill e721f26a76 Implement ln based off FreeBSD's /usr/src/lib/msun/src/e_log.c 2021-11-16 15:05:04 +00:00
gingerBill 91408cb21f Implement atanh based on FreeBSD's /usr/src/lib/msun/src/e_atanh.c 2021-11-16 14:58:59 +00:00
gingerBill eb8b0d7a03 Add log1p, erf, erfc, ilogb logb (implemented based of FreeBSD's) 2021-11-16 14:54:57 +00:00
gingerBill 880af47ae7 Rename math_js.odin to math_basic_js.odin 2021-11-16 14:26:04 +00:00
gingerBill 91949b0992 Implement math.sqrt with intrinsics.sqrt 2021-11-16 14:11:20 +00:00
gingerBill 6a101e69a2 Implement ldexp and frexp in native Odin 2021-11-16 14:04:49 +00:00
gingerBill f55fc4cd08 Add complex32 and quaternion64 for the 16-bit float types to fmt 2021-11-15 17:25:29 +00:00
gingerBill b9701340b8 Add linalg.matrix4_look_at_from_fru 2021-11-13 19:15:37 +00:00
gingerBill 82110bf487 Merge branch 'master' of https://github.com/odin-lang/Odin 2021-11-13 19:07:27 +00:00
gingerBill a75dc9d86d Fix minor issue with unmarshal for booleans 2021-11-13 19:07:16 +00:00
Carwyn Nelson c67c0789eb Add socket() function to windows ws32 bindings
It looks like this was missing from the winsock bindings. Odin contains
WSASocketW which I assume would also work for obtaining a socket, but
socket() is distinct and is what I was using, so I assume others will
want it too.
2021-11-10 15:55:50 +00:00
Carwyn Nelson d8b1523161 Fix the windows binding for getaddrinfo
getaddrinfo should take a double pointer to ADDRINFOA instead of a single pointer. If you call the binding in its current state you will not get back a valid ADDRINFOA struct.

I have also changed the `node` and `service` params to be cstring to avoid having to do `transmute(u8) value`.
2021-11-10 15:15:40 +00:00
Jeroen van Rijn dd88104a81 Fix os.walk for UNC paths. 2021-11-10 14:59:54 +01:00