@@ -17,7 +17,7 @@ use crate::{
1717 check_brace_level, decr_brace_level, enough_text_chars, name_scan_for_and,
1818 von_name_ends_and_last_name_starts_stuff, von_token_found, QUOTE_NEXT_FN ,
1919 } ,
20- ASCIICode , Bibtex , BibtexError , BufPointer , GlobalItems , HashPointer , PoolPointer , StrIlk ,
20+ ASCIICode , Bibtex , BibtexError , BufPointer , GlobalItems , HashPointer , StrIlk ,
2121} ;
2222use std:: ops:: { Deref , DerefMut , Index } ;
2323use crate :: pool:: { Checkpoint , MAX_PRINT_LINE , MIN_PRINT_LINE } ;
@@ -290,7 +290,7 @@ fn pop_whole_stack(
290290 Ok ( ( ) )
291291}
292292
293- pub fn skip_brace_level_greater_than_one ( str : & [ ASCIICode ] , brace_level : & mut i32 ) -> PoolPointer {
293+ pub fn skip_brace_level_greater_than_one ( str : & [ ASCIICode ] , brace_level : & mut i32 ) -> usize {
294294 let mut pos = 0 ;
295295 while * brace_level > 1 && pos < str. len ( ) {
296296 if str[ pos] == b'}' {
@@ -741,7 +741,7 @@ fn add_pool_buf_and_push(
741741) -> Result < ( ) , BibtexError > {
742742 buffers. set_offset ( BufTy :: Ex , 1 , buffers. init ( BufTy :: Ex ) ) ;
743743 let str = & buffers. buffer ( BufTy :: Ex ) [ 0 ..buffers. init ( BufTy :: Ex ) ] ;
744- let val = ExecVal :: String ( pool. add_string ( ctx , str) ? ) ;
744+ let val = ExecVal :: String ( pool. add_string ( str) ) ;
745745 ctx. push_stack ( val) ;
746746 Ok ( ( ) )
747747}
@@ -918,18 +918,18 @@ fn interp_concat(
918918 // Both strings are 'scratch', they must be next to each-other due to external invariants,
919919 // se we just make one new string covering both
920920 let new_len = pool. get_str ( s1) . len ( ) + pool. get_str ( s2) . len ( ) ;
921- let new = pool. write_str ( ctx , |cursor| cursor. extend ( new_len) ) ? ;
921+ let new = pool. write_str ( |cursor| cursor. extend ( new_len) ) ;
922922 ctx. push_stack ( ExecVal :: String ( new) ) ;
923923 } else if ctx. checkpoint . is_before ( s2) {
924924 if pool. get_str ( s2) . is_empty ( ) {
925925 ctx. push_stack ( pop1) ;
926926 } else {
927927 // s2 is scratch, we add s1 to its end and return the new scratch string
928928 let s2_len = pool. get_str ( s2) . len ( ) ;
929- let new = pool. write_str ( ctx , |cursor| {
929+ let new = pool. write_str ( |cursor| {
930930 cursor. extend ( s2_len) ;
931931 cursor. append_str ( s1) ;
932- } ) ? ;
932+ } ) ;
933933 ctx. push_stack ( ExecVal :: String ( new) ) ;
934934 }
935935 } else if ctx. checkpoint . is_before ( s1) {
@@ -939,7 +939,7 @@ fn interp_concat(
939939 if str2. is_empty ( ) {
940940 // s1 is scratch and s2 is empty - just save s1 and return it
941941 let s1_len = str1. len ( ) ;
942- let new = pool. write_str ( ctx , |cursor| cursor. extend ( s1_len) ) ? ;
942+ let new = pool. write_str ( |cursor| cursor. extend ( s1_len) ) ;
943943 ctx. push_stack ( ExecVal :: String ( new) ) ;
944944 } else if str1. is_empty ( ) {
945945 // s1 is empty - just return s2
@@ -950,12 +950,12 @@ fn interp_concat(
950950
951951 // s1 is scratch and s2 is not - we want to copy s1 forward by the length of s2,
952952 // then write s2 in where it was, returning the new scratch string
953- let new = pool. write_str ( ctx , |cursor| {
953+ let new = pool. write_str ( |cursor| {
954954 cursor. extend ( s1_len + s2_len) ;
955955 let raw = cursor. bytes ( ) ;
956956 raw. copy_within ( 0 ..s1_len, s2_len) ;
957957 cursor. insert_str ( s2, 0 ) ;
958- } ) ? ;
958+ } ) ;
959959 let val = ExecVal :: String ( new) ;
960960 ctx. push_stack ( val) ;
961961 }
@@ -969,10 +969,10 @@ fn interp_concat(
969969 ctx. push_stack ( pop1) ;
970970 } else {
971971 // Neither is scratch or empty - make a new scratch string from the concat of both
972- let new = pool. write_str ( ctx , |cursor| {
972+ let new = pool. write_str ( |cursor| {
973973 cursor. append_str ( s2) ;
974974 cursor. append_str ( s1) ;
975- } ) ? ;
975+ } ) ;
976976 let val = ExecVal :: String ( new) ;
977977 ctx. push_stack ( val) ;
978978 }
@@ -1091,7 +1091,7 @@ fn interp_add_period(
10911091 // If scratch, save
10921092 if ctx. checkpoint . is_before ( s1) {
10931093 let s1_len = pool. get_str ( s1) . len ( ) ;
1094- let new = pool. write_str ( ctx , |cursor| cursor. extend ( s1_len) ) ? ;
1094+ let new = pool. write_str ( |cursor| cursor. extend ( s1_len) ) ;
10951095 ctx. push_stack ( ExecVal :: String ( new) ) ;
10961096 } else {
10971097 ctx. push_stack ( pop1) ;
@@ -1100,14 +1100,14 @@ fn interp_add_period(
11001100 _ => {
11011101 let is_bst_str = ctx. checkpoint . is_before ( s1) ;
11021102 let s1_len = pool. get_str ( s1) . len ( ) ;
1103- let new = pool. write_str ( ctx , |cursor| {
1103+ let new = pool. write_str ( |cursor| {
11041104 if is_bst_str {
11051105 cursor. extend ( s1_len) ;
11061106 } else {
11071107 cursor. append_str ( s1) ;
11081108 }
11091109 cursor. append ( b'.' ) ;
1110- } ) ? ;
1110+ } ) ;
11111111 let val = ExecVal :: String ( new) ;
11121112 ctx. push_stack ( val) ;
11131113 }
@@ -1277,7 +1277,7 @@ fn interp_change_case(
12771277 idx += 1 ;
12781278 }
12791279 check_brace_level ( ctx, pool, cites, s2, brace_level) ?;
1280- let val = ExecVal :: String ( pool. add_string ( ctx , & scratch) ? ) ;
1280+ let val = ExecVal :: String ( pool. add_string ( & scratch) ) ;
12811281 ctx. push_stack ( val) ;
12821282 }
12831283 ( ExecVal :: String ( _) , _) => {
@@ -1346,12 +1346,12 @@ fn interp_dup(
13461346 ctx. push_stack ( pop1) ;
13471347 } else {
13481348 let str_len = pool. get_str ( s1) . len ( ) ;
1349- let _ = pool. write_str ( ctx , |cursor| {
1349+ let _ = pool. write_str ( |cursor| {
13501350 cursor. extend ( str_len) ;
1351- } ) ? ;
1352- let new = pool. write_str ( ctx , |cursor| {
1351+ } ) ;
1352+ let new = pool. write_str ( |cursor| {
13531353 cursor. append_str ( s1) ;
1354- } ) ? ;
1354+ } ) ;
13551355 let val = ExecVal :: String ( new) ;
13561356 ctx. push_stack ( val) ;
13571357 }
@@ -1693,7 +1693,7 @@ fn interp_int_to_chr(
16931693 bst_ex_warn_print ( ctx, pool, cites) ?;
16941694 ctx. push_stack ( ExecVal :: String ( ctx. s_null ) ) ;
16951695 } else {
1696- let val = ExecVal :: String ( pool. add_string ( ctx , & [ i1 as u8 ] ) ? ) ;
1696+ let val = ExecVal :: String ( pool. add_string ( & [ i1 as u8 ] ) ) ;
16971697 ctx. push_stack ( val) ;
16981698 }
16991699 Ok ( ( ) )
@@ -1716,7 +1716,7 @@ fn interp_int_to_str(
17161716 } ;
17171717
17181718 let scratch = i1. to_string ( ) ;
1719- let val = ExecVal :: String ( pool. add_string ( ctx , scratch. as_bytes ( ) ) ? ) ;
1719+ let val = ExecVal :: String ( pool. add_string ( scratch. as_bytes ( ) ) ) ;
17201720 ctx. push_stack ( val) ;
17211721 Ok ( ( ) )
17221722}
@@ -1790,7 +1790,7 @@ fn interp_preamble(
17901790 for s in bibs. preamble ( ) {
17911791 out. extend ( pool. get_str ( * s) ) ;
17921792 }
1793- let s = pool. add_string ( ctx , & out) ? ;
1793+ let s = pool. add_string ( & out) ;
17941794 ctx. push_stack ( ExecVal :: String ( s) ) ;
17951795 Ok ( ( ) )
17961796}
@@ -1888,14 +1888,14 @@ fn interp_purify(
18881888 }
18891889
18901890 scratch. truncate ( write_idx) ;
1891- let out = pool. add_string ( ctx , & scratch) ? ;
1891+ let out = pool. add_string ( & scratch) ;
18921892 ctx. push_stack ( ExecVal :: String ( out) ) ;
18931893
18941894 Ok ( ( ) )
18951895}
18961896
18971897fn interp_quote ( ctx : & mut ExecCtx < ' _ , ' _ , ' _ > , pool : & mut StringPool ) -> Result < ( ) , BibtexError > {
1898- let s = pool. add_string ( ctx , b"\" " ) ? ;
1898+ let s = pool. add_string ( b"\" " ) ;
18991899 ctx. push_stack ( ExecVal :: String ( s) ) ;
19001900 Ok ( ( ) )
19011901}
@@ -1968,24 +1968,24 @@ fn interp_substr(
19681968 if len >= str. len ( ) && ( start == 1 || start == -1 ) {
19691969 if ctx. checkpoint . is_before ( s3) {
19701970 let str_len = pool. get_str ( s3) . len ( ) ;
1971- let _ = pool. write_str ( ctx , |cursor| cursor. extend ( str_len) ) ? ;
1971+ let _ = pool. write_str ( |cursor| cursor. extend ( str_len) ) ;
19721972 }
19731973 ctx. push_stack ( pop3) ;
19741974 return Ok ( ( ) ) ;
19751975 }
19761976
19771977 if start == 1 && ctx. checkpoint . is_before ( s3) {
1978- let new = pool. write_str ( ctx , |cursor| {
1978+ let new = pool. write_str ( |cursor| {
19791979 cursor. extend ( len) ;
1980- } ) ? ;
1980+ } ) ;
19811981 ctx. push_stack ( ExecVal :: String ( new) ) ;
19821982 return Ok ( ( ) ) ;
19831983 }
19841984
19851985 // TODO: Remove this intermediate allocation, currently can't pass a `&str` from a StringPool
19861986 // to that StringPool.
19871987 let new_str = Vec :: from ( & str[ SLRange { start, len } ] ) ;
1988- let out = pool. add_string ( ctx , & new_str) ? ;
1988+ let out = pool. add_string ( & new_str) ;
19891989 ctx. push_stack ( ExecVal :: String ( out) ) ;
19901990
19911991 Ok ( ( ) )
@@ -2004,20 +2004,20 @@ fn interp_swap(
20042004 if ctx. checkpoint . is_before ( s1) && ctx. checkpoint . is_before ( s2) =>
20052005 {
20062006 let tmp = Vec :: from ( pool. get_str ( s2) ) ;
2007- let new = pool. write_str ( ctx , |cursor| {
2007+ let new = pool. write_str ( |cursor| {
20082008 cursor. append_str ( s1) ;
2009- } ) ? ;
2009+ } ) ;
20102010 let val = ExecVal :: String ( new) ;
20112011 ctx. push_stack ( val) ;
2012- let val = ExecVal :: String ( pool. add_string ( ctx , & tmp) ? ) ;
2012+ let val = ExecVal :: String ( pool. add_string ( & tmp) ) ;
20132013 ctx. push_stack ( val) ;
20142014 return Ok ( ( ) ) ;
20152015 }
20162016 ( ExecVal :: String ( s) , _) | ( _, ExecVal :: String ( s) ) if ctx. checkpoint . is_before ( s) => {
20172017 let str_len = pool. get_str ( s) . len ( ) ;
2018- let _ = pool. write_str ( ctx , |cursor| {
2018+ let _ = pool. write_str ( |cursor| {
20192019 cursor. extend ( str_len) ;
2020- } ) ? ;
2020+ } ) ;
20212021 }
20222022 ( _, _) => ( ) ,
20232023 }
@@ -2133,7 +2133,7 @@ fn interp_text_prefix(
21332133 }
21342134
21352135 let is_before = ctx. checkpoint . is_before ( s2) ;
2136- let new = pool. write_str ( ctx , |cursor| {
2136+ let new = pool. write_str ( |cursor| {
21372137 if is_before {
21382138 cursor. extend ( idx)
21392139 } else {
@@ -2142,7 +2142,7 @@ fn interp_text_prefix(
21422142 for _ in 0 ..brace_level {
21432143 cursor. append ( b'}' ) ;
21442144 }
2145- } ) ? ;
2145+ } ) ;
21462146
21472147 let val = ExecVal :: String ( new) ;
21482148 ctx. push_stack ( val) ;
@@ -2541,7 +2541,7 @@ pub(crate) fn execute_fn(
25412541 } else {
25422542 let str_ent_ptr = globals. cites . ptr ( ) * globals. entries . num_ent_strs ( ) + * entry;
25432543 let str = globals. entries . strs ( str_ent_ptr) ;
2544- let val = ExecVal :: String ( globals. pool . add_string ( ctx , str) ? ) ;
2544+ let val = ExecVal :: String ( globals. pool . add_string ( str) ) ;
25452545 ctx. push_stack ( val) ;
25462546 Ok ( ( ) )
25472547 }
@@ -2556,7 +2556,7 @@ pub(crate) fn execute_fn(
25562556 ctx. push_stack ( ExecVal :: String ( str_ptr) ) ;
25572557 } else {
25582558 let str = globals. globals . str ( * glb_ptr) ;
2559- let val = ExecVal :: String ( globals. pool . add_string ( ctx , str) ? ) ;
2559+ let val = ExecVal :: String ( globals. pool . add_string ( str) ) ;
25602560 ctx. push_stack ( val) ;
25612561 }
25622562 Ok ( ( ) )
0 commit comments