Skip to content

Commit cd534c9

Browse files
authored
Merge pull request #3947 from BsAtHome/fix_ini-config-quotes
ini: do not treat quotes as a special character in values
2 parents d2813e2 + ceb5349 commit cd534c9

10 files changed

Lines changed: 286 additions & 377 deletions

File tree

docs/src/config/ini-config.adoc

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ DISPLAY = axis
4545
In this list, the DISPLAY variable will be set to axis because the other one is commented out.
4646
If someone carelessly edits a list like this and leaves two of the lines uncommented, the first one encountered will be used.
4747

48-
Note that inside a variable's value, the "#" and ";" characters are still comments.
49-
You should use double or single quoted strings if you need to embed # or ; characters:
48+
Note that inside a variable's value, the "#" and ";" characters are part of the value:
5049

5150
[source,{ini}]
5251
----
53-
# Below results in INCORRECT=value
54-
# because comments are stripped
55-
INCORRECT = value # and a comment
52+
# Below does not result in INCORRECT=value
53+
# because comments are not interpreted as comments in values
54+
INCORRECT = value # and this is not a comment
5655
57-
# Correct embedding
58-
CORRECT = "value # and an embedded # char"
56+
# Correct comment
57+
# hash char # is a comment om this line
58+
CORRECT = value
5959
----
6060

6161
[[sub:ini:sections]]
@@ -119,11 +119,9 @@ ini.2.max_velocity
119119
A specific variable in a specific sections is often denoted in the documentation as [SECTION]VARIABLE.
120120
This specification mirrors the same way they are specified in HAL files for expansion.
121121

122-
Variable values may be quoted to ensure proper space and special character embedding in literal or escaped forms.
123-
Both single and double quoted values are allowed.
124-
Mutiple quoted value segments are merged into one value.
125-
Embedding quotes in quoted values must use the backslash \\ character to escape the embedded quote if it is the same kind as the enclosing quotes.
126-
Double quotes values also support all common escape formats and full Unicode:
122+
Variable values may embed special characters in literal or escaped forms.
123+
Single or double quotes are not treated as special and are a literal part of the value.
124+
Values also support all common escape formats and full Unicode:
127125

128126
* control: \\[abfnrtv]
129127
* octal: \\[0-2][0-7]{0,2}
@@ -134,27 +132,26 @@ Double quotes values also support all common escape formats and full Unicode:
134132
The resulting value is always converted into UTF-8 and checked for validity.
135133
It is not allowed to embed NUL characters either literally or by using an escape.
136134

137-
.Value Quote and Escape Example
135+
Leading and trailing white space is normally removed from a value.
136+
You can add leading and trailing space in a value by using an escaped value for space (\\x20) as first or last character.
137+
Spaces inside a value are automatically part of the value.
138+
Tabs and newlines can be added using \\t and \\n.
139+
140+
.Value Escape Example
138141
[source,{ini}]
139142
----
140-
STRING = "Hello World!"
141-
STRING = 'Hello World Too!'
143+
STRING = Hello World!
142144
143145
# The following would become: Hello World!
144-
STRING = "Hello" \
145-
" " \
146-
'World' \
147-
"!"
148-
149-
EMBED = "Literal single ' in double"
150-
EMBED = 'Literal double " in single'
151-
EMBED = "Literal double \" in double"
152-
EMBED = 'Literal single \' in single'
153-
154-
SMILE = "\\370\\237\\230\\200 = 😀"
155-
SMILE = "\\xf0\\x9f\\x98\\x80 = 😀"
156-
SMILE = "\\ud83d\\ude00 = 😀"
157-
SMILE = "\\U0001f600 = 😀"
146+
STRING = Hello\
147+
\
148+
World\
149+
!
150+
151+
SMILE = \\370\\237\\230\\200 = 😀
152+
SMILE = \\xf0\\x9f\\x98\\x80 = 😀
153+
SMILE = \\ud83d\\ude00 = 😀
154+
SMILE = \\U0001f600 = 😀
158155
----
159156

160157
Variables' value can have types associated when they are read by LinuxCNC.

0 commit comments

Comments
 (0)