[tex-live] Make the extensions for formats different for each
engine.
Olaf Weber
olaf at infovore.xs4all.nl
Thu Apr 15 21:52:58 CEST 2004
Olaf Weber writes:
> Putting a fingerprint in the format file itself is not mutually
> exclusive with this.
Example of how the "fingerprint" would work in case of a mismatch:
infovore:/home/olaf/web2c/src/texk/texk/web2c$ ./tex \&pdftex
This is TeXk, Version 3.141592 (Web2C 7.5.2)
%&-line parsing enabled.
(Fatal format file error; pdftex.fmt was written by pdftex)
Sample implementation of the above (a few changes to other files are
also needed):
$ cvs diff -u tex.ch
Index: tex.ch
===================================================================
RCS file: /usr/local/cvsroot/texk/texk/web2c/tex.ch,v
retrieving revision 1.65
diff -u -r1.65 tex.ch
--- a/tex.ch 28 Mar 2004 11:43:19 -0000 1.65
+++ b/tex.ch 15 Apr 2004 19:40:35 -0000
@@ -224,6 +224,7 @@
@!max_trie_op=ssup_trie_opcode; {largest possible trie opcode for any language}
@!pool_name=TEX_POOL_NAME; {this is configurable, for the sake of ML-\TeX}
{string of length |file_name_size|; tells where the string pool appears}
+@!engine_name=TEX_ENGINE_NAME; {the name of this engine}
@#
@!inf_mem_bot = 0;
@!sup_mem_bot = 1;
@@ -3731,9 +3732,11 @@
@z
% Eliminate now-unused variable `w' in `store_fmt_file'.
+% Add format_engine.
@x [50.1302] l.23690
@!w: four_quarters; {four ASCII codes}
@y
+@!format_engine: ^text_char;
@z
% MLTeX: dump |mltex_p| to fmt file
@@ -3760,9 +3763,11 @@
% Eliminate now-unused variable `w' in `load_fmt_file'.
% Add dummies for undumping encTeX into the void.
+% Add format_engine.
@x [50.1303] l.23722
@!w: four_quarters; {four ASCII codes}
@y
+@!format_engine: ^text_char;
@!dummy_xord: ASCII_code;
@!dummy_xchr: text_char;
@!dummy_xprn: ASCII_code;
@@ -3833,6 +3838,15 @@
@x [50,1307] l.23779 - texarray
dump_int(@$);@/
@y
+dump_int(@"57325458); {Web2C \TeX's magic constant: "W2TX"}
+{Align engine to 4 bytes with one or more trailing NUL}
+x:=strlen(engine_name);
+format_engine:=xmalloc_array(text_char,x+4);
+strcpy(format_engine, engine_name);
+for k:=x to x+3 do format_engine[k]:=0;
+x:=x+4-(x mod 4);
+dump_int(x);dump_things(format_engine[0], x);
+libc_free(format_engine);@/
dump_int(@$);@/
dump_int(max_halfword);@/
dump_int(hash_high);
@@ -3854,6 +3868,28 @@
libc_free(yhash); libc_free(zeqtb); libc_free(yzmem);
@+Tini
undump_int(x);
+format_debug('format magic number')(x);
+if x<>@"57325458 then goto bad_fmt; {not a format file}
+undump_int(x);
+format_debug('engine name size')(x);
+if (x<0) or (x>256) then goto bad_fmt; {corrupted format file}
+format_engine:=xmalloc_array(text_char, x);
+undump_things(format_engine[0], x);
+format_engine[x-1]:=0; {force string termination, just in case}
+if strcmp(engine_name, format_engine) then
+ begin wake_up_terminal;
+ fputs('(Fatal format file error; ', stderr);
+ at .Fatal format file error@>
+ fputs(stringcast(name_of_file+1), stderr);
+ fputs(' was written by ', stderr);
+ fputs(format_engine, stderr);
+ write_ln(stderr, ')');
+ libc_free(format_engine);
+ load_fmt_file:=false;
+ goto exit;
+end;
+libc_free(format_engine);
+undump_int(x);
format_debug('string pool checksum')(x);
if x<>@$ then goto bad_fmt; {check that strings are the same}
undump_int(x);
--
Olaf Weber
(This space left blank for technical reasons.)
More information about the tex-live
mailing list