formats.libconfig: add support for dashes (#359308)

This commit is contained in:
h7x4 2024-11-28 21:11:50 +01:00 committed by GitHub
commit 12cadcb077
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 2 deletions

View File

@ -24,7 +24,7 @@ fn validate_setting_name(key: &str) -> bool {
(first_char.is_alphabetic() || first_char == '*')
&& key[1..]
.chars()
.all(|c| c.is_alphanumeric() || c == '_' || c == '*')
.all(|c| c.is_alphanumeric() || c == '_' || c == '*' || c == '-')
}
const SPECIAL_TYPES: [&str; 5] = ["octal", "hex", "float", "list", "array"];

View File

@ -14,6 +14,9 @@ let
simple_top_level_attr = "1.0";
nested.attrset.has.a.integer.value = 100;
some_floaty = 29.95;
## dashes in key names
top-level-dash = "pass";
nested.level-dash = "pass";
## Same syntax here on these two, but they should get serialized differently:
# > A list may have zero or more elements, each of which can be a scalar value, an array, a group, or another list.
list1d = libconfig.lib.mkList [ 1 "mixed!" 5 2 ];

View File

@ -1,6 +1,6 @@
array1d=[1, 5, 2];array2d=([1, 2], [2, 1]);list1d=(1, "mixed!", 5, 2);list2d=(1, (1, 1.2, "foo"), ("bar", 1.2, 1));nasty_string="\"@
\\ ^*bf
0\";'''$";nested={attrset={has={a={integer={value=100;};};};};};simple_top_level_attr="1.0";some_floaty=29.95;weirderTypes={
0\";'''$";nested={attrset={has={a={integer={value=100;};};};};level-dash="pass";};simple_top_level_attr="1.0";some_floaty=29.95;top-level-dash="pass";weirderTypes={
@include "@include_file@"
array_of_ints=[0732, 0xa3, 1234];bigint=9223372036854775807;float=0.0012;hex=0x1fc3;list_of_weird_types=(3.141592654, 9223372036854775807, 0x1fc3, 027, 1.2e-32, 1.0);octal=027;pi=3.141592654;};