@@ -104,6 +104,8 @@ typedef uint8_t StrIlk;
104104
105105typedef struct PeekableInput PeekableInput ;
106106
107+ typedef struct XBuf_ExecVal XBuf_ExecVal ;
108+
107109typedef uintptr_t StrNumber ;
108110
109111typedef uintptr_t BufPointer ;
@@ -188,8 +190,7 @@ typedef struct {
188190 ExecVal pop1 ;
189191 ExecVal pop2 ;
190192 ExecVal pop3 ;
191- ExecVal * lit_stack ;
192- uintptr_t lit_stk_size ;
193+ XBuf_ExecVal * lit_stack ;
193194 uintptr_t lit_stk_ptr ;
194195 bool mess_with_entries ;
195196 StrNumber bib_str_ptr ;
@@ -199,8 +200,6 @@ typedef uintptr_t FieldLoc;
199200
200201typedef uintptr_t WizFnLoc ;
201202
202- typedef uintptr_t FnDefLoc ;
203-
204203typedef uintptr_t PoolPointer ;
205204
206205typedef struct {
@@ -229,6 +228,21 @@ typedef struct {
229228 };
230229} CResultLookup ;
231230
231+ typedef enum {
232+ CResultBool_Error ,
233+ CResultBool_Recover ,
234+ CResultBool_Ok ,
235+ } CResultBool_Tag ;
236+
237+ typedef struct {
238+ CResultBool_Tag tag ;
239+ union {
240+ struct {
241+ bool ok ;
242+ };
243+ };
244+ } CResultBool ;
245+
232246
233247
234248#ifdef __cplusplus
@@ -279,8 +293,6 @@ void set_bib_ptr(BibNumber num);
279293
280294void check_bib_files (BibNumber ptr );
281295
282- void add_preamble (StrNumber num );
283-
284296StrNumber cur_preamble (void );
285297
286298BibNumber preamble_ptr (void );
@@ -291,7 +303,7 @@ int32_t bib_line_num(void);
291303
292304void set_bib_line_num (int32_t num );
293305
294- uintptr_t bib_buf_size (void );
306+ bool eat_bib_white_space (void );
295307
296308ASCIICode bib_buf (BufTy ty , BufPointer pos );
297309
@@ -307,8 +319,6 @@ BufPointer bib_buf_len(BufTy ty);
307319
308320void bib_set_buf_len (BufTy ty , BufPointer len );
309321
310- void buffer_overflow (void );
311-
312322BufPointer name_tok (BufPointer pos );
313323
314324void set_name_tok (BufPointer pos , BufPointer val );
@@ -385,21 +395,52 @@ ASCIICode entry_strs(int32_t pos);
385395
386396void set_entry_strs (int32_t pos , ASCIICode val );
387397
388- bool print_lit (ExecVal val );
398+ ExecVal int_val (int32_t lit );
399+
400+ ExecVal str_val (StrNumber str );
401+
402+ ExecVal func_val (HashPointer f );
403+
404+ ExecVal missing_val (StrNumber f );
405+
406+ ExecCtx init_exec_ctx (Bibtex * glbl_ctx );
389407
390- bool print_stk_lit (ExecVal val );
408+ CResult print_lit (ExecVal val );
391409
392- bool print_wrong_stk_lit ( ExecCtx * ctx , ExecVal val , StkType typ2 );
410+ CResult print_stk_lit ( ExecVal val );
393411
394- bool bst_ex_warn_print ( const ExecCtx * ctx );
412+ CResult print_wrong_stk_lit ( ExecCtx * ctx , ExecVal val , StkType typ2 );
395413
396- bool bst_ln_num_print (const Bibtex * glbl_ctx );
414+ CResult bst_ex_warn_print (const ExecCtx * ctx );
397415
398- bool print_bst_name (const Bibtex * glbl_ctx );
416+ CResult print_bst_name (const Bibtex * glbl_ctx );
399417
400418void push_lit_stk (ExecCtx * ctx , ExecVal val );
401419
402- bool pop_lit_stk (ExecCtx * ctx , ExecVal * out );
420+ CResult pop_lit_stk (ExecCtx * ctx , ExecVal * out );
421+
422+ CResult pop_top_and_print (ExecCtx * ctx );
423+
424+ CResult pop_whole_stack (ExecCtx * ctx );
425+
426+ void init_command_execution (ExecCtx * ctx );
427+
428+ CResult figure_out_the_formatted_name (ExecCtx * ctx ,
429+ BufPointer first_start ,
430+ BufPointer first_end ,
431+ BufPointer last_end ,
432+ BufPointer von_start ,
433+ BufPointer von_end ,
434+ BufPointer * name_bf_ptr ,
435+ BufPointer * name_bf_xptr ,
436+ BufPointer jr_end ,
437+ int32_t * brace_level );
438+
439+ CResult check_command_execution (ExecCtx * ctx );
440+
441+ CResult add_pool_buf_and_push (ExecCtx * ctx );
442+
443+ ExecVal * cur_lit (ExecCtx * ctx );
403444
404445int32_t num_glb_strs (void );
405446
@@ -441,8 +482,6 @@ History get_history(void);
441482
442483void mark_warning (void );
443484
444- void mark_error (void );
445-
446485uint32_t err_count (void );
447486
448487bool init_standard_output (void );
@@ -461,15 +500,15 @@ void print_confusion(void);
461500
462501void print_a_token (void );
463502
464- bool print_a_pool_str (StrNumber s );
503+ CResult print_a_pool_str (StrNumber s );
465504
466- bool print_aux_name (void );
505+ CResult print_aux_name (void );
467506
468- bool log_pr_aux_name (void );
507+ CResult log_pr_aux_name (void );
469508
470- bool aux_err_print (void );
509+ CResult aux_err_print (void );
471510
472- bool aux_err_illegal_another_print (int32_t cmd_num );
511+ CResult aux_err_illegal_another_print (int32_t cmd_num );
473512
474513void aux_err_no_right_brace_print (void );
475514
@@ -479,59 +518,53 @@ void aux_err_white_space_in_argument_print(void);
479518
480519void aux_end1_err_print (void );
481520
482- bool aux_end2_err_print (void );
521+ CResult aux_end2_err_print (void );
483522
484- bool print_bib_name (void );
523+ CResult print_bib_name (void );
485524
486- bool log_pr_bib_name (void );
525+ CResult log_pr_bib_name (void );
487526
488- bool log_pr_bst_name (const Bibtex * ctx );
527+ CResult log_pr_bst_name (const Bibtex * ctx );
489528
490529void hash_cite_confusion (void );
491530
492- bool bst_warn_print (const Bibtex * ctx );
531+ CResult bst_warn_print (const Bibtex * ctx );
493532
494533void eat_bst_print (void );
495534
496535void unknwn_function_class_confusion (void );
497536
498- bool bst_id_print (ScanRes scan_result );
537+ CResult bst_id_print (ScanRes scan_result );
499538
500539void bst_left_brace_print (void );
501540
502541void bst_right_brace_print (void );
503542
504- bool bib_err_print (bool at_bib_command );
543+ CResult bib_err_print (bool at_bib_command );
505544
506- bool bib_warn_print (void );
545+ CResult bib_warn_print (void );
507546
508- bool eat_bib_print (bool at_bib_command );
547+ CResult eat_bib_print (bool at_bib_command );
509548
510- bool bib_one_of_two_print (ASCIICode char1 , ASCIICode char2 , bool at_bib_command );
549+ CResult bib_one_of_two_print (ASCIICode char1 , ASCIICode char2 , bool at_bib_command );
511550
512- bool bib_equals_sign_print (bool at_bib_command );
551+ CResult bib_equals_sign_print (bool at_bib_command );
513552
514- bool bib_unbalanced_braces_print (bool at_bib_command );
515-
516- void macro_warn_print (void );
517-
518- bool bib_id_print (ScanRes scan_res );
553+ CResult bib_id_print (ScanRes scan_res );
519554
520555void bib_cmd_confusion (void );
521556
522557void cite_key_disappeared_confusion (void );
523558
524- bool bad_cross_reference_print (StrNumber s );
559+ CResult bad_cross_reference_print (StrNumber s );
525560
526- bool print_missing_entry (StrNumber s );
561+ CResult print_missing_entry (StrNumber s );
527562
528- bool bst_cant_mess_with_entries_print (const ExecCtx * ctx );
563+ CResult bst_cant_mess_with_entries_print (const ExecCtx * ctx );
529564
530565void bst_1print_string_size_exceeded (void );
531566
532- bool bst_2print_string_size_exceeded (const ExecCtx * ctx );
533-
534- bool braces_unbalanced_complaint (const ExecCtx * ctx , StrNumber pop_lit_var );
567+ CResult bst_2print_string_size_exceeded (const ExecCtx * ctx );
535568
536569void case_conversion_confusion (void );
537570
@@ -541,20 +574,12 @@ CResult bst_err_print_and_look_for_blank_line(Bibtex *ctx);
541574
542575CResult already_seen_function_print (Bibtex * ctx , HashPointer seen_fn_loc );
543576
544- bool nonexistent_cross_reference_error (FieldLoc field_ptr );
577+ CResult nonexistent_cross_reference_error (FieldLoc field_ptr );
545578
546579void output_bbl_line (Bibtex * ctx );
547580
548581HashPointer2 wiz_functions (WizFnLoc pos );
549582
550- void set_wiz_functions (WizFnLoc pos , HashPointer2 val );
551-
552- WizFnLoc wiz_def_ptr (void );
553-
554- void set_wiz_def_ptr (WizFnLoc val );
555-
556- void check_grow_wiz (FnDefLoc ptr );
557-
558583StrNumber field_info (FieldLoc pos );
559584
560585void set_field_info (FieldLoc pos , StrNumber val );
@@ -605,29 +630,50 @@ void bib_set_pool_ptr(PoolPointer ptr);
605630
606631CResultStr bib_make_string (void );
607632
633+ void add_buf_pool (StrNumber p_str );
634+
608635CResultLookup str_lookup (BufTy buf , BufPointer ptr , BufPointer len , StrIlk ilk , bool insert );
609636
610637CResult pre_def_certain_strings (Bibtex * ctx );
611638
639+ void add_out_pool (Bibtex * ctx , StrNumber str );
640+
612641bool scan1 (ASCIICode char1 );
613642
614643bool scan1_white (ASCIICode char1 );
615644
616- bool scan2 (ASCIICode char1 , ASCIICode char2 );
617-
618645bool scan2_white (ASCIICode char1 , ASCIICode char2 );
619646
620- bool scan3 (ASCIICode char1 , ASCIICode char2 , ASCIICode char3 );
621-
622647bool scan_alpha (void );
623648
624- bool scan_white_space (void );
625-
626649ScanRes scan_identifier (ASCIICode char1 , ASCIICode char2 , ASCIICode char3 );
627650
628- bool scan_nonneg_integer (void );
651+ bool eat_bst_white_space (Bibtex * ctx );
652+
653+ CResult scan_fn_def (Bibtex * ctx , HashPointer fn_hash_loc , HashPointer wiz_loc );
654+
655+ CResultBool scan_and_store_the_field_value_and_eat_white (Bibtex * ctx ,
656+ bool store_field ,
657+ bool at_bib_command ,
658+ int32_t command_num ,
659+ CiteNumber * cite_out ,
660+ HashPointer cur_macro_loc ,
661+ ASCIICode right_outer_delim ,
662+ HashPointer field_name_loc );
663+
664+ CResult decr_brace_level (const ExecCtx * ctx , StrNumber pop_lit_var , int32_t * brace_level );
665+
666+ CResult check_brace_level (const ExecCtx * ctx , StrNumber pop_lit_var , int32_t brace_level );
667+
668+ CResult name_scan_for_and (ExecCtx * ctx , StrNumber pop_lit_var , int32_t * brace_level );
669+
670+ CResultBool von_token_found (BufPointer * name_bf_ptr , BufPointer name_bf_xptr );
629671
630- bool scan_integer (int32_t * token_value );
672+ CResult von_name_ends_and_last_name_starts_stuff (BufPointer last_end ,
673+ BufPointer von_start ,
674+ BufPointer * von_end ,
675+ BufPointer * name_bf_ptr ,
676+ BufPointer * name_bf_xptr );
631677
632678#ifdef __cplusplus
633679} // extern "C"
0 commit comments