Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make printable set exactly the same so we choose precisely the same disassembled representation in all cases #79

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/tests/test_binutils_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"(1 2 3)",
"((4 5 6) (7 8 9))",
"(i (q . 1) (q . 2) (q . 3))",
"((0x33 . i))"
"((0x33 . i))",
"(g . (138935604050210 ()))"
]

def extend_atom():
Expand Down
17 changes: 6 additions & 11 deletions src/classic/clvm_tools/binutils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::borrow::Borrow;
use std::collections::HashSet;
use std::rc::Rc;

use encoding8::ascii::is_printable;
use unicode_segmentation::UnicodeSegmentation;

use clvm_rs::allocator::{Allocator, NodePtr, SExp};
use clvm_rs::reduction::EvalErr;

Expand All @@ -14,15 +12,12 @@ use crate::classic::clvm_tools::ir::r#type::IRRepr;
use crate::classic::clvm_tools::ir::reader::IRReader;
use crate::classic::clvm_tools::ir::writer::write_ir;

lazy_static! {
pub static ref PRINTABLE_CHARS: HashSet<char> =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ".chars().collect();
}
pub fn is_printable_string(s: &str) -> bool {
for ch in s.graphemes(true) {
if ch.chars().next().unwrap() > 0xff as char
|| !is_printable(ch.chars().next().unwrap() as u8)
{
return false;
}
}
true
s.chars().all(|s_char| PRINTABLE_CHARS.contains(&s_char))
}

pub fn assemble_from_ir(
Expand Down
Loading