aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-22 15:55:25 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-22 15:55:25 +0100
commitb4a779f040f18257fde1c357626461ab187490db (patch)
treeff4006cff95e0048a6c2816678a640ca0891fe60 /lib/xixanta
parente3e54cfee6ebc17281bbbf906ff9035f594313cd (diff)
downloadtools.nes-b4a779f040f18257fde1c357626461ab187490db.tar.gz
tools.nes-b4a779f040f18257fde1c357626461ab187490db.zip
Remove dependency to the rand crate
This dependency was easily avoidable and it brought with it a lot of inner dependencies of its own, most notably 'zerocopy-derive', which forbid us to compile the affected programs purely statically. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta')
-rw-r--r--lib/xixanta/Cargo.toml1
-rw-r--r--lib/xixanta/fuzz/Cargo.lock90
-rw-r--r--lib/xixanta/src/parser.rs13
3 files changed, 10 insertions, 94 deletions
diff --git a/lib/xixanta/Cargo.toml b/lib/xixanta/Cargo.toml
index 6d2c66a..ada2ded 100644
--- a/lib/xixanta/Cargo.toml
+++ b/lib/xixanta/Cargo.toml
@@ -11,4 +11,3 @@ rust-version.workspace = true
[dependencies]
lazy_static = "1.5.0"
toml = { version = "0.8", features = ["preserve_order"] }
-rand = "0.8.5"
diff --git a/lib/xixanta/fuzz/Cargo.lock b/lib/xixanta/fuzz/Cargo.lock
index 5122055..eb897dd 100644
--- a/lib/xixanta/fuzz/Cargo.lock
+++ b/lib/xixanta/fuzz/Cargo.lock
@@ -9,12 +9,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110"
[[package]]
-name = "byteorder"
-version = "1.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
-
-[[package]]
name = "cc"
version = "1.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -26,29 +20,12 @@ dependencies = [
]
[[package]]
-name = "cfg-if"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
-
-[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
-name = "getrandom"
-version = "0.2.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
-dependencies = [
- "cfg-if",
- "libc",
- "wasi",
-]
-
-[[package]]
name = "hashbrown"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -109,15 +86,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]]
-name = "ppv-lite86"
-version = "0.2.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
-dependencies = [
- "zerocopy",
-]
-
-[[package]]
name = "proc-macro2"
version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -136,36 +104,6 @@ dependencies = [
]
[[package]]
-name = "rand"
-version = "0.8.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
-dependencies = [
- "libc",
- "rand_chacha",
- "rand_core",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
-dependencies = [
- "ppv-lite86",
- "rand_core",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.6.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
-dependencies = [
- "getrandom",
-]
-
-[[package]]
name = "serde"
version = "1.0.216"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -253,12 +191,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[package]]
-name = "wasi"
-version = "0.11.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
-
-[[package]]
name = "winnow"
version = "0.6.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -272,7 +204,6 @@ name = "xixanta"
version = "0.1.0"
dependencies = [
"lazy_static",
- "rand",
"toml",
]
@@ -283,24 +214,3 @@ dependencies = [
"libfuzzer-sys",
"xixanta",
]
-
-[[package]]
-name = "zerocopy"
-version = "0.7.35"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
-dependencies = [
- "byteorder",
- "zerocopy-derive",
-]
-
-[[package]]
-name = "zerocopy-derive"
-version = "0.7.35"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs
index 0a4d2b8..d508003 100644
--- a/lib/xixanta/src/parser.rs
+++ b/lib/xixanta/src/parser.rs
@@ -1,7 +1,6 @@
use crate::node::{ControlType, NodeBodyType, NodeType, OperationType, PNode, PString};
use crate::opcodes::{CONTROL_FUNCTIONS, INSTRUCTIONS};
use crate::{Error, SourceInfo};
-use rand::distributions::{Alphanumeric, DistString};
use std::cmp::Ordering;
use std::io::{self, BufRead, Read};
use std::path;
@@ -61,6 +60,12 @@ pub struct Parser {
/// look ahead to know where the literal ends before dealing with further
/// operators.
look_ahead_index: usize,
+
+ /// Number that keeps track of random identifiers being generated so far.
+ /// This is because certain anonymous identifiers are not to be exposed to
+ /// the human eye, and we just care about them being unique. Hence this
+ /// counter.
+ generated_identifiers: usize,
}
impl Parser {
@@ -1338,8 +1343,10 @@ impl Parser {
}
// Generate a unique identifier with the given prefix.
- fn unique_identifier(&self, prefix: String) -> String {
- prefix + &String::from("-") + &Alphanumeric.sample_string(&mut rand::thread_rng(), 16)
+ fn unique_identifier(&mut self, prefix: String) -> String {
+ let res = prefix + &String::from("-") + &self.generated_identifiers.to_string();
+ self.generated_identifiers += 1;
+ res
}
// Returns a NodeType::Control node with whatever could be parsed