pub(crate) unsafe fn read_toks(input: &mut input_state_t, n: i32, r: i32, j: i32) -> i32 {
    scanner_status = ScannerStatus::Defining;
    warning_index = r;
    def_ref = get_avail();
    *token_ref_count(def_ref) = None.tex_int();
    let mut p = def_ref; // tail of the token list
    store_new_token(&mut p, END_MATCH_TOKEN);
    let m = if n < 0 || n > 15 { 16 } else { n as i16 }; // stream number
    let s = align_state; // saved value of `align_state`
    align_state = 1000000; // disable tab marks, etc.
    loop {
        // Input and store tokens from the next line of the file
        begin_file_reading(input);
        input.name = m as i32 + 1;
        assert!(
            read_open[m as usize] != OpenMode::Closed,
            /*503:*/
            "terminal input forbidden"
        );
        /*505:*/
        if read_open[m as usize] == OpenMode::JustOpen {
            // Input the first line of `read_file[m]`
            if read_file[m as usize].as_mut().unwrap().input_line() {
                read_open[m as usize] = OpenMode::Normal;
            } else {
                let _ = read_file[m as usize].take();
                read_open[m as usize] = OpenMode::Closed;
            }
        } else if !read_file[m as usize].as_mut().unwrap().input_line() {
            // Input the next line of |read_file[m]|
            let _ = read_file[m as usize].take();
            read_open[m as usize] = OpenMode::Closed;
            if align_state as i64 != 1000000 {
                runaway();
                t_eprint!("File ended within {}", Esc("read"));
                help!("This \\read has unbalanced braces.");
                align_state = 1000000;
                error();
            }
        }
        input.limit = last;
        if get_int_par(IntPar::end_line_char) < 0 || get_int_par(IntPar::end_line_char) > 255 {
            input.limit -= 1
        } else {
            BUFFER[input.limit] = get_int_par(IntPar::end_line_char)
        }
        first = input.limit + 1;
        input.loc = input.start;
        input.state = InputState::NewLine;
        // Handle `\readline` and goto `'done`
        let limit = input.limit;
        let loc = input.loc.as_mut().unwrap();
        if j == 1 {
            while *loc <= limit {
                // current line not yet finished
                let chr = BUFFER[*loc];
                *loc += 1;
                let tok = if chr == ' ' as i32 {
                    SPACE_TOKEN
                } else {
                    chr + OTHER_TOKEN
                };
                store_new_token(&mut p, tok);
            }
        } else {
            loop {
                let mut tok = get_token(input).0;
                if tok == 0 {
                    break;
                    // `cmd=chr=0` will occur at the end of the line
                }
                if (align_state as i64) < 1000000 {
                    // unmatched `}` aborts the line
                    loop {
                        tok = get_token(input).0;
                        if tok == 0 {
                            break;
                        }
                    }
                    align_state = 1000000;
                    break;
                } else {
                    store_new_token(&mut p, tok);
                }
            }
        }
        end_file_reading(input);
        if align_state as i64 == 1000000 {
            break;
        }
    }
    scanner_status = ScannerStatus::Normal;
    align_state = s;
    def_ref as i32
}
/// The `read_toks` procedure constructs a token list like that for any
/// macro definition, and makes `cur_val` point to it. Parameter `r` points
/// to the control sequence that will receive this token list.
The `read_toks` procedure constructs a token list like that for any
macro definition, and makes `cur_val` point to it. Parameter `r` points
to the control sequence that will receive this token list.
The ` read_toks ` procedure constructs a token list like that for any macro definition and makes ` cur_val ` point to it . Parameter ` r ` points to the control sequence that will receive this token list .
pub(crate) unsafe fn read_toks(input: &mut input_state_t, n: i32, r: i32, j: i32) -> i32 {
    scanner_status = ScannerStatus::Defining;
    warning_index = r;
    def_ref = get_avail();
    *token_ref_count(def_ref) = None.tex_int();
    let mut p = def_ref; // tail of the token list
    store_new_token(&mut p, END_MATCH_TOKEN);
    let m = if n < 0 || n > 15 { 16 } else { n as i16 }; // stream number
    let s = align_state; // saved value of `align_state`
    align_state = 1000000; // disable tab marks, etc.
    loop {
        // Input and store tokens from the next line of the file
        begin_file_reading(input);
        input.name = m as i32 + 1;
        assert!(
            read_open[m as usize] != OpenMode::Closed,
            /*503:*/
            "terminal input forbidden"
        );
        /*505:*/
        if read_open[m as usize] == OpenMode::JustOpen {
            // Input the first line of `read_file[m]`
            if read_file[m as usize].as_mut().unwrap().input_line() {
                read_open[m as usize] = OpenMode::Normal;
            } else {
                let _ = read_file[m as usize].take();
                read_open[m as usize] = OpenMode::Closed;
            }
        } else if !read_file[m as usize].as_mut().unwrap().input_line() {
            // Input the next line of |read_file[m]|
            let _ = read_file[m as usize].take();
            read_open[m as usize] = OpenMode::Closed;
            if align_state as i64 != 1000000 {
                runaway();
                t_eprint!("File ended within {}", Esc("read"));
                help!("This \\read has unbalanced braces.");
                align_state = 1000000;
                error();
            }
        }
        input.limit = last;
        if get_int_par(IntPar::end_line_char) < 0 || get_int_par(IntPar::end_line_char) > 255 {
            input.limit -= 1
        } else {
            BUFFER[input.limit] = get_int_par(IntPar::end_line_char)
        }
        first = input.limit + 1;
        input.loc = input.start;
        input.state = InputState::NewLine;
        // Handle `\readline` and goto `'done`
        let limit = input.limit;
        let loc = input.loc.as_mut().unwrap();
        if j == 1 {
            while *loc <= limit {
                // current line not yet finished
                let chr = BUFFER[*loc];
                *loc += 1;
                let tok = if chr == ' ' as i32 {
                    SPACE_TOKEN
                } else {
                    chr + OTHER_TOKEN
                };
                store_new_token(&mut p, tok);
            }
        } else {
            loop {
                let mut tok = get_token(input).0;
                if tok == 0 {
                    break;
                    // `cmd=chr=0` will occur at the end of the line
                }
                if (align_state as i64) < 1000000 {
                    // unmatched `}` aborts the line
                    loop {
                        tok = get_token(input).0;
                        if tok == 0 {
                            break;
                        }
                    }
                    align_state = 1000000;
                    break;
                } else {
                    store_new_token(&mut p, tok);
                }
            }
        }
        end_file_reading(input);
        if align_state as i64 == 1000000 {
            break;
        }
    }
    scanner_status = ScannerStatus::Normal;
    align_state = s;
    def_ref as i32
}
pub ( crate ) unsafe fn read_toks ( input : & mut input_state_t , n : i32 , r : i32 , j : i32 ) -> i32 { scanner_status = ScannerStatus :: Defining ; warning_index = r ; def_ref = get_avail ( ) ; * token_ref_count ( def_ref ) = None . tex_int ( ) ; let mut p = def_ref ; // tail of the token list store_new_token ( & mut p , END_MATCH_TOKEN ) ; let m = if n < 0 || n > 15 { 16 } else { n as i16 } ; // stream number let s = align_state ; // saved value of `align_state` align_state = 1000000 ; // disable tab marks, etc. loop { // Input and store tokens from the next line of the file begin_file_reading ( input ) ; input . name = m as i32 + 1 ; assert ! ( read_open [ m as usize ] OpenMode Closed /*503:*/ " " ) ; /*505:*/ if read_open [ m as usize ] == OpenMode :: JustOpen { // Input the first line of `read_file[m]` if read_file [ m as usize ] . as_mut ( ) . unwrap ( ) . input_line ( ) { read_open [ m as usize ] = OpenMode :: Normal ; } else { let _ = read_file [ m as usize ] . take ( ) ; read_open [ m as usize ] = OpenMode :: Closed ; } } else if ! read_file [ m as usize ] . as_mut ( ) . unwrap ( ) . input_line ( ) { // Input the next line of |read_file[m]| let _ = read_file [ m as usize ] . take ( ) ; read_open [ m as usize ] = OpenMode :: Closed ; if align_state as i64 != 1000000 { runaway ( ) ; t_eprint ! ( " " Esc ( " " ) ) ; help ! ( " \\ " ) ; align_state = 1000000 ; error ( ) ; } } input . limit = last ; if get_int_par ( IntPar :: end_line_char ) < 0 || get_int_par ( IntPar :: end_line_char ) > 255 { input . limit -= 1 } else { BUFFER [ input . limit ] = get_int_par ( IntPar :: end_line_char ) } first = input . limit + 1 ; input . loc = input . start ; input . state = InputState :: NewLine ; // Handle `\readline` and goto `'done` let limit = input . limit ; let loc = input . loc . as_mut ( ) . unwrap ( ) ; if j == 1 { while * loc <= limit { // current line not yet finished let chr = BUFFER [ * loc ] ; * loc += 1 ; let tok = if chr == ' ' as i32 { SPACE_TOKEN } else { chr + OTHER_TOKEN } ; store_new_token ( & mut p , tok ) ; } } else { loop { let mut tok = get_token ( input ) . 0 ; if tok == 0 { break ; // `cmd=chr=0` will occur at the end of the line } if ( align_state as i64 ) < 1000000 { // unmatched `}` aborts the line loop { tok = get_token ( input ) . 0 ; if tok == 0 { break ; } } align_state = 1000000 ; break ; } else { store_new_token ( & mut p , tok ) ; } } } end_file_reading ( input ) ; if align_state as i64 == 1000000 { break ; } } scanner_status = ScannerStatus :: Normal ; align_state = s ; def_ref as i32 }
The `read_toks` procedure constructs a token list like that for any
macro definition, and makes `cur_val` point to it.
The ` read_toks ` procedure constructs a token list like that for any macro definition and makes ` cur_val ` point to it .
input
&mut input_state_t
n
i32
r
i32
j
i32