Commit 7bca292
* bibtex: don't panic on an empty @string macro
`scan_a_field_token_and_eat_white` inspects `str[0]` to collapse leading
whitespace at the start of a field value, where `str` is the expansion of a
macro token. That expansion can be the empty string — cryptobib defines over a
thousand venue name/address macros as "" (e.g. `@string{acispname = ""}`) — in
which case `str` is a zero-length slice and `str[0]` is out of bounds:
thread 'main' panicked at crates/engine_bibtex/src/scan.rs:663:
index out of bounds: the len is 0 but the index is 0
This makes tectonic unable to compile any paper that cites cryptobib. The
original WEB/C BibTeX reads `str_pool[tmp_ptr]` from a shared array here and so
reads one byte past harmlessly; the Rust port returns an exact-length slice,
turning the same access into a panic. The copy loop a few lines below already
guards with `!str.is_empty()` — the leading-whitespace check simply didn't.
Guard it the same way. An empty macro then contributes nothing to the field,
matching reference bibtex/bibtex8.
Adds a regression test (tests/bibtex/cites/empty_macro) whose .bbl is
byte-identical to bibtex8's output.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Remove comment
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0c006e6 commit 7bca292
6 files changed
Lines changed: 31 additions & 0 deletions
File tree
- crates/engine_bibtex/src
- tests
- bibtex/cites
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
| 663 | + | |
663 | 664 | | |
664 | 665 | | |
665 | 666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
99 | 104 | | |
100 | 105 | | |
101 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments