Skip to content

fix: make config file parsing stricter and support config includes - #934

Closed
matchaxnb wants to merge 3 commits into
moonlight-stream:masterfrom
matchaxnb:fix/config
Closed

fix: make config file parsing stricter and support config includes#934
matchaxnb wants to merge 3 commits into
moonlight-stream:masterfrom
matchaxnb:fix/config

Conversation

@matchaxnb

@matchaxnb matchaxnb commented Jul 20, 2026

Copy link
Copy Markdown

Description
fix: make config file parsing stricter and support config includes

Purpose

The config option provably does not work, at least for the width, height, and fps parameters.
This adds a few things:

  • keys that fail to match in config_file_parse will cause an error in the function instead of being silently ignored. Unhandled keys should not be tolerated
  • a special handling for config = /some/path is included (i think it's necessary)
  • comments at the end of lines are supported (before that they were parsed as part of the data); caveat: pound signs can't be part of values anymore but there was no use for them anyway
  • atoi is removed and replaced with a safer version. man atoi explains how bad it is to use atoi.
  • some refactor to be able to catch all errors in config files at once instead of painstakingly finding them one by one (uses a global variable, sorry for that)
  • closed a stray file descriptor in config_file_parse (afaiu)

Matcha added 2 commits July 20, 2026 03:42
- now support comments at the end of lines
- trims values of their trailing whitespaces
- refactor error handling in args and config so that all errors are
  caught at once (alas, uses a global var in the config module, but
  it's fair ig)
- safer integer parsing (atoi is known to not care at all for errors)
@matchaxnb

Copy link
Copy Markdown
Author

I'm aware my dialect of C is fragile, it's been a while since I've written significant C code, but I tried to be as idiomatic as possible.

@matchaxnb

Copy link
Copy Markdown
Author

Additionally, I caught a stray fd remaining open on the config files at the end of parsing and made sure to close it.

@matchaxnb

Copy link
Copy Markdown
Author

Finally: I added some tests fixtures, feel free to make that better, as of now it's a smoke test, very manual.

- make config file parsing use a flag that passes around
- bool -> void for the parse due to use of that flag
- safer rtrim
- updated moonlight.conf with a bit of docs to be explicit about parsing
  format
@matchaxnb

Copy link
Copy Markdown
Author

gonna close and open a cleaner one.

@matchaxnb matchaxnb closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant