[X2Go-Commits] [x2goserver] 23/99: x2goserver/lib/x2goupdateoptionsstring: add new --compact/-c switch to enable the use of compactation.

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 37ddcda0c83d4bf5ddc29f2d3f2cc6950feeba1f
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sat Nov 7 11:11:29 2020 +0100

    x2goserver/lib/x2goupdateoptionsstring: add new --compact/-c switch to enable the use of compactation.
---
 debian/changelog                       |  2 ++
 x2goserver/bin/x2goupdateoptionsstring | 35 ++++++++++++++++++++++++----------
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2d73e953..d03235a3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -224,6 +224,8 @@ x2goserver (4.1.0.4-0x2go1.2) UNRELEASED; urgency=medium
       and make it bold to denote something special.
     - X2Go/Server/Agent/NX/Options.pm: add new function compact_intermediate,
       used to remove duplicated and empty elements.
+    - x2goserver/lib/x2goupdateoptionsstring: add new --compact/-c switch to
+      enable the use of compactation.
   * debian/control:
     + Build-depend upon lsb-release for distro version detection.
   * debian/x2goserver.manpages:
diff --git a/x2goserver/bin/x2goupdateoptionsstring b/x2goserver/bin/x2goupdateoptionsstring
index 9a344dcb..d7b3f04a 100755
--- a/x2goserver/bin/x2goupdateoptionsstring
+++ b/x2goserver/bin/x2goupdateoptionsstring
@@ -145,7 +145,8 @@ sub Main {
   my $help = 0;
   my $man = 0;
   my $debug = 0;
-  GetOptionsFromArray (\@program_arguments, 'help|?|h' => \$help, 'man' => \$man, 'debug|d' => \$debug) or pod2usage (2);
+  my $compact = 0;
+  GetOptionsFromArray (\@program_arguments, 'help|?|h' => \$help, 'man' => \$man, 'debug|d' => \$debug, 'compact|c' => \$compact) or pod2usage (2);
 
   if ($help) {
     pod2usage (1);
@@ -201,6 +202,24 @@ sub Main {
     }
   }
 
+  if (!($error_detected)) {
+    if ($debug) {
+      print {*STDERR} 'Dumping intermediate array after initial parsing: ' . Dumper ($intermediate);
+    }
+
+    if ($compact) {
+      $intermediate = X2Go::Server::Agent::NX::Options::compact_intermediate ($intermediate);
+
+      if (!(defined ($intermediate))) {
+        print {*STDERR} "Unable to compact intermediate options representation, aborting.\n";
+        $error_detected = 8;
+      }
+      elsif ($debug) {
+        print {*STDERR} 'Dumping intermediate array after compacting: ' . Dumper ($intermediate);
+      }
+    }
+  }
+
   if (!($error_detected)) {
     $found_separator |= (0 + shift (@{$sanitized_options}));
     $sanitized_options = shift (@{$sanitized_options});
@@ -208,10 +227,6 @@ sub Main {
 
     my $cur_transform = shift (@program_arguments);
 
-    if ($debug) {
-      print {*STDERR} 'Dumping intermediate array after initial parsing: ' . Dumper ($intermediate);
-    }
-
     # Nasty trick (to some degree): "do"-blocks are not recognized as loops by
     # Perl, but we could wrap the body in another block, which WILL BE recognized
     # as a loop (one, that only executes once), oddly enough. However, using
@@ -222,7 +237,7 @@ sub Main {
       # Shall only be relevant for the first run of the loop.
       if (!(defined ($cur_transform))) {
         print {*STDERR} "No transformation passed, aborting.\n";
-        $error_detected = 8;
+        $error_detected = 9;
         last;
       }
 
@@ -234,7 +249,7 @@ sub Main {
 
       if (!(defined ($interpreted_transform_ref))) {
         print {*STDERR} "Invalid transformation passed, aborting.\n";
-        $error_detected = 9;
+        $error_detected = 10;
         last;
       }
 
@@ -248,7 +263,7 @@ sub Main {
 
       if (!(defined ($intermediate))) {
         print {*STDERR} "Error while transforming intermediate representation, aborting.\n";
-        $error_detected = 10;
+        $error_detected = 11;
         last;
       }
 
@@ -261,7 +276,7 @@ sub Main {
 
       if (!(defined ($sanitized_options))) {
         pod2usage (-exitval => 'NOEXIT');
-        $error_detected = 11;
+        $error_detected = 12;
         last;
       }
 
@@ -278,7 +293,7 @@ sub Main {
 
     if (!(defined ($out))) {
       print {*STDERR} "Unable to transform intermediate back into string, aborting.\n";
-      $error_detected = 12;
+      $error_detected = 13;
     }
   }
 

--
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