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));
42 if (cur_tok == 3117) {
43 negative = ! negative;
46 } while (!(cur_tok != 3115));
48 if (cur_tok == 3168) {
58 /* else if cur_tok<cs_token_flag+single_base then ... */
59 else if (cur_tok < 4352) /* 4095 + 257 */
60 /* cur_val:=cur_tok-cs_token_flag-active_base */
61 cur_val = cur_tok - 4096; /* 4095 + 1 */
62 /* else cur_val:=cur_tok-cs_token_flag-single_base; */
63 else cur_val = cur_tok - 4352; /* 4095 + 257 */
66 print_err("Improper alphabetic constant");
67 help2("A one-character control sequence belongs after a ` mark.",
68 "So I'm essentially inserting \\0 here.");
76 } else if ((cur_cmd >= 68) && (cur_cmd <= 89)) {
77 scan_something_internal(0, false);
79 /* begin radix:=10; m:=214748364; l.8734 */
81 m = 214748364L; /* 7FFFFFFF hex */
82 if (cur_tok == 3111) {
84 m = 268435456L; /* 2^28 */
86 } else if (cur_tok == 3106) {
88 m = 134217728L; /* 2^27 8000000 hex */
94 if ((cur_tok < 3120 + radix) && (cur_tok >= 3120) && (cur_tok <= 3129))
97 if ((cur_tok <= 2886) && (cur_tok >= 2881))
99 else if ((cur_tok <= 3142) && (cur_tok >= 3137))
106 if ((cur_val >= m) && ((cur_val > m) || (d > 7) || (radix != 10))) {
108 print_err("Number too big");
109 help2("I can only go up to 2147483647='17777777777=\"7FFFFFFF,",
110 "so I'm using that number instead of yours.");
112 cur_val = 2147483647L; /* 7FFFFFFF hex */
115 } else cur_val = cur_val * radix + d;
120 print_err("Missing number, treated as zero");
121 help3("A number should have been here; I inserted `0'.",
122 "(If you can't figure out why I needed to see a number,",
123 "look up `weird error' in the index to The TeXbook.)");
125 } else if (cur_cmd != 10)
129 cur_val = - (integer) cur_val;
131 void scan_dimen_(bool mu, bool inf, bool shortcut)
149 } while (!(cur_cmd != 10));
150 if (cur_tok == 3117) {
151 negative = ! negative;
154 } while (!(cur_tok != 3115));
155 if ((cur_cmd >= 68)&&(cur_cmd <= 89))
157 scan_something_internal(3, false);
158 if (cur_val_level >= 2) {
159 v = mem[cur_val + 1].cint;
160 delete_glue_ref(cur_val);
163 if (cur_val_level == 3)
165 if (cur_val_level != 0) {
169 scan_something_internal(1, false);
170 if (cur_val_level == 1)
176 if (cur_tok != 3118) {
184 if ((radix == 10) && (cur_tok == 3118)) {
186 p = 0; /* p:=null l.8883 */
191 if ((cur_tok > 3129) || (cur_tok < 3120))
196 mem[q].hh.v.LH = cur_tok - 3120;
203 register integer for_end;
206 if (kk >= for_end) do {
207 /* long to char ... */
208 dig[kk - 1]= mem[p].hh.v.LH;
212 mem[q].hh.v.RH = avail;
219 } while (kk-- > for_end);
221 f = round_decimals(k);
228 negative = ! negative;
229 cur_val = - (integer) cur_val;
232 if (scan_keyword("fil")) {
234 while (scan_keyword("l")) {
235 if (cur_order == 3) {
236 print_err("Illegal unit of measure(");
237 print_string("replaced by filll)");
238 help1("I dddon't go any higher than filll.");
240 } else incr(cur_order);
244 savecurval = cur_val;
247 } while (!(cur_cmd != 10));
248 if ((cur_cmd < 68) || (cur_cmd > 89))
252 scan_something_internal(3, false);
253 if (cur_val_level >= 2) {
254 v = mem[cur_val + 1].cint;
255 delete_glue_ref(cur_val);
258 if (cur_val_level != 3) {
262 scan_something_internal(1, false);
269 if (scan_keyword("em"))
270 v =(font_info[6 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint);
271 else if (scan_keyword("ex"))
272 v =(font_info[5 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint);
281 cur_val = mult_and_add(savecurval, v, xn_over_d(v, f, 65536L), 1073741823L); /* 2^30 - 1 */
285 if (scan_keyword("mu"))
288 print_err("Illegal unit of measure(");
289 print_string("mu inserted)");
290 help4("The unit of measurement in math glue must be mu.",
291 "To recover gracefully from this error, it's best to",
292 "delete the erroneous units; e.g., type `2' to delete",
293 "two letters. (See Chapter 27 of The TeXbook.)");
297 if (scan_keyword("true")) {
299 if (eqtb[(hash_size + 3180)].cint != 1000) {
300 cur_val = xn_over_d(cur_val, 1000, eqtb[(hash_size + 3180)].cint);
301 f =(1000 * f + 65536L * tex_remainder) / eqtb[(hash_size + 3180)].cint;
302 cur_val = cur_val + (f / 65536L);
306 if (scan_keyword("pt"))
308 if (scan_keyword("in"))
312 } else if (scan_keyword("pc"))
316 } else if (scan_keyword("cm"))
320 } else if (scan_keyword("mm"))
324 } else if (scan_keyword("bp"))
328 } else if (scan_keyword("dd"))
332 } else if (scan_keyword("cc"))
336 } else if (scan_keyword("Q"))
340 } else if (scan_keyword("H"))
344 } else if (scan_keyword("sp"))
347 print_err("Illegal unit of measure(");
348 print_string("pt inserted)");
349 help6("Dimensions can be in units of em, ex, in, pt, pc,",
350 "cm, mm, dd, cc, bp, or sp; but yours is a new one!",
351 "I'll assume that you meant to say pt, for printer's points.",
352 "To recover gracefully from this error, it's best to",
353 "delete the erroneous units; e.g., type `2' to delete",
354 "two letters. (See Chapter 27 of The TeXbook.)");
358 cur_val = xn_over_d(cur_val, num, denom);
359 f =(num * f + 65536L * tex_remainder) / denom;
360 cur_val = cur_val +(f / 65536L);
364 if (cur_val >= 16384) /* 2^14 */
367 cur_val = cur_val * 65536L + f;
375 if (arith_error || (abs(cur_val)>= 1073741824L)) /* 2^30 */
377 print_err("Dimension too large");
378 help2("I can't work with sizes bigger than about 19 feet.",
379 "Continue and I'll use the largest value I can.");
381 cur_val = 1073741823L; /* 2^30 - 1 */
385 cur_val = - (integer) cur_val;
387 void scan_glue_(small_number level)
397 } while (!(cur_cmd != 10));
398 if (cur_tok == 3117) {
399 negative = ! negative;
402 } while (!(cur_tok != 3115));
403 if ((cur_cmd >= 68) && (cur_cmd <= 89)) {
404 scan_something_internal(level, negative);
405 if (cur_val_level >= 2) {
406 if (cur_val_level != level) {
411 if (cur_val_level == 0) {
412 scan_dimen(mu, false, true);
413 } else if (level == 3) {
418 scan_dimen(mu, false, false);
419 if (negative)cur_val = - (integer) cur_val;
422 mem[q + 1].cint = cur_val;
423 if (scan_keyword("plus")) {
424 scan_dimen(mu, true, false);
425 mem[q + 2].cint = cur_val;
426 mem[q].hh.b0 = cur_order;
428 if (scan_keyword("minus")) {
429 scan_dimen(mu, true, false);
430 mem[q + 3].cint = cur_val;
431 mem[q].hh.b1 = cur_order;
435 halfword scan_rule_spec (void)
437 register halfword Result;
440 /* if cur_cmd=vrule then width(q):=default_rule */
441 /* @d default_rule=26214 {0.4\thinspace pt} */
442 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
443 if (cur_cmd == 35) /* cur_cmd == vrule */
444 /* mem[q + 1].cint = 26214; */ /* width := 0.4pt */
445 mem[q + 1].cint = default_rule; /* 95/Oct/9 */
447 /* mem[q + 3].cint = 26214; */ /* height := 0.4pt */
448 mem[q + 3].cint = default_rule; /* 95/Oct/9 */
449 mem[q + 2].cint = 0; /* depth := 0.0pt */
451 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
453 if (scan_keyword("width")) {
454 scan_dimen(false, false, false);
455 mem[q + 1].cint = cur_val;
458 if (scan_keyword("height")) {
459 scan_dimen(false, false, false);
460 mem[q + 3].cint = cur_val;
463 if (scan_keyword("depth")) {
464 scan_dimen(false, false, false);
465 mem[q + 2].cint = cur_val;
471 halfword str_toks_(pool_pointer b)
473 register halfword Result;
479 #ifdef ALLOCATESTRING
480 if (pool_ptr + 1 > current_pool_size)
481 str_pool = realloc_str_pool (increment_pool_size);
482 if (pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/22 */
483 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
484 return 0; // abort_flag set
487 if (pool_ptr + 1 > pool_size) {
488 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
489 return; // abort_flag set
494 mem[p].hh.v.RH = 0; /* link(p):=null l.9135 */
496 while (k < pool_ptr) {
508 avail = mem[q].hh.v.RH;
526 halfword the_toks (void)
528 register halfword Result;
533 scan_something_internal(5, false);
534 if (cur_val_level >= 4)
538 if (cur_val_level == 4)
542 mem[q].hh.v.LH = 4095 + cur_val;
545 else if (cur_val != 0)/* else if cur_val<>null then l.9176 */
547 r = mem[cur_val].hh.v.RH;
548 while(r != 0){ /* while r<>null do l.9178 */
557 avail = mem[q].hh.v.RH;
566 mem[q].hh.v.LH = mem[r].hh.v.LH;
576 old_setting = selector;
579 switch(cur_val_level)
585 print_scaled(cur_val);
591 print_spec(cur_val, 394); /* pt */
592 delete_glue_ref(cur_val);
597 print_spec(cur_val, 334); /* mu */
598 delete_glue_ref(cur_val);
602 selector = old_setting;
603 Result = str_toks(b);
607 void ins_the_toks (void)
609 mem[lig_trick].hh.v.RH = the_toks();
610 begin_token_list(mem[temp_head].hh.v.RH, 4);
612 void conv_toks (void)
616 small_number savescannerstatus;
629 savescannerstatus = scanner_status;
632 scanner_status = savescannerstatus;
639 if (job_name == 0)open_log_file();
642 old_setting = selector;
650 print_roman_int(cur_val);
655 else print_char(cur_chr);
662 print(font_name[cur_val]);
663 if (font_size[cur_val]!= font_dsize[cur_val])
666 print_scaled(font_size[cur_val]);
675 selector = old_setting;
676 mem[lig_trick].hh.v.RH = str_toks(b);
677 begin_token_list(mem[temp_head].hh.v.RH, 4);
679 halfword scan_toks_(bool macrodef, bool xpand)
680 {/* 40 30 31 32 */ register halfword Result;
689 else scanner_status = 5;
690 warning_index = cur_cs;
691 def_ref = get_avail();
692 mem[def_ref].hh.v.LH = 0;
712 mem[q].hh.v.LH = cur_tok;
718 mem[q].hh.v.LH = 3584;
725 print_err("You already have nine parameters");
726 help1("I'm going to ignore the # sign you just used.");
733 print_err("Parameters must be numbered consecutively");
734 help2("I've inserted the digit you should have used after the #.",
735 "Type `1' to delete what you did use.");
744 mem[q].hh.v.LH = cur_tok;
751 mem[q].hh.v.LH = 3584;
756 print_err("Missing { inserted");
758 help2("Where was the left brace? You said something like `\\def\\a}',",
759 "which I'm going to interpret as `\\def\\a{}'.");
773 if (cur_cmd <= 100) goto lab32;
779 /* if link(temp_head)<>null then l.9376 */
780 if (mem[temp_head].hh.v.RH != 0)
782 mem[p].hh.v.RH = mem[temp_head].hh.v.RH;
792 if (cur_cmd < 2) incr(unbalance);
798 else if (cur_cmd == 6)
801 if (xpand)get_x_token();
804 if ((cur_tok <= 3120)||(cur_tok > t)) {
805 print_err("Illegal parameter number in definition of");
806 sprint_cs(warning_index);
807 help3("You meant to type ## instead of #, right?",
808 "Or maybe a } was forgotten somewhere earlier, and things",
809 "are all screwed up? I'm going to assume that you meant ##.");
813 else cur_tok = 1232 + cur_chr;
818 mem[q].hh.v.LH = cur_tok;
822 lab40: scanner_status = 0;
827 mem[q].hh.v.LH = hashbrace;
833 /* used only in ITEX.C */
834 void read_toks_(integer n, halfword r)
839 /* small_number m; */
840 int m; /* 95/Jan/7 */
843 def_ref = get_avail();
844 mem[def_ref].hh.v.LH = 0;
849 mem[q].hh.v.LH = 3584;
852 if ((n < 0)||(n > 15)) m = 16;
855 align_state = 1000000L;
857 begin_file_reading();
858 cur_input.name_field = m + 1;
859 if (read_open[m]== 2)
878 fatal_error("*** (cannot \\read from terminal in nonstop modes)"); /* */
879 return; // abort_flag set
881 else if (read_open[m]== 1)
882 if (input_ln(read_file[m], false))
885 (void) a_close(read_file[m]);
889 if (! input_ln(read_file[m], true)) {
890 (void) a_close(read_file[m]);
892 if (align_state != 1000000L) {
894 print_err("File ended within");
896 help1("This \\read has unbalanced braces.");
897 align_state = 1000000L;
902 cur_input.limit_field = last;
903 if ((eqtb[(hash_size + 3211)].cint < 0)||(eqtb[(hash_size + 3211)].cint > 255))
904 decr(cur_input.limit_field);
905 /* long to unsigned char ... */
906 else buffer[cur_input.limit_field]= eqtb[(hash_size + 3211)].cint;
907 first = cur_input.limit_field + 1;
908 cur_input.loc_field = cur_input.start_field;
909 cur_input.state_field = 33;
914 if (align_state < 1000000L)
918 } while(!(cur_tok == 0));
919 align_state = 1000000L;
925 mem[q].hh.v.LH = cur_tok;
929 lab30: end_file_reading();
930 } while(!(align_state == 1000000L));
935 void pass_text (void)
938 small_number savescannerstatus;
939 savescannerstatus = scanner_status;
946 if (l == 0) goto lab30;
950 else if (cur_cmd == 105) incr(l);
953 scanner_status = savescannerstatus;
955 void change_if_limit_(small_number l, halfword p)
963 if (q == 0) { /* begin if q=null then confusion("if"); l.9674 */
965 return; // abort_flag set
967 if (mem[q].hh.v.RH == p)
976 /* called from tex2.c */
977 void conditional (void)
983 small_number savescannerstatus;
984 halfword savecondptr;
987 /* begin p:=get_node(if_node_size); */
988 p = get_node(2); /* p <- get_node(if_node_size); p.495*/
989 /* link(p):=cond_ptr; */
990 mem[p].hh.v.RH = cond_ptr;
991 /* type(p):=if_limit; */
992 mem[p].hh.b0 = if_limit;
993 /* subtype(p):=cur_if; */
994 mem[p].hh.b1 = cur_if;
995 /* if_line_field(p):=if_line; */
996 mem[p + 1].cint = if_line;
1002 savecondptr = cond_ptr; /* save_cond_ptr <- cond_ptr; p.498 */
1010 if (cur_cmd == 0) /* if cur_cmd = relax then .. p.506 */
1011 if (cur_chr == 257) /* if cur_chr = no_expand_flag then ... p.506 */
1014 cur_chr = cur_tok - 4096;
1017 if ((cur_cmd > 13)||(cur_chr > 255))
1028 if (cur_cmd == 0) /* if cur_cmd = relax then .. p.506 */
1029 if (cur_chr == 257) /* if cur_chr = no_expand_flag then ... p.506 */
1032 cur_chr = cur_tok - 4096;
1035 if ((cur_cmd > 13)||(cur_chr > 255))
1042 else b =(m == cur_cmd);
1052 scan_dimen(false, false, false);
1057 } while(!(cur_cmd != 10));
1058 if ((cur_tok >= 3132)&&(cur_tok <= 3134))
1061 print_err("Missing = inserted for ");
1062 print_cmd_chr(105, thisif); /* i */
1063 help1("I was expecting to see `<', `=', or `>'. Didn't.");
1071 scan_dimen(false, false, false);
1096 b =(abs(mode)== 102);
1099 b =(abs(mode)== 203);
1108 scan_eight_bit_int();
1109 p = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
1114 else if (thisif == 10)
1115 b =(mem[p].hh.b0 == 0);
1116 else b =(mem[p].hh.b0 == 1);
1121 savescannerstatus = scanner_status;
1128 if (cur_cmd != p) b = false;
1129 else if (cur_cmd < 111) b =(cur_chr == q);
1131 p = mem[cur_chr].hh.v.RH;
1132 q = mem[eqtb[n].hh.v.RH].hh.v.RH;
1136 /* else begin while (p<>null)and(q<>null) do l.9840 */
1137 while((p != 0)&&(q != 0)) if (mem[p].hh.v.LH != mem[
1139 p = 0; /* p:=null */
1144 b =((p == 0)&&(q == 0)); /* b:=((p=null)and(q=null)); */
1147 scanner_status = savescannerstatus;
1152 scan_four_bit_int();
1153 b =(read_open[cur_val]== 2);
1166 if (eqtb[(hash_size + 3199)].cint > 1)
1169 print_string("{case ");
1172 end_diagnostic(false);
1176 if (cond_ptr == savecondptr)
1180 else if (cur_chr == 2)
1183 if_line = mem[p + 1].cint;
1184 cur_if = mem[p].hh.b1;
1185 if_limit = mem[p].hh.b0;
1186 cond_ptr = mem[p].hh.v.RH;
1190 change_if_limit(4, savecondptr);
1195 if (eqtb[(hash_size + 3199)].cint > 1)
1199 print_string("{true}");
1200 else print_string("{false}");
1201 end_diagnostic(false);
1203 if (b) /* b may be used without ... */
1205 change_if_limit(3, savecondptr);
1210 if (cond_ptr == savecondptr)
1214 print_err("Extra ");
1216 help1("I'm ignoring this; it doesn't match any \\if.");
1219 else if (cur_chr == 2)
1222 if_line = mem[p + 1].cint;
1223 cur_if = mem[p].hh.b1;
1224 if_limit = mem[p].hh.b0;
1225 cond_ptr = mem[p].hh.v.RH;
1229 lab50: if (cur_chr == 2)
1232 if_line = mem[p + 1].cint;
1233 cur_if = mem[p].hh.b1;
1234 if_limit = mem[p].hh.b0;
1235 cond_ptr = mem[p].hh.v.RH;
1240 void begin_name (void)
1242 area_delimiter = 0; /* index between `file area' and `file name' */
1243 ext_delimiter = 0; /* index between `file name' and `file extension' */
1245 /* This gathers up a file name and makes a string of it */
1246 /* Also tries to break it into `file area' `file name' and `file extension' */
1247 /* Used by scan_file_name and prompt_file_name */
1248 /* We assume tilde has been converted to pseudo_tilde and space to pseudo_space */
1249 /* returns false if it is given a space character - end of file name */
1250 bool more_name_(ASCII_code c)
1252 register bool Result;
1254 /* if (c == 32)*/ /* white space delimits file name ... */
1255 if (quoted_file_name == 0 && c == 32)
1257 else if (quoted_file_name != 0 && c == '"') {
1258 quoted_file_name = 0; /* catch next space character */
1259 Result = true; /* accept ending quote, but throw away */
1261 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1262 /* convert pseudo tilde back to '~' 95/Sep/26 */ /* moved here 97/June/5 */
1263 /* if (pseudo_tilde != 0 && c == pseudo_tilde) c = '~'; */
1264 /* convert pseudo space back to ' ' 97/June/5 */ /* moved here 97/June/5 */
1265 /* if (pseudo_space != 0 && c == pseudo_space) c = ' '; */
1266 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1268 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1269 #ifdef ALLOCATESTRING
1270 if (pool_ptr + 1 > current_pool_size)
1271 str_pool = realloc_str_pool (increment_pool_size);
1272 if (pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
1273 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
1274 return 0; // abort_flag set
1277 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1278 if (pool_ptr + 1 > pool_size){
1279 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
1280 return 0; // abort_flag set
1285 str_pool[pool_ptr] = c;
1288 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1289 // if ((c == 47)) /* / */
1291 if ((c == '/' || c == '\\' || c == ':')) /* 94/Mar/1 */
1292 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1294 area_delimiter = (pool_ptr - str_start[str_ptr]);
1297 else if (c == 46) /* . */
1298 ext_delimiter = (pool_ptr - str_start[str_ptr]);
1303 /******************************** 2000 August 15th start ***********************/
1305 // The following code is to save string space used by TeX for filenames
1306 // Not really critical in a system that has dynamic memory allocation
1307 // And may slow it down slightly - although this linear search only
1308 // occurs when opening a file, which is somewhat slow inany case...
1310 // see if string from str_pool[start] to str_pool[end]
1311 // occurs elsewhere in string pool - returns string number
1312 // returns -1 if not found in string pool 2000 Aug 15
1314 int find_string (int start, int end)
1316 int k, nlen= end-start;
1319 // int trace_flag = 1; // debugging only
1322 sprintf(log_line, "\nLOOKING for string (str_ptr %d nlen %d) ", str_ptr, end-start);
1323 s = log_line + strlen(log_line);
1324 strncpy(s, str_pool + start, nlen);
1326 show_line(log_line, 0);
1329 // avoid problems with(cur_name == flushablestring)by going only up to str_ptr-1
1330 // code in new_font (tex8.c) will take care of reuse of font name already
1331 // for (k = 0; k < str_ptr; k++) {
1332 for (k = 0; k < str_ptr-1; k++) {
1333 if ((str_start[k+1] - str_start[k]) != nlen) continue;
1334 if (strncmp(str_pool+start, str_pool+str_start[k], nlen) == 0) {
1336 sprintf(log_line, "\nFOUND the string %d (%d) ", k, str_start[k+1]-str_start[k]);
1337 s = log_line + strlen(log_line);
1338 strncpy(s, str_pool+start, nlen);
1339 strcpy(s+nlen, "\n");
1340 show_line(log_line, 0);
1342 return k; // return number of matching string
1346 sprintf(log_line, "\nNOT FOUND string ");
1347 s = log_line + strlen(log_line);
1348 strncpy(s, str_pool+start, nlen);
1349 strcpy(s+nlen, "\n");
1350 show_line(log_line, 0);
1352 return -1; // no match found
1355 // snip out the string from str_pool[start] to str_pool[end]
1356 // and move everything above it down 2000 Aug 15
1358 void remove_string (int start, int end)
1360 int nlen = pool_ptr - end; // how many bytes to move down
1363 // int trace_flag=1; // debugging only
1364 // if (end < start) show_line("\nEND < START", 1);
1365 // if (pool_ptr < end) show_line("\nPOOLPTR < END", 1);
1369 sprintf(log_line, "\nSTRIPPING OUT %d %d ", n, nlen);
1370 s = log_line + strlen(log_line);
1371 strncpy(s, str_pool+start, n);
1373 show_line(log_line, 0);
1375 if (nlen > 0) memcpy(str_pool+start, str_pool+end, nlen);
1376 pool_ptr = start + nlen; // poolprt - (end-start);
1379 void show_string (int k)
1381 int nlen = str_start[k+1] - str_start[k];
1384 sprintf(log_line, "\nSTRING %5d (%3d) %5d--%5d ",
1385 k, nlen, str_start[k], str_start[k+1]);
1386 s = log_line + strlen(log_line);
1387 strncpy(s, str_pool+str_start[k], nlen);
1388 strcpy(s + nlen, "");
1389 show_line(log_line, 0);
1392 void show_all_strings (void)
1395 for (k = 0; k < str_ptr; k++) show_string(k);
1398 // int notfirst=0; // debugging only
1400 /********************************** 2000 August 15 end ****************************/
1402 void end_name (void)
1404 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1405 #ifdef ALLOCATESTRING
1406 if (str_ptr + 3 > current_max_strings)
1407 /* str_start = realloc_str_start(increment_max_strings); */
1408 str_start = realloc_str_start(increment_max_strings + 3);
1409 if (str_ptr + 3 > current_max_strings){ /* in case it failed 94/Jan/24 */
1410 overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/7 */
1411 return; // abort_flag set
1414 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1415 if (str_ptr + 3 > max_strings){
1416 overflow("number of strings", max_strings - init_str_ptr); /* number of strings */
1417 return; // abort_flag set
1421 // if (notfirst++ == 0) show_all_strings(); // debugging only
1423 if (area_delimiter == 0) // no area delimiter ':' '/' or '\' found
1424 cur_area = 335; // "" default area
1426 if (save_strings_flag &&
1427 (cur_area = find_string(str_start[str_ptr], str_start[str_ptr]+area_delimiter)) > 0) {
1428 remove_string(str_start[str_ptr], str_start[str_ptr] + area_delimiter);
1429 area_delimiter = 0; // area_delimiter - area_delimiter;
1430 if (ext_delimiter != 0) ext_delimiter = ext_delimiter - area_delimiter;
1431 // str_start[str_ptr + 1]= str_start[str_ptr]+ area_delimiter; // test only
1432 // incr(str_ptr); // test only
1434 else { // carve out string for "cur_area"
1436 str_start[str_ptr + 1]= str_start[str_ptr]+ area_delimiter;
1440 if (ext_delimiter == 0){ // no extension delimiter '.' found
1441 cur_ext = 335; // "" default extension
1442 if (save_strings_flag &&
1443 (cur_name = find_string(str_start[str_ptr], pool_ptr)) > 0) {
1444 remove_string(str_start[str_ptr], pool_ptr);
1445 // (void) make_string(); // test only
1447 else // Make string from str_start[str_ptr]to pool_ptr
1448 cur_name = make_string();
1450 else { // did find an extension
1451 if (save_strings_flag &&
1452 (cur_name = find_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter-1)) > 0) {
1453 remove_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter - 1);
1454 // str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1; // test only
1455 // incr(str_ptr); // test only
1457 else { // carve out string for "cur_name"
1459 str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1;
1462 if (save_strings_flag &&
1463 (cur_ext = find_string(str_start[str_ptr], pool_ptr)) > 0) {
1464 remove_string(str_start[str_ptr], pool_ptr);
1465 // (void) make_string(); // test only
1467 else // Make string from str_start[str_ptr]to pool_ptr
1468 cur_ext = make_string();
1472 /* n current name, a current area, e current extension */
1473 /* result in name_of_file[] */
1475 void pack_file_name_(str_number n, str_number a, str_number e)
1481 {register integer for_end; j = str_start[a];
1482 for_end = str_start[a + 1]- 1; if (j <= for_end) do
1487 name_of_file[k]= xchr[c];
1489 while(j++ < for_end); }
1490 {register integer for_end; j = str_start[n];
1491 for_end = str_start[n + 1]- 1; if (j <= for_end) do
1496 name_of_file[k]= xchr[c];
1498 while(j++ < for_end); }
1499 {register integer for_end; j = str_start[e];
1500 for_end = str_start[e + 1]- 1; if (j <= for_end) do
1505 name_of_file[k]= xchr[c];
1507 while(j++ < for_end); }
1508 if (k < PATHMAX)name_length = k;
1509 else name_length = PATHMAX - 1;
1510 /* pad it out with spaces ... what for ? in case we modify and forget ? */
1511 {register integer for_end; k = name_length + 1; for_end = PATHMAX;
1512 if (k <= for_end) do name_of_file[k]= ' ';
1513 while(k++ < for_end); }
1514 name_of_file[PATHMAX]= '\0'; /* paranoia 94/Mar/24 */
1516 name_of_file [name_length+1] = '\0';
1518 sprintf(log_line, " pack_file_name `%s' (%d) ",
1519 name_of_file+1, name_length); /* debugging */
1520 show_line(log_line, 0);
1522 name_of_file [name_length+1] = ' ';
1526 /* Called only from two places tex9.c for format name - specified and default */
1527 /* for specified format name args are 0, a, b name in buffer[a] --- buffer[b] */
1528 /* for default args are format_default_length-4, 1, 0 */
1529 void pack_buffered_name_(small_number n, integer a, integer b)
1534 if (n + b - a + 5 > PATHMAX)
1535 b = a + PATHMAX - n - 5;
1537 /* This loop kicks in when we want the default format name */
1538 {register integer for_end; j = 1; for_end = n; if (j <= for_end) do
1540 c = xord[TEX_format_default[j]];
1543 name_of_file[k]= xchr[c];
1545 while(j++ < for_end); }
1546 /* This loop kicks in when we want a specififed format name */
1547 {register integer for_end; j = a; for_end = b; if (j <= for_end) do
1552 name_of_file[k]= xchr[c];
1554 while(j++ < for_end); }
1555 /* This adds the extension from the default format name */
1556 {register integer for_end; j = format_default_length - 3; for_end =
1557 format_default_length; if (j <= for_end) do
1559 c = xord[TEX_format_default[j]];
1562 name_of_file[k]= xchr[c];
1564 while(j++ < for_end); }
1567 else name_length = PATHMAX - 1;
1568 /* pad it out with spaces ... what for ? */
1569 {register integer for_end; k = name_length + 1; for_end = PATHMAX; if (k
1571 name_of_file[k]= ' ';
1572 while(k++ < for_end); }
1573 name_of_file[PATHMAX]= '\0'; /* paranoia 94/Mar/24 */
1576 str_number make_name_string (void)
1578 register str_number Result;
1580 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1581 #ifdef ALLOCATESTRING
1582 if (pool_ptr + name_length > current_pool_size)
1583 /* str_pool = realloc_str_pool (increment_pool_size); */
1584 str_pool = realloc_str_pool (increment_pool_size + name_length);
1585 if (str_ptr == current_max_strings)
1586 str_start = realloc_str_start(increment_max_strings);
1587 if ((pool_ptr + name_length > current_pool_size)||
1588 (str_ptr == current_max_strings)||
1589 ((pool_ptr - str_start[str_ptr])> 0))
1591 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1592 if ((pool_ptr + name_length > pool_size)||(str_ptr == max_strings)||
1593 ((pool_ptr - str_start[str_ptr])> 0))
1597 {register integer for_end; k = 1; for_end = name_length; if (k <= for_end) do
1599 str_pool[pool_ptr]= xord[name_of_file[k]];
1600 // sprintf(log_line, "%d => %d ", name_of_file[k], xord[name_of_file[k]]);
1601 // show_line(log_line, 0); // debugging only
1604 while(k++ < for_end); }
1605 Result = make_string();
1610 str_number a_make_name_string_(alpha_file * f)
1612 register str_number Result;
1613 Result = make_name_string();
1615 } /* f unreferenced ? bkph */
1617 str_number b_make_name_string_(byte_file * f)
1619 register str_number Result;
1620 Result = make_name_string();
1622 } /* f unreferenced ? bkph */
1624 str_number w_make_name_string_(word_file * f)
1626 register str_number Result;
1627 Result = make_name_string();
1629 } /* f unreferenced ? bkph */
1631 /* Used by start_input to scan file name on command line */
1632 /* Also in tex8.c new_font_, open_or_close_in, and do_extension */
1634 void scan_file_name (void)
1636 name_in_progress = true;
1640 } while(!(cur_cmd != 10)); /* until cur_cmd != spacer */
1641 quoted_file_name = 0; /* 98/March/15 */
1642 if (allow_quoted_names) { /* check whether quoted name */
1643 if (cur_chr == '"') {
1644 quoted_file_name = 1;
1649 if ((cur_cmd > 12)||(cur_chr > 255))
1650 { /* (cur_cmd > otherchar) OR (cur_chr > 255) */
1651 back_input(); /* not a character put it back and leave */
1654 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1655 /* convert tilde '~' to pseudo tilde */
1656 /* if (pseudo_tilde != 0 && cur_chr == '~') cur_chr = pseudo_tilde; */
1657 /* convert space ' ' to pseudo space */
1658 /* if (pseudo_space != 0 && cur_chr == ' ') cur_chr = pseudo_space; */
1659 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1660 if (! more_name(cur_chr)) /* up to next white space */
1666 name_in_progress = false;
1669 /* argument is string .fmt, .log, or .dvi */
1671 void pack_job_name_(str_number s)
1673 cur_area = 335; /* "" */
1675 cur_name = job_name;
1676 pack_file_name(cur_name, cur_area, cur_ext);
1679 /**********************************************************************/
1681 /* show TEXINPUTS=... or format specific */
1682 /* only show this if name was not fully qualified ? */
1683 void show_tex_inputs (void)
1686 s = "TEXINPUTS"; /* default */
1687 if (format_specific) {
1688 s = format_name; /* try specific */
1689 if (grabenv(s) == NULL) s = "TEXINPUTS"; /* no format specific */
1692 if (grabenv(s) == NULL) s = "TEXINPUT"; /* 94/May/19 */
1696 print_char(40); /*(*/
1698 while (*t > '\0') print_char(*t++);
1703 while (*t > '\0') print_char(*t++);
1708 /**********************************************************************/
1710 void prompt_file_name_(str_number s, str_number e)/* s - what can't be found, e - default */
1713 if (interaction == 2)
1716 print_err("I can't find file `");
1718 print_err("I can't write on file `");
1719 print_file_name(cur_name, cur_area, cur_ext);
1721 if (s == 781){ /* input file name */
1722 if (cur_area == 335) { /* "" only if path not specified */
1723 if (show_texinput_flag) show_tex_inputs();
1726 if (e == 785) /* .tex */
1728 print_nl("Please type another ");
1730 if (interaction < 2){
1731 fatal_error("*** (job aborted, file error in nonstop mode)");
1732 return; // abort_flag set
1736 show_line(" (or ^z to exit)", 0);
1738 show_line(" (or Ctrl-Z to exit)", 0);
1745 /* should we deal with tilde and space in file name here ??? */
1749 /* step over leading spaces ... */
1750 while((buffer[k]== 32)&&(k < last)) incr(k);
1751 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1752 quoted_file_name = 0; /* 98/March/15 */
1753 if (allow_quoted_names && k < last) { /* check whether quoted name */
1754 if (buffer[k]== '"') {
1755 quoted_file_name = 1;
1760 if (k == last) goto lab30;
1761 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1762 /* convert tilde '~' to pseudo tilde */
1763 if (pseudo_tilde != 0 && buffer[k]== '~') buffer[k]= pseudo_tilde;
1764 /* convert space ' ' to pseudo space */
1765 if (pseudo_space != 0 && buffer[k]== ' ') buffer[k]= pseudo_space;
1766 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1767 if (! more_name(buffer[k])) goto lab30;
1772 if (cur_ext == 335) /* "" */
1773 cur_ext = e; /* use default extension */
1774 pack_file_name(cur_name, cur_area, cur_ext);
1777 void open_log_file (void)
1782 ccharpointer months;
1784 old_setting = selector;
1786 if (job_name == 0) job_name = 790; /* default: texput */
1787 pack_job_name(791); /* .log */
1788 while(! a_open_out(log_file)) {
1790 prompt_file_name(793, 791); /* transcript file name texput */
1792 texmf_log_name = a_make_name_string(log_file);
1793 selector = 18; /* log file only */
1796 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1797 // for our version DOS/Windows
1799 // showversion (log_file); /* in local.c - bkph */
1800 // showversion (stdout);
1801 stamp_it(log_line); // ??? use log_line ???
1802 strcat(log_line, "\n");
1803 (void) fputs(log_line, log_file);
1804 // show_line(buffer, 0); // ??? show on screen as well
1806 stampcopy(log_line);
1807 strcat(log_line, "\n");
1808 // show_line(buffer, 0); // ??? show on screen as well
1809 (void) fputs(log_line, log_file);
1812 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1813 /* also change following in itex.c - bkph */
1814 (void) fputs(tex_version, log_file);
1815 (void) fprintf(log_file, " (%s %s)", application, yandyversion);
1816 if (format_ident > 0) slow_print(format_ident); /* bkph */
1818 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1819 if (civilize_flag) print_int(eqtb[(hash_size + 3186)].cint); /* year */
1821 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1822 print_int(eqtb[(hash_size + 3184)].cint); /* day */
1824 months = " JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
1825 {register integer for_end; k = 3 * eqtb[(hash_size + 3185)].cint - 2; for_end = 3
1826 * eqtb[(hash_size + 3185)].cint; if (k <= for_end) do
1827 (void) putc(months[k], log_file);
1828 while(k++ < for_end); } /* month */
1830 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1831 if (civilize_flag) print_int(eqtb[(hash_size + 3184)].cint);/* day */
1833 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1834 print_int(eqtb[(hash_size + 3186)].cint); /* year */
1836 print_two(eqtb[(hash_size + 3183)].cint / 60); /* hour */
1838 print_two(eqtb[(hash_size + 3183)].cint % 60); /* minute */
1840 input_stack[input_ptr]= cur_input;
1842 l = input_stack[0].limit_field;
1843 if (buffer[l]== eqtb[(hash_size + 3211)].cint)
1845 {register integer for_end; k = 1; for_end = l; if (k <= for_end) do
1847 while(k++ < for_end); }
1849 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1850 /* a good place to show the fmt file name or pool file name ? 94/June/21 */
1851 if (show_fmt_flag) {
1852 if (string_file != NULL) {
1853 fprintf(log_file, "(%s)\n", string_file);
1854 free(string_file); /* this was allocated by strdup in openinou */
1855 string_file = NULL; /* for safety */
1857 if (format_file != NULL) {
1858 fprintf(log_file, "(%s)\n", format_file);
1859 free(format_file); /* this was allocated by strdup in openinou */
1860 format_file = NULL; /* for safety */
1863 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1864 selector = old_setting + 2;
1867 /**************************** start of insertion 98/Feb/7 **************/
1869 // Attempt to deal with foo.bar.tex given as foo.bar on command line
1870 // Makes copy of job_name with extension
1872 void morenamecopy(ASCII_code c)
1874 #ifdef ALLOCATESTRING
1875 if (pool_ptr + 1 > current_pool_size)
1876 str_pool = realloc_str_pool (increment_pool_size);
1877 if (pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
1878 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
1879 return; // abort_flag set
1882 if (pool_ptr + 1 > pool_size){
1883 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
1884 return; // abort_flag set
1887 str_pool[pool_ptr]= c;
1891 int endnamecopy(void)
1893 #ifdef ALLOCATESTRING
1894 if (str_ptr + 1 > current_max_strings)
1895 str_start = realloc_str_start(increment_max_strings + 1);
1896 if (str_ptr + 1 > current_max_strings) { /* in case it failed 94/Jan/24 */
1897 overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/7 */
1898 return 0; // abort_flag set
1901 if (str_ptr + 1 > max_strings){
1902 overflow("number of strings", max_strings - init_str_ptr); /* number of strings */
1903 return 0; // abort_flag set
1906 return make_string();
1909 void jobnameappend (void)
1910 { /* add extension to job_name */
1913 k = str_start[job_name];
1914 n = str_start[job_name + 1];
1915 while (k < n) morenamecopy(str_pool[k++]);
1916 /* copy `extension' */
1917 k = str_start[cur_ext];
1918 n = str_start[cur_ext + 1];
1919 while (k < n) morenamecopy(str_pool[k++]);
1920 job_name = endnamecopy();
1923 /**************************** end of insertion 98/Feb/7 **************/
1925 void start_input (void)
1927 bool addedextension = false;
1929 pack_file_name(cur_name, cur_area, cur_ext);
1931 while(true){ /* loop until we get a valid file name */
1932 addedextension = false;
1933 begin_file_reading();
1934 /* *** *** *** *** *** following is new in 3.14159 *** *** *** *** *** *** */
1935 /* if current extension is *not* empty, try to open using name as is */
1936 /* string 335 is "" the empty string */
1937 if ((cur_ext != 335)&& a_open_in(input_file[cur_input.index_field],
1940 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1941 /* we get here if extension is "", or file with extension failed to open */
1942 /* if current extension is not `tex,' and `tex' is not irrelevant, try it */
1943 /* string 785 is .tex */
1944 if ((cur_ext != 785)&&(name_length + 5 < PATHMAX)&&
1945 /* (! extensionirrelevantp(name_of_file, "tex"))){ */
1946 (! extensionirrelevantp(name_of_file, name_length, "tex"))){
1947 name_of_file[name_length + 1] = 46; /* .tex */
1948 name_of_file[name_length + 2] = 116;
1949 name_of_file[name_length + 3] = 101;
1950 name_of_file[name_length + 4] = 120;
1951 name_of_file[name_length + 5] = 32; /* 96/Jan/20 ??? */
1952 name_length = name_length + 4;
1953 addedextension = true;
1954 /* *** *** *** *** following new in 3.14159 *** *** *** *** *** *** *** */
1955 if (a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
1957 name_length = name_length - 4; /* strip extension again */
1958 name_of_file[name_length + 1]= 32; /* ' ' */
1959 addedextension = false;
1960 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1962 /* *** *** *** *** major changes here in 3.14159 *** *** *** *** *** *** */
1963 /* string 335 is "" the empty string */
1964 if ((cur_ext == 335)&& a_open_in(input_file[cur_input.index_field],
1967 if (maketextex () && a_open_in(input_file[cur_input.index_field],
1970 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1972 prompt_file_name(781, 785); /* input file name .tex */
1973 } /* end of while(true)trying to get valid file name */
1975 /* maybe set pseudo_tilde = 0 at this point ? 95/Sep/26 */
1976 lab30: cur_input.name_field =
1977 a_make_name_string(input_file[cur_input.index_field]);
1978 if (job_name == 0) /* only the first time */
1980 job_name = cur_name; /* here we set the job_name */
1981 /* did file name have an `extension' already and we added ".tex" ? */
1982 if (cur_ext != 335 && addedextension) /* 98/Feb/7 */
1983 jobnameappend(); /* append `extension' to job_name */
1986 if (term_offset +(str_start[cur_input.name_field + 1]- str_start[
1987 cur_input.name_field])> max_print_line - 2) /* was 3 ? */
1989 else if ((term_offset > 0)||(file_offset > 0))
1992 // print_char(64); // debugging only marker
1994 if (open_parens > max_open_parens)
1995 max_open_parens = open_parens; /* 1999/Jan/17 */
1996 slow_print(cur_input.name_field);
1997 // print_char(64); // debugging only marker
2001 cur_input.state_field = 33;
2004 if (input_ln(input_file[cur_input.index_field], false))
2007 if ((eqtb[(hash_size + 3211)].cint < 0)||
2008 (eqtb[(hash_size + 3211)].cint > 255))
2009 decr(cur_input.limit_field);
2010 /* long to unsigned char ... */
2011 else buffer[cur_input.limit_field] = eqtb[(hash_size + 3211)].cint;
2012 first = cur_input.limit_field + 1;
2013 cur_input.loc_field = cur_input.start_field;
2017 /**********************************************************************/
2018 /* show TEXFONTS=... or format specific */
2019 /* only show this if name was not fully qualified ? */
2020 void show_tex_fonts (void)
2022 char *s, *t, *v, *u;
2025 if (encoding_specific) {
2026 u = encoding_name; /* try specific */
2027 if ((t = grabenv(u)) != NULL) {
2028 if (strchr(t, ':') != NULL &&
2029 sscanf(t, "%d", &n) == 0) {
2030 s = u; /* look here instead of TEXFONTS=... */
2038 while (*t > '\0') print_char(*t++);
2043 while (*t > '\0') print_char(*t++);
2048 /**********************************************************************/
2050 /* called only from tex8.c */
2052 internal_font_number read_font_info_(halfword u, str_number nom, str_number aire, scaled s)
2054 register internal_font_number Result;
2057 /* halfword lf, lh, bc, ec, nw, nh, nd, ni, nl, nk, ne, np; */
2058 halfword lf, lh, nw, nh, nd, ni, nl, nk, ne, np;
2059 /* halfword bc, ec; */
2060 int bc, ec; /* 95/Jan/7 */
2061 internal_font_number f;
2062 internal_font_number g;
2063 eight_bits a, b, c, d;
2073 pack_file_name(nom, aire, 805); /* .tfm */
2074 if (!b_open_in(tfm_file))
2075 { /* new in C version d */
2078 if (!b_open_in(tfm_file))
2083 /* was just: goto lab11; */
2086 /* tfm_temp = getc(tfm_file); */ /* done already in open_input, but why? */
2091 tfm_temp = getc(tfm_file);
2092 lf = lf * 256 + tfm_temp;
2094 tfm_temp = getc(tfm_file);
2099 tfm_temp = getc(tfm_file);
2100 lh = lh * 256 + tfm_temp;
2102 tfm_temp = getc(tfm_file);
2107 tfm_temp = getc(tfm_file);
2108 bc = bc * 256 + tfm_temp;
2110 tfm_temp = getc(tfm_file);
2115 tfm_temp = getc(tfm_file);
2116 ec = ec * 256 + tfm_temp;
2118 if ((bc > ec + 1)||(ec > 255))
2125 tfm_temp = getc(tfm_file);
2130 tfm_temp = getc(tfm_file);
2131 nw = nw * 256 + tfm_temp;
2133 tfm_temp = getc(tfm_file);
2138 tfm_temp = getc(tfm_file);
2139 nh = nh * 256 + tfm_temp;
2141 tfm_temp = getc(tfm_file);
2146 tfm_temp = getc(tfm_file);
2147 nd = nd * 256 + tfm_temp;
2149 tfm_temp = getc(tfm_file);
2154 tfm_temp = getc(tfm_file);
2155 ni = ni * 256 + tfm_temp;
2157 tfm_temp = getc(tfm_file);
2162 tfm_temp = getc(tfm_file);
2163 nl = nl * 256 + tfm_temp;
2165 tfm_temp = getc(tfm_file);
2170 tfm_temp = getc(tfm_file);
2171 nk = nk * 256 + tfm_temp;
2173 tfm_temp = getc(tfm_file);
2178 tfm_temp = getc(tfm_file);
2179 ne = ne * 256 + tfm_temp;
2181 tfm_temp = getc(tfm_file);
2186 tfm_temp = getc(tfm_file);
2187 np = np * 256 + tfm_temp;
2189 if (lf != 6 + lh +(ec - bc + 1)+ nw + nh + nd + ni + nl + nk + ne + np)
2191 /* For robustness, enforce a restriction checked by TFtoPL (suggested by DRF) */
2192 if ((nw == 0) || (nh == 0) || (nd == 0) || (ni == 0))
2198 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2200 if ((fmem_ptr + lf > current_font_mem_size)) /* 93/Nov/28 */
2201 font_info = realloc_font_info (increment_font_mem_size + lf);
2202 if ((font_ptr == font_max) || (fmem_ptr + lf > current_font_mem_size))
2204 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2205 if ((font_ptr == font_max) || (fmem_ptr + lf > font_mem_size))
2208 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2211 sprintf(log_line, "font_ptr %d font_max %d fmem_ptr %d lf %d font_mem_size %d\n",
2212 font_ptr, font_max, fmem_ptr, lf, font_mem_size); /* debugging */
2213 show_line(log_line, 0);
2216 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2220 print_file_name(nom, aire, 335); /* "" */
2223 print_string(" at ");
2227 else if (s != -1000)
2229 print_string(" scaled ");
2230 print_int(- (integer) s);
2232 print_string(" not loaded: Not enough room left");
2233 help4("I'm afraid I won't be able to make use of this font,",
2234 "because my memory for character-size data is too small.",
2235 "If you're really stuck, ask a wizard to enlarge me.",
2236 "Or maybe try `I\\font<same font id>=<name of loaded font>'.");
2241 char_base[f]= fmem_ptr - bc;
2242 width_base[f]= char_base[f]+ ec + 1;
2243 height_base[f]= width_base[f]+ nw;
2244 depth_base[f]= height_base[f]+ nh;
2245 italic_base[f]= depth_base[f]+ nd;
2246 lig_kern_base[f]= italic_base[f]+ ni;
2247 kern_base[f]= lig_kern_base[f]+ nl - 256 *(128);
2248 exten_base[f]= kern_base[f]+ 256 *(128)+ nk;
2249 param_base[f]= exten_base[f]+ ne;
2253 /* build the font checksum now */
2255 tfm_temp = getc(tfm_file);
2258 tfm_temp = getc(tfm_file);
2261 tfm_temp = getc(tfm_file);
2264 tfm_temp = getc(tfm_file);
2269 tfm_temp = getc(tfm_file);
2274 tfm_temp = getc(tfm_file);
2275 z = z * 256 + tfm_temp;
2277 tfm_temp = getc(tfm_file);
2278 z = z * 256 + tfm_temp;
2279 tfm_temp = getc(tfm_file);
2280 z =(z * 16)+(tfm_temp / 16);
2284 tfm_temp = getc(tfm_file);
2285 tfm_temp = getc(tfm_file);
2286 tfm_temp = getc(tfm_file);
2287 tfm_temp = getc(tfm_file);
2294 else z = xn_over_d(z, - (integer) s, 1000);
2297 {register integer for_end; k = fmem_ptr; for_end = width_base[f]- 1
2298 ; if (k <= for_end) do
2301 tfm_temp = getc(tfm_file);
2304 tfm_temp = getc(tfm_file);
2307 tfm_temp = getc(tfm_file);
2310 tfm_temp = getc(tfm_file);
2313 font_info[k].qqqq = qw;
2315 if ((a >= nw)||(b / 16 >= nh)||(b % 16 >= nd)||(c / 4 >=
2330 if ((d < bc)||(d > ec))
2333 while(d < k + bc - fmem_ptr){
2335 qw = font_info[char_base[f]+ d].qqqq;
2336 if (((qw.b2)% 4)!= 2)
2340 if (d == k + bc - fmem_ptr)
2350 while(k++ < for_end); }
2354 while(z >= 8388608L){ /* 2^23 */
2357 alpha = alpha + alpha;
2359 /* beta = 256 / alpha; */ /* keep compiler happy */
2360 beta = (char) (256 / alpha);
2363 {register integer for_end; k = width_base[f]; for_end = lig_kern_base[
2364 f]- 1; if (k <= for_end) do
2366 tfm_temp = getc(tfm_file);
2368 tfm_temp = getc(tfm_file);
2370 tfm_temp = getc(tfm_file);
2372 tfm_temp = getc(tfm_file);
2374 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2376 font_info[k].cint = sw;
2378 font_info[k].cint = sw - alpha;
2381 while(k++ < for_end); }
2382 if (font_info[width_base[f]].cint != 0)
2384 if (font_info[height_base[f]].cint != 0)
2386 if (font_info[depth_base[f]].cint != 0)
2388 if (font_info[italic_base[f]].cint != 0)
2391 /* read ligature/kern program */
2392 bchlabel = 32767; /* '77777 */
2396 /* begin for k:=lig_kern_base[f] to kern_base[f]+kern_base_offset-1 do */
2397 {register integer for_end; k = lig_kern_base[f]; for_end = kern_base[f
2398 ]+ 256 *(128)- 1; if (k <= for_end) do
2401 tfm_temp = getc(tfm_file);
2404 tfm_temp = getc(tfm_file);
2407 tfm_temp = getc(tfm_file);
2410 tfm_temp = getc(tfm_file);
2413 font_info[k].qqqq = qw; /* store_four_quarters(font_info[k].qqqq */
2417 if (256 * c + d >= nl)
2418 goto lab11; /* error in TFM, abort */
2420 if (k == lig_kern_base[f])
2427 if ((b < bc)||(b > ec)) /* check-existence(b) */
2428 goto lab11; /* error in TFM, abort */
2430 qw = font_info[char_base[f]+ b].qqqq;
2432 goto lab11; /* error in TFM, abort */
2437 if ((d < bc)||(d > ec)) /* check-existence(d) */
2438 goto lab11; /* error in TFM, abort */
2440 qw = font_info[char_base[f]+ d].qqqq;
2442 goto lab11; /* error in TFM, abort */
2444 else if (256 *(c - 128)+ d >= nk)
2445 goto lab11; /* error in TFM, abort */
2447 if (k - lig_kern_base[f]+ a + 1 >= nl)
2448 goto lab11; /* error in TFM, abort */
2451 while(k++ < for_end); }
2453 bchlabel = 256 * c + d;
2455 /* for k:=kern_base[f]+kern_base_offset to exten_base[f]-1 do */
2456 /* store_scaled(font_info[k].sc); */
2457 {register integer for_end; k = kern_base[f]+ 256 *(128); for_end =
2458 exten_base[f]- 1; if (k <= for_end) do
2460 tfm_temp = getc(tfm_file);
2462 tfm_temp = getc(tfm_file);
2464 tfm_temp = getc(tfm_file);
2466 tfm_temp = getc(tfm_file);
2468 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2470 font_info[k].cint = sw;
2472 font_info[k].cint = sw - alpha;
2475 while(k++ < for_end); }
2476 /* read extensible character recipes */
2477 /* for k:=exten_base[f] to param_base[f]-1 do */
2478 {register integer for_end; k = exten_base[f]; for_end = param_base[f]
2479 - 1; if (k <= for_end) do
2482 tfm_temp = getc(tfm_file);
2485 tfm_temp = getc(tfm_file);
2488 tfm_temp = getc(tfm_file);
2491 tfm_temp = getc(tfm_file);
2494 /* store_four_quarters(font_info[k].qqqq); */
2495 font_info[k].qqqq = qw;
2500 if ((a < bc)||(a > ec))
2503 qw = font_info[char_base[f]+ a].qqqq;
2510 if ((b < bc)||(b > ec))
2513 qw = font_info[char_base[f]+ b].qqqq;
2520 if ((c < bc)||(c > ec))
2523 qw = font_info[char_base[f]+ c].qqqq;
2529 if ((d < bc)||(d > ec))
2532 qw = font_info[char_base[f]+ d].qqqq;
2537 while(k++ < for_end); }
2539 {register integer for_end; k = 1; for_end = np; if (k <= for_end) do
2542 tfm_temp = getc(tfm_file);
2546 tfm_temp = getc(tfm_file);
2547 sw = sw * 256 + tfm_temp;
2548 tfm_temp = getc(tfm_file);
2549 sw = sw * 256 + tfm_temp;
2550 tfm_temp = getc(tfm_file);
2551 font_info[param_base[f]].cint =(sw * 16)+(tfm_temp / 16);
2555 tfm_temp = getc(tfm_file);
2557 tfm_temp = getc(tfm_file);
2559 tfm_temp = getc(tfm_file);
2561 tfm_temp = getc(tfm_file);
2563 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2565 font_info[param_base[f]+ k - 1].cint = sw;
2567 font_info[param_base[f]+ k - 1].cint = sw - alpha;
2570 while(k++ < for_end); }
2571 /* use test_eof() here instead ? */
2574 {register integer for_end; k = np + 1; for_end = 7; if (k <= for_end)
2576 font_info[param_base[f]+ k - 1].cint = 0;
2577 while(k++ < for_end); }
2579 /* @<Make final adjustments...@>= l.11174 */
2582 else font_params[f]= 7;
2583 hyphen_char[f]= eqtb[(hash_size + 3209)].cint; /* default_hyphen_char */
2584 skew_char[f]= eqtb[(hash_size + 3210)].cint; /* default_skew_char */
2586 bchar_label[f]= bchlabel + lig_kern_base[f];
2587 /* bchar_label[f]:=non_address; */ /* 3.14159 */
2588 /* else bchar_label[f]= font_mem_size; */ /* OK ??? 93/Nov/28 */
2589 else bchar_label[f]= non_address; /* i.e. 0 --- 96/Jan/15 */
2590 font_bchar[f]= bchar;
2591 font_false_bchar[f]= bchar;
2595 qw = font_info[char_base[f]+ bchar].qqqq;
2597 font_false_bchar[f]= 256;
2600 font_area[f] = aire;
2603 font_glue[f] = 0; /* font_glue[f]:=null; l.11184 */
2604 char_base[f] = char_base[f];
2605 width_base[f] = width_base[f];
2606 lig_kern_base[f] = lig_kern_base[f];
2607 kern_base[f] = kern_base[f];
2608 exten_base[f] = exten_base[f];
2609 decr(param_base[f]);
2610 fmem_ptr = fmem_ptr + lf;
2618 print_file_name(nom, aire, 335); /* "" */
2621 print_string("at ");
2625 else if (s != -1000)
2627 print_string("scaled");
2628 print_int(- (integer) s);
2630 if (fileopened)print_string("not loadable: Bad metric (TFM) file");
2631 else print_string("not loadable: Metric (TFM) file not found");
2632 if (aire == 335) { /* "" only if path not specified */
2633 if (show_texinput_flag) show_tex_fonts(); /* 98/Jan/31 */
2635 help5("I wasn't able to read the size data for this font,",
2636 "so I will ignore the font specification.",
2637 "[Wizards can fix TFM files using TFtoPL/PLtoTF.]",
2638 "You might try inserting a different font spec;",
2639 "e.g., type `I\\font<same font id>=<substitute font name>'.");
2642 if (fileopened)b_close(tfm_file);