示例#1
0
文件: page.c 项目: syntheticpp/cpptex
void tex::show_page_stats(int b, int pi, int c)
	{
	begin_diagnostic();
	print_nl("%");
	print(" t=");
	print_totals();
	print(" g=");
	print_scaled(page_goal);
	print(" b=");
	if (b == AWFUL_BAD) {
		print_char('*');
		} 
	else {
		print_int(b);
		}
	print(" p=");
	print_int(pi);
	print(" c=");
	if (c == AWFUL_BAD) {
		print("*");
	} else {
		print_int(c);
	}
	if (c <= least_page_cost) {
		print("#");
	}
	end_diagnostic(FALSE);
}
示例#2
0
void tex::flush_discretionary(ptr p)
	{
	begin_diagnostic();
	print_nl("The following discretionary sublist has been deleted:");
	show_box(p);
	end_diagnostic(TRUE);
	flush_node_list(p);
	}
示例#3
0
文件: page.c 项目: syntheticpp/cpptex
void tex::box_error(int n)
	{
	error();
	begin_diagnostic();
	print_nl("The following box has been deleted:");
	show_box(box(n));
	end_diagnostic(TRUE);
	flush_node_list(box(n));
	box(n) = null;
	}
示例#4
0
void group_trace(boolean e)
{
begin_diagnostic();
print_char('{');
if(e)
tprint("leaving ");
else
tprint("entering ");
print_group(e);
print_char('}');
end_diagnostic(false);
}
示例#5
0
void
show_cur_cmd_chr()
{
	begin_diagnostic();
	print_nl("{");
	if (mode != shown_mode) {
		print_mode(mode);
		print(": ");
		shown_mode = mode;
	}
	print_cmd_chr(cur_cmd, cur_chr);
	print("}");
	end_diagnostic(FALSE);
}
示例#6
0
文件: page.c 项目: syntheticpp/cpptex
void tex::freeze_page_specs(int s)
	{
	page_contents = s;
	page_goal = vsize;
	page_max_depth = max_depth;
	page_depth = 0;
	do_all_six(set_page_so_far_zero);
	least_page_cost = AWFUL_BAD;
	if (tracing_pages > 0) {
		begin_diagnostic();
		print_nl("%% goal height=");
		print_scaled(page_goal);
		print(", max depth=");
		print_scaled(page_max_depth);
		end_diagnostic(FALSE);
		}
	}
示例#7
0
文件: page.c 项目: syntheticpp/cpptex
void tex::show_split(int n, scal w, ptr q)
	{
	begin_diagnostic();
	print_nl("% split");
	print_int(n);
	print(" to ");
	print_scaled(w);
	print_char(',');
	print_scaled(best_height_plus_depth);
	print(" p=");
	if (q == null) {
		print_int(EJECT_PENALTY);
	} else if (type(q) == PENALTY_NODE) {
		print_int(penalty(q));
	} else {
		print("0");
	}
	end_diagnostic(FALSE);
	}
示例#8
0
文件: cond.c 项目: syntheticpp/cpptex
void tex::conditional ()
	{
	bool	b=false;
	sym	s;
	int	m, n;
	ptr	p, q, r;
	int	this_if;
	ptr	save_cond_ptr;
	int	save_scanner_status;

	push_cond();
	save_cond_ptr = cond_ptr;
	this_if = cur_chr;
	switch (this_if) {
		case IF_CHAR_CODE:
		case IF_CAT_CODE:
			
#define get_x_token_or_active_char() {get_x_token(); \
	if (cur_cmd == RELAX && cur_chr == NO_EXPAND_FLAG) { \
		cur_cmd = ACTIVE_CHAR; \
		cur_chr = tok2sym(cur_tok) - active_base[0]; }}

		get_x_token_or_active_char();
		if (cur_cmd > ACTIVE_CHAR || cur_chr > 255) {
			m = RELAX;
			n = 256;
			} 
		else {
			m = cur_cmd;
			n = cur_chr;
			}
		get_x_token_or_active_char();
		if (cur_cmd > ACTIVE_CHAR || cur_chr > 255) {
			cur_cmd = RELAX;
			cur_chr = 256;
		}
		if (this_if == IF_CHAR_CODE) {
			b = n == cur_chr;
		} else {
			b = m == cur_cmd;
		}
		break;
	
	case IF_INT_CODE:
	case IF_DIM_CODE:
		if (this_if == IF_INT_CODE) {
			scan_int();
		} else {
			scan_normal_dimen();
		}
		n = cur_val;
		get_nbx_token(); 
		if (cur_tok >= OTHER_TOKEN + '<'
		&& cur_tok <= OTHER_TOKEN + '>') {
			r = cur_tok - OTHER_TOKEN;
		} else {
			print_err("Missing = inserted for ");
			print_cmd_chr(IF_TEST, this_if);
			help_relation();
			back_error();
			r = '=';
		}
		if (this_if == IF_INT_CODE) {
			scan_int();
		} else {
			scan_normal_dimen();
		}
		switch (r) {
		case '<': b = n < cur_val; break;
		case '=': b = n == cur_val; break; 
		case '>': b = n > cur_val; break;
		}
		break;
	
	case IF_ODD_CODE:
		scan_int();
		b = odd(cur_val);
		break;
	
	case IF_VMODE_CODE:
		b = abs(mode) == VMODE;
		break;

	case IF_HMODE_CODE:
		b = abs(mode) == HMODE;
		break;

	case IF_MMODE_CODE:
		b = abs(mode) == MMODE;
		break;
	
	case IF_INNER_CODE:
		b = mode < 0;
		break;
	
	case IF_VOID_CODE:
	case IF_HBOX_CODE:
	case IF_VBOX_CODE:
		scan_eight_bit_int();
		p = box(cur_val);
		if (this_if == IF_VOID_CODE) {
			b = p == null;
		} else if (p == null) {
			b = FALSE;
		} else if (this_if == IF_HBOX_CODE) {
			b = type(p) == HLIST_NODE;
		} else {
			b = type(p) == VLIST_NODE;
		}
		break;

	case IFX_CODE:
		save_scanner_status = scanner_status;
		scanner_status = NORMAL;
		get_next();
		s = cur_cs;
		p = cur_cmd;
		q = cur_chr;
		get_next(); 
		if (cur_cmd != p) {
			b = FALSE;
		} else if (cur_cmd < CALL) {
			b = cur_chr == q;
		} else {
			p = token_link(cur_chr);
			q = token_link(equiv(s));
			if (p == q) {
				b = TRUE;
			} else {
				while (p != null && q != null) {
					if (token(p) != token(q)) {
						p = null;
					} else {
						p = token_link(p);
						q = token_link(q);
					}
				}
				b = p == null && q == null;
			}
		}
		scanner_status = save_scanner_status;
		break;

	case IF_EOF_CODE:
		scan_four_bit_int();
		b = read_open[cur_val] == CLOSED;
		break;
	
	case IF_TRUE_CODE:
		b = TRUE;
		break;

	case IF_FALSE_CODE:
		b = FALSE;
		break;

	case IF_CASE_CODE: 
		scan_int();
		n = cur_val;
		if (tracing_commands > 1) {
			begin_diagnostic();
			print("{case ");
			print_int(n);
			print("}");
			end_diagnostic(FALSE);
		}
		while (n != 0) {
			pass_text();
			if (cond_ptr == save_cond_ptr) {
				if (cur_chr == OR_CODE) {
					decr(n);
				} else {
					goto common_end;
				}
			} else if (cur_chr == FI_CODE) {
				pop_cond();
			}
		}
		change_if_limit(OR_CODE, save_cond_ptr);
		return;
	
	default:
		break;
	}

	if (tracing_commands > 1) {
		begin_diagnostic();
		print(b ? "{true}" : "{false}");
		end_diagnostic(FALSE);
	}

	if (b) {
		change_if_limit(ELSE_CODE, save_cond_ptr);
		return;
	}

	loop {
		pass_text(); 
		if (cond_ptr == save_cond_ptr) {
			if (cur_chr != OR_CODE)
				goto common_end;
			print_err("Extra ");
			print_esc("or");
			help_or();
			error();
		} else if (cur_chr == FI_CODE) {
			pop_cond();
		}
	}

