lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [30/50] [abbrv] git commit: refs/heads/master - Copy substring of wrapped strings
Date Fri, 11 Oct 2013 13:32:08 GMT
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/9bf27d98
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/9bf27d98
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/9bf27d98

Branch: refs/heads/master
Commit: 9bf27d9822ffc91672e4475fd7b88d315fb6fc90
Parents: 6bc95d5
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Wed Sep 18 20:43:48 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Fri Oct 11 15:28:18 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/9bf27d98/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