On March 5, 2024 4:07 pm, Max Carrara wrote: > Ceph's docs state the following [0]: >> The backslash character `\` is used as the line-continuation marker >> that combines the next line with the current one. > > This commit implements the support of such line-continuations in our > parser. > > The line following a line ending with a '\' has its whitespace > preserved, which matches the behaviour in Ceph's original > implementation [1]. In other words, leading and trailing whitespace is > not stripped from a continued line.
it's actually a bit more complicated.. ceph only supports line continuations inside values (well, in key value lines after the key ;)), and only if they are unquoted.. > > [0]: > https://docs.ceph.com/en/reef/rados/configuration/ceph-conf/#changes-introduced-in-octopus > [1]: > https://git.proxmox.com/?p=ceph.git;a=blob;f=ceph/src/common/ConfUtils.cc;h=2f78fd02bf9e27467275752e6f3bca0c5e3946ce;hb=refs/heads/master#l262 > > Signed-off-by: Max Carrara <m.carr...@proxmox.com> > --- > Changes v2 --> v3: > * new > Changes v3 --> v4: > * none > > src/PVE/CephConfig.pm | 28 ++++++++++++++++++++++++---- > 1 file changed, 24 insertions(+), 4 deletions(-) > > diff --git a/src/PVE/CephConfig.pm b/src/PVE/CephConfig.pm > index 74a92eb..80f71b0 100644 > --- a/src/PVE/CephConfig.pm > +++ b/src/PVE/CephConfig.pm > @@ -19,13 +19,33 @@ sub parse_ceph_config { > return $cfg if !defined($raw); > > my @lines = split /\n/, $raw; > + my @lines_normalized; > + > + my $re_comment_not_escaped = qr/(?<!\\)(#|;).*$/; > + my $re_leading_ws = qr/^\s+/; > + my $re_trailing_ws = qr/\s+$/; > + > + while (scalar(@lines)) { > + my $line = shift(@lines); > + $line =~ s/$re_comment_not_escaped//; > + $line =~ s/$re_leading_ws//; > + $line =~ s/$re_trailing_ws//; > + next if !$line; > + > + # merge lines ending with continuation character '\' > + while ($line =~ s/\\$//) { > + my $next_line = shift(@lines); > + $next_line =~ s/$re_comment_not_escaped//; > + $next_line =~ s/$re_trailing_ws//; > + $line .= $next_line; > + } > + > + push(@lines_normalized, $line); > + } > > my $section; > > - for my $line (@lines) { > - $line =~ s/(?<!\\)(#|;).*$//; > - $line =~ s/^\s+//; > - $line =~ s/\s+$//; > + for my $line (@lines_normalized) { > next if !$line; > > if ($line =~ m/^\[(.+)\]$/) { > -- > 2.39.2 > > > > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel > > > _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel