From c853ffb5b2f75f5a889ed2e3ef89b818a736e87a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:50:49 +0200 Subject: Adding upstream version 1.3+ds. Signed-off-by: Daniel Baumann --- snap/local/print-inkscape-version.cpp | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 snap/local/print-inkscape-version.cpp (limited to 'snap/local/print-inkscape-version.cpp') 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 +#include + +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; +} -- cgit v1.2.3