[X2Go-Commits] [x2goserver] 26/99: X2Go/Server/Agent/NX/Options.pm: document the new compact_intermediate () function and its implications.
git-admin at x2go.org
git-admin at x2go.org
Mon Dec 28 06:10:40 CET 2020
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2goserver.
commit 050d662b5743463867b8e78ca8b4e7e1c95e0ae1
Author: Mihai Moldovan <ionic at ionic.de>
Date: Sat Nov 7 11:31:40 2020 +0100
X2Go/Server/Agent/NX/Options.pm: document the new compact_intermediate () function and its implications.
---
X2Go/Server/Agent/NX/Options.pm | 24 ++++++++++++++++++++++--
debian/changelog | 2 ++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/X2Go/Server/Agent/NX/Options.pm b/X2Go/Server/Agent/NX/Options.pm
index a73d4e46..ecd7a8a7 100644
--- a/X2Go/Server/Agent/NX/Options.pm
+++ b/X2Go/Server/Agent/NX/Options.pm
@@ -787,7 +787,7 @@ X2Go::Server::Agent::NX::Options - NX Options modification module
# Options string, probably read in from somewhere, but
# hardcoded here.
- my $options = 'some=option,another=opt,more=values:90';
+ my $options = 'some=option,another=opt,more=values,some=override,more=data:90';
# Parse into an intermediate form.
my $intermediate = X2Go::Server::Agent::NX::Options::parse_options ($options);
@@ -795,6 +795,13 @@ X2Go::Server::Agent::NX::Options - NX Options modification module
# Check for errors.
die "Unable to parse option string, aborting.\n" unless (defined ($intermediate));
+ # (Optionally) compact it, this should make the duplicated "some" and "more"
+ # keys unique.
+ $intermediate = X2Go::Server::Agent::NX::Options::compact_intermediate ($intermediate);
+
+ # Error handling ...
+ die "Unable to compact intermediate array, aborting.\n" unless (defined ($intermediate));
+
# Add to options string.
my $transform_op = '+new=value';
@@ -845,7 +852,7 @@ X2Go::Server::Agent::NX::Options - NX Options modification module
# Error handling ...
die "Unable to transform intermediate back into string, aborting.\n" unless (defined ($out));
- # At this point, $out should be 'another=newval,more=values,new=value:90'.
+ # At this point, $out should be 'another=newval,more=data,new=value:90'.
=head1 DESCRIPTION
@@ -862,6 +869,10 @@ I<references>, but you should make no assumptions to the layout or even its
actual format. Treat it as a black box. Crucially, whenever an I<intermediate>
is expected, such a I<reference> should be passed.
+To remove redundant or empty entries within an options string, pass the
+I<intermediate> to C<compact_intermediate>. This is entirely optional and can
+be done at any step, as long as an I<intermediate> is available.
+
To parse transformations, pass each one to C<interpret_transform>. Refer to
L</TRANSFOMATIONS> for documentation on transformation formats. This will
either return C<undef> on error, or an array of two scalars - the
@@ -933,6 +944,12 @@ be preserved, but will trigger warnings at parse time.
An options string such as C<,,,:65> is hence valid.
+To remove such empty elements, use C<compact_intermediate>. An implicit empty
+element is added whenever the resulting options string would only contain the
+display number. This one I<can not> be removed, but also won't show up
+anywhere. Adding any non-empty new key will automatically replace such an
+empty element, without any need for actual compactation.
+
=item *
In a key-value pair, keys and values are separated from each other via an
@@ -982,6 +999,9 @@ It is recommended to avoid duplicate keys in the input options string.
Note that, due to the nature of the supported transformations, keys can not be
duplicated with this module.
+To remove duplicated keys, use C<compact_intermediate>. This will preserve the
+order in a first-seen fashion.
+
=item *
A key-value pair with an empty key but a non-empty value is allowed.
diff --git a/debian/changelog b/debian/changelog
index 8c24ca26..f3914ee0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -230,6 +230,8 @@ x2goserver (4.1.0.4-0x2go1.2) UNRELEASED; urgency=medium
switch.
- x2goserver/lib/x2goupdateoptionsstring: split up GetOptionsFromArray ()
line. Non-functional.
+ - X2Go/Server/Agent/NX/Options.pm: document the new
+ compact_intermediate () function and its implications.
* debian/control:
+ Build-depend upon lsb-release for distro version detection.
* debian/x2goserver.manpages:
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goserver.git
More information about the x2go-commits
mailing list