diff options
author | Corentin Noël <corentin.noel@collabora.com> | 2021-08-02 16:49:27 +0200 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2021-08-03 08:20:30 +0100 |
commit | b2fafbca02219748fd84e3b96f1419030fd5c466 (patch) | |
tree | 8c3aab7f661958630cf8050d23b2af9197241e98 /libappstream-glib/as-node.c | |
parent | 60e85d47255a5a4423f4411532ff16554470a4dc (diff) | |
download | appstream-glib-b2fafbca02219748fd84e3b96f1419030fd5c466.tar.gz |
Consider AppStream version as a string
Always store the AppStream metadata version as a string and compare it
like any other version.
This allows to have 0.10 > 0.8 for instance.
Diffstat (limited to 'libappstream-glib/as-node.c')
-rw-r--r-- | libappstream-glib/as-node.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c index b4159ea..4d438f5 100644 --- a/libappstream-glib/as-node.c +++ b/libappstream-glib/as-node.c @@ -2166,7 +2166,7 @@ as_node_get_localized_unwrap (const AsNode *node, GError **error) struct _AsNodeContext { AsFormatKind format_kind; AsFormatKind output; - gdouble version; + gchar *version; gboolean output_trusted; AsRefString *media_base_url; }; @@ -2185,7 +2185,7 @@ as_node_context_new (void) { AsNodeContext *ctx; ctx = g_new0 (AsNodeContext, 1); - ctx->version = 0.f; + ctx->version = g_strdup ("0.0"); ctx->format_kind = AS_FORMAT_KIND_APPSTREAM; ctx->output = AS_FORMAT_KIND_UNKNOWN; return ctx; @@ -2206,6 +2206,7 @@ as_node_context_free (AsNodeContext *ctx) return; if (ctx->media_base_url != NULL) as_ref_string_unref (ctx->media_base_url); + g_clear_pointer (&ctx->version, g_free); g_free (ctx); } @@ -2215,11 +2216,11 @@ as_node_context_free (AsNodeContext *ctx) * * Gets the AppStream API version used when parsing or inserting nodes. * - * Returns: version number + * Returns: the API version * - * Since: 0.3.6 + * Since: 0.7.19 **/ -gdouble +const gchar * as_node_context_get_version (AsNodeContext *ctx) { return ctx->version; @@ -2228,16 +2229,19 @@ as_node_context_get_version (AsNodeContext *ctx) /** * as_node_context_set_version: (skip) * @ctx: a #AsNodeContext. - * @version: an API version number to target. + * @version: an API version to target. * * Sets the AppStream API version used when parsing or inserting nodes. * - * Since: 0.3.6 + * Since: 0.7.19 **/ void -as_node_context_set_version (AsNodeContext *ctx, gdouble version) +as_node_context_set_version (AsNodeContext *ctx, const gchar *version) { - ctx->version = version; + if (g_strcmp0 (ctx->version, version) != 0) { + g_free (ctx->version); + ctx->version = g_strdup (version); + } } /** |