From 3ee93d47be726d793d999ded2a3639849e322f3b Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 9 Feb 2020 19:12:24 +0000 Subject: \input{...} now in all engines git-svn-id: svn://tug.org/texlive/trunk@53729 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/tex.ch | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'Build/source/texk/web2c/tex.ch') diff --git a/Build/source/texk/web2c/tex.ch b/Build/source/texk/web2c/tex.ch index a45b99198c2..20c1d7dd986 100644 --- a/Build/source/texk/web2c/tex.ch +++ b/Build/source/texk/web2c/tex.ch @@ -1892,6 +1892,27 @@ begin if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings)or area_delimiter:=save_area_delimiter; ext_delimiter:=save_ext_delimiter; @z +@x [29.526] l.10193 - look for a left_brace when scanning a file name +@p procedure scan_file_name; +label done; +@y +@p procedure scan_file_name; +label done; +var + @!save_warning_index: pointer; +begin + save_warning_index := warning_index; + warning_index := cur_cs; {store |cur_cs| here to remember until later} + @; {here the program expands + tokens and removes spaces and \.{\\relax}es from the input. The \.{\\relax} + removal follows LuaTeX''s implementation, and other cases of + balanced text scanning.} + back_input; {return the last token to be read by either code path} + if cur_cmd=left_brace then + scan_file_name_braced + else +@z + @x [29.526] l.10194 - stop scanning file name if we're at end-of-line. if not more_name(cur_chr) then goto done; @y @@ -1902,6 +1923,63 @@ begin if (pool_ptr+name_length>pool_size)or(str_ptr=max_strings)or if not more_name(cur_chr) then goto done; @z +@x [29.526] l.10203 - scan a bgroup/egroup-delimited file name +done: end_name; name_in_progress:=false; +end; +@y + end; +done: end_name; name_in_progress:=false; +warning_index := save_warning_index; {restore |warning_index|} +end; + +@ When |scan_file_name| starts it looks for a |left_brace| +(skipping \.{\\relax}es, as other \.{\\toks}-like primitives). +If a |left_brace| is found, then the procedure scans a file +name contained in a balanced token list, expanding tokens as +it goes. When the scanner finds the balanced token list, it +is converted into a string and fed character-by-character to +|more_name| to do its job the same as in the ``normal'' file +name scanning. + +@p procedure scan_file_name_braced; +var + @!save_scanner_status: small_number; {|scanner_status| upon entry} + @!save_def_ref: pointer; {|def_ref| upon entry, important if inside `\.{\\message}} + @!save_cur_cs: pointer; + @!s: str_number; {temp string} + @!p: pointer; {temp pointer} + @!i: integer; {loop tally} + @!save_stop_at_space: boolean; {this should be in tex.ch} + @!dummy: boolean; + {Initialising} +begin save_scanner_status := scanner_status; {|scan_toks| sets |scanner_status| to |absorbing|} + save_def_ref := def_ref; {|scan_toks| uses |def_ref| to point to the token list just read} + save_cur_cs := cur_cs; {we set |cur_cs| back a few tokens to use in runaway errors} + {Scanning a token list} + cur_cs := warning_index; {for possible runaway error} + {mimick |call_func| from pdfTeX} + if scan_toks(false, true) <> 0 then do_nothing; {actually do the scanning} + {s := tokens_to_string(def_ref);} + old_setting := selector; selector:=new_string; + show_token_list(link(def_ref),null,pool_size-pool_ptr); + selector := old_setting; + s := make_string; + {turns the token list read in a string to input} + {Restoring some variables} + delete_token_ref(def_ref); {remove the token list from memory} + def_ref := save_def_ref; {and restore |def_ref|} + cur_cs := save_cur_cs; {restore |cur_cs|} + scanner_status := save_scanner_status; {restore |scanner_status|} + {Passing the read string to the input machinery} + save_stop_at_space := stop_at_space; {save |stop_at_space|} + stop_at_space := false; {set |stop_at_space| to false to allow spaces in file names} + begin_name; + for i:=str_start[s] to str_start[s+1]-1 do + dummy := more_name(str_pool[i]); {add each read character to the current file name} + stop_at_space := save_stop_at_space; {restore |stop_at_space|} +end; +@z + @x [29.530] l.10245 - prompt_file_name: prevent empty filenames. var k:0..buf_size; {index into |buffer|} @y -- cgit v1.2.3