lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [11/20] git commit: refs/heads/cfish-string-prep1 - Introduce StrIter_Starts_With_UTF8
Date Sat, 07 Sep 2013 16:53:32 GMT
Introduce StrIter_Starts_With_UTF8


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/e1d95d20
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/e1d95d20
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/e1d95d20

Branch: refs/heads/cfish-string-prep1
Commit: e1d95d20cc7772bf66c201ea9740d5d723f58c1a
Parents: e3a2f92
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Sep 7 14:29:32 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Sep 7 18:14:04 2013 +0200

----------------------------------------------------------------------
 clownfish/runtime/core/Clownfish/String.c   | 11 ++++++++---
 clownfish/runtime/core/Clownfish/String.cfh |  6 ++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/e1d95d20/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index ce10b7f..6bfcea7 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -1048,6 +1048,12 @@ StrIter_Skip_Prev_Whitespace_IMP(StringIterator *self) {
 
 bool
 StrIter_Starts_With_IMP(StringIterator *self, String *prefix) {
+    return StrIter_Starts_With_UTF8_IMP(self, prefix->ptr, prefix->size);
+}
+
+bool
+StrIter_Starts_With_UTF8_IMP(StringIterator *self, const char *prefix,
+                             size_t size) {
     String *string      = self->string;
     size_t  byte_offset = self->byte_offset;
 
@@ -1055,10 +1061,9 @@ StrIter_Starts_With_IMP(StringIterator *self, String *prefix) {
         THROW(ERR, "Invalid StringIterator offset");
     }
 
-    if (string->size - byte_offset < prefix->size) { return false; }
+    if (string->size - byte_offset < size) { return false; }
 
-    const char *ptr = string->ptr + byte_offset;
-    return memcmp(ptr, prefix->ptr, prefix->size) == 0;
+    return memcmp(string->ptr + byte_offset, prefix, size) == 0;
 }
 
 void

http://git-wip-us.apache.org/repos/asf/lucy/blob/e1d95d20/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index b49d957..82a51c9 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -460,6 +460,12 @@ class Clownfish::StringIterator cnick StrIter
     bool
     Starts_With(StringIterator *self, String *prefix);
 
+    /** Test whether the content after the iterator starts with the passed-in
+     * string.
+     */
+    bool
+    Starts_With_UTF8(StringIterator *self, const char *prefix, size_t size);
+
     public void
     Destroy(StringIterator *self);
 }


Mime
View raw message