mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
parent
a0249d2309
commit
e84df1a036
@ -2,7 +2,7 @@ use std::cell::{RefCell, RefMut};
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
@ -559,11 +559,8 @@ impl PathHash {
|
|||||||
/// Read a file.
|
/// Read a file.
|
||||||
fn read(path: &Path) -> FileResult<Vec<u8>> {
|
fn read(path: &Path) -> FileResult<Vec<u8>> {
|
||||||
let f = |e| FileError::from_io(e, path);
|
let f = |e| FileError::from_io(e, path);
|
||||||
let mut file = File::open(path).map_err(f)?;
|
if fs::metadata(&path).map_err(f)?.is_file() {
|
||||||
if file.metadata().map_err(f)?.is_file() {
|
fs::read(&path).map_err(f)
|
||||||
let mut data = vec![];
|
|
||||||
file.read_to_end(&mut data).map_err(f)?;
|
|
||||||
Ok(data)
|
|
||||||
} else {
|
} else {
|
||||||
Err(FileError::IsDirectory)
|
Err(FileError::IsDirectory)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@ description: |
|
|||||||
---
|
---
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
## Unreleased
|
||||||
|
- Reduced maximum function call depth from 256 to 64.
|
||||||
|
|
||||||
## March 28, 2023
|
## March 28, 2023
|
||||||
- **Breaking:** Enumerations now require a space after their marker, that is,
|
- **Breaking:** Enumerations now require a space after their marker, that is,
|
||||||
`[1.ok]` must now be written as `[1. ok]`
|
`[1.ok]` must now be written as `[1. ok]`
|
||||||
|
@ -60,7 +60,7 @@ use crate::util::PathExt;
|
|||||||
use crate::World;
|
use crate::World;
|
||||||
|
|
||||||
const MAX_ITERATIONS: usize = 10_000;
|
const MAX_ITERATIONS: usize = 10_000;
|
||||||
const MAX_CALL_DEPTH: usize = 256;
|
const MAX_CALL_DEPTH: usize = 64;
|
||||||
|
|
||||||
/// Evaluate a source file and return the resulting module.
|
/// Evaluate a source file and return the resulting module.
|
||||||
#[comemo::memoize]
|
#[comemo::memoize]
|
||||||
|
@ -2,8 +2,7 @@ use std::cell::{RefCell, RefMut};
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs::{self, File};
|
use std::fs;
|
||||||
use std::io::Read;
|
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
@ -325,11 +324,8 @@ fn read(path: &Path) -> FileResult<Vec<u8>> {
|
|||||||
.unwrap_or_else(|_| path.into());
|
.unwrap_or_else(|_| path.into());
|
||||||
|
|
||||||
let f = |e| FileError::from_io(e, &suffix);
|
let f = |e| FileError::from_io(e, &suffix);
|
||||||
let mut file = File::open(&path).map_err(f)?;
|
if fs::metadata(&path).map_err(f)?.is_file() {
|
||||||
if file.metadata().map_err(f)?.is_file() {
|
fs::read(&path).map_err(f)
|
||||||
let mut data = vec![];
|
|
||||||
file.read_to_end(&mut data).map_err(f)?;
|
|
||||||
Ok(data)
|
|
||||||
} else {
|
} else {
|
||||||
Err(FileError::IsDirectory)
|
Err(FileError::IsDirectory)
|
||||||
}
|
}
|
||||||
@ -472,7 +468,7 @@ fn test_part(
|
|||||||
let mut errors: Vec<_> = errors
|
let mut errors: Vec<_> = errors
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|error| error.span.source() == id)
|
.filter(|error| error.span.source() == id)
|
||||||
.map(|error| (error.range(world), error.message.to_string()))
|
.map(|error| (error.range(world), error.message.replace('\\', "/")))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
errors.sort_by_key(|error| error.0.start);
|
errors.sort_by_key(|error| error.0.start);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user