lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [1/2] git commit: refs/heads/cfish-string-prep1 - Copy substring of wrapped strings
Date Sat, 21 Sep 2013 16:49:49 GMT
Updated Branches:
  refs/heads/cfish-string-prep1 eb309582b -> c69fb741a


Copy substring of wrapped strings


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

Branch: refs/heads/cfish-string-prep1
Commit: 1d7ea094256ace6ae85cdd859d9297e8acb9b019
Parents: eb30958
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Wed Sep 18 20:43:48 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Sep 21 01:58:00 2013 +0200

----------------------------------------------------------------------
 clownfish/runtime/core/Clownfish/String.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/1d7ea094/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index 8747ab3..ab4d34e 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -156,11 +156,19 @@ Str_newf(const char *pattern, ...) {
 }
 
 static String*
-S_new_substring(String *origin, size_t byte_offset, size_t size) {
+S_new_substring(String *string, size_t byte_offset, size_t size) {
     String *self = (String*)VTable_Make_Obj(STRING);
-    self->ptr    = origin->ptr + byte_offset;
-    self->size   = size;
-    self->origin = (String*)INCREF(origin);
+
+    if (string->origin == NULL) {
+        // Copy substring of wrapped strings.
+        Str_init_from_trusted_utf8(self, string->ptr + byte_offset, size);
+    }
+    else {
+        self->ptr    = string->ptr + byte_offset;
+        self->size   = size;
+        self->origin = (String*)INCREF(string->origin);
+    }
+
     return self;
 }
 


Mime
View raw message