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:40 UTC
[lucy-commits] [08/15] git commit: refs/heads/cfish-string-prep1 - Make Str_Get_Ptr8
return a const char pointer.
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)) {