pub(crate) unsafe fn scan_keyword(input: &mut input_state_t, s: &str) -> bool {
    let s = s.as_bytes();
    let mut p = BACKUP_HEAD; // tail of the backup list
    *LLIST_link(p) = None.tex_int();
    if s.len() == 1 {
        let c: i8 = s[0] as i8;
        loop {
            let (tok, cmd, chr, cs) = get_x_token(input); // recursion is possible here
            if cs == 0 && (chr == c as i32 || chr == c as i32 - ('a' as i32) + ('A' as i32)) {
                store_new_token(&mut p, tok);
                flush_list(llist_link(BACKUP_HEAD));
                return true;
            } else if cmd != Cmd::Spacer || p != BACKUP_HEAD {
                back_input(input, tok);
                if p != BACKUP_HEAD {
                    begin_token_list(input, llist_link(BACKUP_HEAD), Btl::BackedUp);
                }
                return false;
            }
        }
    }
    let slen = s.len();
    let mut i = 0;
    while i < slen {
        let (tok, cmd, chr, cs) = get_x_token(input); // recursion is possible here
        if cs == 0
            && (chr == s[i] as i8 as i32 || chr == s[i] as i8 as i32 - ('a' as i32) + ('A' as i32))
        {
            store_new_token(&mut p, tok);
            i += 1;
        } else if cmd != Cmd::Spacer || p != BACKUP_HEAD {
            back_input(input, tok);
            if p != BACKUP_HEAD {
                begin_token_list(input, llist_link(BACKUP_HEAD), Btl::BackedUp);
            }
            return false;
        }
    }
    flush_list(llist_link(BACKUP_HEAD));
    true
}
/// look for a given string
///
/// In case you are getting bored, here is a slightly less trivial routine:
/// Given a string of lowercase letters, like `pt` or `plus` or
/// `width`, the `scan_keyword` routine checks to see whether the next
/// tokens of input match this string. The match must be exact, except that
/// uppercase letters will match their lowercase counterparts; uppercase
/// equivalents are determined by subtracting `"a"-"A"`, rather than using the
/// `uc_code` table, since \TeX uses this routine only for its own limited
/// set of keywords.
///
/// If a match is found, the characters are effectively removed from the input
/// and `true` is returned. Otherwise `false` is returned, and the input
/// is left essentially unchanged (except for the fact that some macros
/// may have been expanded, etc.).


If a match is found, the characters are effectively removed from the input
and `true` is returned. Otherwise `false` is returned, and the input
is left essentially unchanged (except for the fact that some macros
may have been expanded, etc.).
If a match is found the characters are effectively removed from the input and ` true ` is returned . Otherwise ` false ` is returned and the input is left essentially unchanged ( except for the fact that some macros may have been expanded etc . ) .
pub(crate) unsafe fn scan_keyword(input: &mut input_state_t, s: &str) -> bool {
    let s = s.as_bytes();
    let mut p = BACKUP_HEAD; // tail of the backup list
    *LLIST_link(p) = None.tex_int();
    if s.len() == 1 {
        let c: i8 = s[0] as i8;
        loop {
            let (tok, cmd, chr, cs) = get_x_token(input); // recursion is possible here
            if cs == 0 && (chr == c as i32 || chr == c as i32 - ('a' as i32) + ('A' as i32)) {
                store_new_token(&mut p, tok);
                flush_list(llist_link(BACKUP_HEAD));
                return true;
            } else if cmd != Cmd::Spacer || p != BACKUP_HEAD {
                back_input(input, tok);
                if p != BACKUP_HEAD {
                    begin_token_list(input, llist_link(BACKUP_HEAD), Btl::BackedUp);
                }
                return false;
            }
        }
    }
    let slen = s.len();
    let mut i = 0;
    while i < slen {
        let (tok, cmd, chr, cs) = get_x_token(input); // recursion is possible here
        if cs == 0
            && (chr == s[i] as i8 as i32 || chr == s[i] as i8 as i32 - ('a' as i32) + ('A' as i32))
        {
            store_new_token(&mut p, tok);
            i += 1;
        } else if cmd != Cmd::Spacer || p != BACKUP_HEAD {
            back_input(input, tok);
            if p != BACKUP_HEAD {
                begin_token_list(input, llist_link(BACKUP_HEAD), Btl::BackedUp);
            }
            return false;
        }
    }
    flush_list(llist_link(BACKUP_HEAD));
    true
}
pub ( crate ) unsafe fn scan_keyword ( input : & mut input_state_t , s : & str ) -> bool { let s = s . as_bytes ( ) ; let mut p = BACKUP_HEAD ; // tail of the backup list * LLIST_link ( p ) = None . tex_int ( ) ; if s . len ( ) == 1 { let c : i8 = s [ 0 ] as i8 ; loop { let ( tok , cmd , chr , cs ) = get_x_token ( input ) ; // recursion is possible here if cs == 0 && ( chr == c as i32 || chr == c as i32 - ( 'a' as i32 ) + ( 'A' as i32 ) ) { store_new_token ( & mut p , tok ) ; flush_list ( llist_link ( BACKUP_HEAD ) ) ; return true ; } else if cmd != Cmd :: Spacer || p != BACKUP_HEAD { back_input ( input , tok ) ; if p != BACKUP_HEAD { begin_token_list ( input , llist_link ( BACKUP_HEAD ) , Btl :: BackedUp ) ; } return false ; } } } let slen = s . len ( ) ; let mut i = 0 ; while i < slen { let ( tok , cmd , chr , cs ) = get_x_token ( input ) ; // recursion is possible here if cs == 0 && ( chr == s [ i ] as i8 as i32 || chr == s [ i ] as i8 as i32 - ( 'a' as i32 ) + ( 'A' as i32 ) ) { store_new_token ( & mut p , tok ) ; i += 1 ; } else if cmd != Cmd :: Spacer || p != BACKUP_HEAD { back_input ( input , tok ) ; if p != BACKUP_HEAD { begin_token_list ( input , llist_link ( BACKUP_HEAD ) , Btl :: BackedUp ) ; } return false ; } } flush_list ( llist_link ( BACKUP_HEAD ) ) ; true }
look for a given string
In case you are getting bored, here is a slightly less trivial routine:
Given a string of lowercase letters, like `pt` or `plus` or
`width`, the `scan_keyword` routine checks to see whether the next
tokens of input match this string.
look for a given string In case you are getting bored here is a slightly less trivial routine : Given a string of lowercase letters like ` pt ` or ` plus ` or ` width ` the ` scan_keyword ` routine checks to see whether the next tokens of input match this string .
input
&mut input_state_t
s
&str