Ticket #2085 (closed task: fixed)
Repalce GLib deprecated functions
Reported by: | vit_r | Owned by: | andrew_b |
---|---|---|---|
Priority: | major | Milestone: | 4.7.3 |
Component: | mc-core | Version: | master |
Keywords: | Cc: | zaytsev | |
Blocked By: | Blocking: | ||
Branch state: | Votes for changeset: | committed-master |
Description (last modified by andrew_b) (diff)
g_string_sprintf() is deprecated
it is met currently (master) only in src/editor/edit.c
replacing it by g_strdup_printf()
Attachments
Change History
Changed 15 years ago by vit_r
- Attachment 2085-edit.c-replacing-g_string_sprintf-by-g_strdup_printf.patch added
comment:1 Changed 15 years ago by andrew_b
- Component changed from mcedit to mc-core
- Type changed from defect to task
- Description modified (diff)
- Summary changed from edit.c-replacing-g_string_sprintf-by-g_strdup_printf to Repalce GLib deprecated functions
comment:2 Changed 15 years ago by andrew_b
- Owner set to andrew_b
- Status changed from new to accepted
- Description modified (diff)
Created 2085_deprecated_glib_functions branch. Parent branch is master.
Initial changeset:25255b187c821e530de5530ef8eb3b443d842d51
Changed 15 years ago by vit_r
- Attachment 2085-ftpfs.c-repl-deprecated-g_strup-by-g_ascii_strup.patch added
ftpfs.c-repl-deprecated-g_strup-by-g_ascii_strup.patch
comment:3 Changed 15 years ago by vit_r
2085-ftpfs.c-repl-deprecated-g_strup-by-g_ascii_strup.patch
g_strup() is met only once in lib/vfs/mc-vfs/ftpfs.c
GLib says:
g_strup () gchar* g_strup (gchar *string); Warning This function is totally broken ... use g_ascii_strup() or g_utf8_strup() instead. Converts a string to upper case. string : the string to convert. Returns : the string
Checking the current encoding would be better
for choosing between g_ascii_strup() or g_utf8_strup()
---
2085-repl-deprecated-g_strncasecmp-by-g_ascii_strncasecmp.patch
g_strncasecmp() is met twice
GLib says:
g_ascii_strncasecmp () gint g_ascii_strncasecmp (const gchar *s1, const gchar *s2, gsize n); Compare s1 and s2, ignoring the case of ASCII characters and any characters after the first n in each string. Unlike the BSD strcasecmp() function, this only recognizes standard ASCII letters and ignores the locale, treating all non-ASCII characters as if they are not letters. The same warning as in g_ascii_strcasecmp() applies: Use this function only on strings known to be in encodings where bytes corresponding to ASCII letters always represent themselves. s1 : string to compare with s2. s2 : string to compare with s1. n : number of characters to compare. Returns : 0 if the strings match, a negative value if s1 < s2, or a positive value if s1 > s2.
Seems nothing more is needed with g_strncasecmp().
-
Changed 15 years ago by vit_r
- Attachment 2085-repl-deprecated-g_strncasecmp-by-g_ascii_strncasecmp.patch added
repl-deprecated-g_strncasecmp-by-g_ascii_strncasecmp
Changed 15 years ago by vit_r
- Attachment 2085-repl-deprecated-g_strcasecmp-by-g_ascii_strcasecmp.patch added
2085-repl-deprecated-g_strcasecmp-by-g_ascii_strcasecmp
comment:4 Changed 15 years ago by vit_r
2085-repl-deprecated-g_strcasecmp-by-g_ascii_strcasecmp.patch
In case for something else (_NOT_ for ascii):
GLib says:
g_utf8_casefold () gchar * g_utf8_casefold (const gchar *str, gssize len); Converts a string into a form that is independent of case. The result will not correspond to any particular case, but can be compared for equality or ordered with the results of calling g_utf8_casefold() on other strings. Note that calling g_utf8_casefold() followed by g_utf8_collate() is only an approximation to the correct linguistic case insensitive ordering, though it is a fairly good one. Getting this exactly right would require a more sophisticated collation function that takes case sensitivity into account. GLib does not currently provide such a function. str : a UTF-8 encoded string len : length of str, in bytes, or -1 if str is nul-terminated. Returns : a newly allocated string, that is a case independent form of str.
Meanwhile
Seems nothing more is needed with g_strncasecmp() for the moment.
First step (a try) is ready for discussion or decisions
Is need for something like
if (str_detect_termencoding () == ascii) etc?
There are two more left ('g_tree_traverse' once is met)
src/editor/syntax.c:132: g_tree_traverse ()This 'g_tree_traverse' is for experts
and 'g_strdown' four times met in strutil/strutil8bit.c
In last case many questions ... and testing ...
Changed 15 years ago by vit_r
- Attachment 2085-lib-strutil-strutil8bit.c-getting-rid-of-g_strdown.patch added
lib-strutil-strutil8bit.c-getting-rid-of-g_strdown
comment:5 Changed 15 years ago by vit_r
This 2085-lib-strutil-strutil8bit.c-getting-rid-of-g_strdown.patch
has two main goals
- to get rid of 'g_strdown()'
- to concenrate problem in one place
in this case on next line
(from my invention - str_8bit_down (const char *str)):
*rets = char_tolower (*rets);
function 'char_tolower()' is picked up from
str_8bit_tolower (const char *text, char out, size_t * remain) {...}
One of the strangest thing in lib/strutil/strutil8bit.c:
it calls 'char_tolower()', 'char_toupper()'
but where these functions resides?
--
and next
2085-repl-deprecated-g_tree_traverse-by-g_tree_foreach.patch
is about the last found deprecated symbol
--
comment:6 Changed 14 years ago by andrew_b
- severity changed from no branch to on review
- Milestone changed from 4.7 to 4.7.3
Created 2085_deprecated_glib_functions branch. Parent branch is master.
Initial chageset: bf3cb9953749ab2bab861d029539597069dc761d
comment:7 Changed 14 years ago by andrew_b
Rebased to current master.
Initial changeset:4c73c2ae8ee42de7bbcd1fcab6a21456faa4b205
comment:9 Changed 14 years ago by angel_il
- Votes for changeset changed from slavazanko to slavazanko angel_il
- severity changed from on review to approved
comment:10 Changed 14 years ago by andrew_b
- Status changed from accepted to testing
- Votes for changeset changed from slavazanko angel_il to committed-master
- Resolution set to fixed
- severity changed from approved to merged
Merged to master.
changeset:7d000ad5e5b08e3d58a109bb6d7f4496fdf9fdab
git log --pretty=oneline f5ae2bf..7d000ad
comment:11 Changed 14 years ago by andrew_b
- Status changed from testing to closed
- Keywords stable-candidate added
comment:12 Changed 14 years ago by andrew_b
#2249 fixes the incorrect return value of str_8bit_strdown() function.
comment:13 Changed 14 years ago by zaytsev
- Cc zaytsev added
1) Why our own strdown?
2) Why our own strncmp / strcmp? g_ascii_strncasecmp() !
I don't get the point.
comment:14 Changed 14 years ago by andrew_b
g_ascii_strncasecmp() only works on ASCII and is not locale-sensitive. Our own strdown() gives us the correct result in 8-bit locales.
edit.c-replacing-g_string_sprintf-by-g_strdup_printf