You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/09/14 21:29:33 UTC
[lucy-commits] [01/15] git commit: refs/heads/cfish-string-prep1 - Fix bulk renaming
of ZombieCharBuf
Updated Branches:
refs/heads/cfish-string-prep1 0f10d5af2 -> fde94c411
Fix bulk renaming of ZombieCharBuf
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/8ab06750
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/8ab06750
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/8ab06750
Branch: refs/heads/cfish-string-prep1
Commit: 8ab067504db143facc96126ecdf2a1f679aac6ca
Parents: 0f10d5a
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Sep 13 20:56:58 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Fri Sep 13 20:56:58 2013 +0200
----------------------------------------------------------------------
clownfish/compiler/src/CFCPerlTypeMap.c | 2 +-
clownfish/compiler/src/CFCRuby.c | 2 +-
clownfish/runtime/core/Clownfish/String.cfh | 12 ++++++------
.../runtime/perl/buildlib/Clownfish/Build/Binding.pm | 2 +-
clownfish/runtime/perl/xs/XSBind.c | 2 +-
core/Lucy/Store/Folder.c | 2 +-
core/Lucy/Test/Store/TestCompoundFileReader.c | 2 +-
core/Lucy/Test/Store/TestFolderCommon.c | 2 +-
core/Lucy/Test/Store/TestRAMFolder.c | 2 +-
perl/buildlib/Lucy/Build/Binding/Misc.pm | 2 +-
perl/xs/Lucy/Index/DocReader.c | 2 +-
perl/xs/Lucy/Index/Inverter.c | 2 +-
12 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/clownfish/compiler/src/CFCPerlTypeMap.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerlTypeMap.c b/clownfish/compiler/src/CFCPerlTypeMap.c
index a50e013..f568e15 100644
--- a/clownfish/compiler/src/CFCPerlTypeMap.c
+++ b/clownfish/compiler/src/CFCPerlTypeMap.c
@@ -234,7 +234,7 @@ static const char typemap_input[] =
" $var = (sizeof(UV) == 8) ? ($type)SvUV($arg) : ($type)SvNV($arg);\n"
"\n"
"CONST_CHARBUF\n"
- " $var = (const cfish_String*)CFISH_SStr_WRAP_STR(SvPVutf8_nolen($arg), SvCUR($arg));\n"
+ " $var = (const cfish_String*)CFISH_SSTR_WRAP_STR(SvPVutf8_nolen($arg), SvCUR($arg));\n"
"\n";
static const char typemap_output[] =
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/clownfish/compiler/src/CFCRuby.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCRuby.c b/clownfish/compiler/src/CFCRuby.c
index 4b67022..b225fd9 100644
--- a/clownfish/compiler/src/CFCRuby.c
+++ b/clownfish/compiler/src/CFCRuby.c
@@ -205,7 +205,7 @@ S_write_boot_c(CFCRuby *self) {
"%s() {\n"
" %sbootstrap_parcel();\n"
"\n"
- " cfish_StackString *alias = CFISH_SStr_WRAP_STR(\"\", 0);\n"
+ " cfish_StackString *alias = CFISH_SSTR_WRAP_STR(\"\", 0);\n"
"}\n"
"\n"
"%s\n"
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index d54f473..f49ddd2 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -423,20 +423,20 @@ class Clownfish::StackStringIterator cnick SStrIter
__C__
-#define CFISH_SStr_BLANK() cfish_SStr_new(cfish_alloca(cfish_SStr_size()))
+#define CFISH_SSTR_BLANK() cfish_SStr_new(cfish_alloca(cfish_SStr_size()))
-#define CFISH_SStr_WRAP(source) \
+#define CFISH_SSTR_WRAP(source) \
cfish_SStr_wrap(cfish_alloca(cfish_SStr_size()), source)
-#define CFISH_SStr_WRAP_STR(ptr, size) \
+#define CFISH_SSTR_WRAP_STR(ptr, size) \
cfish_SStr_wrap_str(cfish_alloca(cfish_SStr_size()), ptr, size)
#define CFISH_STRITER_DONE UINT32_MAX
#ifdef CFISH_USE_SHORT_NAMES
- #define SStr_BLANK CFISH_SStr_BLANK
- #define SSTR_WRAP CFISH_SStr_WRAP
- #define SSTR_WRAP_STR CFISH_SStr_WRAP_STR
+ #define SSTR_BLANK CFISH_SSTR_BLANK
+ #define SSTR_WRAP CFISH_SSTR_WRAP
+ #define SSTR_WRAP_STR CFISH_SSTR_WRAP_STR
#define STRITER_DONE CFISH_STRITER_DONE
#endif
__END_C__
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index 5edf4c0..2d7ef0e 100644
--- a/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -594,7 +594,7 @@ CODE:
CFISH_UNUSED_VAR(unused_sv);
STRLEN size;
char *ptr = SvPVutf8(class_name_sv, size);
- cfish_StackString *class_name = CFISH_SStr_WRAP_STR(ptr, size);
+ cfish_StackString *class_name = CFISH_SSTR_WRAP_STR(ptr, size);
cfish_VTable *vtable
= cfish_VTable_fetch_vtable((cfish_String*)class_name);
RETVAL = vtable ? (SV*)CFISH_VTable_To_Host(vtable) : &PL_sv_undef;
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/clownfish/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/xs/XSBind.c b/clownfish/runtime/perl/xs/XSBind.c
index b466cf6..39d65d8 100644
--- a/clownfish/runtime/perl/xs/XSBind.c
+++ b/clownfish/runtime/perl/xs/XSBind.c
@@ -64,7 +64,7 @@ XSBind_new_blank_obj(SV *either_sv) {
// Use the supplied class name string to find a VTable.
STRLEN len;
char *ptr = SvPVutf8(either_sv, len);
- cfish_StackString *klass = CFISH_SStr_WRAP_STR(ptr, len);
+ cfish_StackString *klass = CFISH_SSTR_WRAP_STR(ptr, len);
vtable = cfish_VTable_singleton((cfish_String*)klass, NULL);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/core/Lucy/Store/Folder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/Folder.c b/core/Lucy/Store/Folder.c
index c002e9d..9d7bb46 100644
--- a/core/Lucy/Store/Folder.c
+++ b/core/Lucy/Store/Folder.c
@@ -262,7 +262,7 @@ Folder_Open_Dir_IMP(Folder *self, const String *path) {
folder = Folder_Find_Folder(self, path);
}
else {
- StackString *empty = SStr_BLANK();
+ StackString *empty = SSTR_BLANK();
folder = Folder_Find_Folder(self, (String*)empty);
}
if (!folder) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/core/Lucy/Test/Store/TestCompoundFileReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestCompoundFileReader.c b/core/Lucy/Test/Store/TestCompoundFileReader.c
index d28075b..bb7eb89 100644
--- a/core/Lucy/Test/Store/TestCompoundFileReader.c
+++ b/core/Lucy/Test/Store/TestCompoundFileReader.c
@@ -78,7 +78,7 @@ S_folder_with_contents() {
OutStream_Close(bar_out);
DECREF(foo_out);
DECREF(bar_out);
- StackString *empty = SStr_BLANK();
+ StackString *empty = SSTR_BLANK();
RAMFolder_Consolidate(folder, (String*)empty);
return (Folder*)folder;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/core/Lucy/Test/Store/TestFolderCommon.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestFolderCommon.c b/core/Lucy/Test/Store/TestFolderCommon.c
index f137544..ce13170 100644
--- a/core/Lucy/Test/Store/TestFolderCommon.c
+++ b/core/Lucy/Test/Store/TestFolderCommon.c
@@ -137,7 +137,7 @@ test_Local_Find_Folder(TestBatchRunner *runner, set_up_t set_up,
local = Folder_Local_Find_Folder(folder, nope);
TEST_TRUE(runner, local == NULL, "Non-existent entry yields NULL");
- StackString *empty = SStr_BLANK();
+ StackString *empty = SSTR_BLANK();
local = Folder_Local_Find_Folder(folder, (String*)empty);
TEST_TRUE(runner, local == NULL, "Empty string yields NULL");
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/core/Lucy/Test/Store/TestRAMFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestRAMFolder.c b/core/Lucy/Test/Store/TestRAMFolder.c
index e712697..13aeb9d 100644
--- a/core/Lucy/Test/Store/TestRAMFolder.c
+++ b/core/Lucy/Test/Store/TestRAMFolder.c
@@ -139,7 +139,7 @@ test_Local_Find_Folder(TestBatchRunner *runner) {
local = (RAMFolder*)RAMFolder_Local_Find_Folder(folder, nope);
TEST_TRUE(runner, local == NULL, "Non-existent entry yields NULL");
- StackString *empty = SStr_BLANK();
+ StackString *empty = SSTR_BLANK();
local = (RAMFolder*)RAMFolder_Local_Find_Folder(folder, (String*)empty);
TEST_TRUE(runner, local == NULL, "Empty string yields NULL");
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/perl/buildlib/Lucy/Build/Binding/Misc.pm
----------------------------------------------------------------------
diff --git a/perl/buildlib/Lucy/Build/Binding/Misc.pm b/perl/buildlib/Lucy/Build/Binding/Misc.pm
index 287ef18..6f082bc 100644
--- a/perl/buildlib/Lucy/Build/Binding/Misc.pm
+++ b/perl/buildlib/Lucy/Build/Binding/Misc.pm
@@ -141,7 +141,7 @@ PPCODE:
{
char *class_name = HvNAME(SvSTASH(SvRV(blank_obj)));
cfish_StackString *klass
- = CFISH_SStr_WRAP_STR(class_name, strlen(class_name));
+ = CFISH_SSTR_WRAP_STR(class_name, strlen(class_name));
cfish_VTable *vtable
= (cfish_VTable*)cfish_VTable_singleton((cfish_String*)klass, NULL);
STRLEN len;
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/perl/xs/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Index/DocReader.c b/perl/xs/Lucy/Index/DocReader.c
index 0f95a11..15eafe1 100644
--- a/perl/xs/Lucy/Index/DocReader.c
+++ b/perl/xs/Lucy/Index/DocReader.c
@@ -62,7 +62,7 @@ LUCY_DefDocReader_Fetch_Doc_IMP(lucy_DefaultDocReader *self, int32_t doc_id) {
// Find the Field's FieldType.
cfish_StackString *field_name_zcb
- = CFISH_SStr_WRAP_STR(field_name_ptr, field_name_len);
+ = CFISH_SSTR_WRAP_STR(field_name_ptr, field_name_len);
type = LUCY_Schema_Fetch_Type(schema, (cfish_String*)field_name_zcb);
// Read the field value.
http://git-wip-us.apache.org/repos/asf/lucy/blob/8ab06750/perl/xs/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Index/Inverter.c b/perl/xs/Lucy/Index/Inverter.c
index 67116e0..1d120b1 100644
--- a/perl/xs/Lucy/Index/Inverter.c
+++ b/perl/xs/Lucy/Index/Inverter.c
@@ -50,7 +50,7 @@ S_fetch_entry(lucy_Inverter *self, HE *hash_entry) {
}
}
- cfish_StackString *field = CFISH_SStr_WRAP_STR(key, key_len);
+ cfish_StackString *field = CFISH_SSTR_WRAP_STR(key, key_len);
int32_t field_num
= LUCY_Seg_Field_Num(ivars->segment, (cfish_String*)field);
if (!field_num) {
[lucy-commits] [15/15] git commit: refs/heads/cfish-string-prep1 - Rework cloning of
Strings
Posted by nw...@apache.org.
Rework cloning of Strings
Now that strings are immutable, Clone and To_String can simply increase
the refcount and return 'self'. Only wrapped strings have to be copied.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/fde94c41
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/fde94c41
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/fde94c41
Branch: refs/heads/cfish-string-prep1
Commit: fde94c411c7c73ad35171bb19295f781ed48e0dd
Parents: 3c9c7da
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 21:08:56 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 21:20:16 2013 +0200
----------------------------------------------------------------------
clownfish/runtime/core/Clownfish/String.c | 18 ++++++++++++++++--
clownfish/runtime/core/Clownfish/String.cfh | 3 +++
clownfish/runtime/core/Clownfish/Test/TestHash.c | 7 ++++---
.../runtime/core/Clownfish/Test/TestVArray.c | 2 +-
4 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/fde94c41/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index c917a79..e9b0936 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -164,6 +164,20 @@ S_new_substring(String *origin, size_t byte_offset, size_t size) {
return self;
}
+Obj*
+Str_Inc_RefCount_IMP(String *self) {
+ if (self->origin == NULL) {
+ // Copy wrapped strings when the refcount is increased.
+ String *copy = (String*)VTable_Make_Obj(STRING);
+ return (Obj*)Str_init_from_trusted_utf8(copy, self->ptr, self->size);
+ }
+ else {
+ Str_Inc_RefCount_t super_incref
+ = SUPER_METHOD_PTR(STRING, CFISH_Str_Inc_RefCount);
+ return super_incref(self);
+ }
+}
+
void
Str_Destroy_IMP(String *self) {
if (self->origin == self) {
@@ -202,7 +216,7 @@ S_die_invalid_utf8(const char *text, size_t size, const char *file, int line,
String*
Str_To_String_IMP(String *self) {
- return Str_new_from_trusted_utf8(self->ptr, self->size);
+ return (String*)INCREF(self);
}
String*
@@ -291,7 +305,7 @@ Str_To_Utf8_IMP(String *self) {
String*
Str_Clone_IMP(String *self) {
- return Str_new_from_trusted_utf8(self->ptr, self->size);
+ return (String*)INCREF(self);
}
String*
http://git-wip-us.apache.org/repos/asf/lucy/blob/fde94c41/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index a1a0378..e060aa5 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -203,6 +203,9 @@ class Clownfish::String cnick Str
public incremented String*
Clone(String *self);
+ incremented Obj*
+ Inc_RefCount(String *self);
+
public void
Destroy(String *self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/fde94c41/clownfish/runtime/core/Clownfish/Test/TestHash.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestHash.c b/clownfish/runtime/core/Clownfish/Test/TestHash.c
index ca35f1a..cb93b2e 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestHash.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestHash.c
@@ -97,7 +97,8 @@ test_Store_and_Fetch(TestBatchRunner *runner) {
TEST_TRUE(runner, Hash_Fetch(hash, (Obj*)foo) == NULL,
"Fetch against non-existent key returns NULL");
- Hash_Store(hash, (Obj*)forty, INCREF(foo));
+ Obj *stored_foo = INCREF(foo);
+ Hash_Store(hash, (Obj*)forty, stored_foo);
TEST_TRUE(runner, SStr_Equals(foo, Hash_Fetch(hash, (Obj*)forty)),
"Hash_Store replaces existing value");
TEST_FALSE(runner, Hash_Equals(hash, (Obj*)dupe),
@@ -105,9 +106,9 @@ test_Store_and_Fetch(TestBatchRunner *runner) {
TEST_INT_EQ(runner, Hash_Get_Size(hash), 100,
"size unaffected after value replaced");
- TEST_TRUE(runner, Hash_Delete(hash, (Obj*)forty) == (Obj*)foo,
+ TEST_TRUE(runner, Hash_Delete(hash, (Obj*)forty) == stored_foo,
"Delete returns value");
- DECREF(foo);
+ DECREF(stored_foo);
TEST_INT_EQ(runner, Hash_Get_Size(hash), 99,
"size decremented by successful Delete");
TEST_TRUE(runner, Hash_Delete(hash, (Obj*)forty) == NULL,
http://git-wip-us.apache.org/repos/asf/lucy/blob/fde94c41/clownfish/runtime/core/Clownfish/Test/TestVArray.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestVArray.c b/clownfish/runtime/core/Clownfish/Test/TestVArray.c
index 1abb89e..4aa9ccd 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestVArray.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestVArray.c
@@ -278,7 +278,7 @@ test_Clone_and_Shallow_Copy(TestBatchRunner *runner) {
uint32_t i;
for (i = 0; i < 10; i++) {
- VA_Push(array, (Obj*)Str_newf("%u32", i));
+ VA_Push(array, (Obj*)Int32_new(i));
}
twin = VA_Shallow_Copy(array);
TEST_TRUE(runner, VA_Equals(array, (Obj*)twin), "Shallow_Copy");
[lucy-commits] [03/15] Rename _UTF8 and _Str to _Utf8
Posted by nw...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/LucyX/Search/ProximityQuery.c
----------------------------------------------------------------------
diff --git a/core/LucyX/Search/ProximityQuery.c b/core/LucyX/Search/ProximityQuery.c
index 903995a..ee76917 100644
--- a/core/LucyX/Search/ProximityQuery.c
+++ b/core/LucyX/Search/ProximityQuery.c
@@ -104,10 +104,10 @@ ProximityQuery_Dump_IMP(ProximityQuery *self) {
ProximityQuery_Dump_t super_dump
= SUPER_METHOD_PTR(PROXIMITYQUERY, LUCY_ProximityQuery_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
- Hash_Store_Str(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
- Hash_Store_Str(dump, "terms", 5, Freezer_dump((Obj*)ivars->terms));
- Hash_Store_Str(dump, "within", 6,
- (Obj*)Str_newf("%i64", (int64_t)ivars->within));
+ Hash_Store_Utf8(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
+ Hash_Store_Utf8(dump, "terms", 5, Freezer_dump((Obj*)ivars->terms));
+ Hash_Store_Utf8(dump, "within", 6,
+ (Obj*)Str_newf("%i64", (int64_t)ivars->within));
return (Obj*)dump;
}
@@ -118,11 +118,11 @@ ProximityQuery_Load_IMP(ProximityQuery *self, Obj *dump) {
= SUPER_METHOD_PTR(PROXIMITYQUERY, LUCY_ProximityQuery_Load);
ProximityQuery *loaded = (ProximityQuery*)super_load(self, dump);
ProximityQueryIVARS *loaded_ivars = ProximityQuery_IVARS(loaded);
- Obj *field = CERTIFY(Hash_Fetch_Str(source, "field", 5), OBJ);
+ Obj *field = CERTIFY(Hash_Fetch_Utf8(source, "field", 5), OBJ);
loaded_ivars->field = (String*)CERTIFY(Freezer_load(field), STRING);
- Obj *terms = CERTIFY(Hash_Fetch_Str(source, "terms", 5), OBJ);
+ Obj *terms = CERTIFY(Hash_Fetch_Utf8(source, "terms", 5), OBJ);
loaded_ivars->terms = (VArray*)CERTIFY(Freezer_load(terms), VARRAY);
- Obj *within = CERTIFY(Hash_Fetch_Str(source, "within", 6), OBJ);
+ Obj *within = CERTIFY(Hash_Fetch_Utf8(source, "within", 6), OBJ);
loaded_ivars->within = (uint32_t)Obj_To_I64(within);
return (Obj*)loaded;
}
@@ -151,17 +151,17 @@ ProximityQuery_To_String_IMP(ProximityQuery *self) {
ProximityQueryIVARS *const ivars = ProximityQuery_IVARS(self);
uint32_t num_terms = VA_Get_Size(ivars->terms);
CharBuf *buf = CB_new_from_str(ivars->field);
- CB_Cat_Trusted_UTF8(buf, ":\"", 2);
+ CB_Cat_Trusted_Utf8(buf, ":\"", 2);
for (uint32_t i = 0; i < num_terms; i++) {
Obj *term = VA_Fetch(ivars->terms, i);
String *term_string = Obj_To_String(term);
CB_Cat(buf, term_string);
DECREF(term_string);
if (i < num_terms - 1) {
- CB_Cat_Trusted_UTF8(buf, " ", 1);
+ CB_Cat_Trusted_Utf8(buf, " ", 1);
}
}
- CB_Cat_Trusted_UTF8(buf, "\"", 1);
+ CB_Cat_Trusted_Utf8(buf, "\"", 1);
CB_catf(buf, "~%u32", ivars->within);
String *retval = CB_Yield_String(buf);
DECREF(buf);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/perl/xs/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Analysis/RegexTokenizer.c b/perl/xs/Lucy/Analysis/RegexTokenizer.c
index cba3ab0..59baf40 100644
--- a/perl/xs/Lucy/Analysis/RegexTokenizer.c
+++ b/perl/xs/Lucy/Analysis/RegexTokenizer.c
@@ -45,8 +45,8 @@ lucy_RegexTokenizer_init(lucy_RegexTokenizer *self,
lucy_RegexTokenizerIVARS *const ivars = lucy_RegexTokenizer_IVARS(self);
#define DEFAULT_PATTERN "\\w+(?:['\\x{2019}]\\w+)*"
if (pattern) {
- if (CFISH_Str_Find_Str(pattern, "\\p", 2) != -1
- || CFISH_Str_Find_Str(pattern, "\\P", 2) != -1
+ if (CFISH_Str_Find_Utf8(pattern, "\\p", 2) != -1
+ || CFISH_Str_Find_Utf8(pattern, "\\P", 2) != -1
) {
CFISH_DECREF(self);
THROW(CFISH_ERR, "\\p and \\P constructs forbidden");
@@ -137,9 +137,9 @@ LUCY_RegexTokenizer_Destroy_IMP(lucy_RegexTokenizer *self) {
}
void
-LUCY_RegexTokenizer_Tokenize_Str_IMP(lucy_RegexTokenizer *self,
- const char *string, size_t string_len,
- lucy_Inversion *inversion) {
+LUCY_RegexTokenizer_Tokenize_Utf8_IMP(lucy_RegexTokenizer *self,
+ const char *string, size_t string_len,
+ lucy_Inversion *inversion) {
lucy_RegexTokenizerIVARS *const ivars = lucy_RegexTokenizer_IVARS(self);
uint32_t num_code_points = 0;
SV *wrapper = sv_newmortal();
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/perl/xs/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Document/Doc.c b/perl/xs/Lucy/Document/Doc.c
index 224f0bb..1d6723a 100644
--- a/perl/xs/Lucy/Document/Doc.c
+++ b/perl/xs/Lucy/Document/Doc.c
@@ -178,12 +178,12 @@ cfish_Hash*
LUCY_Doc_Dump_IMP(lucy_Doc *self) {
lucy_DocIVARS *const ivars = lucy_Doc_IVARS(self);
cfish_Hash *dump = cfish_Hash_new(0);
- CFISH_Hash_Store_Str(dump, "_class", 6,
- (cfish_Obj*)CFISH_Str_Clone(LUCY_Doc_Get_Class_Name(self)));
- CFISH_Hash_Store_Str(dump, "doc_id", 7,
- (cfish_Obj*)cfish_Str_newf("%i32", ivars->doc_id));
- CFISH_Hash_Store_Str(dump, "fields", 6,
- XSBind_perl_to_cfish((SV*)ivars->fields));
+ CFISH_Hash_Store_Utf8(dump, "_class", 6,
+ (cfish_Obj*)CFISH_Str_Clone(LUCY_Doc_Get_Class_Name(self)));
+ CFISH_Hash_Store_Utf8(dump, "doc_id", 7,
+ (cfish_Obj*)cfish_Str_newf("%i32", ivars->doc_id));
+ CFISH_Hash_Store_Utf8(dump, "fields", 6,
+ XSBind_perl_to_cfish((SV*)ivars->fields));
return dump;
}
@@ -191,15 +191,15 @@ lucy_Doc*
LUCY_Doc_Load_IMP(lucy_Doc *self, cfish_Obj *dump) {
cfish_Hash *source = (cfish_Hash*)CFISH_CERTIFY(dump, CFISH_HASH);
cfish_String *class_name = (cfish_String*)CFISH_CERTIFY(
- CFISH_Hash_Fetch_Str(source, "_class", 6),
+ CFISH_Hash_Fetch_Utf8(source, "_class", 6),
CFISH_STRING);
cfish_VTable *vtable = cfish_VTable_singleton(class_name, NULL);
lucy_Doc *loaded = (lucy_Doc*)CFISH_VTable_Make_Obj(vtable);
cfish_Obj *doc_id = CFISH_CERTIFY(
- CFISH_Hash_Fetch_Str(source, "doc_id", 7),
+ CFISH_Hash_Fetch_Utf8(source, "doc_id", 7),
CFISH_OBJ);
cfish_Hash *fields = (cfish_Hash*)CFISH_CERTIFY(
- CFISH_Hash_Fetch_Str(source, "fields", 6),
+ CFISH_Hash_Fetch_Utf8(source, "fields", 6),
CFISH_HASH);
SV *fields_sv = XSBind_cfish_to_perl((cfish_Obj*)fields);
CHY_UNUSED_VAR(self);
[lucy-commits] [09/15] git commit: refs/heads/cfish-string-prep1 - Const 'ptr'
instance variable of String
Posted by nw...@apache.org.
Const 'ptr' instance variable of String
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/fc363f05
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/fc363f05
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/fc363f05
Branch: refs/heads/cfish-string-prep1
Commit: fc363f05501397e8997856a669ed15ef9d6ebfb2
Parents: 6c88968
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 19:11:59 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 19:11:59 2013 +0200
----------------------------------------------------------------------
clownfish/runtime/core/Clownfish/String.c | 53 +++++++++++++-----------
clownfish/runtime/core/Clownfish/String.cfh | 10 ++---
2 files changed, 34 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/fc363f05/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index df85e29..96cf22f 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -68,35 +68,36 @@ Str_new_from_trusted_utf8(const char *ptr, size_t size) {
}
String*
-Str_init_from_trusted_utf8(String *self, const char *ptr, size_t size) {
- // Derive.
- self->ptr = (char*)MALLOCATE(size + 1);
+Str_init_from_trusted_utf8(String *self, const char *utf8, size_t size) {
+ // Allocate.
+ char *ptr = (char*)MALLOCATE(size + 1);
// Copy.
- memcpy(self->ptr, ptr, size);
+ memcpy(ptr, utf8, size);
+ ptr[size] = '\0'; // Null terminate.
// Assign.
- self->size = size;
- self->ptr[size] = '\0'; // Null terminate.
+ self->ptr = ptr;
+ self->size = size;
return self;
}
String*
-Str_new_steal_from_trusted_str(char *ptr, size_t size) {
+Str_new_steal_from_trusted_str(const char *ptr, size_t size) {
String *self = (String*)VTable_Make_Obj(STRING);
return Str_init_steal_trusted_str(self, ptr, size);
}
String*
-Str_init_steal_trusted_str(String *self, char *ptr, size_t size) {
+Str_init_steal_trusted_str(String *self, const char *ptr, size_t size) {
self->ptr = ptr;
self->size = size;
return self;
}
String*
-Str_new_steal_str(char *ptr, size_t size) {
+Str_new_steal_str(const char *ptr, size_t size) {
if (!StrHelp_utf8_valid(ptr, size)) {
DIE_INVALID_UTF8(ptr, size);
}
@@ -106,10 +107,13 @@ Str_new_steal_str(char *ptr, size_t size) {
String*
Str_new_from_char(uint32_t code_point) {
const size_t MAX_UTF8_BYTES = 4;
+ char *ptr = (char*)MALLOCATE(MAX_UTF8_BYTES + 1);
+ size_t size = StrHelp_encode_utf8_char(code_point, (uint8_t*)ptr);
+ ptr[size] = '\0';
+
String *self = (String*)VTable_Make_Obj(STRING);
- self->ptr = (char*)MALLOCATE(MAX_UTF8_BYTES + 1);
- self->size = StrHelp_encode_utf8_char(code_point, (uint8_t*)self->ptr);
- self->ptr[self->size] = '\0';
+ self->ptr = ptr;
+ self->size = size;
return self;
}
@@ -127,7 +131,7 @@ Str_newf(const char *pattern, ...) {
void
Str_Destroy_IMP(String *self) {
- FREEMEM(self->ptr);
+ FREEMEM((char*)self->ptr);
SUPER_DESTROY(self, STRING);
}
@@ -321,7 +325,7 @@ Str_Ends_With_IMP(String *self, const String *postfix) {
bool
Str_Ends_With_Utf8_IMP(String *self, const char *postfix, size_t postfix_len) {
if (postfix_len <= self->size) {
- char *start = self->ptr + self->size - postfix_len;
+ const char *start = self->ptr + self->size - postfix_len;
if (memcmp(start, postfix, postfix_len) == 0) {
return true;
}
@@ -408,7 +412,7 @@ Str_SubString_IMP(String *self, size_t offset, size_t len) {
SStrIter_Advance(iter, offset);
int start_offset = iter->byte_offset;
- char *sub_start = self->ptr + start_offset;
+ const char *sub_start = self->ptr + start_offset;
SStrIter_Advance(iter, len);
size_t byte_len = iter->byte_offset - start_offset;
@@ -492,7 +496,7 @@ ViewCB_new_from_trusted_utf8(const char *utf8, size_t size) {
ViewCharBuf*
ViewCB_init(ViewCharBuf *self, const char *utf8, size_t size) {
- self->ptr = (char*)utf8;
+ self->ptr = utf8;
self->size = size;
return self;
}
@@ -518,18 +522,19 @@ SStr_new(void *allocation) {
StackString*
SStr_new_from_str(void *allocation, size_t alloc_size, String *string) {
- StackString *self
- = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
- self->size = Str_Get_Size(string);
- self->ptr = ((char*)allocation) + sizeof(StackString);
+ size_t size = string->size;
+ char *ptr = ((char*)allocation) + sizeof(StackString);
- if (alloc_size < sizeof(StackString) + self->size + 1) {
+ if (alloc_size < sizeof(StackString) + size + 1) {
THROW(ERR, "alloc_size of StackString too small");
}
- memcpy(self->ptr, Str_Get_Ptr8(string), self->size);
- self->ptr[self->size] = '\0';
+ memcpy(ptr, string->ptr, size);
+ ptr[size] = '\0';
+ StackString *self = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
+ self->ptr = ptr;
+ self->size = size;
return self;
}
@@ -538,7 +543,7 @@ SStr_wrap_str(void *allocation, const char *ptr, size_t size) {
StackString *self
= (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
self->size = size;
- self->ptr = (char*)ptr;
+ self->ptr = ptr;
return self;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/fc363f05/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index e639fa4..f64b73a 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -23,8 +23,8 @@ parcel Clownfish;
class Clownfish::String cnick Str
inherits Clownfish::Obj {
- char *ptr;
- size_t size;
+ const char *ptr;
+ size_t size;
/** Return a new String which holds a copy of the passed-in string.
* Check for UTF-8 validity.
@@ -48,19 +48,19 @@ class Clownfish::String cnick Str
* passed-in string. Check validity of supplied UTF-8.
*/
inert incremented String*
- new_steal_str(char *ptr, size_t size);
+ new_steal_str(const char *ptr, size_t size);
/** Return a pointer to a new String which assumes ownership of the
* passed-in string. Do not check validity of supplied UTF-8.
*/
inert incremented String*
- new_steal_from_trusted_str(char *ptr, size_t size);
+ new_steal_from_trusted_str(const char *ptr, size_t size);
/** Initialize the String using the passed-in string. Do not check
* validity of supplied UTF-8.
*/
public inert String*
- init_steal_trusted_str(decremented String *self, char *ptr, size_t size);
+ init_steal_trusted_str(String *self, const char *ptr, size_t size);
/** Return a String which holds a single character.
*/
[lucy-commits] [13/15] git commit: refs/heads/cfish-string-prep1 - Make sure the
return value of INCREF is used
Posted by nw...@apache.org.
Make sure the return value of INCREF is used
Verified by temporarily adding __attribute__((warn_unused_result)) to
CFISH_Obj_Inc_RefCount.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/6f3f7525
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/6f3f7525
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/6f3f7525
Branch: refs/heads/cfish-string-prep1
Commit: 6f3f7525399d6958d526a5759906be1039c810c7
Parents: 6f48dc3
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 10 19:06:00 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 20:50:22 2013 +0200
----------------------------------------------------------------------
c/src/Lucy/Document/Doc.c | 6 ++----
clownfish/runtime/core/Clownfish/Test/TestObj.c | 2 +-
clownfish/runtime/core/Clownfish/Test/TestVArray.c | 2 +-
.../runtime/core/Clownfish/TestHarness/TestBatchRunner.c | 3 +--
core/Lucy/Index/LexIndex.c | 2 +-
core/Lucy/Index/Snapshot.c | 5 ++---
core/Lucy/Index/SortReader.c | 7 +++----
core/Lucy/Index/ZombieKeyedHash.c | 2 +-
core/Lucy/Search/QueryParser/ParserElem.c | 4 ++--
9 files changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/c/src/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Document/Doc.c b/c/src/Lucy/Document/Doc.c
index e162839..4aa129c 100644
--- a/c/src/Lucy/Document/Doc.c
+++ b/c/src/Lucy/Document/Doc.c
@@ -36,8 +36,7 @@ Doc_init(Doc *self, void *fields, int32_t doc_id) {
Hash *hash;
if (fields) {
- hash = (Hash *)CERTIFY(fields, HASH);
- INCREF(hash);
+ hash = (Hash *)INCREF(CERTIFY(fields, HASH));
}
else {
hash = Hash_new(0);
@@ -64,8 +63,7 @@ Doc_Get_Size_IMP(Doc *self) {
void
Doc_Store_IMP(Doc *self, const String *field, Obj *value) {
Hash *hash = (Hash*)Doc_IVARS(self)->fields;
- Hash_Store(hash, (Obj *)field, value);
- INCREF(value);
+ Hash_Store(hash, (Obj *)field, INCREF(value));
}
void
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/clownfish/runtime/core/Clownfish/Test/TestObj.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestObj.c b/clownfish/runtime/core/Clownfish/Test/TestObj.c
index 191ec33..4466ef0 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestObj.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestObj.c
@@ -54,7 +54,7 @@ test_refcounts(TestBatchRunner *runner) {
TEST_INT_EQ(runner, Obj_Get_RefCount(obj), 1,
"Correct starting refcount");
- Obj_Inc_RefCount(obj);
+ obj = Obj_Inc_RefCount(obj);
TEST_INT_EQ(runner, Obj_Get_RefCount(obj), 2, "Inc_RefCount");
Obj_Dec_RefCount(obj);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/clownfish/runtime/core/Clownfish/Test/TestVArray.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestVArray.c b/clownfish/runtime/core/Clownfish/Test/TestVArray.c
index d22cad0..1abb89e 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestVArray.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestVArray.c
@@ -88,7 +88,7 @@ test_Store_Fetch(TestBatchRunner *runner) {
TEST_INT_EQ(runner, 3, VA_Get_Size(array), "Store updates size");
TEST_TRUE(runner, Str_Equals_Utf8(elem, "foo", 3), "Store");
- INCREF(elem);
+ elem = (String*)INCREF(elem);
TEST_INT_EQ(runner, 2, Str_Get_RefCount(elem),
"start with refcount of 2");
VA_Store(array, 2, (Obj*)Str_newf("bar"));
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c b/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
index 0e81e04..72cebf2 100644
--- a/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
+++ b/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
@@ -80,8 +80,7 @@ TestBatchRunner_Run_Batch_IMP(TestBatchRunner *self, TestBatch *batch) {
if (err) {
failed = true;
String *mess = Err_Get_Mess(err);
- INCREF(mess);
- Err_warn_mess(mess);
+ Err_warn_mess((String*)INCREF(mess));
}
if (self->num_failed > 0) {
failed = true;
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Index/LexIndex.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/LexIndex.c b/core/Lucy/Index/LexIndex.c
index 3ef77b2..f8a2a82 100644
--- a/core/Lucy/Index/LexIndex.c
+++ b/core/Lucy/Index/LexIndex.c
@@ -62,7 +62,7 @@ LexIndex_init(LexIndex *self, Schema *schema, Folder *folder,
DECREF(self);
Err_throw_mess(ERR, mess);
}
- INCREF(ivars->field_type);
+ ivars->field_type = (FieldType*)INCREF(ivars->field_type);
ivars->term_stepper = FType_Make_Term_Stepper(ivars->field_type);
ivars->ixix_in = Folder_Open_In(folder, ixix_file);
if (!ivars->ixix_in) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Index/Snapshot.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Snapshot.c b/core/Lucy/Index/Snapshot.c
index fd9f546..3f32465 100644
--- a/core/Lucy/Index/Snapshot.c
+++ b/core/Lucy/Index/Snapshot.c
@@ -128,10 +128,9 @@ Snapshot_Read_File_IMP(Snapshot *self, Folder *folder, const String *path) {
}
// Build up list of entries.
- VArray *list = (VArray*)CERTIFY(
+ VArray *list = (VArray*)INCREF(CERTIFY(
Hash_Fetch_Utf8(snap_data, "entries", 7),
- VARRAY);
- INCREF(list);
+ VARRAY));
if (format == 1 || (format == 2 && subformat < 1)) {
VArray *cleaned = S_clean_segment_contents(list);
DECREF(list);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Index/SortReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortReader.c b/core/Lucy/Index/SortReader.c
index 28b55f0..efbd994 100644
--- a/core/Lucy/Index/SortReader.c
+++ b/core/Lucy/Index/SortReader.c
@@ -90,16 +90,15 @@ DefSortReader_init(DefaultSortReader *self, Schema *schema, Folder *folder,
HASH));
ivars->null_ords = (Hash*)Hash_Fetch_Utf8(metadata, "null_ords", 9);
if (ivars->null_ords) {
- CERTIFY(ivars->null_ords, HASH);
- INCREF(ivars->null_ords);
+ ivars->null_ords = (Hash*)INCREF(CERTIFY(ivars->null_ords, HASH));
}
else {
ivars->null_ords = Hash_new(0);
}
ivars->ord_widths = (Hash*)Hash_Fetch_Utf8(metadata, "ord_widths", 10);
if (ivars->ord_widths) {
- CERTIFY(ivars->ord_widths, HASH);
- INCREF(ivars->ord_widths);
+ ivars->ord_widths
+ = (Hash*)INCREF(CERTIFY(ivars->ord_widths, HASH));
}
else {
ivars->ord_widths = Hash_new(0);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Index/ZombieKeyedHash.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/ZombieKeyedHash.c b/core/Lucy/Index/ZombieKeyedHash.c
index 2747888..c991e66 100644
--- a/core/Lucy/Index/ZombieKeyedHash.c
+++ b/core/Lucy/Index/ZombieKeyedHash.c
@@ -99,7 +99,7 @@ ZKHash_Make_Key_IMP(ZombieKeyedHash *self, Obj *key, int32_t hash_sum) {
* reaches 4. However, we must never call Destroy() for these objects,
* because they will try to free() their initial allocation, which is
* invalid because it's part of a MemoryPool arena. */
- INCREF(retval);
+ retval = INCREF(retval);
return retval;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Search/QueryParser/ParserElem.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/QueryParser/ParserElem.c b/core/Lucy/Search/QueryParser/ParserElem.c
index febc56f..9a831df 100644
--- a/core/Lucy/Search/QueryParser/ParserElem.c
+++ b/core/Lucy/Search/QueryParser/ParserElem.c
@@ -44,9 +44,9 @@ ParserElem_Destroy_IMP(ParserElem *self) {
void
ParserElem_Set_Value_IMP(ParserElem *self, Obj *value) {
ParserElemIVARS *const ivars = ParserElem_IVARS(self);
- INCREF(value);
+ Obj *new_value = INCREF(value);
DECREF(ivars->value);
- ivars->value = value;
+ ivars->value = new_value;
}
Obj*
[lucy-commits] [04/15] Rename _UTF8 and _Str to _Utf8
Posted by nw...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/SortReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortReader.c b/core/Lucy/Index/SortReader.c
index 7275621..2958422 100644
--- a/core/Lucy/Index/SortReader.c
+++ b/core/Lucy/Index/SortReader.c
@@ -63,12 +63,12 @@ DefSortReader_init(DefaultSortReader *self, Schema *schema, Folder *folder,
seg_tick);
DefaultSortReaderIVARS *const ivars = DefSortReader_IVARS(self);
Segment *segment = DefSortReader_Get_Segment(self);
- Hash *metadata = (Hash*)Seg_Fetch_Metadata_Str(segment, "sort", 4);
+ Hash *metadata = (Hash*)Seg_Fetch_Metadata_Utf8(segment, "sort", 4);
// Check format.
ivars->format = 0;
if (metadata) {
- Obj *format = Hash_Fetch_Str(metadata, "format", 6);
+ Obj *format = Hash_Fetch_Utf8(metadata, "format", 6);
if (!format) { THROW(ERR, "Missing 'format' var"); }
else {
ivars->format = (int32_t)Obj_To_I64(format);
@@ -86,9 +86,9 @@ DefSortReader_init(DefaultSortReader *self, Schema *schema, Folder *folder,
// hashes.
if (metadata) {
ivars->counts
- = (Hash*)INCREF(CERTIFY(Hash_Fetch_Str(metadata, "counts", 6),
+ = (Hash*)INCREF(CERTIFY(Hash_Fetch_Utf8(metadata, "counts", 6),
HASH));
- ivars->null_ords = (Hash*)Hash_Fetch_Str(metadata, "null_ords", 9);
+ ivars->null_ords = (Hash*)Hash_Fetch_Utf8(metadata, "null_ords", 9);
if (ivars->null_ords) {
CERTIFY(ivars->null_ords, HASH);
INCREF(ivars->null_ords);
@@ -96,7 +96,7 @@ DefSortReader_init(DefaultSortReader *self, Schema *schema, Folder *folder,
else {
ivars->null_ords = Hash_new(0);
}
- ivars->ord_widths = (Hash*)Hash_Fetch_Str(metadata, "ord_widths", 10);
+ ivars->ord_widths = (Hash*)Hash_Fetch_Utf8(metadata, "ord_widths", 10);
if (ivars->ord_widths) {
CERTIFY(ivars->ord_widths, HASH);
INCREF(ivars->ord_widths);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/SortWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortWriter.c b/core/Lucy/Index/SortWriter.c
index 3adf9de..fe1641c 100644
--- a/core/Lucy/Index/SortWriter.c
+++ b/core/Lucy/Index/SortWriter.c
@@ -236,8 +236,8 @@ SortWriter_Finish_IMP(SortWriter *self) {
VA_Clear(field_writers);
// Store metadata.
- Seg_Store_Metadata_Str(ivars->segment, "sort", 4,
- (Obj*)SortWriter_Metadata(self));
+ Seg_Store_Metadata_Utf8(ivars->segment, "sort", 4,
+ (Obj*)SortWriter_Metadata(self));
// Clean up.
Folder *folder = ivars->folder;
@@ -260,9 +260,9 @@ SortWriter_Metadata_IMP(SortWriter *self) {
= (SortWriter_Metadata_t)SUPER_METHOD_PTR(SORTWRITER,
LUCY_SortWriter_Metadata);
Hash *const metadata = super_meta(self);
- Hash_Store_Str(metadata, "counts", 6, INCREF(ivars->counts));
- Hash_Store_Str(metadata, "null_ords", 9, INCREF(ivars->null_ords));
- Hash_Store_Str(metadata, "ord_widths", 10, INCREF(ivars->ord_widths));
+ Hash_Store_Utf8(metadata, "counts", 6, INCREF(ivars->counts));
+ Hash_Store_Utf8(metadata, "null_ords", 9, INCREF(ivars->null_ords));
+ Hash_Store_Utf8(metadata, "ord_widths", 10, INCREF(ivars->ord_widths));
return metadata;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Plan/BlobType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/BlobType.c b/core/Lucy/Plan/BlobType.c
index 90ccc4f..5b94640 100644
--- a/core/Lucy/Plan/BlobType.c
+++ b/core/Lucy/Plan/BlobType.c
@@ -64,18 +64,18 @@ Hash*
BlobType_Dump_For_Schema_IMP(BlobType *self) {
BlobTypeIVARS *const ivars = BlobType_IVARS(self);
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "type", 4, (Obj*)Str_newf("blob"));
+ Hash_Store_Utf8(dump, "type", 4, (Obj*)Str_newf("blob"));
// Store attributes that override the defaults -- even if they're
// meaningless.
if (ivars->boost != 1.0) {
- Hash_Store_Str(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
+ Hash_Store_Utf8(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
}
if (ivars->indexed) {
- Hash_Store_Str(dump, "indexed", 7, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(dump, "indexed", 7, (Obj*)CFISH_TRUE);
}
if (ivars->stored) {
- Hash_Store_Str(dump, "stored", 6, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(dump, "stored", 6, (Obj*)CFISH_TRUE);
}
return dump;
@@ -84,24 +84,24 @@ BlobType_Dump_For_Schema_IMP(BlobType *self) {
Hash*
BlobType_Dump_IMP(BlobType *self) {
Hash *dump = BlobType_Dump_For_Schema(self);
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)Str_Clone(BlobType_Get_Class_Name(self)));
- DECREF(Hash_Delete_Str(dump, "type", 4));
+ Hash_Store_Utf8(dump, "_class", 6,
+ (Obj*)Str_Clone(BlobType_Get_Class_Name(self)));
+ DECREF(Hash_Delete_Utf8(dump, "type", 4));
return dump;
}
BlobType*
BlobType_Load_IMP(BlobType *self, Obj *dump) {
Hash *source = (Hash*)CERTIFY(dump, HASH);
- String *class_name = (String*)Hash_Fetch_Str(source, "_class", 6);
+ String *class_name = (String*)Hash_Fetch_Utf8(source, "_class", 6);
VTable *vtable
= (class_name != NULL && Obj_Is_A((Obj*)class_name, STRING))
? VTable_singleton(class_name, NULL)
: BLOBTYPE;
BlobType *loaded = (BlobType*)VTable_Make_Obj(vtable);
- Obj *boost_dump = Hash_Fetch_Str(source, "boost", 5);
- Obj *indexed_dump = Hash_Fetch_Str(source, "indexed", 7);
- Obj *stored_dump = Hash_Fetch_Str(source, "stored", 6);
+ Obj *boost_dump = Hash_Fetch_Utf8(source, "boost", 5);
+ Obj *indexed_dump = Hash_Fetch_Utf8(source, "indexed", 7);
+ Obj *stored_dump = Hash_Fetch_Utf8(source, "stored", 6);
UNUSED_VAR(self);
BlobType_init(loaded, false);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Plan/FullTextType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/FullTextType.c b/core/Lucy/Plan/FullTextType.c
index 03fcb3e..30f2919 100644
--- a/core/Lucy/Plan/FullTextType.c
+++ b/core/Lucy/Plan/FullTextType.c
@@ -81,23 +81,23 @@ Hash*
FullTextType_Dump_For_Schema_IMP(FullTextType *self) {
FullTextTypeIVARS *const ivars = FullTextType_IVARS(self);
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "type", 4, (Obj*)Str_newf("fulltext"));
+ Hash_Store_Utf8(dump, "type", 4, (Obj*)Str_newf("fulltext"));
// Store attributes that override the defaults.
if (ivars->boost != 1.0) {
- Hash_Store_Str(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
+ Hash_Store_Utf8(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
}
if (!ivars->indexed) {
- Hash_Store_Str(dump, "indexed", 7, (Obj*)CFISH_FALSE);
+ Hash_Store_Utf8(dump, "indexed", 7, (Obj*)CFISH_FALSE);
}
if (!ivars->stored) {
- Hash_Store_Str(dump, "stored", 6, (Obj*)CFISH_FALSE);
+ Hash_Store_Utf8(dump, "stored", 6, (Obj*)CFISH_FALSE);
}
if (ivars->sortable) {
- Hash_Store_Str(dump, "sortable", 8, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(dump, "sortable", 8, (Obj*)CFISH_TRUE);
}
if (ivars->highlightable) {
- Hash_Store_Str(dump, "highlightable", 13, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(dump, "highlightable", 13, (Obj*)CFISH_TRUE);
}
return dump;
@@ -107,11 +107,11 @@ Hash*
FullTextType_Dump_IMP(FullTextType *self) {
FullTextTypeIVARS *const ivars = FullTextType_IVARS(self);
Hash *dump = FullTextType_Dump_For_Schema(self);
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)Str_Clone(FullTextType_Get_Class_Name(self)));
- Hash_Store_Str(dump, "analyzer", 8,
- (Obj*)Analyzer_Dump(ivars->analyzer));
- DECREF(Hash_Delete_Str(dump, "type", 4));
+ Hash_Store_Utf8(dump, "_class", 6,
+ (Obj*)Str_Clone(FullTextType_Get_Class_Name(self)));
+ Hash_Store_Utf8(dump, "analyzer", 8,
+ (Obj*)Analyzer_Dump(ivars->analyzer));
+ DECREF(Hash_Delete_Utf8(dump, "type", 4));
return dump;
}
@@ -120,7 +120,7 @@ FullTextType*
FullTextType_Load_IMP(FullTextType *self, Obj *dump) {
UNUSED_VAR(self);
Hash *source = (Hash*)CERTIFY(dump, HASH);
- String *class_name = (String*)Hash_Fetch_Str(source, "_class", 6);
+ String *class_name = (String*)Hash_Fetch_Utf8(source, "_class", 6);
VTable *vtable
= (class_name != NULL && Obj_Is_A((Obj*)class_name, STRING))
? VTable_singleton(class_name, NULL)
@@ -128,21 +128,21 @@ FullTextType_Load_IMP(FullTextType *self, Obj *dump) {
FullTextType *loaded = (FullTextType*)VTable_Make_Obj(vtable);
// Extract boost.
- Obj *boost_dump = Hash_Fetch_Str(source, "boost", 5);
+ Obj *boost_dump = Hash_Fetch_Utf8(source, "boost", 5);
float boost = boost_dump ? (float)Obj_To_F64(boost_dump) : 1.0f;
// Find boolean properties.
- Obj *indexed_dump = Hash_Fetch_Str(source, "indexed", 7);
- Obj *stored_dump = Hash_Fetch_Str(source, "stored", 6);
- Obj *sort_dump = Hash_Fetch_Str(source, "sortable", 8);
- Obj *hl_dump = Hash_Fetch_Str(source, "highlightable", 13);
+ Obj *indexed_dump = Hash_Fetch_Utf8(source, "indexed", 7);
+ Obj *stored_dump = Hash_Fetch_Utf8(source, "stored", 6);
+ Obj *sort_dump = Hash_Fetch_Utf8(source, "sortable", 8);
+ Obj *hl_dump = Hash_Fetch_Utf8(source, "highlightable", 13);
bool indexed = indexed_dump ? Obj_To_Bool(indexed_dump) : true;
bool stored = stored_dump ? Obj_To_Bool(stored_dump) : true;
bool sortable = sort_dump ? Obj_To_Bool(sort_dump) : false;
bool hl = hl_dump ? Obj_To_Bool(hl_dump) : false;
// Extract an Analyzer.
- Obj *analyzer_dump = Hash_Fetch_Str(source, "analyzer", 8);
+ Obj *analyzer_dump = Hash_Fetch_Utf8(source, "analyzer", 8);
Analyzer *analyzer = NULL;
if (analyzer_dump) {
if (Obj_Is_A(analyzer_dump, ANALYZER)) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Plan/NumericType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/NumericType.c b/core/Lucy/Plan/NumericType.c
index 6ccda7d..1d470d9 100644
--- a/core/Lucy/Plan/NumericType.c
+++ b/core/Lucy/Plan/NumericType.c
@@ -46,20 +46,20 @@ Hash*
NumType_Dump_For_Schema_IMP(NumericType *self) {
NumericTypeIVARS *const ivars = NumType_IVARS(self);
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "type", 4, (Obj*)NumType_Specifier(self));
+ Hash_Store_Utf8(dump, "type", 4, (Obj*)NumType_Specifier(self));
// Store attributes that override the defaults.
if (ivars->boost != 1.0) {
- Hash_Store_Str(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
+ Hash_Store_Utf8(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
}
if (!ivars->indexed) {
- Hash_Store_Str(dump, "indexed", 7, (Obj*)CFISH_FALSE);
+ Hash_Store_Utf8(dump, "indexed", 7, (Obj*)CFISH_FALSE);
}
if (!ivars->stored) {
- Hash_Store_Str(dump, "stored", 6, (Obj*)CFISH_FALSE);
+ Hash_Store_Utf8(dump, "stored", 6, (Obj*)CFISH_FALSE);
}
if (ivars->sortable) {
- Hash_Store_Str(dump, "sortable", 8, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(dump, "sortable", 8, (Obj*)CFISH_TRUE);
}
return dump;
@@ -68,9 +68,9 @@ NumType_Dump_For_Schema_IMP(NumericType *self) {
Hash*
NumType_Dump_IMP(NumericType *self) {
Hash *dump = NumType_Dump_For_Schema(self);
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)Str_Clone(NumType_Get_Class_Name(self)));
- DECREF(Hash_Delete_Str(dump, "type", 4));
+ Hash_Store_Utf8(dump, "_class", 6,
+ (Obj*)Str_Clone(NumType_Get_Class_Name(self)));
+ DECREF(Hash_Delete_Utf8(dump, "type", 4));
return dump;
}
@@ -80,23 +80,23 @@ NumType_Load_IMP(NumericType *self, Obj *dump) {
Hash *source = (Hash*)CERTIFY(dump, HASH);
// Get a VTable
- String *class_name = (String*)Hash_Fetch_Str(source, "_class", 6);
- String *type_spec = (String*)Hash_Fetch_Str(source, "type", 4);
+ String *class_name = (String*)Hash_Fetch_Utf8(source, "_class", 6);
+ String *type_spec = (String*)Hash_Fetch_Utf8(source, "type", 4);
VTable *vtable = NULL;
if (class_name != NULL && Obj_Is_A((Obj*)class_name, STRING)) {
vtable = VTable_singleton(class_name, NULL);
}
else if (type_spec != NULL && Obj_Is_A((Obj*)type_spec, STRING)) {
- if (Str_Equals_Str(type_spec, "i32_t", 5)) {
+ if (Str_Equals_Utf8(type_spec, "i32_t", 5)) {
vtable = INT32TYPE;
}
- else if (Str_Equals_Str(type_spec, "i64_t", 5)) {
+ else if (Str_Equals_Utf8(type_spec, "i64_t", 5)) {
vtable = INT64TYPE;
}
- else if (Str_Equals_Str(type_spec, "f32_t", 5)) {
+ else if (Str_Equals_Utf8(type_spec, "f32_t", 5)) {
vtable = FLOAT32TYPE;
}
- else if (Str_Equals_Str(type_spec, "f64_t", 5)) {
+ else if (Str_Equals_Utf8(type_spec, "f64_t", 5)) {
vtable = FLOAT64TYPE;
}
else {
@@ -107,13 +107,13 @@ NumType_Load_IMP(NumericType *self, Obj *dump) {
NumericType *loaded = (NumericType*)VTable_Make_Obj(vtable);
// Extract boost.
- Obj *boost_dump = Hash_Fetch_Str(source, "boost", 5);
+ Obj *boost_dump = Hash_Fetch_Utf8(source, "boost", 5);
float boost = boost_dump ? (float)Obj_To_F64(boost_dump) : 1.0f;
// Find boolean properties.
- Obj *indexed_dump = Hash_Fetch_Str(source, "indexed", 7);
- Obj *stored_dump = Hash_Fetch_Str(source, "stored", 6);
- Obj *sort_dump = Hash_Fetch_Str(source, "sortable", 8);
+ Obj *indexed_dump = Hash_Fetch_Utf8(source, "indexed", 7);
+ Obj *stored_dump = Hash_Fetch_Utf8(source, "stored", 6);
+ Obj *sort_dump = Hash_Fetch_Utf8(source, "sortable", 8);
bool indexed = indexed_dump ? Obj_To_Bool(indexed_dump) : true;
bool stored = stored_dump ? Obj_To_Bool(stored_dump) : true;
bool sortable = sort_dump ? Obj_To_Bool(sort_dump) : false;
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Plan/Schema.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/Schema.c b/core/Lucy/Plan/Schema.c
index 8ce77d0..098a698 100644
--- a/core/Lucy/Plan/Schema.c
+++ b/core/Lucy/Plan/Schema.c
@@ -256,13 +256,13 @@ Schema_Dump_IMP(Schema *self) {
FieldType *type;
// Record class name, store dumps of unique Analyzers.
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)Str_Clone(Schema_Get_Class_Name(self)));
- Hash_Store_Str(dump, "analyzers", 9,
- Freezer_dump((Obj*)ivars->uniq_analyzers));
+ Hash_Store_Utf8(dump, "_class", 6,
+ (Obj*)Str_Clone(Schema_Get_Class_Name(self)));
+ Hash_Store_Utf8(dump, "analyzers", 9,
+ Freezer_dump((Obj*)ivars->uniq_analyzers));
// Dump FieldTypes.
- Hash_Store_Str(dump, "fields", 6, (Obj*)type_dumps);
+ Hash_Store_Utf8(dump, "fields", 6, (Obj*)type_dumps);
Hash_Iterate(ivars->types);
while (Hash_Next(ivars->types, (Obj**)&field, (Obj**)&type)) {
VTable *type_vtable = FType_Get_VTable(type);
@@ -276,8 +276,8 @@ Schema_Dump_IMP(Schema *self) {
= S_find_in_array(ivars->uniq_analyzers, (Obj*)analyzer);
// Store the tick which references a unique analyzer.
- Hash_Store_Str(type_dump, "analyzer", 8,
- (Obj*)Str_newf("%u32", tick));
+ Hash_Store_Utf8(type_dump, "analyzer", 8,
+ (Obj*)Str_newf("%u32", tick));
Hash_Store(type_dumps, (Obj*)field, (Obj*)type_dump);
}
@@ -306,13 +306,13 @@ Schema*
Schema_Load_IMP(Schema *self, Obj *dump) {
Hash *source = (Hash*)CERTIFY(dump, HASH);
String *class_name
- = (String*)CERTIFY(Hash_Fetch_Str(source, "_class", 6), STRING);
+ = (String*)CERTIFY(Hash_Fetch_Utf8(source, "_class", 6), STRING);
VTable *vtable = VTable_singleton(class_name, NULL);
Schema *loaded = (Schema*)VTable_Make_Obj(vtable);
Hash *type_dumps
- = (Hash*)CERTIFY(Hash_Fetch_Str(source, "fields", 6), HASH);
+ = (Hash*)CERTIFY(Hash_Fetch_Utf8(source, "fields", 6), HASH);
VArray *analyzer_dumps
- = (VArray*)CERTIFY(Hash_Fetch_Str(source, "analyzers", 9), VARRAY);
+ = (VArray*)CERTIFY(Hash_Fetch_Utf8(source, "analyzers", 9), VARRAY);
VArray *analyzers
= (VArray*)Freezer_load((Obj*)analyzer_dumps);
String *field;
@@ -328,56 +328,56 @@ Schema_Load_IMP(Schema *self, Obj *dump) {
while (Hash_Next(type_dumps, (Obj**)&field, (Obj**)&type_dump)) {
String *type_str;
CERTIFY(type_dump, HASH);
- type_str = (String*)Hash_Fetch_Str(type_dump, "type", 4);
+ type_str = (String*)Hash_Fetch_Utf8(type_dump, "type", 4);
if (type_str) {
- if (Str_Equals_Str(type_str, "fulltext", 8)) {
+ if (Str_Equals_Utf8(type_str, "fulltext", 8)) {
// Replace the "analyzer" tick with the real thing.
Obj *tick
- = CERTIFY(Hash_Fetch_Str(type_dump, "analyzer", 8), OBJ);
+ = CERTIFY(Hash_Fetch_Utf8(type_dump, "analyzer", 8), OBJ);
Analyzer *analyzer
= (Analyzer*)VA_Fetch(analyzers,
(uint32_t)Obj_To_I64(tick));
if (!analyzer) {
THROW(ERR, "Can't find analyzer for '%o'", field);
}
- Hash_Store_Str(type_dump, "analyzer", 8, INCREF(analyzer));
+ Hash_Store_Utf8(type_dump, "analyzer", 8, INCREF(analyzer));
FullTextType *type
= (FullTextType*)S_load_type(FULLTEXTTYPE,
(Obj*)type_dump);
Schema_Spec_Field(loaded, field, (FieldType*)type);
DECREF(type);
}
- else if (Str_Equals_Str(type_str, "string", 6)) {
+ else if (Str_Equals_Utf8(type_str, "string", 6)) {
StringType *type
= (StringType*)S_load_type(STRINGTYPE, (Obj*)type_dump);
Schema_Spec_Field(loaded, field, (FieldType*)type);
DECREF(type);
}
- else if (Str_Equals_Str(type_str, "blob", 4)) {
+ else if (Str_Equals_Utf8(type_str, "blob", 4)) {
BlobType *type
= (BlobType*)S_load_type(BLOBTYPE, (Obj*)type_dump);
Schema_Spec_Field(loaded, field, (FieldType*)type);
DECREF(type);
}
- else if (Str_Equals_Str(type_str, "i32_t", 5)) {
+ else if (Str_Equals_Utf8(type_str, "i32_t", 5)) {
Int32Type *type
= (Int32Type*)S_load_type(INT32TYPE, (Obj*)type_dump);
Schema_Spec_Field(loaded, field, (FieldType*)type);
DECREF(type);
}
- else if (Str_Equals_Str(type_str, "i64_t", 5)) {
+ else if (Str_Equals_Utf8(type_str, "i64_t", 5)) {
Int64Type *type
= (Int64Type*)S_load_type(INT64TYPE, (Obj*)type_dump);
Schema_Spec_Field(loaded, field, (FieldType*)type);
DECREF(type);
}
- else if (Str_Equals_Str(type_str, "f32_t", 5)) {
+ else if (Str_Equals_Utf8(type_str, "f32_t", 5)) {
Float32Type *type
= (Float32Type*)S_load_type(FLOAT32TYPE, (Obj*)type_dump);
Schema_Spec_Field(loaded, field, (FieldType*)type);
DECREF(type);
}
- else if (Str_Equals_Str(type_str, "f64_t", 5)) {
+ else if (Str_Equals_Utf8(type_str, "f64_t", 5)) {
Float64Type *type
= (Float64Type*)S_load_type(FLOAT64TYPE, (Obj*)type_dump);
Schema_Spec_Field(loaded, field, (FieldType*)type);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Plan/StringType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/StringType.c b/core/Lucy/Plan/StringType.c
index e87045e..087d743 100644
--- a/core/Lucy/Plan/StringType.c
+++ b/core/Lucy/Plan/StringType.c
@@ -58,20 +58,20 @@ Hash*
StringType_Dump_For_Schema_IMP(StringType *self) {
StringTypeIVARS *const ivars = StringType_IVARS(self);
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "type", 4, (Obj*)Str_newf("string"));
+ Hash_Store_Utf8(dump, "type", 4, (Obj*)Str_newf("string"));
// Store attributes that override the defaults.
if (ivars->boost != 1.0) {
- Hash_Store_Str(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
+ Hash_Store_Utf8(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
}
if (!ivars->indexed) {
- Hash_Store_Str(dump, "indexed", 7, (Obj*)CFISH_FALSE);
+ Hash_Store_Utf8(dump, "indexed", 7, (Obj*)CFISH_FALSE);
}
if (!ivars->stored) {
- Hash_Store_Str(dump, "stored", 6, (Obj*)CFISH_FALSE);
+ Hash_Store_Utf8(dump, "stored", 6, (Obj*)CFISH_FALSE);
}
if (ivars->sortable) {
- Hash_Store_Str(dump, "sortable", 8, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(dump, "sortable", 8, (Obj*)CFISH_TRUE);
}
return dump;
@@ -80,25 +80,25 @@ StringType_Dump_For_Schema_IMP(StringType *self) {
Hash*
StringType_Dump_IMP(StringType *self) {
Hash *dump = StringType_Dump_For_Schema(self);
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)Str_Clone(StringType_Get_Class_Name(self)));
- DECREF(Hash_Delete_Str(dump, "type", 4));
+ Hash_Store_Utf8(dump, "_class", 6,
+ (Obj*)Str_Clone(StringType_Get_Class_Name(self)));
+ DECREF(Hash_Delete_Utf8(dump, "type", 4));
return dump;
}
StringType*
StringType_Load_IMP(StringType *self, Obj *dump) {
Hash *source = (Hash*)CERTIFY(dump, HASH);
- String *class_name = (String*)Hash_Fetch_Str(source, "_class", 6);
+ String *class_name = (String*)Hash_Fetch_Utf8(source, "_class", 6);
VTable *vtable
= (class_name != NULL && Obj_Is_A((Obj*)class_name, STRING))
? VTable_singleton(class_name, NULL)
: STRINGTYPE;
StringType *loaded = (StringType*)VTable_Make_Obj(vtable);
- Obj *boost_dump = Hash_Fetch_Str(source, "boost", 5);
- Obj *indexed_dump = Hash_Fetch_Str(source, "indexed", 7);
- Obj *stored_dump = Hash_Fetch_Str(source, "stored", 6);
- Obj *sortable_dump = Hash_Fetch_Str(source, "sortable", 8);
+ Obj *boost_dump = Hash_Fetch_Utf8(source, "boost", 5);
+ Obj *indexed_dump = Hash_Fetch_Utf8(source, "indexed", 7);
+ Obj *stored_dump = Hash_Fetch_Utf8(source, "stored", 6);
+ Obj *sortable_dump = Hash_Fetch_Utf8(source, "sortable", 8);
UNUSED_VAR(self);
float boost = boost_dump ? (float)Obj_To_F64(boost_dump) : 1.0f;
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/ANDQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/ANDQuery.c b/core/Lucy/Search/ANDQuery.c
index 0ef378e..88bfe5a 100644
--- a/core/Lucy/Search/ANDQuery.c
+++ b/core/Lucy/Search/ANDQuery.c
@@ -55,10 +55,10 @@ ANDQuery_To_String_IMP(ANDQuery *self) {
CB_Cat(buf, kid_string);
DECREF(kid_string);
if (i == num_kids - 1) {
- CB_Cat_Trusted_UTF8(buf, ")", 1);
+ CB_Cat_Trusted_Utf8(buf, ")", 1);
}
else {
- CB_Cat_Trusted_UTF8(buf, " AND ", 5);
+ CB_Cat_Trusted_Utf8(buf, " AND ", 5);
}
}
String *retval = CB_Yield_String(buf);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/Compiler.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/Compiler.c b/core/Lucy/Search/Compiler.c
index 4ffa29d..1ed904e 100644
--- a/core/Lucy/Search/Compiler.c
+++ b/core/Lucy/Search/Compiler.c
@@ -111,7 +111,7 @@ Compiler_To_String_IMP(Compiler *self) {
String *stringified_query = Query_To_String(ivars->parent);
CharBuf *buf = CB_new_from_trusted_utf8("compiler(", 9);
CB_Cat(buf, stringified_query);
- CB_Cat_Trusted_UTF8(buf, ")", 1);
+ CB_Cat_Trusted_Utf8(buf, ")", 1);
String *string = CB_Yield_String(buf);
DECREF(buf);
DECREF(stringified_query);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/LeafQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/LeafQuery.c b/core/Lucy/Search/LeafQuery.c
index 9ff388c..52c2718 100644
--- a/core/Lucy/Search/LeafQuery.c
+++ b/core/Lucy/Search/LeafQuery.c
@@ -118,9 +118,9 @@ LeafQuery_Dump_IMP(LeafQuery *self) {
= SUPER_METHOD_PTR(LEAFQUERY, LUCY_LeafQuery_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
if (ivars->field) {
- Hash_Store_Str(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
+ Hash_Store_Utf8(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
}
- Hash_Store_Str(dump, "text", 4, Freezer_dump((Obj*)ivars->text));
+ Hash_Store_Utf8(dump, "text", 4, Freezer_dump((Obj*)ivars->text));
return (Obj*)dump;
}
@@ -131,12 +131,12 @@ LeafQuery_Load_IMP(LeafQuery *self, Obj *dump) {
= SUPER_METHOD_PTR(LEAFQUERY, LUCY_LeafQuery_Load);
LeafQuery *loaded = (LeafQuery*)super_load(self, dump);
LeafQueryIVARS *loaded_ivars = LeafQuery_IVARS(loaded);
- Obj *field = Hash_Fetch_Str(source, "field", 5);
+ Obj *field = Hash_Fetch_Utf8(source, "field", 5);
if (field) {
loaded_ivars->field
= (String*)CERTIFY(Freezer_load(field), STRING);
}
- Obj *text = CERTIFY(Hash_Fetch_Str(source, "text", 4), OBJ);
+ Obj *text = CERTIFY(Hash_Fetch_Utf8(source, "text", 4), OBJ);
loaded_ivars->text = (String*)CERTIFY(Freezer_load(text), STRING);
return (Obj*)loaded;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/NoMatchQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/NoMatchQuery.c b/core/Lucy/Search/NoMatchQuery.c
index b46d460..bd9a045 100644
--- a/core/Lucy/Search/NoMatchQuery.c
+++ b/core/Lucy/Search/NoMatchQuery.c
@@ -83,8 +83,8 @@ NoMatchQuery_Dump_IMP(NoMatchQuery *self) {
NoMatchQuery_Dump_t super_dump
= SUPER_METHOD_PTR(NOMATCHQUERY, LUCY_NoMatchQuery_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
- Hash_Store_Str(dump, "fails_to_match", 14,
- (Obj*)Bool_singleton(ivars->fails_to_match));
+ Hash_Store_Utf8(dump, "fails_to_match", 14,
+ (Obj*)Bool_singleton(ivars->fails_to_match));
return (Obj*)dump;
}
@@ -94,7 +94,7 @@ NoMatchQuery_Load_IMP(NoMatchQuery *self, Obj *dump) {
NoMatchQuery_Load_t super_load
= SUPER_METHOD_PTR(NOMATCHQUERY, LUCY_NoMatchQuery_Load);
NoMatchQuery *loaded = super_load(self, dump);
- Obj *fails = CFISH_Hash_Fetch_Str(source, "fails_to_match", 14);
+ Obj *fails = CFISH_Hash_Fetch_Utf8(source, "fails_to_match", 14);
NoMatchQuery_IVARS(loaded)->fails_to_match
= fails ? Obj_To_Bool(fails) : true;
return loaded;
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/ORQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/ORQuery.c b/core/Lucy/Search/ORQuery.c
index 3ee0cfd..5167d0c 100644
--- a/core/Lucy/Search/ORQuery.c
+++ b/core/Lucy/Search/ORQuery.c
@@ -71,10 +71,10 @@ ORQuery_To_String_IMP(ORQuery *self) {
CB_Cat(buf, kid_string);
DECREF(kid_string);
if (i == last_kid) {
- CB_Cat_Trusted_UTF8(buf, ")", 1);
+ CB_Cat_Trusted_Utf8(buf, ")", 1);
}
else {
- CB_Cat_Trusted_UTF8(buf, " OR ", 4);
+ CB_Cat_Trusted_Utf8(buf, " OR ", 4);
}
}
String *retval = CB_Yield_String(buf);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/PhraseQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/PhraseQuery.c b/core/Lucy/Search/PhraseQuery.c
index 4f02f61..7576401 100644
--- a/core/Lucy/Search/PhraseQuery.c
+++ b/core/Lucy/Search/PhraseQuery.c
@@ -98,8 +98,8 @@ PhraseQuery_Dump_IMP(PhraseQuery *self) {
PhraseQuery_Dump_t super_dump
= SUPER_METHOD_PTR(PHRASEQUERY, LUCY_PhraseQuery_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
- Hash_Store_Str(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
- Hash_Store_Str(dump, "terms", 5, Freezer_dump((Obj*)ivars->terms));
+ Hash_Store_Utf8(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
+ Hash_Store_Utf8(dump, "terms", 5, Freezer_dump((Obj*)ivars->terms));
return (Obj*)dump;
}
@@ -110,10 +110,10 @@ PhraseQuery_Load_IMP(PhraseQuery *self, Obj *dump) {
= SUPER_METHOD_PTR(PHRASEQUERY, LUCY_PhraseQuery_Load);
PhraseQuery *loaded = (PhraseQuery*)super_load(self, dump);
PhraseQueryIVARS *loaded_ivars = PhraseQuery_IVARS(loaded);
- Obj *field = CERTIFY(Hash_Fetch_Str(source, "field", 5), OBJ);
+ Obj *field = CERTIFY(Hash_Fetch_Utf8(source, "field", 5), OBJ);
loaded_ivars->field
= (String*)CERTIFY(Freezer_load(field), STRING);
- Obj *terms = CERTIFY(Hash_Fetch_Str(source, "terms", 5), OBJ);
+ Obj *terms = CERTIFY(Hash_Fetch_Utf8(source, "terms", 5), OBJ);
loaded_ivars->terms
= (VArray*)CERTIFY(Freezer_load(terms), VARRAY);
return (Obj*)loaded;
@@ -140,17 +140,17 @@ PhraseQuery_To_String_IMP(PhraseQuery *self) {
PhraseQueryIVARS *const ivars = PhraseQuery_IVARS(self);
uint32_t num_terms = VA_Get_Size(ivars->terms);
CharBuf *buf = CB_new_from_str(ivars->field);
- CB_Cat_Trusted_UTF8(buf, ":\"", 2);
+ CB_Cat_Trusted_Utf8(buf, ":\"", 2);
for (uint32_t i = 0; i < num_terms; i++) {
Obj *term = VA_Fetch(ivars->terms, i);
String *term_string = Obj_To_String(term);
CB_Cat(buf, term_string);
DECREF(term_string);
if (i < num_terms - 1) {
- CB_Cat_Trusted_UTF8(buf, " ", 1);
+ CB_Cat_Trusted_Utf8(buf, " ", 1);
}
}
- CB_Cat_Trusted_UTF8(buf, "\"", 1);
+ CB_Cat_Trusted_Utf8(buf, "\"", 1);
String *retval = CB_Yield_String(buf);
DECREF(buf);
return retval;
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/PolyQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/PolyQuery.c b/core/Lucy/Search/PolyQuery.c
index 5a36db0..8e85af9 100644
--- a/core/Lucy/Search/PolyQuery.c
+++ b/core/Lucy/Search/PolyQuery.c
@@ -98,7 +98,7 @@ PolyQuery_Dump_IMP(PolyQuery *self) {
PolyQuery_Dump_t super_dump
= SUPER_METHOD_PTR(POLYQUERY, LUCY_PolyQuery_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
- Hash_Store_Str(dump, "children", 8, Freezer_dump((Obj*)ivars->children));
+ Hash_Store_Utf8(dump, "children", 8, Freezer_dump((Obj*)ivars->children));
return (Obj*)dump;
}
@@ -108,7 +108,7 @@ PolyQuery_Load_IMP(PolyQuery *self, Obj *dump) {
PolyQuery_Load_t super_load
= SUPER_METHOD_PTR(POLYQUERY, LUCY_PolyQuery_Load);
PolyQuery *loaded = (PolyQuery*)super_load(self, dump);
- Obj *children = CERTIFY(Hash_Fetch_Str(source, "children", 8), OBJ);
+ Obj *children = CERTIFY(Hash_Fetch_Utf8(source, "children", 8), OBJ);
PolyQuery_IVARS(loaded)->children
= (VArray*)CERTIFY(Freezer_load(children), VARRAY);
return (Obj*)loaded;
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/Query.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/Query.c b/core/Lucy/Search/Query.c
index d3215fb..78ebea2 100644
--- a/core/Lucy/Search/Query.c
+++ b/core/Lucy/Search/Query.c
@@ -55,10 +55,10 @@ Obj*
Query_Dump_IMP(Query *self) {
QueryIVARS *ivars = Query_IVARS(self);
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)Str_Clone(Obj_Get_Class_Name((Obj*)self)));
- Hash_Store_Str(dump, "boost", 5,
- (Obj*)Str_newf("%f64", (double)ivars->boost));
+ Hash_Store_Utf8(dump, "_class", 6,
+ (Obj*)Str_Clone(Obj_Get_Class_Name((Obj*)self)));
+ Hash_Store_Utf8(dump, "boost", 5,
+ (Obj*)Str_newf("%f64", (double)ivars->boost));
return (Obj*)dump;
}
@@ -67,10 +67,10 @@ Query_Load_IMP(Query *self, Obj *dump) {
CHY_UNUSED_VAR(self);
Hash *source = (Hash*)CERTIFY(dump, HASH);
String *class_name
- = (String*)CERTIFY(Hash_Fetch_Str(source, "_class", 6), STRING);
+ = (String*)CERTIFY(Hash_Fetch_Utf8(source, "_class", 6), STRING);
VTable *vtable = VTable_singleton(class_name, NULL);
Query *loaded = (Query*)VTable_Make_Obj(vtable);
- Obj *boost = CERTIFY(Hash_Fetch_Str(source, "boost", 5), OBJ);
+ Obj *boost = CERTIFY(Hash_Fetch_Utf8(source, "boost", 5), OBJ);
Query_IVARS(loaded)->boost = (float)Obj_To_F64(boost);
return (Obj*)loaded;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/QueryParser.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/QueryParser.c b/core/Lucy/Search/QueryParser.c
index 21100d4..037d6b1 100644
--- a/core/Lucy/Search/QueryParser.c
+++ b/core/Lucy/Search/QueryParser.c
@@ -141,10 +141,10 @@ QParser_init(QueryParser *self, Schema *schema, Analyzer *analyzer,
VA_Sort(ivars->fields, NULL, NULL);
// Derive default "occur" from default boolean operator.
- if (Str_Equals_Str(ivars->default_boolop, "OR", 2)) {
+ if (Str_Equals_Utf8(ivars->default_boolop, "OR", 2)) {
ivars->default_occur = SHOULD;
}
- else if (Str_Equals_Str(ivars->default_boolop, "AND", 3)) {
+ else if (Str_Equals_Utf8(ivars->default_boolop, "AND", 3)) {
ivars->default_occur = MUST;
}
else {
@@ -876,11 +876,11 @@ QParser_Expand_Leaf_IMP(QueryParser *self, Query *query) {
StringIterator *tail = Str_Tail(full_text);
StrIter_Skip_Next_Whitespace(top);
StrIter_Skip_Prev_Whitespace(tail);
- if (StrIter_Starts_With_UTF8(top, "\"", 1)) {
+ if (StrIter_Starts_With_Utf8(top, "\"", 1)) {
is_phrase = true;
StrIter_Advance(top, 1);
- if (StrIter_Ends_With_UTF8(tail, "\"", 1)
- && !StrIter_Ends_With_UTF8(tail, "\\\"", 2)
+ if (StrIter_Ends_With_Utf8(tail, "\"", 1)
+ && !StrIter_Ends_With_Utf8(tail, "\\\"", 2)
) {
StrIter_Recede(tail, 1);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/QueryParser/QueryLexer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/QueryParser/QueryLexer.c b/core/Lucy/Search/QueryParser/QueryLexer.c
index af07f5f..de9e66f 100644
--- a/core/Lucy/Search/QueryParser/QueryLexer.c
+++ b/core/Lucy/Search/QueryParser/QueryLexer.c
@@ -163,7 +163,7 @@ QueryLexer_Tokenize_IMP(QueryLexer *self, const String *query_string) {
static ParserElem*
S_consume_keyword(StringIterator *iter, const char *keyword,
size_t keyword_len, int type) {
- if (!StrIter_Starts_With_UTF8(iter, keyword, keyword_len)) {
+ if (!StrIter_Starts_With_Utf8(iter, keyword, keyword_len)) {
return NULL;
}
StringIterator *temp = StrIter_Clone(iter);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/RangeQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/RangeQuery.c b/core/Lucy/Search/RangeQuery.c
index a208213..d4c7174 100644
--- a/core/Lucy/Search/RangeQuery.c
+++ b/core/Lucy/Search/RangeQuery.c
@@ -166,19 +166,19 @@ RangeQuery_Dump_IMP(RangeQuery *self) {
RangeQuery_Dump_t super_dump
= SUPER_METHOD_PTR(RANGEQUERY, LUCY_RangeQuery_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
- Hash_Store_Str(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
+ Hash_Store_Utf8(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
if (ivars->lower_term) {
- Hash_Store_Str(dump, "lower_term", 10,
- Freezer_dump((Obj*)ivars->lower_term));
+ Hash_Store_Utf8(dump, "lower_term", 10,
+ Freezer_dump((Obj*)ivars->lower_term));
}
if (ivars->upper_term) {
- Hash_Store_Str(dump, "upper_term", 10,
- Freezer_dump((Obj*)ivars->upper_term));
+ Hash_Store_Utf8(dump, "upper_term", 10,
+ Freezer_dump((Obj*)ivars->upper_term));
}
- Hash_Store_Str(dump, "include_lower", 13,
- (Obj*)Bool_singleton(ivars->include_lower));
- Hash_Store_Str(dump, "include_upper", 13,
- (Obj*)Bool_singleton(ivars->include_upper));
+ Hash_Store_Utf8(dump, "include_lower", 13,
+ (Obj*)Bool_singleton(ivars->include_lower));
+ Hash_Store_Utf8(dump, "include_upper", 13,
+ (Obj*)Bool_singleton(ivars->include_upper));
return (Obj*)dump;
}
@@ -189,23 +189,23 @@ RangeQuery_Load_IMP(RangeQuery *self, Obj *dump) {
= SUPER_METHOD_PTR(RANGEQUERY, LUCY_RangeQuery_Load);
RangeQuery *loaded = (RangeQuery*)super_load(self, dump);
RangeQueryIVARS *loaded_ivars = RangeQuery_IVARS(loaded);
- Obj *field = CERTIFY(Hash_Fetch_Str(source, "field", 5), OBJ);
+ Obj *field = CERTIFY(Hash_Fetch_Utf8(source, "field", 5), OBJ);
loaded_ivars->field = (String*)CERTIFY(Freezer_load(field), STRING);
- Obj *lower_term = Hash_Fetch_Str(source, "lower_term", 10);
+ Obj *lower_term = Hash_Fetch_Utf8(source, "lower_term", 10);
if (lower_term) {
loaded_ivars->lower_term
= (Obj*)CERTIFY(Freezer_load(lower_term), OBJ);
}
- Obj *upper_term = Hash_Fetch_Str(source, "upper_term", 10);
+ Obj *upper_term = Hash_Fetch_Utf8(source, "upper_term", 10);
if (upper_term) {
loaded_ivars->upper_term
= (Obj*)CERTIFY(Freezer_load(upper_term), OBJ);
}
Obj *include_lower
- = CERTIFY(Hash_Fetch_Str(source, "include_lower", 13), OBJ);
+ = CERTIFY(Hash_Fetch_Utf8(source, "include_lower", 13), OBJ);
loaded_ivars->include_lower = Obj_To_Bool(include_lower);
Obj *include_upper
- = CERTIFY(Hash_Fetch_Str(source, "include_upper", 13), OBJ);
+ = CERTIFY(Hash_Fetch_Utf8(source, "include_upper", 13), OBJ);
loaded_ivars->include_upper = Obj_To_Bool(include_upper);
return (Obj*)loaded;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Search/TermQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/TermQuery.c b/core/Lucy/Search/TermQuery.c
index 3644834..eeae547 100644
--- a/core/Lucy/Search/TermQuery.c
+++ b/core/Lucy/Search/TermQuery.c
@@ -80,8 +80,8 @@ TermQuery_Dump_IMP(TermQuery *self) {
TermQuery_Dump_t super_dump
= SUPER_METHOD_PTR(TERMQUERY, LUCY_TermQuery_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
- Hash_Store_Str(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
- Hash_Store_Str(dump, "term", 4, Freezer_dump(ivars->term));
+ Hash_Store_Utf8(dump, "field", 5, Freezer_dump((Obj*)ivars->field));
+ Hash_Store_Utf8(dump, "term", 4, Freezer_dump(ivars->term));
return (Obj*)dump;
}
@@ -92,9 +92,9 @@ TermQuery_Load_IMP(TermQuery *self, Obj *dump) {
= SUPER_METHOD_PTR(TERMQUERY, LUCY_TermQuery_Load);
TermQuery *loaded = (TermQuery*)super_load(self, dump);
TermQueryIVARS *loaded_ivars = TermQuery_IVARS(loaded);
- Obj *field = CERTIFY(Hash_Fetch_Str(source, "field", 5), OBJ);
+ Obj *field = CERTIFY(Hash_Fetch_Utf8(source, "field", 5), OBJ);
loaded_ivars->field = (String*)CERTIFY(Freezer_load(field), STRING);
- Obj *term = CERTIFY(Hash_Fetch_Str(source, "term", 4), OBJ);
+ Obj *term = CERTIFY(Hash_Fetch_Utf8(source, "term", 4), OBJ);
loaded_ivars->term = (Obj*)CERTIFY(Freezer_load(term), OBJ);
return (Obj*)loaded;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Store/CompoundFileReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/CompoundFileReader.c b/core/Lucy/Store/CompoundFileReader.c
index 2ecf45c..8ee59c7 100644
--- a/core/Lucy/Store/CompoundFileReader.c
+++ b/core/Lucy/Store/CompoundFileReader.c
@@ -48,9 +48,9 @@ CFReader_do_open(CompoundFileReader *self, Folder *folder) {
Folder_Get_Path(folder)));
}
else {
- Obj *format = Hash_Fetch_Str(metadata, "format", 6);
+ Obj *format = Hash_Fetch_Utf8(metadata, "format", 6);
ivars->format = format ? (int32_t)Obj_To_I64(format) : 0;
- ivars->records = (Hash*)INCREF(Hash_Fetch_Str(metadata, "files", 5));
+ ivars->records = (Hash*)INCREF(Hash_Fetch_Utf8(metadata, "files", 5));
if (ivars->format < 1) {
error = Err_new(Str_newf("Corrupt %o file: Missing or invalid 'format'",
cfmeta_file));
@@ -194,8 +194,8 @@ CFReader_Local_Open_In_IMP(CompoundFileReader *self, const String *name) {
return instream;
}
else {
- Obj *len = Hash_Fetch_Str(entry, "length", 6);
- Obj *offset = Hash_Fetch_Str(entry, "offset", 6);
+ Obj *len = Hash_Fetch_Utf8(entry, "length", 6);
+ Obj *offset = Hash_Fetch_Utf8(entry, "offset", 6);
if (!len || !offset) {
Err_set_error(Err_new(Str_newf("Malformed entry for '%o' in '%o'",
name, Folder_Get_Path(ivars->real_folder))));
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Store/CompoundFileWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/CompoundFileWriter.c b/core/Lucy/Store/CompoundFileWriter.c
index 0cb9891..82e4178 100644
--- a/core/Lucy/Store/CompoundFileWriter.c
+++ b/core/Lucy/Store/CompoundFileWriter.c
@@ -105,15 +105,15 @@ S_do_consolidate(CompoundFileWriter *self, CompoundFileWriterIVARS *ivars) {
if (!outstream) { RETHROW(INCREF(Err_get_error())); }
// Start metadata.
- Hash_Store_Str(metadata, "files", 5, INCREF(sub_files));
- Hash_Store_Str(metadata, "format", 6,
- (Obj*)Str_newf("%i32", CFWriter_current_file_format));
+ Hash_Store_Utf8(metadata, "files", 5, INCREF(sub_files));
+ Hash_Store_Utf8(metadata, "format", 6,
+ (Obj*)Str_newf("%i32", CFWriter_current_file_format));
VA_Sort(files, NULL, NULL);
for (uint32_t i = 0, max = VA_Get_Size(files); i < max; i++) {
String *infilename = (String*)VA_Fetch(files, i);
- if (!Str_Ends_With_Str(infilename, ".json", 5)) {
+ if (!Str_Ends_With_Utf8(infilename, ".json", 5)) {
InStream *instream = Folder_Open_In(folder, infilename);
Hash *file_data = Hash_new(2);
int64_t offset, len;
@@ -126,10 +126,10 @@ S_do_consolidate(CompoundFileWriter *self, CompoundFileWriterIVARS *ivars) {
len = OutStream_Tell(outstream) - offset;
// Record offset and length.
- Hash_Store_Str(file_data, "offset", 6,
- (Obj*)Str_newf("%i64", offset));
- Hash_Store_Str(file_data, "length", 6,
- (Obj*)Str_newf("%i64", len));
+ Hash_Store_Utf8(file_data, "offset", 6,
+ (Obj*)Str_newf("%i64", offset));
+ Hash_Store_Utf8(file_data, "length", 6,
+ (Obj*)Str_newf("%i64", len));
Hash_Store(sub_files, (Obj*)infilename, (Obj*)file_data);
VA_Push(merged, INCREF(infilename));
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Store/FSFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFolder.c b/core/Lucy/Store/FSFolder.c
index cdb353c..70522f3 100644
--- a/core/Lucy/Store/FSFolder.c
+++ b/core/Lucy/Store/FSFolder.c
@@ -229,7 +229,7 @@ FSFolder_Local_Find_Folder_IMP(FSFolder *self, const String *name) {
else if (!S_is_local_entry(name)) {
return NULL;
}
- else if (Str_Starts_With_Str(name, ".", 1)) {
+ else if (Str_Starts_With_Utf8(name, ".", 1)) {
// Don't allow access outside of the main dir.
return NULL;
}
@@ -302,7 +302,7 @@ S_create_dir(const String *path) {
static bool
S_is_local_entry(const String *path) {
- return Str_Find_Str(path, "/", 1) == -1;
+ return Str_Find_Utf8(path, "/", 1) == -1;
}
/***************************************************************************/
@@ -366,7 +366,7 @@ S_hard_link(String *from_path, String *to_path) {
static bool
S_is_absolute(const String *path) {
- return Str_Starts_With_Str(path, DIR_SEP, 1);
+ return Str_Starts_With_Utf8(path, DIR_SEP, 1);
}
static String*
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Store/Folder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/Folder.c b/core/Lucy/Store/Folder.c
index 9d7bb46..c45169f 100644
--- a/core/Lucy/Store/Folder.c
+++ b/core/Lucy/Store/Folder.c
@@ -41,7 +41,7 @@ Folder_init(Folder *self, const String *path) {
}
else {
// Copy path, strip trailing slash or equivalent.
- if (Str_Ends_With_Str(path, DIR_SEP, strlen(DIR_SEP))) {
+ if (Str_Ends_With_Utf8(path, DIR_SEP, strlen(DIR_SEP))) {
ivars->path = Str_SubString(path, 0, Str_Length(path) - 1);
}
else {
@@ -209,7 +209,7 @@ Folder_Delete_Tree_IMP(Folder *self, const String *path) {
static bool
S_is_updir(String *path) {
- if (Str_Equals_Str(path, ".", 1) || Str_Equals_Str(path, "..", 2)) {
+ if (Str_Equals_Utf8(path, ".", 1) || Str_Equals_Utf8(path, "..", 2)) {
return true;
}
else {
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Store/Lock.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/Lock.c b/core/Lucy/Store/Lock.c
index 4d778d0..fc6efc7 100644
--- a/core/Lucy/Store/Lock.c
+++ b/core/Lucy/Store/Lock.c
@@ -168,10 +168,10 @@ LFLock_Request_IMP(LockFileLock *self) {
// Prepare to write pid, lock name, and host to the lock file as JSON.
file_data = Hash_new(3);
- Hash_Store_Str(file_data, "pid", 3,
- (Obj*)Str_newf("%i32", (int32_t)PID_getpid()));
- Hash_Store_Str(file_data, "host", 4, INCREF(ivars->host));
- Hash_Store_Str(file_data, "name", 4, INCREF(ivars->name));
+ Hash_Store_Utf8(file_data, "pid", 3,
+ (Obj*)Str_newf("%i32", (int32_t)PID_getpid()));
+ Hash_Store_Utf8(file_data, "host", 4, INCREF(ivars->host));
+ Hash_Store_Utf8(file_data, "name", 4, INCREF(ivars->name));
// Write to a temporary file, then use the creation of a hard link to
// ensure atomic but non-destructive creation of the lockfile with its
@@ -233,7 +233,7 @@ LFLock_Maybe_Delete_File_IMP(LockFileLock *self, const String *path,
bool success = false;
// Only delete locks that start with our lock name.
- if (!Str_Starts_With_Str(path, "locks", 5)) {
+ if (!Str_Starts_With_Utf8(path, "locks", 5)) {
return false;
}
StringIterator *iter = Str_Top(path);
@@ -248,10 +248,10 @@ LFLock_Maybe_Delete_File_IMP(LockFileLock *self, const String *path,
if (Folder_Exists(folder, path)) {
Hash *hash = (Hash*)Json_slurp_json(folder, path);
if (hash != NULL && Obj_Is_A((Obj*)hash, HASH)) {
- String *pid_buf = (String*)Hash_Fetch_Str(hash, "pid", 3);
- String *host = (String*)Hash_Fetch_Str(hash, "host", 4);
+ String *pid_buf = (String*)Hash_Fetch_Utf8(hash, "pid", 3);
+ String *host = (String*)Hash_Fetch_Utf8(hash, "host", 4);
String *name
- = (String*)Hash_Fetch_Str(hash, "name", 4);
+ = (String*)Hash_Fetch_Utf8(hash, "name", 4);
// Match hostname and lock name.
if (host != NULL
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Store/SharedLock.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/SharedLock.c b/core/Lucy/Store/SharedLock.c
index 7ff1fc6..9d33b7b 100644
--- a/core/Lucy/Store/SharedLock.c
+++ b/core/Lucy/Store/SharedLock.c
@@ -61,7 +61,7 @@ ShLock_Request_IMP(SharedLock *self) {
// Empty lock_path indicates whether this particular instance is locked.
if (ivars->lock_path
- && !Str_Equals_Str(ivars->lock_path, "", 0)
+ && !Str_Equals_Utf8(ivars->lock_path, "", 0)
&& Folder_Exists(ivars->folder, ivars->lock_path)
) {
// Don't allow double obtain.
@@ -83,7 +83,7 @@ ShLock_Request_IMP(SharedLock *self) {
void
ShLock_Release_IMP(SharedLock *self) {
SharedLockIVARS *const ivars = ShLock_IVARS(self);
- if (ivars->lock_path && !Str_Equals_Str(ivars->lock_path, "", 0)) {
+ if (ivars->lock_path && !Str_Equals_Utf8(ivars->lock_path, "", 0)) {
ShLock_Release_t super_release
= SUPER_METHOD_PTR(SHAREDLOCK, LUCY_ShLock_Release);
super_release(self);
@@ -111,7 +111,7 @@ ShLock_Clear_Stale_IMP(SharedLock *self) {
while (DH_Next(dh)) {
String *entry = DH_Get_Entry(dh);
if (Str_Starts_With(entry, ivars->name)
- && Str_Ends_With_Str(entry, ".lock", 5)
+ && Str_Ends_With_Utf8(entry, ".lock", 5)
) {
String *candidate = Str_newf("%o/%o", lock_dir_name, entry);
ShLock_Maybe_Delete_File(self, candidate, false, true);
@@ -149,7 +149,7 @@ ShLock_Is_Locked_IMP(SharedLock *self) {
if (!isdigit(code_point)) { break; }
}
if (code_point == '.'
- && StrIter_Starts_With_UTF8(iter, "lock", 4)
+ && StrIter_Starts_With_Utf8(iter, "lock", 4)
) {
StrIter_Advance(iter, 4);
if (!StrIter_Has_Next(iter)) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Analysis/TestNormalizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Analysis/TestNormalizer.c b/core/Lucy/Test/Analysis/TestNormalizer.c
index 1fb45f4..b1fea5c 100644
--- a/core/Lucy/Test/Analysis/TestNormalizer.c
+++ b/core/Lucy/Test/Analysis/TestNormalizer.c
@@ -79,15 +79,15 @@ test_normalization(TestBatchRunner *runner) {
for (uint32_t i = 0, max = VA_Get_Size(tests); i < max; i++) {
Hash *test = (Hash*)VA_Fetch(tests, i);
- String *form = (String*)Hash_Fetch_Str(
+ String *form = (String*)Hash_Fetch_Utf8(
test, "normalization_form", 18);
- bool case_fold = Bool_Get_Value((BoolNum*)Hash_Fetch_Str(
+ bool case_fold = Bool_Get_Value((BoolNum*)Hash_Fetch_Utf8(
test, "case_fold", 9));
- bool strip_accents = Bool_Get_Value((BoolNum*)Hash_Fetch_Str(
+ bool strip_accents = Bool_Get_Value((BoolNum*)Hash_Fetch_Utf8(
test, "strip_accents", 13));
Normalizer *normalizer = Normalizer_new(form, case_fold, strip_accents);
- VArray *words = (VArray*)Hash_Fetch_Str(test, "words", 5);
- VArray *norms = (VArray*)Hash_Fetch_Str(test, "norms", 5);
+ VArray *words = (VArray*)Hash_Fetch_Utf8(test, "words", 5);
+ VArray *norms = (VArray*)Hash_Fetch_Utf8(test, "norms", 5);
for (uint32_t j = 0, max = VA_Get_Size(words); j < max; j++) {
String *word = (String*)VA_Fetch(words, j);
VArray *got = Normalizer_Split(normalizer, word);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Analysis/TestSnowballStemmer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Analysis/TestSnowballStemmer.c b/core/Lucy/Test/Analysis/TestSnowballStemmer.c
index 894c6e4..3e6a44d 100644
--- a/core/Lucy/Test/Analysis/TestSnowballStemmer.c
+++ b/core/Lucy/Test/Analysis/TestSnowballStemmer.c
@@ -71,8 +71,8 @@ test_stemming(TestBatchRunner *runner) {
Hash *lang_data;
Hash_Iterate(tests);
while (Hash_Next(tests, (Obj**)&iso, (Obj**)&lang_data)) {
- VArray *words = (VArray*)Hash_Fetch_Str(lang_data, "words", 5);
- VArray *stems = (VArray*)Hash_Fetch_Str(lang_data, "stems", 5);
+ VArray *words = (VArray*)Hash_Fetch_Utf8(lang_data, "words", 5);
+ VArray *stems = (VArray*)Hash_Fetch_Utf8(lang_data, "stems", 5);
SnowballStemmer *stemmer = SnowStemmer_new(iso);
for (uint32_t i = 0, max = VA_Get_Size(words); i < max; i++) {
String *word = (String*)VA_Fetch(words, i);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Analysis/TestSnowballStopFilter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Analysis/TestSnowballStopFilter.c b/core/Lucy/Test/Analysis/TestSnowballStopFilter.c
index 46f4cd5..44fe6dc 100644
--- a/core/Lucy/Test/Analysis/TestSnowballStopFilter.c
+++ b/core/Lucy/Test/Analysis/TestSnowballStopFilter.c
@@ -37,8 +37,8 @@ S_make_stopfilter(void *unused, ...) {
va_start(args, unused);
while (NULL != (stopword = va_arg(args, char*))) {
- Hash_Store_Str(stoplist, stopword, strlen(stopword),
- (Obj*)Str_newf(""));
+ Hash_Store_Utf8(stoplist, stopword, strlen(stopword),
+ (Obj*)Str_newf(""));
}
va_end(args);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Analysis/TestStandardTokenizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Analysis/TestStandardTokenizer.c b/core/Lucy/Test/Analysis/TestStandardTokenizer.c
index 837cb58..ab5f36e 100644
--- a/core/Lucy/Test/Analysis/TestStandardTokenizer.c
+++ b/core/Lucy/Test/Analysis/TestStandardTokenizer.c
@@ -66,31 +66,31 @@ test_tokenizer(TestBatchRunner *runner) {
TEST_TRUE(runner,
token
&& Str_Is_A(token, STRING)
- && Str_Equals_Str(token, "tha\xcc\x82t's", 8),
+ && Str_Equals_Utf8(token, "tha\xcc\x82t's", 8),
"Token: %s", Str_Get_Ptr8(token));
token = (String*)VA_Fetch(got, 1);
TEST_TRUE(runner,
token
&& Str_Is_A(token, STRING)
- && Str_Equals_Str(token, "1,02\xC2\xADZ4.38", 11),
+ && Str_Equals_Utf8(token, "1,02\xC2\xADZ4.38", 11),
"Token: %s", Str_Get_Ptr8(token));
token = (String*)VA_Fetch(got, 2);
TEST_TRUE(runner,
token
&& Str_Is_A(token, STRING)
- && Str_Equals_Str(token, "\xE0\xB8\x81\xC2\xAD\xC2\xAD", 7),
+ && Str_Equals_Utf8(token, "\xE0\xB8\x81\xC2\xAD\xC2\xAD", 7),
"Token: %s", Str_Get_Ptr8(token));
token = (String*)VA_Fetch(got, 3);
TEST_TRUE(runner,
token
&& Str_Is_A(token, STRING)
- && Str_Equals_Str(token, "\xF0\xA0\x80\x80", 4),
+ && Str_Equals_Utf8(token, "\xF0\xA0\x80\x80", 4),
"Token: %s", Str_Get_Ptr8(token));
token = (String*)VA_Fetch(got, 4);
TEST_TRUE(runner,
token
&& Str_Is_A(token, STRING)
- && Str_Equals_Str(token, "a", 1),
+ && Str_Equals_Utf8(token, "a", 1),
"Token: %s", Str_Get_Ptr8(token));
DECREF(got);
@@ -101,8 +101,8 @@ test_tokenizer(TestBatchRunner *runner) {
for (uint32_t i = 0, max = VA_Get_Size(tests); i < max; i++) {
Hash *test = (Hash*)VA_Fetch(tests, i);
- String *text = (String*)Hash_Fetch_Str(test, "text", 4);
- VArray *wanted = (VArray*)Hash_Fetch_Str(test, "words", 5);
+ String *text = (String*)Hash_Fetch_Utf8(test, "text", 4);
+ VArray *wanted = (VArray*)Hash_Fetch_Utf8(test, "words", 5);
VArray *got = StandardTokenizer_Split(tokenizer, text);
TEST_TRUE(runner, VA_Equals(wanted, (Obj*)got), "UCD test #%d", i + 1);
DECREF(got);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Highlight/TestHighlighter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Highlight/TestHighlighter.c b/core/Lucy/Test/Highlight/TestHighlighter.c
index 2539ad0..706cd2a 100644
--- a/core/Lucy/Test/Highlight/TestHighlighter.c
+++ b/core/Lucy/Test/Highlight/TestHighlighter.c
@@ -72,7 +72,7 @@ test_Raw_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query) {
raw_excerpt = Highlighter_Raw_Excerpt(highlighter, field_val, &top,
heat_map);
TEST_TRUE(runner,
- Str_Equals_Str(raw_excerpt, "Ook.", 4),
+ Str_Equals_Utf8(raw_excerpt, "Ook.", 4),
"Raw_Excerpt at top %s", Str_Get_Ptr8(raw_excerpt));
TEST_TRUE(runner,
top == 0,
@@ -87,7 +87,7 @@ test_Raw_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query) {
raw_excerpt = Highlighter_Raw_Excerpt(highlighter, field_val, &top,
heat_map);
TEST_TRUE(runner,
- Str_Equals_Str(raw_excerpt, "Urk.", 4),
+ Str_Equals_Utf8(raw_excerpt, "Urk.", 4),
"Raw_Excerpt in middle, with 2 bounds");
TEST_TRUE(runner,
top == 6,
@@ -103,7 +103,7 @@ test_Raw_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query) {
raw_excerpt = Highlighter_Raw_Excerpt(highlighter, field_val, &top,
heat_map);
TEST_TRUE(runner,
- Str_Equals_Str(raw_excerpt, ELLIPSIS " i.", 6),
+ Str_Equals_Utf8(raw_excerpt, ELLIPSIS " i.", 6),
"Ellipsis at top");
TEST_TRUE(runner,
top == 10,
@@ -119,7 +119,7 @@ test_Raw_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query) {
raw_excerpt = Highlighter_Raw_Excerpt(highlighter, field_val, &top,
heat_map);
TEST_TRUE(runner,
- Str_Equals_Str(raw_excerpt, "Iz no" ELLIPSIS, 8),
+ Str_Equals_Utf8(raw_excerpt, "Iz no" ELLIPSIS, 8),
"Ellipsis at end");
TEST_TRUE(runner,
top == 6,
@@ -138,7 +138,7 @@ test_Raw_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query) {
raw_excerpt = Highlighter_Raw_Excerpt(highlighter, field_val, &top,
heat_map);
TEST_TRUE(runner,
- Str_Equals_Str(raw_excerpt, "abc/d" ELLIPSIS, 8),
+ Str_Equals_Utf8(raw_excerpt, "abc/d" ELLIPSIS, 8),
"Long word at top");
DECREF(heat_map);
DECREF(raw_excerpt);
@@ -150,7 +150,7 @@ test_Raw_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query) {
raw_excerpt = Highlighter_Raw_Excerpt(highlighter, field_val, &top,
heat_map);
TEST_TRUE(runner,
- Str_Equals_Str(raw_excerpt, ELLIPSIS " f/g" ELLIPSIS, 10),
+ Str_Equals_Utf8(raw_excerpt, ELLIPSIS " f/g" ELLIPSIS, 10),
"Long word in middle");
DECREF(heat_map);
DECREF(raw_excerpt);
@@ -170,7 +170,7 @@ test_Highlight_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query)
highlighted = Highlighter_Highlight_Excerpt(highlighter, spans,
raw_excerpt, 0);
TEST_TRUE(runner,
- Str_Equals_Str(highlighted, "a <strong>b</strong> c", 22),
+ Str_Equals_Utf8(highlighted, "a <strong>b</strong> c", 22),
"basic Highlight_Excerpt");
DECREF(highlighted);
DECREF(spans);
@@ -182,7 +182,7 @@ test_Highlight_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query)
highlighted = Highlighter_Highlight_Excerpt(highlighter, spans,
raw_excerpt, 0);
TEST_TRUE(runner,
- Str_Equals_Str(highlighted, "<strong>Φ</strong>", 23),
+ Str_Equals_Utf8(highlighted, "<strong>Φ</strong>", 23),
"don't surround spans off end of raw excerpt.");
DECREF(highlighted);
DECREF(spans);
@@ -193,7 +193,7 @@ test_Highlight_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query)
highlighted = Highlighter_Highlight_Excerpt(highlighter, spans,
raw_excerpt, 1);
TEST_TRUE(runner,
- Str_Equals_Str(highlighted,
+ Str_Equals_Utf8(highlighted,
"Φ <strong>Φ</strong> Φ", 37),
"Highlight_Excerpt pays attention to offset");
DECREF(highlighted);
@@ -208,7 +208,7 @@ test_Highlight_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query)
highlighted = Highlighter_Highlight_Excerpt(highlighter, spans,
raw_excerpt, 0);
TEST_TRUE(runner,
- Str_Equals_Str(highlighted,
+ Str_Equals_Utf8(highlighted,
"Φ <strong>Oook. Urk. Ick.</strong> Φ",
46),
"Highlight_Excerpt works with overlapping spans");
@@ -227,7 +227,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
HitDoc *hit = Hits_Next(hits);
String *excerpt = Highlighter_Create_Excerpt(highlighter, hit);
TEST_TRUE(runner,
- Str_Find_Str(excerpt,
+ Str_Find_Utf8(excerpt,
"<strong>Φ</strong> a b c d <strong>x y z</strong>",
54) >= 0,
"highlighter tagged phrase and single term");
@@ -239,7 +239,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
Highlighter_Set_Post_Tag(highlighter, post_tag);
excerpt = Highlighter_Create_Excerpt(highlighter, hit);
TEST_TRUE(runner,
- Str_Find_Str(excerpt,
+ Str_Find_Utf8(excerpt,
"\x1B[1mΦ\x1B[0m a b c d \x1B[1mx y z\x1B[0m",
36) >= 0,
"set_pre_tag and set_post_tag");
@@ -249,7 +249,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
hit = Hits_Next(hits);
excerpt = Highlighter_Create_Excerpt(highlighter, hit);
TEST_TRUE(runner,
- Str_Find_Str(excerpt, "x", 1) >= 0,
+ Str_Find_Utf8(excerpt, "x", 1) >= 0,
"excerpt field with partial hit doesn't cause highlighter freakout");
DECREF(excerpt);
DECREF(hit);
@@ -261,7 +261,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
hit = Hits_Next(hits);
excerpt = Highlighter_Create_Excerpt(highlighter, hit);
TEST_TRUE(runner,
- Str_Find_Str(excerpt,
+ Str_Find_Utf8(excerpt,
"<strong>b</strong> c d <strong>x y z</strong>",
45) >= 0,
"query with same word in both phrase and term doesn't cause freakout");
@@ -276,7 +276,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
hit = Hits_Next(hits);
excerpt = Highlighter_Create_Excerpt(highlighter, hit);
TEST_TRUE(runner,
- Str_Find_Str(excerpt, """, 6) >= 0,
+ Str_Find_Utf8(excerpt, """, 6) >= 0,
"HTML entity encoded properly");
DECREF(excerpt);
DECREF(hit);
@@ -289,7 +289,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
hit = Hits_Next(hits);
excerpt = Highlighter_Create_Excerpt(highlighter, hit);
TEST_TRUE(runner,
- Str_Find_Str(excerpt, "Φ", 6) == -1,
+ Str_Find_Utf8(excerpt, "Φ", 6) == -1,
"no ellipsis for short excerpt");
DECREF(excerpt);
DECREF(hit);
@@ -303,7 +303,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
highlighter = Highlighter_new(searcher, query, content, 200);
excerpt = Highlighter_Create_Excerpt(highlighter, hit);
TEST_TRUE(runner,
- Str_Find_Str(excerpt, "strong", 5) >= 0,
+ Str_Find_Utf8(excerpt, "strong", 5) >= 0,
"specify field highlights correct field...");
DECREF(excerpt);
DECREF(highlighter);
@@ -311,7 +311,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
highlighter = Highlighter_new(searcher, query, alt, 200);
excerpt = Highlighter_Create_Excerpt(highlighter, hit);
TEST_TRUE(runner,
- Str_Find_Str(excerpt, "strong", 5) == -1,
+ Str_Find_Utf8(excerpt, "strong", 5) == -1,
"... but not another field");
DECREF(excerpt);
DECREF(highlighter);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Index/TestSegment.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Index/TestSegment.c b/core/Lucy/Test/Index/TestSegment.c
index bd83256..e0e9b6b 100644
--- a/core/Lucy/Test/Index/TestSegment.c
+++ b/core/Lucy/Test/Index/TestSegment.c
@@ -63,12 +63,12 @@ test_metadata_storage(TestBatchRunner *runner) {
Segment *segment = Seg_new(1);
String *got;
- Seg_Store_Metadata_Str(segment, "foo", 3, (Obj*)Str_newf("bar"));
- got = (String*)Seg_Fetch_Metadata_Str(segment, "foo", 3);
+ Seg_Store_Metadata_Utf8(segment, "foo", 3, (Obj*)Str_newf("bar"));
+ got = (String*)Seg_Fetch_Metadata_Utf8(segment, "foo", 3);
TEST_TRUE(runner,
got
&& Str_Is_A(got, STRING)
- && Str_Equals_Str(got, "bar", 3),
+ && Str_Equals_Utf8(got, "bar", 3),
"metadata round trip"
);
DECREF(segment);
@@ -79,9 +79,9 @@ test_seg_name_and_num(TestBatchRunner *runner) {
Segment *segment_z = Seg_new(35);
String *seg_z_name = Seg_num_to_name(35);
TEST_TRUE(runner, Seg_Get_Number(segment_z) == INT64_C(35), "Get_Number");
- TEST_TRUE(runner, Str_Equals_Str(Seg_Get_Name(segment_z), "seg_z", 5),
+ TEST_TRUE(runner, Str_Equals_Utf8(Seg_Get_Name(segment_z), "seg_z", 5),
"Get_Name");
- TEST_TRUE(runner, Str_Equals_Str(seg_z_name, "seg_z", 5),
+ TEST_TRUE(runner, Str_Equals_Utf8(seg_z_name, "seg_z", 5),
"num_to_name");
DECREF(seg_z_name);
DECREF(segment_z);
@@ -130,7 +130,7 @@ test_Write_File_and_Read_File(TestBatchRunner *runner) {
String *jetsam = (String*)SSTR_WRAP_STR("jetsam", 6);
Seg_Set_Count(segment, 111);
- Seg_Store_Metadata_Str(segment, "foo", 3, (Obj*)Str_newf("bar"));
+ Seg_Store_Metadata_Utf8(segment, "foo", 3, (Obj*)Str_newf("bar"));
Seg_Add_Field(segment, flotsam);
Seg_Add_Field(segment, jetsam);
@@ -143,11 +143,11 @@ test_Write_File_and_Read_File(TestBatchRunner *runner) {
TEST_TRUE(runner,
Seg_Field_Num(got, jetsam) == Seg_Field_Num(segment, jetsam),
"Round trip field names through file");
- meta = (String*)Seg_Fetch_Metadata_Str(got, "foo", 3);
+ meta = (String*)Seg_Fetch_Metadata_Utf8(got, "foo", 3);
TEST_TRUE(runner,
meta
&& Str_Is_A(meta, STRING)
- && Str_Equals_Str(meta, "bar", 3),
+ && Str_Equals_Utf8(meta, "bar", 3),
"Round trip metadata through file");
DECREF(got);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Plan/TestFullTextType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Plan/TestFullTextType.c b/core/Lucy/Test/Plan/TestFullTextType.c
index 0a4436e..243dd69 100644
--- a/core/Lucy/Test/Plan/TestFullTextType.c
+++ b/core/Lucy/Test/Plan/TestFullTextType.c
@@ -52,7 +52,7 @@ test_Dump_Load_and_Equals(TestBatchRunner *runner) {
FullTextType_Set_Highlightable(highlightable, true);
// (This step is normally performed by Schema_Load() internally.)
- Hash_Store_Str((Hash*)another_dump, "analyzer", 8, INCREF(tokenizer));
+ Hash_Store_Utf8((Hash*)another_dump, "analyzer", 8, INCREF(tokenizer));
FullTextType *another_clone = FullTextType_Load(type, another_dump);
TEST_FALSE(runner, FullTextType_Equals(type, (Obj*)boost_differs),
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Search/TestQueryParserSyntax.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestQueryParserSyntax.c b/core/Lucy/Test/Search/TestQueryParserSyntax.c
index d2aab4e..6a074b3 100644
--- a/core/Lucy/Test/Search/TestQueryParserSyntax.c
+++ b/core/Lucy/Test/Search/TestQueryParserSyntax.c
@@ -68,7 +68,7 @@ build_index() {
RegexTokenizer *word_tokenizer = RegexTokenizer_new(word_pattern);
Hash *stop_list = Hash_new(0);
- Hash_Store_Str(stop_list, "x", 1, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(stop_list, "x", 1, (Obj*)CFISH_TRUE);
SnowballStopFilter *stop_filter = SnowStop_new(NULL, stop_list);
VArray *analyzers = VA_new(0);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Search/TestSortSpec.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestSortSpec.c b/core/Lucy/Test/Search/TestSortSpec.c
index ed6b945..6401f27 100644
--- a/core/Lucy/Test/Search/TestSortSpec.c
+++ b/core/Lucy/Test/Search/TestSortSpec.c
@@ -465,7 +465,7 @@ test_sort_spec(TestBatchRunner *runner) {
error = Err_trap(S_attempt_sorted_search, &sort_ctx);
TEST_TRUE(runner, error != NULL
&& Err_Is_A(error, ERR)
- && Str_Find_Str(Err_Get_Mess(error), "sortable", 8) != -1,
+ && Str_Find_Utf8(Err_Get_Mess(error), "sortable", 8) != -1,
"sorting on a non-sortable field throws an error");
DECREF(error);
@@ -473,7 +473,7 @@ test_sort_spec(TestBatchRunner *runner) {
error = Err_trap(S_attempt_sorted_search, &sort_ctx);
TEST_TRUE(runner, error != NULL
&& Err_Is_A(error, ERR)
- && Str_Find_Str(Err_Get_Mess(error), "sortable", 8) != -1,
+ && Str_Find_Utf8(Err_Get_Mess(error), "sortable", 8) != -1,
"sorting on an unknown field throws an error");
DECREF(error);
#endif
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Store/TestCompoundFileReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestCompoundFileReader.c b/core/Lucy/Test/Store/TestCompoundFileReader.c
index bb7eb89..f493762 100644
--- a/core/Lucy/Test/Store/TestCompoundFileReader.c
+++ b/core/Lucy/Test/Store/TestCompoundFileReader.c
@@ -112,7 +112,7 @@ test_open(TestBatchRunner *runner) {
Err_set_error(NULL);
real_folder = S_folder_with_contents();
metadata = (Hash*)Json_slurp_json(real_folder, cfmeta_file);
- Hash_Store_Str(metadata, "format", 6, (Obj*)Str_newf("%i32", -1));
+ Hash_Store_Utf8(metadata, "format", 6, (Obj*)Str_newf("%i32", -1));
Folder_Delete(real_folder, cfmeta_file);
Json_spew_json((Obj*)metadata, real_folder, cfmeta_file);
cf_reader = CFReader_open(real_folder);
@@ -122,7 +122,7 @@ test_open(TestBatchRunner *runner) {
"Set Err_error when format is invalid");
Err_set_error(NULL);
- Hash_Store_Str(metadata, "format", 6, (Obj*)Str_newf("%i32", 1000));
+ Hash_Store_Utf8(metadata, "format", 6, (Obj*)Str_newf("%i32", 1000));
Folder_Delete(real_folder, cfmeta_file);
Json_spew_json((Obj*)metadata, real_folder, cfmeta_file);
cf_reader = CFReader_open(real_folder);
@@ -132,7 +132,7 @@ test_open(TestBatchRunner *runner) {
"Set Err_error when format too recent");
Err_set_error(NULL);
- DECREF(Hash_Delete_Str(metadata, "format", 6));
+ DECREF(Hash_Delete_Utf8(metadata, "format", 6));
Folder_Delete(real_folder, cfmeta_file);
Json_spew_json((Obj*)metadata, real_folder, cfmeta_file);
cf_reader = CFReader_open(real_folder);
@@ -141,9 +141,9 @@ test_open(TestBatchRunner *runner) {
TEST_TRUE(runner, Err_get_error() != NULL,
"Set Err_error when format key is missing");
- Hash_Store_Str(metadata, "format", 6,
- (Obj*)Str_newf("%i32", CFWriter_current_file_format));
- DECREF(Hash_Delete_Str(metadata, "files", 5));
+ Hash_Store_Utf8(metadata, "format", 6,
+ (Obj*)Str_newf("%i32", CFWriter_current_file_format));
+ DECREF(Hash_Delete_Utf8(metadata, "files", 5));
Folder_Delete(real_folder, cfmeta_file);
Json_spew_json((Obj*)metadata, real_folder, cfmeta_file);
cf_reader = CFReader_open(real_folder);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Store/TestCompoundFileWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestCompoundFileWriter.c b/core/Lucy/Test/Store/TestCompoundFileWriter.c
index 5ed0565..3918ca8 100644
--- a/core/Lucy/Test/Store/TestCompoundFileWriter.c
+++ b/core/Lucy/Test/Store/TestCompoundFileWriter.c
@@ -114,7 +114,7 @@ test_offsets(TestBatchRunner *runner) {
cf_metadata = (Hash*)CERTIFY(
Json_slurp_json(folder, cfmeta_file), HASH);
files = (Hash*)CERTIFY(
- Hash_Fetch_Str(cf_metadata, "files", 5), HASH);
+ Hash_Fetch_Utf8(cf_metadata, "files", 5), HASH);
String *file;
Obj *filestats;
@@ -125,7 +125,7 @@ test_offsets(TestBatchRunner *runner) {
Hash_Iterate(files);
while (Hash_Next(files, (Obj**)&file, &filestats)) {
Hash *stats = (Hash*)CERTIFY(filestats, HASH);
- Obj *offset = CERTIFY(Hash_Fetch_Str(stats, "offset", 6), OBJ);
+ Obj *offset = CERTIFY(Hash_Fetch_Utf8(stats, "offset", 6), OBJ);
int64_t offs = Obj_To_I64(offset);
if (offs % 8 != 0) {
offsets_ok = false;
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Store/TestFSFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestFSFolder.c b/core/Lucy/Test/Store/TestFSFolder.c
index 6c66f10..689bfa0 100644
--- a/core/Lucy/Test/Store/TestFSFolder.c
+++ b/core/Lucy/Test/Store/TestFSFolder.c
@@ -119,7 +119,7 @@ test_protect_symlinks(TestBatchRunner *runner) {
bool saw_bazooka_boffo = false;
for (uint32_t i = 0, max = VA_Get_Size(list); i < max; i++) {
String *entry = (String*)VA_Fetch(list, i);
- if (Str_Ends_With_Str(entry, "bazooka/boffo", 13)) {
+ if (Str_Ends_With_Utf8(entry, "bazooka/boffo", 13)) {
saw_bazooka_boffo = true;
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Store/TestFileHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestFileHandle.c b/core/Lucy/Test/Store/TestFileHandle.c
index 3d1e94b..4942d35 100644
--- a/core/Lucy/Test/Store/TestFileHandle.c
+++ b/core/Lucy/Test/Store/TestFileHandle.c
@@ -56,7 +56,7 @@ TestFH_Run_IMP(TestFileHandle *self, TestBatchRunner *runner) {
FileHandle *fh = S_new_filehandle();
StackString *foo = SSTR_WRAP_STR("foo", 3);
- TEST_TRUE(runner, Str_Equals_Str(FH_Get_Path(fh), "", 0), "Get_Path");
+ TEST_TRUE(runner, Str_Equals_Utf8(FH_Get_Path(fh), "", 0), "Get_Path");
FH_Set_Path(fh, (String*)foo);
TEST_TRUE(runner, Str_Equals(FH_Get_Path(fh), (Obj*)foo), "Set_Path");
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Store/TestRAMFileHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestRAMFileHandle.c b/core/Lucy/Test/Store/TestRAMFileHandle.c
index c8a57b9..d276d5d 100644
--- a/core/Lucy/Test/Store/TestRAMFileHandle.c
+++ b/core/Lucy/Test/Store/TestRAMFileHandle.c
@@ -55,7 +55,7 @@ test_Read_Write(TestBatchRunner *runner) {
char buffer[12];
char *buf = buffer;
- TEST_TRUE(runner, Str_Equals_Str(RAMFH_Get_Path(fh), "", 0),
+ TEST_TRUE(runner, Str_Equals_Utf8(RAMFH_Get_Path(fh), "", 0),
"NULL arg as filepath yields empty string");
TEST_TRUE(runner, RAMFH_Write(fh, foo, 3), "Write returns success");
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Store/TestRAMFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestRAMFolder.c b/core/Lucy/Test/Store/TestRAMFolder.c
index 13aeb9d..c173897 100644
--- a/core/Lucy/Test/Store/TestRAMFolder.c
+++ b/core/Lucy/Test/Store/TestRAMFolder.c
@@ -159,7 +159,7 @@ test_Local_Find_Folder(TestBatchRunner *runner) {
TEST_TRUE(runner,
local
&& RAMFolder_Is_A(local, RAMFOLDER)
- && Str_Equals_Str(RAMFolder_Get_Path(local), "foo", 3),
+ && Str_Equals_Utf8(RAMFolder_Get_Path(local), "foo", 3),
"Find local directory");
DECREF(folder);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Util/TestIndexFileNames.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Util/TestIndexFileNames.c b/core/Lucy/Test/Util/TestIndexFileNames.c
index c2b55ee..c5b2a18 100644
--- a/core/Lucy/Test/Util/TestIndexFileNames.c
+++ b/core/Lucy/Test/Util/TestIndexFileNames.c
@@ -32,7 +32,7 @@ S_test_local_part(TestBatchRunner *runner, const char *source,
const char *wanted, const char *test_name) {
StackString *source_str = SSTR_WRAP_STR(source, strlen(source));
String *got = IxFileNames_local_part((String*)source_str);
- TEST_TRUE(runner, Str_Equals_Str(got, wanted, strlen(wanted)), test_name);
+ TEST_TRUE(runner, Str_Equals_Utf8(got, wanted, strlen(wanted)), test_name);
DECREF(got);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Test/Util/TestJson.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Util/TestJson.c b/core/Lucy/Test/Util/TestJson.c
index 3b17a6d..2fa7e32 100644
--- a/core/Lucy/Test/Util/TestJson.c
+++ b/core/Lucy/Test/Util/TestJson.c
@@ -35,8 +35,8 @@ TestJson_new() {
static Obj*
S_make_dump() {
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "foo", 3, (Obj*)Str_newf("foo"));
- Hash_Store_Str(dump, "stuff", 5, (Obj*)VA_new(0));
+ Hash_Store_Utf8(dump, "foo", 3, (Obj*)Str_newf("foo"));
+ Hash_Store_Utf8(dump, "stuff", 5, (Obj*)VA_new(0));
return (Obj*)dump;
}
@@ -163,7 +163,7 @@ test_numbers(TestBatchRunner *runner) {
Integer64 *i64 = Int64_new(33);
String *json = Json_to_json((Obj*)i64);
String *trimmed = Str_Trim(json);
- TEST_TRUE(runner, Str_Equals_Str(trimmed, "33", 2), "Integer");
+ TEST_TRUE(runner, Str_Equals_Utf8(trimmed, "33", 2), "Integer");
DECREF(json);
DECREF(trimmed);
@@ -326,14 +326,14 @@ test_floats(TestBatchRunner *runner) {
static void
test_max_depth(TestBatchRunner *runner) {
Hash *circular = Hash_new(0);
- Hash_Store_Str(circular, "circular", 8, INCREF(circular));
+ Hash_Store_Utf8(circular, "circular", 8, INCREF(circular));
Err_set_error(NULL);
String *not_json = Json_to_json((Obj*)circular);
TEST_TRUE(runner, not_json == NULL,
"to_json returns NULL when fed recursing data");
TEST_TRUE(runner, Err_get_error() != NULL,
"to_json sets Err_error when fed recursing data");
- DECREF(Hash_Delete_Str(circular, "circular", 8));
+ DECREF(Hash_Delete_Utf8(circular, "circular", 8));
DECREF(circular);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Util/Freezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c
index e492962..521ea03 100644
--- a/core/Lucy/Util/Freezer.c
+++ b/core/Lucy/Util/Freezer.c
@@ -455,7 +455,7 @@ S_load_via_load_method(VTable *vtable, Obj *dump) {
static Obj*
S_load_from_hash(Hash *dump) {
- String *class_name = (String*)Hash_Fetch_Str(dump, "_class", 6);
+ String *class_name = (String*)Hash_Fetch_Utf8(dump, "_class", 6);
// Assume that the presence of the "_class" key paired with a valid class
// name indicates the output of a dump() rather than an ordinary Hash.
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Util/IndexFileNames.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/IndexFileNames.c b/core/Lucy/Util/IndexFileNames.c
index e3b7bf7..ee5d237 100644
--- a/core/Lucy/Util/IndexFileNames.c
+++ b/core/Lucy/Util/IndexFileNames.c
@@ -32,8 +32,8 @@ IxFileNames_latest_snapshot(Folder *folder) {
while (DH_Next(dh)) {
String *entry = DH_Get_Entry(dh);
- if (Str_Starts_With_Str(entry, "snapshot_", 9)
- && Str_Ends_With_Str(entry, ".json", 5)
+ if (Str_Starts_With_Utf8(entry, "snapshot_", 9)
+ && Str_Ends_With_Utf8(entry, ".json", 5)
) {
uint64_t gen = IxFileNames_extract_gen(entry);
if (gen > latest_gen) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index b5e7f57..c564c55 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -159,7 +159,7 @@ Json_to_json(Obj *dump) {
}
else {
// Append newline.
- CB_Cat_Trusted_UTF8(buf, "\n", 1);
+ CB_Cat_Trusted_Utf8(buf, "\n", 1);
json = CB_Yield_String(buf);
}
@@ -177,7 +177,7 @@ static const int32_t MAX_DEPTH = 200;
static void
S_append_json_string(String *dump, CharBuf *buf) {
// Append opening quote.
- CB_Cat_Trusted_UTF8(buf, "\"", 1);
+ CB_Cat_Trusted_Utf8(buf, "\"", 1);
// Process string data.
StringIterator *iter = Str_Top(dump);
@@ -241,12 +241,12 @@ S_append_json_string(String *dump, CharBuf *buf) {
buffer[0] = (char)code_point;
len = 1;
}
- CB_Cat_Trusted_UTF8(buf, buffer, len);
+ CB_Cat_Trusted_Utf8(buf, buffer, len);
}
}
// Append closing quote.
- CB_Cat_Trusted_UTF8(buf, "\"", 1);
+ CB_Cat_Trusted_Utf8(buf, "\"", 1);
DECREF(iter);
}
@@ -254,7 +254,7 @@ S_append_json_string(String *dump, CharBuf *buf) {
static void
S_cat_whitespace(CharBuf *buf, int32_t depth) {
while (depth--) {
- CB_Cat_Trusted_UTF8(buf, indentation, INDENTATION_LEN);
+ CB_Cat_Trusted_Utf8(buf, indentation, INDENTATION_LEN);
}
}
@@ -268,13 +268,13 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
}
if (!dump) {
- CB_Cat_Trusted_UTF8(buf, "null", 4);
+ CB_Cat_Trusted_Utf8(buf, "null", 4);
}
else if (dump == (Obj*)CFISH_TRUE) {
- CB_Cat_Trusted_UTF8(buf, "true", 4);
+ CB_Cat_Trusted_Utf8(buf, "true", 4);
}
else if (dump == (Obj*)CFISH_FALSE) {
- CB_Cat_Trusted_UTF8(buf, "false", 5);
+ CB_Cat_Trusted_Utf8(buf, "false", 5);
}
else if (Obj_Is_A(dump, STRING)) {
S_append_json_string((String*)dump, buf);
@@ -290,36 +290,36 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
size_t size = VA_Get_Size(array);
if (size == 0) {
// Put empty array on single line.
- CB_Cat_Trusted_UTF8(buf, "[]", 2);
+ CB_Cat_Trusted_Utf8(buf, "[]", 2);
return true;
}
else if (size == 1) {
Obj *elem = VA_Fetch(array, 0);
if (!(Obj_Is_A(elem, HASH) || Obj_Is_A(elem, VARRAY))) {
// Put array containing single scalar element on one line.
- CB_Cat_Trusted_UTF8(buf, "[", 1);
+ CB_Cat_Trusted_Utf8(buf, "[", 1);
if (!S_to_json(elem, buf, depth + 1)) {
return false;
}
- CB_Cat_Trusted_UTF8(buf, "]", 1);
+ CB_Cat_Trusted_Utf8(buf, "]", 1);
return true;
}
}
// Fall back to spreading elements across multiple lines.
- CB_Cat_Trusted_UTF8(buf, "[", 1);
+ CB_Cat_Trusted_Utf8(buf, "[", 1);
for (size_t i = 0; i < size; i++) {
- CB_Cat_Trusted_UTF8(buf, "\n", 1);
+ CB_Cat_Trusted_Utf8(buf, "\n", 1);
S_cat_whitespace(buf, depth + 1);
if (!S_to_json(VA_Fetch(array, i), buf, depth + 1)) {
return false;
}
if (i + 1 < size) {
- CB_Cat_Trusted_UTF8(buf, ",", 1);
+ CB_Cat_Trusted_Utf8(buf, ",", 1);
}
}
- CB_Cat_Trusted_UTF8(buf, "\n", 1);
+ CB_Cat_Trusted_Utf8(buf, "\n", 1);
S_cat_whitespace(buf, depth);
- CB_Cat_Trusted_UTF8(buf, "]", 1);
+ CB_Cat_Trusted_Utf8(buf, "]", 1);
}
else if (Obj_Is_A(dump, HASH)) {
Hash *hash = (Hash*)dump;
@@ -327,7 +327,7 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
// Put empty hash on single line.
if (size == 0) {
- CB_Cat_Trusted_UTF8(buf, "{}", 2);
+ CB_Cat_Trusted_Utf8(buf, "{}", 2);
return true;
}
@@ -346,24 +346,24 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
VA_Sort(keys, NULL, NULL);
// Spread pairs across multiple lines.
- CB_Cat_Trusted_UTF8(buf, "{", 1);
+ CB_Cat_Trusted_Utf8(buf, "{", 1);
for (size_t i = 0; i < size; i++) {
Obj *key = VA_Fetch(keys, i);
- CB_Cat_Trusted_UTF8(buf, "\n", 1);
+ CB_Cat_Trusted_Utf8(buf, "\n", 1);
S_cat_whitespace(buf, depth + 1);
S_append_json_string((String*)key, buf);
- CB_Cat_Trusted_UTF8(buf, ": ", 2);
+ CB_Cat_Trusted_Utf8(buf, ": ", 2);
if (!S_to_json(Hash_Fetch(hash, key), buf, depth + 1)) {
DECREF(keys);
return false;
}
if (i + 1 < size) {
- CB_Cat_Trusted_UTF8(buf, ",", 1);
+ CB_Cat_Trusted_Utf8(buf, ",", 1);
}
}
- CB_Cat_Trusted_UTF8(buf, "\n", 1);
+ CB_Cat_Trusted_Utf8(buf, "\n", 1);
S_cat_whitespace(buf, depth);
- CB_Cat_Trusted_UTF8(buf, "}", 1);
+ CB_Cat_Trusted_Utf8(buf, "}", 1);
DECREF(keys);
}
[lucy-commits] [02/15] git commit: refs/heads/cfish-string-prep1 - Convert
Str_Swap_Chars to immutable strings
Posted by nw...@apache.org.
Convert Str_Swap_Chars to immutable strings
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/9dbac05f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/9dbac05f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/9dbac05f
Branch: refs/heads/cfish-string-prep1
Commit: 9dbac05fa438886ae5fa24e4fe062735158f3499
Parents: 8ab0675
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 14:43:40 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 14:43:40 2013 +0200
----------------------------------------------------------------------
clownfish/runtime/core/Clownfish/String.c | 28 +++++++-------------
clownfish/runtime/core/Clownfish/String.cfh | 7 ++---
.../runtime/core/Clownfish/Test/TestString.c | 21 ++++++++++++---
core/Lucy/Store/FSFolder.c | 9 +++++--
4 files changed, 39 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/9dbac05f/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index ef98320..d39f271 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -161,28 +161,20 @@ Str_To_String_IMP(String *self) {
return Str_new_from_trusted_utf8(self->ptr, self->size);
}
-int32_t
+String*
Str_Swap_Chars_IMP(String *self, uint32_t match, uint32_t replacement) {
- int32_t num_swapped = 0;
+ CharBuf *charbuf = CB_new(self->size);
+ StackStringIterator *iter = STR_STACKTOP(self);
+ uint32_t code_point;
- if (match > 127) {
- THROW(ERR, "match point too high: %u32", match);
- }
- else if (replacement > 127) {
- THROW(ERR, "replacement code point too high: %u32", replacement);
- }
- else {
- char *ptr = self->ptr;
- char *const limit = ptr + self->size;
- for (; ptr < limit; ptr++) {
- if (*ptr == (char)match) {
- *ptr = (char)replacement;
- num_swapped++;
- }
- }
+ while (STRITER_DONE != (code_point = SStrIter_Next(iter))) {
+ if (code_point == match) { code_point = replacement; }
+ CB_Cat_Char(charbuf, code_point);
}
- return num_swapped;
+ String *retval = CB_Yield_String(charbuf);
+ DECREF(charbuf);
+ return retval;
}
int64_t
http://git-wip-us.apache.org/repos/asf/lucy/blob/9dbac05f/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index f49ddd2..ee78652 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -105,10 +105,11 @@ class Clownfish::String cnick Str
incremented String*
Cat_Trusted_UTF8(String *self, const char *ptr, size_t size);
- /** Replace all instances of one character for the other. For now, both
- * the source and replacement code points must be ASCII.
+ /** Replace all instances of one character for the other.
+ *
+ * @return a new String with the characters replaced.
*/
- int32_t
+ incremented String*
Swap_Chars(String *self, uint32_t match, uint32_t replacement);
public int64_t
http://git-wip-us.apache.org/repos/asf/lucy/blob/9dbac05f/clownfish/runtime/core/Clownfish/Test/TestString.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestString.c b/clownfish/runtime/core/Clownfish/Test/TestString.c
index 31143fc..daecdc6 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestString.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestString.c
@@ -35,6 +35,7 @@
static char smiley[] = { (char)0xE2, (char)0x98, (char)0xBA, 0 };
static uint32_t smiley_len = 3;
+static uint32_t smiley_cp = 0x263A;
TestString*
TestStr_new() {
@@ -60,7 +61,7 @@ S_smiley_with_whitespace(int *num_spaces_ptr) {
CharBuf *buf = CB_new(0);
for (int i = 0; i < num_spaces; i++) { CB_Cat_Char(buf, spaces[i]); }
- CB_Cat_Char(buf, 0x263A);
+ CB_Cat_Char(buf, smiley_cp);
for (int i = 0; i < num_spaces; i++) { CB_Cat_Char(buf, spaces[i]); }
String *retval = CB_To_String(buf);
@@ -138,7 +139,9 @@ test_Find(TestBatchRunner *runner) {
static void
test_Code_Point_At_and_From(TestBatchRunner *runner) {
- uint32_t code_points[] = { 'a', 0x263A, 0x263A, 'b', 0x263A, 'c' };
+ uint32_t code_points[] = {
+ 'a', smiley_cp, smiley_cp, 'b', smiley_cp, 'c'
+ };
uint32_t num_code_points = sizeof(code_points) / sizeof(uint32_t);
String *string = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
uint32_t i;
@@ -289,6 +292,17 @@ test_Compare_To(TestBatchRunner *runner) {
}
static void
+test_Swap_Chars(TestBatchRunner *runner) {
+ String *source = S_get_str("aXXbXc");
+ String *got = Str_Swap_Chars(source, 'X', smiley_cp);
+ String *wanted = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
+ TEST_TRUE(runner, Str_Equals(got, (Obj*)wanted), "Swap_Chars");
+ DECREF(wanted);
+ DECREF(got);
+ DECREF(source);
+}
+
+static void
test_iterator(TestBatchRunner *runner) {
static const uint32_t code_points[] = {
0x41,
@@ -481,7 +495,7 @@ test_iterator_substring(TestBatchRunner *runner) {
void
TestStr_Run_IMP(TestString *self, TestBatchRunner *runner) {
- TestBatchRunner_Plan(runner, (TestBatch*)self, 99);
+ TestBatchRunner_Plan(runner, (TestBatch*)self, 100);
test_Cat(runner);
test_Clone(runner);
test_Code_Point_At_and_From(runner);
@@ -492,6 +506,7 @@ TestStr_Run_IMP(TestString *self, TestBatchRunner *runner) {
test_To_I64(runner);
test_Length(runner);
test_Compare_To(runner);
+ test_Swap_Chars(runner);
test_iterator(runner);
test_iterator_whitespace(runner);
test_iterator_substring(runner);
http://git-wip-us.apache.org/repos/asf/lucy/blob/9dbac05f/core/Lucy/Store/FSFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFolder.c b/core/Lucy/Store/FSFolder.c
index e923d33..cdb353c 100644
--- a/core/Lucy/Store/FSFolder.c
+++ b/core/Lucy/Store/FSFolder.c
@@ -270,10 +270,15 @@ static String*
S_fullpath(FSFolder *self, const String *path) {
FSFolderIVARS *const ivars = FSFolder_IVARS(self);
String *fullpath = Str_newf("%o%s%o", ivars->path, DIR_SEP, path);
+ String *retval;
if (DIR_SEP[0] != '/') {
- Str_Swap_Chars(fullpath, '/', DIR_SEP[0]);
+ retval = Str_Swap_Chars(fullpath, '/', DIR_SEP[0]);
+ DECREF(fullpath);
+ }
+ else {
+ retval = fullpath;
}
- return fullpath;
+ return retval;
}
static bool
[lucy-commits] [10/15] git commit: refs/heads/cfish-string-prep1 - Rework string
constructors
Posted by nw...@apache.org.
Rework string constructors
* Add 'origin' instance variable to String to distinguish normal
strings, substrings, and wrapped strings.
* Add Str_new_wrap_* constructors to replace ViewCharBuf.
* Rename Str_new_steal_* constructors.
* Remove SStr_new constructor
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/0008a998
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/0008a998
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/0008a998
Branch: refs/heads/cfish-string-prep1
Commit: 0008a9980b3d6604f90f0654e0631597c5c7a766
Parents: fc363f0
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 20:16:38 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 20:16:38 2013 +0200
----------------------------------------------------------------------
c/src/Lucy/Index/DocReader.c | 3 +-
clownfish/runtime/core/Clownfish/CharBuf.c | 2 +-
clownfish/runtime/core/Clownfish/Num.c | 1 -
clownfish/runtime/core/Clownfish/String.c | 144 +++++++++----------
clownfish/runtime/core/Clownfish/String.cfh | 53 +++----
.../perl/buildlib/Clownfish/Build/Binding.pm | 17 ---
clownfish/runtime/perl/lib/Clownfish.pm | 8 --
clownfish/runtime/perl/xs/XSBind.c | 1 -
core/Lucy/Analysis/SnowballStopFilter.c | 2 +-
core/Lucy/Index/SortCache/TextSortCache.c | 2 +-
core/Lucy/Util/Freezer.c | 4 +-
core/Lucy/Util/Json.c | 2 +-
example-lang/src/Lucy/Document/Doc.c | 3 +-
perl/xs/Lucy/Document/Doc.c | 2 +-
perl/xs/Lucy/Index/Inverter.c | 2 +-
ruby/src/Lucy/Document/Doc.c | 3 +-
16 files changed, 110 insertions(+), 139 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/c/src/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/DocReader.c b/c/src/Lucy/Index/DocReader.c
index 7904c45..31a1077 100644
--- a/c/src/Lucy/Index/DocReader.c
+++ b/c/src/Lucy/Index/DocReader.c
@@ -77,8 +77,7 @@ DefDocReader_Fetch_Doc_IMP(DefaultDocReader *self, int32_t doc_id) {
char *buf = (char*)MALLOCATE(value_len + 1);
InStream_Read_Bytes(dat_in, buf, value_len);
buf[value_len] = '\0';
- value
- = (Obj*)Str_new_steal_from_trusted_str(buf, value_len);
+ value = (Obj*)Str_new_steal_utf8(buf, value_len);
break;
}
case FType_BLOB: {
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/core/Clownfish/CharBuf.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.c b/clownfish/runtime/core/Clownfish/CharBuf.c
index 7b407ad..bfbae45 100644
--- a/clownfish/runtime/core/Clownfish/CharBuf.c
+++ b/clownfish/runtime/core/Clownfish/CharBuf.c
@@ -304,7 +304,7 @@ CB_To_String_IMP(CharBuf *self) {
String*
CB_Yield_String_IMP(CharBuf *self) {
String *retval
- = Str_new_steal_from_trusted_str(self->ptr, self->size);
+ = Str_new_steal_trusted_utf8(self->ptr, self->size);
self->ptr = NULL;
self->size = 0;
self->cap = 0;
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/core/Clownfish/Num.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Num.c b/clownfish/runtime/core/Clownfish/Num.c
index 728c618..f18bf76 100644
--- a/clownfish/runtime/core/Clownfish/Num.c
+++ b/clownfish/runtime/core/Clownfish/Num.c
@@ -22,7 +22,6 @@
#define C_CFISH_FLOAT32
#define C_CFISH_FLOAT64
#define C_CFISH_BOOLNUM
-#define C_CFISH_VIEWCHARBUF
#define CFISH_USE_SHORT_NAMES
#define CHY_USE_SHORT_NAMES
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index 96cf22f..c917a79 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -15,7 +15,6 @@
*/
#define C_CFISH_STRING
-#define C_CFISH_VIEWCHARBUF
#define C_CFISH_STACKSTRING
#define C_CFISH_STRINGITERATOR
#define C_CFISH_STACKSTRINGITERATOR
@@ -53,18 +52,18 @@ S_die_invalid_utf8(const char *text, size_t size, const char *file, int line,
const char *func);
String*
-Str_new_from_utf8(const char *ptr, size_t size) {
- if (!StrHelp_utf8_valid(ptr, size)) {
- DIE_INVALID_UTF8(ptr, size);
+Str_new_from_utf8(const char *utf8, size_t size) {
+ if (!StrHelp_utf8_valid(utf8, size)) {
+ DIE_INVALID_UTF8(utf8, size);
}
String *self = (String*)VTable_Make_Obj(STRING);
- return Str_init_from_trusted_utf8(self, ptr, size);
+ return Str_init_from_trusted_utf8(self, utf8, size);
}
String*
-Str_new_from_trusted_utf8(const char *ptr, size_t size) {
+Str_new_from_trusted_utf8(const char *utf8, size_t size) {
String *self = (String*)VTable_Make_Obj(STRING);
- return Str_init_from_trusted_utf8(self, ptr, size);
+ return Str_init_from_trusted_utf8(self, utf8, size);
}
String*
@@ -77,31 +76,57 @@ Str_init_from_trusted_utf8(String *self, const char *utf8, size_t size) {
ptr[size] = '\0'; // Null terminate.
// Assign.
- self->ptr = ptr;
- self->size = size;
+ self->ptr = ptr;
+ self->size = size;
+ self->origin = self;
return self;
}
String*
-Str_new_steal_from_trusted_str(const char *ptr, size_t size) {
+Str_new_steal_utf8(const char *utf8, size_t size) {
+ if (!StrHelp_utf8_valid(utf8, size)) {
+ DIE_INVALID_UTF8(utf8, size);
+ }
+ String *self = (String*)VTable_Make_Obj(STRING);
+ return Str_init_steal_trusted_utf8(self, utf8, size);
+}
+
+String*
+Str_new_steal_trusted_utf8(const char *utf8, size_t size) {
String *self = (String*)VTable_Make_Obj(STRING);
- return Str_init_steal_trusted_str(self, ptr, size);
+ return Str_init_steal_trusted_utf8(self, utf8, size);
}
String*
-Str_init_steal_trusted_str(String *self, const char *ptr, size_t size) {
- self->ptr = ptr;
- self->size = size;
+Str_init_steal_trusted_utf8(String *self, const char *utf8, size_t size) {
+ self->ptr = utf8;
+ self->size = size;
+ self->origin = self;
return self;
}
String*
-Str_new_steal_str(const char *ptr, size_t size) {
- if (!StrHelp_utf8_valid(ptr, size)) {
- DIE_INVALID_UTF8(ptr, size);
+Str_new_wrap_utf8(const char *utf8, size_t size) {
+ if (!StrHelp_utf8_valid(utf8, size)) {
+ DIE_INVALID_UTF8(utf8, size);
}
- return Str_new_steal_from_trusted_str(ptr, size);
+ String *self = (String*)VTable_Make_Obj(STRING);
+ return Str_init_wrap_trusted_utf8(self, utf8, size);
+}
+
+String*
+Str_new_wrap_trusted_utf8(const char *utf8, size_t size) {
+ String *self = (String*)VTable_Make_Obj(STRING);
+ return Str_init_wrap_trusted_utf8(self, utf8, size);
+}
+
+String*
+Str_init_wrap_trusted_utf8(String *self, const char *ptr, size_t size) {
+ self->ptr = ptr;
+ self->size = size;
+ self->origin = NULL;
+ return self;
}
String*
@@ -112,8 +137,9 @@ Str_new_from_char(uint32_t code_point) {
ptr[size] = '\0';
String *self = (String*)VTable_Make_Obj(STRING);
- self->ptr = ptr;
- self->size = size;
+ self->ptr = ptr;
+ self->size = size;
+ self->origin = self;
return self;
}
@@ -129,9 +155,23 @@ Str_newf(const char *pattern, ...) {
return self;
}
+static String*
+S_new_substring(String *origin, 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);
+ return self;
+}
+
void
Str_Destroy_IMP(String *self) {
- FREEMEM((char*)self->ptr);
+ if (self->origin == self) {
+ FREEMEM((char*)self->ptr);
+ }
+ else {
+ DECREF(self->origin);
+ }
SUPER_DESTROY(self, STRING);
}
@@ -275,7 +315,7 @@ Str_Cat_Trusted_Utf8_IMP(String *self, const char* ptr, size_t size) {
memcpy(result_ptr + self->size, ptr, size);
result_ptr[result_size] = '\0';
String *result = (String*)VTable_Make_Obj(STRING);
- return Str_init_steal_trusted_str(result, result_ptr, result_size);
+ return Str_init_steal_trusted_utf8(result, result_ptr, result_size);
}
bool
@@ -411,13 +451,12 @@ Str_SubString_IMP(String *self, size_t offset, size_t len) {
StackStringIterator *iter = STR_STACKTOP(self);
SStrIter_Advance(iter, offset);
- int start_offset = iter->byte_offset;
- const char *sub_start = self->ptr + start_offset;
+ size_t start_offset = iter->byte_offset;
SStrIter_Advance(iter, len);
- size_t byte_len = iter->byte_offset - start_offset;
+ size_t size = iter->byte_offset - start_offset;
- return Str_new_from_trusted_utf8(sub_start, byte_len);
+ return S_new_substring(self, start_offset, size);
}
int
@@ -480,46 +519,6 @@ Str_StackTail_IMP(String *self, void *allocation) {
/*****************************************************************/
-ViewCharBuf*
-ViewCB_new_from_utf8(const char *utf8, size_t size) {
- if (!StrHelp_utf8_valid(utf8, size)) {
- DIE_INVALID_UTF8(utf8, size);
- }
- return ViewCB_new_from_trusted_utf8(utf8, size);
-}
-
-ViewCharBuf*
-ViewCB_new_from_trusted_utf8(const char *utf8, size_t size) {
- ViewCharBuf *self = (ViewCharBuf*)VTable_Make_Obj(VIEWCHARBUF);
- return ViewCB_init(self, utf8, size);
-}
-
-ViewCharBuf*
-ViewCB_init(ViewCharBuf *self, const char *utf8, size_t size) {
- self->ptr = utf8;
- self->size = size;
- return self;
-}
-
-void
-ViewCB_Destroy_IMP(ViewCharBuf *self) {
- // Note that we do not free self->ptr, and that we invoke the
- // SUPER_DESTROY with STRING instead of VIEWCHARBUF.
- SUPER_DESTROY(self, STRING);
-}
-
-/*****************************************************************/
-
-StackString*
-SStr_new(void *allocation) {
- static char empty_string[] = "";
- StackString *self
- = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
- self->size = 0;
- self->ptr = empty_string;
- return self;
-}
-
StackString*
SStr_new_from_str(void *allocation, size_t alloc_size, String *string) {
size_t size = string->size;
@@ -533,8 +532,9 @@ SStr_new_from_str(void *allocation, size_t alloc_size, String *string) {
ptr[size] = '\0';
StackString *self = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
- self->ptr = ptr;
- self->size = size;
+ self->ptr = ptr;
+ self->size = size;
+ self->origin = NULL;
return self;
}
@@ -542,8 +542,9 @@ StackString*
SStr_wrap_str(void *allocation, const char *ptr, size_t size) {
StackString *self
= (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
- self->size = size;
- self->ptr = ptr;
+ self->size = size;
+ self->ptr = ptr;
+ self->origin = NULL;
return self;
}
@@ -607,8 +608,7 @@ StrIter_substring(StringIterator *top, StringIterator *tail) {
}
}
- return Str_new_from_trusted_utf8(string->ptr + top_offset,
- tail_offset - top_offset);
+ return S_new_substring(string, top_offset, tail_offset - top_offset);
}
StringIterator*
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index f64b73a..a1a0378 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -25,6 +25,7 @@ class Clownfish::String cnick Str
const char *ptr;
size_t size;
+ String *origin;
/** Return a new String which holds a copy of the passed-in string.
* Check for UTF-8 validity.
@@ -48,19 +49,39 @@ class Clownfish::String cnick Str
* passed-in string. Check validity of supplied UTF-8.
*/
inert incremented String*
- new_steal_str(const char *ptr, size_t size);
+ new_steal_utf8(const char *utf8, size_t size);
/** Return a pointer to a new String which assumes ownership of the
* passed-in string. Do not check validity of supplied UTF-8.
*/
inert incremented String*
- new_steal_from_trusted_str(const char *ptr, size_t size);
+ new_steal_trusted_utf8(const char *utf8, size_t size);
/** Initialize the String using the passed-in string. Do not check
* validity of supplied UTF-8.
*/
public inert String*
- init_steal_trusted_str(String *self, const char *ptr, size_t size);
+ init_steal_trusted_utf8(String *self, const char *utf8, size_t size);
+
+ /** Return a pointer to a new String which wraps an external buffer
+ * containing UTF-8. The buffer must stay unchanged for the lifetime
+ * of the String. Check validity of supplied UTF-8.
+ */
+ inert incremented String*
+ new_wrap_utf8(const char *utf8, size_t size);
+
+ /** Return a pointer to a new String which wraps an external buffer
+ * containing UTF-8. The buffer must stay unchanged for the lifetime
+ * of the String. Do not check validity of supplied UTF-8.
+ */
+ inert incremented String*
+ new_wrap_trusted_utf8(const char *utf8, size_t size);
+
+ /** Initialize the String which wraps an external buffer containing
+ * UTF-8. Do not check validity of supplied UTF-8.
+ */
+ public inert String*
+ init_wrap_trusted_utf8(String *self, const char *utf8, size_t size);
/** Return a String which holds a single character.
*/
@@ -256,29 +277,8 @@ class Clownfish::String cnick Str
StackTail(String *self, void *allocation);
}
-class Clownfish::ViewCharBuf cnick ViewCB
- inherits Clownfish::String {
-
- inert incremented ViewCharBuf*
- new_from_utf8(const char *utf8, size_t size);
-
- inert incremented ViewCharBuf*
- new_from_trusted_utf8(const char *utf8, size_t size);
-
- inert ViewCharBuf*
- init(ViewCharBuf *self, const char *utf8, size_t size);
-
- public void
- Destroy(ViewCharBuf *self);
-}
-
class Clownfish::StackString cnick SStr
- inherits Clownfish::ViewCharBuf {
-
- /** Return a StackString with a blank string.
- */
- inert incremented StackString*
- new(void *allocation);
+ inherits Clownfish::String {
/**
* @param allocation A single block of memory which will be used for both
@@ -424,7 +424,8 @@ class Clownfish::StackStringIterator cnick SStrIter
__C__
-#define CFISH_SSTR_BLANK() cfish_SStr_new(cfish_alloca(cfish_SStr_size()))
+#define CFISH_SSTR_BLANK() \
+ cfish_SStr_wrap_str(cfish_alloca(cfish_SStr_size()), "", 0)
#define CFISH_SSTR_WRAP(source) \
cfish_SStr_wrap(cfish_alloca(cfish_SStr_size()), source)
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index 2d7ef0e..7743525 100644
--- a/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -176,23 +176,6 @@ to_perl(self)
CODE:
RETVAL = XSBind_str_to_sv(self);
OUTPUT: RETVAL
-
-MODULE = Clownfish PACKAGE = Clownfish::ViewCharBuf
-
-SV*
-_new(unused, sv)
- SV *unused;
- SV *sv;
-CODE:
-{
- STRLEN size;
- char *ptr = SvPVutf8(sv, size);
- cfish_ViewCharBuf *self
- = cfish_ViewCB_new_from_trusted_utf8(ptr, size);
- CFISH_UNUSED_VAR(unused);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
-}
-OUTPUT: RETVAL
END_XS_CODE
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/perl/lib/Clownfish.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish.pm b/clownfish/runtime/perl/lib/Clownfish.pm
index 7a4f961..d683245 100644
--- a/clownfish/runtime/perl/lib/Clownfish.pm
+++ b/clownfish/runtime/perl/lib/Clownfish.pm
@@ -162,14 +162,6 @@ sub error {$Clownfish::Err::error}
}
{
- package Clownfish::ViewCharBuf;
- our $VERSION = '0.003000';
- $VERSION = eval $VERSION;
- use Carp;
- sub new { confess "ViewCharBuf has no public constructor." }
-}
-
-{
package Clownfish::StackString;
our $VERSION = '0.003000';
$VERSION = eval $VERSION;
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/xs/XSBind.c b/clownfish/runtime/perl/xs/XSBind.c
index ea7700d..755667a 100644
--- a/clownfish/runtime/perl/xs/XSBind.c
+++ b/clownfish/runtime/perl/xs/XSBind.c
@@ -96,7 +96,6 @@ XSBind_maybe_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable, void *allocation) {
}
else if (allocation &&
(vtable == CFISH_STACKSTRING
- || vtable == CFISH_VIEWCHARBUF
|| vtable == CFISH_STRING
|| vtable == CFISH_OBJ)
) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/core/Lucy/Analysis/SnowballStopFilter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/SnowballStopFilter.c b/core/Lucy/Analysis/SnowballStopFilter.c
index 4aa9d16..f4c995e 100644
--- a/core/Lucy/Analysis/SnowballStopFilter.c
+++ b/core/Lucy/Analysis/SnowballStopFilter.c
@@ -144,7 +144,7 @@ SnowStop_gen_stoplist(const String *language) {
NoCloneHash *stoplist = NoCloneHash_new(num_stopwords);
for (uint32_t i = 0; words[i] != NULL; i++) {
char *word = (char*)words[i];
- ViewCharBuf *stop = ViewCB_new_from_trusted_utf8(word, strlen(word));
+ String *stop = Str_new_wrap_trusted_utf8(word, strlen(word));
NoCloneHash_Store(stoplist, (Obj*)stop, (Obj*)Str_newf(""));
DECREF(stop);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/core/Lucy/Index/SortCache/TextSortCache.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortCache/TextSortCache.c b/core/Lucy/Index/SortCache/TextSortCache.c
index afd5b50..ad533a4 100644
--- a/core/Lucy/Index/SortCache/TextSortCache.c
+++ b/core/Lucy/Index/SortCache/TextSortCache.c
@@ -115,7 +115,7 @@ TextSortCache_Value_IMP(TextSortCache *self, int32_t ord) {
InStream_Seek(ivars->dat_in, offset);
InStream_Read_Bytes(ivars->dat_in, ptr, len);
ptr[len] = '\0';
- return (Obj*)Str_new_steal_str(ptr, len);
+ return (Obj*)Str_new_steal_utf8(ptr, len);
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/core/Lucy/Util/Freezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c
index 5452728..ea22431 100644
--- a/core/Lucy/Util/Freezer.c
+++ b/core/Lucy/Util/Freezer.c
@@ -222,7 +222,7 @@ Freezer_deserialize_string(String *string, InStream *instream) {
if (!StrHelp_utf8_valid(buf, size)) {
THROW(ERR, "Attempt to deserialize invalid UTF-8");
}
- return Str_init_steal_trusted_str(string, buf, size);
+ return Str_init_steal_trusted_utf8(string, buf, size);
}
String*
@@ -338,7 +338,7 @@ Freezer_deserialize_hash(Hash *hash, InStream *instream) {
char *key_buf = (char*)MALLOCATE(len + 1);
InStream_Read_Bytes(instream, key_buf, len);
key_buf[len] = '\0';
- String *key = Str_new_steal_from_trusted_str(key_buf, len);
+ String *key = Str_new_steal_utf8(key_buf, len);
Hash_Store(hash, (Obj*)key, THAW(instream));
DECREF(key);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index 5fedf1e..c877b74 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -654,7 +654,7 @@ S_unescape_text(const char *top, const char *end) {
Err_set_error(Err_new(mess));
return NULL;
}
- return Str_new_steal_from_trusted_str(target_buf, target_size);
+ return Str_new_steal_trusted_utf8(target_buf, target_size);
}
static CFISH_INLINE bool
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/example-lang/src/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/example-lang/src/Lucy/Document/Doc.c b/example-lang/src/Lucy/Document/Doc.c
index db1d8f7..1ec532d 100644
--- a/example-lang/src/Lucy/Document/Doc.c
+++ b/example-lang/src/Lucy/Document/Doc.c
@@ -55,8 +55,7 @@ lucy_Doc_deserialize(lucy_Doc *self, lucy_InStream *instream) {
}
lucy_Obj*
-lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field,
- lucy_ViewCharBuf *target) {
+lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field) {
THROW(LUCY_ERR, "TODO");
UNREACHABLE_RETURN(lucy_Obj*);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/perl/xs/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Document/Doc.c b/perl/xs/Lucy/Document/Doc.c
index f31eca3..f74ed22 100644
--- a/perl/xs/Lucy/Document/Doc.c
+++ b/perl/xs/Lucy/Document/Doc.c
@@ -158,7 +158,7 @@ LUCY_Doc_Extract_IMP(lucy_Doc *self, cfish_String *field) {
else {
STRLEN size;
char *ptr = SvPVutf8(sv, size);
- retval = (cfish_Obj*)cfish_ViewCB_new_from_trusted_utf8(ptr, size);
+ retval = (cfish_Obj*)cfish_Str_new_wrap_trusted_utf8(ptr, size);
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/perl/xs/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Index/Inverter.c b/perl/xs/Lucy/Index/Inverter.c
index 1d120b1..23eb9ab 100644
--- a/perl/xs/Lucy/Index/Inverter.c
+++ b/perl/xs/Lucy/Index/Inverter.c
@@ -101,7 +101,7 @@ LUCY_Inverter_Invert_Doc_IMP(lucy_Inverter *self, lucy_Doc *doc) {
char *val_ptr = SvPVutf8(value_sv, val_len);
CFISH_DECREF(entry_ivars->value);
entry_ivars->value
- = (cfish_Obj*)cfish_ViewCB_new_from_trusted_utf8(
+ = (cfish_Obj*)cfish_Str_new_wrap_trusted_utf8(
val_ptr, val_len);
break;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/ruby/src/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/ruby/src/Lucy/Document/Doc.c b/ruby/src/Lucy/Document/Doc.c
index db1d8f7..1ec532d 100644
--- a/ruby/src/Lucy/Document/Doc.c
+++ b/ruby/src/Lucy/Document/Doc.c
@@ -55,8 +55,7 @@ lucy_Doc_deserialize(lucy_Doc *self, lucy_InStream *instream) {
}
lucy_Obj*
-lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field,
- lucy_ViewCharBuf *target) {
+lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field) {
THROW(LUCY_ERR, "TODO");
UNREACHABLE_RETURN(lucy_Obj*);
}
[lucy-commits] [14/15] git commit: refs/heads/cfish-string-prep1 - Rework previous
change to SortFieldWriter
Posted by nw...@apache.org.
Rework previous change to SortFieldWriter
I'm still not sure whether this is safe.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/3c9c7da1
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/3c9c7da1
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/3c9c7da1
Branch: refs/heads/cfish-string-prep1
Commit: 3c9c7da1336ca9c2ed02fcd4539010a128060908
Parents: 6f3f752
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 21:07:44 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 21:07:44 2013 +0200
----------------------------------------------------------------------
core/Lucy/Index/SortFieldWriter.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/3c9c7da1/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index 86bb84d..bf08089 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -552,7 +552,7 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, OutStream *ix_out,
ords[0] = 0;
// Build array of ords, write non-NULL sorted values.
- Obj *val = elem->value;
+ Obj *val = INCREF(elem->value);
Obj *last_val_address = elem->value;
S_write_val(elem->value, prim_id, ix_out, dat_out, dat_start);
while (NULL != (elem = (SFWriterElem*)SortFieldWriter_Fetch(self))) {
@@ -562,12 +562,14 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, OutStream *ix_out,
if (comparison != 0) {
ord++;
S_write_val(elem->value, prim_id, ix_out, dat_out, dat_start);
- val = elem->value;
+ DECREF(val);
+ val = INCREF(elem->value);
}
last_val_address = elem->value;
}
ords[elem->doc_id] = ord;
}
+ DECREF(val);
// If there are NULL values, write one now and record the NULL ord.
if (has_nulls) {
[lucy-commits] [06/15] git commit: refs/heads/cfish-string-prep1 - Introduce
Str_To_Utf8
Posted by nw...@apache.org.
Introduce Str_To_Utf8
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/41a5ef76
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/41a5ef76
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/41a5ef76
Branch: refs/heads/cfish-string-prep1
Commit: 41a5ef761e57f45a7725976aafe4a23390702fea
Parents: 3804cbc
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 16:45:35 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 16:45:35 2013 +0200
----------------------------------------------------------------------
clownfish/runtime/core/Clownfish/String.c | 9 ++++++---
clownfish/runtime/core/Clownfish/String.cfh | 8 ++++----
clownfish/runtime/core/Clownfish/Test/TestString.c | 15 ++++++++++++++-
3 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/41a5ef76/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index d68aacf..0fb4c5f 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -237,9 +237,12 @@ Str_To_F64_IMP(String *self) {
return value;
}
-String*
-Str_To_CB8_IMP(String *self) {
- return Str_new_from_trusted_utf8(self->ptr, self->size);
+char*
+Str_To_Utf8_IMP(String *self) {
+ char *buf = (char*)MALLOCATE(self->size + 1);
+ memcpy(buf, self->ptr, self->size);
+ buf[self->size] = '\0'; // NULL-terminate.
+ return buf;
}
String*
http://git-wip-us.apache.org/repos/asf/lucy/blob/41a5ef76/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index 22138db..41ca029 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -173,11 +173,11 @@ class Clownfish::String cnick Str
uint8_t*
Get_Ptr8(String *self);
- /** Return a fresh copy of the string data in a String with an internal
- * encoding of UTF-8.
+ /** Return a NULL-terminated copy of the string data in UTF-8 encoding.
+ * The buffer must be freed by the caller.
*/
- String*
- To_CB8(String *self);
+ char*
+ To_Utf8(String *self);
public incremented String*
Clone(String *self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/41a5ef76/clownfish/runtime/core/Clownfish/Test/TestString.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestString.c b/clownfish/runtime/core/Clownfish/Test/TestString.c
index 2b7e911..851ff81 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestString.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestString.c
@@ -31,8 +31,10 @@
#include "Clownfish/Test.h"
#include "Clownfish/TestHarness/TestBatchRunner.h"
#include "Clownfish/TestHarness/TestUtils.h"
+#include "Clownfish/Util/Memory.h"
#include "Clownfish/VTable.h"
+#define SMILEY "\xE2\x98\xBA"
static char smiley[] = { (char)0xE2, (char)0x98, (char)0xBA, 0 };
static uint32_t smiley_len = 3;
static uint32_t smiley_cp = 0x263A;
@@ -263,6 +265,16 @@ test_To_I64(TestBatchRunner *runner) {
}
static void
+test_To_Utf8(TestBatchRunner *runner) {
+ String *string = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
+ char *buf = Str_To_Utf8(string);
+ TEST_TRUE(runner, strcmp(buf, "a" SMILEY SMILEY "b" SMILEY "c") == 0,
+ "To_Utf8");
+ FREEMEM(buf);
+ DECREF(string);
+}
+
+static void
test_Length(TestBatchRunner *runner) {
String *string = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
TEST_INT_EQ(runner, Str_Length(string), 6, "Length");
@@ -495,7 +507,7 @@ test_iterator_substring(TestBatchRunner *runner) {
void
TestStr_Run_IMP(TestString *self, TestBatchRunner *runner) {
- TestBatchRunner_Plan(runner, (TestBatch*)self, 100);
+ TestBatchRunner_Plan(runner, (TestBatch*)self, 101);
test_Cat(runner);
test_Clone(runner);
test_Code_Point_At_and_From(runner);
@@ -504,6 +516,7 @@ TestStr_Run_IMP(TestString *self, TestBatchRunner *runner) {
test_Trim(runner);
test_To_F64(runner);
test_To_I64(runner);
+ test_To_Utf8(runner);
test_Length(runner);
test_Compare_To(runner);
test_Swap_Chars(runner);
[lucy-commits] [07/15] git commit: refs/heads/cfish-string-prep1 - Use Str_To_Utf8
to get NULL-terminated C strings
Posted by nw...@apache.org.
Use Str_To_Utf8 to get NULL-terminated C strings
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/235519b2
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/235519b2
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/235519b2
Branch: refs/heads/cfish-string-prep1
Commit: 235519b29ffd9cdc62e4282e53f434fa3641f470
Parents: 41a5ef7
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 18:28:53 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 18:28:53 2013 +0200
----------------------------------------------------------------------
c/sample/getting_started.c | 4 +-
c/src/Lucy/Analysis/RegexTokenizer.c | 7 +-
clownfish/runtime/c/src/Clownfish/Err.c | 9 +-
.../core/Clownfish/TestHarness/TestFormatter.c | 5 +-
clownfish/runtime/perl/xs/XSBind.c | 2 +
core/Lucy/Store/FSDirHandle.c | 12 ++-
core/Lucy/Store/FSFileHandle.c | 12 ++-
core/Lucy/Store/FSFolder.c | 100 ++++++++++++-------
8 files changed, 101 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/235519b2/c/sample/getting_started.c
----------------------------------------------------------------------
diff --git a/c/sample/getting_started.c b/c/sample/getting_started.c
index 2816a30..f7bbcfe 100644
--- a/c/sample/getting_started.c
+++ b/c/sample/getting_started.c
@@ -175,9 +175,11 @@ S_search(IndexSearcher *searcher, const char *query) {
// Loop over search results.
while (NULL != (hit = Hits_Next(hits))) {
String *value_str = (String*)HitDoc_Extract(hit, field_str);
+ char *value = Str_To_Utf8(value_str);
- printf("Result %d: %s\n", i, Str_Get_Ptr8(value_str));
+ printf("Result %d: %s\n", i, value);
+ DECREF(value);
DECREF(value_str);
DECREF(hit);
i++;
http://git-wip-us.apache.org/repos/asf/lucy/blob/235519b2/c/src/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Analysis/RegexTokenizer.c b/c/src/Lucy/Analysis/RegexTokenizer.c
index bb3f96b..62085cb 100644
--- a/c/src/Lucy/Analysis/RegexTokenizer.c
+++ b/c/src/Lucy/Analysis/RegexTokenizer.c
@@ -48,10 +48,12 @@ RegexTokenizer_init(RegexTokenizer *self, const String *pattern) {
Analyzer_init((Analyzer*)self);
RegexTokenizerIVARS *const ivars = RegexTokenizer_IVARS(self);
+ char *pattern_buf = NULL;
const char *pattern_ptr;
if (pattern) {
ivars->pattern = Str_Clone(pattern);
- pattern_ptr = (char*)Str_Get_Ptr8(ivars->pattern);
+ pattern_buf = Str_To_Utf8(ivars->pattern);
+ pattern_ptr = pattern_buf;
}
else {
pattern_ptr = "\\w+(?:['\\x{2019}]\\w+)*";
@@ -71,6 +73,9 @@ RegexTokenizer_init(RegexTokenizer *self, const String *pattern) {
const char *err_ptr;
int err_offset;
pcre *re = pcre_compile(pattern_ptr, options, &err_ptr, &err_offset, NULL);
+ if (pattern_buf) {
+ FREEMEM(pattern_buf);
+ }
if (!re) {
THROW(ERR, "%s", err_ptr);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/235519b2/clownfish/runtime/c/src/Clownfish/Err.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/c/src/Clownfish/Err.c b/clownfish/runtime/c/src/Clownfish/Err.c
index ae13494..b360d5a 100644
--- a/clownfish/runtime/c/src/Clownfish/Err.c
+++ b/clownfish/runtime/c/src/Clownfish/Err.c
@@ -26,6 +26,7 @@
#include "Clownfish/Err.h"
#include "Clownfish/String.h"
+#include "Clownfish/Util/Memory.h"
#include "Clownfish/VTable.h"
/* TODO: Thread safety */
@@ -58,7 +59,9 @@ Err_do_throw(Err *error) {
}
else {
String *message = Err_Get_Mess(error);
- fprintf(stderr, "%s", Str_Get_Ptr8(message));
+ char *utf8 = Str_To_Utf8(message);
+ fprintf(stderr, "%s", utf8);
+ FREEMEM(utf8);
exit(EXIT_FAILURE);
}
}
@@ -78,7 +81,9 @@ Err_throw_mess(VTable *vtable, String *message) {
void
Err_warn_mess(String *message) {
- fprintf(stderr, "%s", Str_Get_Ptr8(message));
+ char *utf8 = Str_To_Utf8(message);
+ fprintf(stderr, "%s", utf8);
+ FREEMEM(utf8);
DECREF(message);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/235519b2/clownfish/runtime/core/Clownfish/TestHarness/TestFormatter.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/TestHarness/TestFormatter.c b/clownfish/runtime/core/Clownfish/TestHarness/TestFormatter.c
index 6088c89..c5016be 100644
--- a/clownfish/runtime/core/Clownfish/TestHarness/TestFormatter.c
+++ b/clownfish/runtime/core/Clownfish/TestHarness/TestFormatter.c
@@ -28,6 +28,7 @@
#include "Clownfish/Err.h"
#include "Clownfish/TestHarness/TestBatch.h"
#include "Clownfish/TestHarness/TestSuiteRunner.h"
+#include "Clownfish/Util/Memory.h"
#include "Clownfish/VTable.h"
TestFormatter*
@@ -79,7 +80,9 @@ TestFormatterCF_Batch_Prologue_IMP(TestFormatterCF *self, TestBatch *batch,
UNUSED_VAR(self);
UNUSED_VAR(num_planned);
String *class_name = TestBatch_Get_Class_Name(batch);
- printf("Running %s...\n", Str_Get_Ptr8(class_name));
+ char *utf8 = Str_To_Utf8(class_name);
+ printf("Running %s...\n", utf8);
+ FREEMEM(utf8);
}
void
http://git-wip-us.apache.org/repos/asf/lucy/blob/235519b2/clownfish/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/xs/XSBind.c b/clownfish/runtime/perl/xs/XSBind.c
index 379bc7d..0f21e50 100644
--- a/clownfish/runtime/perl/xs/XSBind.c
+++ b/clownfish/runtime/perl/xs/XSBind.c
@@ -85,6 +85,8 @@ cfish_Obj*
XSBind_maybe_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable, void *allocation) {
cfish_Obj *retval = NULL;
if (XSBind_sv_defined(sv)) {
+ // Assume that the class name is always NULL-terminated. Somewhat
+ // dangerous but should be safe.
if (sv_isobject(sv)
&& sv_derived_from(sv, (char*)CFISH_Str_Get_Ptr8(CFISH_VTable_Get_Name(vtable)))
) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/235519b2/core/Lucy/Store/FSDirHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSDirHandle.c b/core/Lucy/Store/FSDirHandle.c
index 631f2f6..6fcf793 100644
--- a/core/Lucy/Store/FSDirHandle.c
+++ b/core/Lucy/Store/FSDirHandle.c
@@ -208,13 +208,13 @@ FSDH_Next_IMP(FSDirHandle *self) {
FSDirHandle*
FSDH_do_open(FSDirHandle *self, const String *dir) {
- char *dir_path_ptr = (char*)Str_Get_Ptr8(dir);
-
DH_init((DirHandle*)self, dir);
FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
ivars->sys_dir_entry = NULL;
+ char *dir_path_ptr = Str_To_Utf8(dir);
ivars->sys_dirhandle = opendir(dir_path_ptr);
+ FREEMEM(dir_path_ptr);
if (!ivars->sys_dirhandle) {
Err_set_error(Err_new(Str_newf("Failed to opendir '%o'", dir)));
DECREF(self);
@@ -272,9 +272,11 @@ FSDH_Entry_Is_Dir_IMP(FSDirHandle *self) {
struct stat stat_buf;
String *fullpath = Str_newf("%o%s%o", ivars->dir, CHY_DIR_SEP,
ivars->entry);
- if (stat((char*)Str_Get_Ptr8(fullpath), &stat_buf) != -1) {
+ char *fullpath_ptr = Str_To_Utf8(fullpath);
+ if (stat(fullpath_ptr, &stat_buf) != -1) {
if (stat_buf.st_mode & S_IFDIR) { retval = true; }
}
+ FREEMEM(fullpath_ptr);
DECREF(fullpath);
return retval;
}
@@ -293,9 +295,11 @@ FSDH_Entry_Is_Symlink_IMP(FSDirHandle *self) {
struct stat stat_buf;
String *fullpath = Str_newf("%o%s%o", ivars->dir, CHY_DIR_SEP,
ivars->entry);
- if (stat((char*)Str_Get_Ptr8(fullpath), &stat_buf) != -1) {
+ char *fullpath_ptr = Str_To_Utf8(fullpath);
+ if (stat(fullpath_ptr, &stat_buf) != -1) {
if (stat_buf.st_mode & S_IFLNK) { retval = true; }
}
+ FREEMEM(fullpath_ptr);
DECREF(fullpath);
return retval;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/235519b2/core/Lucy/Store/FSFileHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFileHandle.c b/core/Lucy/Store/FSFileHandle.c
index 020eb9f..1f8b831 100644
--- a/core/Lucy/Store/FSFileHandle.c
+++ b/core/Lucy/Store/FSFileHandle.c
@@ -100,7 +100,9 @@ FSFH_do_open(FSFileHandle *self, const String *path, uint32_t flags) {
// Attempt to open file.
if (flags & FH_WRITE_ONLY) {
- ivars->fd = open((char*)Str_Get_Ptr8(path), SI_posix_flags(flags), 0666);
+ char *path_ptr = Str_To_Utf8(path);
+ ivars->fd = open(path_ptr, SI_posix_flags(flags), 0666);
+ FREEMEM(path_ptr);
if (ivars->fd == -1) {
ivars->fd = 0;
Err_set_error(Err_new(Str_newf("Attempt to open '%o' failed: %s",
@@ -330,8 +332,9 @@ SI_init_read_only(FSFileHandle *self, FSFileHandleIVARS *ivars) {
UNUSED_VAR(self);
// Open.
- ivars->fd = open((char*)Str_Get_Ptr8(ivars->path),
- SI_posix_flags(ivars->flags), 0666);
+ char *path_ptr = Str_To_Utf8(ivars->path);
+ ivars->fd = open(path_ptr, SI_posix_flags(ivars->flags), 0666);
+ FREEMEM(path_ptr);
if (ivars->fd == -1) {
ivars->fd = 0;
Err_set_error(Err_new(Str_newf("Can't open '%o': %s", ivars->path,
@@ -438,7 +441,7 @@ FSFH_Read_IMP(FSFileHandle *self, char *dest, int64_t offset, size_t len) {
static CFISH_INLINE bool
SI_init_read_only(FSFileHandle *self, FSFileHandleIVARS *ivars) {
- char *filepath = (char*)Str_Get_Ptr8(ivars->path);
+ char *filepath = Str_To_Utf8(ivars->path);
SYSTEM_INFO sys_info;
// Get system page size.
@@ -455,6 +458,7 @@ SI_init_read_only(FSFileHandle *self, FSFileHandleIVARS *ivars) {
FILE_ATTRIBUTE_READONLY | FILE_FLAG_OVERLAPPED,
NULL
);
+ FREEMEM(filepath);
if (ivars->win_fhandle == INVALID_HANDLE_VALUE) {
char *win_error = Err_win_error();
Err_set_error(Err_new(Str_newf("CreateFile for %o failed: %s",
http://git-wip-us.apache.org/repos/asf/lucy/blob/235519b2/core/Lucy/Store/FSFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFolder.c b/core/Lucy/Store/FSFolder.c
index 70522f3..eb1c54f 100644
--- a/core/Lucy/Store/FSFolder.c
+++ b/core/Lucy/Store/FSFolder.c
@@ -50,6 +50,10 @@
static String*
S_fullpath(FSFolder *self, const String *path);
+// Return a String containing a platform-specific absolute filepath.
+static char*
+S_fullpath_ptr(FSFolder *self, const String *path);
+
// Return true if the supplied path is a directory.
static bool
S_dir_ok(const String *path);
@@ -72,7 +76,7 @@ S_absolutify(const String *path);
// Create a hard link.
static bool
-S_hard_link(String *from_path, String *to_path);
+S_hard_link(char *from_path, char *to_path);
FSFolder*
FSFolder_new(const String *path) {
@@ -142,12 +146,12 @@ FSFolder_Local_Exists_IMP(FSFolder *self, const String *name) {
}
else {
struct stat stat_buf;
- String *fullpath = S_fullpath(self, name);
+ char *fullpath_ptr = S_fullpath_ptr(self, name);
bool retval = false;
- if (stat((char*)Str_Get_Ptr8(fullpath), &stat_buf) != -1) {
+ if (stat(fullpath_ptr, &stat_buf) != -1) {
retval = true;
}
- DECREF(fullpath);
+ FREEMEM(fullpath_ptr);
return retval;
}
}
@@ -171,27 +175,26 @@ FSFolder_Local_Is_Directory_IMP(FSFolder *self, const String *name) {
bool
FSFolder_Rename_IMP(FSFolder *self, const String* from, const String *to) {
- String *from_path = S_fullpath(self, from);
- String *to_path = S_fullpath(self, to);
- bool retval = !rename((char*)Str_Get_Ptr8(from_path),
- (char*)Str_Get_Ptr8(to_path));
+ char *from_path = S_fullpath_ptr(self, from);
+ char *to_path = S_fullpath_ptr(self, to);
+ bool retval = !rename(from_path, to_path);
if (!retval) {
- Err_set_error(Err_new(Str_newf("rename from '%o' to '%o' failed: %s",
+ Err_set_error(Err_new(Str_newf("rename from '%s' to '%s' failed: %s",
from_path, to_path, strerror(errno))));
}
- DECREF(from_path);
- DECREF(to_path);
+ FREEMEM(from_path);
+ FREEMEM(to_path);
return retval;
}
bool
FSFolder_Hard_Link_IMP(FSFolder *self, const String *from,
const String *to) {
- String *from_path = S_fullpath(self, from);
- String *to_path = S_fullpath(self, to);
- bool retval = S_hard_link(from_path, to_path);
- DECREF(from_path);
- DECREF(to_path);
+ char *from_path_ptr = S_fullpath_ptr(self, from);
+ char *to_path_ptr = S_fullpath_ptr(self, to);
+ bool retval = S_hard_link(from_path_ptr, to_path_ptr);
+ FREEMEM(from_path_ptr);
+ FREEMEM(to_path_ptr);
return retval;
}
@@ -199,15 +202,14 @@ bool
FSFolder_Local_Delete_IMP(FSFolder *self, const String *name) {
FSFolderIVARS *const ivars = FSFolder_IVARS(self);
- String *fullpath = S_fullpath(self, name);
- char *path_ptr = (char*)Str_Get_Ptr8(fullpath);
+ char *path_ptr = S_fullpath_ptr(self, name);
#ifdef CHY_REMOVE_ZAPS_DIRS
bool result = !remove(path_ptr);
#else
bool result = !rmdir(path_ptr) || !remove(path_ptr);
#endif
DECREF(Hash_Delete(ivars->entries, (Obj*)name));
- DECREF(fullpath);
+ FREEMEM(path_ptr);
return result;
}
@@ -281,23 +283,53 @@ S_fullpath(FSFolder *self, const String *path) {
return retval;
}
+static char*
+S_fullpath_ptr(FSFolder *self, const String *path) {
+ FSFolderIVARS *const ivars = FSFolder_IVARS(self);
+ size_t folder_size = Str_Get_Size(ivars->path);
+ size_t path_size = Str_Get_Size(path);
+ size_t full_size = folder_size + 1 + path_size;
+ const char *folder_ptr = (char*)Str_Get_Ptr8(ivars->path);
+ const char *path_ptr = (char*)Str_Get_Ptr8(path);
+
+ char *buf = (char*)MALLOCATE(full_size + 1);
+ memcpy(buf, folder_ptr, folder_size);
+ buf[folder_size] = DIR_SEP[0];
+ memcpy(buf + folder_size + 1, path_ptr, path_size);
+ buf[full_size] = '\0';
+
+ if (DIR_SEP[0] != '/') {
+ for (size_t i = 0; i < full_size; ++i) {
+ if (buf[i] == '/') { buf[i] = DIR_SEP[0]; }
+ }
+ }
+
+ return buf;
+}
+
static bool
S_dir_ok(const String *path) {
+ bool retval = false;
+ char *path_ptr = Str_To_Utf8(path);
struct stat stat_buf;
- if (stat((char*)Str_Get_Ptr8(path), &stat_buf) != -1) {
- if (stat_buf.st_mode & S_IFDIR) { return true; }
+ if (stat(path_ptr, &stat_buf) != -1) {
+ if (stat_buf.st_mode & S_IFDIR) { retval = true; }
}
- return false;
+ FREEMEM(path_ptr);
+ return retval;
}
static bool
S_create_dir(const String *path) {
- if (-1 == chy_makedir((char*)Str_Get_Ptr8(path), 0777)) {
+ bool retval = true;
+ char *path_ptr = Str_To_Utf8(path);
+ if (-1 == chy_makedir(path_ptr, 0777)) {
Err_set_error(Err_new(Str_newf("Couldn't create directory '%o': %s",
path, strerror(errno))));
- return false;
+ retval = false;
}
- return true;
+ FREEMEM(path_ptr);
+ return retval;
}
static bool
@@ -346,17 +378,14 @@ S_absolutify(const String *path) {
}
static bool
-S_hard_link(String *from_path, String *to_path) {
- char *from8 = (char*)Str_Get_Ptr8(from_path);
- char *to8 = (char*)Str_Get_Ptr8(to_path);
-
+S_hard_link(char *from8, char *to8) {
if (CreateHardLink(to8, from8, NULL)) {
return true;
}
else {
char *win_error = Err_win_error();
- Err_set_error(Err_new(Str_newf("CreateHardLink for new file '%o' from '%o' failed: %s",
- to_path, from_path, win_error)));
+ Err_set_error(Err_new(Str_newf("CreateHardLink for new file '%s' from '%s' failed: %s",
+ to8, from8, win_error)));
FREEMEM(win_error);
return false;
}
@@ -382,13 +411,10 @@ S_absolutify(const String *path) {
}
static bool
-S_hard_link(String *from_path, String *to_path) {
- char *from8 = (char*)Str_Get_Ptr8(from_path);
- char *to8 = (char*)Str_Get_Ptr8(to_path);
-
+S_hard_link(char *from8, char *to8) {
if (-1 == link(from8, to8)) {
- Err_set_error(Err_new(Str_newf("hard link for new file '%o' from '%o' failed: %s",
- to_path, from_path, strerror(errno))));
+ Err_set_error(Err_new(Str_newf("hard link for new file '%s' from '%s' failed: %s",
+ to8, from8, strerror(errno))));
return false;
}
else {
[lucy-commits] [05/15] git commit: refs/heads/cfish-string-prep1 - Rename _UTF8 and
_Str to _Utf8
Posted by nw...@apache.org.
Rename _UTF8 and _Str to _Utf8
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/3804cbc3
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/3804cbc3
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/3804cbc3
Branch: refs/heads/cfish-string-prep1
Commit: 3804cbc34cb9d6343fb4d10dd83b44a3f4bc2489
Parents: 9dbac05
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 16:22:34 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 16:34:17 2013 +0200
----------------------------------------------------------------------
c/src/Lucy/Analysis/RegexTokenizer.c | 8 ++--
c/src/Lucy/Index/DocReader.c | 2 +-
clownfish/runtime/core/Clownfish/CharBuf.c | 28 ++++++------
clownfish/runtime/core/Clownfish/CharBuf.cfh | 6 +--
clownfish/runtime/core/Clownfish/Err.c | 2 +-
clownfish/runtime/core/Clownfish/Hash.c | 6 +--
clownfish/runtime/core/Clownfish/Hash.cfh | 8 ++--
clownfish/runtime/core/Clownfish/String.c | 34 +++++++--------
clownfish/runtime/core/Clownfish/String.cfh | 16 +++----
.../runtime/core/Clownfish/Test/TestCharBuf.c | 12 ++---
.../runtime/core/Clownfish/Test/TestHash.c | 6 +--
clownfish/runtime/core/Clownfish/Test/TestNum.c | 12 ++---
clownfish/runtime/core/Clownfish/Test/TestObj.c | 4 +-
.../runtime/core/Clownfish/Test/TestString.c | 20 ++++-----
.../runtime/core/Clownfish/Test/TestVArray.c | 10 ++---
clownfish/runtime/core/Clownfish/VTable.c | 2 +-
clownfish/runtime/perl/xs/XSBind.c | 8 ++--
core/Lucy/Analysis/Analyzer.c | 6 +--
core/Lucy/Analysis/EasyAnalyzer.c | 4 +-
core/Lucy/Analysis/Normalizer.c | 20 ++++-----
core/Lucy/Analysis/PolyAnalyzer.c | 6 +--
core/Lucy/Analysis/RegexTokenizer.c | 12 ++---
core/Lucy/Analysis/RegexTokenizer.cfh | 4 +-
core/Lucy/Analysis/SnowballStemmer.c | 4 +-
core/Lucy/Analysis/SnowballStopFilter.c | 8 ++--
core/Lucy/Analysis/StandardTokenizer.c | 12 ++---
core/Lucy/Analysis/StandardTokenizer.cfh | 4 +-
core/Lucy/Document/HitDoc.c | 4 +-
core/Lucy/Highlight/Highlighter.c | 8 ++--
core/Lucy/Index/BackgroundMerger.c | 4 +-
core/Lucy/Index/DataWriter.c | 4 +-
core/Lucy/Index/DeletionsReader.c | 8 ++--
core/Lucy/Index/DeletionsWriter.c | 20 ++++-----
core/Lucy/Index/DocReader.c | 4 +-
core/Lucy/Index/DocVector.c | 2 +-
core/Lucy/Index/DocWriter.c | 4 +-
core/Lucy/Index/FilePurger.c | 8 ++--
core/Lucy/Index/HighlightReader.c | 6 +--
core/Lucy/Index/HighlightWriter.c | 4 +-
core/Lucy/Index/IndexManager.c | 10 ++---
core/Lucy/Index/Indexer.c | 10 ++---
core/Lucy/Index/LexiconWriter.c | 14 +++---
core/Lucy/Index/PolyReader.c | 4 +-
core/Lucy/Index/PostingListReader.c | 6 +--
core/Lucy/Index/PostingListWriter.c | 4 +-
core/Lucy/Index/SegLexicon.c | 6 +--
core/Lucy/Index/Segment.c | 32 +++++++-------
core/Lucy/Index/Segment.cfh | 6 +--
core/Lucy/Index/Similarity.c | 6 +--
core/Lucy/Index/Snapshot.c | 18 ++++----
core/Lucy/Index/SortReader.c | 10 ++---
core/Lucy/Index/SortWriter.c | 10 ++---
core/Lucy/Plan/BlobType.c | 22 +++++-----
core/Lucy/Plan/FullTextType.c | 36 +++++++--------
core/Lucy/Plan/NumericType.c | 36 +++++++--------
core/Lucy/Plan/Schema.c | 40 ++++++++---------
core/Lucy/Plan/StringType.c | 26 +++++------
core/Lucy/Search/ANDQuery.c | 4 +-
core/Lucy/Search/Compiler.c | 2 +-
core/Lucy/Search/LeafQuery.c | 8 ++--
core/Lucy/Search/NoMatchQuery.c | 6 +--
core/Lucy/Search/ORQuery.c | 4 +-
core/Lucy/Search/PhraseQuery.c | 14 +++---
core/Lucy/Search/PolyQuery.c | 4 +-
core/Lucy/Search/Query.c | 12 ++---
core/Lucy/Search/QueryParser.c | 10 ++---
core/Lucy/Search/QueryParser/QueryLexer.c | 2 +-
core/Lucy/Search/RangeQuery.c | 28 ++++++------
core/Lucy/Search/TermQuery.c | 8 ++--
core/Lucy/Store/CompoundFileReader.c | 8 ++--
core/Lucy/Store/CompoundFileWriter.c | 16 +++----
core/Lucy/Store/FSFolder.c | 6 +--
core/Lucy/Store/Folder.c | 4 +-
core/Lucy/Store/Lock.c | 16 +++----
core/Lucy/Store/SharedLock.c | 8 ++--
core/Lucy/Test/Analysis/TestNormalizer.c | 10 ++---
core/Lucy/Test/Analysis/TestSnowballStemmer.c | 4 +-
.../Lucy/Test/Analysis/TestSnowballStopFilter.c | 4 +-
core/Lucy/Test/Analysis/TestStandardTokenizer.c | 14 +++---
core/Lucy/Test/Highlight/TestHighlighter.c | 36 +++++++--------
core/Lucy/Test/Index/TestSegment.c | 16 +++----
core/Lucy/Test/Plan/TestFullTextType.c | 2 +-
core/Lucy/Test/Search/TestQueryParserSyntax.c | 2 +-
core/Lucy/Test/Search/TestSortSpec.c | 4 +-
core/Lucy/Test/Store/TestCompoundFileReader.c | 12 ++---
core/Lucy/Test/Store/TestCompoundFileWriter.c | 4 +-
core/Lucy/Test/Store/TestFSFolder.c | 2 +-
core/Lucy/Test/Store/TestFileHandle.c | 2 +-
core/Lucy/Test/Store/TestRAMFileHandle.c | 2 +-
core/Lucy/Test/Store/TestRAMFolder.c | 2 +-
core/Lucy/Test/Util/TestIndexFileNames.c | 2 +-
core/Lucy/Test/Util/TestJson.c | 10 ++---
core/Lucy/Util/Freezer.c | 2 +-
core/Lucy/Util/IndexFileNames.c | 4 +-
core/Lucy/Util/Json.c | 46 ++++++++++----------
core/LucyX/Search/ProximityQuery.c | 20 ++++-----
perl/xs/Lucy/Analysis/RegexTokenizer.c | 10 ++---
perl/xs/Lucy/Document/Doc.c | 18 ++++----
98 files changed, 512 insertions(+), 512 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/c/src/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Analysis/RegexTokenizer.c b/c/src/Lucy/Analysis/RegexTokenizer.c
index 4780430..bb3f96b 100644
--- a/c/src/Lucy/Analysis/RegexTokenizer.c
+++ b/c/src/Lucy/Analysis/RegexTokenizer.c
@@ -101,8 +101,8 @@ RegexTokenizer_Destroy_IMP(RegexTokenizer *self) {
}
void
-RegexTokenizer_Tokenize_Str_IMP(RegexTokenizer *self, const char *string,
- size_t string_len, Inversion *inversion) {
+RegexTokenizer_Tokenize_Utf8_IMP(RegexTokenizer *self, const char *string,
+ size_t string_len, Inversion *inversion) {
RegexTokenizerIVARS *const ivars = RegexTokenizer_IVARS(self);
pcre *re = (pcre*)ivars->token_re;
int byte_offset = 0;
@@ -189,8 +189,8 @@ RegexTokenizer_Destroy_IMP(RegexTokenizer *self) {
}
void
-RegexTokenizer_Tokenize_Str_IMP(RegexTokenizer *self, const char *string,
- size_t string_len, Inversion *inversion) {
+RegexTokenizer_Tokenize_Utf8_IMP(RegexTokenizer *self, const char *string,
+ size_t string_len, Inversion *inversion) {
UNUSED_VAR(self);
UNUSED_VAR(string);
UNUSED_VAR(string_len);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/c/src/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/DocReader.c b/c/src/Lucy/Index/DocReader.c
index dc3619b..7904c45 100644
--- a/c/src/Lucy/Index/DocReader.c
+++ b/c/src/Lucy/Index/DocReader.c
@@ -111,7 +111,7 @@ DefDocReader_Fetch_Doc_IMP(DefaultDocReader *self, int32_t doc_id) {
}
// Store the value.
- Hash_Store_Str(fields, field_name, field_name_len, value);
+ Hash_Store_Utf8(fields, field_name, field_name_len, value);
}
FREEMEM(field_name);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/CharBuf.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.c b/clownfish/runtime/core/Clownfish/CharBuf.c
index 74919dd..9f48caa 100644
--- a/clownfish/runtime/core/Clownfish/CharBuf.c
+++ b/clownfish/runtime/core/Clownfish/CharBuf.c
@@ -173,7 +173,7 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list args) {
while (slice_end < pattern_end && *slice_end != '%') { slice_end++; }
if (pattern != slice_end) {
size_t size = slice_end - pattern;
- CB_Cat_Trusted_UTF8(self, pattern, size);
+ CB_Cat_Trusted_Utf8(self, pattern, size);
pattern = slice_end;
}
@@ -182,13 +182,13 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list args) {
switch (*pattern) {
case '%': {
- CB_Cat_Trusted_UTF8(self, "%", 1);
+ CB_Cat_Trusted_Utf8(self, "%", 1);
}
break;
case 'o': {
Obj *obj = va_arg(args, Obj*);
if (!obj) {
- CB_Cat_Trusted_UTF8(self, "[NULL]", 6);
+ CB_Cat_Trusted_Utf8(self, "[NULL]", 6);
}
else if (Obj_Is_A(obj, STRING)) {
CB_Cat(self, (String*)obj);
@@ -219,7 +219,7 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list args) {
S_die_invalid_pattern(pattern_start);
}
size = sprintf(buf, "%" PRId64, val);
- CB_Cat_Trusted_UTF8(self, buf, size);
+ CB_Cat_Trusted_Utf8(self, buf, size);
}
break;
case 'u': {
@@ -241,7 +241,7 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list args) {
S_die_invalid_pattern(pattern_start);
}
size = sprintf(buf, "%" PRIu64, val);
- CB_Cat_Trusted_UTF8(self, buf, size);
+ CB_Cat_Trusted_Utf8(self, buf, size);
}
break;
case 'f': {
@@ -249,7 +249,7 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list args) {
double num = va_arg(args, double);
char bigbuf[512];
size_t size = sprintf(bigbuf, "%g", num);
- CB_Cat_Trusted_UTF8(self, bigbuf, size);
+ CB_Cat_Trusted_Utf8(self, bigbuf, size);
pattern += 2;
}
else {
@@ -261,7 +261,7 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list args) {
if (pattern[1] == '3' && pattern[2] == '2') {
unsigned long val = va_arg(args, uint32_t);
size_t size = sprintf(buf, "%.8lx", val);
- CB_Cat_Trusted_UTF8(self, buf, size);
+ CB_Cat_Trusted_Utf8(self, buf, size);
pattern += 2;
}
else {
@@ -272,15 +272,15 @@ CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list args) {
case 's': {
char *string = va_arg(args, char*);
if (string == NULL) {
- CB_Cat_Trusted_UTF8(self, "[NULL]", 6);
+ CB_Cat_Trusted_Utf8(self, "[NULL]", 6);
}
else {
size_t size = strlen(string);
if (StrHelp_utf8_valid(string, size)) {
- CB_Cat_Trusted_UTF8(self, string, size);
+ CB_Cat_Trusted_Utf8(self, string, size);
}
else {
- CB_Cat_Trusted_UTF8(self, "[INVALID UTF8]", 14);
+ CB_Cat_Trusted_Utf8(self, "[INVALID UTF8]", 14);
}
}
}
@@ -330,7 +330,7 @@ CB_Clone_IMP(CharBuf *self) {
}
void
-CB_Mimic_UTF8_IMP(CharBuf *self, const char* ptr, size_t size) {
+CB_Mimic_Utf8_IMP(CharBuf *self, const char* ptr, size_t size) {
if (!StrHelp_utf8_valid(ptr, size)) {
DIE_INVALID_UTF8(ptr, size);
}
@@ -362,15 +362,15 @@ CB_Mimic_IMP(CharBuf *self, Obj *other) {
}
void
-CB_Cat_UTF8_IMP(CharBuf *self, const char* ptr, size_t size) {
+CB_Cat_Utf8_IMP(CharBuf *self, const char* ptr, size_t size) {
if (!StrHelp_utf8_valid(ptr, size)) {
DIE_INVALID_UTF8(ptr, size);
}
- CB_Cat_Trusted_UTF8_IMP(self, ptr, size);
+ CB_Cat_Trusted_Utf8_IMP(self, ptr, size);
}
void
-CB_Cat_Trusted_UTF8_IMP(CharBuf *self, const char* ptr, size_t size) {
+CB_Cat_Trusted_Utf8_IMP(CharBuf *self, const char* ptr, size_t size) {
const size_t new_size = self->size + size;
if (new_size >= self->cap) {
size_t amount = Memory_oversize(new_size, sizeof(char));
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/CharBuf.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.cfh b/clownfish/runtime/core/Clownfish/CharBuf.cfh
index a08ba4f..da48822 100644
--- a/clownfish/runtime/core/Clownfish/CharBuf.cfh
+++ b/clownfish/runtime/core/Clownfish/CharBuf.cfh
@@ -63,18 +63,18 @@ class Clownfish::CharBuf cnick CB
Mimic(CharBuf *self, Obj *other);
void
- Mimic_UTF8(CharBuf *self, const char *ptr, size_t size);
+ Mimic_Utf8(CharBuf *self, const char *ptr, size_t size);
/** Concatenate the passed-in string onto the end of the CharBuf.
*/
void
- Cat_UTF8(CharBuf *self, const char *ptr, size_t size);
+ Cat_Utf8(CharBuf *self, const char *ptr, size_t size);
/** Concatenate the supplied text onto the end of the CharBuf. Don't
* check for UTF-8 validity.
*/
void
- Cat_Trusted_UTF8(CharBuf *self, const char *ptr, size_t size);
+ Cat_Trusted_Utf8(CharBuf *self, const char *ptr, size_t size);
/** Concatenate the contents of <code>string</code> onto the end of the
* caller.
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Err.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Err.c b/clownfish/runtime/core/Clownfish/Err.c
index 92050cc..30199a3 100644
--- a/clownfish/runtime/core/Clownfish/Err.c
+++ b/clownfish/runtime/core/Clownfish/Err.c
@@ -157,7 +157,7 @@ void
Err_Add_Frame_IMP(Err *self, const char *file, int line, const char *func) {
CharBuf *buf = CB_new_from_str(self->mess);
- if (!Str_Ends_With_Str(self->mess, "\n", 1)) {
+ if (!Str_Ends_With_Utf8(self->mess, "\n", 1)) {
CB_Cat_Char(buf, '\n');
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Hash.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Hash.c b/clownfish/runtime/core/Clownfish/Hash.c
index 7e3fb2e..02e9794 100644
--- a/clownfish/runtime/core/Clownfish/Hash.c
+++ b/clownfish/runtime/core/Clownfish/Hash.c
@@ -159,7 +159,7 @@ Hash_Store_IMP(Hash *self, Obj *key, Obj *value) {
}
void
-Hash_Store_Str_IMP(Hash *self, const char *key, size_t key_len, Obj *value) {
+Hash_Store_Utf8_IMP(Hash *self, const char *key, size_t key_len, Obj *value) {
StackString *key_buf = SSTR_WRAP_STR((char*)key, key_len);
Hash_do_store(self, (Obj*)key_buf, value,
SStr_Hash_Sum(key_buf), false);
@@ -173,7 +173,7 @@ Hash_Make_Key_IMP(Hash *self, Obj *key, int32_t hash_sum) {
}
Obj*
-Hash_Fetch_Str_IMP(Hash *self, const char *key, size_t key_len) {
+Hash_Fetch_Utf8_IMP(Hash *self, const char *key, size_t key_len) {
StackString *key_buf = SSTR_WRAP_STR(key, key_len);
return Hash_Fetch_IMP(self, (Obj*)key_buf);
}
@@ -225,7 +225,7 @@ Hash_Delete_IMP(Hash *self, const Obj *key) {
}
Obj*
-Hash_Delete_Str_IMP(Hash *self, const char *key, size_t key_len) {
+Hash_Delete_Utf8_IMP(Hash *self, const char *key, size_t key_len) {
StackString *key_buf = SSTR_WRAP_STR(key, key_len);
return Hash_Delete_IMP(self, (Obj*)key_buf);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Hash.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Hash.cfh b/clownfish/runtime/core/Clownfish/Hash.cfh
index 397cc2d..5f289fd 100644
--- a/clownfish/runtime/core/Clownfish/Hash.cfh
+++ b/clownfish/runtime/core/Clownfish/Hash.cfh
@@ -57,8 +57,8 @@ class Clownfish::Hash inherits Clownfish::Obj {
Store(Hash *self, Obj *key, decremented Obj *value);
void
- Store_Str(Hash *self, const char *str, size_t len,
- decremented Obj *value);
+ Store_Utf8(Hash *self, const char *str, size_t len,
+ decremented Obj *value);
/** Fetch the value associated with <code>key</code>.
*
@@ -68,7 +68,7 @@ class Clownfish::Hash inherits Clownfish::Obj {
Fetch(Hash *self, const Obj *key);
nullable Obj*
- Fetch_Str(Hash *self, const char *key, size_t key_len);
+ Fetch_Utf8(Hash *self, const char *key, size_t key_len);
/** Attempt to delete a key-value pair from the hash.
*
@@ -79,7 +79,7 @@ class Clownfish::Hash inherits Clownfish::Obj {
Delete(Hash *self, const Obj *key);
incremented nullable Obj*
- Delete_Str(Hash *self, const char *key, size_t key_ley);
+ Delete_Utf8(Hash *self, const char *key, size_t key_ley);
/** Prepare to iterate over all the key-value pairs in the hash.
*
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index d39f271..d68aacf 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -249,19 +249,19 @@ Str_Clone_IMP(String *self) {
String*
Str_Cat_IMP(String *self, const String *other) {
- return Str_Cat_Trusted_UTF8(self, other->ptr, other->size);
+ return Str_Cat_Trusted_Utf8(self, other->ptr, other->size);
}
String*
-Str_Cat_UTF8_IMP(String *self, const char* ptr, size_t size) {
+Str_Cat_Utf8_IMP(String *self, const char* ptr, size_t size) {
if (!StrHelp_utf8_valid(ptr, size)) {
DIE_INVALID_UTF8(ptr, size);
}
- return Str_Cat_Trusted_UTF8(self, ptr, size);
+ return Str_Cat_Trusted_Utf8(self, ptr, size);
}
String*
-Str_Cat_Trusted_UTF8_IMP(String *self, const char* ptr, size_t size) {
+Str_Cat_Trusted_Utf8_IMP(String *self, const char* ptr, size_t size) {
size_t result_size = self->size + size;
char *result_ptr = (char*)MALLOCATE(result_size + 1);
memcpy(result_ptr, self->ptr, self->size);
@@ -273,11 +273,11 @@ Str_Cat_Trusted_UTF8_IMP(String *self, const char* ptr, size_t size) {
bool
Str_Starts_With_IMP(String *self, const String *prefix) {
- return Str_Starts_With_Str_IMP(self, prefix->ptr, prefix->size);
+ return Str_Starts_With_Utf8_IMP(self, prefix->ptr, prefix->size);
}
bool
-Str_Starts_With_Str_IMP(String *self, const char *prefix, size_t size) {
+Str_Starts_With_Utf8_IMP(String *self, const char *prefix, size_t size) {
if (size <= self->size
&& (memcmp(self->ptr, prefix, size) == 0)
) {
@@ -293,7 +293,7 @@ Str_Equals_IMP(String *self, Obj *other) {
String *const twin = (String*)other;
if (twin == self) { return true; }
if (!Obj_Is_A(other, STRING)) { return false; }
- return Str_Equals_Str_IMP(self, twin->ptr, twin->size);
+ return Str_Equals_Utf8_IMP(self, twin->ptr, twin->size);
}
int32_t
@@ -303,7 +303,7 @@ Str_Compare_To_IMP(String *self, Obj *other) {
}
bool
-Str_Equals_Str_IMP(String *self, const char *ptr, size_t size) {
+Str_Equals_Utf8_IMP(String *self, const char *ptr, size_t size) {
if (self->size != size) {
return false;
}
@@ -312,11 +312,11 @@ Str_Equals_Str_IMP(String *self, const char *ptr, size_t size) {
bool
Str_Ends_With_IMP(String *self, const String *postfix) {
- return Str_Ends_With_Str_IMP(self, postfix->ptr, postfix->size);
+ return Str_Ends_With_Utf8_IMP(self, postfix->ptr, postfix->size);
}
bool
-Str_Ends_With_Str_IMP(String *self, const char *postfix, size_t postfix_len) {
+Str_Ends_With_Utf8_IMP(String *self, const char *postfix, size_t postfix_len) {
if (postfix_len <= self->size) {
char *start = self->ptr + self->size - postfix_len;
if (memcmp(start, postfix, postfix_len) == 0) {
@@ -329,11 +329,11 @@ Str_Ends_With_Str_IMP(String *self, const char *postfix, size_t postfix_len) {
int64_t
Str_Find_IMP(String *self, const String *substring) {
- return Str_Find_Str(self, substring->ptr, substring->size);
+ return Str_Find_Utf8(self, substring->ptr, substring->size);
}
int64_t
-Str_Find_Str_IMP(String *self, const char *ptr, size_t size) {
+Str_Find_Utf8_IMP(String *self, const char *ptr, size_t size) {
StackStringIterator *iter = STR_STACKTOP(self);
int64_t location = 0;
@@ -824,11 +824,11 @@ 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);
+ return StrIter_Starts_With_Utf8_IMP(self, prefix->ptr, prefix->size);
}
bool
-StrIter_Starts_With_UTF8_IMP(StringIterator *self, const char *prefix,
+StrIter_Starts_With_Utf8_IMP(StringIterator *self, const char *prefix,
size_t size) {
String *string = self->string;
size_t byte_offset = self->byte_offset;
@@ -844,12 +844,12 @@ StrIter_Starts_With_UTF8_IMP(StringIterator *self, const char *prefix,
bool
StrIter_Ends_With_IMP(StringIterator *self, String *postfix) {
- return StrIter_Ends_With_UTF8_IMP(self, postfix->ptr, postfix->size);
+ return StrIter_Ends_With_Utf8_IMP(self, postfix->ptr, postfix->size);
}
bool
-StrIter_Ends_With_UTF8_IMP(StringIterator *self, const char *postfix,
- size_t size) {
+StrIter_Ends_With_Utf8_IMP(StringIterator *self, const char *postfix,
+ size_t size) {
String *string = self->string;
size_t byte_offset = self->byte_offset;
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index ee78652..22138db 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -97,13 +97,13 @@ class Clownfish::String cnick Str
/** Return the concatenation of the String and the passed-in raw UTF-8.
*/
incremented String*
- Cat_UTF8(String *self, const char *ptr, size_t size);
+ Cat_Utf8(String *self, const char *ptr, size_t size);
/** Return the concatenation of the String and the passed-in raw UTF-8.
* Don't check for UTF-8 validity.
*/
incremented String*
- Cat_Trusted_UTF8(String *self, const char *ptr, size_t size);
+ Cat_Trusted_Utf8(String *self, const char *ptr, size_t size);
/** Replace all instances of one character for the other.
*
@@ -131,7 +131,7 @@ class Clownfish::String cnick Str
/** Test whether the String starts with the passed-in string.
*/
bool
- Starts_With_Str(String *self, const char *prefix, size_t size);
+ Starts_With_Utf8(String *self, const char *prefix, size_t size);
/** Test whether the String ends with the content of another.
*/
@@ -141,7 +141,7 @@ class Clownfish::String cnick Str
/** Test whether the String ends with the passed-in string.
*/
bool
- Ends_With_Str(String *self, const char *postfix, size_t size);
+ Ends_With_Utf8(String *self, const char *postfix, size_t size);
/** Return the location of the substring within the String (measured in
* code points), or -1 if the substring does not match.
@@ -150,12 +150,12 @@ class Clownfish::String cnick Str
Find(String *self, const String *substring);
int64_t
- Find_Str(String *self, const char *ptr, size_t size);
+ Find_Utf8(String *self, const char *ptr, size_t size);
/** Test whether the String matches the passed-in string.
*/
bool
- Equals_Str(String *self, const char *ptr, size_t size);
+ Equals_Utf8(String *self, const char *ptr, size_t size);
/** Return the number of Unicode code points in the object's string.
*/
@@ -394,7 +394,7 @@ class Clownfish::StringIterator cnick StrIter
* string.
*/
bool
- Starts_With_UTF8(StringIterator *self, const char *prefix, size_t size);
+ Starts_With_Utf8(StringIterator *self, const char *prefix, size_t size);
/** Test whether the content before the iterator ends with
* <code>postfix</code>.
@@ -406,7 +406,7 @@ class Clownfish::StringIterator cnick StrIter
* string.
*/
bool
- Ends_With_UTF8(StringIterator *self, const char *postfix, size_t size);
+ Ends_With_Utf8(StringIterator *self, const char *postfix, size_t size);
public void
Destroy(StringIterator *self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Test/TestCharBuf.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestCharBuf.c b/clownfish/runtime/core/Clownfish/Test/TestCharBuf.c
index 31865f9..48c36a1 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestCharBuf.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestCharBuf.c
@@ -74,13 +74,13 @@ test_Cat(TestBatchRunner *runner) {
DECREF(got);
got = S_get_cb("a");
- CB_Cat_UTF8(got, smiley, smiley_len);
- TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_UTF8");
+ CB_Cat_Utf8(got, smiley, smiley_len);
+ TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Utf8");
DECREF(got);
got = S_get_cb("a");
- CB_Cat_Trusted_UTF8(got, smiley, smiley_len);
- TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Trusted_UTF8");
+ CB_Cat_Trusted_Utf8(got, smiley, smiley_len);
+ TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Trusted_Utf8");
DECREF(got);
DECREF(wanted);
@@ -102,8 +102,8 @@ test_Mimic_and_Clone(TestBatchRunner *runner) {
DECREF(got);
got = S_get_cb("bar");
- CB_Mimic_UTF8(got, "foo", 3);
- TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic_Str");
+ CB_Mimic_Utf8(got, "foo", 3);
+ TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic_Utf8");
DECREF(got);
got = CB_Clone(wanted_cb);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Test/TestHash.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestHash.c b/clownfish/runtime/core/Clownfish/Test/TestHash.c
index ef29c7a..ca35f1a 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestHash.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestHash.c
@@ -45,15 +45,15 @@ test_Equals(TestBatchRunner *runner) {
TEST_TRUE(runner, Hash_Equals(hash, (Obj*)other),
"Empty hashes are equal");
- Hash_Store_Str(hash, "foo", 3, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(hash, "foo", 3, (Obj*)CFISH_TRUE);
TEST_FALSE(runner, Hash_Equals(hash, (Obj*)other),
"Add one pair and Equals returns false");
- Hash_Store_Str(other, "foo", 3, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(other, "foo", 3, (Obj*)CFISH_TRUE);
TEST_TRUE(runner, Hash_Equals(hash, (Obj*)other),
"Add a matching pair and Equals returns true");
- Hash_Store_Str(other, "foo", 3, INCREF(stuff));
+ Hash_Store_Utf8(other, "foo", 3, INCREF(stuff));
TEST_FALSE(runner, Hash_Equals(hash, (Obj*)other),
"Non-matching value spoils Equals");
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Test/TestNum.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestNum.c b/clownfish/runtime/core/Clownfish/Test/TestNum.c
index 0334aac..f84c2c0 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestNum.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestNum.c
@@ -44,17 +44,17 @@ test_To_String(TestBatchRunner *runner) {
String *true_string = Bool_To_String(CFISH_TRUE);
String *false_string = Bool_To_String(CFISH_FALSE);
- TEST_TRUE(runner, Str_Starts_With_Str(f32_string, "1.3", 3),
+ TEST_TRUE(runner, Str_Starts_With_Utf8(f32_string, "1.3", 3),
"Float32_To_String");
- TEST_TRUE(runner, Str_Starts_With_Str(f64_string, "1.3", 3),
+ TEST_TRUE(runner, Str_Starts_With_Utf8(f64_string, "1.3", 3),
"Float64_To_String");
- TEST_TRUE(runner, Str_Equals_Str(i32_string, "2147483647", 10),
+ TEST_TRUE(runner, Str_Equals_Utf8(i32_string, "2147483647", 10),
"Int32_To_String");
- TEST_TRUE(runner, Str_Equals_Str(i64_string, "9223372036854775807", 19),
+ TEST_TRUE(runner, Str_Equals_Utf8(i64_string, "9223372036854775807", 19),
"Int64_To_String");
- TEST_TRUE(runner, Str_Equals_Str(true_string, "true", 4),
+ TEST_TRUE(runner, Str_Equals_Utf8(true_string, "true", 4),
"Bool_To_String [true]");
- TEST_TRUE(runner, Str_Equals_Str(false_string, "false", 5),
+ TEST_TRUE(runner, Str_Equals_Utf8(false_string, "false", 5),
"Bool_To_String [false]");
DECREF(false_string);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Test/TestObj.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestObj.c b/clownfish/runtime/core/Clownfish/Test/TestObj.c
index c848b7d..191ec33 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestObj.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestObj.c
@@ -67,7 +67,7 @@ static void
test_To_String(TestBatchRunner *runner) {
Obj *testobj = S_new_testobj();
String *string = Obj_To_String(testobj);
- TEST_TRUE(runner, Str_Find_Str(string, "TestObj", 7) >= 0, "To_String");
+ TEST_TRUE(runner, Str_Find_Utf8(string, "TestObj", 7) >= 0, "To_String");
DECREF(string);
DECREF(testobj);
}
@@ -149,7 +149,7 @@ S_verify_abstract_error(TestBatchRunner *runner, Err_Attempt_t routine,
Err *error = Err_trap(routine, context);
TEST_TRUE(runner, error != NULL
&& Err_Is_A(error, ERR)
- && Str_Find_Str(Err_Get_Mess(error), "bstract", 7) != -1,
+ && Str_Find_Utf8(Err_Get_Mess(error), "bstract", 7) != -1,
message);
DECREF(error);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Test/TestString.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestString.c b/clownfish/runtime/core/Clownfish/Test/TestString.c
index daecdc6..2b7e911 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestString.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestString.c
@@ -84,14 +84,14 @@ test_Cat(TestBatchRunner *runner) {
DECREF(source);
source = S_get_str("a");
- got = Str_Cat_UTF8(source, smiley, smiley_len);
- TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat_UTF8");
+ got = Str_Cat_Utf8(source, smiley, smiley_len);
+ TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat_Utf8");
DECREF(got);
DECREF(source);
source = S_get_str("a");
- got = Str_Cat_Trusted_UTF8(source, smiley, smiley_len);
- TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat_Trusted_UTF8");
+ got = Str_Cat_Trusted_Utf8(source, smiley, smiley_len);
+ TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat_Trusted_Utf8");
DECREF(got);
DECREF(source);
@@ -177,28 +177,28 @@ test_Trim(TestBatchRunner *runner) {
String *got;
got = Str_Trim(ws_smiley);
- TEST_TRUE(runner, Str_Equals_Str(got, smiley, smiley_len), "Trim");
+ TEST_TRUE(runner, Str_Equals_Utf8(got, smiley, smiley_len), "Trim");
DECREF(got);
got = Str_Trim_Top(ws_foo);
- TEST_TRUE(runner, Str_Equals_Str(got, "foo ", 5), "Trim_Top");
+ TEST_TRUE(runner, Str_Equals_Utf8(got, "foo ", 5), "Trim_Top");
DECREF(got);
got = Str_Trim_Tail(ws_foo);
- TEST_TRUE(runner, Str_Equals_Str(got, " foo", 5), "Trim_Tail");
+ TEST_TRUE(runner, Str_Equals_Utf8(got, " foo", 5), "Trim_Tail");
DECREF(got);
got = Str_Trim(ws_only);
- TEST_TRUE(runner, Str_Equals_Str(got, "", 0), "Trim with only whitespace");
+ TEST_TRUE(runner, Str_Equals_Utf8(got, "", 0), "Trim with only whitespace");
DECREF(got);
got = Str_Trim_Top(ws_only);
- TEST_TRUE(runner, Str_Equals_Str(got, "", 0),
+ TEST_TRUE(runner, Str_Equals_Utf8(got, "", 0),
"Trim_Top with only whitespace");
DECREF(got);
got = Str_Trim_Tail(ws_only);
- TEST_TRUE(runner, Str_Equals_Str(got, "", 0),
+ TEST_TRUE(runner, Str_Equals_Utf8(got, "", 0),
"Trim_Tail with only whitespace");
DECREF(got);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/Test/TestVArray.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestVArray.c b/clownfish/runtime/core/Clownfish/Test/TestVArray.c
index 7f7b72b..d22cad0 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestVArray.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestVArray.c
@@ -86,7 +86,7 @@ test_Store_Fetch(TestBatchRunner *runner) {
VA_Store(array, 2, (Obj*)Str_newf("foo"));
elem = (String*)CERTIFY(VA_Fetch(array, 2), STRING);
TEST_INT_EQ(runner, 3, VA_Get_Size(array), "Store updates size");
- TEST_TRUE(runner, Str_Equals_Str(elem, "foo", 3), "Store");
+ TEST_TRUE(runner, Str_Equals_Utf8(elem, "foo", 3), "Store");
INCREF(elem);
TEST_INT_EQ(runner, 2, Str_Get_RefCount(elem),
@@ -96,7 +96,7 @@ test_Store_Fetch(TestBatchRunner *runner) {
"Displacing elem via Store updates refcount");
DECREF(elem);
elem = (String*)CERTIFY(VA_Fetch(array, 2), STRING);
- TEST_TRUE(runner, Str_Equals_Str(elem, "bar", 3), "Store displacement");
+ TEST_TRUE(runner, Str_Equals_Utf8(elem, "bar", 3), "Store displacement");
DECREF(array);
}
@@ -115,18 +115,18 @@ test_Push_Pop_Shift_Unshift(TestBatchRunner *runner) {
TEST_TRUE(runner, NULL != CERTIFY(VA_Fetch(array, 2), STRING), "Push");
elem = (String*)CERTIFY(VA_Shift(array), STRING);
- TEST_TRUE(runner, Str_Equals_Str(elem, "a", 1), "Shift");
+ TEST_TRUE(runner, Str_Equals_Utf8(elem, "a", 1), "Shift");
TEST_INT_EQ(runner, VA_Get_Size(array), 2, "size after Shift");
DECREF(elem);
elem = (String*)CERTIFY(VA_Pop(array), STRING);
- TEST_TRUE(runner, Str_Equals_Str(elem, "c", 1), "Pop");
+ TEST_TRUE(runner, Str_Equals_Utf8(elem, "c", 1), "Pop");
TEST_INT_EQ(runner, VA_Get_Size(array), 1, "size after Pop");
DECREF(elem);
VA_Unshift(array, (Obj*)Str_newf("foo"));
elem = (String*)CERTIFY(VA_Fetch(array, 0), STRING);
- TEST_TRUE(runner, Str_Equals_Str(elem, "foo", 3), "Unshift");
+ TEST_TRUE(runner, Str_Equals_Utf8(elem, "foo", 3), "Unshift");
TEST_INT_EQ(runner, VA_Get_Size(array), 2, "size after Shift");
DECREF(array);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/core/Clownfish/VTable.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/VTable.c b/clownfish/runtime/core/Clownfish/VTable.c
index 67ec977..c2bfde8 100644
--- a/clownfish/runtime/core/Clownfish/VTable.c
+++ b/clownfish/runtime/core/Clownfish/VTable.c
@@ -417,7 +417,7 @@ S_find_method(VTable *self, const char *name) {
for (uint32_t i = 0; i < size; i++) {
Method *method = (Method*)VA_Fetch(self->methods, i);
- if (Str_Equals_Str(method->name, name, name_len)) {
+ if (Str_Equals_Utf8(method->name, name, name_len)) {
return method;
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/clownfish/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/xs/XSBind.c b/clownfish/runtime/perl/xs/XSBind.c
index 39d65d8..379bc7d 100644
--- a/clownfish/runtime/perl/xs/XSBind.c
+++ b/clownfish/runtime/perl/xs/XSBind.c
@@ -252,10 +252,10 @@ S_perl_hash_to_cfish_hash(HV *phash) {
// this.
SV *key_sv = HeKEY_sv(entry);
char *key_str = SvPVutf8(key_sv, key_len);
- CFISH_Hash_Store_Str(retval, key_str, key_len, value);
+ CFISH_Hash_Store_Utf8(retval, key_str, key_len, value);
}
else if (HeKUTF8(entry)) {
- CFISH_Hash_Store_Str(retval, HeKEY(entry), key_len, value);
+ CFISH_Hash_Store_Utf8(retval, HeKEY(entry), key_len, value);
}
else {
char *key_str = HeKEY(entry);
@@ -264,12 +264,12 @@ S_perl_hash_to_cfish_hash(HV *phash) {
if ((key_str[i] & 0x80) == 0x80) { pure_ascii = false; }
}
if (pure_ascii) {
- CFISH_Hash_Store_Str(retval, key_str, key_len, value);
+ CFISH_Hash_Store_Utf8(retval, key_str, key_len, value);
}
else {
SV *key_sv = HeSVKEY_force(entry);
key_str = SvPVutf8(key_sv, key_len);
- CFISH_Hash_Store_Str(retval, key_str, key_len, value);
+ CFISH_Hash_Store_Utf8(retval, key_str, key_len, value);
}
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/Analyzer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/Analyzer.c b/core/Lucy/Analysis/Analyzer.c
index b620e9e..4683276 100644
--- a/core/Lucy/Analysis/Analyzer.c
+++ b/core/Lucy/Analysis/Analyzer.c
@@ -61,8 +61,8 @@ Analyzer_Split_IMP(Analyzer *self, String *text) {
Obj*
Analyzer_Dump_IMP(Analyzer *self) {
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)Str_Clone(Obj_Get_Class_Name((Obj*)self)));
+ Hash_Store_Utf8(dump, "_class", 6,
+ (Obj*)Str_Clone(Obj_Get_Class_Name((Obj*)self)));
return (Obj*)dump;
}
@@ -71,7 +71,7 @@ Analyzer_Load_IMP(Analyzer *self, Obj *dump) {
CHY_UNUSED_VAR(self);
Hash *source = (Hash*)CERTIFY(dump, HASH);
String *class_name
- = (String*)CERTIFY(Hash_Fetch_Str(source, "_class", 6), STRING);
+ = (String*)CERTIFY(Hash_Fetch_Utf8(source, "_class", 6), STRING);
VTable *vtable = VTable_singleton(class_name, NULL);
Analyzer *loaded = (Analyzer*)VTable_Make_Obj(vtable);
return (Obj*)loaded;
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/EasyAnalyzer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/EasyAnalyzer.c b/core/Lucy/Analysis/EasyAnalyzer.c
index f4d0947..136dca9 100644
--- a/core/Lucy/Analysis/EasyAnalyzer.c
+++ b/core/Lucy/Analysis/EasyAnalyzer.c
@@ -78,7 +78,7 @@ EasyAnalyzer_Dump_IMP(EasyAnalyzer *self) {
EasyAnalyzer_Dump_t super_dump
= SUPER_METHOD_PTR(EASYANALYZER, LUCY_EasyAnalyzer_Dump);
Hash *dump = super_dump(self);
- Hash_Store_Str(dump, "language", 8, (Obj*)Str_Clone(ivars->language));
+ Hash_Store_Utf8(dump, "language", 8, (Obj*)Str_Clone(ivars->language));
return dump;
}
@@ -89,7 +89,7 @@ EasyAnalyzer_Load_IMP(EasyAnalyzer *self, Obj *dump) {
EasyAnalyzer *loaded = super_load(self, dump);
Hash *source = (Hash*)CERTIFY(dump, HASH);
String *language
- = (String*)CERTIFY(Hash_Fetch_Str(source, "language", 8), STRING);
+ = (String*)CERTIFY(Hash_Fetch_Utf8(source, "language", 8), STRING);
return EasyAnalyzer_init(loaded, language);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/Normalizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/Normalizer.c b/core/Lucy/Analysis/Normalizer.c
index 924d966..c022f5f 100644
--- a/core/Lucy/Analysis/Normalizer.c
+++ b/core/Lucy/Analysis/Normalizer.c
@@ -40,17 +40,17 @@ Normalizer_init(Normalizer *self, const String *form, bool case_fold,
NormalizerIVARS *const ivars = Normalizer_IVARS(self);
if (form == NULL
- || Str_Equals_Str(form, "NFKC", 4) || Str_Equals_Str(form, "nfkc", 4)
+ || Str_Equals_Utf8(form, "NFKC", 4) || Str_Equals_Utf8(form, "nfkc", 4)
) {
options |= UTF8PROC_COMPOSE | UTF8PROC_COMPAT;
}
- else if (Str_Equals_Str(form, "NFC", 3) || Str_Equals_Str(form, "nfc", 3)) {
+ else if (Str_Equals_Utf8(form, "NFC", 3) || Str_Equals_Utf8(form, "nfc", 3)) {
options |= UTF8PROC_COMPOSE;
}
- else if (Str_Equals_Str(form, "NFKD", 4) || Str_Equals_Str(form, "nfkd", 4)) {
+ else if (Str_Equals_Utf8(form, "NFKD", 4) || Str_Equals_Utf8(form, "nfkd", 4)) {
options |= UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT;
}
- else if (Str_Equals_Str(form, "NFD", 3) || Str_Equals_Str(form, "nfd", 3)) {
+ else if (Str_Equals_Utf8(form, "NFD", 3) || Str_Equals_Utf8(form, "nfd", 3)) {
options |= UTF8PROC_DECOMPOSE;
}
else {
@@ -133,13 +133,13 @@ Normalizer_Dump_IMP(Normalizer *self) {
Str_new_from_trusted_utf8("NFKD", 4) :
Str_new_from_trusted_utf8("NFD", 3);
- Hash_Store_Str(dump, "normalization_form", 18, (Obj*)form);
+ Hash_Store_Utf8(dump, "normalization_form", 18, (Obj*)form);
BoolNum *case_fold = Bool_singleton(options & UTF8PROC_CASEFOLD);
- Hash_Store_Str(dump, "case_fold", 9, (Obj*)case_fold);
+ Hash_Store_Utf8(dump, "case_fold", 9, (Obj*)case_fold);
BoolNum *strip_accents = Bool_singleton(options & UTF8PROC_STRIPMARK);
- Hash_Store_Str(dump, "strip_accents", 13, (Obj*)strip_accents);
+ Hash_Store_Utf8(dump, "strip_accents", 13, (Obj*)strip_accents);
return dump;
}
@@ -151,11 +151,11 @@ Normalizer_Load_IMP(Normalizer *self, Obj *dump) {
Normalizer *loaded = super_load(self, dump);
Hash *source = (Hash*)CERTIFY(dump, HASH);
- Obj *obj = Hash_Fetch_Str(source, "normalization_form", 18);
+ Obj *obj = Hash_Fetch_Utf8(source, "normalization_form", 18);
String *form = (String*)CERTIFY(obj, STRING);
- obj = Hash_Fetch_Str(source, "case_fold", 9);
+ obj = Hash_Fetch_Utf8(source, "case_fold", 9);
bool case_fold = Bool_Get_Value((BoolNum*)CERTIFY(obj, BOOLNUM));
- obj = Hash_Fetch_Str(source, "strip_accents", 13);
+ obj = Hash_Fetch_Utf8(source, "strip_accents", 13);
bool strip_accents = Bool_Get_Value((BoolNum*)CERTIFY(obj, BOOLNUM));
return Normalizer_init(loaded, form, case_fold, strip_accents);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/PolyAnalyzer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/PolyAnalyzer.c b/core/Lucy/Analysis/PolyAnalyzer.c
index 00f8a4a..59ba1d9 100644
--- a/core/Lucy/Analysis/PolyAnalyzer.c
+++ b/core/Lucy/Analysis/PolyAnalyzer.c
@@ -128,8 +128,8 @@ PolyAnalyzer_Dump_IMP(PolyAnalyzer *self) {
= SUPER_METHOD_PTR(POLYANALYZER, LUCY_PolyAnalyzer_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
if (ivars->analyzers) {
- Hash_Store_Str(dump, "analyzers", 9,
- Freezer_dump((Obj*)ivars->analyzers));
+ Hash_Store_Utf8(dump, "analyzers", 9,
+ Freezer_dump((Obj*)ivars->analyzers));
}
return (Obj*)dump;
}
@@ -141,7 +141,7 @@ PolyAnalyzer_Load_IMP(PolyAnalyzer *self, Obj *dump) {
= SUPER_METHOD_PTR(POLYANALYZER, LUCY_PolyAnalyzer_Load);
PolyAnalyzer *loaded = super_load(self, dump);
VArray *analyzer_dumps
- = (VArray*)CERTIFY(Hash_Fetch_Str(source, "analyzers", 9), VARRAY);
+ = (VArray*)CERTIFY(Hash_Fetch_Utf8(source, "analyzers", 9), VARRAY);
VArray *analyzers
= (VArray*)CERTIFY(Freezer_load((Obj*)analyzer_dumps), VARRAY);
PolyAnalyzer_init(loaded, NULL, analyzers);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/RegexTokenizer.c b/core/Lucy/Analysis/RegexTokenizer.c
index ee8be64..3b9e6fa 100644
--- a/core/Lucy/Analysis/RegexTokenizer.c
+++ b/core/Lucy/Analysis/RegexTokenizer.c
@@ -35,8 +35,8 @@ RegexTokenizer_Transform_IMP(RegexTokenizer *self, Inversion *inversion) {
while (NULL != (token = Inversion_Next(inversion))) {
TokenIVARS *const token_ivars = Token_IVARS(token);
- RegexTokenizer_Tokenize_Str(self, token_ivars->text, token_ivars->len,
- new_inversion);
+ RegexTokenizer_Tokenize_Utf8(self, token_ivars->text, token_ivars->len,
+ new_inversion);
}
return new_inversion;
@@ -45,8 +45,8 @@ RegexTokenizer_Transform_IMP(RegexTokenizer *self, Inversion *inversion) {
Inversion*
RegexTokenizer_Transform_Text_IMP(RegexTokenizer *self, String *text) {
Inversion *new_inversion = Inversion_new(NULL);
- RegexTokenizer_Tokenize_Str(self, (char*)Str_Get_Ptr8(text),
- Str_Get_Size(text), new_inversion);
+ RegexTokenizer_Tokenize_Utf8(self, (char*)Str_Get_Ptr8(text),
+ Str_Get_Size(text), new_inversion);
return new_inversion;
}
@@ -56,7 +56,7 @@ RegexTokenizer_Dump_IMP(RegexTokenizer *self) {
RegexTokenizer_Dump_t super_dump
= SUPER_METHOD_PTR(REGEXTOKENIZER, LUCY_RegexTokenizer_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
- Hash_Store_Str(dump, "pattern", 7, (Obj*)Str_Clone(ivars->pattern));
+ Hash_Store_Utf8(dump, "pattern", 7, (Obj*)Str_Clone(ivars->pattern));
return (Obj*)dump;
}
@@ -67,7 +67,7 @@ RegexTokenizer_Load_IMP(RegexTokenizer *self, Obj *dump) {
= SUPER_METHOD_PTR(REGEXTOKENIZER, LUCY_RegexTokenizer_Load);
RegexTokenizer *loaded = super_load(self, dump);
String *pattern
- = (String*)CERTIFY(Hash_Fetch_Str(source, "pattern", 7), STRING);
+ = (String*)CERTIFY(Hash_Fetch_Utf8(source, "pattern", 7), STRING);
return RegexTokenizer_init(loaded, pattern);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/RegexTokenizer.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/RegexTokenizer.cfh b/core/Lucy/Analysis/RegexTokenizer.cfh
index fb0fb56..a4bde3c 100644
--- a/core/Lucy/Analysis/RegexTokenizer.cfh
+++ b/core/Lucy/Analysis/RegexTokenizer.cfh
@@ -81,8 +81,8 @@ public class Lucy::Analysis::RegexTokenizer
* supplied Inversion.
*/
void
- Tokenize_Str(RegexTokenizer *self, const char *text, size_t len,
- Inversion *inversion);
+ Tokenize_Utf8(RegexTokenizer *self, const char *text, size_t len,
+ Inversion *inversion);
/** Set the compiled regular expression for matching a token. Also sets
* <code>pattern</code> as a side effect.
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/SnowballStemmer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/SnowballStemmer.c b/core/Lucy/Analysis/SnowballStemmer.c
index 3df82a4..955d2fc 100644
--- a/core/Lucy/Analysis/SnowballStemmer.c
+++ b/core/Lucy/Analysis/SnowballStemmer.c
@@ -90,7 +90,7 @@ SnowStemmer_Dump_IMP(SnowballStemmer *self) {
SnowStemmer_Dump_t super_dump
= SUPER_METHOD_PTR(SNOWBALLSTEMMER, LUCY_SnowStemmer_Dump);
Hash *dump = super_dump(self);
- Hash_Store_Str(dump, "language", 8, (Obj*)Str_Clone(ivars->language));
+ Hash_Store_Utf8(dump, "language", 8, (Obj*)Str_Clone(ivars->language));
return dump;
}
@@ -101,7 +101,7 @@ SnowStemmer_Load_IMP(SnowballStemmer *self, Obj *dump) {
SnowballStemmer *loaded = super_load(self, dump);
Hash *source = (Hash*)CERTIFY(dump, HASH);
String *language
- = (String*)CERTIFY(Hash_Fetch_Str(source, "language", 8), STRING);
+ = (String*)CERTIFY(Hash_Fetch_Utf8(source, "language", 8), STRING);
return SnowStemmer_init(loaded, language);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/SnowballStopFilter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/SnowballStopFilter.c b/core/Lucy/Analysis/SnowballStopFilter.c
index 323c108..4aa9d16 100644
--- a/core/Lucy/Analysis/SnowballStopFilter.c
+++ b/core/Lucy/Analysis/SnowballStopFilter.c
@@ -69,7 +69,7 @@ SnowStop_Transform_IMP(SnowballStopFilter *self, Inversion *inversion) {
while (NULL != (token = Inversion_Next(inversion))) {
TokenIVARS *const token_ivars = Token_IVARS(token);
- if (!Hash_Fetch_Str(stoplist, token_ivars->text, token_ivars->len)) {
+ if (!Hash_Fetch_Utf8(stoplist, token_ivars->text, token_ivars->len)) {
Inversion_Append(new_inversion, (Token*)INCREF(token));
}
}
@@ -97,8 +97,8 @@ SnowStop_Dump_IMP(SnowballStopFilter *self) {
= SUPER_METHOD_PTR(SNOWBALLSTOPFILTER, LUCY_SnowStop_Dump);
Hash *dump = (Hash*)CERTIFY(super_dump(self), HASH);
if (ivars->stoplist) {
- Hash_Store_Str(dump, "stoplist", 8,
- Freezer_dump((Obj*)ivars->stoplist));
+ Hash_Store_Utf8(dump, "stoplist", 8,
+ Freezer_dump((Obj*)ivars->stoplist));
}
return (Obj*)dump;
}
@@ -109,7 +109,7 @@ SnowStop_Load_IMP(SnowballStopFilter *self, Obj *dump) {
SnowStop_Load_t super_load
= SUPER_METHOD_PTR(SNOWBALLSTOPFILTER, LUCY_SnowStop_Load);
SnowballStopFilter *loaded = (SnowballStopFilter*)super_load(self, dump);
- Obj *stoplist = Hash_Fetch_Str(source, "stoplist", 8);
+ Obj *stoplist = Hash_Fetch_Utf8(source, "stoplist", 8);
if (stoplist) {
SnowStop_IVARS(loaded)->stoplist
= (Hash*)CERTIFY(Freezer_load(stoplist), HASH);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/StandardTokenizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/StandardTokenizer.c b/core/Lucy/Analysis/StandardTokenizer.c
index eaa68f5..8db94ec 100644
--- a/core/Lucy/Analysis/StandardTokenizer.c
+++ b/core/Lucy/Analysis/StandardTokenizer.c
@@ -87,8 +87,8 @@ StandardTokenizer_Transform_IMP(StandardTokenizer *self, Inversion *inversion) {
while (NULL != (token = Inversion_Next(inversion))) {
TokenIVARS *const token_ivars = Token_IVARS(token);
- StandardTokenizer_Tokenize_Str(self, token_ivars->text,
- token_ivars->len, new_inversion);
+ StandardTokenizer_Tokenize_Utf8(self, token_ivars->text,
+ token_ivars->len, new_inversion);
}
return new_inversion;
@@ -97,14 +97,14 @@ StandardTokenizer_Transform_IMP(StandardTokenizer *self, Inversion *inversion) {
Inversion*
StandardTokenizer_Transform_Text_IMP(StandardTokenizer *self, String *text) {
Inversion *new_inversion = Inversion_new(NULL);
- StandardTokenizer_Tokenize_Str(self, (char*)Str_Get_Ptr8(text),
- Str_Get_Size(text), new_inversion);
+ StandardTokenizer_Tokenize_Utf8(self, (char*)Str_Get_Ptr8(text),
+ Str_Get_Size(text), new_inversion);
return new_inversion;
}
void
-StandardTokenizer_Tokenize_Str_IMP(StandardTokenizer *self, const char *text,
- size_t len, Inversion *inversion) {
+StandardTokenizer_Tokenize_Utf8_IMP(StandardTokenizer *self, const char *text,
+ size_t len, Inversion *inversion) {
UNUSED_VAR(self);
if ((len >= 1 && (uint8_t)text[len - 1] >= 0xC0)
|| (len >= 2 && (uint8_t)text[len - 2] >= 0xE0)
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Analysis/StandardTokenizer.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/StandardTokenizer.cfh b/core/Lucy/Analysis/StandardTokenizer.cfh
index 6e4041a..2bac5c7 100644
--- a/core/Lucy/Analysis/StandardTokenizer.cfh
+++ b/core/Lucy/Analysis/StandardTokenizer.cfh
@@ -47,8 +47,8 @@ public class Lucy::Analysis::StandardTokenizer
* supplied Inversion.
*/
void
- Tokenize_Str(StandardTokenizer *self, const char *text, size_t len,
- Inversion *inversion);
+ Tokenize_Utf8(StandardTokenizer *self, const char *text, size_t len,
+ Inversion *inversion);
public bool
Equals(StandardTokenizer *self, Obj *other);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Document/HitDoc.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Document/HitDoc.c b/core/Lucy/Document/HitDoc.c
index 83cfdf9..2abcbbc 100644
--- a/core/Lucy/Document/HitDoc.c
+++ b/core/Lucy/Document/HitDoc.c
@@ -70,7 +70,7 @@ HitDoc_Dump_IMP(HitDoc *self) {
HitDoc_Dump_t super_dump
= SUPER_METHOD_PTR(HITDOC, LUCY_HitDoc_Dump);
Hash *dump = super_dump(self);
- Hash_Store_Str(dump, "score", 5, (Obj*)Str_newf("%f64", ivars->score));
+ Hash_Store_Utf8(dump, "score", 5, (Obj*)Str_newf("%f64", ivars->score));
return dump;
}
@@ -81,7 +81,7 @@ HitDoc_Load_IMP(HitDoc *self, Obj *dump) {
= SUPER_METHOD_PTR(HITDOC, LUCY_HitDoc_Load);
HitDoc *loaded = super_load(self, dump);
HitDocIVARS *const loaded_ivars = HitDoc_IVARS(loaded);
- Obj *score = CERTIFY(Hash_Fetch_Str(source, "score", 5), OBJ);
+ Obj *score = CERTIFY(Hash_Fetch_Utf8(source, "score", 5), OBJ);
loaded_ivars->score = (float)Obj_To_F64(score);
return loaded;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Highlight/Highlighter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Highlight/Highlighter.c b/core/Lucy/Highlight/Highlighter.c
index 35585a1..2d55639 100644
--- a/core/Lucy/Highlight/Highlighter.c
+++ b/core/Lucy/Highlight/Highlighter.c
@@ -614,16 +614,16 @@ S_encode_entities(String *text, CharBuf *buf) {
CB_catf(buf, "&#%u32;", code_point);
}
else if (code_point == '<') {
- CB_Cat_Trusted_UTF8(buf, "<", 4);
+ CB_Cat_Trusted_Utf8(buf, "<", 4);
}
else if (code_point == '>') {
- CB_Cat_Trusted_UTF8(buf, ">", 4);
+ CB_Cat_Trusted_Utf8(buf, ">", 4);
}
else if (code_point == '&') {
- CB_Cat_Trusted_UTF8(buf, "&", 5);
+ CB_Cat_Trusted_Utf8(buf, "&", 5);
}
else if (code_point == '"') {
- CB_Cat_Trusted_UTF8(buf, """, 6);
+ CB_Cat_Trusted_Utf8(buf, """, 6);
}
else {
CB_Cat_Char(buf, code_point);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/BackgroundMerger.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/BackgroundMerger.c b/core/Lucy/Index/BackgroundMerger.c
index 45bd39d..547a5f9 100644
--- a/core/Lucy/Index/BackgroundMerger.c
+++ b/core/Lucy/Index/BackgroundMerger.c
@@ -413,7 +413,7 @@ BGMerger_Prepare_Commit_IMP(BackgroundMerger *self) {
// Write temporary snapshot file.
DECREF(ivars->snapfile);
String *snapfile = IxManager_Make_Snapshot_Filename(ivars->manager);
- ivars->snapfile = Str_Cat_Trusted_UTF8(snapfile, ".temp", 5);
+ ivars->snapfile = Str_Cat_Trusted_Utf8(snapfile, ".temp", 5);
DECREF(snapfile);
Folder_Delete(folder, ivars->snapfile);
Snapshot_Write_File(snapshot, folder, ivars->snapfile);
@@ -444,7 +444,7 @@ BGMerger_Prepare_Commit_IMP(BackgroundMerger *self) {
VArray *files = Snapshot_List(latest_snapshot);
for (uint32_t i = 0, max = VA_Get_Size(files); i < max; i++) {
String *file = (String*)VA_Fetch(files, i);
- if (Str_Starts_With_Str(file, "seg_", 4)) {
+ if (Str_Starts_With_Utf8(file, "seg_", 4)) {
int64_t gen = (int64_t)IxFileNames_extract_gen(file);
if (gen > ivars->cutoff) {
Snapshot_Add_Entry(ivars->snapshot, file);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/DataWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DataWriter.c b/core/Lucy/Index/DataWriter.c
index 747dc89..5cc299a 100644
--- a/core/Lucy/Index/DataWriter.c
+++ b/core/Lucy/Index/DataWriter.c
@@ -91,8 +91,8 @@ DataWriter_Merge_Segment_IMP(DataWriter *self, SegReader *reader,
Hash*
DataWriter_Metadata_IMP(DataWriter *self) {
Hash *metadata = Hash_new(0);
- Hash_Store_Str(metadata, "format", 6,
- (Obj*)Str_newf("%i32", DataWriter_Format(self)));
+ Hash_Store_Utf8(metadata, "format", 6,
+ (Obj*)Str_newf("%i32", DataWriter_Format(self)));
return metadata;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/DeletionsReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DeletionsReader.c b/core/Lucy/Index/DeletionsReader.c
index 3e21ada..bb5e49d 100644
--- a/core/Lucy/Index/DeletionsReader.c
+++ b/core/Lucy/Index/DeletionsReader.c
@@ -168,19 +168,19 @@ DefDelReader_Read_Deletions_IMP(DefaultDeletionsReader *self) {
for (int32_t i = VA_Get_Size(segments) - 1; i >= 0; i--) {
Segment *other_seg = (Segment*)VA_Fetch(segments, i);
Hash *metadata
- = (Hash*)Seg_Fetch_Metadata_Str(other_seg, "deletions", 9);
+ = (Hash*)Seg_Fetch_Metadata_Utf8(other_seg, "deletions", 9);
if (metadata) {
Hash *files = (Hash*)CERTIFY(
- Hash_Fetch_Str(metadata, "files", 5), HASH);
+ Hash_Fetch_Utf8(metadata, "files", 5), HASH);
Hash *seg_files_data
= (Hash*)Hash_Fetch(files, (Obj*)my_seg_name);
if (seg_files_data) {
Obj *count = (Obj*)CERTIFY(
- Hash_Fetch_Str(seg_files_data, "count", 5),
+ Hash_Fetch_Utf8(seg_files_data, "count", 5),
OBJ);
del_count = (int32_t)Obj_To_I64(count);
del_file = (String*)CERTIFY(
- Hash_Fetch_Str(seg_files_data, "filename", 8),
+ Hash_Fetch_Utf8(seg_files_data, "filename", 8),
STRING);
break;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/DeletionsWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DeletionsWriter.c b/core/Lucy/Index/DeletionsWriter.c
index 2bb0f02..829a04c 100644
--- a/core/Lucy/Index/DeletionsWriter.c
+++ b/core/Lucy/Index/DeletionsWriter.c
@@ -168,8 +168,8 @@ DefDelWriter_Finish_IMP(DefaultDeletionsWriter *self) {
}
}
- Seg_Store_Metadata_Str(ivars->segment, "deletions", 9,
- (Obj*)DefDelWriter_Metadata(self));
+ Seg_Store_Metadata_Utf8(ivars->segment, "deletions", 9,
+ (Obj*)DefDelWriter_Metadata(self));
}
Hash*
@@ -187,14 +187,14 @@ DefDelWriter_Metadata_IMP(DefaultDeletionsWriter *self) {
BitVector *deldocs = (BitVector*)VA_Fetch(ivars->bit_vecs, i);
Segment *segment = SegReader_Get_Segment(seg_reader);
Hash *mini_meta = Hash_new(2);
- Hash_Store_Str(mini_meta, "count", 5,
- (Obj*)Str_newf("%u32", (uint32_t)BitVec_Count(deldocs)));
- Hash_Store_Str(mini_meta, "filename", 8,
- (Obj*)S_del_filename(self, seg_reader));
+ Hash_Store_Utf8(mini_meta, "count", 5,
+ (Obj*)Str_newf("%u32", (uint32_t)BitVec_Count(deldocs)));
+ Hash_Store_Utf8(mini_meta, "filename", 8,
+ (Obj*)S_del_filename(self, seg_reader));
Hash_Store(files, (Obj*)Seg_Get_Name(segment), (Obj*)mini_meta);
}
}
- Hash_Store_Str(metadata, "files", 5, (Obj*)files);
+ Hash_Store_Utf8(metadata, "files", 5, (Obj*)files);
return metadata;
}
@@ -344,11 +344,11 @@ DefDelWriter_Merge_Segment_IMP(DefaultDeletionsWriter *self,
DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
UNUSED_VAR(doc_map);
Segment *segment = SegReader_Get_Segment(reader);
- Hash *del_meta = (Hash*)Seg_Fetch_Metadata_Str(segment, "deletions", 9);
+ Hash *del_meta = (Hash*)Seg_Fetch_Metadata_Utf8(segment, "deletions", 9);
if (del_meta) {
VArray *seg_readers = ivars->seg_readers;
- Hash *files = (Hash*)Hash_Fetch_Str(del_meta, "files", 5);
+ Hash *files = (Hash*)Hash_Fetch_Utf8(del_meta, "files", 5);
if (files) {
String *seg;
Hash *mini_meta;
@@ -370,7 +370,7 @@ DefDelWriter_Merge_Segment_IMP(DefaultDeletionsWriter *self,
* merge away the most recent deletions file
* pointing at this target segment -- so force a
* new file to be written out. */
- int32_t count = (int32_t)Obj_To_I64(Hash_Fetch_Str(mini_meta, "count", 5));
+ int32_t count = (int32_t)Obj_To_I64(Hash_Fetch_Utf8(mini_meta, "count", 5));
DeletionsReader *del_reader
= (DeletionsReader*)SegReader_Obtain(
candidate, VTable_Get_Name(DELETIONSREADER));
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocReader.c b/core/Lucy/Index/DocReader.c
index 483af50..30f8dba 100644
--- a/core/Lucy/Index/DocReader.c
+++ b/core/Lucy/Index/DocReader.c
@@ -139,13 +139,13 @@ DefDocReader_init(DefaultDocReader *self, Schema *schema, Folder *folder,
seg_tick);
DefaultDocReaderIVARS *const ivars = DefDocReader_IVARS(self);
segment = DefDocReader_Get_Segment(self);
- metadata = (Hash*)Seg_Fetch_Metadata_Str(segment, "documents", 9);
+ metadata = (Hash*)Seg_Fetch_Metadata_Utf8(segment, "documents", 9);
if (metadata) {
String *seg_name = Seg_Get_Name(segment);
String *ix_file = Str_newf("%o/documents.ix", seg_name);
String *dat_file = Str_newf("%o/documents.dat", seg_name);
- Obj *format = Hash_Fetch_Str(metadata, "format", 6);
+ Obj *format = Hash_Fetch_Utf8(metadata, "format", 6);
// Check format.
if (!format) { THROW(ERR, "Missing 'format' var"); }
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/DocVector.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocVector.c b/core/Lucy/Index/DocVector.c
index 5821f90..585c955 100644
--- a/core/Lucy/Index/DocVector.c
+++ b/core/Lucy/Index/DocVector.c
@@ -132,7 +132,7 @@ S_extract_tv_cache(ByteBuf *field_buf) {
// Decompress the term text.
CB_Set_Size(text_buf, overlap);
- CB_Cat_Trusted_UTF8(text_buf, tv_string, len);
+ CB_Cat_Trusted_Utf8(text_buf, tv_string, len);
tv_string += len;
// Get positions & offsets string.
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/DocWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocWriter.c b/core/Lucy/Index/DocWriter.c
index cb8c9e3..16f86ef 100644
--- a/core/Lucy/Index/DocWriter.c
+++ b/core/Lucy/Index/DocWriter.c
@@ -208,8 +208,8 @@ DocWriter_Finish_IMP(DocWriter *self) {
// Close down output streams.
OutStream_Close(ivars->dat_out);
OutStream_Close(ivars->ix_out);
- Seg_Store_Metadata_Str(ivars->segment, "documents", 9,
- (Obj*)DocWriter_Metadata(self));
+ Seg_Store_Metadata_Utf8(ivars->segment, "documents", 9,
+ (Obj*)DocWriter_Metadata(self));
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/FilePurger.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/FilePurger.c b/core/Lucy/Index/FilePurger.c
index 46957a9..d61482e 100644
--- a/core/Lucy/Index/FilePurger.c
+++ b/core/Lucy/Index/FilePurger.c
@@ -60,7 +60,7 @@ FilePurger_init(FilePurger *self, Folder *folder, Snapshot *snapshot,
// Don't allow the locks directory to be zapped.
ivars->disallowed = Hash_new(0);
- Hash_Store_Str(ivars->disallowed, "locks", 5, (Obj*)CFISH_TRUE);
+ Hash_Store_Utf8(ivars->disallowed, "locks", 5, (Obj*)CFISH_TRUE);
return self;
}
@@ -149,7 +149,7 @@ S_zap_dead_merge(FilePurger *self, Hash *candidates) {
if (!Lock_Is_Locked(merge_lock)) {
Hash *merge_data = IxManager_Read_Merge_Data(manager);
Obj *cutoff = merge_data
- ? Hash_Fetch_Str(merge_data, "cutoff", 6)
+ ? Hash_Fetch_Utf8(merge_data, "cutoff", 6)
: NULL;
if (cutoff) {
@@ -209,8 +209,8 @@ S_discover_unused(FilePurger *self, VArray **purgables_ptr,
Hash *candidates = Hash_new(64);
while (DH_Next(dh)) {
String *entry = DH_Get_Entry(dh);
- if (Str_Starts_With_Str(entry, "snapshot_", 9)
- && Str_Ends_With_Str(entry, ".json", 5)
+ if (Str_Starts_With_Utf8(entry, "snapshot_", 9)
+ && Str_Ends_With_Utf8(entry, ".json", 5)
&& (!snapfile || !Str_Equals(entry, (Obj*)snapfile))
) {
Snapshot *snapshot
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/HighlightReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/HighlightReader.c b/core/Lucy/Index/HighlightReader.c
index f24c346..af2c269 100644
--- a/core/Lucy/Index/HighlightReader.c
+++ b/core/Lucy/Index/HighlightReader.c
@@ -119,14 +119,14 @@ DefHLReader_init(DefaultHighlightReader *self, Schema *schema,
segments, seg_tick);
DefaultHighlightReaderIVARS *const ivars = DefHLReader_IVARS(self);
Segment *segment = DefHLReader_Get_Segment(self);
- Hash *metadata = (Hash*)Seg_Fetch_Metadata_Str(segment, "highlight", 9);
+ Hash *metadata = (Hash*)Seg_Fetch_Metadata_Utf8(segment, "highlight", 9);
if (!metadata) {
- metadata = (Hash*)Seg_Fetch_Metadata_Str(segment, "term_vectors", 12);
+ metadata = (Hash*)Seg_Fetch_Metadata_Utf8(segment, "term_vectors", 12);
}
// Check format.
if (metadata) {
- Obj *format = Hash_Fetch_Str(metadata, "format", 6);
+ Obj *format = Hash_Fetch_Utf8(metadata, "format", 6);
if (!format) { THROW(ERR, "Missing 'format' var"); }
else {
if (Obj_To_I64(format) != HLWriter_current_file_format) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/HighlightWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/HighlightWriter.c b/core/Lucy/Index/HighlightWriter.c
index 0d03233..e259a61 100644
--- a/core/Lucy/Index/HighlightWriter.c
+++ b/core/Lucy/Index/HighlightWriter.c
@@ -259,8 +259,8 @@ HLWriter_Finish_IMP(HighlightWriter *self) {
// Close down the output streams.
OutStream_Close(ivars->dat_out);
OutStream_Close(ivars->ix_out);
- Seg_Store_Metadata_Str(ivars->segment, "highlight", 9,
- (Obj*)HLWriter_Metadata(self));
+ Seg_Store_Metadata_Utf8(ivars->segment, "highlight", 9,
+ (Obj*)HLWriter_Metadata(self));
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/IndexManager.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/IndexManager.c b/core/Lucy/Index/IndexManager.c
index b1b29b4..b22e993 100644
--- a/core/Lucy/Index/IndexManager.c
+++ b/core/Lucy/Index/IndexManager.c
@@ -91,8 +91,8 @@ IxManager_Make_Snapshot_Filename_IMP(IndexManager *self) {
if (!dh) { RETHROW(INCREF(Err_get_error())); }
while (DH_Next(dh)) {
String *entry = DH_Get_Entry(dh);
- if (Str_Starts_With_Str(entry, "snapshot_", 9)
- && Str_Ends_With_Str(entry, ".json", 5)
+ if (Str_Starts_With_Utf8(entry, "snapshot_", 9)
+ && Str_Ends_With_Utf8(entry, ".json", 5)
) {
uint64_t gen = IxFileNames_extract_gen(entry);
if (gen > max_gen) { max_gen = gen; }
@@ -266,7 +266,7 @@ IxManager_Write_Merge_Data_IMP(IndexManager *self, int64_t cutoff) {
StackString *merge_json = SSTR_WRAP_STR("merge.json", 10);
Hash *data = Hash_new(1);
bool success;
- Hash_Store_Str(data, "cutoff", 6, (Obj*)Str_newf("%i64", cutoff));
+ Hash_Store_Utf8(data, "cutoff", 6, (Obj*)Str_newf("%i64", cutoff));
success = Json_spew_json((Obj*)data, ivars->folder, (String*)merge_json);
DECREF(data);
if (!success) {
@@ -306,8 +306,8 @@ IxManager_Make_Snapshot_Read_Lock_IMP(IndexManager *self,
const String *filename) {
LockFactory *lock_factory = S_obtain_lock_factory(self);
- if (!Str_Starts_With_Str(filename, "snapshot_", 9)
- || !Str_Ends_With_Str(filename, ".json", 5)
+ if (!Str_Starts_With_Utf8(filename, "snapshot_", 9)
+ || !Str_Ends_With_Utf8(filename, ".json", 5)
) {
THROW(ERR, "Not a snapshot filename: %o", filename);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/Indexer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Indexer.c b/core/Lucy/Index/Indexer.c
index 815e7b4..7ef8ae2 100644
--- a/core/Lucy/Index/Indexer.c
+++ b/core/Lucy/Index/Indexer.c
@@ -176,7 +176,7 @@ Indexer_init(Indexer *self, Schema *schema, Obj *index,
// way.
Hash *merge_data = IxManager_Read_Merge_Data(ivars->manager);
Obj *cutoff_obj = merge_data
- ? Hash_Fetch_Str(merge_data, "cutoff", 6)
+ ? Hash_Fetch_Utf8(merge_data, "cutoff", 6)
: NULL;
if (!cutoff_obj) {
DECREF(merge_lock);
@@ -384,8 +384,8 @@ S_find_schema_file(Snapshot *snapshot) {
String *retval = NULL;
for (uint32_t i = 0, max = VA_Get_Size(files); i < max; i++) {
String *file = (String*)VA_Fetch(files, i);
- if (Str_Starts_With_Str(file, "schema_", 7)
- && Str_Ends_With_Str(file, ".json", 5)
+ if (Str_Starts_With_Utf8(file, "schema_", 7)
+ && Str_Ends_With_Utf8(file, ".json", 5)
) {
retval = file;
break;
@@ -412,7 +412,7 @@ S_maybe_merge(Indexer *self, VArray *seg_readers) {
// If something else holds the merge lock, don't interfere.
Hash *merge_data = IxManager_Read_Merge_Data(ivars->manager);
if (merge_data) {
- Obj *cutoff_obj = Hash_Fetch_Str(merge_data, "cutoff", 6);
+ Obj *cutoff_obj = Hash_Fetch_Utf8(merge_data, "cutoff", 6);
if (cutoff_obj) {
cutoff = Obj_To_I64(cutoff_obj);
}
@@ -508,7 +508,7 @@ Indexer_Prepare_Commit_IMP(Indexer *self) {
// Derive snapshot and schema file names.
DECREF(ivars->snapfile);
String *snapfile = IxManager_Make_Snapshot_Filename(ivars->manager);
- ivars->snapfile = Str_Cat_Trusted_UTF8(snapfile, ".temp", 5);
+ ivars->snapfile = Str_Cat_Trusted_Utf8(snapfile, ".temp", 5);
DECREF(snapfile);
uint64_t schema_gen = IxFileNames_extract_gen(ivars->snapfile);
char base36[StrHelp_MAX_BASE36_BYTES];
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/LexiconWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/LexiconWriter.c b/core/Lucy/Index/LexiconWriter.c
index 9ffd853..5189c49 100644
--- a/core/Lucy/Index/LexiconWriter.c
+++ b/core/Lucy/Index/LexiconWriter.c
@@ -230,8 +230,8 @@ LexWriter_Finish_IMP(LexiconWriter *self) {
}
// Store metadata.
- Seg_Store_Metadata_Str(ivars->segment, "lexicon", 7,
- (Obj*)LexWriter_Metadata(self));
+ Seg_Store_Metadata_Utf8(ivars->segment, "lexicon", 7,
+ (Obj*)LexWriter_Metadata(self));
}
Hash*
@@ -246,13 +246,13 @@ LexWriter_Metadata_IMP(LexiconWriter *self) {
// Placeholders.
if (Hash_Get_Size(counts) == 0) {
- Hash_Store_Str(counts, "none", 4, (Obj*)Str_newf("%i32", (int32_t)0));
- Hash_Store_Str(ix_counts, "none", 4,
- (Obj*)Str_newf("%i32", (int32_t)0));
+ Hash_Store_Utf8(counts, "none", 4, (Obj*)Str_newf("%i32", (int32_t)0));
+ Hash_Store_Utf8(ix_counts, "none", 4,
+ (Obj*)Str_newf("%i32", (int32_t)0));
}
- Hash_Store_Str(metadata, "counts", 6, (Obj*)counts);
- Hash_Store_Str(metadata, "index_counts", 12, (Obj*)ix_counts);
+ Hash_Store_Utf8(metadata, "counts", 6, (Obj*)counts);
+ Hash_Store_Utf8(metadata, "index_counts", 12, (Obj*)ix_counts);
return metadata;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/PolyReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PolyReader.c b/core/Lucy/Index/PolyReader.c
index e63a639..0446bcb 100644
--- a/core/Lucy/Index/PolyReader.c
+++ b/core/Lucy/Index/PolyReader.c
@@ -237,8 +237,8 @@ S_try_open_elements(void *context) {
if (Seg_valid_seg_name(entry)) {
num_segs++;
}
- else if (Str_Starts_With_Str(entry, "schema_", 7)
- && Str_Ends_With_Str(entry, ".json", 5)
+ else if (Str_Starts_With_Utf8(entry, "schema_", 7)
+ && Str_Ends_With_Utf8(entry, ".json", 5)
) {
uint64_t gen = IxFileNames_extract_gen(entry);
if (gen > latest_schema_gen) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/PostingListReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingListReader.c b/core/Lucy/Index/PostingListReader.c
index 02ae03d..f643917 100644
--- a/core/Lucy/Index/PostingListReader.c
+++ b/core/Lucy/Index/PostingListReader.c
@@ -71,13 +71,13 @@ DefPListReader_init(DefaultPostingListReader *self, Schema *schema,
ivars->lex_reader = (LexiconReader*)INCREF(lex_reader);
// Check format.
- Hash *my_meta = (Hash*)Seg_Fetch_Metadata_Str(segment, "postings", 8);
+ Hash *my_meta = (Hash*)Seg_Fetch_Metadata_Utf8(segment, "postings", 8);
if (!my_meta) {
- my_meta = (Hash*)Seg_Fetch_Metadata_Str(segment, "posting_list", 12);
+ my_meta = (Hash*)Seg_Fetch_Metadata_Utf8(segment, "posting_list", 12);
}
if (my_meta) {
- Obj *format = Hash_Fetch_Str(my_meta, "format", 6);
+ Obj *format = Hash_Fetch_Utf8(my_meta, "format", 6);
if (!format) { THROW(ERR, "Missing 'format' var"); }
else {
if (Obj_To_I64(format) != PListWriter_current_file_format) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/PostingListWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingListWriter.c b/core/Lucy/Index/PostingListWriter.c
index 0245413..b398bc2 100644
--- a/core/Lucy/Index/PostingListWriter.c
+++ b/core/Lucy/Index/PostingListWriter.c
@@ -243,8 +243,8 @@ PListWriter_Finish_IMP(PostingListWriter *self) {
}
// Store metadata.
- Seg_Store_Metadata_Str(ivars->segment, "postings", 8,
- (Obj*)PListWriter_Metadata(self));
+ Seg_Store_Metadata_Utf8(ivars->segment, "postings", 8,
+ (Obj*)PListWriter_Metadata(self));
// Close down and clean up.
OutStream_Close(ivars->skip_out);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/SegLexicon.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SegLexicon.c b/core/Lucy/Index/SegLexicon.c
index 19c6e7b..dd5931f 100644
--- a/core/Lucy/Index/SegLexicon.c
+++ b/core/Lucy/Index/SegLexicon.c
@@ -47,11 +47,11 @@ SegLexicon*
SegLex_init(SegLexicon *self, Schema *schema, Folder *folder,
Segment *segment, const String *field) {
Hash *metadata = (Hash*)CERTIFY(
- Seg_Fetch_Metadata_Str(segment, "lexicon", 7),
+ Seg_Fetch_Metadata_Utf8(segment, "lexicon", 7),
HASH);
Architecture *arch = Schema_Get_Architecture(schema);
- Hash *counts = (Hash*)Hash_Fetch_Str(metadata, "counts", 6);
- Obj *format = Hash_Fetch_Str(metadata, "format", 6);
+ Hash *counts = (Hash*)Hash_Fetch_Utf8(metadata, "counts", 6);
+ Obj *format = Hash_Fetch_Utf8(metadata, "format", 6);
String *seg_name = Seg_Get_Name(segment);
int32_t field_num = Seg_Field_Num(segment, field);
FieldType *type = Schema_Fetch_Type(schema, field);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/Segment.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Segment.c b/core/Lucy/Index/Segment.c
index d375e98..21a3f66 100644
--- a/core/Lucy/Index/Segment.c
+++ b/core/Lucy/Index/Segment.c
@@ -65,7 +65,7 @@ Seg_num_to_name(int64_t number) {
bool
Seg_valid_seg_name(const String *name) {
- if (Str_Starts_With_Str(name, "seg_", 4)) {
+ if (Str_Starts_With_Utf8(name, "seg_", 4)) {
StringIterator *iter = Str_Top(name);
StrIter_Advance(iter, 4);
uint32_t code_point;
@@ -107,17 +107,17 @@ Seg_Read_File_IMP(Segment *self, Folder *folder) {
DECREF(ivars->metadata);
ivars->metadata = metadata;
my_metadata
- = (Hash*)CERTIFY(Hash_Fetch_Str(ivars->metadata, "segmeta", 7), HASH);
+ = (Hash*)CERTIFY(Hash_Fetch_Utf8(ivars->metadata, "segmeta", 7), HASH);
// Assign.
- Obj *count = Hash_Fetch_Str(my_metadata, "count", 5);
- if (!count) { count = Hash_Fetch_Str(my_metadata, "doc_count", 9); }
+ Obj *count = Hash_Fetch_Utf8(my_metadata, "count", 5);
+ if (!count) { count = Hash_Fetch_Utf8(my_metadata, "doc_count", 9); }
if (!count) { THROW(ERR, "Missing 'count'"); }
else { ivars->count = Obj_To_I64(count); }
// Get list of field nums.
- VArray *source_by_num = (VArray*)Hash_Fetch_Str(my_metadata,
- "field_names", 11);
+ VArray *source_by_num = (VArray*)Hash_Fetch_Utf8(my_metadata,
+ "field_names", 11);
uint32_t num_fields = source_by_num ? VA_Get_Size(source_by_num) : 0;
if (source_by_num == NULL) {
THROW(ERR, "Failed to extract 'field_names' from metadata");
@@ -144,12 +144,12 @@ Seg_Write_File_IMP(Segment *self, Folder *folder) {
Hash *my_metadata = Hash_new(16);
// Store metadata specific to this Segment object.
- Hash_Store_Str(my_metadata, "count", 5,
- (Obj*)Str_newf("%i64", ivars->count));
- Hash_Store_Str(my_metadata, "name", 4, (Obj*)Str_Clone(ivars->name));
- Hash_Store_Str(my_metadata, "field_names", 11, INCREF(ivars->by_num));
- Hash_Store_Str(my_metadata, "format", 6, (Obj*)Str_newf("%i32", 1));
- Hash_Store_Str(ivars->metadata, "segmeta", 7, (Obj*)my_metadata);
+ Hash_Store_Utf8(my_metadata, "count", 5,
+ (Obj*)Str_newf("%i64", ivars->count));
+ Hash_Store_Utf8(my_metadata, "name", 4, (Obj*)Str_Clone(ivars->name));
+ Hash_Store_Utf8(my_metadata, "field_names", 11, INCREF(ivars->by_num));
+ Hash_Store_Utf8(my_metadata, "format", 6, (Obj*)Str_newf("%i32", 1));
+ Hash_Store_Utf8(ivars->metadata, "segmeta", 7, (Obj*)my_metadata);
String *filename = Str_newf("%o/segmeta.json", ivars->name);
bool result = Json_spew_json((Obj*)ivars->metadata, folder, filename);
@@ -209,8 +209,8 @@ Seg_Store_Metadata_IMP(Segment *self, const String *key, Obj *value) {
}
void
-Seg_Store_Metadata_Str_IMP(Segment *self, const char *key, size_t key_len,
- Obj *value) {
+Seg_Store_Metadata_Utf8_IMP(Segment *self, const char *key, size_t key_len,
+ Obj *value) {
StackString *k = SSTR_WRAP_STR((char*)key, key_len);
Seg_Store_Metadata(self, (String*)k, value);
}
@@ -222,9 +222,9 @@ Seg_Fetch_Metadata_IMP(Segment *self, const String *key) {
}
Obj*
-Seg_Fetch_Metadata_Str_IMP(Segment *self, const char *key, size_t len) {
+Seg_Fetch_Metadata_Utf8_IMP(Segment *self, const char *key, size_t len) {
SegmentIVARS *const ivars = Seg_IVARS(self);
- return Hash_Fetch_Str(ivars->metadata, key, len);
+ return Hash_Fetch_Utf8(ivars->metadata, key, len);
}
Hash*
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/Segment.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Segment.cfh b/core/Lucy/Index/Segment.cfh
index 3231938..43ca509 100644
--- a/core/Lucy/Index/Segment.cfh
+++ b/core/Lucy/Index/Segment.cfh
@@ -77,8 +77,8 @@ public class Lucy::Index::Segment cnick Seg inherits Clownfish::Obj {
decremented Obj *metadata);
void
- Store_Metadata_Str(Segment *self, const char *key, size_t len,
- decremented Obj *value);
+ Store_Metadata_Utf8(Segment *self, const char *key, size_t len,
+ decremented Obj *value);
/** Fetch a value from the Segment's metadata hash.
*/
@@ -86,7 +86,7 @@ public class Lucy::Index::Segment cnick Seg inherits Clownfish::Obj {
Fetch_Metadata(Segment *self, const String *key);
nullable Obj*
- Fetch_Metadata_Str(Segment *self, const char *key, size_t len);
+ Fetch_Metadata_Utf8(Segment *self, const char *key, size_t len);
/** Given a field name, return its field number for this segment (which
* may differ from its number in other segments). Return 0 (an invalid
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/Similarity.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Similarity.c b/core/Lucy/Index/Similarity.c
index ddfbcf5..c43d9b4 100644
--- a/core/Lucy/Index/Similarity.c
+++ b/core/Lucy/Index/Similarity.c
@@ -83,8 +83,8 @@ Sim_Get_Norm_Decoder_IMP(Similarity *self) {
Obj*
Sim_Dump_IMP(Similarity *self) {
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)Str_Clone(Sim_Get_Class_Name(self)));
+ Hash_Store_Utf8(dump, "_class", 6,
+ (Obj*)Str_Clone(Sim_Get_Class_Name(self)));
return (Obj*)dump;
}
@@ -92,7 +92,7 @@ Similarity*
Sim_Load_IMP(Similarity *self, Obj *dump) {
Hash *source = (Hash*)CERTIFY(dump, HASH);
String *class_name
- = (String*)CERTIFY(Hash_Fetch_Str(source, "_class", 6), STRING);
+ = (String*)CERTIFY(Hash_Fetch_Utf8(source, "_class", 6), STRING);
VTable *vtable = VTable_singleton(class_name, NULL);
Similarity *loaded = (Similarity*)VTable_Make_Obj(vtable);
UNUSED_VAR(self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/3804cbc3/core/Lucy/Index/Snapshot.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Snapshot.c b/core/Lucy/Index/Snapshot.c
index 5ea097d..a8b2afe 100644
--- a/core/Lucy/Index/Snapshot.c
+++ b/core/Lucy/Index/Snapshot.c
@@ -114,9 +114,9 @@ Snapshot_Read_File_IMP(Snapshot *self, Folder *folder, const String *path) {
Hash *snap_data
= (Hash*)CERTIFY(Json_slurp_json(folder, ivars->path), HASH);
Obj *format_obj
- = CERTIFY(Hash_Fetch_Str(snap_data, "format", 6), OBJ);
+ = CERTIFY(Hash_Fetch_Utf8(snap_data, "format", 6), OBJ);
int32_t format = (int32_t)Obj_To_I64(format_obj);
- Obj *subformat_obj = Hash_Fetch_Str(snap_data, "subformat", 9);
+ Obj *subformat_obj = Hash_Fetch_Utf8(snap_data, "subformat", 9);
int32_t subformat = subformat_obj
? (int32_t)Obj_To_I64(subformat_obj)
: 0;
@@ -129,7 +129,7 @@ Snapshot_Read_File_IMP(Snapshot *self, Folder *folder, const String *path) {
// Build up list of entries.
VArray *list = (VArray*)CERTIFY(
- Hash_Fetch_Str(snap_data, "entries", 7),
+ Hash_Fetch_Utf8(snap_data, "entries", 7),
VARRAY);
INCREF(list);
if (format == 1 || (format == 2 && subformat < 1)) {
@@ -160,7 +160,7 @@ S_clean_segment_contents(VArray *orig) {
for (uint32_t i = 0, max = VA_Get_Size(orig); i < max; i++) {
String *name = (String*)VA_Fetch(orig, i);
if (!Seg_valid_seg_name(name)) {
- if (Str_Starts_With_Str(name, "seg_", 4)) {
+ if (Str_Starts_With_Utf8(name, "seg_", 4)) {
continue; // Skip this file.
}
}
@@ -197,13 +197,13 @@ Snapshot_Write_File_IMP(Snapshot *self, Folder *folder, const String *path) {
// Sort, then store file names.
VA_Sort(list, NULL, NULL);
- Hash_Store_Str(all_data, "entries", 7, (Obj*)list);
+ Hash_Store_Utf8(all_data, "entries", 7, (Obj*)list);
// Create a JSON-izable data structure.
- Hash_Store_Str(all_data, "format", 6,
- (Obj*)Str_newf("%i32", (int32_t)Snapshot_current_file_format));
- Hash_Store_Str(all_data, "subformat", 9,
- (Obj*)Str_newf("%i32", (int32_t)Snapshot_current_file_subformat));
+ Hash_Store_Utf8(all_data, "format", 6,
+ (Obj*)Str_newf("%i32", (int32_t)Snapshot_current_file_format));
+ Hash_Store_Utf8(all_data, "subformat", 9,
+ (Obj*)Str_newf("%i32", (int32_t)Snapshot_current_file_subformat));
// Write out JSON-ized data to the new file.
Json_spew_json((Obj*)all_data, folder, ivars->path);
[lucy-commits] [11/15] git commit: refs/heads/cfish-string-prep1 - Replace
Str_Inc_RefCount with INCREF
Posted by nw...@apache.org.
Replace Str_Inc_RefCount with INCREF
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/c798605f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/c798605f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/c798605f
Branch: refs/heads/cfish-string-prep1
Commit: c798605fadf478db1fa27b1040f3954e506778ab
Parents: 0008a99
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 10 18:42:05 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 20:29:46 2013 +0200
----------------------------------------------------------------------
clownfish/runtime/core/Clownfish/Num.c | 2 +-
core/Lucy/Index/PolyReader.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/c798605f/clownfish/runtime/core/Clownfish/Num.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Num.c b/clownfish/runtime/core/Clownfish/Num.c
index f18bf76..cf38a86 100644
--- a/clownfish/runtime/core/Clownfish/Num.c
+++ b/clownfish/runtime/core/Clownfish/Num.c
@@ -375,7 +375,7 @@ Bool_Hash_Sum_IMP(BoolNum *self) {
String*
Bool_To_String_IMP(BoolNum *self) {
- return (String*)Str_Inc_RefCount(self->string);
+ return (String*)INCREF(self->string);
}
bool
http://git-wip-us.apache.org/repos/asf/lucy/blob/c798605f/core/Lucy/Index/PolyReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PolyReader.c b/core/Lucy/Index/PolyReader.c
index 0446bcb..1dbc0b5 100644
--- a/core/Lucy/Index/PolyReader.c
+++ b/core/Lucy/Index/PolyReader.c
@@ -355,7 +355,7 @@ PolyReader_do_open(PolyReader *self, Obj *index, Snapshot *snapshot,
THROW(ERR, "Supplied snapshot objects must not be empty");
}
else {
- Str_Inc_RefCount(target_snap_file);
+ target_snap_file = (String*)INCREF(target_snap_file);
}
}
else {
[lucy-commits] [08/15] git commit: refs/heads/cfish-string-prep1 - Make Str_Get_Ptr8
return a const char pointer.
Posted by nw...@apache.org.
Make Str_Get_Ptr8 return a const char pointer.
Also make CB_Get_Ptr8 return a char pointer and const a couple of other
pointers in the process.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/6c889682
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/6c889682
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/6c889682
Branch: refs/heads/cfish-string-prep1
Commit: 6c889682d54daf0659872ec6027906b01fc23a1b
Parents: 235519b
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 14 19:03:48 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 19:03:48 2013 +0200
----------------------------------------------------------------------
clownfish/runtime/core/Clownfish/CharBuf.c | 4 +-
clownfish/runtime/core/Clownfish/CharBuf.cfh | 2 +-
clownfish/runtime/core/Clownfish/String.c | 4 +-
clownfish/runtime/core/Clownfish/String.cfh | 2 +-
.../runtime/core/Clownfish/Util/StringHelper.c | 2 +-
.../core/Clownfish/Util/StringHelper.cfh | 2 +-
clownfish/runtime/perl/xs/XSBind.c | 6 +--
clownfish/runtime/ruby/ext/Bind.c | 2 +-
core/Lucy/Analysis/Analyzer.c | 2 +-
core/Lucy/Analysis/PolyAnalyzer.c | 6 +--
core/Lucy/Analysis/RegexTokenizer.c | 2 +-
core/Lucy/Analysis/StandardTokenizer.c | 2 +-
core/Lucy/Index/DocWriter.c | 4 +-
core/Lucy/Index/Inverter.c | 2 +-
core/Lucy/Index/Posting/MatchPosting.c | 22 ++++-----
core/Lucy/Index/Posting/RawPosting.c | 2 +-
core/Lucy/Index/Posting/RawPosting.cfh | 2 +-
core/Lucy/Index/Posting/RichPosting.c | 22 ++++-----
core/Lucy/Index/Posting/ScorePosting.c | 22 ++++-----
core/Lucy/Index/PostingPool.c | 6 +--
core/Lucy/Index/SortFieldWriter.c | 2 +-
core/Lucy/Plan/TextType.c | 16 +++----
core/Lucy/Store/FSDirHandle.c | 8 ++--
core/Lucy/Store/FSFolder.c | 4 +-
core/Lucy/Test/Analysis/TestNormalizer.c | 3 +-
core/Lucy/Test/Search/TestQueryParserLogic.c | 12 ++---
core/Lucy/Test/Search/TestQueryParserSyntax.c | 10 ++--
core/Lucy/Test/Store/TestFSFileHandle.c | 18 +++----
core/Lucy/Test/TestUtils.c | 2 +-
core/Lucy/Util/Freezer.c | 4 +-
core/Lucy/Util/Json.c | 50 ++++++++++----------
perl/xs/Lucy/Document/Doc.c | 6 +--
32 files changed, 128 insertions(+), 125 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/clownfish/runtime/core/Clownfish/CharBuf.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.c b/clownfish/runtime/core/Clownfish/CharBuf.c
index 9f48caa..7b407ad 100644
--- a/clownfish/runtime/core/Clownfish/CharBuf.c
+++ b/clownfish/runtime/core/Clownfish/CharBuf.c
@@ -406,9 +406,9 @@ CB_Get_Size_IMP(CharBuf *self) {
return self->size;
}
-uint8_t*
+char*
CB_Get_Ptr8_IMP(CharBuf *self) {
- return (uint8_t*)self->ptr;
+ return self->ptr;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/clownfish/runtime/core/Clownfish/CharBuf.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.cfh b/clownfish/runtime/core/Clownfish/CharBuf.cfh
index da48822..64d38da 100644
--- a/clownfish/runtime/core/Clownfish/CharBuf.cfh
+++ b/clownfish/runtime/core/Clownfish/CharBuf.cfh
@@ -130,7 +130,7 @@ class Clownfish::CharBuf cnick CB
/** Return the internal backing array for the CharBuf if its internal
* encoding is UTF-8. If it is not encoded as UTF-8 throw an exception.
*/
- uint8_t*
+ char*
Get_Ptr8(CharBuf *self);
public incremented CharBuf*
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index 0fb4c5f..df85e29 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -449,9 +449,9 @@ Str_Get_Size_IMP(String *self) {
return self->size;
}
-uint8_t*
+const char*
Str_Get_Ptr8_IMP(String *self) {
- return (uint8_t*)self->ptr;
+ return self->ptr;
}
StringIterator*
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index 41ca029..e639fa4 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -170,7 +170,7 @@ class Clownfish::String cnick Str
/** Return the internal backing array for the String if its internal
* encoding is UTF-8. If it is not encoded as UTF-8 throw an exception.
*/
- uint8_t*
+ const char*
Get_Ptr8(String *self);
/** Return a NULL-terminated copy of the string data in UTF-8 encoding.
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/clownfish/runtime/core/Clownfish/Util/StringHelper.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Util/StringHelper.c b/clownfish/runtime/core/Clownfish/Util/StringHelper.c
index 89bd319..98e7f11 100644
--- a/clownfish/runtime/core/Clownfish/Util/StringHelper.c
+++ b/clownfish/runtime/core/Clownfish/Util/StringHelper.c
@@ -222,7 +222,7 @@ StrHelp_decode_utf8_char(const char *ptr) {
}
const char*
-StrHelp_back_utf8_char(const char *ptr, char *start) {
+StrHelp_back_utf8_char(const char *ptr, const char *start) {
while (--ptr >= start) {
if ((*ptr & 0xC0) != 0x80) { return ptr; }
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/clownfish/runtime/core/Clownfish/Util/StringHelper.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Util/StringHelper.cfh b/clownfish/runtime/core/Clownfish/Util/StringHelper.cfh
index 482666f..905613d 100644
--- a/clownfish/runtime/core/Clownfish/Util/StringHelper.cfh
+++ b/clownfish/runtime/core/Clownfish/Util/StringHelper.cfh
@@ -67,7 +67,7 @@ inert class Clownfish::Util::StringHelper cnick StrHelp {
* If backtracking progresses beyond the supplied start, return NULL.
*/
inert nullable const char*
- back_utf8_char(const char *utf8, char *start);
+ back_utf8_char(const char *utf8, const char *start);
}
__C__
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/clownfish/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/xs/XSBind.c b/clownfish/runtime/perl/xs/XSBind.c
index 0f21e50..ea7700d 100644
--- a/clownfish/runtime/perl/xs/XSBind.c
+++ b/clownfish/runtime/perl/xs/XSBind.c
@@ -88,7 +88,7 @@ XSBind_maybe_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable, void *allocation) {
// Assume that the class name is always NULL-terminated. Somewhat
// dangerous but should be safe.
if (sv_isobject(sv)
- && sv_derived_from(sv, (char*)CFISH_Str_Get_Ptr8(CFISH_VTable_Get_Name(vtable)))
+ && sv_derived_from(sv, CFISH_Str_Get_Ptr8(CFISH_VTable_Get_Name(vtable)))
) {
// Unwrap a real Clownfish object.
IV tmp = SvIV(SvRV(sv));
@@ -231,7 +231,7 @@ XSBind_str_to_sv(const cfish_String *str) {
return newSV(0);
}
else {
- SV *sv = newSVpvn((char*)CFISH_Str_Get_Ptr8(str), CFISH_Str_Get_Size(str));
+ SV *sv = newSVpvn(CFISH_Str_Get_Ptr8(str), CFISH_Str_Get_Size(str));
SvUTF8_on(sv);
return sv;
}
@@ -603,7 +603,7 @@ S_lazy_init_host_obj(cfish_Obj *self) {
// Connect class association.
cfish_String *class_name = CFISH_VTable_Get_Name(self->vtable);
- HV *stash = gv_stashpvn((char*)CFISH_Str_Get_Ptr8(class_name),
+ HV *stash = gv_stashpvn(CFISH_Str_Get_Ptr8(class_name),
CFISH_Str_Get_Size(class_name), TRUE);
SvSTASH_set(inner_obj, (HV*)SvREFCNT_inc(stash));
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/clownfish/runtime/ruby/ext/Bind.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/ruby/ext/Bind.c b/clownfish/runtime/ruby/ext/Bind.c
index 2113176..9fa2fbd 100644
--- a/clownfish/runtime/ruby/ext/Bind.c
+++ b/clownfish/runtime/ruby/ext/Bind.c
@@ -35,7 +35,7 @@ Bind_str_to_ruby(const cfish_String *str) {
return rb_str_new2("");
}
else {
- return rb_str_new((char*)CFISH_Str_Get_Ptr8(str), CFISH_Str_Get_Size(str));
+ return rb_str_new(CFISH_Str_Get_Ptr8(str), CFISH_Str_Get_Size(str));
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Analysis/Analyzer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/Analyzer.c b/core/Lucy/Analysis/Analyzer.c
index 4683276..0e52eb7 100644
--- a/core/Lucy/Analysis/Analyzer.c
+++ b/core/Lucy/Analysis/Analyzer.c
@@ -31,7 +31,7 @@ Analyzer_init(Analyzer *self) {
Inversion*
Analyzer_Transform_Text_IMP(Analyzer *self, String *text) {
size_t token_len = Str_Get_Size(text);
- Token *seed = Token_new((char*)Str_Get_Ptr8(text), token_len, 0,
+ Token *seed = Token_new(Str_Get_Ptr8(text), token_len, 0,
token_len, 1.0, 1);
Inversion *starter = Inversion_new(seed);
Inversion *retval = Analyzer_Transform(self, starter);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Analysis/PolyAnalyzer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/PolyAnalyzer.c b/core/Lucy/Analysis/PolyAnalyzer.c
index 59ba1d9..92dd9bf 100644
--- a/core/Lucy/Analysis/PolyAnalyzer.c
+++ b/core/Lucy/Analysis/PolyAnalyzer.c
@@ -91,9 +91,9 @@ PolyAnalyzer_Transform_Text_IMP(PolyAnalyzer *self, String *text) {
Inversion *retval;
if (num_analyzers == 0) {
- size_t token_len = Str_Get_Size(text);
- char *buf = (char*)Str_Get_Ptr8(text);
- Token *seed = Token_new(buf, token_len, 0, token_len, 1.0f, 1);
+ size_t token_len = Str_Get_Size(text);
+ const char *buf = Str_Get_Ptr8(text);
+ Token *seed = Token_new(buf, token_len, 0, token_len, 1.0f, 1);
retval = Inversion_new(seed);
DECREF(seed);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/RegexTokenizer.c b/core/Lucy/Analysis/RegexTokenizer.c
index 3b9e6fa..07215a5 100644
--- a/core/Lucy/Analysis/RegexTokenizer.c
+++ b/core/Lucy/Analysis/RegexTokenizer.c
@@ -45,7 +45,7 @@ RegexTokenizer_Transform_IMP(RegexTokenizer *self, Inversion *inversion) {
Inversion*
RegexTokenizer_Transform_Text_IMP(RegexTokenizer *self, String *text) {
Inversion *new_inversion = Inversion_new(NULL);
- RegexTokenizer_Tokenize_Utf8(self, (char*)Str_Get_Ptr8(text),
+ RegexTokenizer_Tokenize_Utf8(self, Str_Get_Ptr8(text),
Str_Get_Size(text), new_inversion);
return new_inversion;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Analysis/StandardTokenizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/StandardTokenizer.c b/core/Lucy/Analysis/StandardTokenizer.c
index 8db94ec..9992927 100644
--- a/core/Lucy/Analysis/StandardTokenizer.c
+++ b/core/Lucy/Analysis/StandardTokenizer.c
@@ -97,7 +97,7 @@ StandardTokenizer_Transform_IMP(StandardTokenizer *self, Inversion *inversion) {
Inversion*
StandardTokenizer_Transform_Text_IMP(StandardTokenizer *self, String *text) {
Inversion *new_inversion = Inversion_new(NULL);
- StandardTokenizer_Tokenize_Utf8(self, (char*)Str_Get_Ptr8(text),
+ StandardTokenizer_Tokenize_Utf8(self, Str_Get_Ptr8(text),
Str_Get_Size(text), new_inversion);
return new_inversion;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/DocWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocWriter.c b/core/Lucy/Index/DocWriter.c
index 16f86ef..d1e316e 100644
--- a/core/Lucy/Index/DocWriter.c
+++ b/core/Lucy/Index/DocWriter.c
@@ -115,8 +115,8 @@ DocWriter_Add_Inverted_Doc_IMP(DocWriter *self, Inverter *inverter,
Freezer_serialize_string(field, dat_out);
switch (FType_Primitive_ID(type) & FType_PRIMITIVE_ID_MASK) {
case FType_TEXT: {
- uint8_t *buf = Str_Get_Ptr8((String*)value);
- size_t size = Str_Get_Size((String*)value);
+ const char *buf = Str_Get_Ptr8((String*)value);
+ size_t size = Str_Get_Size((String*)value);
OutStream_Write_C32(dat_out, size);
OutStream_Write_Bytes(dat_out, buf, size);
break;
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Inverter.c b/core/Lucy/Index/Inverter.c
index 0147732..d24e14f 100644
--- a/core/Lucy/Index/Inverter.c
+++ b/core/Lucy/Index/Inverter.c
@@ -166,7 +166,7 @@ Inverter_Add_Field_IMP(Inverter *self, InverterEntry *entry) {
else if (entry_ivars->indexed || entry_ivars->highlightable) {
String *value = (String*)entry_ivars->value;
size_t token_len = Str_Get_Size(value);
- Token *seed = Token_new((char*)Str_Get_Ptr8(value),
+ Token *seed = Token_new(Str_Get_Ptr8(value),
token_len, 0, token_len, 1.0f, 1);
DECREF(entry_ivars->inversion);
entry_ivars->inversion = Inversion_new(seed);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/Posting/MatchPosting.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Posting/MatchPosting.c b/core/Lucy/Index/Posting/MatchPosting.c
index c794660..55c9734 100644
--- a/core/Lucy/Index/Posting/MatchPosting.c
+++ b/core/Lucy/Index/Posting/MatchPosting.c
@@ -98,17 +98,17 @@ RawPosting*
MatchPost_Read_Raw_IMP(MatchPosting *self, InStream *instream,
int32_t last_doc_id, String *term_text,
MemoryPool *mem_pool) {
- char *const text_buf = (char*)Str_Get_Ptr8(term_text);
- const size_t text_size = Str_Get_Size(term_text);
- const uint32_t doc_code = InStream_Read_C32(instream);
- const uint32_t delta_doc = doc_code >> 1;
- const int32_t doc_id = last_doc_id + delta_doc;
- const uint32_t freq = (doc_code & 1)
- ? 1
- : InStream_Read_C32(instream);
- const size_t base_size = VTable_Get_Obj_Alloc_Size(RAWPOSTING);
- size_t raw_post_bytes = MAX_RAW_POSTING_LEN(base_size, text_size);
- void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
+ const char *const text_buf = Str_Get_Ptr8(term_text);
+ const size_t text_size = Str_Get_Size(term_text);
+ const uint32_t doc_code = InStream_Read_C32(instream);
+ const uint32_t delta_doc = doc_code >> 1;
+ const int32_t doc_id = last_doc_id + delta_doc;
+ const uint32_t freq = (doc_code & 1)
+ ? 1
+ : InStream_Read_C32(instream);
+ const size_t base_size = VTable_Get_Obj_Alloc_Size(RAWPOSTING);
+ size_t raw_post_bytes = MAX_RAW_POSTING_LEN(base_size, text_size);
+ void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
UNUSED_VAR(self);
return RawPost_new(allocation, doc_id, freq, text_buf, text_size);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/Posting/RawPosting.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Posting/RawPosting.c b/core/Lucy/Index/Posting/RawPosting.c
index 90ba43f..5f5e8d4 100644
--- a/core/Lucy/Index/Posting/RawPosting.c
+++ b/core/Lucy/Index/Posting/RawPosting.c
@@ -32,7 +32,7 @@
RawPosting*
RawPost_new(void *pre_allocated_memory, int32_t doc_id, uint32_t freq,
- char *term_text, size_t term_text_len) {
+ const char *term_text, size_t term_text_len) {
RawPosting *self
= (RawPosting*)VTable_Init_Obj(RAWPOSTING, pre_allocated_memory);
RawPostingIVARS *const ivars = RawPost_IVARS(self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/Posting/RawPosting.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Posting/RawPosting.cfh b/core/Lucy/Index/Posting/RawPosting.cfh
index aab5846..e82c390 100644
--- a/core/Lucy/Index/Posting/RawPosting.cfh
+++ b/core/Lucy/Index/Posting/RawPosting.cfh
@@ -48,7 +48,7 @@ class Lucy::Index::RawPosting cnick RawPost
*/
inert incremented RawPosting*
new(void *pre_allocated_memory, int32_t doc_id, uint32_t freq,
- char *term_text, size_t term_text_len);
+ const char *term_text, size_t term_text_len);
uint32_t
Get_RefCount(RawPosting* self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/Posting/RichPosting.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Posting/RichPosting.c b/core/Lucy/Index/Posting/RichPosting.c
index e50eb48..f5af4ce 100644
--- a/core/Lucy/Index/Posting/RichPosting.c
+++ b/core/Lucy/Index/Posting/RichPosting.c
@@ -155,17 +155,17 @@ RawPosting*
RichPost_Read_Raw_IMP(RichPosting *self, InStream *instream,
int32_t last_doc_id, String *term_text,
MemoryPool *mem_pool) {
- char *const text_buf = (char*)Str_Get_Ptr8(term_text);
- const size_t text_size = Str_Get_Size(term_text);
- const uint32_t doc_code = InStream_Read_C32(instream);
- const uint32_t delta_doc = doc_code >> 1;
- const int32_t doc_id = last_doc_id + delta_doc;
- const uint32_t freq = (doc_code & 1)
- ? 1
- : InStream_Read_C32(instream);
- const size_t base_size = VTable_Get_Obj_Alloc_Size(RAWPOSTING);
- size_t raw_post_bytes = MAX_RAW_POSTING_LEN(base_size, text_size, freq);
- void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
+ const char *const text_buf = Str_Get_Ptr8(term_text);
+ const size_t text_size = Str_Get_Size(term_text);
+ const uint32_t doc_code = InStream_Read_C32(instream);
+ const uint32_t delta_doc = doc_code >> 1;
+ const int32_t doc_id = last_doc_id + delta_doc;
+ const uint32_t freq = (doc_code & 1)
+ ? 1
+ : InStream_Read_C32(instream);
+ const size_t base_size = VTable_Get_Obj_Alloc_Size(RAWPOSTING);
+ size_t raw_post_bytes = MAX_RAW_POSTING_LEN(base_size, text_size, freq);
+ void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
RawPosting *const raw_posting
= RawPost_new(allocation, doc_id, freq, text_buf, text_size);
RawPostingIVARS *const raw_post_ivars = RawPost_IVARS(raw_posting);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/Posting/ScorePosting.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Posting/ScorePosting.c b/core/Lucy/Index/Posting/ScorePosting.c
index 321065f..b2d3265 100644
--- a/core/Lucy/Index/Posting/ScorePosting.c
+++ b/core/Lucy/Index/Posting/ScorePosting.c
@@ -174,17 +174,17 @@ RawPosting*
ScorePost_Read_Raw_IMP(ScorePosting *self, InStream *instream,
int32_t last_doc_id, String *term_text,
MemoryPool *mem_pool) {
- char *const text_buf = (char*)Str_Get_Ptr8(term_text);
- const size_t text_size = Str_Get_Size(term_text);
- const uint32_t doc_code = InStream_Read_C32(instream);
- const uint32_t delta_doc = doc_code >> 1;
- const int32_t doc_id = last_doc_id + delta_doc;
- const uint32_t freq = (doc_code & 1)
- ? 1
- : InStream_Read_C32(instream);
- const size_t base_size = VTable_Get_Obj_Alloc_Size(RAWPOSTING);
- size_t raw_post_bytes = MAX_RAW_POSTING_LEN(base_size, text_size, freq);
- void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
+ const char *const text_buf = Str_Get_Ptr8(term_text);
+ const size_t text_size = Str_Get_Size(term_text);
+ const uint32_t doc_code = InStream_Read_C32(instream);
+ const uint32_t delta_doc = doc_code >> 1;
+ const int32_t doc_id = last_doc_id + delta_doc;
+ const uint32_t freq = (doc_code & 1)
+ ? 1
+ : InStream_Read_C32(instream);
+ const size_t base_size = VTable_Get_Obj_Alloc_Size(RAWPOSTING);
+ size_t raw_post_bytes = MAX_RAW_POSTING_LEN(base_size, text_size, freq);
+ void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
RawPosting *const raw_posting
= RawPost_new(allocation, doc_id, freq, text_buf, text_size);
RawPostingIVARS *const raw_post_ivars = RawPost_IVARS(raw_posting);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/PostingPool.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingPool.c b/core/Lucy/Index/PostingPool.c
index 86eab72..a969fd5 100644
--- a/core/Lucy/Index/PostingPool.c
+++ b/core/Lucy/Index/PostingPool.c
@@ -379,8 +379,8 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
RawPostingIVARS *post_ivars = RawPost_IVARS(posting);
String *last_term_text
= Str_new_from_utf8(post_ivars->blob, post_ivars->content_len);
- char *last_text_buf = (char*)Str_Get_Ptr8(last_term_text);
- uint32_t last_text_size = Str_Get_Size(last_term_text);
+ const char *last_text_buf = Str_Get_Ptr8(last_term_text);
+ uint32_t last_text_size = Str_Get_Size(last_term_text);
SkipStepper_Set_ID_And_Filepos(skip_stepper, 0, 0);
// Initialize sentinel to be used on the last iter, using an empty string
@@ -429,7 +429,7 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
DECREF(last_term_text);
last_term_text
= Str_new_from_utf8(post_ivars->blob, post_ivars->content_len);
- last_text_buf = (char*)Str_Get_Ptr8(last_term_text);
+ last_text_buf = Str_Get_Ptr8(last_term_text);
last_text_size = Str_Get_Size(last_term_text);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index 5e4f173..86bb84d 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -265,7 +265,7 @@ S_write_val(Obj *val, int8_t prim_id, OutStream *ix_out, OutStream *dat_out,
String *string = (String*)val;
int64_t dat_pos = OutStream_Tell(dat_out) - dat_start;
OutStream_Write_I64(ix_out, dat_pos);
- OutStream_Write_Bytes(dat_out, (char*)Str_Get_Ptr8(string),
+ OutStream_Write_Bytes(dat_out, Str_Get_Ptr8(string),
Str_Get_Size(string));
break;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Plan/TextType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/TextType.c b/core/Lucy/Plan/TextType.c
index f9e6fcc..487317c 100644
--- a/core/Lucy/Plan/TextType.c
+++ b/core/Lucy/Plan/TextType.c
@@ -93,8 +93,8 @@ void
TextTermStepper_Write_Key_Frame_IMP(TextTermStepper *self,
OutStream *outstream, Obj *value) {
TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
- uint8_t *buf = Str_Get_Ptr8((String*)value);
- size_t size = Str_Get_Size((String*)value);
+ const char *buf = Str_Get_Ptr8((String*)value);
+ size_t size = Str_Get_Size((String*)value);
OutStream_Write_C32(outstream, size);
OutStream_Write_Bytes(outstream, buf, size);
Obj_Mimic(ivars->value, value);
@@ -107,12 +107,12 @@ void
TextTermStepper_Write_Delta_IMP(TextTermStepper *self, OutStream *outstream,
Obj *value) {
TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
- String *new_value = (String*)CERTIFY(value, STRING);
- CharBuf *last_value = (CharBuf*)ivars->value;
- char *new_text = (char*)Str_Get_Ptr8(new_value);
- size_t new_size = Str_Get_Size(new_value);
- char *last_text = (char*)CB_Get_Ptr8(last_value);
- size_t last_size = CB_Get_Size(last_value);
+ String *new_value = (String*)CERTIFY(value, STRING);
+ CharBuf *last_value = (CharBuf*)ivars->value;
+ const char *new_text = Str_Get_Ptr8(new_value);
+ size_t new_size = Str_Get_Size(new_value);
+ const char *last_text = CB_Get_Ptr8(last_value);
+ size_t last_size = CB_Get_Size(last_value);
// Count how many bytes the strings share at the top.
const int32_t overlap = StrHelp_overlap(last_text, new_text,
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Store/FSDirHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSDirHandle.c b/core/Lucy/Store/FSDirHandle.c
index 6fcf793..5f1a23f 100644
--- a/core/Lucy/Store/FSDirHandle.c
+++ b/core/Lucy/Store/FSDirHandle.c
@@ -65,10 +65,10 @@ SI_is_updir(const char *name, size_t len) {
FSDirHandle*
FSDH_do_open(FSDirHandle *self, const String *dir) {
- size_t dir_path_size = Str_Get_Size(dir);
- char *dir_path_ptr = (char*)Str_Get_Ptr8(dir);
- char search_string[MAX_PATH + 1];
- char *path_ptr = search_string;
+ size_t dir_path_size = Str_Get_Size(dir);
+ const char *dir_path_ptr = Str_Get_Ptr8(dir);
+ char search_string[MAX_PATH + 1];
+ char *path_ptr = search_string;
DH_init((DirHandle*)self, dir);
FSDirHandleIVARS *const ivars = FSDH_IVARS(self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Store/FSFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFolder.c b/core/Lucy/Store/FSFolder.c
index eb1c54f..cb4d09e 100644
--- a/core/Lucy/Store/FSFolder.c
+++ b/core/Lucy/Store/FSFolder.c
@@ -289,8 +289,8 @@ S_fullpath_ptr(FSFolder *self, const String *path) {
size_t folder_size = Str_Get_Size(ivars->path);
size_t path_size = Str_Get_Size(path);
size_t full_size = folder_size + 1 + path_size;
- const char *folder_ptr = (char*)Str_Get_Ptr8(ivars->path);
- const char *path_ptr = (char*)Str_Get_Ptr8(path);
+ const char *folder_ptr = Str_Get_Ptr8(ivars->path);
+ const char *path_ptr = Str_Get_Ptr8(path);
char *buf = (char*)MALLOCATE(full_size + 1);
memcpy(buf, folder_ptr, folder_size);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Test/Analysis/TestNormalizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Analysis/TestNormalizer.c b/core/Lucy/Test/Analysis/TestNormalizer.c
index b1fea5c..9bea51c 100644
--- a/core/Lucy/Test/Analysis/TestNormalizer.c
+++ b/core/Lucy/Test/Analysis/TestNormalizer.c
@@ -119,7 +119,8 @@ test_utf8proc_normalization(TestBatchRunner *runner) {
// Normalize once.
uint8_t *normalized;
- int32_t check = utf8proc_map(Str_Get_Ptr8(source), Str_Get_Size(source),
+ int32_t check = utf8proc_map((const uint8_t*)Str_Get_Ptr8(source),
+ Str_Get_Size(source),
&normalized,
UTF8PROC_STABLE |
UTF8PROC_COMPOSE |
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Test/Search/TestQueryParserLogic.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestQueryParserLogic.c b/core/Lucy/Test/Search/TestQueryParserLogic.c
index 6083fac..902c257 100644
--- a/core/Lucy/Test/Search/TestQueryParserLogic.c
+++ b/core/Lucy/Test/Search/TestQueryParserLogic.c
@@ -906,9 +906,9 @@ TestQPLogic_Run_IMP(TestQueryParserLogic *self, TestBatchRunner *runner) {
Hits *hits = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);
TEST_TRUE(runner, Query_Equals(tree, (Obj*)test_case->tree),
- "tree() OR %s", (char*)Str_Get_Ptr8(test_case->query_string));
+ "tree() OR %s", Str_Get_Ptr8(test_case->query_string));
TEST_INT_EQ(runner, Hits_Total_Hits(hits), test_case->num_hits,
- "hits: OR %s", (char*)Str_Get_Ptr8(test_case->query_string));
+ "hits: OR %s", Str_Get_Ptr8(test_case->query_string));
DECREF(hits);
DECREF(parsed);
DECREF(tree);
@@ -925,9 +925,9 @@ TestQPLogic_Run_IMP(TestQueryParserLogic *self, TestBatchRunner *runner) {
Hits *hits = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);
TEST_TRUE(runner, Query_Equals(tree, (Obj*)test_case->tree),
- "tree() AND %s", (char*)Str_Get_Ptr8(test_case->query_string));
+ "tree() AND %s", Str_Get_Ptr8(test_case->query_string));
TEST_INT_EQ(runner, Hits_Total_Hits(hits), test_case->num_hits,
- "hits: AND %s", (char*)Str_Get_Ptr8(test_case->query_string));
+ "hits: AND %s", Str_Get_Ptr8(test_case->query_string));
DECREF(hits);
DECREF(parsed);
DECREF(tree);
@@ -949,11 +949,11 @@ TestQPLogic_Run_IMP(TestQueryParserLogic *self, TestBatchRunner *runner) {
Hits *hits;
TEST_TRUE(runner, Query_Equals(pruned, (Obj*)wanted),
- "prune() %s", (char*)Str_Get_Ptr8(qstring));
+ "prune() %s", Str_Get_Ptr8(qstring));
expanded = QParser_Expand(or_parser, pruned);
hits = IxSearcher_Hits(searcher, (Obj*)expanded, 0, 10, NULL);
TEST_INT_EQ(runner, Hits_Total_Hits(hits), test_case->num_hits,
- "hits: %s", (char*)Str_Get_Ptr8(qstring));
+ "hits: %s", Str_Get_Ptr8(qstring));
DECREF(hits);
DECREF(expanded);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Test/Search/TestQueryParserSyntax.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestQueryParserSyntax.c b/core/Lucy/Test/Search/TestQueryParserSyntax.c
index 6a074b3..fde587d 100644
--- a/core/Lucy/Test/Search/TestQueryParserSyntax.c
+++ b/core/Lucy/Test/Search/TestQueryParserSyntax.c
@@ -405,11 +405,11 @@ test_query_parser_syntax(TestBatchRunner *runner) {
Hits *hits = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);
TEST_TRUE(runner, Query_Equals(tree, (Obj*)ivars->tree),
- "tree() %s", (char*)Str_Get_Ptr8(ivars->query_string));
+ "tree() %s", Str_Get_Ptr8(ivars->query_string));
TEST_TRUE(runner, Query_Equals(expanded, (Obj*)ivars->expanded),
- "expand_leaf() %s", (char*)Str_Get_Ptr8(ivars->query_string));
+ "expand_leaf() %s", Str_Get_Ptr8(ivars->query_string));
TEST_INT_EQ(runner, Hits_Total_Hits(hits), ivars->num_hits,
- "hits: %s", (char*)Str_Get_Ptr8(ivars->query_string));
+ "hits: %s", Str_Get_Ptr8(ivars->query_string));
DECREF(hits);
DECREF(parsed);
DECREF(expanded);
@@ -426,9 +426,9 @@ test_query_parser_syntax(TestBatchRunner *runner) {
Hits *hits = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);
TEST_TRUE(runner, Query_Equals(tree, (Obj*)ivars->tree),
- "tree() %s", (char*)Str_Get_Ptr8(ivars->query_string));
+ "tree() %s", Str_Get_Ptr8(ivars->query_string));
TEST_INT_EQ(runner, Hits_Total_Hits(hits), ivars->num_hits,
- "hits: %s", (char*)Str_Get_Ptr8(ivars->query_string));
+ "hits: %s", Str_Get_Ptr8(ivars->query_string));
DECREF(hits);
DECREF(parsed);
DECREF(tree);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Test/Store/TestFSFileHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestFSFileHandle.c b/core/Lucy/Test/Store/TestFSFileHandle.c
index d9faa32..f1f78fb 100644
--- a/core/Lucy/Test/Store/TestFSFileHandle.c
+++ b/core/Lucy/Test/Store/TestFSFileHandle.c
@@ -44,7 +44,7 @@ test_open(TestBatchRunner *runner) {
FSFileHandle *fh;
String *test_filename = (String*)SSTR_WRAP_STR("_fstest", 7);
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
Err_set_error(NULL);
fh = FSFH_open(test_filename, FH_READ_ONLY);
@@ -98,7 +98,7 @@ test_open(TestBatchRunner *runner) {
"open() read only -- no errors");
DECREF(fh);
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
}
static void
@@ -110,7 +110,7 @@ test_Read_Write(TestBatchRunner *runner) {
char *buf = buffer;
String *test_filename = (String*)SSTR_WRAP_STR("_fstest", 7);
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
fh = FSFH_open(test_filename,
FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
@@ -157,7 +157,7 @@ test_Read_Write(TestBatchRunner *runner) {
"Writing to a read-only handle sets error");
DECREF(fh);
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
}
static void
@@ -165,7 +165,7 @@ test_Close(TestBatchRunner *runner) {
String *test_filename = (String*)SSTR_WRAP_STR("_fstest", 7);
FSFileHandle *fh;
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
fh = FSFH_open(test_filename,
FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
TEST_TRUE(runner, FSFH_Close(fh), "Close returns true for write-only");
@@ -173,7 +173,7 @@ test_Close(TestBatchRunner *runner) {
// Simulate an OS error when closing the file descriptor. This
// approximates what would happen if, say, we run out of disk space.
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
fh = FSFH_open(test_filename,
FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
#ifdef _MSC_VER
@@ -195,7 +195,7 @@ test_Close(TestBatchRunner *runner) {
TEST_TRUE(runner, FSFH_Close(fh), "Close returns true for read-only");
DECREF(fh);
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
}
static void
@@ -206,7 +206,7 @@ test_Window(TestBatchRunner *runner) {
FileWindowIVARS *const window_ivars = FileWindow_IVARS(window);
uint32_t i;
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
fh = FSFH_open(test_filename,
FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
for (i = 0; i < 1024; i++) {
@@ -245,7 +245,7 @@ test_Window(TestBatchRunner *runner) {
DECREF(window);
DECREF(fh);
- remove((char*)Str_Get_Ptr8(test_filename));
+ remove(Str_Get_Ptr8(test_filename));
}
void
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Test/TestUtils.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/TestUtils.c b/core/Lucy/Test/TestUtils.c
index 6da1d7f..38576a6 100644
--- a/core/Lucy/Test/TestUtils.c
+++ b/core/Lucy/Test/TestUtils.c
@@ -131,7 +131,7 @@ void
TestUtils_test_analyzer(TestBatchRunner *runner, Analyzer *analyzer,
String *source, VArray *expected,
const char *message) {
- Token *seed = Token_new((char*)Str_Get_Ptr8(source), Str_Get_Size(source),
+ Token *seed = Token_new(Str_Get_Ptr8(source), Str_Get_Size(source),
0, 0, 1.0f, 1);
Inversion *starter = Inversion_new(seed);
Inversion *transformed = Analyzer_Transform(analyzer, starter);
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Util/Freezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c
index 521ea03..5452728 100644
--- a/core/Lucy/Util/Freezer.c
+++ b/core/Lucy/Util/Freezer.c
@@ -204,8 +204,8 @@ Freezer_deserialize(Obj *obj, InStream *instream) {
void
Freezer_serialize_string(String *string, OutStream *outstream) {
- size_t size = Str_Get_Size(string);
- uint8_t *buf = Str_Get_Ptr8(string);
+ size_t size = Str_Get_Size(string);
+ const char *buf = Str_Get_Ptr8(string);
OutStream_Write_C64(outstream, size);
OutStream_Write_Bytes(outstream, buf, size);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index c564c55..5fedf1e 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -46,31 +46,32 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth);
// Parse JSON from raw UTF-8 in memory.
static Obj*
-S_parse_json(char *text, size_t size);
+S_parse_json(const char *text, size_t size);
static Obj*
-S_do_parse_json(void *json_parser, char *json, size_t len);
+S_do_parse_json(void *json_parser, const char *json, size_t len);
// Parse a JSON number. Advance the text buffer just past the number.
static Float64*
-S_parse_number(char **json_ptr, char *const limit);
+S_parse_number(const char **json_ptr, const char *limit);
// Parse a JSON string. Advance the text buffer from pointing at the opening
// double quote to pointing just after the closing double quote.
static String*
-S_parse_string(char **json_ptr, char *const limit);
+S_parse_string(const char **json_ptr, const char *limit);
// Unescape JSON string text. Expects pointers bookending the text data (i.e.
// pointing just after the opening double quote and directly at the closing
// double quote), and assumes that escapes have already been sanity checked
// for length.
static String*
-S_unescape_text(char *const top, char *const end);
+S_unescape_text(const char *top, const char *end);
// Check that the supplied text begins with the specified keyword, which must
// then end on a word boundary (i.e. match "null" but not the first four
// letters of "nullify").
static CFISH_INLINE bool
-SI_check_keyword(char *json, char* end, const char *keyword, size_t len);
+SI_check_keyword(const char *json, const char* end, const char *keyword,
+ size_t len);
// Make it possible to be loosen constraints during testing.
static bool tolerant = false;
@@ -85,14 +86,14 @@ S_cat_whitespace(CharBuf *buf, int32_t depth);
// Set Err_error, appending escaped JSON in the vicinity of the error.
static void
-S_set_error(CharBuf *buf, char *json, char *limit, int line,
+S_set_error(CharBuf *buf, const char *json, const char *limit, int line,
const char *func);
#define SET_ERROR(_mess, _json, _end) \
S_set_error(_mess, _json, _end, __LINE__, CFISH_ERR_FUNC_MACRO)
Obj*
Json_from_json(String *json) {
- Obj *dump = S_parse_json((char*)Str_Get_Ptr8(json), Str_Get_Size(json));
+ Obj *dump = S_parse_json(Str_Get_Ptr8(json), Str_Get_Size(json));
if (!dump) {
ERR_ADD_FRAME(Err_get_error());
}
@@ -372,7 +373,7 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
}
static Obj*
-S_parse_json(char *text, size_t size) {
+S_parse_json(const char *text, size_t size) {
void *json_parser = LucyParseJsonAlloc(Memory_wrapped_malloc);
if (json_parser == NULL) {
String *mess = MAKE_MESS("Failed to allocate JSON parser");
@@ -385,17 +386,17 @@ S_parse_json(char *text, size_t size) {
}
static Obj*
-S_do_parse_json(void *json_parser, char *json, size_t len) {
+S_do_parse_json(void *json_parser, const char *json, size_t len) {
lucy_JsonParserState state;
state.result = NULL;
state.errors = false;
- char *text = json;
- char *const end = text + len;
+ const char *text = json;
+ const char *const end = text + len;
while (text < end) {
int token_type = -1;
Obj *value = NULL;
- char *const save = text;
+ const char *const save = text;
switch (*text) {
case ' ': case '\n': case '\r': case '\t':
// Skip insignificant whitespace, which the JSON RFC defines
@@ -491,9 +492,9 @@ S_do_parse_json(void *json_parser, char *json, size_t len) {
}
static Float64*
-S_parse_number(char **json_ptr, char *const limit) {
- char *top = *json_ptr;
- char *end = top;
+S_parse_number(const char **json_ptr, const char *limit) {
+ const char *top = *json_ptr;
+ const char *end = top;
bool terminated = false;
// We can't assume NULL termination for the JSON string, so we need to
@@ -529,12 +530,12 @@ S_parse_number(char **json_ptr, char *const limit) {
}
static String*
-S_parse_string(char **json_ptr, char *const limit) {
+S_parse_string(const char **json_ptr, const char *limit) {
// Find terminating double quote, determine whether there are any escapes.
- char *top = *json_ptr + 1;
- char *end = NULL;
+ const char *top = *json_ptr + 1;
+ const char *end = NULL;
bool saw_backslash = false;
- for (char *text = top; text < limit; text++) {
+ for (const char *text = top; text < limit; text++) {
if (*text == '"') {
end = text;
break;
@@ -573,7 +574,7 @@ S_parse_string(char **json_ptr, char *const limit) {
}
static String*
-S_unescape_text(char *const top, char *const end) {
+S_unescape_text(const char *top, const char *end) {
// The unescaped string will never be longer than the escaped string
// because only a \u escape can theoretically be too long and
// StrHelp_encode_utf8_char guards against sequences over 4 bytes.
@@ -581,7 +582,7 @@ S_unescape_text(char *const top, char *const end) {
size_t cap = end - top + 1;
char *target_buf = (char*)MALLOCATE(cap);
size_t target_size = 0;
- for (char *text = top; text < end; text++) {
+ for (const char *text = top; text < end; text++) {
if (*text != '\\') {
target_buf[target_size++] = *text;
}
@@ -657,7 +658,8 @@ S_unescape_text(char *const top, char *const end) {
}
static CFISH_INLINE bool
-SI_check_keyword(char *json, char* end, const char *keyword, size_t len) {
+SI_check_keyword(const char *json, const char* end, const char *keyword,
+ size_t len) {
if ((size_t)(end - json) > len
&& strncmp(json, keyword, len) == 0
&& json[len] != '_'
@@ -669,7 +671,7 @@ SI_check_keyword(char *json, char* end, const char *keyword, size_t len) {
}
static void
-S_set_error(CharBuf *buf, char *json, char *limit, int line,
+S_set_error(CharBuf *buf, const char *json, const char *limit, int line,
const char *func) {
if (func) {
CB_catf(buf, " at %s %s line %i32 near ", func, __FILE__,
http://git-wip-us.apache.org/repos/asf/lucy/blob/6c889682/perl/xs/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Document/Doc.c b/perl/xs/Lucy/Document/Doc.c
index 1d6723a..f31eca3 100644
--- a/perl/xs/Lucy/Document/Doc.c
+++ b/perl/xs/Lucy/Document/Doc.c
@@ -54,8 +54,8 @@ LUCY_Doc_Get_Size_IMP(lucy_Doc *self) {
void
LUCY_Doc_Store_IMP(lucy_Doc *self, const cfish_String *field, cfish_Obj *value) {
lucy_DocIVARS *const ivars = lucy_Doc_IVARS(self);
- char *key = (char*)CFISH_Str_Get_Ptr8(field);
- size_t key_size = CFISH_Str_Get_Size(field);
+ const char *key = CFISH_Str_Get_Ptr8(field);
+ size_t key_size = CFISH_Str_Get_Size(field);
SV *key_sv = newSVpvn(key, key_size);
SV *val_sv = value == NULL
? newSV(0)
@@ -146,7 +146,7 @@ cfish_Obj*
LUCY_Doc_Extract_IMP(lucy_Doc *self, cfish_String *field) {
lucy_DocIVARS *const ivars = lucy_Doc_IVARS(self);
cfish_Obj *retval = NULL;
- SV **sv_ptr = hv_fetch((HV*)ivars->fields, (char*)CFISH_Str_Get_Ptr8(field),
+ SV **sv_ptr = hv_fetch((HV*)ivars->fields, CFISH_Str_Get_Ptr8(field),
CFISH_Str_Get_Size(field), 0);
if (sv_ptr && XSBind_sv_defined(*sv_ptr)) {
[lucy-commits] [12/15] git commit: refs/heads/cfish-string-prep1 - Replace
*_Dec_RefCount with DECREF
Posted by nw...@apache.org.
Replace *_Dec_RefCount with DECREF
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/6f48dc35
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/6f48dc35
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/6f48dc35
Branch: refs/heads/cfish-string-prep1
Commit: 6f48dc3541dfed4fa7beef1f5ba48870f376bbaa
Parents: c798605
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 10 18:51:46 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 14 20:36:20 2013 +0200
----------------------------------------------------------------------
core/Lucy/Index/Snapshot.c | 2 +-
core/Lucy/Index/SortCache/NumericSortCache.c | 4 ++--
core/Lucy/Index/SortCache/TextSortCache.c | 6 +++---
core/Lucy/Index/SortReader.c | 8 ++++----
core/Lucy/Search/PolyQuery.c | 2 +-
core/Lucy/Store/CompoundFileReader.c | 4 ++--
core/Lucy/Store/RAMDirHandle.c | 4 ++--
7 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f48dc35/core/Lucy/Index/Snapshot.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Snapshot.c b/core/Lucy/Index/Snapshot.c
index a8b2afe..fd9f546 100644
--- a/core/Lucy/Index/Snapshot.c
+++ b/core/Lucy/Index/Snapshot.c
@@ -70,7 +70,7 @@ Snapshot_Delete_Entry_IMP(Snapshot *self, const String *entry) {
SnapshotIVARS *const ivars = Snapshot_IVARS(self);
Obj *val = Hash_Delete(ivars->entries, (Obj*)entry);
if (val) {
- Obj_Dec_RefCount(val);
+ DECREF(val);
return true;
}
else {
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f48dc35/core/Lucy/Index/SortCache/NumericSortCache.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortCache/NumericSortCache.c b/core/Lucy/Index/SortCache/NumericSortCache.c
index 7241e6f..fe35359 100644
--- a/core/Lucy/Index/SortCache/NumericSortCache.c
+++ b/core/Lucy/Index/SortCache/NumericSortCache.c
@@ -70,11 +70,11 @@ NumSortCache_Destroy_IMP(NumericSortCache *self) {
NumericSortCacheIVARS *const ivars = NumSortCache_IVARS(self);
if (ivars->ord_in) {
InStream_Close(ivars->ord_in);
- InStream_Dec_RefCount(ivars->ord_in);
+ DECREF(ivars->ord_in);
}
if (ivars->dat_in) {
InStream_Close(ivars->dat_in);
- InStream_Dec_RefCount(ivars->dat_in);
+ DECREF(ivars->dat_in);
}
SUPER_DESTROY(self, NUMERICSORTCACHE);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f48dc35/core/Lucy/Index/SortCache/TextSortCache.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortCache/TextSortCache.c b/core/Lucy/Index/SortCache/TextSortCache.c
index ad533a4..b96c49f 100644
--- a/core/Lucy/Index/SortCache/TextSortCache.c
+++ b/core/Lucy/Index/SortCache/TextSortCache.c
@@ -73,15 +73,15 @@ TextSortCache_Destroy_IMP(TextSortCache *self) {
TextSortCacheIVARS *const ivars = TextSortCache_IVARS(self);
if (ivars->ord_in) {
InStream_Close(ivars->ord_in);
- InStream_Dec_RefCount(ivars->ord_in);
+ DECREF(ivars->ord_in);
}
if (ivars->ix_in) {
InStream_Close(ivars->ix_in);
- InStream_Dec_RefCount(ivars->ix_in);
+ DECREF(ivars->ix_in);
}
if (ivars->dat_in) {
InStream_Close(ivars->dat_in);
- InStream_Dec_RefCount(ivars->dat_in);
+ DECREF(ivars->dat_in);
}
SUPER_DESTROY(self, TEXTSORTCACHE);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f48dc35/core/Lucy/Index/SortReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortReader.c b/core/Lucy/Index/SortReader.c
index 2958422..28b55f0 100644
--- a/core/Lucy/Index/SortReader.c
+++ b/core/Lucy/Index/SortReader.c
@@ -118,19 +118,19 @@ void
DefSortReader_Close_IMP(DefaultSortReader *self) {
DefaultSortReaderIVARS *const ivars = DefSortReader_IVARS(self);
if (ivars->caches) {
- Hash_Dec_RefCount(ivars->caches);
+ DECREF(ivars->caches);
ivars->caches = NULL;
}
if (ivars->counts) {
- Hash_Dec_RefCount(ivars->counts);
+ DECREF(ivars->counts);
ivars->counts = NULL;
}
if (ivars->null_ords) {
- Hash_Dec_RefCount(ivars->null_ords);
+ DECREF(ivars->null_ords);
ivars->null_ords = NULL;
}
if (ivars->ord_widths) {
- Hash_Dec_RefCount(ivars->ord_widths);
+ DECREF(ivars->ord_widths);
ivars->ord_widths = NULL;
}
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f48dc35/core/Lucy/Search/PolyQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/PolyQuery.c b/core/Lucy/Search/PolyQuery.c
index 8e85af9..6d74c35 100644
--- a/core/Lucy/Search/PolyQuery.c
+++ b/core/Lucy/Search/PolyQuery.c
@@ -194,7 +194,7 @@ PolyCompiler_Highlight_Spans_IMP(PolyCompiler *self, Searcher *searcher,
doc_vec, field);
if (child_spans) {
VA_Push_VArray(spans, child_spans);
- VA_Dec_RefCount(child_spans);
+ DECREF(child_spans);
}
}
return spans;
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f48dc35/core/Lucy/Store/CompoundFileReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/CompoundFileReader.c b/core/Lucy/Store/CompoundFileReader.c
index 8ee59c7..86307c3 100644
--- a/core/Lucy/Store/CompoundFileReader.c
+++ b/core/Lucy/Store/CompoundFileReader.c
@@ -299,11 +299,11 @@ bool
CFReaderDH_Close_IMP(CFReaderDirHandle *self) {
CFReaderDirHandleIVARS *const ivars = CFReaderDH_IVARS(self);
if (ivars->elems) {
- VA_Dec_RefCount(ivars->elems);
+ DECREF(ivars->elems);
ivars->elems = NULL;
}
if (ivars->cf_reader) {
- CFReader_Dec_RefCount(ivars->cf_reader);
+ DECREF(ivars->cf_reader);
ivars->cf_reader = NULL;
}
return true;
http://git-wip-us.apache.org/repos/asf/lucy/blob/6f48dc35/core/Lucy/Store/RAMDirHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/RAMDirHandle.c b/core/Lucy/Store/RAMDirHandle.c
index 993f741..39caf05 100644
--- a/core/Lucy/Store/RAMDirHandle.c
+++ b/core/Lucy/Store/RAMDirHandle.c
@@ -42,11 +42,11 @@ bool
RAMDH_Close_IMP(RAMDirHandle *self) {
RAMDirHandleIVARS *const ivars = RAMDH_IVARS(self);
if (ivars->elems) {
- VA_Dec_RefCount(ivars->elems);
+ DECREF(ivars->elems);
ivars->elems = NULL;
}
if (ivars->folder) {
- RAMFolder_Dec_RefCount(ivars->folder);
+ DECREF(ivars->folder);
ivars->folder = NULL;
}
return true;