6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
13 #pragma warning(disable:4996)
14 #pragma warning(disable:4131) // old style declarator
15 #pragma warning(disable:4135) // conversion between different integral types
16 #pragma warning(disable:4127) // conditional expression is constant
24 #pragma warning(disable:4244) /* 96/Jan/10 */
26 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
41 } while(!(cur_cmd != 10));
44 negative = ! negative;
47 } while(!(cur_tok != 3115));
57 else decr(align_state);
59 /* else if cur_tok<cs_token_flag+single_base then ... */
60 else if(cur_tok < 4352) /* 4095 + 257 */
61 /* cur_val:=cur_tok-cs_token_flag-active_base */
62 cur_val = cur_tok - 4096; /* 4095 + 1 */
63 /* else cur_val:=cur_tok-cs_token_flag-single_base; */
64 else cur_val = cur_tok - 4352; /* 4095 + 257 */
67 print_err("Improper alphabetic constant");
68 help2("A one-character control sequence belongs after a ` mark.",
69 "So I'm essentially inserting \\0 here.");
79 else if((cur_cmd >= 68)&&(cur_cmd <= 89)) {
80 scan_something_internal(0, false);
84 /* begin radix:=10; m:=214748364; l.8734 */
86 m = 214748364L; /* 7FFFFFFF hex */
90 m = 268435456L; /* 2^28 */
93 else if(cur_tok == 3106)
96 m = 134217728L; /* 2^27 8000000 hex */
102 if((cur_tok < 3120 + radix)&&(cur_tok >= 3120)&&(cur_tok <= 3129
106 if((cur_tok <= 2886)&&(cur_tok >= 2881))
108 else if((cur_tok <= 3142)&&(cur_tok >= 3137))
113 if((cur_val >= m)&&((cur_val > m)||(d > 7)||(radix != 10)
118 print_err("Number too big");
119 help2("I can only go up to 2147483647='17777777777=\"7FFFFFFF,",
120 "so I'm using that number instead of yours.");
122 cur_val = 2147483647L; /* 7FFFFFFF hex */
126 else cur_val = cur_val * radix + d;
132 print_err("Missing number, treated as zero");
133 help3("A number should have been here; I inserted `0'.",
134 "(If you can't figure out why I needed to see a number,",
135 "look up `weird error' in the index to The TeXbook.)");
138 else if(cur_cmd != 10)
142 cur_val = - (integer) cur_val;
144 void scan_dimen_(bool mu, bool inf, bool shortcut)
145 {/* 30 31 32 40 45 88 89 */
163 } while(!(cur_cmd != 10));
166 negative = ! negative;
169 } while(!(cur_tok != 3115));
170 if((cur_cmd >= 68)&&(cur_cmd <= 89))
173 scan_something_internal(3, false);
174 if(cur_val_level >= 2){
175 v = mem[cur_val + 1].cint;
176 delete_glue_ref(cur_val);
179 if(cur_val_level == 3)
181 if(cur_val_level != 0){
186 scan_something_internal(1, false);
187 if(cur_val_level == 1)goto lab89;
204 if((radix == 10)&&(cur_tok == 3118))
207 p = 0; /* p:=null l.8883 */
211 if((cur_tok > 3129)||(cur_tok < 3120))
217 mem[q].hh.v.LH = cur_tok - 3120;
223 register integer for_end; kk = k; for_end = 1; if(kk >=
226 /* long to char ... */
227 dig[kk - 1]= mem[p].hh.v.LH;
231 mem[q].hh.v.RH = avail;
239 while(kk-- > for_end); }
240 f = round_decimals(k);
248 negative = ! negative;
249 cur_val = - (integer) cur_val;
252 if(scan_keyword(309)) /* fil */
255 while(scan_keyword(108)) { /* l */
258 print_err("Illegal unit of measure(");
259 print_string("replaced by filll)");
260 help1("I dddon't go any higher than filll.");
263 else incr(cur_order);
267 savecurval = cur_val;
270 } while(!(cur_cmd != 10));
271 if((cur_cmd < 68)||(cur_cmd > 89))
277 scan_something_internal(3, false);
278 if(cur_val_level >= 2){
279 v = mem[cur_val + 1].cint;
280 delete_glue_ref(cur_val);
283 if(cur_val_level != 3){
288 scan_something_internal(1, false);
295 if(scan_keyword(705)) /* em */
296 v =(font_info[6 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint);
297 else if(scan_keyword(706)) /* ex */
298 v =(font_info[5 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint);
302 if(cur_cmd != 10) back_input ();
304 lab40: cur_val = mult_and_add(savecurval, v, xn_over_d(v, f, 65536L),
305 1073741823L); /* 2^30 - 1 */
309 if(scan_keyword(334)) /* mu */
312 print_err("Illegal unit of measure(");
313 print_string("mu inserted)");
314 help4("The unit of measurement in math glue must be mu.",
315 "To recover gracefully from this error, it's best to",
316 "delete the erroneous units; e.g., type `2' to delete",
317 "two letters. (See Chapter 27 of The TeXbook.)");
321 if(scan_keyword(701)) /* true */
324 if(eqtb[(hash_size + 3180)].cint != 1000)
326 cur_val = xn_over_d(cur_val, 1000, eqtb[(hash_size + 3180)].cint);
327 f =(1000 * f + 65536L * tex_remainder)/
328 eqtb[(hash_size + 3180)].cint;
329 cur_val = cur_val +(f / 65536L);
330 /* cur_val = cur_val +(f >> 16); */ /* f positive ??? */
332 /* f = f & 65535L; */ /* f positive ??? */
335 if(scan_keyword(394)) /* pt */
337 if(scan_keyword(712)) /* in */
342 else if(scan_keyword(713)) /* pc */
347 else if(scan_keyword(714)) /* cm */
352 else if(scan_keyword(715)) /* mm */
357 else if(scan_keyword(716)) /* bp */
362 else if(scan_keyword(717)) /* dd */
367 else if(scan_keyword(718)) /* cc */
369 num = 14856; /* numerator */
370 denom = 1157; /* denominator */
372 else if(scan_keyword(719)) /* sp */
375 print_err("Illegal unit of measure(");
376 print_string("pt inserted)");
377 help6("Dimensions can be in units of em, ex, in, pt, pc,",
378 "cm, mm, dd, cc, bp, or sp; but yours is a new one!",
379 "I'll assume that you meant to say pt, for printer's points.",
380 "To recover gracefully from this error, it's best to",
381 "delete the erroneous units; e.g., type `2' to delete",
382 "two letters. (See Chapter 27 of The TeXbook.)");
386 cur_val = xn_over_d(cur_val, num, denom);
387 f =(num * f + 65536L * tex_remainder)/ denom;
388 cur_val = cur_val +(f / 65536L);
389 /* cur_val = cur_val +(f >> 16); */ /* f positive ??? */
391 /* f = f & 65535L; */ /* f positive ??? */
393 lab88: if(cur_val >= 16384) /* 2^14 */
395 else cur_val = cur_val * 65536L + f;
396 /* else cur_val = cur_val << 16 + f; */ /* f positive ?? */
400 if(cur_cmd != 10) back_input ();
403 if(arith_error ||(abs(cur_val)>= 1073741824L)) /* 2^30 */
405 print_err("Dimension too large");
406 help2("I can't work with sizes bigger than about 19 feet.",
407 "Continue and I'll use the largest value I can.");
409 cur_val = 1073741823L; /* 2^30 - 1 */
413 cur_val = - (integer) cur_val;
415 void scan_glue_(small_number level)
425 } while(!(cur_cmd != 10));
428 negative = ! negative;
431 } while(!(cur_tok != 3115));
432 if((cur_cmd >= 68)&&(cur_cmd <= 89))
434 scan_something_internal(level, negative);
435 if(cur_val_level >= 2){
436 if(cur_val_level != level){
441 if(cur_val_level == 0){
442 scan_dimen(mu, false, true);
450 scan_dimen(mu, false, false);
451 if(negative)cur_val = - (integer) cur_val;
454 mem[q + 1].cint = cur_val;
455 if(scan_keyword(727)) /* plus */
457 scan_dimen(mu, true, false);
458 mem[q + 2].cint = cur_val;
459 mem[q].hh.b0 = cur_order;
461 if(scan_keyword(728)) /* minus */
463 scan_dimen(mu, true, false);
464 mem[q + 3].cint = cur_val;
465 mem[q].hh.b1 = cur_order;
469 halfword scan_rule_spec (void)
470 {/* 21 */ register halfword Result;
473 /* if cur_cmd=vrule then width(q):=default_rule */
474 /* @d default_rule=26214 {0.4\thinspace pt} */
475 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
476 if(cur_cmd == 35) /* cur_cmd == vrule */
477 /* mem[q + 1].cint = 26214; */ /* width := 0.4pt */
478 mem[q + 1].cint = default_rule; /* 95/Oct/9 */
481 /* mem[q + 3].cint = 26214; */ /* height := 0.4pt */
482 mem[q + 3].cint = default_rule; /* 95/Oct/9 */
483 mem[q + 2].cint = 0; /* depth := 0.0pt */
485 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
486 lab21: if(scan_keyword(729)) /* width */
488 scan_dimen(false, false, false);
489 mem[q + 1].cint = cur_val;
492 if(scan_keyword(730)) /* height */
494 scan_dimen(false, false, false);
495 mem[q + 3].cint = cur_val;
498 if(scan_keyword(731)) /* depth */
500 scan_dimen(false, false, false);
501 mem[q + 2].cint = cur_val;
507 halfword str_toks_(pool_pointer b)
508 {register halfword Result;
514 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
515 #ifdef ALLOCATESTRING
516 if(pool_ptr + 1 > current_pool_size)
517 str_pool = realloc_str_pool (increment_pool_size);
518 if(pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/22 */
519 overflow(257, current_pool_size - init_pool_ptr); /* 97/Mar/7 */
520 return 0; // abort_flag set
523 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
524 if(pool_ptr + 1 > pool_size){
525 overflow(257, pool_size - init_pool_ptr); /* pool size */
526 return; // abort_flag set
531 mem[p].hh.v.RH = 0; /* link(p):=null l.9135 */
546 avail = mem[q].hh.v.RH;
564 halfword the_toks (void)
565 {register halfword Result;
570 scan_something_internal(5, false);
571 if(cur_val_level >= 4)
575 if(cur_val_level == 4)
579 mem[q].hh.v.LH = 4095 + cur_val;
582 else if(cur_val != 0)/* else if cur_val<>null then l.9176 */
584 r = mem[cur_val].hh.v.RH;
585 while(r != 0){ /* while r<>null do l.9178 */
594 avail = mem[q].hh.v.RH;
603 mem[q].hh.v.LH = mem[r].hh.v.LH;
613 old_setting = selector;
616 switch(cur_val_level)
622 print_scaled(cur_val);
628 print_spec(cur_val, 394); /* pt */
629 delete_glue_ref(cur_val);
634 print_spec(cur_val, 334); /* mu */
635 delete_glue_ref(cur_val);
639 selector = old_setting;
640 Result = str_toks(b);
644 void ins_the_toks (void)
646 mem[mem_top - 12].hh.v.RH = the_toks ();
647 begin_token_list(mem[mem_top - 3].hh.v.RH, 4);
649 void conv_toks (void)
653 small_number savescannerstatus;
666 savescannerstatus = scanner_status;
669 scanner_status = savescannerstatus;
676 if(job_name == 0)open_log_file ();
679 old_setting = selector;
687 print_roman_int(cur_val);
692 else print_char(cur_chr);
699 print(font_name[cur_val]);
700 if(font_size[cur_val]!= font_dsize[cur_val])
703 print_scaled(font_size[cur_val]);
712 selector = old_setting;
713 mem[mem_top - 12].hh.v.RH = str_toks(b);
714 begin_token_list(mem[mem_top - 3].hh.v.RH, 4);
716 halfword scan_toks_(bool macrodef, bool xpand)
717 {/* 40 30 31 32 */ register halfword Result;
726 else scanner_status = 5;
727 warning_index = cur_cs;
728 def_ref = get_avail ();
729 mem[def_ref].hh.v.LH = 0;
749 mem[q].hh.v.LH = cur_tok;
755 mem[q].hh.v.LH = 3584;
762 print_err("You already have nine parameters");
763 help1("I'm going to ignore the # sign you just used.");
771 print_err("Parameters must be numbered consecutively");
772 help2("I've inserted the digit you should have used after the #.",
773 "Type `1' to delete what you did use.");
782 mem[q].hh.v.LH = cur_tok;
790 mem[q].hh.v.LH = 3584;
795 print_err("Missing { inserted");
797 help2("Where was the left brace? You said something like `\\def\\a}',",
798 "which I'm going to interpret as `\\def\\a{}'.");
812 if(cur_cmd <= 100) goto lab32;
819 /* if link(temp_head)<>null then l.9376 */
820 if(mem[mem_top - 3].hh.v.RH != 0)
822 mem[p].hh.v.RH = mem[mem_top - 3].hh.v.RH;
832 if(cur_cmd < 2) incr(unbalance);
838 else if(cur_cmd == 6)
841 if(xpand)get_x_token ();
844 if((cur_tok <= 3120)||(cur_tok > t)) {
845 print_err("Illegal parameter number in definition of");
846 sprint_cs(warning_index);
847 help3("You meant to type ## instead of #, right?",
848 "Or maybe a } was forgotten somewhere earlier, and things",
849 "are all screwed up? I'm going to assume that you meant ##.");
853 else cur_tok = 1232 + cur_chr;
858 mem[q].hh.v.LH = cur_tok;
862 lab40: scanner_status = 0;
867 mem[q].hh.v.LH = hashbrace;
873 /* used only in ITEX.C */
874 void read_toks_(integer n, halfword r)
879 /* small_number m; */
880 int m; /* 95/Jan/7 */
883 def_ref = get_avail ();
884 mem[def_ref].hh.v.LH = 0;
889 mem[q].hh.v.LH = 3584;
892 if((n < 0)||(n > 15)) m = 16;
895 align_state = 1000000L;
897 begin_file_reading ();
898 cur_input.name_field = m + 1;
918 fatal_error("*** (cannot \\read from terminal in nonstop modes)"); /* */
919 return; // abort_flag set
921 else if(read_open[m]== 1)
922 if(input_ln(read_file[m], false))
925 (void) a_close(read_file[m]);
929 if(! input_ln(read_file[m], true)) {
930 (void) a_close(read_file[m]);
932 if(align_state != 1000000L) {
934 print_err("File ended within");
936 help1("This \\read has unbalanced braces.");
937 align_state = 1000000L;
942 cur_input.limit_field = last;
943 if((eqtb[(hash_size + 3211)].cint < 0)||(eqtb[(hash_size + 3211)].cint > 255))
944 decr(cur_input.limit_field);
945 /* long to unsigned char ... */
946 else buffer[cur_input.limit_field]= eqtb[(hash_size + 3211)].cint;
947 first = cur_input.limit_field + 1;
948 cur_input.loc_field = cur_input.start_field;
949 cur_input.state_field = 33;
954 if(align_state < 1000000L)
958 } while(!(cur_tok == 0));
959 align_state = 1000000L;
965 mem[q].hh.v.LH = cur_tok;
969 lab30: end_file_reading ();
970 } while(!(align_state == 1000000L));
975 void pass_text (void)
978 small_number savescannerstatus;
979 savescannerstatus = scanner_status;
986 if(l == 0) goto lab30;
990 else if(cur_cmd == 105) incr(l);
992 lab30: scanner_status = savescannerstatus;
994 void change_if_limit_(small_number l, halfword p)
1002 if(q == 0) { /* begin if q=null then confusion("if"); l.9674 */
1003 confusion(753); /* if */
1004 return; // abort_flag set
1006 if(mem[q].hh.v.RH == p)
1015 /* called from tex2.c */
1016 void conditional (void)
1022 small_number savescannerstatus;
1023 halfword savecondptr;
1024 small_number thisif;
1027 /* begin p:=get_node(if_node_size); */
1028 p = get_node(2); /* p <- get_node(if_node_size); p.495*/
1029 /* link(p):=cond_ptr; */
1030 mem[p].hh.v.RH = cond_ptr;
1031 /* type(p):=if_limit; */
1032 mem[p].hh.b0 = if_limit;
1033 /* subtype(p):=cur_if; */
1034 mem[p].hh.b1 = cur_if;
1035 /* if_line_field(p):=if_line; */
1036 mem[p + 1].cint = if_line;
1042 savecondptr = cond_ptr; /* save_cond_ptr <- cond_ptr; p.498 */
1050 if(cur_cmd == 0) /* if cur_cmd = relax then .. p.506 */
1051 if(cur_chr == 257) /* if cur_chr = no_expand_flag then ... p.506 */
1054 cur_chr = cur_tok - 4096;
1057 if((cur_cmd > 13)||(cur_chr > 255))
1069 if(cur_cmd == 0) /* if cur_cmd = relax then .. p.506 */
1070 if(cur_chr == 257) /* if cur_chr = no_expand_flag then ... p.506 */
1073 cur_chr = cur_tok - 4096;
1076 if((cur_cmd > 13)||(cur_chr > 255))
1083 else b =(m == cur_cmd);
1093 scan_dimen(false, false, false);
1098 } while(!(cur_cmd != 10));
1099 if((cur_tok >= 3132)&&(cur_tok <= 3134))
1102 print_err("Missing = inserted for ");
1103 print_cmd_chr(105, thisif); /* i */
1104 help1("I was expecting to see `<', `=', or `>'. Didn't.");
1112 scan_dimen(false, false, false);
1137 b =(abs(mode)== 102);
1140 b =(abs(mode)== 203);
1149 scan_eight_bit_int ();
1150 p = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
1155 else if(thisif == 10)
1156 b =(mem[p].hh.b0 == 0);
1157 else b =(mem[p].hh.b0 == 1);
1162 savescannerstatus = scanner_status;
1169 if(cur_cmd != p) b = false;
1170 else if(cur_cmd < 111) b =(cur_chr == q);
1173 p = mem[cur_chr].hh.v.RH;
1174 q = mem[eqtb[n].hh.v.RH].hh.v.RH;
1178 /* else begin while (p<>null)and(q<>null) do l.9840 */
1179 while((p != 0)&&(q != 0)) if(mem[p].hh.v.LH != mem[
1181 p = 0; /* p:=null */
1187 b =((p == 0)&&(q == 0)); /* b:=((p=null)and(q=null)); */
1190 scanner_status = savescannerstatus;
1195 scan_four_bit_int ();
1196 b =(read_open[cur_val]== 2);
1209 if(eqtb[(hash_size + 3199)].cint > 1)
1211 begin_diagnostic ();
1212 print_string("{case ");
1214 print_char(125); /* } */
1215 end_diagnostic(false);
1220 if(cond_ptr == savecondptr)
1224 else if(cur_chr == 2)
1227 if_line = mem[p + 1].cint;
1228 cur_if = mem[p].hh.b1;
1229 if_limit = mem[p].hh.b0;
1230 cond_ptr = mem[p].hh.v.RH;
1234 change_if_limit(4, savecondptr);
1239 if(eqtb[(hash_size + 3199)].cint > 1)
1241 begin_diagnostic ();
1243 print_string("{true}");
1244 else print_string("{false}");
1245 end_diagnostic(false);
1247 if(b) /* b may be used without ... */
1249 change_if_limit(3, savecondptr);
1254 if(cond_ptr == savecondptr)
1258 print_err("Extra ");
1260 help1("I'm ignoring this; it doesn't match any \\if.");
1263 else if(cur_chr == 2)
1266 if_line = mem[p + 1].cint;
1267 cur_if = mem[p].hh.b1;
1268 if_limit = mem[p].hh.b0;
1269 cond_ptr = mem[p].hh.v.RH;
1273 lab50: if(cur_chr == 2)
1276 if_line = mem[p + 1].cint;
1277 cur_if = mem[p].hh.b1;
1278 if_limit = mem[p].hh.b0;
1279 cond_ptr = mem[p].hh.v.RH;
1284 void begin_name (void)
1286 area_delimiter = 0; /* index between `file area' and `file name' */
1287 ext_delimiter = 0; /* index between `file name' and `file extension' */
1289 /* This gathers up a file name and makes a string of it */
1290 /* Also tries to break it into `file area' `file name' and `file extension' */
1291 /* Used by scan_file_name and prompt_file_name */
1292 /* We assume tilde has been converted to pseudo_tilde and space to pseudo_space */
1293 /* returns false if it is given a space character - end of file name */
1294 bool more_name_(ASCII_code c)
1295 {register bool Result;
1297 /* if(c == 32)*/ /* white space delimits file name ... */
1298 if (quoted_file_name == 0 && c == 32)
1300 else if (quoted_file_name != 0 && c == '"') {
1301 quoted_file_name = 0; /* catch next space character */
1302 Result = true; /* accept ending quote, but throw away */
1305 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1306 /* convert pseudo tilde back to '~' 95/Sep/26 */ /* moved here 97/June/5 */
1307 /* if (pseudo_tilde != 0 && c == pseudo_tilde) c = '~'; */
1308 /* convert pseudo space back to ' ' 97/June/5 */ /* moved here 97/June/5 */
1309 /* if (pseudo_space != 0 && c == pseudo_space) c = ' '; */
1310 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1312 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1313 #ifdef ALLOCATESTRING
1314 if(pool_ptr + 1 > current_pool_size)
1315 str_pool = realloc_str_pool (increment_pool_size);
1316 if(pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
1317 overflow(257, current_pool_size - init_pool_ptr); /* 97/Mar/7 */
1318 return 0; // abort_flag set
1321 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1322 if(pool_ptr + 1 > pool_size){
1323 overflow(257, pool_size - init_pool_ptr); /* pool size */
1324 return 0; // abort_flag set
1329 str_pool[pool_ptr]= c;
1332 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1333 // if((c == 47)) /* / */
1335 if((c == '/' || c == '\\' || c == ':')) /* 94/Mar/1 */
1336 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1338 area_delimiter =(pool_ptr - str_start[str_ptr]);
1341 else if(c == 46) /* . */
1342 ext_delimiter =(pool_ptr - str_start[str_ptr]);
1347 /******************************** 2000 August 15th start ***********************/
1349 // The following code is to save string space used by TeX for filenames
1350 // Not really critical in a system that has dynamic memory allocation
1351 // And may slow it down slightly - although this linear search only
1352 // occurs when opening a file, which is somewhat slow inany case...
1354 // see if string from str_pool[start] to str_pool[end]
1355 // occurs elsewhere in string pool - returns string number
1356 // returns -1 if not found in string pool 2000 Aug 15
1358 int find_string (int start, int end)
1360 int k, nlen=end-start;
1363 // int trace_flag = 1; // debugging only
1366 sprintf(log_line, "\nLOOKING for string (str_ptr %d nlen %d) ", str_ptr, end-start);
1367 s = log_line + strlen(log_line);
1368 strncpy(s, str_pool+start, nlen);
1370 show_line(log_line, 0);
1373 // avoid problems with(cur_name == flushablestring)by going only up to str_ptr-1
1374 // code in new_font (tex8.c) will take care of reuse of font name already
1375 // for (k = 0; k < str_ptr; k++) {
1376 for (k = 0; k < str_ptr-1; k++) {
1377 if ((str_start[k+1] - str_start[k]) != nlen) continue;
1378 if (strncmp(str_pool+start, str_pool+str_start[k], nlen) == 0) {
1380 sprintf(log_line, "\nFOUND the string %d (%d) ", k, str_start[k+1]-str_start[k]);
1381 s = log_line + strlen(log_line);
1382 strncpy(s, str_pool+start, nlen);
1383 strcpy(s+nlen, "\n");
1384 show_line(log_line, 0);
1386 return k; // return number of matching string
1390 sprintf(log_line, "\nNOT FOUND string ");
1391 s = log_line + strlen(log_line);
1392 strncpy(s, str_pool+start, nlen);
1393 strcpy(s+nlen, "\n");
1394 show_line(log_line, 0);
1396 return -1; // no match found
1399 // snip out the string from str_pool[start] to str_pool[end]
1400 // and move everything above it down 2000 Aug 15
1402 void remove_string (int start, int end)
1404 int nlen = pool_ptr - end; // how many bytes to move down
1407 // int trace_flag=1; // debugging only
1408 // if (end < start) show_line("\nEND < START", 1);
1409 // if (pool_ptr < end) show_line("\nPOOLPTR < END", 1);
1413 sprintf(log_line, "\nSTRIPPING OUT %d %d ", n, nlen);
1414 s = log_line + strlen(log_line);
1415 strncpy(s, str_pool+start, n);
1417 show_line(log_line, 0);
1419 if (nlen > 0) memcpy(str_pool+start, str_pool+end, nlen);
1420 pool_ptr = start + nlen; // poolprt - (end-start);
1423 void show_string (int k)
1425 int nlen = str_start[k+1] - str_start[k];
1428 sprintf(log_line, "\nSTRING %5d (%3d) %5d--%5d ",
1429 k, nlen, str_start[k], str_start[k+1]);
1430 s = log_line + strlen(log_line);
1431 strncpy(s, str_pool+str_start[k], nlen);
1432 strcpy(s + nlen, "");
1433 show_line(log_line, 0);
1436 void show_all_strings (void)
1439 for (k = 0; k < str_ptr; k++) show_string(k);
1442 // int notfirst=0; // debugging only
1444 /********************************** 2000 August 15 end ****************************/
1446 void end_name (void)
1448 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1449 #ifdef ALLOCATESTRING
1450 if(str_ptr + 3 > current_max_strings)
1451 /* str_start = realloc_str_start(increment_max_strings); */
1452 str_start = realloc_str_start(increment_max_strings + 3);
1453 if(str_ptr + 3 > current_max_strings){ /* in case it failed 94/Jan/24 */
1454 overflow(258, current_max_strings - init_str_ptr); /* 97/Mar/7 */
1455 return; // abort_flag set
1458 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1459 if(str_ptr + 3 > max_strings){
1460 overflow(258, max_strings - init_str_ptr); /* number of strings */
1461 return; // abort_flag set
1465 // if (notfirst++ == 0) show_all_strings(); // debugging only
1467 if(area_delimiter == 0) // no area delimiter ':' '/' or '\' found
1468 cur_area = 335; // "" default area
1470 if (save_strings_flag &&
1471 (cur_area = find_string(str_start[str_ptr], str_start[str_ptr]+area_delimiter)) > 0) {
1472 remove_string(str_start[str_ptr], str_start[str_ptr] + area_delimiter);
1473 area_delimiter = 0; // area_delimiter - area_delimiter;
1474 if (ext_delimiter != 0) ext_delimiter = ext_delimiter - area_delimiter;
1475 // str_start[str_ptr + 1]= str_start[str_ptr]+ area_delimiter; // test only
1476 // incr(str_ptr); // test only
1478 else { // carve out string for "cur_area"
1480 str_start[str_ptr + 1]= str_start[str_ptr]+ area_delimiter;
1484 if(ext_delimiter == 0){ // no extension delimiter '.' found
1485 cur_ext = 335; // "" default extension
1486 if (save_strings_flag &&
1487 (cur_name = find_string(str_start[str_ptr], pool_ptr)) > 0) {
1488 remove_string(str_start[str_ptr], pool_ptr);
1489 // (void) make_string (); // test only
1491 else // Make string from str_start[str_ptr]to pool_ptr
1492 cur_name = make_string ();
1494 else { // did find an extension
1495 if (save_strings_flag &&
1496 (cur_name = find_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter-1)) > 0) {
1497 remove_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter - 1);
1498 // str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1; // test only
1499 // incr(str_ptr); // test only
1501 else { // carve out string for "cur_name"
1503 str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1;
1506 if (save_strings_flag &&
1507 (cur_ext = find_string(str_start[str_ptr], pool_ptr)) > 0) {
1508 remove_string(str_start[str_ptr], pool_ptr);
1509 // (void) make_string (); // test only
1511 else // Make string from str_start[str_ptr]to pool_ptr
1512 cur_ext = make_string ();
1516 /* n current name, a current area, e current extension */
1517 /* result in name_of_file[] */
1519 void pack_file_name_(str_number n, str_number a, str_number e)
1525 {register integer for_end; j = str_start[a];
1526 for_end = str_start[a + 1]- 1; if(j <= for_end) do
1531 name_of_file[k]= xchr[c];
1533 while(j++ < for_end); }
1534 {register integer for_end; j = str_start[n];
1535 for_end = str_start[n + 1]- 1; if(j <= for_end) do
1540 name_of_file[k]= xchr[c];
1542 while(j++ < for_end); }
1543 {register integer for_end; j = str_start[e];
1544 for_end = str_start[e + 1]- 1; if(j <= for_end) do
1549 name_of_file[k]= xchr[c];
1551 while(j++ < for_end); }
1552 if(k < PATHMAX)name_length = k;
1553 else name_length = PATHMAX - 1;
1554 /* pad it out with spaces ... what for ? in case we modify and forget ? */
1555 {register integer for_end; k = name_length + 1; for_end = PATHMAX;
1556 if(k <= for_end) do name_of_file[k]= ' ';
1557 while(k++ < for_end); }
1558 name_of_file[PATHMAX]= '\0'; /* paranoia 94/Mar/24 */
1560 name_of_file [name_length+1] = '\0';
1562 sprintf(log_line, " pack_file_name `%s' (%d) ",
1563 name_of_file+1, name_length); /* debugging */
1564 show_line(log_line, 0);
1566 name_of_file [name_length+1] = ' ';
1570 /* Called only from two places tex9.c for format name - specified and default */
1571 /* for specified format name args are 0, a, b name in buffer[a] --- buffer[b] */
1572 /* for default args are format_default_length-4, 1, 0 */
1573 void pack_buffered_name_(small_number n, integer a, integer b)
1578 if(n + b - a + 5 > PATHMAX)
1579 b = a + PATHMAX - n - 5;
1581 /* This loop kicks in when we want the default format name */
1582 {register integer for_end; j = 1; for_end = n; if(j <= for_end) do
1584 c = xord[TEX_format_default[j]];
1587 name_of_file[k]= xchr[c];
1589 while(j++ < for_end); }
1590 /* This loop kicks in when we want a specififed format name */
1591 {register integer for_end; j = a; for_end = b; if(j <= for_end) do
1596 name_of_file[k]= xchr[c];
1598 while(j++ < for_end); }
1599 /* This adds the extension from the default format name */
1600 {register integer for_end; j = format_default_length - 3; for_end =
1601 format_default_length; if(j <= for_end) do
1603 c = xord[TEX_format_default[j]];
1606 name_of_file[k]= xchr[c];
1608 while(j++ < for_end); }
1611 else name_length = PATHMAX - 1;
1612 /* pad it out with spaces ... what for ? */
1613 {register integer for_end; k = name_length + 1; for_end = PATHMAX; if(k
1615 name_of_file[k]= ' ';
1616 while(k++ < for_end); }
1617 name_of_file[PATHMAX]= '\0'; /* paranoia 94/Mar/24 */
1620 str_number make_name_string (void)
1621 {register str_number Result;
1623 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1624 #ifdef ALLOCATESTRING
1625 if(pool_ptr + name_length > current_pool_size)
1626 /* str_pool = realloc_str_pool (increment_pool_size); */
1627 str_pool = realloc_str_pool (increment_pool_size + name_length);
1628 if(str_ptr == current_max_strings)
1629 str_start = realloc_str_start(increment_max_strings);
1630 if((pool_ptr + name_length > current_pool_size)||
1631 (str_ptr == current_max_strings)||
1632 ((pool_ptr - str_start[str_ptr])> 0))
1634 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1635 if((pool_ptr + name_length > pool_size)||(str_ptr == max_strings)||
1636 ((pool_ptr - str_start[str_ptr])> 0))
1641 {register integer for_end; k = 1; for_end = name_length; if(k <= for_end) do
1643 str_pool[pool_ptr]= xord[name_of_file[k]];
1644 // sprintf(log_line, "%d => %d ", name_of_file[k], xord[name_of_file[k]]);
1645 // show_line(log_line, 0); // debugging only
1648 while(k++ < for_end); }
1649 Result = make_string ();
1654 str_number a_make_name_string_(alpha_file * f)
1655 {register str_number Result;
1656 Result = make_name_string ();
1658 } /* f unreferenced ? bkph */
1660 str_number b_make_name_string_(byte_file * f)
1661 {register str_number Result;
1662 Result = make_name_string ();
1664 } /* f unreferenced ? bkph */
1666 str_number w_make_name_string_(word_file * f)
1667 {register str_number Result;
1668 Result = make_name_string ();
1670 } /* f unreferenced ? bkph */
1672 /* Used by start_input to scan file name on command line */
1673 /* Also in tex8.c new_font_, open_or_close_in, and do_extension */
1675 void scan_file_name (void)
1677 name_in_progress = true;
1681 } while(!(cur_cmd != 10)); /* until cur_cmd != spacer */
1682 quoted_file_name = 0; /* 98/March/15 */
1683 if (allow_quoted_names) { /* check whether quoted name */
1684 if(cur_chr == '"') {
1685 quoted_file_name = 1;
1690 if((cur_cmd > 12)||(cur_chr > 255))
1691 { /* (cur_cmd > otherchar) OR (cur_chr > 255) */
1692 back_input (); /* not a character put it back and leave */
1695 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1696 /* convert tilde '~' to pseudo tilde */
1697 /* if (pseudo_tilde != 0 && cur_chr == '~') cur_chr = pseudo_tilde; */
1698 /* convert space ' ' to pseudo space */
1699 /* if (pseudo_space != 0 && cur_chr == ' ') cur_chr = pseudo_space; */
1700 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1701 if(! more_name(cur_chr)) /* up to next white space */
1707 name_in_progress = false;
1710 /* argument is string .fmt, .log, or .dvi */
1712 void pack_job_name_(str_number s)
1714 cur_area = 335; /* "" */
1716 cur_name = job_name;
1717 pack_file_name(cur_name, cur_area, cur_ext);
1720 /**********************************************************************/
1722 /* show TEXINPUTS=... or format specific */
1723 /* only show this if name was not fully qualified ? */
1724 void show_tex_inputs (void)
1727 s = "TEXINPUTS"; /* default */
1728 if (format_specific) {
1729 s = format_name; /* try specific */
1730 if (grabenv(s) == NULL) s = "TEXINPUTS"; /* no format specific */
1733 if (grabenv(s) == NULL) s = "TEXINPUT"; /* 94/May/19 */
1735 print_nl(" "); /* */
1736 print_char(32); /* */
1737 print_char(40); /*(*/
1739 while (*t > '\0') print_char(*t++);
1740 print_char(61); /* = */
1744 while (*t > '\0') print_char(*t++);
1746 print_char(41); /*)*/
1749 /**********************************************************************/
1751 void prompt_file_name_(str_number s, str_number e)/* s - what can't be found, e - default */
1754 if(interaction == 2)
1757 print_err("I can't find file `");
1759 print_err("I can't write on file `");
1760 print_file_name(cur_name, cur_area, cur_ext);
1762 if(s == 781){ /* input file name */
1763 if (cur_area == 335) { /* "" only if path not specified */
1764 if (show_texinput_flag) show_tex_inputs();
1767 if(e == 785) /* .tex */
1769 print_nl("Please type another "); /* */
1771 if(interaction < 2){
1772 fatal_error("*** (job aborted, file error in nonstop mode)"); /* */
1773 return; // abort_flag set
1777 // show_line(" (or ^Z to exit)\n", 0);
1778 show_line(" (or ^z to exit)", 0);
1780 show_line(" (or Ctrl-Z to exit)", 0);
1787 /* should we deal with tilde and space in file name here ??? */
1791 /* step over leading spaces ... */
1792 while((buffer[k]== 32)&&(k < last)) incr(k);
1793 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1794 quoted_file_name = 0; /* 98/March/15 */
1795 if (allow_quoted_names && k < last) { /* check whether quoted name */
1796 if(buffer[k]== '"') {
1797 quoted_file_name = 1;
1802 if(k == last) goto lab30;
1803 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1804 /* convert tilde '~' to pseudo tilde */
1805 if (pseudo_tilde != 0 && buffer[k]== '~') buffer[k]= pseudo_tilde;
1806 /* convert space ' ' to pseudo space */
1807 if (pseudo_space != 0 && buffer[k]== ' ') buffer[k]= pseudo_space;
1808 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1809 if(! more_name(buffer[k])) goto lab30;
1814 if(cur_ext == 335) /* "" */
1815 cur_ext = e; /* use default extension */
1816 pack_file_name(cur_name, cur_area, cur_ext);
1819 void open_log_file (void)
1824 ccharpointer months;
1826 old_setting = selector;
1828 if(job_name == 0) job_name = 790; /* default: texput */
1829 pack_job_name(791); /* .log */
1830 while(! a_open_out(log_file)) {
1832 prompt_file_name(793, 791); /* transcript file name texput */
1834 texmf_log_name = a_make_name_string(log_file);
1835 selector = 18; /* log file only */
1838 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1839 // for our version DOS/Windows
1841 // showversion (log_file); /* in local.c - bkph */
1842 // showversion (stdout);
1843 stamp_it(log_line); // ??? use log_line ???
1844 strcat(log_line, "\n");
1845 (void) fputs(log_line, log_file);
1846 // show_line(buffer, 0); // ??? show on screen as well
1848 stampcopy(log_line);
1849 strcat(log_line, "\n");
1850 // show_line(buffer, 0); // ??? show on screen as well
1851 (void) fputs(log_line, log_file);
1854 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1855 /* also change following in itex.c - bkph */
1856 (void) fputs(tex_version, log_file);
1857 (void) fprintf(log_file, " (%s %s)", application, yandyversion);
1858 if (format_ident > 0) slow_print(format_ident); /* bkph */
1860 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1861 if (civilize_flag) print_int(eqtb[(hash_size + 3186)].cint); /* year */
1863 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1864 print_int(eqtb[(hash_size + 3184)].cint); /* day */
1865 print_char(32); /* */
1866 months = " JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
1867 {register integer for_end; k = 3 * eqtb[(hash_size + 3185)].cint - 2; for_end = 3
1868 * eqtb[(hash_size + 3185)].cint; if(k <= for_end) do
1869 (void) putc(months[k], log_file);
1870 while(k++ < for_end); } /* month */
1871 print_char(32); /* */
1872 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1873 if (civilize_flag) print_int(eqtb[(hash_size + 3184)].cint);/* day */
1875 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1876 print_int(eqtb[(hash_size + 3186)].cint); /* year */
1877 print_char(32); /* */
1878 print_two(eqtb[(hash_size + 3183)].cint / 60); /* hour */
1879 print_char(58); /* : */
1880 print_two(eqtb[(hash_size + 3183)].cint % 60); /* minute */
1882 input_stack[input_ptr]= cur_input;
1883 print_nl("**"); /* ** */
1884 l = input_stack[0].limit_field;
1885 if(buffer[l]== eqtb[(hash_size + 3211)].cint)
1887 {register integer for_end; k = 1; for_end = l; if(k <= for_end) do
1889 while(k++ < for_end); }
1891 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1892 /* a good place to show the fmt file name or pool file name ? 94/June/21 */
1893 if (show_fmt_flag) {
1894 if (string_file != NULL) {
1895 fprintf(log_file, "(%s)\n", string_file);
1896 free(string_file); /* this was allocated by strdup in openinou */
1897 string_file = NULL; /* for safety */
1899 if (format_file != NULL) {
1900 fprintf(log_file, "(%s)\n", format_file);
1901 free(format_file); /* this was allocated by strdup in openinou */
1902 format_file = NULL; /* for safety */
1905 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1906 selector = old_setting + 2;
1909 /**************************** start of insertion 98/Feb/7 **************/
1911 // Attempt to deal with foo.bar.tex given as foo.bar on command line
1912 // Makes copy of job_name with extension
1914 void morenamecopy(ASCII_code c)
1916 #ifdef ALLOCATESTRING
1917 if(pool_ptr + 1 > current_pool_size)
1918 str_pool = realloc_str_pool (increment_pool_size);
1919 if(pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
1920 overflow(257, current_pool_size - init_pool_ptr); /* 97/Mar/7 */
1921 return; // abort_flag set
1924 if(pool_ptr + 1 > pool_size){
1925 overflow(257, pool_size - init_pool_ptr); /* pool size */
1926 return; // abort_flag set
1929 str_pool[pool_ptr]= c;
1933 int endnamecopy(void)
1935 #ifdef ALLOCATESTRING
1936 if(str_ptr + 1 > current_max_strings)
1937 str_start = realloc_str_start(increment_max_strings + 1);
1938 if(str_ptr + 1 > current_max_strings) { /* in case it failed 94/Jan/24 */
1939 overflow(258, current_max_strings - init_str_ptr); /* 97/Mar/7 */
1940 return 0; // abort_flag set
1943 if(str_ptr + 1 > max_strings){
1944 overflow(258, max_strings - init_str_ptr); /* number of strings */
1945 return 0; // abort_flag set
1948 return make_string ();
1951 void jobnameappend (void)
1952 { /* add extension to job_name */
1955 k = str_start[job_name];
1956 n = str_start[job_name + 1];
1957 while (k < n) morenamecopy(str_pool[k++]);
1958 /* copy `extension' */
1959 k = str_start[cur_ext];
1960 n = str_start[cur_ext + 1];
1961 while (k < n) morenamecopy(str_pool[k++]);
1962 job_name = endnamecopy ();
1965 /**************************** end of insertion 98/Feb/7 **************/
1967 void start_input (void)
1969 bool addedextension = false;
1971 pack_file_name(cur_name, cur_area, cur_ext);
1973 while(true){ /* loop until we get a valid file name */
1974 addedextension = false;
1975 begin_file_reading ();
1976 /* *** *** *** *** *** following is new in 3.14159 *** *** *** *** *** *** */
1977 /* if current extension is *not* empty, try to open using name as is */
1978 /* string 335 is "" the empty string */
1979 if((cur_ext != 335)&& a_open_in(input_file[cur_input.index_field],
1982 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1983 /* we get here if extension is "", or file with extension failed to open */
1984 /* if current extension is not `tex,' and `tex' is not irrelevant, try it */
1985 /* string 785 is .tex */
1986 if((cur_ext != 785)&&(name_length + 5 < PATHMAX)&&
1987 /* (! extensionirrelevantp(name_of_file, "tex"))){ */
1988 (! extensionirrelevantp(name_of_file, name_length, "tex"))){
1989 name_of_file[name_length + 1]= 46; /* .tex */
1990 name_of_file[name_length + 2]= 116;
1991 name_of_file[name_length + 3]= 101;
1992 name_of_file[name_length + 4]= 120;
1993 name_of_file[name_length + 5]= 32; /* 96/Jan/20 ??? */
1994 name_length = name_length + 4;
1995 addedextension = true;
1996 /* *** *** *** *** following new in 3.14159 *** *** *** *** *** *** *** */
1997 if(a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
1999 name_length = name_length - 4; /* strip extension again */
2000 name_of_file[name_length + 1]= 32; /* ' ' */
2001 addedextension = false;
2002 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2004 /* *** *** *** *** major changes here in 3.14159 *** *** *** *** *** *** */
2005 /* string 335 is "" the empty string */
2006 if((cur_ext == 335)&& a_open_in(input_file[cur_input.index_field],
2009 if(maketextex () && a_open_in(input_file[cur_input.index_field],
2012 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2013 end_file_reading ();
2014 prompt_file_name(781, 785); /* input file name .tex */
2015 } /* end of while(true)trying to get valid file name */
2017 /* maybe set pseudo_tilde = 0 at this point ? 95/Sep/26 */
2018 lab30: cur_input.name_field =
2019 a_make_name_string(input_file[cur_input.index_field]);
2020 if(job_name == 0) /* only the first time */
2022 job_name = cur_name; /* here we set the job_name */
2023 /* did file name have an `extension' already and we added ".tex" ? */
2024 if (cur_ext != 335 && addedextension) /* 98/Feb/7 */
2025 jobnameappend (); /* append `extension' to job_name */
2028 if(term_offset +(str_start[cur_input.name_field + 1]- str_start[
2029 cur_input.name_field])> max_print_line - 2) /* was 3 ? */
2031 else if((term_offset > 0)||(file_offset > 0))
2032 print_char(32); /* */
2033 print_char(40); /*(*/
2034 // print_char(64); // debugging only marker
2036 if(open_parens > max_open_parens)
2037 max_open_parens = open_parens; /* 1999/Jan/17 */
2038 slow_print(cur_input.name_field);
2039 // print_char(64); // debugging only marker
2043 cur_input.state_field = 33;
2046 if(input_ln(input_file[cur_input.index_field], false))
2048 firm_up_the_line ();
2049 if((eqtb[(hash_size + 3211)].cint < 0)||
2050 (eqtb[(hash_size + 3211)].cint > 255))
2051 decr(cur_input.limit_field);
2052 /* long to unsigned char ... */
2053 else buffer[cur_input.limit_field] = eqtb[(hash_size + 3211)].cint;
2054 first = cur_input.limit_field + 1;
2055 cur_input.loc_field = cur_input.start_field;
2059 /**********************************************************************/
2060 /* show TEXFONTS=... or format specific */
2061 /* only show this if name was not fully qualified ? */
2062 void show_tex_fonts(void)
2064 char *s, *t, *v, *u;
2067 if (encoding_specific) {
2068 u = encoding_name; /* try specific */
2069 if ((t = grabenv(u)) != NULL) {
2070 if (strchr(t, ':') != NULL &&
2071 sscanf(t, "%d", &n) == 0) {
2072 s = u; /* look here instead of TEXFONTS=... */
2076 print_nl(" "); /* */
2077 print_char(32); /* */
2078 print_char(40); /*(*/
2080 while (*t > '\0') print_char(*t++);
2081 print_char(61); /* = */
2085 while (*t > '\0') print_char(*t++);
2087 print_char(41); /*)*/
2090 /**********************************************************************/
2092 /* called only from tex8.c */
2094 internal_font_number read_font_info_(halfword u, str_number nom, str_number aire, scaled s)
2095 {/* 30 11 45 */ register internal_font_number Result;
2098 /* halfword lf, lh, bc, ec, nw, nh, nd, ni, nl, nk, ne, np; */
2099 halfword lf, lh, nw, nh, nd, ni, nl, nk, ne, np;
2100 /* halfword bc, ec; */
2101 int bc, ec; /* 95/Jan/7 */
2102 internal_font_number f;
2103 internal_font_number g;
2104 eight_bits a, b, c, d;
2114 pack_file_name(nom, aire, 805); /* .tfm */
2115 if(! b_open_in(tfm_file))
2116 { /* new in C version d */
2119 if(! b_open_in(tfm_file))
2124 /* was just: goto lab11; */
2127 /* tfm_temp = getc(tfm_file); */ /* done already in open_input, but why? */
2132 tfm_temp = getc(tfm_file);
2133 lf = lf * 256 + tfm_temp;
2135 tfm_temp = getc(tfm_file);
2140 tfm_temp = getc(tfm_file);
2141 lh = lh * 256 + tfm_temp;
2143 tfm_temp = getc(tfm_file);
2148 tfm_temp = getc(tfm_file);
2149 bc = bc * 256 + tfm_temp;
2151 tfm_temp = getc(tfm_file);
2156 tfm_temp = getc(tfm_file);
2157 ec = ec * 256 + tfm_temp;
2159 if((bc > ec + 1)||(ec > 255))
2166 tfm_temp = getc(tfm_file);
2171 tfm_temp = getc(tfm_file);
2172 nw = nw * 256 + tfm_temp;
2174 tfm_temp = getc(tfm_file);
2179 tfm_temp = getc(tfm_file);
2180 nh = nh * 256 + tfm_temp;
2182 tfm_temp = getc(tfm_file);
2187 tfm_temp = getc(tfm_file);
2188 nd = nd * 256 + tfm_temp;
2190 tfm_temp = getc(tfm_file);
2195 tfm_temp = getc(tfm_file);
2196 ni = ni * 256 + tfm_temp;
2198 tfm_temp = getc(tfm_file);
2203 tfm_temp = getc(tfm_file);
2204 nl = nl * 256 + tfm_temp;
2206 tfm_temp = getc(tfm_file);
2211 tfm_temp = getc(tfm_file);
2212 nk = nk * 256 + tfm_temp;
2214 tfm_temp = getc(tfm_file);
2219 tfm_temp = getc(tfm_file);
2220 ne = ne * 256 + tfm_temp;
2222 tfm_temp = getc(tfm_file);
2227 tfm_temp = getc(tfm_file);
2228 np = np * 256 + tfm_temp;
2230 if(lf != 6 + lh +(ec - bc + 1)+ nw + nh + nd + ni + nl + nk + ne +
2237 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2239 if((fmem_ptr + lf > current_font_mem_size)) /* 93/Nov/28 */
2240 font_info = realloc_font_info (increment_font_mem_size + lf);
2241 if((font_ptr == font_max)||(fmem_ptr + lf > current_font_mem_size))
2243 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2244 if((font_ptr == font_max)||(fmem_ptr + lf > font_mem_size))
2247 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2250 sprintf(log_line, "font_ptr %d font_max %d fmem_ptr %d lf %d font_mem_size %d\n",
2251 font_ptr, font_max, fmem_ptr, lf, font_mem_size); /* debugging */
2252 show_line(log_line, 0);
2255 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2258 print_char(61); /* = */
2259 print_file_name(nom, aire, 335); /* "" */
2262 print_string(" at ");
2268 print_string(" scaled ");
2269 print_int(- (integer) s);
2271 print_string(" not loaded: Not enough room left");
2272 help4("I'm afraid I won't be able to make use of this font,",
2273 "because my memory for character-size data is too small.",
2274 "If you're really stuck, ask a wizard to enlarge me.",
2275 "Or maybe try `I\\font<same font id>=<name of loaded font>'.");
2280 char_base[f]= fmem_ptr - bc;
2281 width_base[f]= char_base[f]+ ec + 1;
2282 height_base[f]= width_base[f]+ nw;
2283 depth_base[f]= height_base[f]+ nh;
2284 italic_base[f]= depth_base[f]+ nd;
2285 lig_kern_base[f]= italic_base[f]+ ni;
2286 kern_base[f]= lig_kern_base[f]+ nl - 256 *(128);
2287 exten_base[f]= kern_base[f]+ 256 *(128)+ nk;
2288 param_base[f]= exten_base[f]+ ne;
2292 /* build the font checksum now */
2294 tfm_temp = getc(tfm_file);
2297 tfm_temp = getc(tfm_file);
2300 tfm_temp = getc(tfm_file);
2303 tfm_temp = getc(tfm_file);
2308 tfm_temp = getc(tfm_file);
2313 tfm_temp = getc(tfm_file);
2314 z = z * 256 + tfm_temp;
2316 tfm_temp = getc(tfm_file);
2317 z = z * 256 + tfm_temp;
2318 tfm_temp = getc(tfm_file);
2319 z =(z * 16)+(tfm_temp / 16);
2323 tfm_temp = getc(tfm_file);
2324 tfm_temp = getc(tfm_file);
2325 tfm_temp = getc(tfm_file);
2326 tfm_temp = getc(tfm_file);
2333 else z = xn_over_d(z, - (integer) s, 1000);
2336 {register integer for_end; k = fmem_ptr; for_end = width_base[f]- 1
2337 ; if(k <= for_end) do
2340 tfm_temp = getc(tfm_file);
2343 tfm_temp = getc(tfm_file);
2346 tfm_temp = getc(tfm_file);
2349 tfm_temp = getc(tfm_file);
2352 font_info[k].qqqq = qw;
2354 if((a >= nw)||(b / 16 >= nh)||(b % 16 >= nd)||(c / 4 >=
2369 if((d < bc)||(d > ec))
2372 while(d < k + bc - fmem_ptr){
2374 qw = font_info[char_base[f]+ d].qqqq;
2375 if(((qw.b2)% 4)!= 2)
2379 if(d == k + bc - fmem_ptr)
2389 while(k++ < for_end); }
2393 while(z >= 8388608L){ /* 2^23 */
2396 alpha = alpha + alpha;
2398 /* beta = 256 / alpha; */ /* keep compiler happy */
2399 beta = (char) (256 / alpha);
2402 {register integer for_end; k = width_base[f]; for_end = lig_kern_base[
2403 f]- 1; if(k <= for_end) do
2405 tfm_temp = getc(tfm_file);
2407 tfm_temp = getc(tfm_file);
2409 tfm_temp = getc(tfm_file);
2411 tfm_temp = getc(tfm_file);
2413 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2415 font_info[k].cint = sw;
2417 font_info[k].cint = sw - alpha;
2420 while(k++ < for_end); }
2421 if(font_info[width_base[f]].cint != 0)
2423 if(font_info[height_base[f]].cint != 0)
2425 if(font_info[depth_base[f]].cint != 0)
2427 if(font_info[italic_base[f]].cint != 0)
2430 /* read ligature/kern program */
2431 bchlabel = 32767; /* '77777 */
2435 /* begin for k:=lig_kern_base[f] to kern_base[f]+kern_base_offset-1 do */
2436 {register integer for_end; k = lig_kern_base[f]; for_end = kern_base[f
2437 ]+ 256 *(128)- 1; if(k <= for_end) do
2440 tfm_temp = getc(tfm_file);
2443 tfm_temp = getc(tfm_file);
2446 tfm_temp = getc(tfm_file);
2449 tfm_temp = getc(tfm_file);
2452 font_info[k].qqqq = qw; /* store_four_quarters(font_info[k].qqqq */
2456 if(256 * c + d >= nl)
2457 goto lab11; /* error in TFM, abort */
2459 if(k == lig_kern_base[f])
2466 if((b < bc)||(b > ec)) /* check-existence(b) */
2467 goto lab11; /* error in TFM, abort */
2469 qw = font_info[char_base[f]+ b].qqqq;
2471 goto lab11; /* error in TFM, abort */
2476 if((d < bc)||(d > ec)) /* check-existence(d) */
2477 goto lab11; /* error in TFM, abort */
2479 qw = font_info[char_base[f]+ d].qqqq;
2481 goto lab11; /* error in TFM, abort */
2483 else if(256 *(c - 128)+ d >= nk)
2484 goto lab11; /* error in TFM, abort */
2486 if(k - lig_kern_base[f]+ a + 1 >= nl)
2487 goto lab11; /* error in TFM, abort */
2490 while(k++ < for_end); }
2492 bchlabel = 256 * c + d;
2494 /* for k:=kern_base[f]+kern_base_offset to exten_base[f]-1 do */
2495 /* store_scaled(font_info[k].sc); */
2496 {register integer for_end; k = kern_base[f]+ 256 *(128); for_end =
2497 exten_base[f]- 1; if(k <= for_end) do
2499 tfm_temp = getc(tfm_file);
2501 tfm_temp = getc(tfm_file);
2503 tfm_temp = getc(tfm_file);
2505 tfm_temp = getc(tfm_file);
2507 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2509 font_info[k].cint = sw;
2511 font_info[k].cint = sw - alpha;
2514 while(k++ < for_end); }
2515 /* read extensible character recipes */
2516 /* for k:=exten_base[f] to param_base[f]-1 do */
2517 {register integer for_end; k = exten_base[f]; for_end = param_base[f]
2518 - 1; if(k <= for_end) do
2521 tfm_temp = getc(tfm_file);
2524 tfm_temp = getc(tfm_file);
2527 tfm_temp = getc(tfm_file);
2530 tfm_temp = getc(tfm_file);
2533 /* store_four_quarters(font_info[k].qqqq); */
2534 font_info[k].qqqq = qw;
2539 if((a < bc)||(a > ec))
2542 qw = font_info[char_base[f]+ a].qqqq;
2549 if((b < bc)||(b > ec))
2552 qw = font_info[char_base[f]+ b].qqqq;
2559 if((c < bc)||(c > ec))
2562 qw = font_info[char_base[f]+ c].qqqq;
2568 if((d < bc)||(d > ec))
2571 qw = font_info[char_base[f]+ d].qqqq;
2576 while(k++ < for_end); }
2578 {register integer for_end; k = 1; for_end = np; if(k <= for_end) do
2581 tfm_temp = getc(tfm_file);
2585 tfm_temp = getc(tfm_file);
2586 sw = sw * 256 + tfm_temp;
2587 tfm_temp = getc(tfm_file);
2588 sw = sw * 256 + tfm_temp;
2589 tfm_temp = getc(tfm_file);
2590 font_info[param_base[f]].cint =(sw * 16)+(tfm_temp / 16);
2594 tfm_temp = getc(tfm_file);
2596 tfm_temp = getc(tfm_file);
2598 tfm_temp = getc(tfm_file);
2600 tfm_temp = getc(tfm_file);
2602 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2604 font_info[param_base[f]+ k - 1].cint = sw;
2606 font_info[param_base[f]+ k - 1].cint = sw - alpha;
2609 while(k++ < for_end); }
2610 /* use test_eof() here instead ? */
2613 {register integer for_end; k = np + 1; for_end = 7; if(k <= for_end)
2615 font_info[param_base[f]+ k - 1].cint = 0;
2616 while(k++ < for_end); }
2618 /* @<Make final adjustments...@>= l.11174 */
2621 else font_params[f]= 7;
2622 hyphen_char[f]= eqtb[(hash_size + 3209)].cint; /* default_hyphen_char */
2623 skew_char[f]= eqtb[(hash_size + 3210)].cint; /* default_skew_char */
2625 bchar_label[f]= bchlabel + lig_kern_base[f];
2626 /* bchar_label[f]:=non_address; */ /* 3.14159 */
2627 /* else bchar_label[f]= font_mem_size; */ /* OK ??? 93/Nov/28 */
2628 else bchar_label[f]= non_address; /* i.e. 0 --- 96/Jan/15 */
2629 font_bchar[f]= bchar;
2630 font_false_bchar[f]= bchar;
2634 qw = font_info[char_base[f]+ bchar].qqqq;
2636 font_false_bchar[f]= 256;
2642 font_glue[f]= 0; /* font_glue[f]:=null; l.11184 */
2643 char_base[f]= char_base[f];
2644 width_base[f]= width_base[f];
2645 lig_kern_base[f]= lig_kern_base[f];
2646 kern_base[f]= kern_base[f];
2647 exten_base[f]= exten_base[f];
2648 decr(param_base[f]);
2649 fmem_ptr = fmem_ptr + lf;
2654 lab11: print_err("Font ");
2656 print_char(61); /* = */
2657 print_file_name(nom, aire, 335); /* "" */
2666 print_string("scaled");
2667 print_int(- (integer) s);
2669 if(fileopened)print_string("not loadable: Bad metric (TFM) file");
2670 else print_string("not loadable: Metric (TFM) file not found");
2671 if (aire == 335) { /* "" only if path not specified */
2672 if (show_texinput_flag) show_tex_fonts(); /* 98/Jan/31 */
2674 help5("I wasn't able to read the size data for this font,",
2675 "so I will ignore the font specification.",
2676 "[Wizards can fix TFM files using TFtoPL/PLtoTF.]",
2677 "You might try inserting a different font spec;",
2678 "e.g., type `I\\font<same font id>=<substitute font name>'.");
2682 if(fileopened)b_close(tfm_file);