Commit 911b122
authored
Fix encoding error when C parser reads external source files (#1657)
When a C file references another source file via `/* in file.c */`, the
parser read it with bare `File.read` which uses
`Encoding.default_external`. On systems where this is US-ASCII (e.g.
Debian CI), non-ASCII bytes in the source file cause `ArgumentError:
invalid byte sequence in US-ASCII` in String#scan.
Use `RDoc::Encoding.read_file` instead, which reads in binary mode and
properly handles encoding detection and transcoding.
This was triggered by Ruby commit
[`a2531ba293`](ruby/ruby@a2531ba293) which
added UTF-8 right arrows (→) in comments in `class.c`, which is
referenced from `object.c` via `/* in class.c */`.1 parent 0e9daee commit 911b122
2 files changed
+37
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1016 | 1016 | | |
1017 | 1017 | | |
1018 | 1018 | | |
1019 | | - | |
| 1019 | + | |
1020 | 1020 | | |
1021 | 1021 | | |
1022 | 1022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2292 | 2292 | | |
2293 | 2293 | | |
2294 | 2294 | | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
2295 | 2331 | | |
2296 | 2332 | | |
2297 | 2333 | | |
| |||
0 commit comments