common_end:
	if (cur_chr == FI_CODE) {
		pop_cond();
	} else {
		if_limit = FI_CODE;
	}
}
示例#9
0
void pdf_ship_out (pointer p)
{
  integer page_loc;
  char j, k;

  if (tracing_output > 0)
  {
    print_nl("");
    print_ln();
    prints("Completed box being shipped out");
  }

  if (term_offset > max_print_line - 9)
    print_ln();
  else if ((term_offset > 0) || (file_offset > 0))
    print_char(' ');

  print_char('[');
  j = 9;

  while ((count(j) == 0) && (j > 0))
    decr(j);

  for (k = 0; k <= j; k++)
  {
    print_int(count(k));

    if (k < j)
      print_char('.');
  }

  update_terminal();

  if (tracing_output > 0)
  {
    print_char(']');
    begin_diagnostic();
    show_box(p);
    end_diagnostic(true);
  }

  if ((height(p) > max_dimen) || (depth(p) > max_dimen) ||
      (height(p) + depth(p) + v_offset > max_dimen) ||
      (width(p) + h_offset > max_dimen))
  {
    print_err("Huge page cannot be shipped out");
    help2("The page just created is more than 18 feet tall or",
      "more than 18 feet wide, so I suspect something went wrong.");
    error();

    if (tracing_output <= 0)
    {
      begin_diagnostic();
      print_nl("The following box has been deleted:");
      show_box(p);
      end_diagnostic(true);
    }

    goto done;
  }

  if (height(p) + depth(p) + v_offset > max_v)
    max_v = height(p) + depth(p) + v_offset;

  if (width(p) + h_offset > max_h)
    max_h = width(p) + h_offset;

  dvi_h = 0;
  dvi_v = 0;
  cur_h = h_offset;
  dvi_f = null_font;
  ensure_pdf_open();

  if (total_pages == 0)
  {
    pdf_set_version(5);
    pdf_set_compression(9);
    pdf_init_fontmaps();
    read_config_file("dvipdfmx.cfg");
    pdf_doc_set_producer("Y&YTeX 2.3.0");
    pdf_doc_set_creator("TeX");
    pdf_files_init();
    pdf_init_device(0.000015202, 2, 0);
    // TODO: pdfTeX's page width and height.
    // page_width  = pdf_page_width  != 0 ? <- : width(p)             + 2 * (pdf_h_origin + h_offset);
    // page_height = pdf_page_height != 0 ? <- : height(p) + depth(p) + 2 * (pdf_v_origin + v_offset);
    pdf_open_document(pdf_file_name, 0, 595.0, 842.0, 0, 0, (1 << 4));
    spc_exec_at_begin_document();
  }

  page_loc = dvi_offset + dvi_ptr;
  pdf_doc_begin_page(1.0, 72.0, 770.0);
  spc_exec_at_begin_page();

  last_bop = page_loc;
  cur_v = height(p) + v_offset;
  temp_ptr = p;

  if (type(p) == vlist_node)
    pdf_vlist_out();
  else
    pdf_hlist_out();

  spc_exec_at_end_page();
  pdf_doc_end_page();
  incr(total_pages);
  cur_s = -1;

done:
  if (tracing_output <= 0)
    print_char(']');

  dead_cycles = 0;
  update_terminal();

#ifdef STAT
  if (tracing_stats > 1)
  {
    print_nl("Memory usage before: ");
    print_int(var_used);
    print_char('&');
    print_int(dyn_used);
    print_char(';');
  }
#endif

  flush_node_list(p);

#ifdef STAT
  if (tracing_stats > 1)
  {
    prints(" after: ");
    print_int(var_used);
    print_char('&');
    print_int(dyn_used);
    prints("; still utouched: ");
    print_int(hi_mem_min - lo_mem_max - 1);
    print_ln();
  }
#endif
}