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:54 UTC
[lucy-commits] [1/2] git commit: refs/heads/cfish-string-prep1 - Use int32_t for
remaining Unicode code points
Updated Branches:
refs/heads/cfish-string-prep1 c69fb741a -> e57cd26dd
Use int32_t for remaining Unicode code points
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/e57cd26d
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/e57cd26d
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/e57cd26d
Branch: refs/heads/cfish-string-prep1
Commit: e57cd26dd413089dd9b8dcd546842ea0751a5745
Parents: 7b5ef78
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Mon Sep 23 15:13:43 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Sep 23 15:15:04 2013 +0200
----------------------------------------------------------------------
clownfish/runtime/core/Clownfish/CharBuf.c | 2 +-
clownfish/runtime/core/Clownfish/CharBuf.cfh | 2 +-
clownfish/runtime/core/Clownfish/String.c | 6 +++---
clownfish/runtime/core/Clownfish/String.cfh | 6 +++---
clownfish/runtime/core/Clownfish/Test/TestString.c | 8 ++++----
.../runtime/core/Clownfish/Test/Util/TestStringHelper.c | 2 +-
clownfish/runtime/core/Clownfish/TestHarness/TestUtils.c | 4 ++--
clownfish/runtime/core/Clownfish/Util/StringHelper.c | 8 ++++----
clownfish/runtime/core/Clownfish/Util/StringHelper.cfh | 6 +++---
core/Lucy/Highlight/Highlighter.c | 2 +-
core/Lucy/Store/FSFolder.c | 2 +-
core/Lucy/Test/Search/TestSortSpec.c | 2 +-
core/Lucy/Util/Json.c | 2 +-
13 files changed, 26 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/clownfish/runtime/core/Clownfish/CharBuf.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.c b/clownfish/runtime/core/Clownfish/CharBuf.c
index bfbae45..ea056b8 100644
--- a/clownfish/runtime/core/Clownfish/CharBuf.c
+++ b/clownfish/runtime/core/Clownfish/CharBuf.c
@@ -312,7 +312,7 @@ CB_Yield_String_IMP(CharBuf *self) {
}
void
-CB_Cat_Char_IMP(CharBuf *self, uint32_t code_point) {
+CB_Cat_Char_IMP(CharBuf *self, int32_t code_point) {
const size_t MAX_UTF8_BYTES = 4;
if (self->size + MAX_UTF8_BYTES >= self->cap) {
S_grow(self, Memory_oversize(self->size + MAX_UTF8_BYTES,
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/clownfish/runtime/core/Clownfish/CharBuf.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.cfh b/clownfish/runtime/core/Clownfish/CharBuf.cfh
index 64d38da..34c23c3 100644
--- a/clownfish/runtime/core/Clownfish/CharBuf.cfh
+++ b/clownfish/runtime/core/Clownfish/CharBuf.cfh
@@ -106,7 +106,7 @@ class Clownfish::CharBuf cnick CB
/** Concatenate one Unicode character onto the end of the CharBuf.
*/
void
- Cat_Char(CharBuf *self, uint32_t code_point);
+ Cat_Char(CharBuf *self, int32_t code_point);
/** Assign more memory to the CharBuf, if it doesn't already have enough
* room to hold a string of <code>size</code> bytes. Cannot shrink the
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index 28f27e6..b2c2c97 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -130,7 +130,7 @@ Str_init_wrap_trusted_utf8(String *self, const char *ptr, size_t size) {
}
String*
-Str_new_from_char(uint32_t code_point) {
+Str_new_from_char(int32_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);
@@ -451,7 +451,7 @@ Str_Length_IMP(String *self) {
return SStrIter_Advance(iter, SIZE_MAX);
}
-uint32_t
+int32_t
Str_Code_Point_At_IMP(String *self, size_t tick) {
StackStringIterator *iter = STR_STACKTOP(self);
SStrIter_Advance(iter, tick);
@@ -459,7 +459,7 @@ Str_Code_Point_At_IMP(String *self, size_t tick) {
return code_point == STRITER_DONE ? 0 : code_point;
}
-uint32_t
+int32_t
Str_Code_Point_From_IMP(String *self, size_t tick) {
if (tick == 0) { return 0; }
StackStringIterator *iter = STR_STACKTAIL(self);
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index 1151589..c4ea6d5 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -86,7 +86,7 @@ class Clownfish::String cnick Str
/** Return a String which holds a single character.
*/
inert incremented String*
- new_from_char(uint32_t code_point);
+ new_from_char(int32_t code_point);
/** Return a pointer to a new String which contains formatted data
* expanded according to CB_VCatF.
@@ -241,14 +241,14 @@ class Clownfish::String cnick Str
* better to throw an exception, but that's not practical with UTF-8 and
* no cached length.)
*/
- uint32_t
+ int32_t
Code_Point_At(String *self, size_t tick);
/** Return the Unicode code point at the specified number of code points
* counted backwards from the end of the string. Return 0 if outside the
* string.
*/
- uint32_t
+ int32_t
Code_Point_From(String *self, size_t tick);
/** Return a newly allocated String containing a copy of the indicated
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/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 652c8e9..a59ff4c 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestString.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestString.c
@@ -52,7 +52,7 @@ S_get_str(const char *string) {
// Surround a smiley with lots of whitespace.
static String*
S_smiley_with_whitespace(int *num_spaces_ptr) {
- uint32_t spaces[] = {
+ int32_t spaces[] = {
' ', '\t', '\r', '\n', 0x000B, 0x000C, 0x000D, 0x0085,
0x00A0, 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004,
0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x2028, 0x2029,
@@ -141,10 +141,10 @@ test_Find(TestBatchRunner *runner) {
static void
test_Code_Point_At_and_From(TestBatchRunner *runner) {
- uint32_t code_points[] = {
+ int32_t code_points[] = {
'a', smiley_cp, smiley_cp, 'b', smiley_cp, 'c'
};
- uint32_t num_code_points = sizeof(code_points) / sizeof(uint32_t);
+ uint32_t num_code_points = sizeof(code_points) / sizeof(int32_t);
String *string = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
uint32_t i;
@@ -316,7 +316,7 @@ test_Swap_Chars(TestBatchRunner *runner) {
static void
test_iterator(TestBatchRunner *runner) {
- static const uint32_t code_points[] = {
+ static const int32_t code_points[] = {
0x41,
0x7F,
0x80,
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/clownfish/runtime/core/Clownfish/Test/Util/TestStringHelper.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/Util/TestStringHelper.c b/clownfish/runtime/core/Clownfish/Test/Util/TestStringHelper.c
index 2ecb528..339de02 100644
--- a/clownfish/runtime/core/Clownfish/Test/Util/TestStringHelper.c
+++ b/clownfish/runtime/core/Clownfish/Test/Util/TestStringHelper.c
@@ -156,7 +156,7 @@ test_to_base36(TestBatchRunner *runner) {
static void
test_utf8_round_trip(TestBatchRunner *runner) {
- uint32_t code_point;
+ int32_t code_point;
for (code_point = 0; code_point <= 0x10FFFF; code_point++) {
char buffer[4];
uint32_t size = StrHelp_encode_utf8_char(code_point, buffer);
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/clownfish/runtime/core/Clownfish/TestHarness/TestUtils.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/TestHarness/TestUtils.c b/clownfish/runtime/core/Clownfish/TestHarness/TestUtils.c
index 31195ed..a987d5c 100644
--- a/clownfish/runtime/core/Clownfish/TestHarness/TestUtils.c
+++ b/clownfish/runtime/core/Clownfish/TestHarness/TestUtils.c
@@ -70,9 +70,9 @@ TestUtils_random_f64s(double *buf, size_t count) {
return f64s;
}
-static uint32_t
+static int32_t
S_random_code_point(void) {
- uint32_t code_point = 0;
+ int32_t code_point = 0;
while (1) {
uint8_t chance = (rand() % 9) + 1;
switch (chance) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/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 98e7f11..ba117c5 100644
--- a/clownfish/runtime/core/Clownfish/Util/StringHelper.c
+++ b/clownfish/runtime/core/Clownfish/Util/StringHelper.c
@@ -130,7 +130,7 @@ StrHelp_utf8_valid(const char *ptr, size_t size) {
}
bool
-StrHelp_is_whitespace(uint32_t code_point) {
+StrHelp_is_whitespace(int32_t code_point) {
switch (code_point) {
// <control-0009>..<control-000D>
case 0x0009: case 0x000A: case 0x000B: case 0x000C: case 0x000D:
@@ -156,7 +156,7 @@ StrHelp_is_whitespace(uint32_t code_point) {
}
uint32_t
-StrHelp_encode_utf8_char(uint32_t code_point, void *buffer) {
+StrHelp_encode_utf8_char(int32_t code_point, void *buffer) {
uint8_t *buf = (uint8_t*)buffer;
if (code_point <= 0x7F) { // ASCII
buf[0] = (uint8_t)code_point;
@@ -186,10 +186,10 @@ StrHelp_encode_utf8_char(uint32_t code_point, void *buffer) {
}
}
-uint32_t
+int32_t
StrHelp_decode_utf8_char(const char *ptr) {
const uint8_t *const string = (const uint8_t*)ptr;
- uint32_t retval = *string;
+ int32_t retval = *string;
int bytes = StrHelp_UTF8_COUNT[retval];
switch (bytes & 0x7) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/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 905613d..1cbb46a 100644
--- a/clownfish/runtime/core/Clownfish/Util/StringHelper.cfh
+++ b/clownfish/runtime/core/Clownfish/Util/StringHelper.cfh
@@ -47,7 +47,7 @@ inert class Clownfish::Util::StringHelper cnick StrHelp {
/** Returns true if the code point qualifies as Unicode whitespace.
*/
inert bool
- is_whitespace(uint32_t code_point);
+ is_whitespace(int32_t code_point);
/** Encode a Unicode code point to a UTF-8 sequence.
*
@@ -56,11 +56,11 @@ inert class Clownfish::Util::StringHelper cnick StrHelp {
* maximum legal length for a UTF-8 char).
*/
inert uint32_t
- encode_utf8_char(uint32_t code_point, void *buffer);
+ encode_utf8_char(int32_t code_point, void *buffer);
/** Decode a UTF-8 sequence to a Unicode code point. Assumes valid UTF-8.
*/
- inert uint32_t
+ inert int32_t
decode_utf8_char(const char *utf8);
/** Return the first non-continuation byte before the supplied pointer.
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/core/Lucy/Highlight/Highlighter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Highlight/Highlighter.c b/core/Lucy/Highlight/Highlighter.c
index b181115..c384b46 100644
--- a/core/Lucy/Highlight/Highlighter.c
+++ b/core/Lucy/Highlight/Highlighter.c
@@ -28,7 +28,7 @@
#include "Lucy/Search/Span.h"
#include "Lucy/Index/DocVector.h"
-const uint32_t ELLIPSIS_CODE_POINT = 0x2026;
+const int32_t ELLIPSIS_CODE_POINT = 0x2026;
/* If Highlighter_Encode has been overridden, return its output. If not,
* increment the refcount of the supplied encode_buf and call encode_entities.
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/core/Lucy/Store/FSFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFolder.c b/core/Lucy/Store/FSFolder.c
index cb4d09e..1550d73 100644
--- a/core/Lucy/Store/FSFolder.c
+++ b/core/Lucy/Store/FSFolder.c
@@ -350,7 +350,7 @@ S_is_local_entry(const String *path) {
static bool
S_is_absolute(const String *path) {
- uint32_t code_point = Str_Code_Point_At(path, 0);
+ int32_t code_point = Str_Code_Point_At(path, 0);
if (isalpha(code_point)) {
code_point = Str_Code_Point_At(path, 1);
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/core/Lucy/Test/Search/TestSortSpec.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestSortSpec.c b/core/Lucy/Test/Search/TestSortSpec.c
index 6401f27..81effa3 100644
--- a/core/Lucy/Test/Search/TestSortSpec.c
+++ b/core/Lucy/Test/Search/TestSortSpec.c
@@ -272,7 +272,7 @@ S_random_string() {
size_t length = 1 + rand() % 10;
CharBuf *buf = CB_new(length);
while (length--) {
- uint32_t code_point = 'a' + rand() % ('z' - 'a' + 1);
+ int32_t code_point = 'a' + rand() % ('z' - 'a' + 1);
CB_Cat_Char(buf, code_point);
}
String *string = CB_Yield_String(buf);
http://git-wip-us.apache.org/repos/asf/lucy/blob/e57cd26d/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index 9b751ad..cdb01fb 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -634,7 +634,7 @@ S_unescape_text(const char *top, const char *end) {
text - 5, end);
return NULL;
}
- target_size += StrHelp_encode_utf8_char((uint32_t)code_point,
+ target_size += StrHelp_encode_utf8_char((int32_t)code_point,
target_buf + target_size);
}
break;
[lucy-commits] [2/2] git commit: refs/heads/cfish-string-prep1 - Make StrIter_Next
and StrIter_Prev return an int32_t
Posted by nw...@apache.org.
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