Ejemplo n.º 1
0
void expand_macros_in_tokenlist(halfword p)
{
int old_mode;
pointer q= get_avail();
pointer r= get_avail();
token_info(q)= right_brace_token+'}';
token_link(q)= r;
token_info(r)= end_write_token;
begin_token_list(q,inserted);
begin_token_list(write_tokens(p),write_text);
q= get_avail();
token_info(q)= left_brace_token+'{';
begin_token_list(q,inserted);


old_mode= mode;
mode= 0;

cur_cs= write_loc;
q= scan_toks(false,true);
get_token();
if(cur_tok!=end_write_token){

const char*hlp[]= {
"On this page there's a \\write with fewer real {'s than }'s.",
"I can't handle that very well; good luck.",NULL
};
tex_error("Unbalanced write command",hlp);
do{
get_token();
}while(cur_tok!=end_write_token);
}
mode= old_mode;
end_token_list();
}
Ejemplo n.º 2
0
int 
read_font_info(pointer u,  strnumber nom, strnumber aire, scaled s,
               integer natural_dir) {
  integer f;
  char *cnom, *caire = NULL;
  char *msg;
  cnom  = xstrdup(makecstring(nom));
  if (aire != 0) 
    caire = xstrdup(makecstring(aire));

  f = new_font();
  if ((f = do_define_font(f, cnom,caire,s,natural_dir))) {
	if (caire != NULL) free(caire);
	free(cnom);
    return f;
  } else {
    char *help[] = {"I wasn't able to read the size data for this font,",
		    "so I will ignore the font specification.",
		    "[Wizards can fix TFM files using TFtoPL/PLtoTF.]",
		    "You might try inserting a different font spec;",
		    "e.g., type `I\font<same font id>=<substitute font name>'.",
		    NULL } ;
	if(!get_suppress_fontnotfound_error()) {
	  msg = font_error_message(u, cnom, s);
	  tex_error(msg,help);
	  free(msg);
	}
	if (caire != NULL) free(caire);
	free(cnom);
    return 0;
  }
}
Ejemplo n.º 3
0
static int 
do_integer_error(double m) {
  char *help[] = {"I can only go up to 2147483647='17777777777=""7FFFFFFF,",
				  "so I'm using that number instead of yours.",   
				  NULL } ;
  tex_error("Number too big",help);
  return (m>0.0 ? infinity : -infinity);
}
Ejemplo n.º 4
0
static void do_extension_dvi(int immediate)
{
if(scan_keyword("literal")){
new_whatsit(special_node);
write_stream(tail)= null;
scan_toks(false,true);
write_tokens(tail)= def_ref;
}else{
tex_error("unexpected use of \\dviextension",null);
}
}
Ejemplo n.º 5
0
static void do_extension_pdf(int immediate)
{
int i;

if(scan_keyword("literal")){
new_whatsit(pdf_literal_node);
if(scan_keyword("direct"))
set_pdf_literal_mode(tail,direct_always);
else if(scan_keyword("page"))
set_pdf_literal_mode(tail,direct_page);
else
set_pdf_literal_mode(tail,set_origin);
scan_toks(false,true);
set_pdf_literal_type(tail,normal);
set_pdf_literal_data(tail,def_ref);
}else if(scan_keyword("dest")){
scan_pdfdest(static_pdf);
}else if(scan_keyword("annot")){
scan_annot(static_pdf);
}else if(scan_keyword("save")){
new_whatsit(pdf_save_node);
}else if(scan_keyword("restore")){
new_whatsit(pdf_restore_node);
}else if(scan_keyword("setmatrix")){
new_whatsit(pdf_setmatrix_node);
scan_toks(false,true);
set_pdf_setmatrix_data(tail,def_ref);
}else if(scan_keyword("obj")){
scan_obj(static_pdf);
if(immediate){
if(obj_data_ptr(static_pdf,pdf_last_obj)==0)
normal_error("pdf backend","\\pdfextension obj 'reserveobjnum' cannot be used with \\immediate");
pdf_write_obj(static_pdf,pdf_last_obj);
}
}else if(scan_keyword("refobj")){
scan_refobj(static_pdf);
}else if(scan_keyword("colorstack")){
scan_int();
if(cur_val>=colorstackused()){
print_err("Unknown color stack number ");
print_int(cur_val);
help3
("Allocate and initialize a color stack with \\pdfextension colorstackinit.",
"I'll use default color stack 0 here.",
"Proceed, with fingers crossed.");
error();
cur_val= 0;
}
if(cur_val<0){
print_err("Invalid negative color stack number");
help2("I'll use default color stack 0 here.",
"Proceed, with fingers crossed.");
error();
cur_val= 0;
}
if(scan_keyword("set"))
i= colorstack_set;
else if(scan_keyword("push"))
i= colorstack_push;
else if(scan_keyword("pop"))
i= colorstack_pop;
else if(scan_keyword("current"))
i= colorstack_current;
else
i= -1;
if(i>=0){
new_whatsit(pdf_colorstack_node);
set_pdf_colorstack_stack(tail,cur_val);
set_pdf_colorstack_cmd(tail,i);
set_pdf_colorstack_data(tail,null);
if(i<=colorstack_data){
scan_toks(false,true);
set_pdf_colorstack_data(tail,def_ref);
}
}else{
print_err("Color stack action is missing");
help3("The expected actions for \\pdfextension colorstack:",
"    set, push, pop, current",
"I'll ignore the color stack command.");
error();
}
}else if(scan_keyword("startlink")){
scan_startlink(static_pdf);
}else if(scan_keyword("endlink")){
if(abs(mode)==vmode)
normal_error("pdf backend","\\pdfextension endlink cannot be used in vertical mode");
new_whatsit(pdf_end_link_node);
}else if(scan_keyword("startthread")){
new_annot_whatsit(pdf_start_thread_node);
scan_thread_id();
}else if(scan_keyword("endthread")){
new_whatsit(pdf_end_thread_node);
}else if(scan_keyword("thread")){
new_annot_whatsit(pdf_thread_node);
scan_thread_id();
}else if(scan_keyword("outline")){
scan_pdfoutline(static_pdf);
}else if(scan_keyword("glyphtounicode")){
glyph_to_unicode();
}else if(scan_keyword("catalog")){
scan_pdfcatalog(static_pdf);
}else if(scan_keyword("fontattr")){





scan_font_ident();
i= cur_val;
if(i==null_font)
normal_error("pdf backend","invalid font identifier");
scan_toks(false,true);
set_pdf_font_attr(i,tokens_to_string(def_ref));
if(str_length(pdf_font_attr(i))==0){
flush_str((str_ptr-1));
set_pdf_font_attr(i,0);
}
}else if(scan_keyword("mapfile")){
scan_toks(false,true);
pdfmapfile(def_ref);
delete_token_ref(def_ref);
}else if(scan_keyword("mapline")){
scan_toks(false,true);
pdfmapline(def_ref);
delete_token_ref(def_ref);
}else if(scan_keyword("includechars")){
pdf_include_chars(static_pdf);
}else if(scan_keyword("info")){
scan_toks(false,true);
pdf_info_toks= concat_tokens(pdf_info_toks,def_ref);
}else if(scan_keyword("names")){
scan_toks(false,true);
pdf_names_toks= concat_tokens(pdf_names_toks,def_ref);
}else if(scan_keyword("trailer")){
scan_toks(false,true);
pdf_trailer_toks= concat_tokens(pdf_trailer_toks,def_ref);
}else{
tex_error("unexpected use of \\pdfextension",null);
}
}