fn make_format_pass(&mut self, status: &mut dyn StatusBackend) -> Result<i32> {
        if self.io.bundle.is_none() {
            return Err(
                ErrorKind::Msg("cannot create formats without using a bundle".to_owned()).into(),
            );
        }

        if self.io.format_cache.is_none() {
            return Err(ErrorKind::Msg(
                "cannot create formats without having a place to save them".to_owned(),
            )
            .into());
        }

        // PathBuf.file_stem() doesn't do what we want since it only strips
        // one extension. As of 1.17, the compiler needs a type annotation for
        // some reason, which is why we use the `r` variable.
        let r: Result<&str> = self.format_name.splitn(2, '.').next().ok_or_else(|| {
            ErrorKind::Msg(format!(
                "incomprehensible format file name \"{}\"",
                self.format_name
            ))
            .into()
        });
        let stem = r?;

        let result = {
            let mut stack = self
                .io
                .as_stack_for_format(&format!("tectonic-format-{}.tex", stem));
            TexEngine::new()
                .halt_on_error_mode(true)
                .initex_mode(true)
                .process(
                    &mut stack,
                    &mut self.events,
                    status,
                    "UNUSED.fmt",
                    "texput",
                    &self.unstables,
                )
        };

        match result {
            Ok(TexResult::Spotless) => {}
            Ok(TexResult::Warnings) => {
                tt_warning!(status, "warnings were issued by the TeX engine; use --print and/or --keep-logs for details.");
            }
            Ok(TexResult::Errors) => {
                tt_error!(status, "errors were issued by the TeX engine; use --print and/or --keep-logs for details.");
                return Err(ErrorKind::Msg("unhandled TeX engine error".to_owned()).into());
            }
            Err(e) => {
                return Err(e.chain_err(|| ErrorKind::EngineError("TeX")));
            }
        }

        // Now we can write the format file to its special location. In
        // principle we could stream the format file directly to the staging
        // area as we ran the TeX engine, but we don't bother.

        let format_cache = &mut *self.io.format_cache.as_mut().unwrap();

        for (name, contents) in &*self.io.mem.files.borrow() {
            if name == self.io.mem.stdout_key() {
                continue;
            }

            let sname = name.to_string_lossy();

            if !sname.ends_with(".fmt") {
                continue;
            }

            // Note that we intentionally pass 'stem', not 'name'.
            ctry!(format_cache.write_format(stem, contents, status); "cannot write format file {}", sname);
        }

        // All done. Clear the memory layer since this was a special preparatory step.
        self.io.mem.files.borrow_mut().clear();

        Ok(0)
    }
