[vala] glib-2.0: Add string.last_index_of
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] glib-2.0: Add string.last_index_of
- Date: Thu, 20 Jan 2011 21:16:14 +0000 (UTC)
commit 7e4a8f29ba14303d543d18bab2299d41f069c867
Author: Jürg Billeter <j bitron ch>
Date: Thu Jan 20 22:08:41 2011 +0100
glib-2.0: Add string.last_index_of
This deprecates string.rstr.
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 5ea94db..628192b 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -958,6 +958,7 @@ public class string {
[Deprecated (replacement = "string.index_of")]
[CCode (cname = "strstr")]
public unowned string? str (string needle);
+ [Deprecated (replacement = "string.last_index_of")]
[CCode (cname = "g_strrstr")]
public unowned string? rstr (string needle);
[CCode (cname = "g_strrstr_len")]
@@ -965,6 +966,8 @@ public class string {
[CCode (cname = "strstr")]
static char* strstr (char* haystack, char* needle);
+ [CCode (cname = "g_strrstr")]
+ static char* strrstr (char* haystack, char* needle);
[CCode (cname = "g_utf8_strchr")]
static char* utf8_strchr (char* str, ssize_t len, unichar c);
@@ -978,6 +981,16 @@ public class string {
}
}
+ public int last_index_of (string needle, int start_index = 0) {
+ char* result = strrstr ((char*) this + start_index, (char*) needle);
+
+ if (result != null) {
+ return (int) (result - (char*) this);
+ } else {
+ return -1;
+ }
+ }
+
public int index_of_char (unichar c, int start_index = 0) {
char* result = utf8_strchr ((char*) this + start_index, -1, c);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]