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/23 15:40:55 UTC
[lucy-commits] [2/2] git commit: refs/heads/cfish-string-prep1 - Make StrIter_Next
and StrIter_Prev return an int32_t
Make StrIter_Next and StrIter_Prev return an int32_t
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/7b5ef781
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/7b5ef781
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/7b5ef781
Branch: refs/heads/cfish-string-prep1
Commit: 7b5ef781c8a9689749e9e867869fa228a500ae2c
Parents: c69fb74
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Mon Sep 23 14:55:48 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Sep 23 15:15:04 2013 +0200
----------------------------------------------------------------------
clownfish/runtime/core/Clownfish/String.c | 36 ++++++++++----------
clownfish/runtime/core/Clownfish/String.cfh | 6 ++--
.../runtime/core/Clownfish/Test/TestString.c | 4 +--
clownfish/runtime/core/Clownfish/VTable.c | 2 +-
core/Lucy/Highlight/Highlighter.c | 8 ++---
core/Lucy/Index/Segment.c | 2 +-
core/Lucy/Search/QueryParser.c | 4 +--
core/Lucy/Search/QueryParser/QueryLexer.c | 12 +++----
core/Lucy/Store/Folder.c | 2 +-
core/Lucy/Store/Lock.c | 2 +-
core/Lucy/Store/SharedLock.c | 2 +-
core/Lucy/Util/IndexFileNames.c | 4 +--
core/Lucy/Util/Json.c | 2 +-
13 files changed, 43 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index ab4d34e..28f27e6 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -204,7 +204,7 @@ Str_Hash_Sum_IMP(String *self) {
const StrIter_Next_t next
= METHOD_PTR(STRINGITERATOR, CFISH_StrIter_Next);
- uint32_t code_point;
+ int32_t code_point;
while (STRITER_DONE != (code_point = next((StringIterator*)iter))) {
hashvalue = ((hashvalue << 5) + hashvalue) ^ code_point;
}
@@ -231,7 +231,7 @@ String*
Str_Swap_Chars_IMP(String *self, uint32_t match, uint32_t replacement) {
CharBuf *charbuf = CB_new(self->size);
StackStringIterator *iter = STR_STACKTOP(self);
- uint32_t code_point;
+ int32_t code_point;
while (STRITER_DONE != (code_point = SStrIter_Next(iter))) {
if (code_point == match) { code_point = replacement; }
@@ -253,7 +253,7 @@ Str_BaseX_To_I64_IMP(String *self, uint32_t base) {
StackStringIterator *iter = STR_STACKTOP(self);
int64_t retval = 0;
bool is_negative = false;
- uint32_t code_point = SStrIter_Next(iter);
+ int32_t code_point = SStrIter_Next(iter);
// Advance past minus sign.
if (code_point == '-') {
@@ -455,7 +455,7 @@ uint32_t
Str_Code_Point_At_IMP(String *self, size_t tick) {
StackStringIterator *iter = STR_STACKTOP(self);
SStrIter_Advance(iter, tick);
- uint32_t code_point = SStrIter_Next(iter);
+ int32_t code_point = SStrIter_Next(iter);
return code_point == STRITER_DONE ? 0 : code_point;
}
@@ -464,7 +464,7 @@ Str_Code_Point_From_IMP(String *self, size_t tick) {
if (tick == 0) { return 0; }
StackStringIterator *iter = STR_STACKTAIL(self);
SStrIter_Recede(iter, tick - 1);
- uint32_t code_point = SStrIter_Prev(iter);
+ int32_t code_point = SStrIter_Prev(iter);
return code_point == STRITER_DONE ? 0 : code_point;
}
@@ -677,7 +677,7 @@ StrIter_Has_Prev_IMP(StringIterator *self) {
return self->byte_offset != 0;
}
-uint32_t
+int32_t
StrIter_Next_IMP(StringIterator *self) {
String *string = self->string;
size_t byte_offset = self->byte_offset;
@@ -686,7 +686,7 @@ StrIter_Next_IMP(StringIterator *self) {
if (byte_offset >= size) { return STRITER_DONE; }
const uint8_t *const ptr = (const uint8_t*)string->ptr;
- uint32_t retval = ptr[byte_offset++];
+ int32_t retval = ptr[byte_offset++];
if (retval >= 0x80) {
/*
@@ -713,7 +713,7 @@ StrIter_Next_IMP(StringIterator *self) {
* is tested. After the second iteration, the fourth, and so on.
*/
- uint32_t mask = 1 << 6;
+ int32_t mask = 1 << 6;
do {
if (byte_offset >= size) {
@@ -731,14 +731,14 @@ StrIter_Next_IMP(StringIterator *self) {
return retval;
}
-uint32_t
+int32_t
StrIter_Prev_IMP(StringIterator *self) {
size_t byte_offset = self->byte_offset;
if (byte_offset == 0) { return STRITER_DONE; }
const uint8_t *const ptr = (const uint8_t*)self->string->ptr;
- uint32_t retval = ptr[--byte_offset];
+ int32_t retval = ptr[--byte_offset];
if (retval >= 0x80) {
// Construct the result from right to left.
@@ -749,8 +749,8 @@ StrIter_Prev_IMP(StringIterator *self) {
retval &= 0x3F;
int shift = 6;
- uint32_t first_byte_mask = 0x1F;
- uint32_t byte = ptr[--byte_offset];
+ int32_t first_byte_mask = 0x1F;
+ int32_t byte = ptr[--byte_offset];
while ((byte & 0xC0) == 0x80) {
if (byte_offset == 0) {
@@ -822,9 +822,9 @@ StrIter_Recede_IMP(StringIterator *self, size_t num) {
size_t
StrIter_Skip_Next_Whitespace_IMP(StringIterator *self) {
- size_t num_skipped = 0;
- size_t byte_offset = self->byte_offset;
- uint32_t code_point;
+ size_t num_skipped = 0;
+ size_t byte_offset = self->byte_offset;
+ int32_t code_point;
while (STRITER_DONE != (code_point = StrIter_Next(self))) {
if (!StrHelp_is_whitespace(code_point)) { break; }
@@ -838,9 +838,9 @@ StrIter_Skip_Next_Whitespace_IMP(StringIterator *self) {
size_t
StrIter_Skip_Prev_Whitespace_IMP(StringIterator *self) {
- size_t num_skipped = 0;
- size_t byte_offset = self->byte_offset;
- uint32_t code_point;
+ size_t num_skipped = 0;
+ size_t byte_offset = self->byte_offset;
+ int32_t code_point;
while (STRITER_DONE != (code_point = StrIter_Prev(self))) {
if (!StrHelp_is_whitespace(code_point)) { break; }
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index e060aa5..1151589 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -350,13 +350,13 @@ class Clownfish::StringIterator cnick StrIter
/** Return the code point after the current position and advance the
* iterator. Return CFISH_STRITER_DONE at the end of the string.
*/
- public uint32_t
+ public int32_t
Next(StringIterator *self);
/** Return the code point before the current position and go one step back.
* Return CFISH_STRITER_DONE at the start of the string.
*/
- public uint32_t
+ public int32_t
Prev(StringIterator *self);
/** Skip code points.
@@ -436,7 +436,7 @@ __C__
#define CFISH_SSTR_WRAP_STR(ptr, size) \
cfish_SStr_wrap_str(cfish_alloca(cfish_SStr_size()), ptr, size)
-#define CFISH_STRITER_DONE UINT32_MAX
+#define CFISH_STRITER_DONE -1
#ifdef CFISH_USE_SHORT_NAMES
#define SSTR_BLANK CFISH_SSTR_BLANK
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/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 851ff81..652c8e9 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestString.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestString.c
@@ -362,7 +362,7 @@ test_iterator(TestBatchRunner *runner) {
for (int i = 0; i < num_code_points; ++i) {
TEST_TRUE(runner, StrIter_Has_Next(iter), "Has_Next %d", i);
- uint32_t code_point = StrIter_Next(iter);
+ int32_t code_point = StrIter_Next(iter);
TEST_INT_EQ(runner, code_point, code_points[i], "Next %d", i);
}
@@ -383,7 +383,7 @@ test_iterator(TestBatchRunner *runner) {
for (int i = num_code_points - 1; i >= 0; --i) {
TEST_TRUE(runner, StrIter_Has_Prev(iter), "Has_Prev %d", i);
- uint32_t code_point = StrIter_Prev(iter);
+ int32_t code_point = StrIter_Prev(iter);
TEST_INT_EQ(runner, code_point, code_points[i], "Prev %d", i);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/clownfish/runtime/core/Clownfish/VTable.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/VTable.c b/clownfish/runtime/core/Clownfish/VTable.c
index c2bfde8..6596018 100644
--- a/clownfish/runtime/core/Clownfish/VTable.c
+++ b/clownfish/runtime/core/Clownfish/VTable.c
@@ -329,7 +329,7 @@ static String*
S_scrunch_string(String *source) {
CharBuf *buf = CB_new(Str_Get_Size(source));
StringIterator *iter = Str_Top(source);
- uint32_t code_point;
+ int32_t code_point;
while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
if (code_point > 127) {
THROW(ERR, "Can't fold case for %o", source);
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Highlight/Highlighter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Highlight/Highlighter.c b/core/Lucy/Highlight/Highlighter.c
index 2d55639..b181115 100644
--- a/core/Lucy/Highlight/Highlighter.c
+++ b/core/Lucy/Highlight/Highlighter.c
@@ -224,7 +224,7 @@ S_find_starting_boundary(StringIterator *top, uint32_t max_skip,
StringIterator *iter = StrIter_Clone(top);
while (true) {
- uint32_t code_point = StrIter_Prev(iter);
+ int32_t code_point = StrIter_Prev(iter);
if (code_point == STRITER_DONE || code_point == '.') {
// Skip remaining whitespace.
@@ -249,7 +249,7 @@ S_find_starting_boundary(StringIterator *top, uint32_t max_skip,
StrIter_Assign(iter, top);
for (uint32_t i = 0; i < max_skip; ++i) {
- uint32_t code_point = StrIter_Next(iter);
+ int32_t code_point = StrIter_Next(iter);
if (code_point == STRITER_DONE || code_point == '.') {
found_edge = true;
@@ -286,7 +286,7 @@ S_find_starting_boundary(StringIterator *top, uint32_t max_skip,
bool
S_find_ending_boundary(StringIterator *tail, uint32_t max_skip,
uint32_t *num_skipped_ptr) {
- uint32_t code_point;
+ int32_t code_point;
// Check if we're at an ending boundary already. Don't check for a word
// boundary because we need space for a trailing ellipsis.
@@ -587,7 +587,7 @@ S_encode_entities(String *text, CharBuf *buf) {
const int MAX_ENTITY_BYTES = 9; // &#dddddd;
// Scan first so that we only allocate once.
- uint32_t code_point;
+ int32_t code_point;
while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
if (code_point > 127
|| (!isgraph(code_point) && !isspace(code_point))
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Index/Segment.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Segment.c b/core/Lucy/Index/Segment.c
index 21a3f66..50b4e8a 100644
--- a/core/Lucy/Index/Segment.c
+++ b/core/Lucy/Index/Segment.c
@@ -68,7 +68,7 @@ Seg_valid_seg_name(const String *name) {
if (Str_Starts_With_Utf8(name, "seg_", 4)) {
StringIterator *iter = Str_Top(name);
StrIter_Advance(iter, 4);
- uint32_t code_point;
+ int32_t code_point;
while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
if (!isalnum(code_point)) {
DECREF(iter);
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Search/QueryParser.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/QueryParser.c b/core/Lucy/Search/QueryParser.c
index 037d6b1..4d4c86d 100644
--- a/core/Lucy/Search/QueryParser.c
+++ b/core/Lucy/Search/QueryParser.c
@@ -827,7 +827,7 @@ QParser_Expand_IMP(QueryParser *self, Query *query) {
static String*
S_unescape(QueryParser *self, String *orig, CharBuf *buf) {
StringIterator *iter = Str_Top(orig);
- uint32_t code_point;
+ int32_t code_point;
UNUSED_VAR(self);
CB_Set_Size(buf, 0);
@@ -835,7 +835,7 @@ S_unescape(QueryParser *self, String *orig, CharBuf *buf) {
while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
if (code_point == '\\') {
- uint32_t next_code_point = StrIter_Next(iter);
+ int32_t next_code_point = StrIter_Next(iter);
if (next_code_point == ':'
|| next_code_point == '"'
|| next_code_point == '\\'
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Search/QueryParser/QueryLexer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/QueryParser/QueryLexer.c b/core/Lucy/Search/QueryParser/QueryLexer.c
index de9e66f..1f819d6 100644
--- a/core/Lucy/Search/QueryParser/QueryLexer.c
+++ b/core/Lucy/Search/QueryParser/QueryLexer.c
@@ -94,7 +94,7 @@ QueryLexer_Tokenize_IMP(QueryLexer *self, const String *query_string) {
}
}
- uint32_t code_point = StrIter_Next(iter);
+ int32_t code_point = StrIter_Next(iter);
switch (code_point) {
case '(':
elem = ParserElem_new(TOKEN_OPEN_PAREN, NULL);
@@ -168,7 +168,7 @@ S_consume_keyword(StringIterator *iter, const char *keyword,
}
StringIterator *temp = StrIter_Clone(iter);
StrIter_Advance(temp, keyword_len);
- uint32_t lookahead = StrIter_Next(temp);
+ int32_t lookahead = StrIter_Next(temp);
if (lookahead == STRITER_DONE) {
DECREF(temp);
return NULL;
@@ -194,7 +194,7 @@ S_consume_field(StringIterator *iter) {
StringIterator *temp = StrIter_Clone(iter);
// Field names constructs must start with a letter or underscore.
- uint32_t code_point = StrIter_Next(temp);
+ int32_t code_point = StrIter_Next(temp);
if (code_point == STRITER_DONE) {
DECREF(temp);
return NULL;
@@ -217,7 +217,7 @@ S_consume_field(StringIterator *iter) {
}
// Field name constructs must be followed by something sensible.
- uint32_t lookahead = StrIter_Next(temp);
+ int32_t lookahead = StrIter_Next(temp);
if (lookahead == STRITER_DONE) {
DECREF(temp);
return NULL;
@@ -247,7 +247,7 @@ S_consume_text(StringIterator *iter) {
StringIterator *temp = StrIter_Clone(iter);
while (1) {
- uint32_t code_point = StrIter_Next(temp);
+ int32_t code_point = StrIter_Next(temp);
if (code_point == '\\') {
code_point = StrIter_Next(temp);
if (code_point == STRITER_DONE) {
@@ -282,7 +282,7 @@ S_consume_quoted_string(StringIterator *iter) {
}
while (1) {
- uint32_t code_point = StrIter_Next(temp);
+ int32_t code_point = StrIter_Next(temp);
if (code_point == STRITER_DONE || code_point == '"') {
break;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Store/Folder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/Folder.c b/core/Lucy/Store/Folder.c
index c45169f..935c794 100644
--- a/core/Lucy/Store/Folder.c
+++ b/core/Lucy/Store/Folder.c
@@ -431,7 +431,7 @@ Folder_Consolidate_IMP(Folder *self, const String *path) {
static Folder*
S_enclosing_folder(Folder *self, StringIterator *path) {
- uint32_t code_point;
+ int32_t code_point;
// Find first component of the file path.
String *path_component = NULL;
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Store/Lock.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/Lock.c b/core/Lucy/Store/Lock.c
index fc6efc7..907b16b 100644
--- a/core/Lucy/Store/Lock.c
+++ b/core/Lucy/Store/Lock.c
@@ -40,7 +40,7 @@ Lock_init(Lock *self, Folder *folder, const String *name,
THROW(ERR, "Invalid value for 'interval': %i32", interval);
}
StringIterator *iter = Str_Top(name);
- uint32_t code_point;
+ int32_t code_point;
while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
if (isalnum(code_point)
|| code_point == '.'
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Store/SharedLock.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/SharedLock.c b/core/Lucy/Store/SharedLock.c
index 9d33b7b..f89f6f0 100644
--- a/core/Lucy/Store/SharedLock.c
+++ b/core/Lucy/Store/SharedLock.c
@@ -141,7 +141,7 @@ ShLock_Is_Locked_IMP(SharedLock *self) {
if (Str_Starts_With(entry, ivars->name)) {
StringIterator *iter = Str_Top(entry);
StrIter_Advance(iter, Str_Length(ivars->name));
- uint32_t code_point = StrIter_Next(iter);
+ int32_t code_point = StrIter_Next(iter);
if (code_point == '-') {
code_point = StrIter_Next(iter);
if (code_point != STRITER_DONE && isdigit(code_point)) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Util/IndexFileNames.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/IndexFileNames.c b/core/Lucy/Util/IndexFileNames.c
index ee5d237..5d616f2 100644
--- a/core/Lucy/Util/IndexFileNames.c
+++ b/core/Lucy/Util/IndexFileNames.c
@@ -56,7 +56,7 @@ IxFileNames_extract_gen(const String *name) {
// Advance past first underscore. Bail if we run out of string or if we
// encounter a NULL.
while (1) {
- uint32_t code_point = StrIter_Next(iter);
+ int32_t code_point = StrIter_Next(iter);
if (code_point == STRITER_DONE) { return 0; }
else if (code_point == '_') { break; }
}
@@ -72,7 +72,7 @@ IxFileNames_extract_gen(const String *name) {
String*
IxFileNames_local_part(const String *path) {
StringIterator *top = Str_Tail(path);
- uint32_t code_point = StrIter_Prev(top);
+ int32_t code_point = StrIter_Prev(top);
// Trim trailing slash.
while (code_point == '/') {
http://git-wip-us.apache.org/repos/asf/lucy/blob/7b5ef781/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index c877b74..9b751ad 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -182,7 +182,7 @@ S_append_json_string(String *dump, CharBuf *buf) {
// Process string data.
StringIterator *iter = Str_Top(dump);
- uint32_t code_point;
+ int32_t code_point;
while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
if (code_point > 127) {
// There is no need to escape any high characters, including those