/// Use the TeX engine to generate a format file.
Use the TeX engine to generate a format file.
Use the TeX engine to generate a format file .
fn make_format_pass(&mut self, status: &mut dyn StatusBackend) -> Result<i32> {
        if self.io.bundle.is_none() {
            return Err(
                ErrorKind::Msg("cannot create formats without using a bundle".to_owned()).into(),
            );
        }
        if self.io.format_cache.is_none() {
            return Err(ErrorKind::Msg(
                "cannot create formats without having a place to save them".to_owned(),
            )
            .into());
        }
        // PathBuf.file_stem() doesn't do what we want since it only strips
        // one extension. As of 1.17, the compiler needs a type annotation for
        // some reason, which is why we use the `r` variable.
        let r: Result<&str> = self.format_name.splitn(2, '.').next().ok_or_else(|| {
            ErrorKind::Msg(format!(
                "incomprehensible format file name \"{}\"",
                self.format_name
            ))
            .into()
        });
        let stem = r?;
        let result = {
            let mut stack = self
                .io
                .as_stack_for_format(&format!("tectonic-format-{}.tex", stem));
            TexEngine::new()
                .halt_on_error_mode(true)
                .initex_mode(true)
                .process(
                    &mut stack,
                    &mut self.events,
                    status,
                    "UNUSED.fmt",
                    "texput",
                    &self.unstables,
                )
        };
        match result {
            Ok(TexResult::Spotless) => {}
            Ok(TexResult::Warnings) => {
                tt_warning!(status, "warnings were issued by the TeX engine; use --print and/or --keep-logs for details.");
            }
            Ok(TexResult::Errors) => {
                tt_error!(status, "errors were issued by the TeX engine; use --print and/or --keep-logs for details.");
                return Err(ErrorKind::Msg("unhandled TeX engine error".to_owned()).into());
            }
            Err(e) => {
                return Err(e.chain_err(|| ErrorKind::EngineError("TeX")));
            }
        }
        // Now we can write the format file to its special location. In
        // principle we could stream the format file directly to the staging
        // area as we ran the TeX engine, but we don't bother.
        let format_cache = &mut *self.io.format_cache.as_mut().unwrap();
        for (name, contents) in &*self.io.mem.files.borrow() {
            if name == self.io.mem.stdout_key() {
                continue;
            }
            let sname = name.to_string_lossy();
            if !sname.ends_with(".fmt") {
                continue;
            }
            // Note that we intentionally pass 'stem', not 'name'.
            ctry!(format_cache.write_format(stem, contents, status); "cannot write format file {}", sname);
        }
        // All done. Clear the memory layer since this was a special preparatory step.
        self.io.mem.files.borrow_mut().clear();
        Ok(0)
    }
fn make_format_pass ( & mut self , status : & mut dyn StatusBackend ) -> Result < i32 > { if self . io . bundle . is_none ( ) { return Err ( ErrorKind :: Msg ( " " . to_owned ( ) ) . into ( ) , ) ; } if self . io . format_cache . is_none ( ) { return Err ( ErrorKind :: Msg ( " " . to_owned ( ) , ) . into ( ) ) ; } // PathBuf.file_stem() doesn't do what we want since it only strips // one extension. As of 1.17, the compiler needs a type annotation for // some reason, which is why we use the `r` variable. let r : Result < & str > = self . format_name . splitn ( 2 , '.' ) . next ( ) . ok_or_else ( | | { ErrorKind :: Msg ( format ! ( " \" \" " self format_name ) ) . into ( ) } ) ; let stem = r ? ; let result = { let mut stack = self . io . as_stack_for_format ( & format ! ( " " stem ) ) ; TexEngine :: new ( ) . halt_on_error_mode ( true ) . initex_mode ( true ) . process ( & mut stack , & mut self . events , status , " " , " " , & self . unstables , ) } ; match result { Ok ( TexResult :: Spotless ) => { } Ok ( TexResult :: Warnings ) => { tt_warning ! ( status " " ) ; } Ok ( TexResult :: Errors ) => { tt_error ! ( status " " ) ; return Err ( ErrorKind :: Msg ( " " . to_owned ( ) ) . into ( ) ) ; } Err ( e ) => { return Err ( e . chain_err ( | | ErrorKind :: EngineError ( " " ) ) ) ; } } // Now we can write the format file to its special location. In // principle we could stream the format file directly to the staging // area as we ran the TeX engine, but we don't bother. let format_cache = & mut * self . io . format_cache . as_mut ( ) . unwrap ( ) ; for ( name , contents ) in & * self . io . mem . files . borrow ( ) { if name == self . io . mem . stdout_key ( ) { continue ; } let sname = name . to_string_lossy ( ) ; if ! sname . ends_with ( " " ) { continue ; } // Note that we intentionally pass 'stem', not 'name'. ctry ! ( format_cache write_format ( stem contents status ) " " sname ) ; } // All done. Clear the memory layer since this was a special preparatory step. self . io . mem . files . borrow_mut ( ) . clear ( ) ; Ok ( 0 ) }
Use the TeX engine to generate a format file.
Use the TeX engine to generate a format file .
&mut self
status
&mut dyn StatusBackend