[gimp/metadata-browser] metadata: Test with harder to parse values.
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] metadata: Test with harder to parse values.
- Date: Wed, 6 Mar 2013 09:57:22 +0000 (UTC)
commit 9760b41486ad01770229291c7ec9d8dee72de065
Author: Roman Joost <roman bromeco de>
Date: Tue Mar 5 11:02:19 2013 +1000
metadata: Test with harder to parse values.
My first implementation of converting string values to "raw" values
would fail if the user would use characters I'm splitting on. This
implementation should be more implementation independant.
plug-ins/metadata/tests/files/test.xmp | 4 ++--
plug-ins/metadata/tests/test-xmp-model.c | 2 +-
plug-ins/metadata/xmp-model.c | 13 ++++++-------
3 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/plug-ins/metadata/tests/files/test.xmp b/plug-ins/metadata/tests/files/test.xmp
index ed38e96..ef3814d 100644
--- a/plug-ins/metadata/tests/files/test.xmp
+++ b/plug-ins/metadata/tests/files/test.xmp
@@ -15,8 +15,8 @@
</dc:creator>
<dc:description>
<rdf:Alt>
- <rdf:li xml:lang='x-default'>bla</rdf:li>
- <rdf:li xml:lang='de_DE'>Deutsche Beschreibung</rdf:li>
+ <rdf:li xml:lang='x-default'>Hello, World</rdf:li>
+ <rdf:li xml:lang='de_DE'>Hallo, "Welt!"</rdf:li>
</rdf:Alt>
</dc:description>
<dc:subject>
diff --git a/plug-ins/metadata/tests/test-xmp-model.c b/plug-ins/metadata/tests/test-xmp-model.c
index 842a495..982d135 100644
--- a/plug-ins/metadata/tests/test-xmp-model.c
+++ b/plug-ins/metadata/tests/test-xmp-model.c
@@ -267,7 +267,7 @@ test_xmp_model_parse_file (GimpTestFixture *fixture,
// description
value = xmp_model_get_scalar_property (fixture->xmp_model, "dc", "description");
- g_assert_cmpstr (value, == , "bla");
+ g_assert_cmpstr (value, == , "Hello, World,");
g_free (uri);
}
diff --git a/plug-ins/metadata/xmp-model.c b/plug-ins/metadata/xmp-model.c
index 9344f5d..75676b4 100644
--- a/plug-ins/metadata/xmp-model.c
+++ b/plug-ins/metadata/xmp-model.c
@@ -245,16 +245,15 @@ convert_to_xmp_model_raw_value (const gchar *in)
GSList *list_iter;
int i;
- /* extract the language and corresponding value
+ /* extract the language and corresponding value.
+ * TODO: Fix up values ending with a separator charactor (e.g. ',')
*/
- splitted = g_strsplit_set (in, "\",", -1);
+ splitted = g_regex_split_simple ("lang=\"([\\w_\\-]+)\"", in, 0, 0);
for (i=0; splitted[i] != NULL; i++)
{
- value = g_strchug (splitted[i]);
- if (g_str_has_prefix (value, "lang"))
- continue;
- else
- list = g_slist_append (list, g_strdup (value));
+ value = g_strstrip (splitted[i]);
+ if (strcmp (value, ""))
+ list = g_slist_append (list, g_strdup (value));
}
/* in case we only extracted one element, the language identifier is
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]