[tex-live] \scantokens and --file-line-error

Olaf Weber olaf at infovore.xs4all.nl
Mon Aug 23 23:25:22 CEST 2004


Karl Berry writes:

> Hi Olaf (I guess this one is for you),
> The \scantokens etex construct and --file-line-error option apparently
> interact in strange ways.

Then let's remove \scantokens.

Ok, ok.  Here's what several error cases could look like.

--------------
$ ./etex -file-line-error '\scantokens{\foo}'
This is e-TeXk, Version 3.141592-2.1 (Web2C 7.5.3)
 file:line:error style messages enabled.
entering extended mode
! Undefined control sequence.
l.1 \foo

<*> \scantokens{\foo}

?
--------------
$ ./etex -file-line-error '\foo'
This is e-TeXk, Version 3.141592-2.1 (Web2C 7.5.3)
 file:line:error style messages enabled.
entering extended mode
! Undefined control sequence.
<*> \foo

?                                                    
--------------
$ ./etex -file-line-error bar
This is e-TeXk, Version 3.141592-2.1 (Web2C 7.5.3)
 file:line:error style messages enabled.
entering extended mode
(./bar.tex (./ssc.tex
./ssc.tex:2: Undefined control sequence.
l.1 \foo

l.1 \scantokens {\foo }

l.2 \scantokens{\scantokens{\foo}}

?
-------------- bar.tex --------------
\input ssc
-------------- ssc.tex --------------

\scantokens{\scantokens{\foo}}
--------------  --------------

Code that does the above follows.  Should I check it in?

Index: tex.ch
===================================================================
RCS file: /usr/local/cvsroot/texk/texk/web2c/tex.ch,v
retrieving revision 1.83
diff -u -d -r1.83 tex.ch
--- tex.ch      5 Aug 2004 21:23:19 -0000       1.83
+++ tex.ch      23 Aug 2004 21:23:00 -0000
@@ -851,14 +851,9 @@
 @x [6.73] l.1734 - file:line:error style error messages.
   print_nl("! "); print(#);
 @y
-  if (file_line_error_style_p and not terminal_input) then
-  begin
-    print_nl ("");
-    print (full_source_filename_stack[in_open]);
-    print (":"); print_int (line); print (": ");
-    print (#);
-  end
-  else begin print_nl("! "); print(#) end;
+  if file_line_error_style_p then print_file_line
+  else print_nl("! ");
+  print(#);
 @z


@@ -4994,6 +4989,29 @@
 @<Glob...@> =
 @!debug_format_file: boolean;

+
+@ A helper for printing file:line:error style messages.  Look for a
+filename in |full_source_filename_stack|, and if we fail to find
+one fall back on the non-file:line:error style.
+
+@<Basic print...@>=
+procedure print_file_line;
+var level: 0..max_in_open;
+begin
+  level:=in_open;
+  while (level>0) and (full_source_filename_stack[level]=0) do
+    decr(level);
+  if level=0 then
+    print_nl("! ")
+  else begin
+    print_nl (""); print (full_source_filename_stack[level]); print (":");
+    if level=in_open then print_int (line)
+    else print_int (line_stack[index+1-(in_open-level)]);
+    print (": ");
+  end;
+end;
+
+
 @ Dumping the |xord|, |xchr|, and |xprn| arrays.  We dump these always
 in the format, so a TCX file loaded during format creation can set a
 default for users of the format.


-- 
Olaf Weber

               (This space left blank for technical reasons.)



More information about the tex-live mailing list