projects
/
idzebra-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
af102b1
)
Proper sort entry copying
author
Adam Dickmeiss
<adam@indexdata.dk>
Wed, 10 Sep 2008 12:50:00 +0000
(14:50 +0200)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Wed, 10 Sep 2008 12:50:00 +0000
(14:50 +0200)
index/zsets.c
patch
|
blob
|
history
diff --git
a/index/zsets.c
b/index/zsets.c
index
5187cf4
..
225876c
100644
(file)
--- a/
index/zsets.c
+++ b/
index/zsets.c
@@
-581,18
+581,31
@@
void resultSetInsertSort(ZebraHandle zh, ZebraSet sset,
int off = 0;
while (off != wrbuf_len(w))
{
int off = 0;
while (off != wrbuf_len(w))
{
+ size_t l = strlen(wrbuf_buf(w)+off);
assert(off < wrbuf_len(w));
assert(off < wrbuf_len(w));
+
+ if (l >= SORT_IDX_ENTRYSIZE)
+ l = SORT_IDX_ENTRYSIZE-1;
if (off == 0)
if (off == 0)
- strcpy(this_entry_buf, wrbuf_buf(w));
+ {
+ memcpy(this_entry_buf, wrbuf_buf(w)+off, l);
+ this_entry_buf[l] = '\0';
+ }
else if (criteria[i].relation == 'A')
{
if (strcmp(wrbuf_buf(w)+off, this_entry_buf) < 0)
else if (criteria[i].relation == 'A')
{
if (strcmp(wrbuf_buf(w)+off, this_entry_buf) < 0)
- strcpy(this_entry_buf, wrbuf_buf(w)+off);
+ {
+ memcpy(this_entry_buf, wrbuf_buf(w)+off, l);
+ this_entry_buf[l] = '\0';
+ }
}
else if (criteria[i].relation == 'D')
{
if (strcmp(wrbuf_buf(w)+off, this_entry_buf) > 0)
}
else if (criteria[i].relation == 'D')
{
if (strcmp(wrbuf_buf(w)+off, this_entry_buf) > 0)
- strcpy(this_entry_buf, wrbuf_buf(w)+off);
+ {
+ memcpy(this_entry_buf, wrbuf_buf(w)+off, l);
+ this_entry_buf[l] = '\0';
+ }
}
off += 1 + strlen(wrbuf_buf(w)+off);
}
}
off += 1 + strlen(wrbuf_buf(w)+off);
}