Skip to content

toml: can't process windows CRLF format toml file #24321

Description

@kbkpbot

Describe the bug

If a .toml file create under Windows and in CRLF format, the toml.parse_file() will panic.

Reproduction Steps

Under windows, create a toml file, in CRLF format(default).

t.toml:

str1 = """x|
>Roses are red<"""

a file reader:
t.v

module main
import toml

fn main() {
	doc := toml.parse_file('t.toml')!
	dump(doc)
}

Expected Behavior

$ ./t
[t.v:6] doc: toml.Doc{
    ast: &ast.Root{
  input:  input.Config{
    text: ''
    file_path: ''
}
  table:  { "str1": "x|
>Roses are red<" }
}
}

Current Behavior

$ ./t
\n>Roses ar...")pt): "...1 = """x|er.Parser.value value expected .boolean, .quoted, .lsbr, .lcbr or .number got "cr" "
v hash: 188d68d
/tmp/v_1000/t.01JSR09W8PMK1B3BR3QY3R357M.tmp.c:6828: at _v_panic: Backtrace
/tmp/v_1000/t.01JSR09W8PMK1B3BR3QY3R357M.tmp.c:6791: by panic_result_not_set
/tmp/v_1000/t.01JSR09W8PMK1B3BR3QY3R357M.tmp.c:14937: by main__main
/tmp/v_1000/t.01JSR09W8PMK1B3BR3QY3R357M.tmp.c:15001: by main

Possible Solution

enhance the toml.parse_file(), let it can handle CRLF not only LF.

Additional Information/Context

No response

V version

V 0.4.10 188d68d.188d68d

Environment details (OS name and version, etc.)

V full version V 0.4.10 188d68d.188d68d
OS linux, Ubuntu 24.04.2 LTS
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
Memory 10.89GB/15.51GB
V executable /media/HD/github/kbkpbot/v/v
V last modified time 2025-04-23 14:52:13
V home dir OK, value: /media/HD/github/kbkpbot/v
VMODULES OK, value: /home/mars/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/mars/v/bug
Git version git version 2.43.0
V git status weekly.2025.16-42-g09d83a16-dirty (3 commit(s) behind V master)
.git/config present true
cc version cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
gcc version gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
clang version Ubuntu clang version 18.1.3 (1ubuntu1)
tcc version tcc version 0.9.28rc 2025-04-19 mob@36ff4f52 (x86_64 Linux)
tcc git status N/A
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.39-0ubuntu8.4) 2.39

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions