Skip to content

Commit 4e7931a

Browse files
committed
Port mag_set variable
1 parent 0b59d96 commit 4e7931a

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

crates/engine_xetex/src/c_api/engine.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ pub const INTER_CHAR_TEXT: u16 = 17;
190190
pub const WRITE_TEXT: u16 = 18;
191191
pub const TECTONIC_CODA_TEXT: u16 = 19;
192192

193+
pub const EOP: u8 = 140;
193194
pub const POP: u8 = 142;
195+
pub const POST: u8 = 248;
194196

195197
pub const TOKEN_LIST: u16 = 0;
196198

@@ -239,6 +241,7 @@ pub struct EngineCtx {
239241
pub(crate) use_err_help: bool,
240242
pub(crate) help_ptr: usize,
241243
pub(crate) help_line: [*const libc::c_char; 6],
244+
pub(crate) mag_set: i32,
242245

243246
pub(crate) eqtb: Vec<MemoryWord>,
244247
pub(crate) prim: Box<[B32x2; PRIM_SIZE + 1]>,
@@ -355,6 +358,7 @@ impl EngineCtx {
355358
use_err_help: false,
356359
help_ptr: 0,
357360
help_line: [ptr::null(); 6],
361+
mag_set: 0,
358362

359363
eqtb: Vec::new(),
360364
prim: Box::new([B32x2 { s0: 0, s1: 0 }; PRIM_SIZE + 1]),
@@ -897,6 +901,16 @@ pub extern "C" fn set_help_line(idx: usize, ptr: *const libc::c_char) {
897901
ENGINE_CTX.with_borrow_mut(|engine| engine.help_line[idx] = ptr)
898902
}
899903

904+
#[no_mangle]
905+
pub extern "C" fn mag_set() -> i32 {
906+
ENGINE_CTX.with_borrow(|engine| engine.mag_set)
907+
}
908+
909+
#[no_mangle]
910+
pub extern "C" fn set_mag_set(val: i32) {
911+
ENGINE_CTX.with_borrow_mut(|engine| engine.mag_set = val)
912+
}
913+
900914
#[no_mangle]
901915
pub extern "C" fn eqtb(idx: usize) -> MemoryWord {
902916
ENGINE_CTX.with_borrow(|engine| engine.eqtb[idx])

crates/engine_xetex/xetex/xetex-ini.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ int32_t max_save_stack;
8383
uint16_t cur_level;
8484
group_code cur_group;
8585
int32_t cur_boundary;
86-
int32_t mag_set;
8786
eight_bits cur_cmd;
8887
int32_t cur_chr;
8988
int32_t cur_cs;
@@ -3066,7 +3065,7 @@ initialize_more_variables(void)
30663065
cur_group = BOTTOM_LEVEL;
30673066
cur_boundary = 0;
30683067
max_save_stack = 0;
3069-
mag_set = 0;
3068+
set_mag_set(0);
30703069
expand_depth_count = 0;
30713070
is_in_csname = false;
30723071
cur_mark[TOP_MARK_CODE] = TEX_NULL;

crates/engine_xetex/xetex/xetex-xetex0.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,22 +4449,22 @@ void unsave(void)
44494449
void prepare_mag(void)
44504450
{
44514451

4452-
if (mag_set > 0 && INTPAR(mag) != mag_set) {
4452+
if (mag_set() > 0 && INTPAR(mag) != mag_set()) {
44534453
ttbc_diagnostic_t *errmsg = error_here_with_diagnostic("Incompatible magnification (");
44544454
print_int(INTPAR(mag));
44554455
print_cstr(");");
44564456
print_nl_cstr(" the previous value will be retained");
44574457

4458-
ttstub_diag_printf(errmsg, " (%d)", mag_set);
4458+
ttstub_diag_printf(errmsg, " (%d)", mag_set());
44594459
capture_to_diagnostic(NULL);
44604460

44614461
{
44624462
set_help_ptr(2);
44634463
set_help_line(1, "I can handle only one magnification ratio per job. So I've");
44644464
set_help_line(0, "reverted to the magnification you used earlier on this run.");
44654465
}
4466-
int_error(mag_set);
4467-
geq_word_define(INT_BASE + INT_PAR__mag, mag_set);
4466+
int_error(mag_set());
4467+
geq_word_define(INT_BASE + INT_PAR__mag, mag_set());
44684468
}
44694469
if ((INTPAR(mag) <= 0) || (INTPAR(mag) > 32768L)) {
44704470
ttbc_diagnostic_t *errmsg = error_here_with_diagnostic("Illegal magnification has been changed to 1000");
@@ -4478,7 +4478,7 @@ void prepare_mag(void)
44784478
int_error(INTPAR(mag));
44794479
geq_word_define(INT_BASE + INT_PAR__mag, 1000);
44804480
}
4481-
mag_set = INTPAR(mag);
4481+
set_mag_set(INTPAR(mag));
44824482
}
44834483

44844484
void print_meaning(void)

crates/engine_xetex/xetex/xetex-xetexd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ extern int32_t max_save_stack;
443443
extern uint16_t cur_level;
444444
extern group_code cur_group;
445445
extern int32_t cur_boundary;
446-
extern int32_t mag_set;
447446
extern eight_bits cur_cmd;
448447
extern int32_t cur_chr;
449448
extern int32_t cur_cs;

crates/engine_xetex/xetex/xetex_bindings.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,12 @@
359359

360360
#define TECTONIC_CODA_TEXT 19
361361

362+
#define EOP 140
363+
362364
#define POP 142
363365

366+
#define POST 248
367+
364368
#define TOKEN_LIST 0
365369

366370
#define MAX_CHAR_VAL 2097152
@@ -696,6 +700,10 @@ const char *help_line(uintptr_t idx);
696700

697701
void set_help_line(uintptr_t idx, const char *ptr);
698702

703+
int32_t mag_set(void);
704+
705+
void set_mag_set(int32_t val);
706+
699707
MemoryWord eqtb(uintptr_t idx);
700708

701709
void set_eqtb(uintptr_t idx, MemoryWord val);
@@ -764,7 +772,7 @@ void error(void);
764772

765773
void post_error_message(int32_t need_to_print_it);
766774

767-
void fatal_error(void);
775+
void fatal_error(const char *s);
768776

769777
extern void close_files_and_terminate(void);
770778

0 commit comments

Comments
 (0)