summaryrefslogtreecommitdiffstats
path: root/snap/local/print-inkscape-version.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /snap/local/print-inkscape-version.cpp
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'snap/local/print-inkscape-version.cpp')
-rw-r--r--snap/local/print-inkscape-version.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/snap/local/print-inkscape-version.cpp b/snap/local/print-inkscape-version.cpp
new file mode 100644
index 0000000..17d0c17
--- /dev/null
+++ b/snap/local/print-inkscape-version.cpp
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// Use the Inkscape compiled version identifier and print it out with
+// the Snap restrictions on versions. Only a few characters allowed
+// and a limit of 32 characters.
+#include "inkscape-version.h"
+
+#include <iostream>
+#include <cctype>
+
+int main (int argc, char ** argv) {
+ std::string outstr;
+
+ for (const auto& c : std::string{Inkscape::version_string}) {
+ if (outstr.length() == 32) {
+ break;
+ }
+
+ if (std::isalpha(c) || std::isdigit(c)) {
+ outstr.append(1, c);
+ continue;
+ }
+
+ if (c == '(' || c == ')' || c == ',') {
+ continue;
+ }
+
+ if (c == '.' || c == '-') {
+ outstr.append(1, c);
+ continue;
+ }
+
+ outstr.append(1, '-');
+ }
+
+ while (outstr.length() > 0 && !std::isalpha(outstr.back()) && !std::isdigit(outstr.back())) {
+ outstr.pop_back();
+ }
+
+ std::cout << outstr << std::endl;
+
+ return 0;
+}