Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gThumb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
91
Issues
91
List
Boards
Labels
Service Desk
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
gThumb
Commits
3bdb4f94
Commit
3bdb4f94
authored
Dec 31, 2020
by
Paolo Bacchilega
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exiv2: remove the charset= prefix from strings
Fixes
#137
parent
a658a8ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
16 deletions
+42
-16
extensions/exiv2_tools/exiv2-utils.cpp
extensions/exiv2_tools/exiv2-utils.cpp
+3
-7
gthumb/str-utils.c
gthumb/str-utils.c
+20
-0
gthumb/str-utils.h
gthumb/str-utils.h
+2
-0
gthumb/test-glib-utils.c
gthumb/test-glib-utils.c
+17
-9
No files found.
extensions/exiv2_tools/exiv2-utils.cpp
View file @
3bdb4f94
...
...
@@ -273,14 +273,10 @@ create_metadata (const char *key,
else
formatted_value_utf8
=
g_locale_to_utf8
(
formatted_value
,
-
1
,
NULL
,
NULL
,
NULL
);
}
else
if
(
_g_utf8_has_prefix
(
formatted_value_utf8
,
"lang="
))
{
const
char
*
after_space
;
char
*
formatted_clean
;
after_space
=
_g_utf8_after_ascii_space
(
formatted_value_utf8
);
formatted_clean
=
g_strdup
(
after_space
);
else
{
char
*
tmp
=
_g_utf8_remove_string_properties
(
formatted_value_utf8
);
g_free
(
formatted_value_utf8
);
formatted_value_utf8
=
formatted_clean
;
formatted_value_utf8
=
tmp
;
}
if
(
formatted_value_utf8
==
NULL
)
...
...
gthumb/str-utils.c
View file @
3bdb4f94
...
...
@@ -995,3 +995,23 @@ _g_utf8_text_escape_xml (const char *str)
{
return
_g_utf8_escape_xml_flags
(
str
,
XML_ESCAPE_TEXT
);
}
char
*
_g_utf8_remove_string_properties
(
const
char
*
str
)
{
const
char
*
known_properties
[]
=
{
"lang="
,
"charset="
};
const
char
*
after_properties
=
str
;
int
i
;
for
(
i
=
0
;
i
<
G_N_ELEMENTS
(
known_properties
);
/* void */
)
{
if
(
_g_utf8_has_prefix
(
after_properties
,
known_properties
[
i
]))
{
after_properties
=
_g_utf8_after_ascii_space
(
after_properties
);
i
=
0
;
}
else
i
++
;
}
return
(
after_properties
!=
NULL
)
?
g_strdup
(
after_properties
)
:
NULL
;
}
gthumb/str-utils.h
View file @
3bdb4f94
...
...
@@ -96,6 +96,8 @@ char * _g_utf8_translate (const char *str,
...)
G_GNUC_NULL_TERMINATED
;
char
*
_g_utf8_escape_xml
(
const
char
*
str
);
char
*
_g_utf8_text_escape_xml
(
const
char
*
str
);
char
*
_g_utf8_remove_string_properties
(
const
char
*
str
);
G_END_DECLS
...
...
gthumb/test-glib-utils.c
View file @
3bdb4f94
...
...
@@ -146,13 +146,12 @@ test_g_utf8_find_str (void)
static
void
test_remove_
lang
_from_utf8_string
(
const
char
*
value
,
const
char
*
expected
)
test_remove_
properties
_from_utf8_string
(
const
char
*
value
,
const
char
*
expected
)
{
char
*
result
=
NULL
;
if
(
_g_utf8_has_prefix
(
value
,
"lang="
))
result
=
g_strdup
(
_g_utf8_after_ascii_space
(
value
));
result
=
_g_utf8_remove_string_properties
(
value
);
g_assert_cmpstr
(
result
,
==
,
expected
);
g_free
(
result
);
...
...
@@ -160,11 +159,20 @@ test_remove_lang_from_utf8_string (const char *value,
static
void
test_
remove_lang_from_utf8_string_all
(
void
)
test_
g_utf8_remove_string_properties
(
void
)
{
test_remove_lang_from_utf8_string
(
"lang=EN hello"
,
"hello"
);
test_remove_lang_from_utf8_string
(
"lang=FR langue d’oïl"
,
"langue d’oïl"
);
test_remove_lang_from_utf8_string
(
"lang=正體字/繁體字 中华人民共和国"
,
"中华人民共和国"
);
test_remove_properties_from_utf8_string
(
NULL
,
NULL
);
test_remove_properties_from_utf8_string
(
""
,
""
);
test_remove_properties_from_utf8_string
(
"正體字"
,
"正體字"
);
test_remove_properties_from_utf8_string
(
"langue d’oïl"
,
"langue d’oïl"
);
test_remove_properties_from_utf8_string
(
"lang=FR langue d’oïl"
,
"langue d’oïl"
);
test_remove_properties_from_utf8_string
(
"lang=正體字/繁體字 中华人民共和国"
,
"中华人民共和国"
);
test_remove_properties_from_utf8_string
(
"charset=UTF-8 langue d’oïl"
,
"langue d’oïl"
);
test_remove_properties_from_utf8_string
(
"lang=FR charset=UTF-8 langue d’oïl"
,
"langue d’oïl"
);
test_remove_properties_from_utf8_string
(
"charset=UTF-8 lang=FR langue d’oïl"
,
"langue d’oïl"
);
test_remove_properties_from_utf8_string
(
"lang=FR charset=UTF-8 field=value langue d’oïl"
,
"field=value langue d’oïl"
);
test_remove_properties_from_utf8_string
(
"lang=FR field=value charset=UTF-8 langue d’oïl"
,
"field=value charset=UTF-8 langue d’oïl"
);
test_remove_properties_from_utf8_string
(
"field=value lang=FR charset=UTF-8 langue d’oïl"
,
"field=value lang=FR charset=UTF-8 langue d’oïl"
);
}
...
...
@@ -926,6 +934,7 @@ main (int argc,
g_test_add_func
(
"/glib-utils/_g_utf8_split_template"
,
test_g_utf8_split_template_all
);
g_test_add_func
(
"/glib-utils/_g_utf8_strip"
,
test_g_utf8_strip_all
);
g_test_add_func
(
"/glib-utils/_g_utf8_translate"
,
test_g_utf8_translate_all
);
g_test_add_func
(
"/glib-utils/_g_utf8_remove_string_properties"
,
test_g_utf8_remove_string_properties
);
g_test_add_func
(
"/glib-utils/_g_path_get_basename"
,
test_g_path_get_basename_all
);
g_test_add_func
(
"/glib-utils/_g_path_get_extension"
,
test_g_path_get_extension_all
);
...
...
@@ -949,7 +958,6 @@ main (int argc,
g_test_add_func
(
"/glib-utils/_g_file_get_display_name"
,
test_g_file_get_display_name_all
);
g_test_add_func
(
"/glib-utils/_g_rand_string"
,
test_g_rand_string
);
g_test_add_func
(
"/glib-utils/regex"
,
test_regexp
);
g_test_add_func
(
"/glib-utils/remove_lang_from_utf8_string"
,
test_remove_lang_from_utf8_string_all
);
return
g_test_run
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment