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")) {
300 cur_val = xn_over_d(cur_val, 1000, mag);
301 f =(1000 * f + 65536L * tex_remainder) / mag;
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 */
556 avail = mem[q].hh.v.RH;
565 mem[q].hh.v.LH = mem[r].hh.v.LH;
573 old_setting = selector;
576 switch(cur_val_level)
582 print_scaled(cur_val);
588 print_spec(cur_val, "pt");
589 delete_glue_ref(cur_val);
594 print_spec(cur_val, "mu");
595 delete_glue_ref(cur_val);
599 selector = old_setting;
600 Result = str_toks(b);
604 void ins_the_toks (void)
606 mem[lig_trick].hh.v.RH = the_toks();
607 begin_token_list(mem[temp_head].hh.v.RH, 4);
609 void conv_toks (void)
613 small_number savescannerstatus;
626 savescannerstatus = scanner_status;
629 scanner_status = savescannerstatus;
636 if (job_name == 0)open_log_file();
639 old_setting = selector;
647 print_roman_int(cur_val);
652 else print_char(cur_chr);
659 print(font_name[cur_val]);
660 if (font_size[cur_val]!= font_dsize[cur_val])
662 print_string(" at ");
663 print_scaled(font_size[cur_val]);
672 selector = old_setting;
673 mem[lig_trick].hh.v.RH = str_toks(b);
674 begin_token_list(mem[temp_head].hh.v.RH, 4);
676 halfword scan_toks_(bool macrodef, bool xpand)
677 {/* 40 30 31 32 */ register halfword Result;
686 else scanner_status = 5;
687 warning_index = cur_cs;
688 def_ref = get_avail();
689 mem[def_ref].hh.v.LH = 0;
709 mem[q].hh.v.LH = cur_tok;
715 mem[q].hh.v.LH = 3584;
722 print_err("You already have nine parameters");
723 help1("I'm going to ignore the # sign you just used.");
730 print_err("Parameters must be numbered consecutively");
731 help2("I've inserted the digit you should have used after the #.",
732 "Type `1' to delete what you did use.");
741 mem[q].hh.v.LH = cur_tok;
748 mem[q].hh.v.LH = 3584;
753 print_err("Missing { inserted");
755 help2("Where was the left brace? You said something like `\\def\\a}',",
756 "which I'm going to interpret as `\\def\\a{}'.");
770 if (cur_cmd <= 100) goto lab32;
776 /* if link(temp_head)<>null then l.9376 */
777 if (mem[temp_head].hh.v.RH != 0)
779 mem[p].hh.v.RH = mem[temp_head].hh.v.RH;
789 if (cur_cmd < 2) incr(unbalance);
795 else if (cur_cmd == 6)
798 if (xpand)get_x_token();
801 if ((cur_tok <= 3120)||(cur_tok > t)) {
802 print_err("Illegal parameter number in definition of");
803 sprint_cs(warning_index);
804 help3("You meant to type ## instead of #, right?",
805 "Or maybe a } was forgotten somewhere earlier, and things",
806 "are all screwed up? I'm going to assume that you meant ##.");
810 else cur_tok = 1232 + cur_chr;
815 mem[q].hh.v.LH = cur_tok;
819 lab40: scanner_status = 0;
824 mem[q].hh.v.LH = hashbrace;
830 /* used only in ITEX.C */
831 void read_toks_(integer n, halfword r)
836 /* small_number m; */
837 int m; /* 95/Jan/7 */
840 def_ref = get_avail();
841 mem[def_ref].hh.v.LH = 0;
846 mem[q].hh.v.LH = 3584;
849 if ((n < 0)||(n > 15)) m = 16;
852 align_state = 1000000L;
854 begin_file_reading();
855 cur_input.name_field = m + 1;
856 if (read_open[m]== 2)
875 fatal_error("*** (cannot \\read from terminal in nonstop modes)"); /* */
876 return; // abort_flag set
878 else if (read_open[m]== 1)
879 if (input_ln(read_file[m], false))
882 (void) a_close(read_file[m]);
886 if (! input_ln(read_file[m], true)) {
887 (void) a_close(read_file[m]);
889 if (align_state != 1000000L) {
891 print_err("File ended within");
893 help1("This \\read has unbalanced braces.");
894 align_state = 1000000L;
899 cur_input.limit_field = last;
900 if ((end_line_char < 0)||(end_line_char > 255))
901 decr(cur_input.limit_field);
902 /* long to unsigned char ... */
903 else buffer[cur_input.limit_field]= end_line_char;
904 first = cur_input.limit_field + 1;
905 cur_input.loc_field = cur_input.start_field;
906 cur_input.state_field = 33;
911 if (align_state < 1000000L)
915 } while(!(cur_tok == 0));
916 align_state = 1000000L;
922 mem[q].hh.v.LH = cur_tok;
926 lab30: end_file_reading();
927 } while(!(align_state == 1000000L));
932 void pass_text (void)
935 small_number savescannerstatus;
936 savescannerstatus = scanner_status;
943 if (l == 0) goto lab30;
947 else if (cur_cmd == 105) incr(l);
950 scanner_status = savescannerstatus;
952 void change_if_limit_(small_number l, halfword p)
960 if (q == 0) { /* begin if q=null then confusion("if"); l.9674 */
962 return; // abort_flag set
964 if (mem[q].hh.v.RH == p)
973 /* called from tex2.c */
974 void conditional (void)
980 small_number savescannerstatus;
981 halfword savecondptr;
984 /* begin p:=get_node(if_node_size); */
985 p = get_node(2); /* p <- get_node(if_node_size); p.495*/
986 /* link(p):=cond_ptr; */
987 mem[p].hh.v.RH = cond_ptr;
988 /* type(p):=if_limit; */
989 mem[p].hh.b0 = if_limit;
990 /* subtype(p):=cur_if; */
991 mem[p].hh.b1 = cur_if;
992 /* if_line_field(p):=if_line; */
993 mem[p + 1].cint = if_line;
999 savecondptr = cond_ptr; /* save_cond_ptr <- cond_ptr; p.498 */
1007 if (cur_cmd == 0) /* if cur_cmd = relax then .. p.506 */
1008 if (cur_chr == 257) /* if cur_chr = no_expand_flag then ... p.506 */
1011 cur_chr = cur_tok - 4096;
1014 if ((cur_cmd > 13)||(cur_chr > 255))
1025 if (cur_cmd == 0) /* if cur_cmd = relax then .. p.506 */
1026 if (cur_chr == 257) /* if cur_chr = no_expand_flag then ... p.506 */
1029 cur_chr = cur_tok - 4096;
1032 if ((cur_cmd > 13)||(cur_chr > 255))
1039 else b =(m == cur_cmd);
1049 scan_dimen(false, false, false);
1054 } while(!(cur_cmd != 10));
1055 if ((cur_tok >= 3132)&&(cur_tok <= 3134))
1058 print_err("Missing = inserted for ");
1059 print_cmd_chr(105, thisif); /* i */
1060 help1("I was expecting to see `<', `=', or `>'. Didn't.");
1068 scan_dimen(false, false, false);
1093 b =(abs(mode)== 102);
1096 b =(abs(mode)== 203);
1105 scan_eight_bit_int();
1106 p = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
1111 else if (thisif == 10)
1112 b =(mem[p].hh.b0 == 0);
1113 else b =(mem[p].hh.b0 == 1);
1118 savescannerstatus = scanner_status;
1125 if (cur_cmd != p) b = false;
1126 else if (cur_cmd < 111) b =(cur_chr == q);
1128 p = mem[cur_chr].hh.v.RH;
1129 q = mem[eqtb[n].hh.v.RH].hh.v.RH;
1133 /* else begin while (p<>null)and(q<>null) do l.9840 */
1134 while((p != 0)&&(q != 0)) if (mem[p].hh.v.LH != mem[
1136 p = 0; /* p:=null */
1141 b =((p == 0)&&(q == 0)); /* b:=((p=null)and(q=null)); */
1144 scanner_status = savescannerstatus;
1149 scan_four_bit_int();
1150 b =(read_open[cur_val]== 2);
1163 if (tracing_commands > 1)
1166 print_string("{case ");
1169 end_diagnostic(false);
1173 if (cond_ptr == savecondptr)
1177 else if (cur_chr == 2)
1180 if_line = mem[p + 1].cint;
1181 cur_if = mem[p].hh.b1;
1182 if_limit = mem[p].hh.b0;
1183 cond_ptr = mem[p].hh.v.RH;
1187 change_if_limit(4, savecondptr);
1192 if (tracing_commands > 1)
1196 print_string("{true}");
1197 else print_string("{false}");
1198 end_diagnostic(false);
1200 if (b) /* b may be used without ... */
1202 change_if_limit(3, savecondptr);
1207 if (cond_ptr == savecondptr)
1211 print_err("Extra ");
1213 help1("I'm ignoring this; it doesn't match any \\if.");
1216 else if (cur_chr == 2)
1219 if_line = mem[p + 1].cint;
1220 cur_if = mem[p].hh.b1;
1221 if_limit = mem[p].hh.b0;
1222 cond_ptr = mem[p].hh.v.RH;
1226 lab50: if (cur_chr == 2)
1229 if_line = mem[p + 1].cint;
1230 cur_if = mem[p].hh.b1;
1231 if_limit = mem[p].hh.b0;
1232 cond_ptr = mem[p].hh.v.RH;
1237 void begin_name (void)
1239 area_delimiter = 0; /* index between `file area' and `file name' */
1240 ext_delimiter = 0; /* index between `file name' and `file extension' */
1242 /* This gathers up a file name and makes a string of it */
1243 /* Also tries to break it into `file area' `file name' and `file extension' */
1244 /* Used by scan_file_name and prompt_file_name */
1245 /* We assume tilde has been converted to pseudo_tilde and space to pseudo_space */
1246 /* returns false if it is given a space character - end of file name */
1247 bool more_name_(ASCII_code c)
1249 register bool Result;
1251 /* if (c == 32)*/ /* white space delimits file name ... */
1252 if (quoted_file_name == 0 && c == 32)
1254 else if (quoted_file_name != 0 && c == '"') {
1255 quoted_file_name = 0; /* catch next space character */
1256 Result = true; /* accept ending quote, but throw away */
1258 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1259 /* convert pseudo tilde back to '~' 95/Sep/26 */ /* moved here 97/June/5 */
1260 /* if (pseudo_tilde != 0 && c == pseudo_tilde) c = '~'; */
1261 /* convert pseudo space back to ' ' 97/June/5 */ /* moved here 97/June/5 */
1262 /* if (pseudo_space != 0 && c == pseudo_space) c = ' '; */
1263 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1265 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1266 #ifdef ALLOCATESTRING
1267 if (pool_ptr + 1 > current_pool_size)
1268 str_pool = realloc_str_pool (increment_pool_size);
1269 if (pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
1270 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
1271 return 0; // abort_flag set
1274 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1275 if (pool_ptr + 1 > pool_size){
1276 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
1277 return 0; // abort_flag set
1282 str_pool[pool_ptr] = c;
1285 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1286 // if ((c == 47)) /* / */
1288 if ((c == '/' || c == '\\' || c == ':')) /* 94/Mar/1 */
1289 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1291 area_delimiter = cur_length;
1294 else if (c == 46) /* . */
1295 ext_delimiter = cur_length;
1300 /******************************** 2000 August 15th start ***********************/
1302 // The following code is to save string space used by TeX for filenames
1303 // Not really critical in a system that has dynamic memory allocation
1304 // And may slow it down slightly - although this linear search only
1305 // occurs when opening a file, which is somewhat slow inany case...
1307 // see if string from str_pool[start] to str_pool[end]
1308 // occurs elsewhere in string pool - returns string number
1309 // returns -1 if not found in string pool 2000 Aug 15
1311 int find_string (int start, int end)
1313 int k, nlen= end-start;
1316 // int trace_flag = 1; // debugging only
1319 sprintf(log_line, "\nLOOKING for string (str_ptr %d nlen %d) ", str_ptr, end-start);
1320 s = log_line + strlen(log_line);
1321 strncpy(s, str_pool + start, nlen);
1323 show_line(log_line, 0);
1326 // avoid problems with(cur_name == flushablestring)by going only up to str_ptr-1
1327 // code in new_font (tex8.c) will take care of reuse of font name already
1328 // for (k = 0; k < str_ptr; k++) {
1329 for (k = 0; k < str_ptr-1; k++) {
1330 if (length(k) != nlen) continue;
1331 if (strncmp((const char *)str_pool + start, (const char *) str_pool + str_start[k], nlen) == 0) {
1333 sprintf(log_line, "\nFOUND the string %d (%d) ", k, str_start[k+1]-str_start[k]);
1334 s = log_line + strlen(log_line);
1335 strncpy(s, (const char *)str_pool + start, nlen);
1336 strcpy(s+nlen, "\n");
1337 show_line(log_line, 0);
1339 return k; // return number of matching string
1343 sprintf(log_line, "\nNOT FOUND string ");
1344 s = log_line + strlen(log_line);
1345 strncpy(s, (const char*)str_pool + start, nlen);
1346 strcpy(s+nlen, "\n");
1347 show_line(log_line, 0);
1349 return -1; // no match found
1352 // snip out the string from str_pool[start] to str_pool[end]
1353 // and move everything above it down 2000 Aug 15
1355 void remove_string (int start, int end)
1357 int nlen = pool_ptr - end; // how many bytes to move down
1360 // int trace_flag=1; // debugging only
1361 // if (end < start) show_line("\nEND < START", 1);
1362 // if (pool_ptr < end) show_line("\nPOOLPTR < END", 1);
1366 sprintf(log_line, "\nSTRIPPING OUT %d %d ", n, nlen);
1367 s = log_line + strlen(log_line);
1368 strncpy(s, (const char *)str_pool + start, n);
1370 show_line(log_line, 0);
1372 if (nlen > 0) memcpy(str_pool+start, str_pool+end, nlen);
1373 pool_ptr = start + nlen; // poolprt - (end-start);
1376 void show_string (int k)
1378 int nlen = length(k);
1381 sprintf(log_line, "\nSTRING %5d (%3d) %5d--%5d ",
1382 k, nlen, str_start[k], str_start[k+1]);
1383 s = log_line + strlen(log_line);
1384 strncpy(s, (const char *)str_pool + str_start[k], nlen);
1385 strcpy(s + nlen, "");
1386 show_line(log_line, 0);
1389 void show_all_strings (void)
1392 for (k = 0; k < str_ptr; k++) show_string(k);
1395 // int notfirst=0; // debugging only
1397 /********************************** 2000 August 15 end ****************************/
1399 void end_name (void)
1401 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1402 #ifdef ALLOCATESTRING
1403 if (str_ptr + 3 > current_max_strings)
1404 /* str_start = realloc_str_start(increment_max_strings); */
1405 str_start = realloc_str_start(increment_max_strings + 3);
1406 if (str_ptr + 3 > current_max_strings){ /* in case it failed 94/Jan/24 */
1407 overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/7 */
1408 return; // abort_flag set
1411 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1412 if (str_ptr + 3 > max_strings){
1413 overflow("number of strings", max_strings - init_str_ptr); /* number of strings */
1414 return; // abort_flag set
1418 // if (notfirst++ == 0) show_all_strings(); // debugging only
1420 if (area_delimiter == 0) // no area delimiter ':' '/' or '\' found
1421 cur_area = 335; // "" default area
1423 if (save_strings_flag &&
1424 (cur_area = find_string(str_start[str_ptr], str_start[str_ptr]+area_delimiter)) > 0) {
1425 remove_string(str_start[str_ptr], str_start[str_ptr] + area_delimiter);
1426 area_delimiter = 0; // area_delimiter - area_delimiter;
1427 if (ext_delimiter != 0) ext_delimiter = ext_delimiter - area_delimiter;
1428 // str_start[str_ptr + 1]= str_start[str_ptr]+ area_delimiter; // test only
1429 // incr(str_ptr); // test only
1431 else { // carve out string for "cur_area"
1433 str_start[str_ptr + 1]= str_start[str_ptr]+ area_delimiter;
1437 if (ext_delimiter == 0){ // no extension delimiter '.' found
1438 cur_ext = 335; // "" default extension
1439 if (save_strings_flag &&
1440 (cur_name = find_string(str_start[str_ptr], pool_ptr)) > 0) {
1441 remove_string(str_start[str_ptr], pool_ptr);
1442 // (void) make_string(); // test only
1444 else // Make string from str_start[str_ptr]to pool_ptr
1445 cur_name = make_string();
1447 else { // did find an extension
1448 if (save_strings_flag &&
1449 (cur_name = find_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter-1)) > 0) {
1450 remove_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter - 1);
1451 // str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1; // test only
1452 // incr(str_ptr); // test only
1454 else { // carve out string for "cur_name"
1456 str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1;
1459 if (save_strings_flag &&
1460 (cur_ext = find_string(str_start[str_ptr], pool_ptr)) > 0) {
1461 remove_string(str_start[str_ptr], pool_ptr);
1462 // (void) make_string(); // test only
1464 else // Make string from str_start[str_ptr]to pool_ptr
1465 cur_ext = make_string();
1469 /* n current name, a current area, e current extension */
1470 /* result in name_of_file[] */
1472 void pack_file_name_(str_number n, str_number a, str_number e)
1478 {register integer for_end; j = str_start[a];
1479 for_end = str_start[a + 1]- 1; if (j <= for_end) do
1484 name_of_file[k]= xchr[c];
1486 while(j++ < for_end); }
1487 {register integer for_end; j = str_start[n];
1488 for_end = str_start[n + 1]- 1; if (j <= for_end) do
1493 name_of_file[k]= xchr[c];
1495 while(j++ < for_end); }
1496 {register integer for_end; j = str_start[e];
1497 for_end = str_start[e + 1]- 1; if (j <= for_end) do
1502 name_of_file[k]= xchr[c];
1504 while(j++ < for_end); }
1505 if (k < PATHMAX)name_length = k;
1506 else name_length = PATHMAX - 1;
1507 /* pad it out with spaces ... what for ? in case we modify and forget ? */
1508 {register integer for_end; k = name_length + 1; for_end = PATHMAX;
1509 if (k <= for_end) do name_of_file[k]= ' ';
1510 while(k++ < for_end); }
1511 name_of_file[PATHMAX]= '\0'; /* paranoia 94/Mar/24 */
1513 name_of_file [name_length+1] = '\0';
1515 sprintf(log_line, " pack_file_name `%s' (%d) ",
1516 name_of_file+1, name_length); /* debugging */
1517 show_line(log_line, 0);
1519 name_of_file [name_length+1] = ' ';
1523 /* Called only from two places tex9.c for format name - specified and default */
1524 /* for specified format name args are 0, a, b name in buffer[a] --- buffer[b] */
1525 /* for default args are format_default_length-4, 1, 0 */
1526 void pack_buffered_name_(small_number n, integer a, integer b)
1531 if (n + b - a + 5 > PATHMAX)
1532 b = a + PATHMAX - n - 5;
1534 /* This loop kicks in when we want the default format name */
1535 {register integer for_end; j = 1; for_end = n; if (j <= for_end) do
1537 c = xord[TEX_format_default[j]];
1540 name_of_file[k]= xchr[c];
1542 while(j++ < for_end); }
1543 /* This loop kicks in when we want a specififed format name */
1544 {register integer for_end; j = a; for_end = b; if (j <= for_end) do
1549 name_of_file[k]= xchr[c];
1551 while(j++ < for_end); }
1552 /* This adds the extension from the default format name */
1553 {register integer for_end; j = format_default_length - 3; for_end =
1554 format_default_length; if (j <= for_end) do
1556 c = xord[TEX_format_default[j]];
1559 name_of_file[k]= xchr[c];
1561 while(j++ < for_end); }
1564 else name_length = PATHMAX - 1;
1565 /* pad it out with spaces ... what for ? */
1566 {register integer for_end; k = name_length + 1; for_end = PATHMAX; if (k
1568 name_of_file[k]= ' ';
1569 while(k++ < for_end); }
1570 name_of_file[PATHMAX]= '\0'; /* paranoia 94/Mar/24 */
1573 str_number make_name_string (void)
1575 register str_number Result;
1577 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1578 #ifdef ALLOCATESTRING
1579 if (pool_ptr + name_length > current_pool_size)
1580 /* str_pool = realloc_str_pool (increment_pool_size); */
1581 str_pool = realloc_str_pool (increment_pool_size + name_length);
1582 if (str_ptr == current_max_strings)
1583 str_start = realloc_str_start(increment_max_strings);
1584 if ((pool_ptr + name_length > current_pool_size)||
1585 (str_ptr == current_max_strings)||
1588 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1589 if ((pool_ptr + name_length > pool_size)||(str_ptr == max_strings)||
1594 {register integer for_end; k = 1; for_end = name_length; if (k <= for_end) do
1596 str_pool[pool_ptr]= xord[name_of_file[k]];
1597 // sprintf(log_line, "%d => %d ", name_of_file[k], xord[name_of_file[k]]);
1598 // show_line(log_line, 0); // debugging only
1601 while(k++ < for_end); }
1602 Result = make_string();
1607 str_number a_make_name_string_(alpha_file * f)
1609 register str_number Result;
1610 Result = make_name_string();
1612 } /* f unreferenced ? bkph */
1614 str_number b_make_name_string_(byte_file * f)
1616 register str_number Result;
1617 Result = make_name_string();
1619 } /* f unreferenced ? bkph */
1621 str_number w_make_name_string_(word_file * f)
1623 register str_number Result;
1624 Result = make_name_string();
1626 } /* f unreferenced ? bkph */
1628 /* Used by start_input to scan file name on command line */
1629 /* Also in tex8.c new_font_, open_or_close_in, and do_extension */
1631 void scan_file_name (void)
1633 name_in_progress = true;
1637 } while(!(cur_cmd != 10)); /* until cur_cmd != spacer */
1638 quoted_file_name = 0; /* 98/March/15 */
1639 if (allow_quoted_names) { /* check whether quoted name */
1640 if (cur_chr == '"') {
1641 quoted_file_name = 1;
1646 if ((cur_cmd > 12)||(cur_chr > 255))
1647 { /* (cur_cmd > otherchar) OR (cur_chr > 255) */
1648 back_input(); /* not a character put it back and leave */
1651 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1652 /* convert tilde '~' to pseudo tilde */
1653 /* if (pseudo_tilde != 0 && cur_chr == '~') cur_chr = pseudo_tilde; */
1654 /* convert space ' ' to pseudo space */
1655 /* if (pseudo_space != 0 && cur_chr == ' ') cur_chr = pseudo_space; */
1656 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1657 if (! more_name(cur_chr)) /* up to next white space */
1663 name_in_progress = false;
1666 /* argument is string .fmt, .log, or .dvi */
1668 void pack_job_name_(str_number s)
1670 cur_area = 335; /* "" */
1672 cur_name = job_name;
1673 pack_file_name(cur_name, cur_area, cur_ext);
1676 /**********************************************************************/
1678 /* show TEXINPUTS=... or format specific */
1679 /* only show this if name was not fully qualified ? */
1680 void show_tex_inputs (void)
1683 s = "TEXINPUTS"; /* default */
1684 if (format_specific) {
1685 s = format_name; /* try specific */
1686 if (grabenv(s) == NULL) s = "TEXINPUTS"; /* no format specific */
1689 if (grabenv(s) == NULL) s = "TEXINPUT"; /* 94/May/19 */
1693 print_char(40); /*(*/
1695 while (*t > '\0') print_char(*t++);
1700 while (*t > '\0') print_char(*t++);
1705 /**********************************************************************/
1707 void prompt_file_name_(str_number s, str_number e)/* s - what can't be found, e - default */
1710 if (interaction == scroll_mode)
1713 print_err("I can't find file `");
1715 print_err("I can't write on file `");
1716 print_file_name(cur_name, cur_area, cur_ext);
1718 if (s == 781){ /* input file name */
1719 if (cur_area == 335) { /* "" only if path not specified */
1720 if (show_texinput_flag) show_tex_inputs();
1723 if (e == 785) /* .tex */
1725 print_nl("Please type another ");
1727 if (interaction < 2){
1728 fatal_error("*** (job aborted, file error in nonstop mode)");
1729 return; // abort_flag set
1733 show_line(" (or ^z to exit)", 0);
1735 show_line(" (or Ctrl-Z to exit)", 0);
1742 /* should we deal with tilde and space in file name here ??? */
1746 /* step over leading spaces ... */
1747 while((buffer[k]== 32)&&(k < last)) incr(k);
1748 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1749 quoted_file_name = 0; /* 98/March/15 */
1750 if (allow_quoted_names && k < last) { /* check whether quoted name */
1751 if (buffer[k]== '"') {
1752 quoted_file_name = 1;
1757 if (k == last) goto lab30;
1758 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1759 /* convert tilde '~' to pseudo tilde */
1760 if (pseudo_tilde != 0 && buffer[k]== '~') buffer[k]= pseudo_tilde;
1761 /* convert space ' ' to pseudo space */
1762 if (pseudo_space != 0 && buffer[k]== ' ') buffer[k]= pseudo_space;
1763 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1764 if (! more_name(buffer[k])) goto lab30;
1769 if (cur_ext == 335) /* "" */
1770 cur_ext = e; /* use default extension */
1771 pack_file_name(cur_name, cur_area, cur_ext);
1774 void open_log_file (void)
1779 ccharpointer months;
1781 old_setting = selector;
1783 if (job_name == 0) job_name = 790; /* default: texput */
1784 pack_job_name(791); /* .log */
1785 while(! a_open_out(log_file)) {
1787 prompt_file_name(793, 791); /* transcript file name texput */
1789 texmf_log_name = a_make_name_string(log_file);
1790 selector = 18; /* log file only */
1793 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1794 // for our version DOS/Windows
1796 // showversion (log_file); /* in local.c - bkph */
1797 // showversion (stdout);
1798 stamp_it(log_line); // ??? use log_line ???
1799 strcat(log_line, "\n");
1800 (void) fputs(log_line, log_file);
1801 // show_line(buffer, 0); // ??? show on screen as well
1803 stampcopy(log_line);
1804 strcat(log_line, "\n");
1805 // show_line(buffer, 0); // ??? show on screen as well
1806 (void) fputs(log_line, log_file);
1809 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1810 /* also change following in itex.c - bkph */
1811 (void) fputs(tex_version, log_file);
1812 (void) fprintf(log_file, " (%s %s)", application, yandyversion);
1813 if (format_ident > 0) slow_print(format_ident); /* bkph */
1815 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1816 if (civilize_flag) print_int(year); /* year */
1818 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1821 months = " JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
1822 {register integer for_end; k = 3 * month - 2; for_end = 3
1823 * month; if (k <= for_end) do
1824 (void) putc(months[k], log_file);
1825 while(k++ < for_end); } /* month */
1827 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1828 if (civilize_flag) print_int(day);
1830 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1831 print_int(year); /* year */
1833 print_two(tex_time / 60); /* hour */
1835 print_two(tex_time % 60); /* minute */
1837 input_stack[input_ptr]= cur_input;
1839 l = input_stack[0].limit_field;
1840 if (buffer[l]== eqtb[(hash_size + 3211)].cint)
1842 {register integer for_end; k = 1; for_end = l; if (k <= for_end) do
1844 while(k++ < for_end); }
1846 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1847 /* a good place to show the fmt file name or pool file name ? 94/June/21 */
1848 if (show_fmt_flag) {
1849 if (string_file != NULL) {
1850 fprintf(log_file, "(%s)\n", string_file);
1851 free(string_file); /* this was allocated by strdup in openinou */
1852 string_file = NULL; /* for safety */
1854 if (format_file != NULL) {
1855 fprintf(log_file, "(%s)\n", format_file);
1856 free(format_file); /* this was allocated by strdup in openinou */
1857 format_file = NULL; /* for safety */
1860 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1861 selector = old_setting + 2;
1864 /**************************** start of insertion 98/Feb/7 **************/
1866 // Attempt to deal with foo.bar.tex given as foo.bar on command line
1867 // Makes copy of job_name with extension
1869 void morenamecopy(ASCII_code c)
1871 #ifdef ALLOCATESTRING
1872 if (pool_ptr + 1 > current_pool_size)
1873 str_pool = realloc_str_pool (increment_pool_size);
1874 if (pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
1875 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
1876 return; // abort_flag set
1879 if (pool_ptr + 1 > pool_size){
1880 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
1881 return; // abort_flag set
1884 str_pool[pool_ptr]= c;
1888 int endnamecopy(void)
1890 #ifdef ALLOCATESTRING
1891 if (str_ptr + 1 > current_max_strings)
1892 str_start = realloc_str_start(increment_max_strings + 1);
1893 if (str_ptr + 1 > current_max_strings) { /* in case it failed 94/Jan/24 */
1894 overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/7 */
1895 return 0; // abort_flag set
1898 if (str_ptr + 1 > max_strings){
1899 overflow("number of strings", max_strings - init_str_ptr); /* number of strings */
1900 return 0; // abort_flag set
1903 return make_string();
1906 void jobnameappend (void)
1907 { /* add extension to job_name */
1910 k = str_start[job_name];
1911 n = str_start[job_name + 1];
1912 while (k < n) morenamecopy(str_pool[k++]);
1913 /* copy `extension' */
1914 k = str_start[cur_ext];
1915 n = str_start[cur_ext + 1];
1916 while (k < n) morenamecopy(str_pool[k++]);
1917 job_name = endnamecopy();
1920 /**************************** end of insertion 98/Feb/7 **************/
1922 void start_input (void)
1924 bool addedextension = false;
1926 pack_file_name(cur_name, cur_area, cur_ext);
1928 while(true){ /* loop until we get a valid file name */
1929 addedextension = false;
1930 begin_file_reading();
1931 /* *** *** *** *** *** following is new in 3.14159 *** *** *** *** *** *** */
1932 /* if current extension is *not* empty, try to open using name as is */
1933 /* string 335 is "" the empty string */
1934 if ((cur_ext != 335)&& a_open_in(input_file[cur_input.index_field],
1937 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1938 /* we get here if extension is "", or file with extension failed to open */
1939 /* if current extension is not `tex,' and `tex' is not irrelevant, try it */
1940 /* string 785 is .tex */
1941 if ((cur_ext != 785)&&(name_length + 5 < PATHMAX)&&
1942 /* (! extensionirrelevantp(name_of_file, "tex"))){ */
1943 (! extensionirrelevantp(name_of_file, name_length, "tex"))){
1944 name_of_file[name_length + 1] = 46; /* .tex */
1945 name_of_file[name_length + 2] = 116;
1946 name_of_file[name_length + 3] = 101;
1947 name_of_file[name_length + 4] = 120;
1948 name_of_file[name_length + 5] = 32; /* 96/Jan/20 ??? */
1949 name_length = name_length + 4;
1950 addedextension = true;
1951 /* *** *** *** *** following new in 3.14159 *** *** *** *** *** *** *** */
1952 if (a_open_in(input_file[cur_input.index_field], TEXINPUTPATH))
1954 name_length = name_length - 4; /* strip extension again */
1955 name_of_file[name_length + 1]= 32; /* ' ' */
1956 addedextension = false;
1957 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1959 /* *** *** *** *** major changes here in 3.14159 *** *** *** *** *** *** */
1960 /* string 335 is "" the empty string */
1961 if ((cur_ext == 335)&& a_open_in(input_file[cur_input.index_field],
1964 if (maketextex () && a_open_in(input_file[cur_input.index_field],
1967 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1969 prompt_file_name(781, 785); /* input file name .tex */
1970 } /* end of while(true)trying to get valid file name */
1972 /* maybe set pseudo_tilde = 0 at this point ? 95/Sep/26 */
1973 lab30: cur_input.name_field =
1974 a_make_name_string(input_file[cur_input.index_field]);
1975 if (job_name == 0) /* only the first time */
1977 job_name = cur_name; /* here we set the job_name */
1978 /* did file name have an `extension' already and we added ".tex" ? */
1979 if (cur_ext != 335 && addedextension) /* 98/Feb/7 */
1980 jobnameappend(); /* append `extension' to job_name */
1983 if (term_offset + length(cur_input.name_field) > max_print_line - 2) /* was 3 ? */
1985 else if ((term_offset > 0)||(file_offset > 0))
1988 // print_char(64); // debugging only marker
1990 if (open_parens > max_open_parens)
1991 max_open_parens = open_parens; /* 1999/Jan/17 */
1992 slow_print(cur_input.name_field);
1993 // print_char(64); // debugging only marker
1997 cur_input.state_field = 33;
2000 if (input_ln(input_file[cur_input.index_field], false))
2003 if ((end_line_char < 0)||
2004 (end_line_char > 255))
2005 decr(cur_input.limit_field);
2006 /* long to unsigned char ... */
2007 else buffer[cur_input.limit_field] = end_line_char;
2008 first = cur_input.limit_field + 1;
2009 cur_input.loc_field = cur_input.start_field;
2013 /**********************************************************************/
2014 /* show TEXFONTS=... or format specific */
2015 /* only show this if name was not fully qualified ? */
2016 void show_tex_fonts (void)
2018 char *s, *t, *v, *u;
2021 if (encoding_specific) {
2022 u = encoding_name; /* try specific */
2023 if ((t = grabenv(u)) != NULL) {
2024 if (strchr(t, ':') != NULL &&
2025 sscanf(t, "%d", &n) == 0) {
2026 s = u; /* look here instead of TEXFONTS=... */
2034 while (*t > '\0') print_char(*t++);
2039 while (*t > '\0') print_char(*t++);
2044 /**********************************************************************/
2046 /* called only from tex8.c */
2048 internal_font_number read_font_info_(halfword u, str_number nom, str_number aire, scaled s)
2050 register internal_font_number Result;
2053 /* halfword lf, lh, bc, ec, nw, nh, nd, ni, nl, nk, ne, np; */
2054 halfword lf, lh, nw, nh, nd, ni, nl, nk, ne, np;
2055 /* halfword bc, ec; */
2056 int bc, ec; /* 95/Jan/7 */
2057 internal_font_number f;
2058 internal_font_number g;
2059 eight_bits a, b, c, d;
2069 pack_file_name(nom, aire, 805); /* .tfm */
2070 if (!b_open_in(tfm_file))
2071 { /* new in C version d */
2074 if (!b_open_in(tfm_file))
2079 /* was just: goto lab11; */
2082 /* tfm_temp = getc(tfm_file); */ /* done already in open_input, but why? */
2087 tfm_temp = getc(tfm_file);
2088 lf = lf * 256 + tfm_temp;
2090 tfm_temp = getc(tfm_file);
2095 tfm_temp = getc(tfm_file);
2096 lh = lh * 256 + tfm_temp;
2098 tfm_temp = getc(tfm_file);
2103 tfm_temp = getc(tfm_file);
2104 bc = bc * 256 + tfm_temp;
2106 tfm_temp = getc(tfm_file);
2111 tfm_temp = getc(tfm_file);
2112 ec = ec * 256 + tfm_temp;
2114 if ((bc > ec + 1)||(ec > 255))
2121 tfm_temp = getc(tfm_file);
2126 tfm_temp = getc(tfm_file);
2127 nw = nw * 256 + tfm_temp;
2129 tfm_temp = getc(tfm_file);
2134 tfm_temp = getc(tfm_file);
2135 nh = nh * 256 + tfm_temp;
2137 tfm_temp = getc(tfm_file);
2142 tfm_temp = getc(tfm_file);
2143 nd = nd * 256 + tfm_temp;
2145 tfm_temp = getc(tfm_file);
2150 tfm_temp = getc(tfm_file);
2151 ni = ni * 256 + tfm_temp;
2153 tfm_temp = getc(tfm_file);
2158 tfm_temp = getc(tfm_file);
2159 nl = nl * 256 + tfm_temp;
2161 tfm_temp = getc(tfm_file);
2166 tfm_temp = getc(tfm_file);
2167 nk = nk * 256 + tfm_temp;
2169 tfm_temp = getc(tfm_file);
2174 tfm_temp = getc(tfm_file);
2175 ne = ne * 256 + tfm_temp;
2177 tfm_temp = getc(tfm_file);
2182 tfm_temp = getc(tfm_file);
2183 np = np * 256 + tfm_temp;
2185 if (lf != 6 + lh +(ec - bc + 1)+ nw + nh + nd + ni + nl + nk + ne + np)
2187 /* For robustness, enforce a restriction checked by TFtoPL (suggested by DRF) */
2188 if ((nw == 0) || (nh == 0) || (nd == 0) || (ni == 0))
2194 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2196 if ((fmem_ptr + lf > current_font_mem_size)) /* 93/Nov/28 */
2197 font_info = realloc_font_info (increment_font_mem_size + lf);
2198 if ((font_ptr == font_max) || (fmem_ptr + lf > current_font_mem_size))
2200 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2201 if ((font_ptr == font_max) || (fmem_ptr + lf > font_mem_size))
2204 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2207 sprintf(log_line, "font_ptr %d font_max %d fmem_ptr %d lf %d font_mem_size %d\n",
2208 font_ptr, font_max, fmem_ptr, lf, font_mem_size); /* debugging */
2209 show_line(log_line, 0);
2212 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
2216 print_file_name(nom, aire, 335); /* "" */
2219 print_string(" at ");
2223 else if (s != -1000)
2225 print_string(" scaled ");
2226 print_int(- (integer) s);
2228 print_string(" not loaded: Not enough room left");
2229 help4("I'm afraid I won't be able to make use of this font,",
2230 "because my memory for character-size data is too small.",
2231 "If you're really stuck, ask a wizard to enlarge me.",
2232 "Or maybe try `I\\font<same font id>=<name of loaded font>'.");
2237 char_base[f]= fmem_ptr - bc;
2238 width_base[f]= char_base[f]+ ec + 1;
2239 height_base[f]= width_base[f]+ nw;
2240 depth_base[f]= height_base[f]+ nh;
2241 italic_base[f]= depth_base[f]+ nd;
2242 lig_kern_base[f]= italic_base[f]+ ni;
2243 kern_base[f]= lig_kern_base[f]+ nl - 256 *(128);
2244 exten_base[f]= kern_base[f]+ 256 *(128)+ nk;
2245 param_base[f]= exten_base[f]+ ne;
2249 /* build the font checksum now */
2251 tfm_temp = getc(tfm_file);
2254 tfm_temp = getc(tfm_file);
2257 tfm_temp = getc(tfm_file);
2260 tfm_temp = getc(tfm_file);
2265 tfm_temp = getc(tfm_file);
2270 tfm_temp = getc(tfm_file);
2271 z = z * 256 + tfm_temp;
2273 tfm_temp = getc(tfm_file);
2274 z = z * 256 + tfm_temp;
2275 tfm_temp = getc(tfm_file);
2276 z =(z * 16)+(tfm_temp / 16);
2280 tfm_temp = getc(tfm_file);
2281 tfm_temp = getc(tfm_file);
2282 tfm_temp = getc(tfm_file);
2283 tfm_temp = getc(tfm_file);
2290 else z = xn_over_d(z, - (integer) s, 1000);
2293 {register integer for_end; k = fmem_ptr; for_end = width_base[f]- 1
2294 ; if (k <= for_end) do
2297 tfm_temp = getc(tfm_file);
2300 tfm_temp = getc(tfm_file);
2303 tfm_temp = getc(tfm_file);
2306 tfm_temp = getc(tfm_file);
2309 font_info[k].qqqq = qw;
2311 if ((a >= nw)||(b / 16 >= nh)||(b % 16 >= nd)||(c / 4 >=
2326 if ((d < bc)||(d > ec))
2329 while(d < k + bc - fmem_ptr){
2331 qw = font_info[char_base[f]+ d].qqqq;
2332 if (((qw.b2)% 4)!= 2)
2336 if (d == k + bc - fmem_ptr)
2346 while(k++ < for_end); }
2350 while(z >= 8388608L){ /* 2^23 */
2353 alpha = alpha + alpha;
2355 /* beta = 256 / alpha; */ /* keep compiler happy */
2356 beta = (char) (256 / alpha);
2359 {register integer for_end; k = width_base[f]; for_end = lig_kern_base[
2360 f]- 1; if (k <= for_end) do
2362 tfm_temp = getc(tfm_file);
2364 tfm_temp = getc(tfm_file);
2366 tfm_temp = getc(tfm_file);
2368 tfm_temp = getc(tfm_file);
2370 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2372 font_info[k].cint = sw;
2374 font_info[k].cint = sw - alpha;
2377 while(k++ < for_end); }
2378 if (font_info[width_base[f]].cint != 0)
2380 if (font_info[height_base[f]].cint != 0)
2382 if (font_info[depth_base[f]].cint != 0)
2384 if (font_info[italic_base[f]].cint != 0)
2387 /* read ligature/kern program */
2388 bchlabel = 32767; /* '77777 */
2392 /* begin for k:=lig_kern_base[f] to kern_base[f]+kern_base_offset-1 do */
2393 {register integer for_end; k = lig_kern_base[f]; for_end = kern_base[f
2394 ]+ 256 *(128)- 1; if (k <= for_end) do
2397 tfm_temp = getc(tfm_file);
2400 tfm_temp = getc(tfm_file);
2403 tfm_temp = getc(tfm_file);
2406 tfm_temp = getc(tfm_file);
2409 font_info[k].qqqq = qw; /* store_four_quarters(font_info[k].qqqq */
2413 if (256 * c + d >= nl)
2414 goto lab11; /* error in TFM, abort */
2416 if (k == lig_kern_base[f])
2423 if ((b < bc)||(b > ec)) /* check-existence(b) */
2424 goto lab11; /* error in TFM, abort */
2426 qw = font_info[char_base[f]+ b].qqqq;
2428 goto lab11; /* error in TFM, abort */
2433 if ((d < bc)||(d > ec)) /* check-existence(d) */
2434 goto lab11; /* error in TFM, abort */
2436 qw = font_info[char_base[f]+ d].qqqq;
2438 goto lab11; /* error in TFM, abort */
2440 else if (256 *(c - 128)+ d >= nk)
2441 goto lab11; /* error in TFM, abort */
2443 if (k - lig_kern_base[f]+ a + 1 >= nl)
2444 goto lab11; /* error in TFM, abort */
2447 while(k++ < for_end); }
2449 bchlabel = 256 * c + d;
2451 /* for k:=kern_base[f]+kern_base_offset to exten_base[f]-1 do */
2452 /* store_scaled(font_info[k].sc); */
2453 {register integer for_end; k = kern_base[f]+ 256 *(128); for_end =
2454 exten_base[f]- 1; if (k <= for_end) do
2456 tfm_temp = getc(tfm_file);
2458 tfm_temp = getc(tfm_file);
2460 tfm_temp = getc(tfm_file);
2462 tfm_temp = getc(tfm_file);
2464 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2466 font_info[k].cint = sw;
2468 font_info[k].cint = sw - alpha;
2471 while(k++ < for_end); }
2472 /* read extensible character recipes */
2473 /* for k:=exten_base[f] to param_base[f]-1 do */
2474 {register integer for_end; k = exten_base[f]; for_end = param_base[f]
2475 - 1; if (k <= for_end) do
2478 tfm_temp = getc(tfm_file);
2481 tfm_temp = getc(tfm_file);
2484 tfm_temp = getc(tfm_file);
2487 tfm_temp = getc(tfm_file);
2490 /* store_four_quarters(font_info[k].qqqq); */
2491 font_info[k].qqqq = qw;
2496 if ((a < bc)||(a > ec))
2499 qw = font_info[char_base[f]+ a].qqqq;
2506 if ((b < bc)||(b > ec))
2509 qw = font_info[char_base[f]+ b].qqqq;
2516 if ((c < bc)||(c > ec))
2519 qw = font_info[char_base[f]+ c].qqqq;
2525 if ((d < bc)||(d > ec))
2528 qw = font_info[char_base[f]+ d].qqqq;
2533 while(k++ < for_end); }
2535 {register integer for_end; k = 1; for_end = np; if (k <= for_end) do
2538 tfm_temp = getc(tfm_file);
2542 tfm_temp = getc(tfm_file);
2543 sw = sw * 256 + tfm_temp;
2544 tfm_temp = getc(tfm_file);
2545 sw = sw * 256 + tfm_temp;
2546 tfm_temp = getc(tfm_file);
2547 font_info[param_base[f]].cint =(sw * 16)+(tfm_temp / 16);
2551 tfm_temp = getc(tfm_file);
2553 tfm_temp = getc(tfm_file);
2555 tfm_temp = getc(tfm_file);
2557 tfm_temp = getc(tfm_file);
2559 sw =(((((d * z)/ 256)+(c * z)) / 256)+(b * z)) / beta;
2561 font_info[param_base[f]+ k - 1].cint = sw;
2563 font_info[param_base[f]+ k - 1].cint = sw - alpha;
2566 while(k++ < for_end); }
2567 /* use test_eof() here instead ? */
2570 {register integer for_end; k = np + 1; for_end = 7; if (k <= for_end)
2572 font_info[param_base[f]+ k - 1].cint = 0;
2573 while(k++ < for_end); }
2575 /* @<Make final adjustments...@>= l.11174 */
2578 else font_params[f]= 7;
2579 hyphen_char[f] = default_hyphen_char;
2580 skew_char[f] = default_skew_char;
2582 bchar_label[f]= bchlabel + lig_kern_base[f];
2583 /* bchar_label[f]:=non_address; */ /* 3.14159 */
2584 /* else bchar_label[f]= font_mem_size; */ /* OK ??? 93/Nov/28 */
2585 else bchar_label[f]= non_address; /* i.e. 0 --- 96/Jan/15 */
2586 font_bchar[f]= bchar;
2587 font_false_bchar[f]= bchar;
2591 qw = font_info[char_base[f]+ bchar].qqqq;
2593 font_false_bchar[f]= 256;
2596 font_area[f] = aire;
2599 font_glue[f] = 0; /* font_glue[f]:=null; l.11184 */
2600 char_base[f] = char_base[f];
2601 width_base[f] = width_base[f];
2602 lig_kern_base[f] = lig_kern_base[f];
2603 kern_base[f] = kern_base[f];
2604 exten_base[f] = exten_base[f];
2605 decr(param_base[f]);
2606 fmem_ptr = fmem_ptr + lf;
2614 print_file_name(nom, aire, 335); /* "" */
2617 print_string(" at ");
2621 else if (s != -1000)
2623 print_string("scaled");
2624 print_int(- (integer) s);
2626 if (fileopened)print_string(" not loadable: Bad metric (TFM) file");
2627 else print_string(" not loadable: Metric (TFM) file not found");
2628 if (aire == 335) { /* "" only if path not specified */
2629 if (show_texinput_flag) show_tex_fonts(); /* 98/Jan/31 */
2631 help5("I wasn't able to read the size data for this font,",
2632 "so I will ignore the font specification.",
2633 "[Wizards can fix TFM files using TFtoPL/PLtoTF.]",
2634 "You might try inserting a different font spec;",
2635 "e.g., type `I\\font<same font id>=<substitute font name>'.");
2638 if (fileopened)b_close(tfm_file);