You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by lo...@apache.org on 2011/12/03 08:34:57 UTC

[lucy-commits] svn commit: r1209842 - in /incubator/lucy/trunk/core/Lucy: Index/ Index/Posting/ Plan/ Search/ Search/Collector/

Author: logie
Date: Sat Dec  3 07:34:56 2011
New Revision: 1209842

URL: http://svn.apache.org/viewvc?rev=1209842&view=rev
Log:
C99 Updates - https://issues.apache.org/jira/browse/LUCY-148

Modified:
    incubator/lucy/trunk/core/Lucy/Index/IndexManager.c
    incubator/lucy/trunk/core/Lucy/Index/Inverter.c
    incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c
    incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c
    incubator/lucy/trunk/core/Lucy/Index/PostingPool.c
    incubator/lucy/trunk/core/Lucy/Index/SegWriter.c
    incubator/lucy/trunk/core/Lucy/Plan/Schema.c
    incubator/lucy/trunk/core/Lucy/Search/Collector/SortCollector.c
    incubator/lucy/trunk/core/Lucy/Search/IndexSearcher.c
    incubator/lucy/trunk/core/Lucy/Search/ORMatcher.c
    incubator/lucy/trunk/core/Lucy/Search/ORQuery.c
    incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c
    incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c
    incubator/lucy/trunk/core/Lucy/Search/PolySearcher.c
    incubator/lucy/trunk/core/Lucy/Search/QueryParser.c
    incubator/lucy/trunk/core/Lucy/Search/SortSpec.c

