[dovecot-cvs] dovecot/src/plugins/fts-squat squat-test.c, 1.3, 1.4 squat-trie.c, 1.11, 1.12

tss at dovecot.org tss at dovecot.org
Thu Dec 21 13:56:52 UTC 2006


Update of /var/lib/cvs/dovecot/src/plugins/fts-squat
In directory talvi:/tmp/cvs-serv25097

Modified Files:
	squat-test.c squat-trie.c 
Log Message:
Cleanups and fixes



Index: squat-test.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts-squat/squat-test.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- squat-test.c	6 Dec 2006 23:43:15 -0000	1.3
+++ squat-test.c	21 Dec 2006 13:56:50 -0000	1.4
@@ -72,7 +72,7 @@
 		}
 
 		if (squat_trie_build_more(build_ctx, seq,
-					  line, strlen(line)) < 0)
+					  (const void *)line, strlen(line)) < 0)
 			break;
 	}
 	squat_trie_build_deinit(build_ctx);

Index: squat-trie.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts-squat/squat-trie.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- squat-trie.c	13 Dec 2006 13:49:46 -0000	1.11
+++ squat-trie.c	21 Dec 2006 13:56:50 -0000	1.12
@@ -932,11 +932,10 @@
 			chars[i] = i;
 
 		if (chars16_count > 0) {
-			uint16_t *chrp;
+			uint16_t *chars16 = NODE_CHARS16(node, 0);
 
 			node->chars_16bit_count = chars16_count;
-			chrp = (uint16_t *)&chars[i];
-			*chrp = chr;
+			chars16[0] = chr;
 		}
 	} else if (chr < MAX_8BIT_CHAR_COUNT) {
 		uint8_t *chrp;
@@ -983,7 +982,7 @@
 
 	if (chr < MAX_8BIT_CHAR_COUNT) {
 		new_idx_offset = sizeof(*node) +
-			ALIGN(node->chars_8bit_count + sizeof(uint8_t));
+			ALIGN(node->chars_8bit_count + 1);
 		new_size = new_idx_offset + old_size_16bit +
 			(node->chars_8bit_count + 1) * idx_size;
 	} else {
@@ -1005,12 +1004,14 @@
 	}
 	hole2_pos = old_idx_offset + idx_size * char_idx;
 
+	/* 0..character position */
 	memcpy(new_node, node, hole1_pos);
 	if (chr < MAX_8BIT_CHAR_COUNT) {
 		uint8_t *chrp = PTR_OFFSET(new_node, hole1_pos);
 		*chrp = chr;
 		new_node->chars_8bit_count++;
 
+		/* rest of the characters */
 		memcpy(PTR_OFFSET(new_node, hole1_pos + sizeof(uint8_t)),
 		       PTR_OFFSET(node, hole1_pos), old_idx_offset - hole1_pos);
 	} else {
@@ -1018,18 +1019,23 @@
 		*chrp = chr;
 		new_node->chars_16bit_count++;
 
+		/* rest of the characters */
 		memcpy(PTR_OFFSET(new_node, hole1_pos + sizeof(uint16_t)),
 		       PTR_OFFSET(node, hole1_pos), old_idx_offset - hole1_pos);
 	}
 
+	/* indexes from 0 to character position */
 	memcpy(PTR_OFFSET(new_node, new_idx_offset),
 	       PTR_OFFSET(node, old_idx_offset),
 	       hole2_pos - old_idx_offset);
 
-	skip = new_idx_offset - old_idx_offset;
-	memset(PTR_OFFSET(new_node, hole2_pos + skip), 0, idx_size);
-	skip += sizeof(uint32_t);
-	memcpy(PTR_OFFSET(new_node, hole2_pos + skip),
+	/* zero the inserted character index */
+	skip = char_idx * idx_size;
+	memset(PTR_OFFSET(new_node, new_idx_offset + skip), 0, idx_size);
+
+	/* rest of the indexes */
+	skip += idx_size;
+	memcpy(PTR_OFFSET(new_node, new_idx_offset + skip),
 	       PTR_OFFSET(node, hole2_pos),
 	       old_size - hole2_pos);
 



More information about the dovecot-cvs mailing list