[Libosinfo] [PATCH v2 4/4] osinfo_loader: do not use xpath to read localized strings

Giuseppe Scrivano gscrivan at redhat.com
Thu Jun 5 10:43:35 UTC 2014


Giuseppe Scrivano <gscrivan at redhat.com> writes:

> Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
> ---
>  osinfo/osinfo_loader.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
> index 6e79e78..6fe7145 100644
> --- a/osinfo/osinfo_loader.c
> +++ b/osinfo/osinfo_loader.c
> @@ -328,17 +328,21 @@ static void osinfo_loader_entity(OsinfoLoader *loader,
>           * want to ignore that, hence the NULL check on index 'j + 1'.
>           */
>          if (keys[i].type == G_TYPE_STRING) {
> -            for (j = 0; langs[j + 1] != NULL; j++) {
> -                xpath = g_strdup_printf("string(./%s[lang('%s')])",
> -                                        keys[i].name, langs[j]);
> -                value_str = osinfo_loader_string(xpath, loader, ctxt, err);
> -                g_free(xpath);
> -                xpath = NULL;
> -                if (error_is_set(err))
> -                    return;
> -
> -                if (value_str != NULL)
> -                    break;
> +            xmlNodePtr it;
> +            for (it = root->children; it; it = it->next) {
> +                if (xmlStrEqual(it->name, BAD_CAST keys[i].name)) {
> +                    xmlChar *lang = xmlGetProp(it, BAD_CAST "lang");
> +                    if (lang == NULL)
> +                        continue;
> +
> +                    for (j = 0; langs[j + 1] != NULL; j++) {
> +                        if (xmlStrEqual(lang, BAD_CAST langs[j])) {
> +                            gchar *content = (gchar *) it->children->content;
> +                            value_str = g_strdup(content);
> +                            break;
> +                        }
> +                    }
> +                }
>              }
>          }


This is the last patch tht misses an ACK, is it OK?  In case, can I push
these changes amending the small changes reported for other patches or
should I go for v3?

Thanks,
Giuseppe




More information about the Libosinfo mailing list