Modified: incubator/lucy/trunk/core/Lucy/Index/IndexManager.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/IndexManager.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/IndexManager.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/IndexManager.c Sat Dec  3 07:34:56 2011
@@ -66,10 +66,9 @@ IxManager_destroy(IndexManager *self) {
 int64_t
 IxManager_highest_seg_num(IndexManager *self, Snapshot *snapshot) {
     VArray *files = Snapshot_List(snapshot);
-    uint32_t i, max;
     uint64_t highest_seg_num = 0;
     UNUSED_VAR(self);
-    for (i = 0, max = VA_Get_Size(files); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(files); i < max; i++) {
         CharBuf *file = (CharBuf*)VA_Fetch(files, i);
         if (Seg_valid_seg_name(file)) {
             uint64_t seg_num = IxFileNames_extract_gen(file);
@@ -84,11 +83,10 @@ CharBuf*
 IxManager_make_snapshot_filename(IndexManager *self) {
     Folder *folder = (Folder*)CERTIFY(self->folder, FOLDER);
     DirHandle *dh = Folder_Open_Dir(folder, NULL);
-    CharBuf *entry;
     uint64_t max_gen = 0;
 
     if (!dh) { RETHROW(INCREF(Err_get_error())); }
-    entry = DH_Get_Entry(dh);
+    CharBuf *entry = DH_Get_Entry(dh);
     while (DH_Next(dh)) {
         if (CB_Starts_With_Str(entry, "snapshot_", 9)
             && CB_Ends_With_Str(entry, ".json", 5)

Modified: incubator/lucy/trunk/core/Lucy/Index/Inverter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Inverter.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Inverter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Inverter.c Sat Dec  3 07:34:56 2011
@@ -165,8 +165,7 @@ Inverter_add_field(Inverter *self, Inver
 
 void
 Inverter_clear(Inverter *self) {
-    uint32_t i, max;
-    for (i = 0, max = VA_Get_Size(self->entries); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->entries); i < max; i++) {
         InvEntry_Clear(VA_Fetch(self->entries, i));
     }
     VA_Clear(self->entries);

Modified: incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c Sat Dec  3 07:34:56 2011
@@ -36,7 +36,6 @@ PolyLex_new(const CharBuf *field, VArray
 
 PolyLexicon*
 PolyLex_init(PolyLexicon *self, const CharBuf *field, VArray *sub_readers) {
-    uint32_t  i;
     uint32_t  num_sub_readers = VA_Get_Size(sub_readers);
     VArray   *seg_lexicons    = VA_new(num_sub_readers);
 
@@ -46,7 +45,7 @@ PolyLex_init(PolyLexicon *self, const Ch
     self->lex_q           = SegLexQ_new(num_sub_readers);
 
     // Derive.
-    for (i = 0; i < num_sub_readers; i++) {
+    for (uint32_t i = 0; i < num_sub_readers; i++) {
         LexiconReader *lex_reader = (LexiconReader*)VA_Fetch(sub_readers, i);
         if (lex_reader && CERTIFY(lex_reader, LEXICONREADER)) {
             Lexicon *seg_lexicon = LexReader_Lexicon(lex_reader, field, NULL);
@@ -72,8 +71,6 @@ PolyLex_destroy(PolyLexicon *self) {
 
 static void
 S_refresh_lex_q(SegLexQueue *lex_q, VArray *seg_lexicons, Obj *target) {
-    uint32_t i, max;
-
     // Empty out the queue.
     while (1) {
         SegLexicon *seg_lex = (SegLexicon*)SegLexQ_Pop(lex_q);
@@ -82,7 +79,7 @@ S_refresh_lex_q(SegLexQueue *lex_q, VArr
     }
 
     // Refill the queue.
-    for (i = 0, max = VA_Get_Size(seg_lexicons); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(seg_lexicons); i < max; i++) {
         SegLexicon *const seg_lexicon
             = (SegLexicon*)VA_Fetch(seg_lexicons, i);
         SegLex_Seek(seg_lexicon, target);
@@ -94,7 +91,6 @@ S_refresh_lex_q(SegLexQueue *lex_q, VArr
 
 void
 PolyLex_reset(PolyLexicon *self) {
-    uint32_t i;
     VArray *seg_lexicons = self->seg_lexicons;
     uint32_t num_segs = VA_Get_Size(seg_lexicons);
     SegLexQueue *lex_q = self->lex_q;
@@ -107,7 +103,7 @@ PolyLex_reset(PolyLexicon *self) {
     }
 
     // Fill the queue with valid SegLexicons.
-    for (i = 0; i < num_segs; i++) {
+    for (uint32_t i = 0; i < num_segs; i++) {
         SegLexicon *const seg_lexicon
             = (SegLexicon*)VA_Fetch(seg_lexicons, i);
         SegLex_Reset(seg_lexicon);

Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c Sat Dec  3 07:34:56 2011
@@ -93,14 +93,13 @@ ScorePost_add_inversion_to_pool(ScorePos
         char *const start  = raw_posting->blob + token->len;
         char *dest         = start;
         uint32_t last_prox = 0;
-        uint32_t i;
 
         // Field_boost.
         *((uint8_t*)dest) = field_boost_byte;
         dest++;
 
         // Positions.
-        for (i = 0; i < freq; i++) {
+        for (uint32_t i = 0; i < freq; i++) {
             Token *const t = tokens[i];
             const uint32_t prox_delta = t->pos - last_prox;
             NumUtil_encode_c32(prox_delta, &dest);
@@ -124,9 +123,7 @@ ScorePost_reset(ScorePosting *self) {
 
 void
 ScorePost_read_record(ScorePosting *self, InStream *instream) {
-    uint32_t  num_prox;
     uint32_t  position = 0;
-    uint32_t *positions;
     const size_t max_start_bytes = (C32_MAX_BYTES * 2) + 1;
     char *buf = InStream_Buf(instream, max_start_bytes);
     const uint32_t doc_code = NumUtil_decode_c32(&buf);
@@ -146,13 +143,13 @@ ScorePost_read_record(ScorePosting *self
     buf++;
 
     // Read positions.
-    num_prox = self->freq;
+    uint32_t num_prox = self->freq;
     if (num_prox > self->prox_cap) {
         self->prox = (uint32_t*)REALLOCATE(
                          self->prox, num_prox * sizeof(uint32_t));
         self->prox_cap = num_prox;
     }
-    positions = self->prox;
+    uint32_t *positions = self->prox;
 
     InStream_Advance_Buf(instream, buf);
     buf = InStream_Buf(instream, num_prox * C32_MAX_BYTES);
@@ -216,14 +213,12 @@ ScorePost_make_matcher(ScorePosting *sel
 ScorePostingMatcher*
 ScorePostMatcher_init(ScorePostingMatcher *self, Similarity *sim,
                       PostingList *plist, Compiler *compiler) {
-    uint32_t i;
-
     // Init.
     TermMatcher_init((TermMatcher*)self, sim, plist, compiler);
 
     // Fill score cache.
     self->score_cache = (float*)MALLOCATE(TERMMATCHER_SCORE_CACHE_SIZE * sizeof(float));
-    for (i = 0; i < TERMMATCHER_SCORE_CACHE_SIZE; i++) {
+    for (uint32_t i = 0; i < TERMMATCHER_SCORE_CACHE_SIZE; i++) {
         self->score_cache[i] = Sim_TF(sim, (float)i) * self->weight;
     }
 

Modified: incubator/lucy/trunk/core/Lucy/Index/PostingPool.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PostingPool.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PostingPool.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PostingPool.c Sat Dec  3 07:34:56 2011
@@ -164,7 +164,6 @@ PostPool_get_mem_pool(PostingPool *self)
 
 void
 PostPool_flip(PostingPool *self) {
-    uint32_t i;
     uint32_t num_runs   = VA_Get_Size(self->runs);
     uint32_t sub_thresh = num_runs > 0
                           ? self->mem_thresh / num_runs
@@ -206,7 +205,7 @@ PostPool_flip(PostingPool *self) {
     }
 
     // Assign.
-    for (i = 0; i < num_runs; i++) {
+    for (uint32_t i = 0; i < num_runs; i++) {
         PostingPool *run = (PostingPool*)VA_Fetch(self->runs, i);
         if (run != NULL) {
             PostPool_Set_Mem_Thresh(run, sub_thresh);

Modified: incubator/lucy/trunk/core/Lucy/Index/SegWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegWriter.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegWriter.c Sat Dec  3 07:34:56 2011
@@ -107,8 +107,7 @@ SegWriter_add_doc(SegWriter *self, Doc *
 void
 SegWriter_add_inverted_doc(SegWriter *self, Inverter *inverter,
                            int32_t doc_id) {
-    uint32_t i, max;
-    for (i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
         DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
         DataWriter_Add_Inverted_Doc(writer, inverter, doc_id);
     }
@@ -120,8 +119,7 @@ SegWriter_add_inverted_doc(SegWriter *se
 static void
 S_adjust_doc_id(SegWriter *self, SegReader *reader, I32Array *doc_map) {
     uint32_t doc_count = SegReader_Doc_Max(reader);
-    uint32_t i, max;
-    for (i = 1, max = I32Arr_Get_Size(doc_map); i < max; i++) {
+    for (uint32_t i = 1, max = I32Arr_Get_Size(doc_map); i < max; i++) {
         if (I32Arr_Get(doc_map, i) == 0) { doc_count--; }
     }
     Seg_Increment_Count(self->segment, doc_count);
@@ -129,10 +127,8 @@ S_adjust_doc_id(SegWriter *self, SegRead
 
 void
 SegWriter_add_segment(SegWriter *self, SegReader *reader, I32Array *doc_map) {
-    uint32_t i, max;
-
     // Bulk add the slab of documents to the various writers.
-    for (i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
         DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
         DataWriter_Add_Segment(writer, reader, doc_map);
     }
@@ -150,10 +146,9 @@ SegWriter_merge_segment(SegWriter *self,
                         I32Array *doc_map) {
     Snapshot *snapshot = SegWriter_Get_Snapshot(self);
     CharBuf  *seg_name = Seg_Get_Name(SegReader_Get_Segment(reader));
-    uint32_t i, max;
 
     // Have all the sub-writers merge the segment.
-    for (i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
         DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
         DataWriter_Merge_Segment(writer, reader, doc_map);
     }
@@ -170,10 +165,9 @@ void
 SegWriter_delete_segment(SegWriter *self, SegReader *reader) {
     Snapshot *snapshot = SegWriter_Get_Snapshot(self);
     CharBuf  *seg_name = Seg_Get_Name(SegReader_Get_Segment(reader));
-    uint32_t i, max;
 
     // Have all the sub-writers delete the segment.
-    for (i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
         DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
         DataWriter_Delete_Segment(writer, reader);
     }
@@ -186,10 +180,9 @@ SegWriter_delete_segment(SegWriter *self
 void
 SegWriter_finish(SegWriter *self) {
     CharBuf *seg_name = Seg_Get_Name(self->segment);
-    uint32_t i, max;
 
     // Finish off children.
-    for (i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
         DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
         DataWriter_Finish(writer);
     }

Modified: incubator/lucy/trunk/core/Lucy/Plan/Schema.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Plan/Schema.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Plan/Schema.c (original)
+++ incubator/lucy/trunk/core/Lucy/Plan/Schema.c Sat Dec  3 07:34:56 2011
@@ -80,9 +80,8 @@ Schema_destroy(Schema *self) {
 
 static void
 S_add_unique(VArray *array, Obj *elem) {
-    uint32_t i, max;
     if (!elem) { return; }
-    for (i = 0, max = VA_Get_Size(array); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(array); i < max; i++) {
         Obj *candidate = VA_Fetch(array, i);
         if (!candidate) { continue; }
         if (elem == candidate) { return; }
@@ -219,8 +218,7 @@ Schema_all_fields(Schema *self) {
 
 uint32_t
 S_find_in_array(VArray *array, Obj *obj) {
-    uint32_t i, max;
-    for (i = 0, max = VA_Get_Size(array); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(array); i < max; i++) {
         Obj *candidate = VA_Fetch(array, i);
         if (obj == NULL && candidate == NULL) {
             return i;

Modified: incubator/lucy/trunk/core/Lucy/Search/Collector/SortCollector.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/Collector/SortCollector.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/Collector/SortCollector.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/Collector/SortCollector.c Sat Dec  3 07:34:56 2011
@@ -87,7 +87,6 @@ SortColl_init(SortCollector *self, Schem
                     ? (VArray*)INCREF(SortSpec_Get_Rules(sort_spec))
                     : S_default_sort_rules();
     uint32_t num_rules = VA_Get_Size(rules);
-    uint32_t i;
 
     // Validate.
     if (sort_spec && !schema) {
@@ -120,7 +119,7 @@ SortColl_init(SortCollector *self, Schem
     // values.
     self->need_score  = false;
     self->need_values = false;
-    for (i = 0; i < num_rules; i++) {
+    for (uint32_t i = 0; i < num_rules; i++) {
         SortRule *rule   = (SortRule*)VA_Fetch(rules, i);
         int32_t rule_type  = SortRule_Get_Type(rule);
         self->actions[i] = S_derive_action(rule, NULL);
@@ -234,8 +233,7 @@ SortColl_set_reader(SortCollector *self,
 
     // Obtain sort caches. Derive actions array for this segment.
     if (self->need_values && sort_reader) {
-        uint32_t i, max;
-        for (i = 0, max = self->num_rules; i < max; i++) {
+        for (uint32_t i = 0, max = self->num_rules; i < max; i++) {
             SortRule  *rule  = (SortRule*)VA_Fetch(self->rules, i);
             CharBuf   *field = SortRule_Get_Field(rule);
             SortCache *cache = field
@@ -283,9 +281,8 @@ SortColl_collect(SortCollector *self, in
         // Fetch values so that cross-segment sorting can work.
         if (self->need_values) {
             VArray *values = match_doc->values;
-            uint32_t i, max;
 
-            for (i = 0, max = self->num_rules; i < max; i++) {
+            for (uint32_t i = 0, max = self->num_rules; i < max; i++) {
                 SortCache *cache   = self->sort_caches[i];
                 Obj       *old_val = (Obj*)VA_Delete(values, i);
                 if (cache) {

Modified: incubator/lucy/trunk/core/Lucy/Search/IndexSearcher.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/IndexSearcher.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/IndexSearcher.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/IndexSearcher.c Sat Dec  3 07:34:56 2011
@@ -123,7 +123,6 @@ IxSearcher_top_docs(IndexSearcher *self,
 
 void
 IxSearcher_collect(IndexSearcher *self, Query *query, Collector *collector) {
-    uint32_t i, max;
     VArray   *const seg_readers = self->seg_readers;
     I32Array *const seg_starts  = self->seg_starts;
     bool_t    need_score        = Coll_Need_Score(collector);
@@ -133,7 +132,7 @@ IxSearcher_collect(IndexSearcher *self, 
                                                Query_Get_Boost(query), false);
 
     // Accumulate hits into the Collector.
-    for (i = 0, max = VA_Get_Size(seg_readers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(seg_readers); i < max; i++) {
         SegReader *seg_reader = (SegReader*)VA_Fetch(seg_readers, i);
         DeletionsReader *del_reader = (DeletionsReader*)SegReader_Fetch(
                                           seg_reader,

Modified: incubator/lucy/trunk/core/Lucy/Search/ORMatcher.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/ORMatcher.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/ORMatcher.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/ORMatcher.c Sat Dec  3 07:34:56 2011
@@ -70,9 +70,6 @@ ORMatcher_new(VArray *children) {
 
 static ORMatcher*
 S_ormatcher_init2(ORMatcher *self, VArray *children, Similarity *sim) {
-    size_t amount_to_malloc;
-    uint32_t i;
-
     // Init.
     PolyMatcher_init((PolyMatcher*)self, children, sim);
     self->size = 0;
@@ -85,17 +82,17 @@ S_ormatcher_init2(ORMatcher *self, VArra
 
     // Create a pool of HMDs.  Encourage CPU cache hits by using a single
     // allocation for all of them.
-    amount_to_malloc = (self->max_size + 1) * sizeof(HeapedMatcherDoc);
+    size_t amount_to_malloc = (self->max_size + 1) * sizeof(HeapedMatcherDoc);
     self->blob = (char*)MALLOCATE(amount_to_malloc);
     self->pool = (HeapedMatcherDoc**)CALLOCATE(self->max_size + 1, sizeof(HeapedMatcherDoc*));
-    for (i = 1; i <= self->max_size; i++) {
+    for (uint32_t i = 1; i <= self->max_size; i++) {
         size_t offset = i * sizeof(HeapedMatcherDoc);
         HeapedMatcherDoc *hmd = (HeapedMatcherDoc*)(self->blob + offset);
         self->pool[i] = hmd;
     }
 
     // Prime queue.
-    for (i = 0; i < self->max_size; i++) {
+    for (uint32_t i = 0; i < self->max_size; i++) {
         Matcher *matcher = (Matcher*)VA_Fetch(children, i);
         if (matcher) {
             S_add_element(self, (Matcher*)INCREF(matcher), 0);
@@ -385,10 +382,9 @@ float
 ORScorer_score(ORScorer *self) {
     float *const scores = self->scores;
     float score = 0.0f;
-    uint32_t i;
 
     // Accumulate score, then factor in coord bonus.
-    for (i = 0; i < self->matching_kids; i++) {
+    for (uint32_t i = 0; i < self->matching_kids; i++) {
         score += scores[i];
     }
     score *= self->coord_factors[self->matching_kids];

Modified: incubator/lucy/trunk/core/Lucy/Search/ORQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/ORQuery.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/ORQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/ORQuery.c Sat Dec  3 07:34:56 2011
@@ -60,9 +60,8 @@ ORQuery_to_string(ORQuery *self) {
     if (!num_kids) { return CB_new_from_trusted_utf8("()", 2); }
     else {
         CharBuf *retval = CB_new_from_trusted_utf8("(", 1);
-        uint32_t i;
         uint32_t last_kid = num_kids - 1;
-        for (i = 0; i < num_kids; i++) {
+        for (uint32_t i = 0; i < num_kids; i++) {
             CharBuf *kid_string = Obj_To_String(VA_Fetch(self->children, i));
             CB_Cat(retval, kid_string);
             DECREF(kid_string);
@@ -105,11 +104,10 @@ ORCompiler_make_matcher(ORCompiler *self
     }
     else {
         VArray *submatchers = VA_new(num_kids);
-        uint32_t i;
         uint32_t num_submatchers = 0;
 
         // Accumulate sub-matchers.
-        for (i = 0; i < num_kids; i++) {
+        for (uint32_t i = 0; i < num_kids; i++) {
             Compiler *child = (Compiler*)VA_Fetch(self->children, i);
             Matcher *submatcher
                 = Compiler_Make_Matcher(child, reader, need_score);

Modified: incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c Sat Dec  3 07:34:56 2011
@@ -63,9 +63,8 @@ PhraseQuery_destroy(PhraseQuery *self) {
 
 static PhraseQuery*
 S_do_init(PhraseQuery *self, CharBuf *field, VArray *terms, float boost) {
-    uint32_t i, max;
     Query_init((Query*)self, boost);
-    for (i = 0, max = VA_Get_Size(terms); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(terms); i < max; i++) {
         CERTIFY(VA_Fetch(terms, i), OBJ);
     }
     self->field = field;
@@ -106,11 +105,10 @@ PhraseQuery_equals(PhraseQuery *self, Ob
 
 CharBuf*
 PhraseQuery_to_string(PhraseQuery *self) {
-    uint32_t i;
     uint32_t  num_terms = VA_Get_Size(self->terms);
     CharBuf  *retval    = CB_Clone(self->field);
     CB_Cat_Trusted_Str(retval, ":\"", 2);
-    for (i = 0; i < num_terms; i++) {
+    for (uint32_t i = 0; i < num_terms; i++) {
         Obj     *term        = VA_Fetch(self->terms, i);
         CharBuf *term_string = Obj_To_String(term);
         CB_Cat(retval, term_string);
@@ -172,7 +170,6 @@ PhraseCompiler_init(PhraseCompiler *self
     Schema     *schema = Searcher_Get_Schema(searcher);
     Similarity *sim    = Schema_Fetch_Sim(schema, parent->field);
     VArray     *terms  = parent->terms;
-    uint32_t i, max;
 
     // Try harder to find a Similarity if necessary.
     if (!sim) { sim = Schema_Get_Similarity(schema); }
@@ -182,7 +179,7 @@ PhraseCompiler_init(PhraseCompiler *self
 
     // Store IDF for the phrase.
     self->idf = 0;
-    for (i = 0, max = VA_Get_Size(terms); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(terms); i < max; i++) {
         Obj     *term     = VA_Fetch(terms, i);
         int32_t  doc_max  = Searcher_Doc_Max(searcher);
         int32_t  doc_freq = Searcher_Doc_Freq(searcher, parent->field, term);
@@ -297,22 +294,17 @@ PhraseCompiler_highlight_spans(PhraseCom
     PhraseQuery *const parent    = (PhraseQuery*)self->parent;
     VArray *const      terms     = parent->terms;
     VArray *const      spans     = VA_new(0);
-    VArray      *term_vectors;
-    BitVector   *posit_vec;
-    BitVector   *other_posit_vec;
-    uint32_t     i;
     const uint32_t     num_terms = VA_Get_Size(terms);
-    uint32_t     num_tvs;
     UNUSED_VAR(searcher);
 
     // Bail if no terms or field doesn't match.
     if (!num_terms) { return spans; }
     if (!CB_Equals(field, (Obj*)parent->field)) { return spans; }
 
-    term_vectors    = VA_new(num_terms);
-    posit_vec       = BitVec_new(0);
-    other_posit_vec = BitVec_new(0);
-    for (i = 0; i < num_terms; i++) {
+    VArray *term_vectors    = VA_new(num_terms);
+    BitVector *posit_vec       = BitVec_new(0);
+    BitVector *other_posit_vec = BitVec_new(0);
+    for (uint32_t i = 0; i < num_terms; i++) {
         Obj *term = VA_Fetch(terms, i);
         TermVector *term_vector
             = DocVec_Term_Vector(doc_vec, field, (CharBuf*)term);
@@ -326,19 +318,17 @@ PhraseCompiler_highlight_spans(PhraseCom
 
         if (i == 0) {
             // Set initial positions from first term.
-            uint32_t j;
             I32Array *positions = TV_Get_Positions(term_vector);
-            for (j = I32Arr_Get_Size(positions); j > 0; j--) {
+            for (uint32_t j = I32Arr_Get_Size(positions); j > 0; j--) {
                 BitVec_Set(posit_vec, I32Arr_Get(positions, j - 1));
             }
         }
         else {
             // Filter positions using logical "and".
-            uint32_t j;
             I32Array *positions = TV_Get_Positions(term_vector);
 
             BitVec_Clear_All(other_posit_vec);
-            for (j = I32Arr_Get_Size(positions); j > 0; j--) {
+            for (uint32_t j = I32Arr_Get_Size(positions); j > 0; j--) {
                 int32_t pos = I32Arr_Get(positions, j - 1) - i;
                 if (pos >= 0) {
                     BitVec_Set(other_posit_vec, pos);
@@ -349,7 +339,7 @@ PhraseCompiler_highlight_spans(PhraseCom
     }
 
     // Proceed only if all terms are present.
-    num_tvs = VA_Get_Size(term_vectors);
+    uint32_t num_tvs = VA_Get_Size(term_vectors);
     if (num_tvs == num_terms) {
         TermVector *first_tv = (TermVector*)VA_Fetch(term_vectors, 0);
         TermVector *last_tv
@@ -362,24 +352,22 @@ PhraseCompiler_highlight_spans(PhraseCom
         I32Array *valid_posits       = BitVec_To_Array(posit_vec);
         uint32_t  num_valid_posits   = I32Arr_Get_Size(valid_posits);
         uint32_t j = 0;
-        uint32_t posit_tick;
         float weight = PhraseCompiler_Get_Weight(self);
-        i = 0;
+        uint32_t i = 0;
 
         // Add only those starts/ends that belong to a valid position.
-        for (posit_tick = 0; posit_tick < num_valid_posits; posit_tick++) {
+        for (uint32_t posit_tick = 0; posit_tick < num_valid_posits; posit_tick++) {
             int32_t valid_start_posit = I32Arr_Get(valid_posits, posit_tick);
             int32_t valid_end_posit   = valid_start_posit + terms_max;
             int32_t start_offset = 0, end_offset = 0;
-            uint32_t max;
 
-            for (max = I32Arr_Get_Size(tv_start_positions); i < max; i++) {
+            for (uint32_t max = I32Arr_Get_Size(tv_start_positions); i < max; i++) {
                 if (I32Arr_Get(tv_start_positions, i) == valid_start_posit) {
                     start_offset = I32Arr_Get(tv_start_offsets, i);
                     break;
                 }
             }
-            for (max = I32Arr_Get_Size(tv_end_positions); j < max; j++) {
+            for (uint32_t max = I32Arr_Get_Size(tv_end_positions); j < max; j++) {
                 if (I32Arr_Get(tv_end_positions, j) == valid_end_posit) {
                     end_offset = I32Arr_Get(tv_end_offsets, j);
                     break;

Modified: incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c Sat Dec  3 07:34:56 2011
@@ -30,11 +30,10 @@
 
 PolyQuery*
 PolyQuery_init(PolyQuery *self, VArray *children) {
-    uint32_t i;
     const uint32_t num_kids = children ? VA_Get_Size(children) : 0;
     Query_init((Query*)self, 1.0f);
     self->children = VA_new(num_kids);
-    for (i = 0; i < num_kids; i++) {
+    for (uint32_t i = 0; i < num_kids; i++) {
         PolyQuery_Add_Child(self, (Query*)VA_Fetch(children, i));
     }
     return self;
@@ -66,10 +65,9 @@ PolyQuery_get_children(PolyQuery *self) 
 void
 PolyQuery_serialize(PolyQuery *self, OutStream *outstream) {
     const uint32_t num_kids = VA_Get_Size(self->children);
-    uint32_t i;
     OutStream_Write_F32(outstream, self->boost);
     OutStream_Write_U32(outstream, num_kids);
-    for (i = 0; i < num_kids; i++) {
+    for (uint32_t i = 0; i < num_kids; i++) {
         Query *child = (Query*)VA_Fetch(self->children, i);
         FREEZE(child, outstream);
     }
@@ -108,14 +106,13 @@ PolyQuery_equals(PolyQuery *self, Obj *o
 PolyCompiler*
 PolyCompiler_init(PolyCompiler *self, PolyQuery *parent,
                   Searcher *searcher, float boost) {
-    uint32_t i;
     const uint32_t num_kids = VA_Get_Size(parent->children);
 
     Compiler_init((Compiler*)self, (Query*)parent, searcher, NULL, boost);
     self->children = VA_new(num_kids);
 
     // Iterate over the children, creating a Compiler for each one.
-    for (i = 0; i < num_kids; i++) {
+    for (uint32_t i = 0; i < num_kids; i++) {
         Query *child_query = (Query*)VA_Fetch(parent->children, i);
         float sub_boost = boost * Query_Get_Boost(child_query);
         Compiler *child_compiler
@@ -135,10 +132,9 @@ PolyCompiler_destroy(PolyCompiler *self)
 float
 PolyCompiler_sum_of_squared_weights(PolyCompiler *self) {
     float sum      = 0;
-    uint32_t i, max;
     float my_boost = PolyCompiler_Get_Boost(self);
 
-    for (i = 0, max = VA_Get_Size(self->children); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->children); i < max; i++) {
         Compiler *child = (Compiler*)VA_Fetch(self->children, i);
         sum += Compiler_Sum_Of_Squared_Weights(child);
     }
@@ -151,8 +147,7 @@ PolyCompiler_sum_of_squared_weights(Poly
 
 void
 PolyCompiler_apply_norm_factor(PolyCompiler *self, float factor) {
-    uint32_t i, max;
-    for (i = 0, max = VA_Get_Size(self->children); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->children); i < max; i++) {
         Compiler *child = (Compiler*)VA_Fetch(self->children, i);
         Compiler_Apply_Norm_Factor(child, factor);
     }
@@ -162,8 +157,7 @@ VArray*
 PolyCompiler_highlight_spans(PolyCompiler *self, Searcher *searcher,
                              DocVector *doc_vec, const CharBuf *field) {
     VArray *spans = VA_new(0);
-    uint32_t i, max;
-    for (i = 0, max = VA_Get_Size(self->children); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->children); i < max; i++) {
         Compiler *child = (Compiler*)VA_Fetch(self->children, i);
         VArray *child_spans = Compiler_Highlight_Spans(child, searcher,
                                                        doc_vec, field);

Modified: incubator/lucy/trunk/core/Lucy/Search/PolySearcher.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/PolySearcher.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/PolySearcher.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/PolySearcher.c Sat Dec  3 07:34:56 2011
@@ -36,7 +36,6 @@
 PolySearcher*
 PolySearcher_init(PolySearcher *self, Schema *schema, VArray *searchers) {
     const uint32_t num_searchers = VA_Get_Size(searchers);
-    uint32_t i;
     int32_t *starts_array = (int32_t*)MALLOCATE(num_searchers * sizeof(int32_t));
     int32_t  doc_max      = 0;
 
@@ -44,7 +43,7 @@ PolySearcher_init(PolySearcher *self, Sc
     self->searchers = (VArray*)INCREF(searchers);
     self->starts = NULL; // Safe cleanup.
 
-    for (i = 0; i < num_searchers; i++) {
+    for (uint32_t i = 0; i < num_searchers; i++) {
         Searcher *searcher
             = (Searcher*)CERTIFY(VA_Fetch(searchers, i), SEARCHER);
         Schema *candidate    = Searcher_Get_Schema(searcher);
@@ -103,9 +102,8 @@ PolySearcher_doc_max(PolySearcher *self)
 
 uint32_t
 PolySearcher_doc_freq(PolySearcher *self, const CharBuf *field, Obj *term) {
-    uint32_t i, max;
     uint32_t doc_freq = 0;
-    for (i = 0, max = VA_Get_Size(self->searchers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(self->searchers); i < max; i++) {
         Searcher *searcher = (Searcher*)VA_Fetch(self->searchers, i);
         doc_freq += Searcher_Doc_Freq(searcher, field, term);
     }
@@ -114,8 +112,7 @@ PolySearcher_doc_freq(PolySearcher *self
 
 static void
 S_modify_doc_ids(VArray *match_docs, int32_t base) {
-    uint32_t i, max;
-    for (i = 0, max = VA_Get_Size(match_docs); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(match_docs); i < max; i++) {
         MatchDoc *match_doc = (MatchDoc*)VA_Fetch(match_docs, i);
         int32_t  new_doc_id = MatchDoc_Get_Doc_ID(match_doc) + base;
         MatchDoc_Set_Doc_ID(match_doc, new_doc_id);
@@ -137,20 +134,18 @@ PolySearcher_top_docs(PolySearcher *self
                             : Query_Make_Compiler(query, (Searcher*)self,
                                                   Query_Get_Boost(query),
                                                   false);
-    uint32_t i, max;
 
-    for (i = 0, max = VA_Get_Size(searchers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(searchers); i < max; i++) {
         Searcher   *searcher   = (Searcher*)VA_Fetch(searchers, i);
         int32_t     base       = I32Arr_Get(starts, i);
         TopDocs    *top_docs   = Searcher_Top_Docs(searcher, (Query*)compiler,
                                                    num_wanted, sort_spec);
         VArray     *sub_match_docs = TopDocs_Get_Match_Docs(top_docs);
-        uint32_t j, jmax;
 
         total_hits += TopDocs_Get_Total_Hits(top_docs);
 
         S_modify_doc_ids(sub_match_docs, base);
-        for (j = 0, jmax = VA_Get_Size(sub_match_docs); j < jmax; j++) {
+        for (uint32_t j = 0, jmax = VA_Get_Size(sub_match_docs); j < jmax; j++) {
             MatchDoc *match_doc = (MatchDoc*)VA_Fetch(sub_match_docs, j);
             if (!HitQ_Insert(hit_q, INCREF(match_doc))) { break; }
         }
@@ -171,11 +166,10 @@ PolySearcher_top_docs(PolySearcher *self
 void
 PolySearcher_collect(PolySearcher *self, Query *query,
                      Collector *collector) {
-    uint32_t i, max;
     VArray *const searchers = self->searchers;
     I32Array *starts = self->starts;
 
-    for (i = 0, max = VA_Get_Size(searchers); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(searchers); i < max; i++) {
         int32_t start = I32Arr_Get(starts, i);
         Searcher *searcher = (Searcher*)VA_Fetch(searchers, i);
         OffsetCollector *offset_coll = OffsetColl_new(collector, start);

Modified: incubator/lucy/trunk/core/Lucy/Search/QueryParser.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/QueryParser.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/QueryParser.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/QueryParser.c Sat Dec  3 07:34:56 2011
@@ -118,8 +118,6 @@ QParser_new(Schema *schema, Analyzer *an
 QueryParser*
 QParser_init(QueryParser *self, Schema *schema, Analyzer *analyzer,
              const CharBuf *default_boolop, VArray *fields) {
-    uint32_t i;
-
     // Init.
     self->heed_colons = false;
     self->label_inc   = 0;
@@ -164,7 +162,7 @@ QParser_init(QueryParser *self, Schema *
     self->bool_group_label = CB_new_from_trusted_utf8("_bool_group", 11);
     CB_Grow(self->phrase_label, PHRASE_LABEL_LEN + 5);
     CB_Grow(self->bool_group_label, BOOL_GROUP_LABEL_LEN + 5);
-    for (i = 0; i < RAND_STRING_LEN; i++) {
+    for (uint32_t i = 0; i < RAND_STRING_LEN; i++) {
         char rand_char = (rand() % 26) + 'A';
         CB_Cat_Trusted_Str(self->phrase_label, &rand_char, 1);
         CB_Cat_Trusted_Str(self->bool_group_label, &rand_char, 1);
@@ -336,17 +334,15 @@ S_do_tree(QueryParser *self, CharBuf *qu
                               ? MUST
                               : SHOULD;
     VArray   *elems         = S_parse_flat_string(self, query_string);
-    uint32_t  i, max;
 
     // Determine whether this subclause is bracketed by parens.
     ParserToken *maybe_open_paren = (ParserToken*)VA_Fetch(elems, 0);
     if (maybe_open_paren != NULL
         && maybe_open_paren->type == TOKEN_OPEN_PAREN
        ) {
-        uint32_t num_elems;
         apply_parens = true;
         VA_Excise(elems, 0, 1);
-        num_elems = VA_Get_Size(elems);
+        uint32_t num_elems = VA_Get_Size(elems);
         if (num_elems) {
             ParserToken *maybe_close_paren
                 = (ParserToken*)VA_Fetch(elems, num_elems - 1);
@@ -357,7 +353,7 @@ S_do_tree(QueryParser *self, CharBuf *qu
     }
 
     // Generate all queries.  Apply any fields.
-    for (i = VA_Get_Size(elems); i--;) {
+    for (uint32_t i = VA_Get_Size(elems); i--;) {
         CharBuf *field = default_field;
         ParserToken *token = (ParserToken*)VA_Fetch(elems, i);
 
@@ -408,11 +404,10 @@ S_do_tree(QueryParser *self, CharBuf *qu
     S_splice_out_token_type(elems, TOKEN_FIELD | TOKEN_QUERY);
 
     // Apply +, -, NOT.
-    for (i = VA_Get_Size(elems); i--;) {
+    for (uint32_t i = VA_Get_Size(elems); i--;) {
         ParserClause *clause = (ParserClause*)VA_Fetch(elems, i);
         if (Obj_Is_A((Obj*)clause, PARSERCLAUSE)) {
-            uint32_t j;
-            for (j = i; j--;) {
+            for (uint32_t j = i; j--;) {
                 ParserToken *token = (ParserToken*)VA_Fetch(elems, j);
                 if (Obj_Is_A((Obj*)token, PARSERTOKEN)) {
                     if (token->type == TOKEN_MINUS
@@ -437,7 +432,7 @@ S_do_tree(QueryParser *self, CharBuf *qu
     S_splice_out_token_type(elems, TOKEN_PLUS | TOKEN_MINUS | TOKEN_NOT);
 
     // Wrap negated queries with NOTQuery objects.
-    for (i = 0, max = VA_Get_Size(elems); i < max; i++) {
+    for (uint32_t i = 0, max = VA_Get_Size(elems); i < max; i++) {
         ParserClause *clause = (ParserClause*)VA_Fetch(elems, i);
         if (Obj_Is_A((Obj*)clause, PARSERCLAUSE) && clause->occur == MUST_NOT) {
             Query *not_query = QParser_Make_NOT_Query(self, clause->query);
@@ -448,10 +443,9 @@ S_do_tree(QueryParser *self, CharBuf *qu
 
     // Silently discard non-sensical combos of AND and OR, e.g.
     // 'OR a AND AND OR b AND'.
-    for (i = 0; i < VA_Get_Size(elems); i++) {
+    for (uint32_t i = 0; i < VA_Get_Size(elems); i++) {
         ParserToken *token = (ParserToken*)VA_Fetch(elems, i);
         if (Obj_Is_A((Obj*)token, PARSERTOKEN)) {
-            uint32_t j, jmax;
             uint32_t num_to_zap = 0;
             ParserClause *preceding = (ParserClause*)VA_Fetch(elems, i - 1);
             ParserClause *following = (ParserClause*)VA_Fetch(elems, i + 1);
@@ -461,7 +455,7 @@ S_do_tree(QueryParser *self, CharBuf *qu
             if (!following || !Obj_Is_A((Obj*)following, PARSERCLAUSE)) {
                 num_to_zap = 1;
             }
-            for (j = i + 1, jmax = VA_Get_Size(elems); j < jmax; j++) {
+            for (uint32_t j = i + 1, jmax = VA_Get_Size(elems); j < jmax; j++) {
                 ParserClause *clause = (ParserClause*)VA_Fetch(elems, j);
                 if (Obj_Is_A((Obj*)clause, PARSERCLAUSE)) { break; }
                 else { num_to_zap++; }
@@ -471,19 +465,18 @@ S_do_tree(QueryParser *self, CharBuf *qu
     }
 
     // Apply AND.
-    for (i = 0; i + 2 < VA_Get_Size(elems); i++) {
+    for (uint32_t i = 0; i + 2 < VA_Get_Size(elems); i++) {
         ParserToken *token = (ParserToken*)VA_Fetch(elems, i + 1);
         if (Obj_Is_A((Obj*)token, PARSERTOKEN) && token->type == TOKEN_AND) {
             ParserClause *preceding  = (ParserClause*)VA_Fetch(elems, i);
             VArray       *children   = VA_new(2);
             uint32_t      num_to_zap = 0;
-            uint32_t      j, jmax;
 
             // Add first clause.
             VA_Push(children, INCREF(preceding->query));
 
             // Add following clauses.
-            for (j = i + 1, jmax = VA_Get_Size(elems);
+            for (uint32_t j = i + 1, jmax = VA_Get_Size(elems);
                  j < jmax;
                  j += 2, num_to_zap += 2
                 ) {
@@ -513,19 +506,18 @@ S_do_tree(QueryParser *self, CharBuf *qu
     }
 
     // Apply OR.
-    for (i = 0; i + 2 < VA_Get_Size(elems); i++) {
+    for (uint32_t i = 0; i + 2 < VA_Get_Size(elems); i++) {
         ParserToken *token = (ParserToken*)VA_Fetch(elems, i + 1);
         if (Obj_Is_A((Obj*)token, PARSERTOKEN) && token->type == TOKEN_OR) {
             ParserClause *preceding  = (ParserClause*)VA_Fetch(elems, i);
             VArray       *children   = VA_new(2);
             uint32_t      num_to_zap = 0;
-            uint32_t      j, jmax;
 
             // Add first clause.
             VA_Push(children, INCREF(preceding->query));
 
             // Add following clauses.
-            for (j = i + 1, jmax = VA_Get_Size(elems);
+            for (uint32_t j = i + 1, jmax = VA_Get_Size(elems);
                  j < jmax;
                  j += 2, num_to_zap += 2
                 ) {
@@ -577,10 +569,9 @@ S_do_tree(QueryParser *self, CharBuf *qu
         VArray   *negated   = VA_new(num_elems);
         Query    *req_query = NULL;
         Query    *opt_query = NULL;
-        uint32_t  i, num_required, num_negated, num_optional;
 
         // Demux elems into bins.
-        for (i = 0; i < num_elems; i++) {
+        for (uint32_t i = 0; i < num_elems; i++) {
             ParserClause *clause = (ParserClause*)VA_Fetch(elems, i);
             if (clause->occur == MUST) {
                 VA_Push(required, INCREF(clause->query));
@@ -592,9 +583,9 @@ S_do_tree(QueryParser *self, CharBuf *qu
                 VA_Push(negated, INCREF(clause->query));
             }
         }
-        num_required = VA_Get_Size(required);
-        num_negated  = VA_Get_Size(negated);
-        num_optional = VA_Get_Size(optional);
+        uint32_t num_required = VA_Get_Size(required);
+        uint32_t num_negated  = VA_Get_Size(negated);
+        uint32_t num_optional = VA_Get_Size(optional);
 
         // Bind all mandatory matchers together in one Query.
         if (num_required || num_negated) {

Modified: incubator/lucy/trunk/core/Lucy/Search/SortSpec.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/SortSpec.c?rev=1209842&r1=1209841&r2=1209842&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/SortSpec.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/SortSpec.c Sat Dec  3 07:34:56 2011
@@ -35,9 +35,8 @@ SortSpec_new(VArray *rules) {
 
 SortSpec*
 SortSpec_init(SortSpec *self, VArray *rules) {
-    int32_t i, max;
     self->rules = VA_Shallow_Copy(rules);
-    for (i = 0, max = VA_Get_Size(rules); i < max; i++) {
+    for (int32_t i = 0, max = VA_Get_Size(rules); i < max; i++) {
         SortRule *rule = (SortRule*)VA_Fetch(rules, i);
         CERTIFY(rule, SORTRULE);
     }
@@ -54,13 +53,12 @@ SortSpec*
 SortSpec_deserialize(SortSpec *self, InStream *instream) {
     uint32_t num_rules = InStream_Read_C32(instream);
     VArray *rules = VA_new(num_rules);
-    uint32_t i;
 
     // Create base object.
     self = self ? self : (SortSpec*)VTable_Make_Obj(SORTSPEC);
 
     // Add rules.
-    for (i = 0; i < num_rules; i++) {
+    for (uint32_t i = 0; i < num_rules; i++) {
         VA_Push(rules, (Obj*)SortRule_deserialize(NULL, instream));
     }
     SortSpec_init(self, rules);
@@ -77,9 +75,8 @@ SortSpec_get_rules(SortSpec *self) {
 void
 SortSpec_serialize(SortSpec *self, OutStream *target) {
     uint32_t num_rules = VA_Get_Size(self->rules);
-    uint32_t i;
     OutStream_Write_C32(target, num_rules);
-    for (i = 0; i < num_rules; i++) {
+    for (uint32_t i = 0; i < num_rules; i++) {
         SortRule *rule = (SortRule*)VA_Fetch(self->rules, i);
         SortRule_Serialize(rule, target);
     }