Implement pdfTeX random primitives with checkpointed state
This commit is contained in:
1 parent
a958954308
commit
5c2ba9fad0
13 files changed
+230
-8
No files matched your search
+10
-3
@@ -31,8 +31,8 @@ pub fn job_time() -> Result<JobTime, String> {
|
||||
let local = chrono::Local::now().fixed_offset();
|
||||
let source_date = std::env::var_os("SOURCE_DATE_EPOCH");
|
||||
let force_utc = std::env::var_os("FORCE_SOURCE_DATE").is_some_and(|value| value == "1");
|
||||
let pdf_date = match source_date {
|
||||
Some(value) => source_date_epoch(&value)?,
|
||||
let pdf_date = match source_date.as_deref() {
|
||||
Some(value) => source_date_epoch(value)?,
|
||||
None => local,
|
||||
};
|
||||
let registers = if force_utc {
|
||||
@@ -40,7 +40,14 @@ pub fn job_time() -> Result<JobTime, String> {
|
||||
} else {
|
||||
local
|
||||
};
|
||||
Ok(pdf_clock(registers)?.with_pdf_date(pdf_clock(pdf_date)?))
|
||||
// A declared build clock also fixes the random stream, so an independent
|
||||
// full build can replay an editor revision under the same inputs.
|
||||
let seed_clock = if source_date.is_some() { pdf_date } else { local };
|
||||
let seed = i64::from(seed_clock.timestamp_subsec_micros()) * 1000
|
||||
+ seed_clock.timestamp().rem_euclid(1_000_000);
|
||||
Ok(pdf_clock(registers)?
|
||||
.with_pdf_date(pdf_clock(pdf_date)?)
|
||||
.with_random_seed(seed as i32))
|
||||
}
|
||||
|
||||
fn source_date_epoch(value: &OsStr) -> Result<DateTime<FixedOffset>, String> {
|
||||
|
||||
Reference in new issue
Block a user