@@ -7,7 +7,7 @@ use std::ffi::{CStr, CString};
7
7
use errors:: { ErrorKind , Result } ;
8
8
use io:: IoStack ;
9
9
use status:: StatusBackend ;
10
- use super :: { assign_global_state , c_api , IoEventBackend , ExecutionState } ;
10
+ use super :: { IoEventBackend , ExecutionState , TectonicBridgeApi } ;
11
11
use super :: tex:: TexResult ;
12
12
13
13
@@ -25,25 +25,24 @@ impl BibtexEngine {
25
25
status : & mut StatusBackend , aux : & str ) -> Result < TexResult > {
26
26
let caux = CString :: new ( aux) ?;
27
27
28
- let mut state = ExecutionState :: new ( io, events, status) ;
28
+ let /*mut*/ state = ExecutionState :: new ( io, events, status) ;
29
+ let bridge = TectonicBridgeApi :: new ( & state) ;
29
30
30
31
unsafe {
31
- assign_global_state ( & mut state, || {
32
- match c_api:: bibtex_simple_main ( caux. as_ptr ( ) ) {
33
- 0 => Ok ( TexResult :: Spotless ) ,
34
- 1 => Ok ( TexResult :: Warnings ) ,
35
- 2 => Ok ( TexResult :: Errors ) ,
36
- 3 => {
37
- Err ( ErrorKind :: Msg ( "unspecified fatal bibtex error" . into ( ) ) . into ( ) )
38
- } ,
39
- 99 => {
40
- let ptr = c_api:: tt_get_error_message ( ) ;
41
- let msg = CStr :: from_ptr ( ptr) . to_string_lossy ( ) . into_owned ( ) ;
42
- Err ( ErrorKind :: Msg ( msg) . into ( ) )
43
- } ,
44
- x => Err ( ErrorKind :: Msg ( format ! ( "internal error: unexpected 'history' value {}" , x) ) . into ( ) )
45
- }
46
- } )
32
+ match super :: bibtex_simple_main ( & bridge, caux. as_ptr ( ) ) {
33
+ 0 => Ok ( TexResult :: Spotless ) ,
34
+ 1 => Ok ( TexResult :: Warnings ) ,
35
+ 2 => Ok ( TexResult :: Errors ) ,
36
+ 3 => {
37
+ Err ( ErrorKind :: Msg ( "unspecified fatal bibtex error" . into ( ) ) . into ( ) )
38
+ } ,
39
+ 99 => {
40
+ let ptr = super :: tt_get_error_message ( ) ;
41
+ let msg = CStr :: from_ptr ( ptr) . to_string_lossy ( ) . into_owned ( ) ;
42
+ Err ( ErrorKind :: Msg ( msg) . into ( ) )
43
+ } ,
44
+ x => Err ( ErrorKind :: Msg ( format ! ( "internal error: unexpected 'history' value {}" , x) ) . into ( ) )
45
+ }
47
46
}
48
47
}
49
48
}
0 commit comments