diff options
author | Jürg Billeter <j@bitron.ch> | 2011-01-20 22:10:27 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2011-01-20 22:15:14 +0100 |
commit | f586e13e182eee9d73e6d44fb3f4439fad4b5114 (patch) | |
tree | 28fb25cbe045cf4ae86be5adc85d515097d0f7ac /vapi | |
parent | 7e4a8f29ba14303d543d18bab2299d41f069c867 (diff) | |
download | vala-f586e13e182eee9d73e6d44fb3f4439fad4b5114.tar.gz |
glib-2.0: Add string.last_index_of_char
This deprecates string.rchr.
Diffstat (limited to 'vapi')
-rw-r--r-- | vapi/glib-2.0.vapi | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index 628192b88..71846b1d9 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -970,6 +970,8 @@ public class string { static char* strrstr (char* haystack, char* needle); [CCode (cname = "g_utf8_strchr")] static char* utf8_strchr (char* str, ssize_t len, unichar c); + [CCode (cname = "g_utf8_strrchr")] + static char* utf8_strrchr (char* str, ssize_t len, unichar c); public int index_of (string needle, int start_index = 0) { char* result = strstr ((char*) this + start_index, (char*) needle); @@ -1001,6 +1003,16 @@ public class string { } } + public int last_index_of_char (unichar c, int start_index = 0) { + char* result = utf8_strrchr ((char*) this + start_index, -1, c); + + if (result != null) { + return (int) (result - (char*) this); + } else { + return -1; + } + } + [CCode (cname = "g_str_has_prefix")] public bool has_prefix (string prefix); [CCode (cname = "g_str_has_suffix")] @@ -1080,6 +1092,7 @@ public class string { [Deprecated (replacement = "string.index_of_char")] [CCode (cname = "g_utf8_strchr")] public unowned string chr (ssize_t len, unichar c); + [Deprecated (replacement = "string.last_index_of_char")] [CCode (cname = "g_utf8_strrchr")] public unowned string rchr (ssize_t len, unichar c); [CCode (cname = "g_utf8_strreverse")] |