On 3/29/26 3:27 AM, Luca Toniolo wrote:
Two questions about the new parser:
1. Invalid variable names, what's the failure mode?
If the parser encounters a variable name with spaces (or otherwise not
matching [a-zA-Z_][a-zA-Z0-9_]*), will it refuse to start? A silently
dropped axis limit would be dangerous, so I'd expect a hard error,
what's your take?
You now instantiate like:
IniFile myini(filename);
The parser class overloads the cast-to-bool operator. And you check
validity right after instantiation with:
if(!myini) {
// error condition, parse failed
// message already printed by parser
return ...error...
}
All sources have been updated to check like this and return an error on
failure.
Note: the new class uses an internal static system of caching based on
filename. Instantiating the IniFile class on the same file multiple
times, regardless where and when, only reads and parses the file once
upon creating the first instance.
Since the same ini-file is used for all processing, if it fails, then
most processes refuse to start and drop out very early in the startup
process. This prevents linuxcnc to start at all.
BTW, the actual startup script (scripts/linuxcnc) also uses the new
ini-file parser and will bail on errors from the new inivalue program
(to get ini values from command-line). The old inivar program is now a
compatibility script that invokes inivalue.
Therefore, you wouldn't even get as far as starting the actual binaries
because of error(s).
When the syntax if fine, then you can still have problems with missing
or wrong values, but those are not a concern of the ini-parser. Those
you need to program correctly (like defaults). The parser interface does
implement to get values with defaults if not found and is extensively
used. There also is an optional bounds-check implementation in the
interface when getting values.
2. Will we get Inline comments?
Since 2.7.x the parser doesn't support inline comments, VAR = value #
comment treats everything after = as the value. This is a common source
of confusion. Will the new parser support inline comments (e.g. # or ;
after the value)? If so, an escape character (e.g. \# or \;) would be
needed for values that legitimately contain those characters.
Having inline comments is effectively no longer possible with the 2.7
update because everything after the '=' is treated as the value and
there are not defined any string delimiters for values.
It would only be possible if you change the string syntax into:
val="string"
But, that will interfere with the continuation syntax:
val=bla bla \
more bla \
and more bla
You can't easily have both or you need to do string concatenation. But
when you do string concatenation, then why would you need continuation
as you'd simply use "foo" "bar" on two lines to make "foobar".
Using escapes for '#' and ';' is (very) ugly. If you change the syntax,
then it should be changed more radically to conform to other ini file
forms and use proper string delimiters. However, changing syntax this
way would require to major change to the existing _values_ in ini-files
in a conversion process. I don't know if I'd recommend that, but is can
be discussed.
--
Greetings Bertho
(disclaimers are disclaimed)
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers