/* Receive a byte through the virtual link * On error: Throws a Byte Exception */ static u_char link_recv(CPU_t *cpu) { link_t *link = cpu->pio.link; u_char byte = 0; u_int i; for (u_int bit = 0; bit < 8; bit++) { byte >>= 1; for (i = 0; i < LINK_TIMEOUT && vlink(link) == 3; i += LINK_STEP) link_wait(cpu, LINK_STEP); if (vlink(link) == 0) longjmp(exc_byte, LERR_LINK); if (i >= LINK_TIMEOUT) longjmp(exc_byte, LERR_TIMEOUT); link->vout = vlink(link); if (link->vout == 1) byte |= 0x80; for (i = 0; i < LINK_TIMEOUT && vlink(link) == 0; i += LINK_STEP) link_wait(cpu, LINK_STEP); if (i >= LINK_TIMEOUT) longjmp(exc_byte, LERR_TIMEOUT); link->vout = 0; } cpu->pio.link->vlink_recv++; return byte; }
void if_warning(void) { boolean w= false; int i= in_open; base_ptr= input_ptr; input_stack[base_ptr]= cur_input; while(if_stack[i]==cond_ptr){ if(tracing_nesting_par> 0){ while((input_stack[base_ptr].state_field==token_list)|| (input_stack[base_ptr].index_field> i)) decr(base_ptr); if(input_stack[base_ptr].name_field> 17) w= true; } if_stack[i]= vlink(cond_ptr); decr(i); } if(w){ tprint_nl("Warning: end of "); print_cmd_chr(if_test_cmd,cur_if); print_if_line(if_line); tprint(" of a different file"); print_ln(); if(tracing_nesting_par> 1) show_context(); if(history==spotless) history= warning_issued; } }
void short_display_n(int p,int m) { int i= 0; font_in_short_display= null_font; if(p==null) return; while(p!=null){ if(is_char_node(p)){ if(p<=max_halfword){ if(font(p)!=font_in_short_display){ if(!is_valid_font(font(p))) print_char('*'); else print_font_identifier(font(p)); print_char(' '); font_in_short_display= font(p); } print(character(p)); } }else{ if((type(p)==glue_node)|| (type(p)==disc_node)|| (type(p)==penalty_node)|| ((type(p)==kern_node)&&(subtype(p)==explicit_kern|| subtype(p)==italic_kern))){ incr(i); } if(i>=m) return; if(type(p)==disc_node){ print_char('|'); short_display(vlink(pre_break(p))); print_char('|'); short_display(vlink(post_break(p))); print_char('|'); }else{ print_short_node_contents(p); } } p= vlink(p); if(p==null) return; } update_terminal(); }
halfword pop_tail(void) { halfword n, r; if (cur_list.tail_field != cur_list.head_field) { r = cur_list.tail_field; if (vlink(alink(cur_list.tail_field)) == cur_list.tail_field) { n = alink(cur_list.tail_field); } else { n = cur_list.head_field; while (vlink(n) != cur_list.tail_field) n = vlink(n); } cur_list.tail_field = n; alink(r) = null; vlink(n) = null; return r; } else { return null; } }
/* Send a byte through the virtual link * On error: Throws a Byte Exception */ static void link_send(CPU_t *cpu, u_char byte) { link_t *link = cpu->pio.link; u_int i; for (u_int bit = 0; bit < 8; bit++, byte >>= 1) { link->vout = (byte & 1) + 1; for (i = 0; i < LINK_TIMEOUT && vlink(link) != 0; i += LINK_STEP) link_wait(cpu, LINK_STEP); if (i >= LINK_TIMEOUT) longjmp(exc_byte, LERR_TIMEOUT); link->vout = 0; for (i = 0; i < LINK_TIMEOUT && vlink(link) != 3; i += LINK_STEP) link_wait(cpu, LINK_STEP); if (i >= LINK_TIMEOUT) longjmp(exc_byte, LERR_TIMEOUT); } cpu->pio.link->vlink_send++; }
void file_warning(void) { halfword p= save_ptr; int l= cur_level; int c= cur_group; int i; save_ptr= cur_boundary; while(grp_stack[in_open]!=save_ptr){ decr(cur_level); tprint_nl("Warning: end of file when "); print_group(true); tprint(" is incomplete"); cur_group= save_level(save_ptr); save_ptr= save_value(save_ptr); } save_ptr= p; cur_level= (quarterword)l; cur_group= (group_code)c; p= cond_ptr; l= if_limit; c= cur_if; i= if_line; while(if_stack[in_open]!=cond_ptr){ tprint_nl("Warning: end of file when "); print_cmd_chr(if_test_cmd,cur_if); if(if_limit==fi_code) tprint_esc("else"); print_if_line(if_line); tprint(" is incomplete"); if_line= if_line_field(cond_ptr); cur_if= if_limit_subtype(cond_ptr); if_limit= if_limit_type(cond_ptr); cond_ptr= vlink(cond_ptr); } cond_ptr= p; if_limit= l; cur_if= c; if_line= i; print_ln(); if(tracing_nesting_par> 1) show_context(); if(history==spotless) history= warning_issued; }
void short_display(int p) { while(p!=null){ if(is_char_node(p)){ if(lig_ptr(p)!=null){ short_display(lig_ptr(p)); }else{ if(font(p)!=font_in_short_display){ if(!is_valid_font(font(p))) print_char('*'); else print_font_identifier(font(p)); print_char(' '); font_in_short_display= font(p); } print(character(p)); } }else{ print_short_node_contents(p); } p= vlink(p); } }
void do_extension(int immediate) { halfword p; if(cur_cmd==extension_cmd){ switch(cur_chr){ case open_code: p= tail; new_write_whatsit(open_node_size,1); scan_optional_equals(); scan_file_name(); open_name(tail)= cur_name; open_area(tail)= cur_area; open_ext(tail)= cur_ext; if(immediate){ out_what(static_pdf,tail); flush_node_list(tail); tail= p; vlink(p)= null; } break; case write_code: p= tail; new_write_whatsit(write_node_size,0); cur_cs= write_stream(tail); scan_toks(false,false); write_tokens(tail)= def_ref; if(immediate){ out_what(static_pdf,tail); flush_node_list(tail); tail= p; vlink(p)= null; } break; case close_code: p= tail; new_write_whatsit(close_node_size,1); write_tokens(tail)= null; if(immediate){ out_what(static_pdf,tail); flush_node_list(tail); tail= p; vlink(p)= null; } break; case special_code: new_whatsit(special_node); write_stream(tail)= null; p= scan_toks(false,true); write_tokens(tail)= def_ref; break; case immediate_code: get_x_token(); do_extension(1); break; case use_box_resource_code: case use_image_resource_code: case save_box_resource_code: case save_image_resource_code: switch(get_o_mode()){ case OMODE_DVI: do_resource_dvi(immediate,cur_chr); break; case OMODE_PDF: do_resource_pdf(immediate,cur_chr); break; default: break; } break; case dvi_extension_code: if(get_o_mode()==OMODE_DVI) do_extension_dvi(immediate); break; case pdf_extension_code: if(get_o_mode()==OMODE_PDF) do_extension_pdf(immediate); break; default: if(immediate){ back_input(); }else{ confusion("invalid extension"); } break; } }else{ back_input(); } }
void show_activities(void) { /*tex Index into |nest|: */ int p; /*tex The mode: */ int m; /*tex For showing the current page: */ halfword q, r; /*tex Ditto: */ int t; tprint_nl(""); print_ln(); for (p = nest_ptr; p >= 0; p--) { m = nest[p].mode_field; tprint_nl("### "); print_mode(m); tprint(" entered at line "); print_int(abs(nest[p].ml_field)); if (nest[p].ml_field < 0) tprint(" (\\output routine)"); if (p == 0) { /*tex Show the status of the current page */ if (page_head != page_tail) { tprint_nl("### current page:"); if (output_active) tprint(" (held over for next output)"); show_box(vlink(page_head)); if (page_contents > empty) { tprint_nl("total height "); print_totals(); tprint_nl(" goal height "); print_scaled(page_goal); r = vlink(page_ins_head); while (r != page_ins_head) { print_ln(); tprint_esc("insert"); t = subtype(r); print_int(t); tprint(" adds "); if (count(t) == 1000) t = height(r); else t = x_over_n(height(r), 1000) * count(t); print_scaled(t); if (type(r) == split_up_node) { q = page_head; t = 0; do { q = vlink(q); if ((type(q) == ins_node) && (subtype(q) == subtype(r))) incr(t); } while (q != broken_ins(r)); tprint(", #"); print_int(t); tprint(" might split"); } r = vlink(r); } } } if (vlink(contrib_head) != null) tprint_nl("### recent contributions:"); } show_box(vlink(nest[p].head_field)); /*tex Show the auxiliary field, |a|. */ switch (abs(m) / (max_command_cmd + 1)) { case 0: tprint_nl("prevdepth "); if (nest[p].prev_depth_field <= ignore_depth) tprint("ignored"); else print_scaled(nest[p].prev_depth_field); if (nest[p].pg_field != 0) { tprint(", prevgraf "); print_int(nest[p].pg_field); if (nest[p].pg_field != 1) tprint(" lines"); else tprint(" line"); } break; case 1: tprint_nl("spacefactor "); print_int(nest[p].space_factor_field); break; case 2: if (nest[p].incompleat_noad_field != null) { tprint("this will be denominator of:"); show_box(nest[p].incompleat_noad_field); } break; } } }
void tail_append(halfword p) { couple_nodes(cur_list.tail_field, p); cur_list.tail_field = vlink(cur_list.tail_field); }